| ceed-qfunction.c (1176cc3a9721a4533d0e68f729d54c54717d4a1d) | ceed-qfunction.c (0219ea01e2c00bd70a330a05b50ef0218d6ddcb0) |
|---|---|
| 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. --- 65 unchanged lines hidden (view full) --- 74 return 0; 75 } 76 77 ierr = CeedCalloc(1,qf); CeedChk(ierr); 78 (*qf)->ceed = ceed; 79 ceed->refcount++; 80 (*qf)->refcount = 1; 81 (*qf)->vlength = vlength; | 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. --- 65 unchanged lines hidden (view full) --- 74 return 0; 75 } 76 77 ierr = CeedCalloc(1,qf); CeedChk(ierr); 78 (*qf)->ceed = ceed; 79 ceed->refcount++; 80 (*qf)->refcount = 1; 81 (*qf)->vlength = vlength; |
| 82 (*qf)->identity = 0; |
|
| 82 (*qf)->function = f; 83 ierr = CeedCalloc(strlen(source)+1, &source_copy); CeedChk(ierr); 84 strncpy(source_copy, source, strlen(source)); 85 (*qf)->sourcepath = source_copy; 86 ierr = CeedCalloc(16, &(*qf)->inputfields); CeedChk(ierr); 87 ierr = CeedCalloc(16, &(*qf)->outputfields); CeedChk(ierr); 88 ierr = ceed->QFunctionCreate(*qf); CeedChk(ierr); 89 return 0; --- 71 unchanged lines hidden (view full) --- 161 162 // QFunction specific setup 163 ierr = qfunctions[matchidx].init(ceed, name, *qf); CeedChk(ierr); 164 165 return 0; 166} 167 168/** | 83 (*qf)->function = f; 84 ierr = CeedCalloc(strlen(source)+1, &source_copy); CeedChk(ierr); 85 strncpy(source_copy, source, strlen(source)); 86 (*qf)->sourcepath = source_copy; 87 ierr = CeedCalloc(16, &(*qf)->inputfields); CeedChk(ierr); 88 ierr = CeedCalloc(16, &(*qf)->outputfields); CeedChk(ierr); 89 ierr = ceed->QFunctionCreate(*qf); CeedChk(ierr); 90 return 0; --- 71 unchanged lines hidden (view full) --- 162 163 // QFunction specific setup 164 ierr = qfunctions[matchidx].init(ceed, name, *qf); CeedChk(ierr); 165 166 return 0; 167} 168 169/** |
| 170 @brief Create an identity CeedQFunction. Inputs are written into outputs in 171 the order given. This is useful for CeedOperators that can be 172 represented with only the action of a CeedRestriction and CeedBasis, 173 such as restriction and prolongation operators for p-multigrid. 174 Backends may optimize CeedOperators with this CeedQFunction to avoid 175 the copy of input data to output fields by using the same memory 176 location for both. 177 178 @param ceed A Ceed object where the CeedQFunction will be created 179 @param size Size of the qfunction fields 180 @param[out] qf Address of the variable where the newly created 181 CeedQFunction will be stored 182 183 @return An error code: 0 - success, otherwise - failure 184 185 @ref Basic 186**/ 187int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedQFunction *qf) { 188 int ierr; 189 190 ierr = CeedQFunctionCreateInteriorByName(ceed, "Identity", qf); CeedChk(ierr); 191 192 (*qf)->identity = 1; 193 if (size > 1) { 194 CeedInt *ctx; 195 ierr = CeedCalloc(1, &ctx); CeedChk(ierr); 196 ctx[0] = size; 197 ierr = CeedQFunctionSetContext(*qf, ctx, sizeof(ctx)); CeedChk(ierr); 198 } 199 200 return 0; 201} 202 203/** |
|
| 169 @brief Set a CeedQFunction field, used by CeedQFunctionAddInput/Output 170 171 @param f CeedQFunctionField 172 @param fieldname Name of QFunction field 173 @param size Size of QFunction field, ncomp * (dim for CEED_EVAL_GRAD or 174 1 for CEED_EVAL_NONE and CEED_EVAL_INTERP) 175 @param emode \ref CEED_EVAL_NONE to use values directly, 176 \ref CEED_EVAL_INTERP to use interpolated values, --- 201 unchanged lines hidden (view full) --- 378**/ 379 380int CeedQFunctionGetFortranStatus(CeedQFunction qf, bool *fortranstatus) { 381 *fortranstatus = qf->fortranstatus; 382 return 0; 383} 384 385/** | 204 @brief Set a CeedQFunction field, used by CeedQFunctionAddInput/Output 205 206 @param f CeedQFunctionField 207 @param fieldname Name of QFunction field 208 @param size Size of QFunction field, ncomp * (dim for CEED_EVAL_GRAD or 209 1 for CEED_EVAL_NONE and CEED_EVAL_INTERP) 210 @param emode \ref CEED_EVAL_NONE to use values directly, 211 \ref CEED_EVAL_INTERP to use interpolated values, --- 201 unchanged lines hidden (view full) --- 413**/ 414 415int CeedQFunctionGetFortranStatus(CeedQFunction qf, bool *fortranstatus) { 416 *fortranstatus = qf->fortranstatus; 417 return 0; 418} 419 420/** |
| 421 @brief Determine if QFunction is identity 422 423 @param qf CeedQFunction 424 @param[out] identity Variable to store identity status 425 426 @return An error code: 0 - success, otherwise - failure 427 428 @ref Advanced 429**/ 430 431int CeedQFunctionGetIdentityStatus(CeedQFunction qf, bool *identity) { 432 *identity = qf->identity; 433 return 0; 434} 435 436/** |
|
| 386 @brief Get true user context for a CeedQFunction 387 388 @param qf CeedQFunction 389 @param[out] ctx Variable to store context data values 390 391 @return An error code: 0 - success, otherwise - failure 392 393 @ref Advanced --- 178 unchanged lines hidden (view full) --- 572 ierr = CeedFree(&(*qf)->inputfields[i]); CeedChk(ierr); 573 } 574 for (int i=0; i<(*qf)->numoutputfields; i++) { 575 ierr = CeedFree(&(*(*qf)->outputfields[i]).fieldname); CeedChk(ierr); 576 ierr = CeedFree(&(*qf)->outputfields[i]); CeedChk(ierr); 577 } 578 ierr = CeedFree(&(*qf)->inputfields); CeedChk(ierr); 579 ierr = CeedFree(&(*qf)->outputfields); CeedChk(ierr); | 437 @brief Get true user context for a CeedQFunction 438 439 @param qf CeedQFunction 440 @param[out] ctx Variable to store context data values 441 442 @return An error code: 0 - success, otherwise - failure 443 444 @ref Advanced --- 178 unchanged lines hidden (view full) --- 623 ierr = CeedFree(&(*qf)->inputfields[i]); CeedChk(ierr); 624 } 625 for (int i=0; i<(*qf)->numoutputfields; i++) { 626 ierr = CeedFree(&(*(*qf)->outputfields[i]).fieldname); CeedChk(ierr); 627 ierr = CeedFree(&(*qf)->outputfields[i]); CeedChk(ierr); 628 } 629 ierr = CeedFree(&(*qf)->inputfields); CeedChk(ierr); 630 ierr = CeedFree(&(*qf)->outputfields); CeedChk(ierr); |
| 631 // Free ctx if identity 632 if ((*qf)->identity) { 633 ierr = CeedFree(&(*qf)->ctx); CeedChk(ierr); 634 } |
|
| 580 581 ierr = CeedFree(&(*qf)->sourcepath); CeedChk(ierr); 582 ierr = CeedDestroy(&(*qf)->ceed); CeedChk(ierr); 583 ierr = CeedFree(qf); CeedChk(ierr); 584 return 0; 585} 586 587/// @} | 635 636 ierr = CeedFree(&(*qf)->sourcepath); CeedChk(ierr); 637 ierr = CeedDestroy(&(*qf)->ceed); CeedChk(ierr); 638 ierr = CeedFree(qf); CeedChk(ierr); 639 return 0; 640} 641 642/// @} |