| ceed-qfunction.c (27fd97390cbb1fb324d3eaa88f8b6806cf86f420) | ceed-qfunction.c (95bb1877d9b2fcda84fdb8cecd2747929a23a65b) |
|---|---|
| 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. --- 30 unchanged lines hidden (view full) --- 39/// 40/// @addtogroup CeedQFunction 41/// @{ 42 43/** 44 @brief Create a CeedQFunction for evaluating interior (volumetric) terms. 45 46 @param ceed A Ceed object where the CeedQFunction will be created | 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. --- 30 unchanged lines hidden (view full) --- 39/// 40/// @addtogroup CeedQFunction 41/// @{ 42 43/** 44 @brief Create a CeedQFunction for evaluating interior (volumetric) terms. 45 46 @param ceed A Ceed object where the CeedQFunction will be created |
| 47 @param vlength Vector length. Caller must ensure that number of quadrature | 47 @param vlength Vector length. Caller must ensure that number of quadrature |
| 48 points is a multiple of vlength. 49 @param f Function pointer to evaluate action at quadrature points. 50 See \ref CeedQFunctionUser. 51 @param source Absolute path to source of QFunction, 52 "\abs_path\file.h:function_name" 53 @param[out] qf Address of the variable where the newly created 54 CeedQFunction will be stored 55 --- 4 unchanged lines hidden (view full) --- 60 61 @ref Basic 62**/ 63int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vlength, CeedQFunctionUser f, 64 const char *source, CeedQFunction *qf) { 65 int ierr; 66 char *source_copy; 67 | 48 points is a multiple of vlength. 49 @param f Function pointer to evaluate action at quadrature points. 50 See \ref CeedQFunctionUser. 51 @param source Absolute path to source of QFunction, 52 "\abs_path\file.h:function_name" 53 @param[out] qf Address of the variable where the newly created 54 CeedQFunction will be stored 55 --- 4 unchanged lines hidden (view full) --- 60 61 @ref Basic 62**/ 63int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vlength, CeedQFunctionUser f, 64 const char *source, CeedQFunction *qf) { 65 int ierr; 66 char *source_copy; 67 |
| 68 if (!f) return CeedError(ceed, 1, "Must pass valid function f"); | |
| 69 if (!ceed->QFunctionCreate) { 70 Ceed delegate; 71 ierr = CeedGetObjectDelegate(ceed, &delegate, "QFunction"); CeedChk(ierr); 72 73 if (!delegate) 74 // LCOV_EXCL_START 75 return CeedError(ceed, 1, "Backend does not support QFunctionCreate"); 76 // LCOV_EXCL_STOP --- 5 unchanged lines hidden (view full) --- 82 83 ierr = CeedCalloc(1, qf); CeedChk(ierr); 84 (*qf)->ceed = ceed; 85 ceed->refcount++; 86 (*qf)->refcount = 1; 87 (*qf)->vlength = vlength; 88 (*qf)->identity = 0; 89 (*qf)->function = f; | 68 if (!ceed->QFunctionCreate) { 69 Ceed delegate; 70 ierr = CeedGetObjectDelegate(ceed, &delegate, "QFunction"); CeedChk(ierr); 71 72 if (!delegate) 73 // LCOV_EXCL_START 74 return CeedError(ceed, 1, "Backend does not support QFunctionCreate"); 75 // LCOV_EXCL_STOP --- 5 unchanged lines hidden (view full) --- 81 82 ierr = CeedCalloc(1, qf); CeedChk(ierr); 83 (*qf)->ceed = ceed; 84 ceed->refcount++; 85 (*qf)->refcount = 1; 86 (*qf)->vlength = vlength; 87 (*qf)->identity = 0; 88 (*qf)->function = f; |
| 90 (*qf)->sourcepath = NULL; 91 if (source) { 92 size_t slen = strlen(source) + 1; 93 ierr = CeedMalloc(slen, &source_copy); CeedChk(ierr); 94 memcpy(source_copy, source, slen); 95 (*qf)->sourcepath = source_copy; 96 } | 89 size_t slen = strlen(source) + 1; 90 ierr = CeedMalloc(slen, &source_copy); CeedChk(ierr); 91 memcpy(source_copy, source, slen); 92 (*qf)->sourcepath = source_copy; |
| 97 ierr = CeedCalloc(16, &(*qf)->inputfields); CeedChk(ierr); 98 ierr = CeedCalloc(16, &(*qf)->outputfields); CeedChk(ierr); 99 ierr = ceed->QFunctionCreate(*qf); CeedChk(ierr); 100 return 0; 101} 102 103/** 104 @brief Register a gallery QFunction 105 | 93 ierr = CeedCalloc(16, &(*qf)->inputfields); CeedChk(ierr); 94 ierr = CeedCalloc(16, &(*qf)->outputfields); CeedChk(ierr); 95 ierr = ceed->QFunctionCreate(*qf); CeedChk(ierr); 96 return 0; 97} 98 99/** 100 @brief Register a gallery QFunction 101 |
| 106 @param name Name for this backend to respond to 107 @param source Absolute path to source of QFunction, 108 "\path\CEED_DIR\gallery\folder\file.h:function_name" 109 @param vlength Vector length. Caller must ensure that number of quadrature 110 points is a multiple of vlength. 111 @param f Function pointer to evaluate action at quadrature points. 112 See \ref CeedQFunctionUser. 113 @param init Initialization function called by CeedQFunctionInit() when the 114 QFunction is selected. | 102 @param name Name for this backend to respond to 103 @param source Absolute path to source of QFunction, 104 "\path\CEED_DIR\gallery\folder\file.h:function_name" 105 @param vlength Vector length. Caller must ensure that number of quadrature 106 points is a multiple of vlength. 107 @param f Function pointer to evaluate action at quadrature points. 108 See \ref CeedQFunctionUser. 109 @param init Initialization function called by CeedQFunctionInit() when the 110 QFunction is selected. |
| 115 116 @return An error code: 0 - success, otherwise - failure 117 118 @ref Advanced 119**/ 120int CeedQFunctionRegister(const char *name, const char *source, 121 CeedInt vlength, CeedQFunctionUser f, 122 int (*init)(Ceed, const char *, CeedQFunction)) { --- 69 unchanged lines hidden (view full) --- 192 @brief Create an identity CeedQFunction. Inputs are written into outputs in 193 the order given. This is useful for CeedOperators that can be 194 represented with only the action of a CeedRestriction and CeedBasis, 195 such as restriction and prolongation operators for p-multigrid. 196 Backends may optimize CeedOperators with this CeedQFunction to avoid 197 the copy of input data to output fields by using the same memory 198 location for both. 199 | 111 112 @return An error code: 0 - success, otherwise - failure 113 114 @ref Advanced 115**/ 116int CeedQFunctionRegister(const char *name, const char *source, 117 CeedInt vlength, CeedQFunctionUser f, 118 int (*init)(Ceed, const char *, CeedQFunction)) { --- 69 unchanged lines hidden (view full) --- 188 @brief Create an identity CeedQFunction. Inputs are written into outputs in 189 the order given. This is useful for CeedOperators that can be 190 represented with only the action of a CeedRestriction and CeedBasis, 191 such as restriction and prolongation operators for p-multigrid. 192 Backends may optimize CeedOperators with this CeedQFunction to avoid 193 the copy of input data to output fields by using the same memory 194 location for both. 195 |
| 200 @param ceed A Ceed object where the CeedQFunction will be created 201 @param[in] size Size of the qfunction fields 202 @param[in] inmode CeedEvalMode for input to CeedQFunction 203 @param[in] outmode CeedEvalMode for output to CeedQFunction 204 @param[out] qf Address of the variable where the newly created 205 CeedQFunction will be stored | 196 @param ceed A Ceed object where the CeedQFunction will be created 197 @param[in] size Size of the qfunction fields 198 @param[in] inmode CeedEvalMode for input to CeedQFunction 199 @param[in] outmode CeedEvalMode for output to CeedQFunction 200 @param[out] qf Address of the variable where the newly created 201 CeedQFunction will be stored |
| 206 207 @return An error code: 0 - success, otherwise - failure 208 209 @ref Basic 210**/ 211int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode inmode, 212 CeedEvalMode outmode, CeedQFunction *qf) { 213 int ierr; --- 21 unchanged lines hidden (view full) --- 235 return 0; 236} 237 238/** 239 @brief Set a CeedQFunction field, used by CeedQFunctionAddInput/Output 240 241 @param f CeedQFunctionField 242 @param fieldname Name of QFunction field | 202 203 @return An error code: 0 - success, otherwise - failure 204 205 @ref Basic 206**/ 207int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode inmode, 208 CeedEvalMode outmode, CeedQFunction *qf) { 209 int ierr; --- 21 unchanged lines hidden (view full) --- 231 return 0; 232} 233 234/** 235 @brief Set a CeedQFunction field, used by CeedQFunctionAddInput/Output 236 237 @param f CeedQFunctionField 238 @param fieldname Name of QFunction field |
| 243 @param size Size of QFunction field, ncomp * (dim for CEED_EVAL_GRAD or 244 1 for CEED_EVAL_NONE, CEED_EVAL_INTERP, and CEED_EVAL_WEIGHT) | 239 @param size Size of QFunction field, (ncomp * dim) for CEED_EVAL_GRAD or 240 (ncomp * 1) for CEED_EVAL_NONE, CEED_EVAL_INTERP, and CEED_EVAL_WEIGHT |
| 245 @param emode \ref CEED_EVAL_NONE to use values directly, 246 \ref CEED_EVAL_INTERP to use interpolated values, 247 \ref CEED_EVAL_GRAD to use gradients, 248 \ref CEED_EVAL_WEIGHT to use quadrature weights. 249 250 @return An error code: 0 - success, otherwise - failure 251 252 @ref Developer --- 13 unchanged lines hidden (view full) --- 266 return 0; 267} 268 269/** 270 @brief Add a CeedQFunction input 271 272 @param qf CeedQFunction 273 @param fieldname Name of QFunction field | 241 @param emode \ref CEED_EVAL_NONE to use values directly, 242 \ref CEED_EVAL_INTERP to use interpolated values, 243 \ref CEED_EVAL_GRAD to use gradients, 244 \ref CEED_EVAL_WEIGHT to use quadrature weights. 245 246 @return An error code: 0 - success, otherwise - failure 247 248 @ref Developer --- 13 unchanged lines hidden (view full) --- 262 return 0; 263} 264 265/** 266 @brief Add a CeedQFunction input 267 268 @param qf CeedQFunction 269 @param fieldname Name of QFunction field |
| 274 @param size Size of QFunction field, ncomp * (dim for CEED_EVAL_GRAD or 275 1 for CEED_EVAL_NONE and CEED_EVAL_INTERP) | 270 @param size Size of QFunction field, (ncomp * dim) for CEED_EVAL_GRAD or 271 (ncomp * 1) for CEED_EVAL_NONE and CEED_EVAL_INTERP |
| 276 @param emode \ref CEED_EVAL_NONE to use values directly, 277 \ref CEED_EVAL_INTERP to use interpolated values, 278 \ref CEED_EVAL_GRAD to use gradients. 279 280 @return An error code: 0 - success, otherwise - failure 281 282 @ref Basic 283**/ --- 6 unchanged lines hidden (view full) --- 290 return 0; 291} 292 293/** 294 @brief Add a CeedQFunction output 295 296 @param qf CeedQFunction 297 @param fieldname Name of QFunction field | 272 @param emode \ref CEED_EVAL_NONE to use values directly, 273 \ref CEED_EVAL_INTERP to use interpolated values, 274 \ref CEED_EVAL_GRAD to use gradients. 275 276 @return An error code: 0 - success, otherwise - failure 277 278 @ref Basic 279**/ --- 6 unchanged lines hidden (view full) --- 286 return 0; 287} 288 289/** 290 @brief Add a CeedQFunction output 291 292 @param qf CeedQFunction 293 @param fieldname Name of QFunction field |
| 298 @param size Size of QFunction field, ncomp * (dim for CEED_EVAL_GRAD or 299 1 for CEED_EVAL_NONE and CEED_EVAL_INTERP) | 294 @param size Size of QFunction field, (ncomp * dim) for CEED_EVAL_GRAD or 295 (ncomp * 1) for CEED_EVAL_NONE and CEED_EVAL_INTERP |
| 300 @param emode \ref CEED_EVAL_NONE to use values directly, 301 \ref CEED_EVAL_INTERP to use interpolated values, 302 \ref CEED_EVAL_GRAD to use gradients. 303 304 @return An error code: 0 - success, otherwise - failure 305 306 @ref Basic 307**/ --- 233 unchanged lines hidden (view full) --- 541 qf->ctx = ctx; 542 qf->ctxsize = ctxsize; 543 return 0; 544} 545 546/** 547 @brief View a field of a CeedQFunction 548 | 296 @param emode \ref CEED_EVAL_NONE to use values directly, 297 \ref CEED_EVAL_INTERP to use interpolated values, 298 \ref CEED_EVAL_GRAD to use gradients. 299 300 @return An error code: 0 - success, otherwise - failure 301 302 @ref Basic 303**/ --- 233 unchanged lines hidden (view full) --- 537 qf->ctx = ctx; 538 qf->ctxsize = ctxsize; 539 return 0; 540} 541 542/** 543 @brief View a field of a CeedQFunction 544 |
| 549 @param[in] field QFunction field to view 550 @param[in] fieldnumber Number of field being viewed 551 @param[in] stream Stream to view to, e.g., stdout | 545 @param[in] field QFunction field to view 546 @param[in] fieldnumber Number of field being viewed 547 @param[in] stream Stream to view to, e.g., stdout |
| 552 553 @return An error code: 0 - success, otherwise - failure 554 555 @ref Utility 556**/ 557static int CeedQFunctionFieldView(CeedQFunctionField field, CeedInt fieldnumber, 558 bool in, FILE *stream) { 559 const char *inout = in ? "Input" : "Output"; --- 5 unchanged lines hidden (view full) --- 565 CeedEvalModes[field->emode]); 566 567 return 0; 568} 569 570/** 571 @brief View a CeedQFunction 572 | 548 549 @return An error code: 0 - success, otherwise - failure 550 551 @ref Utility 552**/ 553static int CeedQFunctionFieldView(CeedQFunctionField field, CeedInt fieldnumber, 554 bool in, FILE *stream) { 555 const char *inout = in ? "Input" : "Output"; --- 5 unchanged lines hidden (view full) --- 561 CeedEvalModes[field->emode]); 562 563 return 0; 564} 565 566/** 567 @brief View a CeedQFunction 568 |
| 573 @param[in] qf CeedQFunction to view 574 @param[in] stream Stream to write; typically stdout/stderr or a file | 569 @param[in] qf CeedQFunction to view 570 @param[in] stream Stream to write; typically stdout/stderr or a file |
| 575 576 @return Error code: 0 - success, otherwise - failure 577 578 @ref Utility 579**/ 580int CeedQFunctionView(CeedQFunction qf, FILE *stream) { 581 int ierr; 582 --- 163 unchanged lines hidden --- | 571 572 @return Error code: 0 - success, otherwise - failure 573 574 @ref Utility 575**/ 576int CeedQFunctionView(CeedQFunction qf, FILE *stream) { 577 int ierr; 578 --- 163 unchanged lines hidden --- |