12 #ifndef MFEM_LIBCEED_INTEG
13 #define MFEM_LIBCEED_INTEG
15 #include "../../../config/config.hpp"
16 #include "../../fespace.hpp"
17 #include "../../gridfunc.hpp"
18 #include "operator.hpp"
19 #include "coefficient.hpp"
20 #include "restriction.hpp"
111 template <
typename CeedOperatorInfo,
typename CoeffType>
136 template <
typename CeedOperatorInfo,
typename CoeffType>
144 Assemble(info, fes, fes, ir, nelem, indices, Q);
157 template <
typename CeedOperatorInfo,
typename CoeffType>
164 Assemble(info, trial_fes, test_fes, ir, trial_fes.
GetNE(),
nullptr, Q);
181 template <
typename CeedOperatorInfo,
typename CoeffType>
190 Ceed ceed(internal::ceed);
193 "Use ceed::MixedIntegrator on mixed meshes.");
196 std::string build_func = const_coeff ? info.build_func_const
197 : info.build_func_quad;
198 CeedQFunctionUser build_qf = const_coeff ? info.build_qf_const
199 : info.build_qf_quad;
200 PAOperator op {info.qdatasize, info.header,
201 build_func, build_qf,
202 info.apply_func, info.apply_qf,
207 CeedInt trial_vdim = trial_fes.
GetVDim();
208 CeedInt test_vdim = test_fes.
GetVDim();
211 if ( &trial_fes == &test_fes )
227 MFEM_VERIFY(mesh_fes,
"the Mesh has no nodal FE space");
231 CeedInt trial_nqpts, test_nqpts;
232 CeedBasisGetNumQuadraturePoints(
trial_basis, &trial_nqpts);
233 CeedBasisGetNumQuadraturePoints(
test_basis, &test_nqpts);
234 MFEM_VERIFY(trial_nqpts == test_nqpts,
235 "Trial and test basis must have the same number of quadrature"
237 CeedInt nqpts = trial_nqpts;
239 const int qdatasize = op.qdatasize;
241 CEED_STRIDES_BACKEND,
246 CeedVectorCreate(ceed, nelem * nqpts * qdatasize, &
qdata);
251 info.ctx.vdim = trial_fes.
GetVDim();
254 std::string qf = qf_file + op.build_func;
255 CeedQFunctionCreateInterior(ceed, 1, op.build_qf, qf.c_str(),
261 dynamic_cast<VariableCoefficient*>(
coeff))
266 CeedQFunctionAddInput(
build_qfunc,
"dx", dim * dim, CEED_EVAL_GRAD);
267 CeedQFunctionAddInput(
build_qfunc,
"weights", 1, CEED_EVAL_WEIGHT);
268 CeedQFunctionAddOutput(
build_qfunc,
"qdata", qdatasize, CEED_EVAL_NONE);
270 CeedQFunctionContextCreate(ceed, &
build_ctx);
271 CeedQFunctionContextSetData(
build_ctx, CEED_MEM_HOST,
282 nelem, indices, ceed,
285 CeedOperatorSetField(
build_oper,
"coeff", gridCoeff->restr,
286 gridCoeff->basis, gridCoeff->coeffVector);
289 dynamic_cast<QuadCoefficient*>(
coeff))
291 const int ncomp = quadCoeff->ncomp;
292 CeedInt strides[3] = {ncomp, 1, ncomp*nqpts};
294 nelem, nqpts, ncomp, strides,
296 CeedOperatorSetField(
build_oper,
"coeff", quadCoeff->restr,
297 CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
301 CeedOperatorSetField(
build_oper,
"weights", CEED_ELEMRESTRICTION_NONE,
304 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
310 qf = qf_file + op.apply_func;
311 CeedQFunctionCreateInterior(ceed, 1, op.apply_qf, qf.c_str(),
317 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim, CEED_EVAL_NONE);
320 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim, CEED_EVAL_INTERP);
323 CeedQFunctionAddInput(
apply_qfunc,
"gu", trial_vdim*dim, CEED_EVAL_GRAD);
326 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim, CEED_EVAL_INTERP);
327 CeedQFunctionAddInput(
apply_qfunc,
"gu", trial_vdim*dim, CEED_EVAL_GRAD);
331 CeedQFunctionAddInput(
apply_qfunc,
"qdata", qdatasize, CEED_EVAL_NONE);
336 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim, CEED_EVAL_NONE);
339 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim, CEED_EVAL_INTERP);
342 CeedQFunctionAddOutput(
apply_qfunc,
"gv", test_vdim*dim, CEED_EVAL_GRAD);
345 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim, CEED_EVAL_INTERP);
346 CeedQFunctionAddOutput(
apply_qfunc,
"gv", test_vdim*dim, CEED_EVAL_GRAD);
358 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
372 CeedOperatorSetField(
oper,
"qdata",
restr_i, CEED_BASIS_COLLOCATED,
379 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
393 CeedVectorCreate(ceed, trial_vdim*trial_fes.
GetNDofs(), &
u);
394 CeedVectorCreate(ceed, test_vdim*test_fes.
GetNDofs(), &
v);
403 CeedVectorDestroy(&
qdata);
418 std::string build_func;
420 CeedQFunctionUser build_qf;
422 std::string apply_func;
424 CeedQFunctionUser apply_qf;
467 template <
typename CeedOperatorInfo,
typename CoeffType>
492 template <
typename CeedOperatorInfo,
typename CoeffType>
500 Assemble(info, fes, fes, ir, nelem, indices, Q);
513 template <
typename CeedOperatorInfo,
typename CoeffType>
520 Assemble(info, trial_fes, test_fes, ir, trial_fes.
GetNE(),
nullptr, Q);
537 template <
typename CeedOperatorInfo,
typename CoeffType>
546 Ceed ceed(internal::ceed);
549 "Use ceed::MixedIntegrator on mixed meshes.");
552 std::string apply_func = const_coeff ? info.apply_func_mf_const
553 : info.apply_func_mf_quad;
554 CeedQFunctionUser apply_qf = const_coeff ? info.apply_qf_mf_const
555 : info.apply_qf_mf_quad;
556 MFOperator op {info.header,
557 apply_func, apply_qf,
563 CeedInt trial_vdim = trial_fes.
GetVDim();
564 CeedInt test_vdim = test_fes.
GetVDim();
567 if ( &trial_fes == &test_fes )
583 MFEM_VERIFY(mesh_fes,
"the Mesh has no nodal FE space");
587 CeedInt trial_nqpts, test_nqpts;
588 CeedBasisGetNumQuadraturePoints(
trial_basis, &trial_nqpts);
589 CeedBasisGetNumQuadraturePoints(
trial_basis, &test_nqpts);
590 MFEM_VERIFY(trial_nqpts == test_nqpts,
591 "Trial and test basis must have the same number of quadrature"
593 CeedInt nqpts = trial_nqpts;
600 info.ctx.vdim = trial_fes.
GetVDim();
603 std::string qf = qf_file + op.apply_func;
604 CeedQFunctionCreateInterior(ceed, 1, op.apply_qf, qf.c_str(),
610 dynamic_cast<VariableCoefficient*>(
coeff))
619 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
623 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
627 CeedQFunctionAddInput(
apply_qfunc,
"gu", trial_vdim*dim,
631 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
633 CeedQFunctionAddInput(
apply_qfunc,
"gu", trial_vdim*dim,
637 CeedQFunctionAddInput(
apply_qfunc,
"dx", dim * dim, CEED_EVAL_GRAD);
638 CeedQFunctionAddInput(
apply_qfunc,
"weights", 1, CEED_EVAL_WEIGHT);
643 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
647 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
651 CeedQFunctionAddOutput(
apply_qfunc,
"gv", test_vdim*dim,
655 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
657 CeedQFunctionAddOutput(
apply_qfunc,
"gv", test_vdim*dim,
662 CeedQFunctionContextCreate(ceed, &
build_ctx);
663 CeedQFunctionContextSetData(
build_ctx, CEED_MEM_HOST,
675 ceed, &gridCoeff->basis, &gridCoeff->restr);
676 CeedOperatorSetField(
oper,
"coeff", gridCoeff->restr,
677 gridCoeff->basis, gridCoeff->coeffVector);
680 dynamic_cast<QuadCoefficient*>(
coeff))
682 const int ncomp = quadCoeff->ncomp;
683 CeedInt strides[3] = {ncomp, 1, ncomp*nqpts};
685 nelem, nqpts, ncomp, strides,
687 CeedOperatorSetField(
oper,
"coeff", quadCoeff->restr,
688 CEED_BASIS_COLLOCATED, quadCoeff->coeffVector);
695 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
714 CeedOperatorSetField(
oper,
"weights", CEED_ELEMRESTRICTION_NONE,
721 CEED_BASIS_COLLOCATED, CEED_VECTOR_ACTIVE);
739 CeedVectorCreate(ceed, trial_vdim*trial_fes.
GetNDofs(), &
u);
740 CeedVectorCreate(ceed, test_vdim*test_fes.
GetNDofs(), &
v);
748 CeedVectorDestroy(&
qdata);
760 std::string apply_func;
762 CeedQFunctionUser apply_qf;
777 #endif // MFEM_LIBCEED_INTEG
CeedQFunctionContext build_ctx
int GetNDofs() const
Returns number of degrees of freedom.
Class for an integration rule - an Array of IntegrationPoint.
void InitVector(const mfem::Vector &v, CeedVector &cv)
Initialize a CeedVector from an mfem::Vector.
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
CeedElemRestriction test_restr
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, int nelem, const int *indices, CoeffType *Q)
CeedQFunctionUser build_qf_quad
CeedElemRestriction restr_i
CeedElemRestriction restr_i
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &fes, const mfem::IntegrationRule &ir, int nelem, const int *indices, CoeffType *Q)
This method assembles the PAIntegrator with the given CeedOperatorInfo info, an mfem::FiniteElementSp...
CeedQFunctionContext build_ctx
CeedElemRestriction test_restr
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &fes, const mfem::IntegrationRule &ir, int nelem, const int *indices, CoeffType *Q)
This method assembles the MFIntegrator with the given CeedOperatorInfo info, an mfem::FiniteElementSp...
int GetNE() const
Returns number of elements in the mesh.
virtual bool IsConstant() const
void InitCoefficient(mfem::Coefficient *Q, mfem::Mesh &mesh, const mfem::IntegrationRule &ir, Coefficient *&coeff_ptr, Context &ctx)
Initializes an mfem::ceed::Coefficient coeff_ptr from an mfem::Coefficient Q, an mfem::Mesh mesh...
CeedQFunctionUser build_qf_const
CeedElemRestriction trial_restr
Mesh * GetMesh() const
Returns the mesh.
const char * build_func_const
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, CoeffType *Q)
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &fes, const mfem::IntegrationRule &ir, CoeffType *Q)
This method assembles the PAIntegrator with the given CeedOperatorInfo info, an mfem::FiniteElementSp...
int GetVDim() const
Returns vector dimension.
CeedQFunctionUser apply_qf_mf_const
CeedQFunction build_qfunc
const char * apply_func_mf_quad
CeedElemRestriction trial_restr
CeedQFunctionUser apply_qf_mf_quad
const char * apply_func_mf_const
int SpaceDimension() const
CeedElemRestriction mesh_restr
const char * build_func_quad
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &fes, const mfem::IntegrationRule &ir, CoeffType *Q)
This method assembles the MFIntegrator with the given CeedOperatorInfo info, an mfem::FiniteElementSp...
const std::string & GetCeedPath()
Return the path to the libCEED q-function headers.
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, int nelem, const int *indices, CoeffType *Q)
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, CoeffType *Q)
void InitStridedRestriction(const mfem::FiniteElementSpace &fes, CeedInt nelem, CeedInt nqpts, CeedInt qdatasize, const CeedInt *strides, CeedElemRestriction *restr)
Initialize a strided CeedElemRestriction.
const FiniteElementSpace * GetNodalFESpace() const
CeedQFunction apply_qfunc
CeedQFunction apply_qfunc
void GetNodes(Vector &node_coord) const
void InitBasisAndRestriction(const FiniteElementSpace &fes, const IntegrationRule &irm, Ceed ceed, CeedBasis *basis, CeedElemRestriction *restr)
Initialize a CeedBasis and a CeedElemRestriction based on an mfem::FiniteElementSpace fes...
CeedQFunctionUser apply_qf
CeedElemRestriction mesh_restr