9#include <kernel/assembly/asm_traits.hpp>
46 const VectorIn_& coeff,
49 typedef Space_ SpaceType;
50 typedef typename SpaceType::TrafoType TrafoType;
51 typedef typename TrafoType::MeshType MeshType;
52 typedef typename MeshType::ShapeType ShapeType;
54 static constexpr int shape_dim = ShapeType::dimension;
59 typedef typename AsmTraits::DataType DataType;
62 typedef typename VectorOut_::ValueType ValueType;
65 const TrafoType& trafo(space.get_trafo());
66 const MeshType& mesh(space.get_mesh());
69 typedef typename MeshType::template IndexSet<shape_dim, 0>::Type IndexSetType;
70 const IndexSetType& vert_idx(mesh.template get_index_set<shape_dim, 0>());
73 const Index num_verts(mesh.get_num_entities(0));
76 vector = VectorOut_(num_verts, DataType(0));
79 std::vector<int> aux(num_verts, 0);
82 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
85 typename AsmTraits::SpaceEvaluator space_eval(space);
88 typename AsmTraits::DofMapping dof_mapping(space);
91 typename AsmTraits::TrafoEvalData trafo_data;
94 typename AsmTraits::SpaceEvalData space_data;
97 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
100 typename VectorIn_::GatherAxpy gather_axpy(coeff);
103 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
109 dof_mapping.prepare(cell);
112 gather_axpy(loc_vec, dof_mapping);
115 dof_mapping.finish();
118 trafo_eval.prepare(cell);
121 space_eval.prepare(trafo_eval);
124 int num_loc_dofs = space_eval.get_num_local_dofs();
127 for(
int k(0); k < nverts; ++k)
129 typename AsmTraits::DomainPointType
dom_point;
132 for(
int i(0); i < shape_dim; ++i)
141 space_eval(space_data, trafo_data);
144 ValueType
value(DataType(0));
147 for(
int i(0); i < num_loc_dofs; ++i)
156 Index vi = vert_idx(cell, k);
159 vector(vi, vector(vi) +
value);
175 for(
Index i(0); i < num_verts; ++i)
179 vector(i, (DataType(1) / DataType(aux[i])) * vector(i));
204 const VectorIn_& coeff,
207 typedef Space_ SpaceType;
208 typedef typename SpaceType::TrafoType TrafoType;
209 typedef typename TrafoType::MeshType MeshType;
210 typedef typename MeshType::ShapeType ShapeType;
212 static constexpr int shape_dim = ShapeType::dimension;
217 typedef typename AsmTraits::DataType DataType;
220 typedef typename VectorOut_::ValueType ValueOutType;
221 typedef typename VectorIn_::ValueType ValueInType;
224 const TrafoType& trafo(space.get_trafo());
225 const MeshType& mesh(space.get_mesh());
228 typedef typename MeshType::template IndexSet<shape_dim, 0>::Type IndexSetType;
229 const IndexSetType& vert_idx(mesh.template get_index_set<shape_dim, 0>());
232 const Index num_verts(mesh.get_num_entities(0));
235 vector = VectorOut_(num_verts, DataType(0));
238 std::vector<int> aux(num_verts, 0);
241 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
244 typename AsmTraits::SpaceEvaluator space_eval(space);
247 typename AsmTraits::DofMapping dof_mapping(space);
250 typename AsmTraits::TrafoEvalData trafo_data;
253 typename AsmTraits::SpaceEvalData space_data;
256 typename AsmTraits::template TLocalVector<ValueInType> loc_vec;
259 typename VectorIn_::GatherAxpy gather_axpy(coeff);
262 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
268 dof_mapping.prepare(cell);
271 gather_axpy(loc_vec, dof_mapping);
274 dof_mapping.finish();
277 trafo_eval.prepare(cell);
280 space_eval.prepare(trafo_eval);
283 int num_loc_dofs = space_eval.get_num_local_dofs();
286 for(
int k(0); k < nverts; ++k)
288 typename AsmTraits::DomainPointType
dom_point;
291 for(
int i(0); i < shape_dim; ++i)
300 space_eval(space_data, trafo_data);
303 ValueOutType
value(DataType(0));
306 for(
int i(0); i < num_loc_dofs; ++i)
315 Index vi = vert_idx(cell, k);
318 vector(vi, vector(vi) +
value);
333 ValueOutType* vv = vector.elements();
336 for(
Index i(0); i < num_verts; ++i)
340 vv[i] *= (DataType(1) / DataType(aux[i]));
375 const VectorIn_& coeff,
379 project(vector, coeff, space, cubature_factory);
403 const VectorIn_& coeff,
405 const String& cubature_name)
408 project(vector, coeff, space, cubature_factory);
426 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
429 const VectorIn_& coeff,
433 typedef Space_ SpaceType;
434 typedef typename SpaceType::TrafoType TrafoType;
435 typedef typename TrafoType::MeshType MeshType;
436 typedef typename MeshType::ShapeType ShapeType;
440 typedef typename AsmTraits::DataType DataType;
443 typedef typename VectorOut_::ValueType ValueType;
446 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
449 const TrafoType& trafo(space.get_trafo());
450 const MeshType& mesh(space.get_mesh());
453 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
456 vector = VectorOut_(num_cells, DataType(0));
459 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
462 typename AsmTraits::SpaceEvaluator space_eval(space);
465 typename AsmTraits::DofMapping dof_mapping(space);
468 typename AsmTraits::TrafoEvalData trafo_data;
471 typename AsmTraits::SpaceEvalData space_data;
474 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
477 typename VectorIn_::GatherAxpy gather_axpy(coeff);
480 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
486 dof_mapping.prepare(cell);
489 gather_axpy(loc_vec, dof_mapping);
492 dof_mapping.finish();
495 trafo_eval.prepare(cell);
498 space_eval.prepare(trafo_eval);
501 int num_loc_dofs = space_eval.get_num_local_dofs();
504 DataType
value(DataType(0));
505 DataType area(DataType(0));
508 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
511 trafo_eval(trafo_data, cubature_rule.get_point(k));
514 space_eval(space_data, trafo_data);
516 ValueType val(DataType(0));
519 for(
int i(0); i < num_loc_dofs; ++i)
522 Tiny::axpy(val, loc_vec[i], space_data.phi[i].value);
527 DataType weight(trafo_data.jac_det * cubature_rule.get_weight(k));
533 value += weight * val;
539 vector(cell, (DataType(1) / area) *
value);
571 const VectorIn_& coeff,
573 const String& cubature_name)
594 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
597 const VectorIn_& coeff,
601 typedef Space_ SpaceType;
602 typedef typename SpaceType::TrafoType TrafoType;
603 typedef typename TrafoType::MeshType MeshType;
604 typedef typename MeshType::ShapeType ShapeType;
608 typedef typename AsmTraits::DataType DataType;
611 typedef typename VectorIn_::ValueType ValueInType;
612 typedef typename VectorOut_::ValueType ValueOutType;
615 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
618 const TrafoType& trafo(space.get_trafo());
619 const MeshType& mesh(space.get_mesh());
622 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
625 vector = VectorOut_(num_cells, DataType(0));
628 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
631 typename AsmTraits::SpaceEvaluator space_eval(space);
634 typename AsmTraits::DofMapping dof_mapping(space);
637 typename AsmTraits::TrafoEvalData trafo_data;
640 typename AsmTraits::SpaceEvalData space_data;
643 typename AsmTraits::template TLocalVector<ValueInType> loc_vec;
646 typename VectorIn_::GatherAxpy gather_axpy(coeff);
649 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
655 dof_mapping.prepare(cell);
658 gather_axpy(loc_vec, dof_mapping);
661 dof_mapping.finish();
664 trafo_eval.prepare(cell);
667 space_eval.prepare(trafo_eval);
670 int num_loc_dofs = space_eval.get_num_local_dofs();
673 ValueOutType
value(DataType(0));
674 DataType area(DataType(0));
677 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
680 trafo_eval(trafo_data, cubature_rule.get_point(k));
683 space_eval(space_data, trafo_data);
685 ValueOutType val(DataType(0));
688 for(
int i(0); i < num_loc_dofs; ++i)
691 Tiny::axpy(val, space_data.phi[i].grad, loc_vec[i]);
696 DataType weight(trafo_data.jac_det * cubature_rule.get_weight(k));
708 vector(cell, (DataType(1) / area) *
value);
730 template<
typename VectorOut_,
typename VectorIn_,
typename Space_>
731 static void project_refined(VectorOut_& vector,
const VectorIn_& coeff,
const Space_& space)
733 typedef Space_ SpaceType;
734 typedef typename SpaceType::TrafoType TrafoType;
735 typedef typename TrafoType::MeshType MeshType;
736 typedef typename MeshType::ShapeType ShapeType;
740 typedef typename AsmTraits::DataType DataType;
743 typedef typename VectorOut_::ValueType ValueType;
747 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
750 const TrafoType& trafo(space.get_trafo());
751 const MeshType& mesh(space.get_mesh());
754 const Index num_cells(mesh.get_num_entities(ShapeType::dimension));
755 const int num_points = cubature_rule.get_num_points();
758 vector = VectorOut_(num_cells *
Index(num_points), DataType(0));
761 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
764 typename AsmTraits::SpaceEvaluator space_eval(space);
767 typename AsmTraits::DofMapping dof_mapping(space);
770 typename AsmTraits::TrafoEvalData trafo_data;
773 typename AsmTraits::SpaceEvalData space_data;
776 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
779 typename VectorIn_::GatherAxpy gather_axpy(coeff);
782 for(
Index cell(0); cell < trafo_eval.get_num_cells(); ++cell)
788 dof_mapping.prepare(cell);
791 gather_axpy(loc_vec, dof_mapping);
794 dof_mapping.finish();
797 trafo_eval.prepare(cell);
800 space_eval.prepare(trafo_eval);
803 int num_loc_dofs = space_eval.get_num_local_dofs();
806 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
809 trafo_eval(trafo_data, cubature_rule.get_point(k));
812 space_eval(space_data, trafo_data);
814 ValueType
value(DataType(0));
817 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.
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.