24 Ceed ceed, CeedElemRestriction *restr)
27 const int P = fe->
GetDof();
33 const int stride = compstride == 1 ? fes.
GetVDim() : 1;
36 for (
int i = 0; i < fes.
GetNE(); i++)
38 const int el_offset = P * i;
39 for (
int j = 0; j < P; j++)
41 tp_el_dof[j+el_offset] = stride*el_dof.
GetJ()[dof_map[j]+el_offset];
45 CeedElemRestrictionCreate(ceed, fes.
GetNE(), P, fes.
GetVDim(),
47 CEED_MEM_HOST, CEED_COPY_VALUES,
48 tp_el_dof.GetData(), restr);
52 Ceed ceed, CeedElemRestriction *restr)
55 const int P = fe->
GetDof();
59 const int stride = compstride == 1 ? fes.
GetVDim() : 1;
61 for (
int e = 0; e < fes.
GetNE(); e++)
63 for (
int i = 0; i < P; i++)
65 tp_el_dof[i + e*P] = stride*el_dof.
GetJ()[i + e*P];
69 CeedElemRestrictionCreate(ceed, fes.
GetNE(), P, fes.
GetVDim(),
71 CEED_MEM_HOST, CEED_COPY_VALUES,
72 tp_el_dof.GetData(), restr);
76 Ceed ceed, CeedElemRestriction *restr)
83 InitNativeRestr(fes, ceed, restr);
87 InitLexicoRestr(fes, ceed, restr);
91static void InitNativeRestrWithIndices(
95 Ceed ceed, CeedElemRestriction *restr)
98 const int P = fe->
GetDof();
104 const int stride = compstride == 1 ? fes.
GetVDim() : 1;
107 for (
int i = 0; i < nelem; i++)
109 const int elem_index = indices[i];
111 const int el_offset = P * i;
112 for (
int j = 0; j < P; j++)
114 tp_el_dof[j + el_offset] = stride*dofs[dof_map[j]];
118 CeedElemRestrictionCreate(ceed, nelem, P, fes.
GetVDim(),
120 CEED_MEM_HOST, CEED_COPY_VALUES,
121 tp_el_dof.GetData(), restr);
124static void InitLexicoRestrWithIndices(
128 Ceed ceed, CeedElemRestriction *restr)
131 const int P = fe->
GetDof();
135 const int stride = compstride == 1 ? fes.
GetVDim() : 1;
137 for (
int i = 0; i < nelem; i++)
139 const int elem_index = indices[i];
141 const int el_offset = P * i;
142 for (
int j = 0; j < P; j++)
144 tp_el_dof[j + el_offset] = stride*dofs[j];
148 CeedElemRestrictionCreate(ceed, nelem, P, fes.
GetVDim(),
150 CEED_MEM_HOST, CEED_COPY_VALUES,
151 tp_el_dof.GetData(), restr);
154static void InitRestrictionWithIndicesImpl(
158 Ceed ceed, CeedElemRestriction *restr)
165 InitNativeRestrWithIndices(fes, nelem, indices, ceed, restr);
169 InitLexicoRestrWithIndices(fes, nelem, indices, ceed, restr);
173static void InitCoeffRestrictionWithIndicesImpl(
180 CeedElemRestriction *restr)
183 const int stride_quad = ncomp;
184 const int stride_elem = ncomp*nquads;
186 for (
int i = 0; i < nelem; i++)
188 const int elem_index = indices[i];
189 const int el_offset = elem_index * stride_elem;
190 for (
int j = 0; j < nquads; j++)
192 tp_el_dof[j + nquads * i] = j * stride_quad + el_offset;
195 CeedElemRestrictionCreate(ceed, nelem, nquads, ncomp, 1,
196 ncomp*fes.
GetNE()*nquads,
197 CEED_MEM_HOST, CEED_COPY_VALUES,
198 tp_el_dof.GetData(), restr);
202 CeedInt nelem, CeedInt nqpts, CeedInt qdatasize,
203 const CeedInt *strides,
204 CeedElemRestriction *restr)
207 auto restr_itr = mfem::internal::ceed_restr_map.find(restr_key);
208 if (restr_itr == mfem::internal::ceed_restr_map.end())
210 CeedElemRestrictionCreateStrided(mfem::internal::ceed, nelem, nqpts, qdatasize,
211 nelem*nqpts*qdatasize,
215 mfem::internal::ceed_restr_map[restr_key] = *restr;
219 *restr = restr_itr->second;
225 CeedElemRestriction *restr)
229 const int P = fe->
GetDof();
230 const int nelem = fes.
GetNE();
231 const int ncomp = fes.
GetVDim();
233 auto restr_itr = mfem::internal::ceed_restr_map.find(restr_key);
236 if (restr_itr == mfem::internal::ceed_restr_map.end())
238 InitRestrictionImpl(fes, ceed, restr);
239 mfem::internal::ceed_restr_map[restr_key] = *restr;
243 *restr = restr_itr->second;
251 CeedElemRestriction *restr)
255 const int P = fe->
GetDof();
256 const int ncomp = fes.
GetVDim();
258 auto restr_itr = mfem::internal::ceed_restr_map.find(restr_key);
261 if (restr_itr == mfem::internal::ceed_restr_map.end())
263 InitRestrictionWithIndicesImpl(fes, nelem, indices, ceed, restr);
264 mfem::internal::ceed_restr_map[restr_key] = *restr;
268 *restr = restr_itr->second;
278 CeedElemRestriction *restr)
282 auto restr_itr = mfem::internal::ceed_restr_map.find(restr_key);
285 if (restr_itr == mfem::internal::ceed_restr_map.end())
287 InitCoeffRestrictionWithIndicesImpl(fes, nelem, indices, nquads, ncomp,
289 mfem::internal::ceed_restr_map[restr_key] = *restr;
293 *restr = restr_itr->second;
int Size() const
Return the logical size of the array.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
const Table & GetElementToDofTable() const
Return a reference to the internal Table that stores the lists of scalar dofs, for each mesh element,...
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
int GetNDofs() const
Returns number of degrees of freedom. This is the number of Local Degrees of Freedom.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Ordering::Type GetOrdering() const
Return the ordering method.
int GetNE() const
Returns number of elements in the mesh.
int GetVDim() const
Returns vector dimension.
Abstract class for all finite elements.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int Size_of_connections() const
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
void InitCoeffRestrictionWithIndices(const FiniteElementSpace &fes, int nelem, const int *indices, int nquads, int ncomp, Ceed ceed, CeedElemRestriction *restr)
Initialize a CeedElemRestriction for a mfem::Coefficient on a mixed mesh.
void InitStridedRestriction(const mfem::FiniteElementSpace &fes, CeedInt nelem, CeedInt nqpts, CeedInt qdatasize, const CeedInt *strides, CeedElemRestriction *restr)
Initialize a strided CeedElemRestriction.
void InitRestriction(const FiniteElementSpace &fes, Ceed ceed, CeedElemRestriction *restr)
Initialize a CeedElemRestriction for non-mixed meshes.
void InitRestrictionWithIndices(const FiniteElementSpace &fes, int nelem, const int *indices, Ceed ceed, CeedElemRestriction *restr)
Initialize a CeedElemRestriction for mixed meshes.
std::tuple< const mfem::FiniteElementSpace *, int, int, int, int > RestrKey