9#include <kernel/assembly/asm_traits.hpp>
10#include <kernel/util/memory_arbiter.hpp>
48 const VectorIn_& coeff,
51 typedef Space_ SpaceType;
52 typedef typename SpaceType::TrafoType TrafoType;
53 typedef typename TrafoType::MeshType MeshType;
54 typedef typename MeshType::ShapeType ShapeType;
56 static constexpr int shape_dim = ShapeType::dimension;
61 typedef typename AsmTraits::DataType DataType;
64 typedef typename VectorOut_::ValueType ValueType;
67 const TrafoType& trafo(space.get_trafo());
68 const MeshType& mesh(space.get_mesh());
71 typedef typename MeshType::template IndexSet<shape_dim, 0>::Type IndexSetType;
72 const IndexSetType& vert_idx(mesh.template get_index_set<shape_dim, 0>());
75 const Index num_verts(mesh.get_num_entities(0));
78 vector = VectorOut_(num_verts, DataType(0));
81 std::vector<int> aux(num_verts, 0);
84 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
87 typename AsmTraits::SpaceEvaluator space_eval(space);
90 typename AsmTraits::DofMapping dof_mapping(space);
93 typename AsmTraits::TrafoEvalData trafo_data;
96 typename AsmTraits::SpaceEvalData space_data;
99 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
102 typename VectorIn_::GatherAxpy gather_axpy(coeff);
108 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
114 dof_mapping.prepare(cell);
117 gather_axpy(loc_vec, dof_mapping);
120 dof_mapping.finish();
123 trafo_eval.prepare(cell);
126 space_eval.prepare(trafo_eval);
129 int num_loc_dofs = space_eval.get_num_local_dofs();
132 for(
int k(0); k < nverts; ++k)
134 typename AsmTraits::DomainPointType
dom_point;
137 for(
int i(0); i < shape_dim; ++i)
146 space_eval(space_data, trafo_data);
149 ValueType
value(DataType(0));
152 for(
int i(0); i < num_loc_dofs; ++i)
161 Index vi = vert_idx(cell, k);
164 vector_view[vi] +=
value;
180 for(
Index i(0); i < num_verts; ++i)
184 vector_view[i] *= DataType(1) / DataType(aux[i]);
209 const VectorIn_& coeff,
212 typedef Space_ SpaceType;
213 typedef typename SpaceType::TrafoType TrafoType;
214 typedef typename TrafoType::MeshType MeshType;
215 typedef typename MeshType::ShapeType ShapeType;
217 static constexpr int shape_dim = ShapeType::dimension;
222 typedef typename AsmTraits::DataType DataType;
225 typedef typename VectorOut_::ValueType ValueOutType;
226 typedef typename VectorIn_::ValueType ValueInType;
229 const TrafoType& trafo(space.get_trafo());
230 const MeshType& mesh(space.get_mesh());
233 typedef typename MeshType::template IndexSet<shape_dim, 0>::Type IndexSetType;
234 const IndexSetType& vert_idx(mesh.template get_index_set<shape_dim, 0>());
237 const Index num_verts(mesh.get_num_entities(0));
240 vector = VectorOut_(num_verts, DataType(0));
243 std::vector<int> aux(num_verts, 0);
246 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
249 typename AsmTraits::SpaceEvaluator space_eval(space);
252 typename AsmTraits::DofMapping dof_mapping(space);
255 typename AsmTraits::TrafoEvalData trafo_data;
258 typename AsmTraits::SpaceEvalData space_data;
261 typename AsmTraits::template TLocalVector<ValueInType> loc_vec;
264 typename VectorIn_::GatherAxpy gather_axpy(coeff);
270 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
276 dof_mapping.prepare(cell);
279 gather_axpy(loc_vec, dof_mapping);
282 dof_mapping.finish();
285 trafo_eval.prepare(cell);
288 space_eval.prepare(trafo_eval);
291 int num_loc_dofs = space_eval.get_num_local_dofs();
294 for(
int k(0); k < nverts; ++k)
296 typename AsmTraits::DomainPointType
dom_point;
299 for(
int i(0); i < shape_dim; ++i)
308 space_eval(space_data, trafo_data);
311 ValueOutType
value(DataType(0));
314 for(
int i(0); i < num_loc_dofs; ++i)
323 Index vi = vert_idx(cell, k);
326 vector_view[vi] +=
value;
342 for(
Index i(0); i < num_verts; ++i)
346 vector_view[i] *= (DataType(1) / DataType(aux[i]));
381 const VectorIn_& coeff,
385 project(vector, coeff, space, cubature_factory);
409 const VectorIn_& coeff,
411 const String& cubature_name)
414 project(vector, coeff, space, cubature_factory);
432 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
435 const VectorIn_& coeff,
439 typedef Space_ SpaceType;
440 typedef typename SpaceType::TrafoType TrafoType;
441 typedef typename TrafoType::MeshType MeshType;
442 typedef typename MeshType::ShapeType ShapeType;
446 typedef typename AsmTraits::DataType DataType;
449 typedef typename VectorOut_::ValueType ValueType;
452 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
455 const TrafoType& trafo(space.get_trafo());
456 const MeshType& mesh(space.get_mesh());
459 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
462 vector = VectorOut_(num_cells);
465 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
468 typename AsmTraits::SpaceEvaluator space_eval(space);
471 typename AsmTraits::DofMapping dof_mapping(space);
474 typename AsmTraits::TrafoEvalData trafo_data;
477 typename AsmTraits::SpaceEvalData space_data;
480 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
483 typename VectorIn_::GatherAxpy gather_axpy(coeff);
489 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
495 dof_mapping.prepare(cell);
498 gather_axpy(loc_vec, dof_mapping);
501 dof_mapping.finish();
504 trafo_eval.prepare(cell);
507 space_eval.prepare(trafo_eval);
510 int num_loc_dofs = space_eval.get_num_local_dofs();
513 DataType
value(DataType(0));
514 DataType area(DataType(0));
517 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
520 trafo_eval(trafo_data, cubature_rule.get_point(k));
523 space_eval(space_data, trafo_data);
525 ValueType val(DataType(0));
528 for(
int i(0); i < num_loc_dofs; ++i)
531 Tiny::axpy(val, loc_vec[i], space_data.phi[i].value);
536 DataType weight(trafo_data.jac_det * cubature_rule.get_weight(k));
542 value += weight * val;
548 vector_view[cell] = (DataType(1) / area) *
value;
580 const VectorIn_& coeff,
582 const String& cubature_name)
603 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
606 const VectorIn_& coeff,
610 typedef Space_ SpaceType;
611 typedef typename SpaceType::TrafoType TrafoType;
612 typedef typename TrafoType::MeshType MeshType;
613 typedef typename MeshType::ShapeType ShapeType;
617 typedef typename AsmTraits::DataType DataType;
620 typedef typename VectorIn_::ValueType ValueInType;
621 typedef typename VectorOut_::ValueType ValueOutType;
624 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
627 const TrafoType& trafo(space.get_trafo());
628 const MeshType& mesh(space.get_mesh());
631 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
634 vector = VectorOut_(num_cells);
637 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
640 typename AsmTraits::SpaceEvaluator space_eval(space);
643 typename AsmTraits::DofMapping dof_mapping(space);
646 typename AsmTraits::TrafoEvalData trafo_data;
649 typename AsmTraits::SpaceEvalData space_data;
652 typename AsmTraits::template TLocalVector<ValueInType> loc_vec;
655 typename VectorIn_::GatherAxpy gather_axpy(coeff);
661 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
667 dof_mapping.prepare(cell);
670 gather_axpy(loc_vec, dof_mapping);
673 dof_mapping.finish();
676 trafo_eval.prepare(cell);
679 space_eval.prepare(trafo_eval);
682 int num_loc_dofs = space_eval.get_num_local_dofs();
685 ValueOutType
value(DataType(0));
686 DataType area(DataType(0));
689 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
692 trafo_eval(trafo_data, cubature_rule.get_point(k));
695 space_eval(space_data, trafo_data);
697 ValueOutType val(DataType(0));
700 for(
int i(0); i < num_loc_dofs; ++i)
703 Tiny::axpy(val, space_data.phi[i].grad, loc_vec[i]);
708 DataType weight(trafo_data.jac_det * cubature_rule.get_weight(k));
720 vector_view[cell] = (DataType(1) / area) *
value;
742 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
743 static void project_refined(VectorOut_& vector,
const VectorIn_& coeff,
const Space_& space)
745 typedef Space_ SpaceType;
746 typedef typename SpaceType::TrafoType TrafoType;
747 typedef typename TrafoType::MeshType MeshType;
748 typedef typename MeshType::ShapeType ShapeType;
752 typedef typename AsmTraits::DataType DataType;
755 typedef typename VectorOut_::ValueType ValueType;
759 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
762 const TrafoType& trafo(space.get_trafo());
763 const MeshType& mesh(space.get_mesh());
766 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
767 const int num_points = cubature_rule.get_num_points();
770 vector = VectorOut_(num_cells *
Index(num_points), DataType(0));
773 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
776 typename AsmTraits::SpaceEvaluator space_eval(space);
779 typename AsmTraits::DofMapping dof_mapping(space);
782 typename AsmTraits::TrafoEvalData trafo_data;
785 typename AsmTraits::SpaceEvalData space_data;
788 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
791 typename VectorIn_::GatherAxpy gather_axpy(coeff);
797 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
803 dof_mapping.prepare(cell);
806 gather_axpy(loc_vec, dof_mapping);
809 dof_mapping.finish();
812 trafo_eval.prepare(cell);
815 space_eval.prepare(trafo_eval);
818 int num_loc_dofs = space_eval.get_num_local_dofs();
821 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
824 trafo_eval(trafo_data, cubature_rule.get_point(k));
827 space_eval(space_data, trafo_data);
829 ValueType
value(DataType(0));
832 for(
int i(0); i < num_loc_dofs; ++i)
Common single-space assembly traits class template.
Discrete cell projector class.
static void project(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space, const String &cubature_name)
Projects a discrete function into the cells.
static void project(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space)
Projects a discrete function into the cells using the barycentre cubature rule.
static void project(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space, const Cubature::DynamicFactory &cubature_factory)
Projects a discrete function into the cells.
static void project_refined(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space)
Projects a discrete function into the cells of a once refined mesh.
static void project_gradient(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space, const Cubature::DynamicFactory &cubature_factory)
Projects the gradient of a scalar discrete function into the cells.
static void project_gradient(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space, const String &cubature_name)
Projects the gradient of a scalar discrete function into the cells.
Discrete vertex projector class.
static void project_gradient(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space)
Projects the gradient of a scalar discrete function into the vertices.
static void project(VectorOut_ &vector, const VectorIn_ &coeff, const Space_ &space)
Projects a discrete function into the vertices.
void format(const T_ &value)
Formats the array elements to a given value, i.e. sets all elements to the same value.
String class implementation.
CUDA_HOST_DEVICE void axpy(T_ &y, const T_ &x, const T_ &alpha)
Performs an AXPY of two scalars.
@ value
specifies whether the space should supply basis function values
std::uint64_t Index
Index data type.
@ dom_point
specifies whether the trafo should supply domain point coordinates
Face traits tag struct template.
Reference cell traits structure.