8#include <kernel/assembly/trace_assembler.hpp>
9#include <kernel/assembly/function_integral_info.hpp>
10#include <kernel/geometry/intern/face_index_mapping.hpp>
11#include <kernel/geometry/intern/face_ref_trafo.hpp>
12#include <kernel/geometry/intern/congruency_sampler.hpp>
13#include <kernel/geometry/intern/congruency_trafo.hpp>
26 Index glob_dofs[max_];
31 explicit CommonDofMap() : num_dofs(0) {}
38 int push_1(Index dof,
int loc)
40 for(
int i(0); i < num_dofs; ++i)
42 if(dof == glob_dofs[i])
49 glob_dofs[num_dofs] = dof;
50 loc1_dofs[num_dofs] = loc;
51 loc2_dofs[num_dofs] = -1;
55 int push_2(Index dof,
int loc)
57 for(
int i(0); i < num_dofs; ++i)
59 if(dof == glob_dofs[i])
66 glob_dofs[num_dofs] = dof;
67 loc1_dofs[num_dofs] = -1;
68 loc2_dofs[num_dofs] = loc;
72 int loc_1(
int k)
const
77 int loc_2(
int k)
const
82 int get_num_local_dofs()
const
87 Index get_index(
int i)
const
100 template<
typename DataType_,
typename Space_, TrafoTags trafo_config_, TrafoTags facet_trafo_config_, SpaceTags space_config_>
105 static constexpr bool assemble_pairwise =
true;
138 typedef typename TrafoFacetEvaluator::template ConfigTraits<facet_trafo_config>::EvalDataType
TrafoFacetEvalData;
168 static constexpr int max_common_dofs = 2 * AsmTraits::max_local_test_dofs;
169 Intern::CommonDofMap<max_common_dofs> common_map;
203 dof_mapping_2(
space),
221 void prepare(
Index facet,
Index cell,
int local_facet,
int facet_ori)
227 Geometry::Intern::FaceRefTrafo<ShapeType, facet_dim>::compute(
face_mat_1, face_vec_1, local_facet);
230 Geometry::Intern::CongruencyTrafo<FacetType>::compute(ori_mat_1, ori_vec_1, facet_ori);
233 cell_facet_ori_1 = Geometry::Intern::CongruencySampler<FacetType>::orientation(facet_ori)
250 void prepare(
Index facet,
Index cell_1,
Index cell_2,
int local_facet_1,
int local_facet_2,
int facet_ori_1,
int facet_ori_2)
256 Geometry::Intern::FaceRefTrafo<ShapeType, facet_dim>::compute(
face_mat_1, face_vec_1, local_facet_1);
257 Geometry::Intern::FaceRefTrafo<ShapeType, facet_dim>::compute(face_mat_2, face_vec_2, local_facet_2);
260 Geometry::Intern::CongruencyTrafo<FacetType>::compute(ori_mat_1, ori_vec_1, facet_ori_1);
261 Geometry::Intern::CongruencyTrafo<FacetType>::compute(ori_mat_2, ori_vec_2, facet_ori_2);
264 cell_facet_ori_1 = Geometry::Intern::CongruencySampler<FacetType>::orientation(facet_ori_1)
266 cell_facet_ori_2 = Geometry::Intern::CongruencySampler<FacetType>::orientation(facet_ori_2)
272 trafo_eval_2.prepare(cell_2);
274 space_eval_2.prepare(trafo_eval_2);
278 dof_mapping_2.prepare(cell_2);
284 for(
int i(0); i < dof_mapping_2.get_num_local_dofs(); ++i)
285 common_map.push_2(dof_mapping_2.get_index(i), i);
288 void prepare_point(Tiny::Vector<DataType, facet_dim>& pt)
319 cur_point_2 = (face_mat_2 * ((ori_mat_2 *
cur_point_facet) + ori_vec_2)) + face_vec_2;
322 trafo_eval_2(trafo_data_2, cur_point_2);
328 if(cell_facet_ori_2 < 0)
329 trafo_data_2.normal.negate();
332 space_eval_2(space_data_2, trafo_data_2);
339 dof_mapping_2.finish();
340 space_eval_2.finish();
341 trafo_eval_2.finish();
378 template<
typename Derived_,
typename Matrix_,
typename Space_,
381 public TraceAssemblyJumpTaskBase1<typename Matrix_::DataType, Space_, trafo_config_, facet_trafo_config_ | TrafoTags::jac_det, space_config_>
399 using typename BaseClass::SpaceBasisData;
401 using BaseClass::max_common_dofs;
487 const SpaceBasisData& psi_1,
const SpaceBasisData& psi_2,
488 const SpaceBasisData& phi_1,
const SpaceBasisData& phi_2);
500 const int num_loc_dofs = this->common_map.get_num_local_dofs();
506 static_cast<Derived_&
>(*this).prepare_point(
cubature_rule.get_point(k));
509 static_cast<Derived_&
>(*this).set_point(this->trafo_facet_data, this->cell_pair, this->trafo_data_1, this->trafo_data_2);
512 for(
int i(0); i < num_loc_dofs; ++i)
514 const int i_1 = this->common_map.loc_1(i);
515 const int i_2 = this->common_map.loc_2(i);
516 const SpaceBasisData& psi_1 = (i_1 > -1 ? this->space_data_1.phi[i_1] : this->
null_basis_data);
517 const SpaceBasisData& psi_2 = (i_2 > -1 ? this->space_data_2.phi[i_2] : this->
null_basis_data);
520 for(
int j(0); j < num_loc_dofs; ++j)
522 const int j_1 = this->common_map.loc_1(j);
523 const int j_2 = this->common_map.loc_2(j);
524 const SpaceBasisData& phi_1 = (j_1 > -1 ? this->space_data_1.phi[j_1] : this->
null_basis_data);
525 const SpaceBasisData& phi_2 = (j_2 > -1 ? this->space_data_2.phi[j_2] : this->
null_basis_data);
529 this->trafo_facet_data.jac_det *
cubature_rule.get_weight(k),
530 this->
cell_pair, psi_1, psi_2, phi_1, phi_2);
567 template<
typename Matrix_,
typename Space_>
571 typedef typename Matrix_::DataType DataType;
572 typedef typename Matrix_::ValueType ValueType;
586 using typename BaseClass::SpaceBasisData;
598 jacdet_power(job.jacdet_power),
610 const SpaceBasisData& psi_1,
const SpaceBasisData& psi_2,
611 const SpaceBasisData& phi_1,
const SpaceBasisData& phi_2)
653 DataType gamma_ = DataType(1), DataType jacdet_scale_ = DataType(2), DataType jacdet_power_ = DataType(2)) :
659 jacdet_power(jacdet_power_)
688 template<
typename Trafo_,
typename Matrix_,
typename Space_>
690 Matrix_& matrix,
const Space_& space,
const String& cubature,
691 const typename Matrix_::DataType gamma =
typename Matrix_::DataType(1),
692 const typename Matrix_::DataType jacdet_scale =
typename Matrix_::DataType(2),
693 const typename Matrix_::DataType jacdet_power =
typename Matrix_::DataType(2))
695 XASSERTM(trace_asm.
get_trafo() == space.get_trafo(),
"trace assembler and space have different trafos");
696 XASSERTM(matrix.columns() == space.get_num_dofs(),
"invalid matrix column count");
697 XASSERTM(matrix.rows() == space.get_num_dofs(),
"invalid matrix row count");
700 gamma, jacdet_scale, jacdet_power);
718 template<
typename Matrix_,
typename Space_>
722 typedef typename Matrix_::DataType DataType;
723 typedef typename Matrix_::ValueType ValueType;
737 using typename BaseClass::SpaceBasisData;
745 void eval(ValueType& val,
const DataType& weight,
bool,
746 const SpaceBasisData& psi_1,
const SpaceBasisData& psi_2,
747 const SpaceBasisData& phi_1,
const SpaceBasisData& phi_2)
749 Tiny::add_id(val, weight * (psi_2.value - psi_1.value) * (phi_2.value - phi_1.value));
806 template<
typename Trafo_,
typename Matrix_,
typename Space_>
808 Matrix_& matrix,
const Space_& space,
const String& cubature,
809 const typename Matrix_::DataType alpha =
typename Matrix_::DataType(1))
811 XASSERTM(trace_asm.
get_trafo() == space.get_trafo(),
"trace assembler and space have different trafos");
812 XASSERTM(matrix.columns() == space.get_num_dofs(),
"invalid matrix column count");
813 XASSERTM(matrix.rows() == space.get_num_dofs(),
"invalid matrix row count");
#define ASSERT(expr)
Debug-Assertion macro definition.
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Common single-space assembly traits class template.
TrafoType::template Evaluator< ShapeType, DataType >::Type TrafoEvaluator
trafo evaluator type
SpaceEvalData::BasisDataType SpaceBasisData
basis function data types
SpaceEvaluator::template ConfigTraits< space_config >::EvalDataType SpaceEvalData
space evaluation data types
DataType_ DataType
data type
SpaceType::TrafoType TrafoType
trafo type
SpaceType::DofMappingType DofMapping
dof-mapping types
TrafoEvaluator::template ConfigTraits< trafo_config >::EvalDataType TrafoEvalData
trafo evaluation data type
SpaceType::template Evaluator< TrafoEvaluator >::Type SpaceEvaluator
space evaluator types
Space_ SpaceType
space type
Trace Integral Assembler class template.
void assemble(Job_ &job)
Executes a trace assembly job.
const TrafoType & get_trafo() const
TraceAssemblyJumpMatrixTaskCRTP1< Task, Matrix_, Space_, TrafoTags::none, TrafoTags::none, SpaceTags::value > BaseClass
our base-class typedef
BaseClass::AsmTraits AsmTraits
our assembly traits
Matrix assembly job for the mass jump operator.
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
TraceAssemblyJumpMassMatrixJob(Matrix_ &matrix_, const Space_ &space_, String cubature_, DataType alpha_=DataType(1))
Constructor.
DataType alpha
the scaling factor for the assembly.
Matrix_ & matrix
a reference to the matrix that is to be assembled
Jump Matrix assembly task CRTP base-class for identical test-/trial-space.
void eval(ValueType &val, const DataType &weight, bool is_pair, const SpaceBasisData &psi_1, const SpaceBasisData &psi_2, const SpaceBasisData &phi_1, const SpaceBasisData &phi_2)
Evaluates the assembly for the a test-/trial-basis function pair.
DataType scatter_alpha
the scatter scaling factor
Tiny::Matrix< ValueType, max_common_dofs, max_common_dofs > local_matrix
the local matrix to be assembled
static constexpr bool need_combine
this task has no combine
Matrix_::ScatterAxpy scatter_axpy
the matrix scatter object
void assemble()
Performs the local assembly.
static constexpr bool need_scatter
this task needs to scatter
TraceAssemblyJumpTaskBase1< typename Matrix_::DataType, Space_, trafo_config_, facet_trafo_config_|TrafoTags::jac_det, space_config_ > BaseClass
our base class
Matrix_::ValueType ValueType
the value-type of the matrix
void scatter()
Scatters the local assembly.
Matrix_::DataType DataType
the data-type of the matrix
void combine()
Finalizes the assembly.
BaseClass::CubatureRuleType cubature_rule
the cubature rule used for integration
TraceAssemblyJumpMatrixTaskCRTP1(Matrix_ &matrix_, const Space_ &space_, const Cubature::DynamicFactory &cubature_factory, DataType alpha_)
Constructor.
AsmTraits::TrafoEvalData TrafoEvalData
trafo evaluation data
Matrix_ & matrix
the matrix that is to be assembled
TrafoFacetEvaluator::template ConfigTraits< facet_trafo_config >::EvalDataType TrafoFacetEvalData
trafo facet evaluation data
void set_point(TrafoFacetEvalData &tau_f, bool is_pair, TrafoEvalData &tau_1, TrafoEvalData &tau_2)
Sets the current cubature point.
DataType point_scale
h-dependent point-wise scaling factor
BaseClass::AsmTraits AsmTraits
our assembly traits
TraceAssemblyJumpMatrixTaskCRTP1< Task, Matrix_, Space_, TrafoTags::none, TrafoTags::jac_det, SpaceTags::grad > BaseClass
our base-class typedef
const DataType jacdet_scale
stabilization parameters
Matrix assembly job for the edge-oriented jump stabilization operator.
DataType gamma
the scaling factor for the assembly.
TraceAssemblyJumpStabilizationMatrixJob(Matrix_ &matrix_, const Space_ &space_, String cubature_, DataType gamma_=DataType(1), DataType jacdet_scale_=DataType(2), DataType jacdet_power_=DataType(2))
Constructor.
DataType jacdet_scale
stabilization parameters
Cubature::DynamicFactory cubature_factory
the cubature factory to be used for integration
Matrix_ & matrix
a reference to the matrix that is to be assembled
const Space_ & space
a reference to the finite element space to be used as test-/trial-space
Basic assembly task base class for a single finite element space with pairwise assembly support.
bool cell_pair
are assembling a cell pair
SpaceEvaluator space_eval_1
the space evaluator
TrafoEvalData trafo_data_1
the trafo evaluation data
TrafoType::ShapeType ShapeType
our shape type
TrafoEvaluator trafo_eval_1
the trafo evaluator
AsmTraits::TrafoEvaluator TrafoEvaluator
trafo evaluator type
Assembly::AsmTraits1< DataType_, Space_, trafo_config_, space_config_ > AsmTraits
our assembly traits
AsmTraits::SpaceType SpaceType
space type
static constexpr int facet_dim
the facet dimension; always equal to shape_dim-1
static constexpr int shape_dim
the shape dimension
Tiny::Vector< DataType, shape_dim > cur_point_1
current cubature point on reference cell
AsmTraits::DofMapping dof_mapping_1
the space dof-mapping
const TrafoType & trafo
the trafo
SpaceEvalData space_data_1
the space evaluation data
TrafoFacetEvaluator trafo_facet_eval
the trafo facet evaluator
AsmTraits::SpaceEvalData SpaceEvalData
space evaluation data
const SpaceType & space
the space
Shape::FaceTraits< ShapeType, ShapeType::dimension-1 >::ShapeType FacetType
our facet type
Tiny::Matrix< DataType, shape_dim, facet_dim > face_mat_1
local facet trafo matrices and vectors
static constexpr TrafoTags facet_trafo_config
include jacobian in facet trafo config (required for normal vector computation)
AsmTraits::BasisData null_basis_data
null-basis data
Intern::CubatureTraits< TrafoFacetEvaluator >::RuleType CubatureRuleType
cubature rule type
AsmTraits::TrafoEvalData TrafoEvalData
trafo evaluation data
AsmTraits::TrafoType TrafoType
trafo type
AsmTraits::DataType DataType
our data type
int cell_facet_ori_1
the internal cell facet orientation code
TrafoFacetEvalData trafo_facet_data
the trafo facet evaluation data
Tiny::Vector< DataType, facet_dim > cur_point_facet
current cubature point on reference facet
TrafoType::template Evaluator< FacetType, DataType >::Type TrafoFacetEvaluator
trafo facet evaluator type
AsmTraits::SpaceEvaluator SpaceEvaluator
space evaluator type
TrafoFacetEvaluator::template ConfigTraits< facet_trafo_config >::EvalDataType TrafoFacetEvalData
trafo facet evaluation data
String class implementation.
Tiny Matrix class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the matrix.
Tiny Vector class template.
CUDA_HOST_DEVICE void format(DataType alpha=DataType(0))
Formats the vector.
void assemble_jump_stabilization_matrix(TraceAssembler< Trafo_ > &trace_asm, Matrix_ &matrix, const Space_ &space, const String &cubature, const typename Matrix_::DataType gamma=typename Matrix_::DataType(1), const typename Matrix_::DataType jacdet_scale=typename Matrix_::DataType(2), const typename Matrix_::DataType jacdet_power=typename Matrix_::DataType(2))
Assembles edge-oriented jump stabilization operator into a matrix.
void assemble_jump_mass_matrix(TraceAssembler< Trafo_ > &trace_asm, Matrix_ &matrix, const Space_ &space, const String &cubature, const typename Matrix_::DataType alpha=typename Matrix_::DataType(1))
Assembles mass jump operator into a matrix.
T_ pow(T_ x, T_ y)
Returns x raised to the power of y.
CUDA_HOST_DEVICE T_ dot(const T_ &a, const T_ &b)
Computes the dot-product of two scalars.
CUDA_HOST_DEVICE void add_id(T_ &x, const T_ &alpha)
Adds a scaled identity onto a scalar.
Vector< T_, m_ > orthogonal(const Matrix< T_, m_, m_-1, sm_, sn_ > &tau)
Computes the positively oriented orthogonal vector to the columns of a m_ x (m_-1) Matrix.
SpaceTags
Space configuration tags enum.
std::uint64_t Index
Index data type.
TrafoTags
Trafo configuration tags enum.
@ jac_mat
specifies whether the trafo should supply jacobian matrices
Face traits tag struct template.
static int facet_orientation(int facet_index)
Returns the orientation of a facet.