| ceed-elemrestriction.c (38d0029a08e84b16bbdde77c27446234f5f09cf2) | ceed-elemrestriction.c (7a982d89c751e293e39d23a7c44a161cef1fcd06) |
|---|---|
| 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. 9// 10// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11// a collaborative effort of two U.S. Department of Energy organizations (Office 12// of Science and the National Nuclear Security Administration) responsible for 13// the planning and preparation of a capable exascale ecosystem, including 14// software, applications, hardware, advanced system engineering and early 15// testbed platforms, in support of the nation's exascale computing imperative. 16 17#include <ceed-impl.h> 18#include <ceed-backend.h> 19 | 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. 9// 10// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11// a collaborative effort of two U.S. Department of Energy organizations (Office 12// of Science and the National Nuclear Security Administration) responsible for 13// the planning and preparation of a capable exascale ecosystem, including 14// software, applications, hardware, advanced system engineering and early 15// testbed platforms, in support of the nation's exascale computing imperative. 16 17#include <ceed-impl.h> 18#include <ceed-backend.h> 19 |
| 20/// @file 21/// Implementation of CeedElemRestriction interfaces 22 23/// ---------------------------------------------------------------------------- 24/// CeedElemRestriction Library Internal Functions 25/// ---------------------------------------------------------------------------- 26/// @addtogroup CeedElemRestrictionDeveloper 27/// @{ 28 29/** 30 @brief Permute and pad indices for a blocked restriction 31 32 @param indices Array of shape [@a nelem, @a elemsize]. Row i holds the 33 ordered list of the indices (into the input CeedVector) 34 for the unknowns corresponding to element i, where 35 0 <= i < @a nelem. All indices must be in the range 36 [0, @a nnodes). 37 @param blkindices Array of permuted and padded indices of 38 shape [@a nblk, @a elemsize, @a blksize]. 39 @param nblk Number of blocks 40 @param nelem Number of elements 41 @param blksize Number of elements in a block 42 @param elemsize Size of each element 43 44 @return An error code: 0 - success, otherwise - failure 45 46 @ref Utility 47**/ 48int CeedPermutePadIndices(const CeedInt *indices, CeedInt *blkindices, 49 CeedInt nblk, CeedInt nelem, CeedInt blksize, 50 CeedInt elemsize) { 51 for (CeedInt e = 0; e < nblk*blksize; e+=blksize) 52 for (int j = 0; j < blksize; j++) 53 for (int k = 0; k < elemsize; k++) 54 blkindices[e*elemsize + k*blksize + j] 55 = indices[CeedIntMin(e+j,nelem-1)*elemsize + k]; 56 return 0; 57} 58 59/// @} 60 61/// ---------------------------------------------------------------------------- 62/// CeedElemRestriction Backend API 63/// ---------------------------------------------------------------------------- 64/// @addtogroup CeedElemRestrictionBackend 65/// @{ 66 67/** 68 @brief Get the Ceed associated with a CeedElemRestriction 69 70 @param rstr CeedElemRestriction 71 @param[out] ceed Variable to store Ceed 72 73 @return An error code: 0 - success, otherwise - failure 74 75 @ref Backend 76**/ 77int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed) { 78 *ceed = rstr->ceed; 79 return 0; 80} 81 82/** 83 @brief Get the L-vector interlaced mode of a CeedElemRestriction 84 85 @param rstr CeedElemRestriction 86 @param[out] imode Variable to store imode 87 88 @return An error code: 0 - success, otherwise - failure 89 90 @ref Backend 91**/ 92int CeedElemRestrictionGetIMode(CeedElemRestriction rstr, 93 CeedInterlaceMode *imode) { 94 *imode = rstr->imode; 95 return 0; 96} 97 98/** 99 @brief Get the total number of elements in the range of a CeedElemRestriction 100 101 @param rstr CeedElemRestriction 102 @param[out] numelem Variable to store number of elements 103 104 @return An error code: 0 - success, otherwise - failure 105 106 @ref Backend 107**/ 108int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, 109 CeedInt *numelem) { 110 *numelem = rstr->nelem; 111 return 0; 112} 113 114/** 115 @brief Get the size of elements in the CeedElemRestriction 116 117 @param rstr CeedElemRestriction 118 @param[out] elemsize Variable to store size of elements 119 120 @return An error code: 0 - success, otherwise - failure 121 122 @ref Backend 123**/ 124int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, 125 CeedInt *elemsize) { 126 *elemsize = rstr->elemsize; 127 return 0; 128} 129 130/** 131 @brief Get the number of degrees of freedom in the range of a 132 CeedElemRestriction 133 134 @param rstr CeedElemRestriction 135 @param[out] numnodes Variable to store number of nodes 136 137 @return An error code: 0 - success, otherwise - failure 138 139 @ref Backend 140**/ 141int CeedElemRestrictionGetNumNodes(CeedElemRestriction rstr, 142 CeedInt *numnodes) { 143 *numnodes = rstr->nnodes; 144 return 0; 145} 146 147/** 148 @brief Get the number of components in the elements of a 149 CeedElemRestriction 150 151 @param rstr CeedElemRestriction 152 @param[out] numcomp Variable to store number of components 153 154 @return An error code: 0 - success, otherwise - failure 155 156 @ref Backend 157**/ 158int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, 159 CeedInt *numcomp) { 160 *numcomp = rstr->ncomp; 161 return 0; 162} 163 164/** 165 @brief Get the number of blocks in a CeedElemRestriction 166 167 @param rstr CeedElemRestriction 168 @param[out] numblock Variable to store number of blocks 169 170 @return An error code: 0 - success, otherwise - failure 171 172 @ref Backend 173**/ 174int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, 175 CeedInt *numblock) { 176 *numblock = rstr->nblk; 177 return 0; 178} 179 180/** 181 @brief Get the size of blocks in the CeedElemRestriction 182 183 @param rstr CeedElemRestriction 184 @param[out] blksize Variable to store size of blocks 185 186 @return An error code: 0 - success, otherwise - failure 187 188 @ref Backend 189**/ 190int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, 191 CeedInt *blksize) { 192 *blksize = rstr->blksize; 193 return 0; 194} 195 196/** 197 @brief Get the backend data of a CeedElemRestriction 198 199 @param rstr CeedElemRestriction 200 @param[out] data Variable to store data 201 202 @return An error code: 0 - success, otherwise - failure 203 204 @ref Backend 205**/ 206int CeedElemRestrictionGetData(CeedElemRestriction rstr, void **data) { 207 *data = rstr->data; 208 return 0; 209} 210 211/** 212 @brief Set the backend data of a CeedElemRestriction 213 214 @param[out] rstr CeedElemRestriction 215 @param data Data to set 216 217 @return An error code: 0 - success, otherwise - failure 218 219 @ref Backend 220**/ 221int CeedElemRestrictionSetData(CeedElemRestriction rstr, void **data) { 222 rstr->data = *data; 223 return 0; 224} 225 226/// @} 227 |
|
| 20/// @cond DOXYGEN_SKIP 21static struct CeedElemRestriction_private ceed_elemrestriction_none; 22/// @endcond 23 | 228/// @cond DOXYGEN_SKIP 229static struct CeedElemRestriction_private ceed_elemrestriction_none; 230/// @endcond 231 |
| 24/// @file 25/// Implementation of public CeedElemRestriction interfaces 26/// 27/// @addtogroup CeedElemRestriction | 232/// ---------------------------------------------------------------------------- 233/// CeedElemRestriction Public API 234/// ---------------------------------------------------------------------------- 235/// @addtogroup CeedElemRestrictionUser |
| 28/// @{ 29 | 236/// @{ 237 |
| 238/// Indicate that the stride is determined by the backend 239const CeedInt CEED_STRIDES_BACKEND[3] = {}; 240 241/// Indicate that no ElemRestriction is provided by the user 242const CeedElemRestriction CEED_ELEMRESTRICTION_NONE = 243 &ceed_elemrestriction_none; 244 |
|
| 30/** 31 @brief Create a CeedElemRestriction 32 33 @param ceed A Ceed object where the CeedElemRestriction will be created 34 @param imode Ordering of the ncomp components, i.e. it specifies 35 the ordering of the components of the L-vector used 36 by this CeedElemRestriction. CEED_NONINTERLACED indicates 37 the component is the outermost index and CEED_INTERLACED --- 15 unchanged lines hidden (view full) --- 53 for the unknowns corresponding to element i, where 54 0 <= i < @a nelem. All indices must be in the range 55 [0, @a nnodes - 1]. 56 @param[out] rstr Address of the variable where the newly created 57 CeedElemRestriction will be stored 58 59 @return An error code: 0 - success, otherwise - failure 60 | 245/** 246 @brief Create a CeedElemRestriction 247 248 @param ceed A Ceed object where the CeedElemRestriction will be created 249 @param imode Ordering of the ncomp components, i.e. it specifies 250 the ordering of the components of the L-vector used 251 by this CeedElemRestriction. CEED_NONINTERLACED indicates 252 the component is the outermost index and CEED_INTERLACED --- 15 unchanged lines hidden (view full) --- 268 for the unknowns corresponding to element i, where 269 0 <= i < @a nelem. All indices must be in the range 270 [0, @a nnodes - 1]. 271 @param[out] rstr Address of the variable where the newly created 272 CeedElemRestriction will be stored 273 274 @return An error code: 0 - success, otherwise - failure 275 |
| 61 @ref Basic | 276 @ref User |
| 62**/ 63int CeedElemRestrictionCreate(Ceed ceed, CeedInterlaceMode imode, 64 CeedInt nelem, CeedInt elemsize, CeedInt nnodes, 65 CeedInt ncomp, CeedMemType mtype, 66 CeedCopyMode cmode, const CeedInt *indices, 67 CeedElemRestriction *rstr) { 68 int ierr; 69 --- 45 unchanged lines hidden (view full) --- 115 The data for node i, component j, element k in the 116 L-vector is given by 117 i*strides[0] + j*strides[1] + k*strides[2] 118 @param rstr Address of the variable where the newly created 119 CeedElemRestriction will be stored 120 121 @return An error code: 0 - success, otherwise - failure 122 | 277**/ 278int CeedElemRestrictionCreate(Ceed ceed, CeedInterlaceMode imode, 279 CeedInt nelem, CeedInt elemsize, CeedInt nnodes, 280 CeedInt ncomp, CeedMemType mtype, 281 CeedCopyMode cmode, const CeedInt *indices, 282 CeedElemRestriction *rstr) { 283 int ierr; 284 --- 45 unchanged lines hidden (view full) --- 330 The data for node i, component j, element k in the 331 L-vector is given by 332 i*strides[0] + j*strides[1] + k*strides[2] 333 @param rstr Address of the variable where the newly created 334 CeedElemRestriction will be stored 335 336 @return An error code: 0 - success, otherwise - failure 337 |
| 123 @ref Basic | 338 @ref User |
| 124**/ 125int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt nelem, CeedInt elemsize, 126 CeedInt nnodes, CeedInt ncomp, 127 const CeedInt strides[3], 128 CeedElemRestriction *rstr) { 129 int ierr; 130 131 if (!ceed->ElemRestrictionCreate) { --- 26 unchanged lines hidden (view full) --- 158 (*rstr)->strides[i] = strides[i]; 159 ierr = ceed->ElemRestrictionCreate(CEED_MEM_HOST, CEED_OWN_POINTER, NULL, 160 *rstr); 161 CeedChk(ierr); 162 return 0; 163} 164 165/** | 339**/ 340int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt nelem, CeedInt elemsize, 341 CeedInt nnodes, CeedInt ncomp, 342 const CeedInt strides[3], 343 CeedElemRestriction *rstr) { 344 int ierr; 345 346 if (!ceed->ElemRestrictionCreate) { --- 26 unchanged lines hidden (view full) --- 373 (*rstr)->strides[i] = strides[i]; 374 ierr = ceed->ElemRestrictionCreate(CEED_MEM_HOST, CEED_OWN_POINTER, NULL, 375 *rstr); 376 CeedChk(ierr); 377 return 0; 378} 379 380/** |
| 166 @brief Permute and pad indices for a blocked restriction 167 168 @param indices Array of shape [@a nelem, @a elemsize]. Row i holds the 169 ordered list of the indices (into the input CeedVector) 170 for the unknowns corresponding to element i, where 171 0 <= i < @a nelem. All indices must be in the range 172 [0, @a nnodes). 173 @param blkindices Array of permuted and padded indices of 174 shape [@a nblk, @a elemsize, @a blksize]. 175 @param nblk Number of blocks 176 @param nelem Number of elements 177 @param blksize Number of elements in a block 178 @param elemsize Size of each element 179 180 @return An error code: 0 - success, otherwise - failure 181 182 @ref Utility 183**/ 184int CeedPermutePadIndices(const CeedInt *indices, CeedInt *blkindices, 185 CeedInt nblk, CeedInt nelem, CeedInt blksize, 186 CeedInt elemsize) { 187 for (CeedInt e = 0; e < nblk*blksize; e+=blksize) 188 for (int j = 0; j < blksize; j++) 189 for (int k = 0; k < elemsize; k++) 190 blkindices[e*elemsize + k*blksize + j] 191 = indices[CeedIntMin(e+j,nelem-1)*elemsize + k]; 192 return 0; 193} 194 195/** | |
| 196 @brief Create a blocked CeedElemRestriction, typically only called by backends 197 198 @param ceed A Ceed object where the CeedElemRestriction will be created. 199 @param imode Ordering of the ncomp components, i.e. it specifies 200 the ordering of the components of the L-vector used 201 by this CeedElemRestriction. CEED_NONINTERLACED indicates 202 the component is the outermost index and CEED_INTERLACED 203 indicates the component is the innermost index in --- 18 unchanged lines hidden (view full) --- 222 array to the desired ordering for the blocksize, which is 223 typically given by the backend. The default reordering is 224 to interlace elements. 225 @param rstr Address of the variable where the newly created 226 CeedElemRestriction will be stored 227 228 @return An error code: 0 - success, otherwise - failure 229 | 381 @brief Create a blocked CeedElemRestriction, typically only called by backends 382 383 @param ceed A Ceed object where the CeedElemRestriction will be created. 384 @param imode Ordering of the ncomp components, i.e. it specifies 385 the ordering of the components of the L-vector used 386 by this CeedElemRestriction. CEED_NONINTERLACED indicates 387 the component is the outermost index and CEED_INTERLACED 388 indicates the component is the innermost index in --- 18 unchanged lines hidden (view full) --- 407 array to the desired ordering for the blocksize, which is 408 typically given by the backend. The default reordering is 409 to interlace elements. 410 @param rstr Address of the variable where the newly created 411 CeedElemRestriction will be stored 412 413 @return An error code: 0 - success, otherwise - failure 414 |
| 230 @ref Advanced | 415 @ref Backend |
| 231 **/ 232int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInterlaceMode imode, 233 CeedInt nelem, CeedInt elemsize, 234 CeedInt blksize, CeedInt nnodes, 235 CeedInt ncomp, CeedMemType mtype, 236 CeedCopyMode cmode, const CeedInt *indices, 237 CeedElemRestriction *rstr) { 238 int ierr; --- 62 unchanged lines hidden (view full) --- 301 The data for node i, component j, element k in the 302 L-vector is given by 303 i*strides[0] + j*strides[1] + k*strides[2] 304 @param rstr Address of the variable where the newly created 305 CeedElemRestriction will be stored 306 307 @return An error code: 0 - success, otherwise - failure 308 | 416 **/ 417int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInterlaceMode imode, 418 CeedInt nelem, CeedInt elemsize, 419 CeedInt blksize, CeedInt nnodes, 420 CeedInt ncomp, CeedMemType mtype, 421 CeedCopyMode cmode, const CeedInt *indices, 422 CeedElemRestriction *rstr) { 423 int ierr; --- 62 unchanged lines hidden (view full) --- 486 The data for node i, component j, element k in the 487 L-vector is given by 488 i*strides[0] + j*strides[1] + k*strides[2] 489 @param rstr Address of the variable where the newly created 490 CeedElemRestriction will be stored 491 492 @return An error code: 0 - success, otherwise - failure 493 |
| 309 @ref Basic | 494 @ref User |
| 310**/ 311int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt nelem, 312 CeedInt elemsize, CeedInt blksize, CeedInt nnodes, CeedInt ncomp, 313 const CeedInt strides[3], CeedElemRestriction *rstr) { 314 int ierr; 315 CeedInt nblk = (nelem / blksize) + !!(nelem % blksize); 316 317 if (!ceed->ElemRestrictionCreateBlocked) { --- 37 unchanged lines hidden (view full) --- 355 @brief Create CeedVectors associated with a CeedElemRestriction 356 357 @param rstr CeedElemRestriction 358 @param lvec The address of the L-vector to be created, or NULL 359 @param evec The address of the E-vector to be created, or NULL 360 361 @return An error code: 0 - success, otherwise - failure 362 | 495**/ 496int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt nelem, 497 CeedInt elemsize, CeedInt blksize, CeedInt nnodes, CeedInt ncomp, 498 const CeedInt strides[3], CeedElemRestriction *rstr) { 499 int ierr; 500 CeedInt nblk = (nelem / blksize) + !!(nelem % blksize); 501 502 if (!ceed->ElemRestrictionCreateBlocked) { --- 37 unchanged lines hidden (view full) --- 540 @brief Create CeedVectors associated with a CeedElemRestriction 541 542 @param rstr CeedElemRestriction 543 @param lvec The address of the L-vector to be created, or NULL 544 @param evec The address of the E-vector to be created, or NULL 545 546 @return An error code: 0 - success, otherwise - failure 547 |
| 363 @ref Advanced | 548 @ref User |
| 364**/ 365int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, 366 CeedVector *evec) { 367 int ierr; 368 CeedInt n, m; 369 m = rstr->nnodes * rstr->ncomp; 370 n = rstr->nblk * rstr->blksize * rstr->elemsize * rstr->ncomp; 371 if (lvec) { --- 14 unchanged lines hidden (view full) --- 386 tmode=CEED_NOTRANSPOSE, imode=CEED_INTERLACED) 387 @param ru Output vector (of shape [@a nelem * @a elemsize] when 388 tmode=CEED_NOTRANSPOSE). Ordering of the e-vector is decided 389 by the backend. 390 @param request Request or CEED_REQUEST_IMMEDIATE 391 392 @return An error code: 0 - success, otherwise - failure 393 | 549**/ 550int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, 551 CeedVector *evec) { 552 int ierr; 553 CeedInt n, m; 554 m = rstr->nnodes * rstr->ncomp; 555 n = rstr->nblk * rstr->blksize * rstr->elemsize * rstr->ncomp; 556 if (lvec) { --- 14 unchanged lines hidden (view full) --- 571 tmode=CEED_NOTRANSPOSE, imode=CEED_INTERLACED) 572 @param ru Output vector (of shape [@a nelem * @a elemsize] when 573 tmode=CEED_NOTRANSPOSE). Ordering of the e-vector is decided 574 by the backend. 575 @param request Request or CEED_REQUEST_IMMEDIATE 576 577 @return An error code: 0 - success, otherwise - failure 578 |
| 394 @ref Advanced | 579 @ref User |
| 395**/ 396int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode tmode, 397 CeedVector u, CeedVector ru, 398 CeedRequest *request) { 399 CeedInt m,n; 400 int ierr; 401 402 if (tmode == CEED_NOTRANSPOSE) { --- 30 unchanged lines hidden (view full) --- 433 tmode=CEED_NOTRANSPOSE, imode=CEED_INTERLACED) 434 @param ru Output vector (of shape [@a blksize * @a elemsize] when 435 tmode=CEED_NOTRANSPOSE). Ordering of the e-vector is decided 436 by the backend. 437 @param request Request or CEED_REQUEST_IMMEDIATE 438 439 @return An error code: 0 - success, otherwise - failure 440 | 580**/ 581int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode tmode, 582 CeedVector u, CeedVector ru, 583 CeedRequest *request) { 584 CeedInt m,n; 585 int ierr; 586 587 if (tmode == CEED_NOTRANSPOSE) { --- 30 unchanged lines hidden (view full) --- 618 tmode=CEED_NOTRANSPOSE, imode=CEED_INTERLACED) 619 @param ru Output vector (of shape [@a blksize * @a elemsize] when 620 tmode=CEED_NOTRANSPOSE). Ordering of the e-vector is decided 621 by the backend. 622 @param request Request or CEED_REQUEST_IMMEDIATE 623 624 @return An error code: 0 - success, otherwise - failure 625 |
| 441 @ref Advanced | 626 @ref Backend |
| 442**/ 443int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, 444 CeedTransposeMode tmode, CeedVector u, 445 CeedVector ru, CeedRequest *request) { 446 CeedInt m,n; 447 int ierr; 448 449 if (tmode == CEED_NOTRANSPOSE) { --- 28 unchanged lines hidden (view full) --- 478/** 479 @brief Get the multiplicity of nodes in a CeedElemRestriction 480 481 @param rstr CeedElemRestriction 482 @param[out] mult Vector to store multiplicity (of size nnodes*ncomp) 483 484 @return An error code: 0 - success, otherwise - failure 485 | 627**/ 628int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, 629 CeedTransposeMode tmode, CeedVector u, 630 CeedVector ru, CeedRequest *request) { 631 CeedInt m,n; 632 int ierr; 633 634 if (tmode == CEED_NOTRANSPOSE) { --- 28 unchanged lines hidden (view full) --- 663/** 664 @brief Get the multiplicity of nodes in a CeedElemRestriction 665 666 @param rstr CeedElemRestriction 667 @param[out] mult Vector to store multiplicity (of size nnodes*ncomp) 668 669 @return An error code: 0 - success, otherwise - failure 670 |
| 486 @ref Advanced | 671 @ref User |
| 487**/ 488int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, 489 CeedVector mult) { 490 int ierr; 491 CeedVector evec; 492 493 // Create and set evec 494 ierr = CeedElemRestrictionCreateVector(rstr, NULL, &evec); CeedChk(ierr); --- 6 unchanged lines hidden (view full) --- 501 502 // Cleanup 503 ierr = CeedVectorDestroy(&evec); CeedChk(ierr); 504 505 return 0; 506} 507 508/** | 672**/ 673int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, 674 CeedVector mult) { 675 int ierr; 676 CeedVector evec; 677 678 // Create and set evec 679 ierr = CeedElemRestrictionCreateVector(rstr, NULL, &evec); CeedChk(ierr); --- 6 unchanged lines hidden (view full) --- 686 687 // Cleanup 688 ierr = CeedVectorDestroy(&evec); CeedChk(ierr); 689 690 return 0; 691} 692 693/** |
| 509 @brief Get the Ceed associated with a CeedElemRestriction | |
| 510 | 694 |
| 511 @param rstr CeedElemRestriction 512 @param[out] ceed Variable to store Ceed 513 514 @return An error code: 0 - success, otherwise - failure 515 516 @ref Advanced 517**/ 518int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed) { 519 *ceed = rstr->ceed; 520 return 0; 521} 522 523/** 524 @brief Get the L-vector interlaced mode of a CeedElemRestriction 525 526 @param rstr CeedElemRestriction 527 @param[out] imode Variable to store imode 528 529 @return An error code: 0 - success, otherwise - failure 530 531 @ref Advanced 532**/ 533int CeedElemRestrictionGetIMode(CeedElemRestriction rstr, 534 CeedInterlaceMode *imode) { 535 if (rstr->strides) 536 // LCOV_EXCL_START 537 return CeedError(rstr->ceed, 1, "Strided ElemRestriction has no interlace " 538 "mode"); 539 // LCOV_EXCL_STOP 540 541 *imode = rstr->imode; 542 return 0; 543} 544 545/** 546 @brief Get the total number of elements in the range of a CeedElemRestriction 547 548 @param rstr CeedElemRestriction 549 @param[out] numelem Variable to store number of elements 550 551 @return An error code: 0 - success, otherwise - failure 552 553 @ref Advanced 554**/ 555int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, 556 CeedInt *numelem) { 557 *numelem = rstr->nelem; 558 return 0; 559} 560 561/** 562 @brief Get the size of elements in the CeedElemRestriction 563 564 @param rstr CeedElemRestriction 565 @param[out] elemsize Variable to store size of elements 566 567 @return An error code: 0 - success, otherwise - failure 568 569 @ref Advanced 570**/ 571int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, 572 CeedInt *elemsize) { 573 *elemsize = rstr->elemsize; 574 return 0; 575} 576 577/** 578 @brief Get the number of degrees of freedom in the range of a 579 CeedElemRestriction 580 581 @param rstr CeedElemRestriction 582 @param[out] numnodes Variable to store number of nodes 583 584 @return An error code: 0 - success, otherwise - failure 585 586 @ref Advanced 587**/ 588int CeedElemRestrictionGetNumNodes(CeedElemRestriction rstr, 589 CeedInt *numnodes) { 590 *numnodes = rstr->nnodes; 591 return 0; 592} 593 594/** 595 @brief Get the number of components in the elements of a 596 CeedElemRestriction 597 598 @param rstr CeedElemRestriction 599 @param[out] numcomp Variable to store number of components 600 601 @return An error code: 0 - success, otherwise - failure 602 603 @ref Advanced 604**/ 605int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, 606 CeedInt *numcomp) { 607 *numcomp = rstr->ncomp; 608 return 0; 609} 610 611/** 612 @brief Get the number of blocks in a CeedElemRestriction 613 614 @param rstr CeedElemRestriction 615 @param[out] numblock Variable to store number of blocks 616 617 @return An error code: 0 - success, otherwise - failure 618 619 @ref Advanced 620**/ 621int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, 622 CeedInt *numblock) { 623 *numblock = rstr->nblk; 624 return 0; 625} 626 627/** 628 @brief Get the size of blocks in the CeedElemRestriction 629 630 @param rstr CeedElemRestriction 631 @param[out] blksize Variable to store size of blocks 632 633 @return An error code: 0 - success, otherwise - failure 634 635 @ref Advanced 636**/ 637int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, 638 CeedInt *blksize) { 639 *blksize = rstr->blksize; 640 return 0; 641} 642 643/** | |
| 644 @brief Get the strides of a strided CeedElemRestriction 645 646 @param rstr CeedElemRestriction 647 @param[out] strides Variable to store strides array 648 649 @return An error code: 0 - success, otherwise - failure 650 | 695 @brief Get the strides of a strided CeedElemRestriction 696 697 @param rstr CeedElemRestriction 698 @param[out] strides Variable to store strides array 699 700 @return An error code: 0 - success, otherwise - failure 701 |
| 651 @ref Advanced | 702 @ref Backend |
| 652**/ 653int CeedElemRestrictionGetStrides(CeedElemRestriction rstr, 654 CeedInt (*strides)[3]) { 655 if (!rstr->strides) 656 // LCOV_EXCL_START 657 return CeedError(rstr->ceed, 1, "ElemRestriction has no stride data"); 658 // LCOV_EXCL_STOP 659 --- 5 unchanged lines hidden (view full) --- 665/** 666 @brief Get the backend stride status of a CeedElemRestriction 667 668 @param rstr CeedElemRestriction 669 @param[out] bool Variable to store stride status 670 671 @return An error code: 0 - success, otherwise - failure 672 | 703**/ 704int CeedElemRestrictionGetStrides(CeedElemRestriction rstr, 705 CeedInt (*strides)[3]) { 706 if (!rstr->strides) 707 // LCOV_EXCL_START 708 return CeedError(rstr->ceed, 1, "ElemRestriction has no stride data"); 709 // LCOV_EXCL_STOP 710 --- 5 unchanged lines hidden (view full) --- 716/** 717 @brief Get the backend stride status of a CeedElemRestriction 718 719 @param rstr CeedElemRestriction 720 @param[out] bool Variable to store stride status 721 722 @return An error code: 0 - success, otherwise - failure 723 |
| 673 @ref Advanced | 724 @ref Backend |
| 674**/ 675int CeedElemRestrictionGetBackendStridesStatus(CeedElemRestriction rstr, 676 bool *status) { 677 if (!rstr->strides) 678 // LCOV_EXCL_START 679 return CeedError(rstr->ceed, 1, "ElemRestriction has no stride data"); 680 // LCOV_EXCL_STOP 681 682 *status = ((rstr->strides[0] == CEED_STRIDES_BACKEND[0]) && 683 (rstr->strides[1] == CEED_STRIDES_BACKEND[1]) && 684 (rstr->strides[2] == CEED_STRIDES_BACKEND[2])); 685 return 0; 686} 687 688/** | 725**/ 726int CeedElemRestrictionGetBackendStridesStatus(CeedElemRestriction rstr, 727 bool *status) { 728 if (!rstr->strides) 729 // LCOV_EXCL_START 730 return CeedError(rstr->ceed, 1, "ElemRestriction has no stride data"); 731 // LCOV_EXCL_STOP 732 733 *status = ((rstr->strides[0] == CEED_STRIDES_BACKEND[0]) && 734 (rstr->strides[1] == CEED_STRIDES_BACKEND[1]) && 735 (rstr->strides[2] == CEED_STRIDES_BACKEND[2])); 736 return 0; 737} 738 739/** |
| 689 @brief Get the backend data of a CeedElemRestriction 690 691 @param rstr CeedElemRestriction 692 @param[out] data Variable to store data 693 694 @return An error code: 0 - success, otherwise - failure 695 696 @ref Advanced 697**/ 698int CeedElemRestrictionGetData(CeedElemRestriction rstr, void **data) { 699 *data = rstr->data; 700 return 0; 701} 702 703/** 704 @brief Set the backend data of a CeedElemRestriction 705 706 @param[out] rstr CeedElemRestriction 707 @param data Data to set 708 709 @return An error code: 0 - success, otherwise - failure 710 711 @ref Advanced 712**/ 713int CeedElemRestrictionSetData(CeedElemRestriction rstr, void **data) { 714 rstr->data = *data; 715 return 0; 716} 717 718/** | |
| 719 @brief View a CeedElemRestriction 720 721 @param[in] rstr CeedElemRestriction to view 722 @param[in] stream Stream to write; typically stdout/stderr or a file 723 724 @return Error code: 0 - success, otherwise - failure 725 | 740 @brief View a CeedElemRestriction 741 742 @param[in] rstr CeedElemRestriction to view 743 @param[in] stream Stream to write; typically stdout/stderr or a file 744 745 @return Error code: 0 - success, otherwise - failure 746 |
| 726 @ref Utility | 747 @ref User |
| 727**/ 728int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream) { 729 char stridesstr[500]; 730 if (rstr->strides) 731 sprintf(stridesstr, "[%d, %d, %d]", rstr->strides[0], rstr->strides[1], 732 rstr->strides[2]); 733 734 fprintf(stream, "%sCeedElemRestriction from (%d, %d) to %d elements with %d " --- 6 unchanged lines hidden (view full) --- 741 742/** 743 @brief Destroy a CeedElemRestriction 744 745 @param rstr CeedElemRestriction to destroy 746 747 @return An error code: 0 - success, otherwise - failure 748 | 748**/ 749int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream) { 750 char stridesstr[500]; 751 if (rstr->strides) 752 sprintf(stridesstr, "[%d, %d, %d]", rstr->strides[0], rstr->strides[1], 753 rstr->strides[2]); 754 755 fprintf(stream, "%sCeedElemRestriction from (%d, %d) to %d elements with %d " --- 6 unchanged lines hidden (view full) --- 762 763/** 764 @brief Destroy a CeedElemRestriction 765 766 @param rstr CeedElemRestriction to destroy 767 768 @return An error code: 0 - success, otherwise - failure 769 |
| 749 @ref Basic | 770 @ref User |
| 750**/ 751int CeedElemRestrictionDestroy(CeedElemRestriction *rstr) { 752 int ierr; 753 754 if (!*rstr || --(*rstr)->refcount > 0) 755 return 0; 756 if ((*rstr)->Destroy) { 757 ierr = (*rstr)->Destroy(*rstr); CeedChk(ierr); 758 } 759 ierr = CeedFree(&(*rstr)->strides); CeedChk(ierr); 760 ierr = CeedDestroy(&(*rstr)->ceed); CeedChk(ierr); 761 ierr = CeedFree(rstr); CeedChk(ierr); 762 return 0; 763} 764 | 771**/ 772int CeedElemRestrictionDestroy(CeedElemRestriction *rstr) { 773 int ierr; 774 775 if (!*rstr || --(*rstr)->refcount > 0) 776 return 0; 777 if ((*rstr)->Destroy) { 778 ierr = (*rstr)->Destroy(*rstr); CeedChk(ierr); 779 } 780 ierr = CeedFree(&(*rstr)->strides); CeedChk(ierr); 781 ierr = CeedDestroy(&(*rstr)->ceed); CeedChk(ierr); 782 ierr = CeedFree(rstr); CeedChk(ierr); 783 return 0; 784} 785 |
| 765/// @cond DOXYGEN_SKIP 766// Indicate that the stride is determined by the backend 767const CeedInt CEED_STRIDES_BACKEND[3] = {}; 768 769// Indicate that no ElemRestriction is provided by the user 770const CeedElemRestriction CEED_ELEMRESTRICTION_NONE = 771 &ceed_elemrestriction_none; 772/// @endcond 773 | |
| 774/// @} | 786/// @} |