| ceed.c (28d161ee4cd635f16369e03ebed5b346eb0f02f0) | ceed.c (2c8abac2ee194ac906d4e02f2b6d5f0ed0464ba2) |
|---|---|
| 1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3// reserved. See files LICENSE and NOTICE for details. 4// 5// This file is part of CEED, a collection of benchmarks, miniapps, software 6// libraries and APIs for efficient high-order finite element and spectral 7// element discretizations for exascale applications. For more information and 8// source code availability see http://github.com/ceed. --- 326 unchanged lines hidden (view full) --- 335 (*ceed)->Error = CeedErrorExit; 336 else 337 (*ceed)->Error = CeedErrorAbort; 338 (*ceed)->refcount = 1; 339 (*ceed)->data = NULL; 340 341 // Set lookup table 342 foffset foffsets[CEED_NUM_BACKEND_FUNCTIONS] = { | 1// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3// reserved. See files LICENSE and NOTICE for details. 4// 5// This file is part of CEED, a collection of benchmarks, miniapps, software 6// libraries and APIs for efficient high-order finite element and spectral 7// element discretizations for exascale applications. For more information and 8// source code availability see http://github.com/ceed. --- 326 unchanged lines hidden (view full) --- 335 (*ceed)->Error = CeedErrorExit; 336 else 337 (*ceed)->Error = CeedErrorAbort; 338 (*ceed)->refcount = 1; 339 (*ceed)->data = NULL; 340 341 // Set lookup table 342 foffset foffsets[CEED_NUM_BACKEND_FUNCTIONS] = { |
| 343 {"Error", ceedoffsetof(Ceed, Error)}, 344 {"CeedDestroy", ceedoffsetof(Ceed, Destroy)}, 345 {"VecCreate", ceedoffsetof(Ceed, VecCreate)}, 346 {"ElemRestrictionCreate", ceedoffsetof(Ceed, ElemRestrictionCreate)}, 347 {"ElemRestrictionCreateBlocked", 348 ceedoffsetof(Ceed, ElemRestrictionCreateBlocked)}, 349 {"BasisCreateTensorH1", ceedoffsetof(Ceed, BasisCreateTensorH1)}, 350 {"BasisCreateH1", ceedoffsetof(Ceed, BasisCreateH1)}, 351 {"QFunctionCreate", ceedoffsetof(Ceed, QFunctionCreate)}, 352 {"OperatorCreate", ceedoffsetof(Ceed, OperatorCreate)}, 353 {"SetArray", ceedoffsetof(CeedVector, SetArray)}, 354 {"SetValue", ceedoffsetof(CeedVector, SetValue)}, 355 {"GetArray", ceedoffsetof(CeedVector, GetArray)}, 356 {"GetArrayRead", ceedoffsetof(CeedVector, GetArrayRead)}, 357 {"RestoreArray", ceedoffsetof(CeedVector, RestoreArray)}, 358 {"RestoreArrayRead", ceedoffsetof(CeedVector, RestoreArrayRead)}, 359 {"VectorDestroy", ceedoffsetof(CeedVector, Destroy)}, 360 {"ElemRestrictionApply", ceedoffsetof(CeedElemRestriction, Apply)}, 361 {"ElemRestrictionDestroy", ceedoffsetof(CeedElemRestriction, Destroy)}, 362 {"BasisApply", ceedoffsetof(CeedBasis, Apply)}, 363 {"BasisDestroy", ceedoffsetof(CeedBasis, Destroy)}, 364 {"QFunctionApply", ceedoffsetof(CeedQFunction, Apply)}, 365 {"QFunctionDestroy", ceedoffsetof(CeedQFunction, Destroy)}, 366 {"OperatorApply", ceedoffsetof(CeedOperator, Apply)}, 367 {"ApplyJacobian", ceedoffsetof(CeedOperator, ApplyJacobian)}, 368 {"OperatorDestroy", ceedoffsetof(CeedOperator, Destroy)} }; | 343 {"CeedError", ceedoffsetof(Ceed, Error)}, 344 {"CeedDestroy", ceedoffsetof(Ceed, Destroy)}, 345 {"CeedVecCreate", ceedoffsetof(Ceed, VecCreate)}, 346 {"CeedElemRestrictionCreate", ceedoffsetof(Ceed, ElemRestrictionCreate)}, 347 {"CeedElemRestrictionCreateBlocked", 348 ceedoffsetof(Ceed, ElemRestrictionCreateBlocked)}, 349 {"CeedBasisCreateTensorH1", ceedoffsetof(Ceed, BasisCreateTensorH1)}, 350 {"CeedBasisCreateH1", ceedoffsetof(Ceed, BasisCreateH1)}, 351 {"CeedQFunctionCreate", ceedoffsetof(Ceed, QFunctionCreate)}, 352 {"CeedOperatorCreate", ceedoffsetof(Ceed, OperatorCreate)}, 353 {"VectorSetArray", ceedoffsetof(CeedVector, SetArray)}, 354 {"VectorSetValue", ceedoffsetof(CeedVector, SetValue)}, 355 {"VectorGetArray", ceedoffsetof(CeedVector, GetArray)}, 356 {"VectorGetArrayRead", ceedoffsetof(CeedVector, GetArrayRead)}, 357 {"VectorRestoreArray", ceedoffsetof(CeedVector, RestoreArray)}, 358 {"VectorRestoreArrayRead", ceedoffsetof(CeedVector, RestoreArrayRead)}, 359 {"VectorDestroy", ceedoffsetof(CeedVector, Destroy)}, 360 {"ElemRestrictionApply", ceedoffsetof(CeedElemRestriction, Apply)}, 361 {"ElemRestrictionDestroy", ceedoffsetof(CeedElemRestriction, Destroy)}, 362 {"BasisApply", ceedoffsetof(CeedBasis, Apply)}, 363 {"BasisDestroy", ceedoffsetof(CeedBasis, Destroy)}, 364 {"QFunctionApply", ceedoffsetof(CeedQFunction, Apply)}, 365 {"QFunctionDestroy", ceedoffsetof(CeedQFunction, Destroy)}, 366 {"OperatorApply", ceedoffsetof(CeedOperator, Apply)}, 367 {"OperatorApplyJacobian", ceedoffsetof(CeedOperator, ApplyJacobian)}, 368 {"OperatorDestroy", ceedoffsetof(CeedOperator, Destroy)} }; |
| 369 370 memcpy((*ceed)->foffsets, foffsets, 371 CEED_NUM_BACKEND_FUNCTIONS*sizeof(foffset)); 372 373 // Backend specific setup 374 ierr = backends[matchidx].init(resource, *ceed); CeedChk(ierr); 375 376 return 0; --- 44 unchanged lines hidden (view full) --- 421**/ 422int CeedSetBackendFunction(Ceed ceed, 423 const char *type, void *object, 424 const char *fname, int (*f)()) { 425 char lookupname[100]; 426 strcpy(lookupname, ""); 427 428 // Build lookup name | 369 370 memcpy((*ceed)->foffsets, foffsets, 371 CEED_NUM_BACKEND_FUNCTIONS*sizeof(foffset)); 372 373 // Backend specific setup 374 ierr = backends[matchidx].init(resource, *ceed); CeedChk(ierr); 375 376 return 0; --- 44 unchanged lines hidden (view full) --- 421**/ 422int CeedSetBackendFunction(Ceed ceed, 423 const char *type, void *object, 424 const char *fname, int (*f)()) { 425 char lookupname[100]; 426 strcpy(lookupname, ""); 427 428 // Build lookup name |
| 429 if (!strcmp(fname, "Apply") || !strcmp(fname, "Destroy")) { 430 strcat(strcat(lookupname, type), fname); 431 } else { 432 strcat(lookupname, fname); 433 } | 429 strcat(strcat(lookupname, type), fname); |
| 434 435 // Find and use offset 436 for (CeedInt i = 0; i < CEED_NUM_BACKEND_FUNCTIONS; i++) { 437 if (!strcmp(ceed->foffsets[i].fname, lookupname)) { 438 size_t offset = ceed->foffsets[i].offset; 439 size_t *fpointer; 440 fpointer = (size_t *)(object + offset); 441 *fpointer = (size_t) f; 442 return 0; 443 } 444 } 445 | 430 431 // Find and use offset 432 for (CeedInt i = 0; i < CEED_NUM_BACKEND_FUNCTIONS; i++) { 433 if (!strcmp(ceed->foffsets[i].fname, lookupname)) { 434 size_t offset = ceed->foffsets[i].offset; 435 size_t *fpointer; 436 fpointer = (size_t *)(object + offset); 437 *fpointer = (size_t) f; 438 return 0; 439 } 440 } 441 |
| 446 return CeedError(ceed, 1, "Requested function '%s' was not found", fname); | 442 return CeedError(ceed, 1, "Requested function '%s' was not found for CEED object '%s'", fname, type); |
| 447} 448 449/** 450 @brief Retrieve backend data for a CEED 451 452 @param ceed Ceed to retrieve data of 453 @param[out] data Address to save data to 454 --- 48 unchanged lines hidden --- | 443} 444 445/** 446 @brief Retrieve backend data for a CEED 447 448 @param ceed Ceed to retrieve data of 449 @param[out] data Address to save data to 450 --- 48 unchanged lines hidden --- |