Actual source code: fvceed.c
1: #include <petsc/private/petscfvimpl.h>
3: #ifdef PETSC_HAVE_LIBCEED
4: #include <petscfvceed.h>
6: /*@C
7: PetscFVSetCeed - Set the `Ceed` object to a `PetscFV`
9: Not Collective
11: Input Parameters:
12: + fv - The `PetscFV`
13: - ceed - The `Ceed` object
15: Level: intermediate
17: .seealso: `PetscFV`, `PetscFVGetCeedBasis()`, `DMGetCeed()`
18: @*/
19: PetscErrorCode PetscFVSetCeed(PetscFV fv, Ceed ceed)
20: {
21: PetscFunctionBegin;
23: if (fv->ceed == ceed) PetscFunctionReturn(PETSC_SUCCESS);
24: PetscCallCEED(CeedReferenceCopy(ceed, &fv->ceed));
25: PetscFunctionReturn(PETSC_SUCCESS);
26: }
28: /*@C
29: PetscFVGetCeedBasis - Get the `Ceed` object mirroring this `PetscFV`
31: Not Collective
33: Input Parameter:
34: . fv - The `PetscFV`
36: Output Parameter:
37: . basis - The `CeedBasis`
39: Level: intermediate
41: Note:
42: This is a borrowed reference, so it is not freed.
44: .seealso: `PetscFV`, `PetscFVSetCeed()`, `DMGetCeed()`
45: @*/
46: PetscErrorCode PetscFVGetCeedBasis(PetscFV fv, CeedBasis *basis)
47: {
48: PetscQuadrature q;
49: PetscInt dim, Nc, ord;
51: PetscFunctionBegin;
53: PetscAssertPointer(basis, 2);
54: if (!fv->ceedBasis && fv->ceed) {
55: PetscCall(PetscFVGetSpatialDimension(fv, &dim));
56: PetscCall(PetscFVGetNumComponents(fv, &Nc));
57: PetscCall(PetscFVGetQuadrature(fv, &q));
58: PetscCall(PetscQuadratureGetOrder(q, &ord));
59: PetscCallCEED(CeedBasisCreateTensorH1Lagrange(fv->ceed, dim, Nc, 1, (ord + 1) / 2, CEED_GAUSS, &fv->ceedBasis));
60: }
61: *basis = fv->ceedBasis;
62: PetscFunctionReturn(PETSC_SUCCESS);
63: }
65: #endif