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(),
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);
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_NONE, quadCoeff->coeffVector);
301 CeedOperatorSetField(
build_oper,
"weights", CEED_ELEMRESTRICTION_NONE,
304 CEED_BASIS_NONE, 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_NONE, CEED_VECTOR_ACTIVE);
372 CeedOperatorSetField(
oper,
"qdata",
restr_i, CEED_BASIS_NONE,
379 CEED_BASIS_NONE, 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(),
619 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
623 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
631 CeedQFunctionAddInput(
apply_qfunc,
"u", trial_vdim,
638 CeedQFunctionAddInput(
apply_qfunc,
"weights", 1, CEED_EVAL_WEIGHT);
643 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
647 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
655 CeedQFunctionAddOutput(
apply_qfunc,
"v", test_vdim,
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);
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_NONE, quadCoeff->coeffVector);
695 CEED_BASIS_NONE, CEED_VECTOR_ACTIVE);
714 CeedOperatorSetField(
oper,
"weights", CEED_ELEMRESTRICTION_NONE,
721 CEED_BASIS_NONE, 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;
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
int GetNE() const
Returns number of elements in the mesh.
Mesh * GetMesh() const
Returns the mesh.
int GetVDim() const
Returns vector dimension.
Class for an integration rule - an Array of IntegrationPoint.
void EnsureNodes()
Make sure that the mesh has valid nodes, i.e. its geometry is described by a vector finite element gr...
const FiniteElementSpace * GetNodalFESpace() const
int Dimension() const
Dimension of the reference space used within the elements.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void GetNodes(Vector &node_coord) const
int GetNumGeometries(int dim) const
Return the number of geometries of the given dimension present in the mesh.
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...
CeedElemRestriction trial_restr
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, CoeffType *Q)
CeedElemRestriction mesh_restr
CeedQFunction apply_qfunc
CeedQFunctionContext build_ctx
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 &fes, const mfem::IntegrationRule &ir, CoeffType *Q)
This method assembles the MFIntegrator with the given CeedOperatorInfo info, an mfem::FiniteElementSp...
CeedElemRestriction restr_i
CeedElemRestriction test_restr
CeedQFunction build_qfunc
CeedElemRestriction restr_i
CeedElemRestriction test_restr
void Assemble(CeedOperatorInfo &info, const mfem::FiniteElementSpace &trial_fes, const mfem::FiniteElementSpace &test_fes, const mfem::IntegrationRule &ir, CoeffType *Q)
CeedQFunctionContext build_ctx
CeedElemRestriction mesh_restr
CeedQFunction apply_qfunc
CeedElemRestriction trial_restr
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...
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...
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)
const std::string & GetCeedPath()
Return the path to the libCEED q-function headers.
void InitVector(const mfem::Vector &v, CeedVector &cv)
Initialize a CeedVector from an mfem::Vector.
void InitStridedRestriction(const mfem::FiniteElementSpace &fes, CeedInt nelem, CeedInt nqpts, CeedInt qdatasize, const CeedInt *strides, CeedElemRestriction *restr)
Initialize a strided CeedElemRestriction.
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,...
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,...
virtual bool IsConstant() const
CeedQFunctionUser apply_qf_mf_const
const char * apply_func_mf_quad
const char * apply_func_mf_const
CeedQFunctionUser build_qf_const
CeedQFunctionUser apply_qf
CeedQFunctionUser build_qf_quad
CeedQFunctionUser apply_qf_mf_quad
const char * build_func_const
const char * build_func_quad