9#include <kernel/assembly/asm_traits.hpp>
46 typename CubatureFactory_,
50 const Functional_& functional,
52 const CubatureFactory_& cubature_factory,
53 typename Vector_::DataType alpha =
typename Vector_::DataType(1))
56 XASSERTM(vector.size() == space.get_num_dofs(),
"invalid vector size");
59 typedef Vector_ VectorType;
61 typedef Functional_ FunctionalType;
63 typedef Space_ SpaceType;
67 typename VectorType::DataType,
69 FunctionalType::trafo_config,
70 FunctionalType::test_config> AsmTraits;
73 const typename AsmTraits::TrafoType& trafo = space.get_trafo();
76 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
79 typename AsmTraits::TestEvaluator test_eval(space);
82 typename AsmTraits::DofMapping dof_mapping(space);
85 typename FunctionalType::template Evaluator<AsmTraits> func_eval(functional);
88 typename AsmTraits::TrafoEvalData trafo_data;
91 typename AsmTraits::TestEvalData test_data;
94 typedef typename FunctionalType::template Evaluator<AsmTraits>::ValueType ValueType;
97 static_assert(std::is_same<ValueType, typename VectorType::ValueType>::value,
98 "vector and linear functional have different value types!");
101 typename AsmTraits::template TLocalVector<ValueType> loc_vec;
104 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
107 typename VectorType::ScatterAxpy scatter_axpy(vector);
110 for(
typename AsmTraits::CellIterator cell(trafo_eval.begin()); cell != trafo_eval.end(); ++cell)
113 trafo_eval.prepare(cell);
116 test_eval.prepare(trafo_eval);
119 func_eval.prepare(trafo_eval);
122 int num_loc_dofs = test_eval.get_num_local_dofs();
128 for(
int k(0); k < cubature_rule.get_num_points(); ++k)
131 trafo_eval(trafo_data, cubature_rule.get_point(k));
134 test_eval(test_data, trafo_data);
137 func_eval.set_point(trafo_data);
140 for(
int i(0); i < num_loc_dofs; ++i)
143 Tiny::axpy(loc_vec(i), func_eval.eval(test_data.phi[i]),
144 trafo_data.jac_det * cubature_rule.get_weight(k));
158 dof_mapping.prepare(cell);
161 scatter_axpy(loc_vec, dof_mapping, alpha);
164 dof_mapping.finish();
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Common single-space assembly traits class template.
Linear Functional Assembly class template.
static void assemble_vector(Vector_ &vector, const Functional_ &functional, const Space_ &space, const CubatureFactory_ &cubature_factory, typename Vector_::DataType alpha=typename Vector_::DataType(1))
Assembles a linear functional into a vector.
CUDA_HOST_DEVICE void axpy(T_ &y, const T_ &x, const T_ &alpha)
Performs an AXPY of two scalars.