12 #ifndef MFEM_TEMPLATE_BILINEAR_FORM
13 #define MFEM_TEMPLATE_BILINEAR_FORM
15 #include "../config/tconfig.hpp"
16 #include "../linalg/ttensor.hpp"
30 template <
typename meshType,
typename solFESpace,
31 typename IR,
typename IntegratorType,
32 typename solVecLayout_t = ScalarLayout,
33 typename complex_t = double,
typename real_t =
double>
47 static const int sdim = meshType::space_dim;
48 static const int dofs = solFE_type::dofs;
49 static const int vdim = solVecLayout_t::vec_dim;
50 static const int qpts = IR::qpts;
53 typedef typename integ_t::coefficient_type
coeff_t;
54 typedef typename integ_t::template kernel<sdim,dim,complex_t>::type
kernel_t;
55 typedef typename kernel_t::template p_asm_data<qpts>::type
p_assembled_t;
56 typedef typename kernel_t::template f_asm_data<qpts>::type
f_assembled_t;
62 Trans_t::template Get<coeff_t,kernel_t>::EvalOps;
63 typedef typename Trans_t::template Result<EvalOps,NE>
Type;
96 mesh(*sol_fes.GetMesh()),
124 const int num_elem = 1;
125 MultAssembled<num_elem>(x, y);
139 typedef typename kernel_t::template
140 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
151 const int NE =
mesh.GetNE();
152 for (
int el = 0; el < NE; el++)
156 solFEval.Eval(el, R);
165 solFEval.Eval(el, R);
168 typename coeff_eval_t::result_t res;
171 kernel_t::Action(0, F, wQ, res, R);
173 solFEval.template Assemble<true>(R);
181 typedef typename kernel_t::template
182 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
187 const int NE =
mesh.GetNE();
192 for (
int el = 0; el < NE; el++)
197 typename coeff_eval_t::result_t res;
200 for (
int k = 0; k < BE; k++)
207 template <
int num_elem>
208 inline MFEM_ALWAYS_INLINE
212 solFEval.
Eval(el, R);
214 for (
int k = 0; k < num_elem; k++)
219 solFEval.template Assemble<true>(R);
223 template <
int num_elem>
231 const int NE =
mesh.GetNE();
232 const int bNE = NE-NE%num_elem;
233 for (
int el = 0; el < bNE; el += num_elem)
235 ElementAddMultAssembled<num_elem>(el, solFEval);
237 for (
int el = bNE; el < NE; el++)
239 ElementAddMultAssembled<1>(el, solFEval);
243 #ifdef MFEM_TEMPLATE_ENABLE_SERIALIZE
254 const int NE =
mesh.GetNE();
255 for (
int el = 0; el < NE; el++)
257 solFES.SetElement(el);
259 solFES.VectorExtract(solVecLayout, x, xy_dof.
layout, xy_dof);
260 solFES.VectorAssemble(xy_dof.
layout, xy_dof, solVecLayout, y);
267 typedef typename meshType::FESpace_type meshFESpace;
268 meshFESpace meshFES(
mesh.t_fes);
271 const int NE =
mesh.GetNE();
272 sNodes.
SetSize(lnodes_t::size*NE);
273 real_t *lNodes = sNodes.
GetData();
274 for (
int el = 0; el < NE; el++)
276 meshFES.SetElement(el);
277 meshFES.VectorExtract(
mesh.node_layout,
mesh.Nodes,
278 lnodes_t::layout, lNodes);
279 lNodes += lnodes_t::size;
288 typedef typename kernel_t::template
289 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
294 const int NE =
mesh.GetNE();
299 for (
int el = 0; el < NE; el++)
304 typename coeff_eval_t::result_t res;
318 const int NE =
mesh.GetNE();
320 complex_t *loc_sx = sx.
GetData();
321 for (
int el = 0; el < NE; el++)
323 solFES.SetElement(el);
324 solFES.VectorExtract(solVecLayout, x, vdof_data_t::layout, loc_sx);
335 const int NE =
mesh.GetNE();
336 const complex_t *loc_sx = sx.
GetData();
337 complex_t *loc_sy = sy.
GetData();
338 for (
int el = 0; el < NE; el++)
345 solFEval.template AssembleSerialized<false>(R, loc_sy);
351 #endif // MFEM_TEMPLATE_ENABLE_SERIALIZE
358 typedef typename kernel_t::template
359 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
367 const int NE =
mesh.GetNE();
368 for (
int el = 0; el < NE; el++)
375 typename coeff_eval_t::result_t res;
378 kernel_t::Assemble(0, F, wQ, res, asm_qpt_data);
385 asm_qpt_data.layout, asm_qpt_data, M_loc.
layout, M_loc, solEval);
387 solFES.SetElement(el);
388 for (
int bi = 0; bi <
vdim; bi++)
390 solFES.AssembleBlock(bi, bi, solVecLayout, M_loc, M);
400 typedef typename kernel_t::template
401 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
407 const int NE =
mesh.GetNE();
408 for (
int el = 0; el < NE; el++)
415 typename coeff_eval_t::result_t res;
418 kernel_t::Assemble(0, F, wQ, res, asm_qpt_data);
426 asm_qpt_data.layout, asm_qpt_data, M_loc.
layout, M_loc, solEval);
428 complex_t *M_data = M.
GetData(el);
429 M_loc.template AssignTo<AssignOp::Set>(M_data);
438 typedef typename kernel_t::template
439 CoefficientEval<IR,coeff_t,BE>::Type coeff_eval_t;
447 const int *dof_map_ = dof_map->
GetData();
450 const int NE =
mesh.GetNE();
451 for (
int el = 0; el < NE; el++)
458 typename coeff_eval_t::result_t res;
461 kernel_t::Assemble(0, F, wQ, res, asm_qpt_data);
468 asm_qpt_data.layout, asm_qpt_data, M_loc.
layout, M_loc, solEval);
472 for (
int i = 0; i <
dofs; i++)
474 for (
int j = 0; j <
dofs; j++)
476 M_loc_perm(dof_map_[i],dof_map_[j]) = M_loc(i,j);
479 for (
int bi = 1; bi <
vdim; bi++)
481 M_loc_perm.
CopyMN(M_loc_perm, dofs, dofs, 0, 0,
495 for (
int bi = 0; bi <
vdim; bi++)
513 const int NE =
mesh.GetNE();
514 for (
int el = 0; el < NE; el++)
519 solFES.VectorExtract(solVecLayout, x, x_dof.
layout, x_dof);
522 x_dof.
layout.merge_23(), x_dof,
523 y_dof.
layout.merge_23(), y_dof);
524 solFES.VectorAssemble(y_dof.
layout, y_dof, solVecLayout, y);
531 #endif // MFEM_TEMPLATE_BILINEAR_FORM
void SetSize(int s)
Resize the vector to size s.
static const layout_type layout
MFEM_ALWAYS_INLINE void Eval(DataType &F)
T * GetData()
Returns the data.
Data type dense matrix using column-major storage.
static const layout_type layout
MFEM_ALWAYS_INLINE void EvalSerialized(const complex_t *loc_dofs, DataType &F)
void CopyMN(const DenseMatrix &A, int m, int n, int Aro, int Aco)
Copy the m x n submatrix of A at row/col offsets Aro/Aco to *this.
data_t data[aligned_size >0?aligned_size:1]
Rank 3 tensor (array of matrices)