8#include <kernel/assembly/asm_traits.hpp>
9#include <kernel/assembly/symbolic_assembler.hpp>
10#include <kernel/lafem/sparse_matrix_bcsr.hpp>
54 typename DataType_,
typename IndexType_,
int dim_,
55 typename SpaceVelo_,
typename SpacePres_>
59 const SpaceVelo_& space_velo,
60 const SpacePres_& space_pres,
61 const String& cubature_name,
62 const DataType_ scale_b = -DataType_(1),
63 const DataType_ scale_d = -DataType_(1)
67 assemble(matrix_b, matrix_d, space_velo, space_pres, cubature_factory, scale_b, scale_d);
90 typename DataType_,
typename IndexType_,
int dim_,
91 typename SpaceVelo_,
typename SpacePres_>
95 const SpaceVelo_& space_velo,
96 const SpacePres_& space_pres,
98 const DataType_ scale_b = -DataType_(1),
99 const DataType_ scale_d = -DataType_(1)
102 typedef DataType_ DataType;
105 static_assert(SpaceVelo_::shape_dim == dim_,
"invalid matrix block sizes");
108 XASSERTM((&space_velo.get_trafo()) == (&space_pres.get_trafo()),
109 "Velocity and Pressure spaces must be defined on the same trafo!");
124 const typename AsmTraits::TrafoType& trafo = space_velo.get_trafo();
127 typename AsmTraits::TrafoEvaluator trafo_eval(trafo);
130 typename AsmTraits::TestEvaluator velo_eval(space_velo);
131 typename AsmTraits::TrialEvaluator pres_eval(space_pres);
134 typename AsmTraits::TestDofMapping velo_dof_mapping(space_velo);
135 typename AsmTraits::TrialDofMapping pres_dof_mapping(space_pres);
138 typename AsmTraits::TrafoEvalData trafo_data;
141 typename AsmTraits::TestEvalData velo_data;
142 typename AsmTraits::TrialEvalData pres_data;
145 static constexpr int max_velo_dofs = AsmTraits::max_local_test_dofs;
146 static constexpr int max_pres_dofs = AsmTraits::max_local_trial_dofs;
156 typename AsmTraits::CubatureRuleType cubature_rule(Cubature::ctor_factory, cubature_factory);
162 matrix_b = MatrixB(graph_b);
168 matrix_d = MatrixD(graph_d);
174 typename MatrixB::ScatterAxpy scatter_b(matrix_b);
175 typename MatrixD::ScatterAxpy scatter_d(matrix_d);
178 for(
typename AsmTraits::CellIterator cell(trafo_eval.begin()); cell != trafo_eval.end(); ++cell)
181 trafo_eval.prepare(cell);
184 velo_eval.prepare(trafo_eval);
185 pres_eval.prepare(trafo_eval);
188 const int num_loc_velo_dofs = velo_eval.get_num_local_dofs();
189 const int num_loc_pres_dofs = pres_eval.get_num_local_dofs();
196 for(
int pt(0); pt < cubature_rule.get_num_points(); ++pt)
199 trafo_eval(trafo_data, cubature_rule.get_point(pt));
202 velo_eval(velo_data, trafo_data);
203 pres_eval(pres_data, trafo_data);
206 for(
int i(0); i < num_loc_velo_dofs; ++i)
209 for(
int j(0); j < num_loc_pres_dofs; ++j)
211 const DataType pv = trafo_data.jac_det * cubature_rule.get_weight(pt) * pres_data.phi[j].value;
214 for(
int k(0); k < dim_; ++k)
216 local_b[i][j][k][0] += velo_data.phi[i].grad[k] * pv;
217 local_d[j][i][0][k] += velo_data.phi[i].grad[k] * pv;
233 velo_dof_mapping.prepare(cell);
234 pres_dof_mapping.prepare(cell);
237 scatter_b(local_b, velo_dof_mapping, pres_dof_mapping, scale_b);
238 scatter_d(local_d, pres_dof_mapping, velo_dof_mapping, scale_d);
241 pres_dof_mapping.finish();
242 velo_dof_mapping.finish();
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Adjacency Graph implementation.
Common test-/trial-space assembly traits class template.
Grad(P)/Div(V) assembler class.
static void assemble(LAFEM::SparseMatrixBCSR< DataType_, IndexType_, dim_, 1 > &matrix_b, LAFEM::SparseMatrixBCSR< DataType_, IndexType_, 1, dim_ > &matrix_d, const SpaceVelo_ &space_velo, const SpacePres_ &space_pres, const String &cubature_name, const DataType_ scale_b=-DataType_(1), const DataType_ scale_d=-DataType_(1))
Assembles the B and D matrices.
static void assemble(LAFEM::SparseMatrixBCSR< DataType_, IndexType_, dim_, 1 > &matrix_b, LAFEM::SparseMatrixBCSR< DataType_, IndexType_, 1, dim_ > &matrix_d, const SpaceVelo_ &space_velo, const SpacePres_ &space_pres, const Cubature::DynamicFactory &cubature_factory, const DataType_ scale_b=-DataType_(1), const DataType_ scale_d=-DataType_(1))
Assembles the B and D matrices.
static Adjacency::Graph assemble_graph_std2(const TestSpace_ &test_space, const TrialSpace_ &trial_space)
Assembles the standard Dof-Adjacency graph for different test- and trial-spaces.
bool empty() const
Checks whether the container is empty.
void format(DT_ value=DT_(0))
Reset all elements of the container to a given value or zero if missing.
CSR based blocked sparse matrix.
String class implementation.
Tiny Matrix class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the matrix.
@ value
specifies whether the space should supply basis function values
@ grad
specifies whether the space should supply basis function gradients
@ jac_det
specifies whether the trafo should supply jacobian determinants