Actual source code: fvceed.c
  1: #include <petsc/private/petscfvimpl.h>
  3: #include <petscfvceed.h>
  5: /*@C
  6:   PetscFVSetCeed - Set the `Ceed` object to a `PetscFV`
  8:   Not Collective
 10:   Input Parameters:
 11: + fv   - The `PetscFV`
 12: - ceed - The `Ceed` object
 14:   Level: intermediate
 16: .seealso: `PetscFV`, `PetscFVGetCeedBasis()`, `DMGetCeed()`
 17: @*/
 18: PetscErrorCode PetscFVSetCeed(PetscFV fv, Ceed ceed)
 19: {
 20:   PetscFunctionBegin;
 22:   if (fv->ceed == ceed) PetscFunctionReturn(PETSC_SUCCESS);
 23:   PetscCallCEED(CeedReferenceCopy(ceed, &fv->ceed));
 24:   PetscFunctionReturn(PETSC_SUCCESS);
 25: }
 27: /*@C
 28:   PetscFVGetCeedBasis - Get the `Ceed` object mirroring this `PetscFV`
 30:   Not Collective
 32:   Input Parameter:
 33: . fv - The `PetscFV`
 35:   Output Parameter:
 36: . basis - The `CeedBasis`
 38:   Level: intermediate
 40:   Note:
 41:   This is a borrowed reference, so it is not freed.
 43: .seealso: `PetscFV`, `PetscFVSetCeed()`, `DMGetCeed()`
 44: @*/
 45: PetscErrorCode PetscFVGetCeedBasis(PetscFV fv, CeedBasis *basis)
 46: {
 47:   PetscQuadrature q;
 48:   PetscInt        dim, Nc, ord;
 50:   PetscFunctionBegin;
 52:   PetscAssertPointer(basis, 2);
 53:   if (!fv->ceedBasis && fv->ceed) {
 54:     PetscCall(PetscFVGetSpatialDimension(fv, &dim));
 55:     PetscCall(PetscFVGetNumComponents(fv, &Nc));
 56:     PetscCall(PetscFVGetQuadrature(fv, &q));
 57:     PetscCall(PetscQuadratureGetOrder(q, &ord));
 58:     PetscCallCEED(CeedBasisCreateTensorH1Lagrange(fv->ceed, dim, Nc, 1, (ord + 1) / 2, CEED_GAUSS, &fv->ceedBasis));
 59:   }
 60:   *basis = fv->ceedBasis;
 61:   PetscFunctionReturn(PETSC_SUCCESS);
 62: }