OGS
LocalAssemblerFactory.h
Go to the documentation of this file.
1
11#pragma once
12
15
16namespace ProcessLib
17{
18namespace BoundaryConditionAndSourceTerm
19{
20template <typename LocalAssemblerInterface,
21 template <typename, typename, int>
22 class LocalAssemblerImplementation,
23 int GlobalDim,
24 typename... ConstructorArgs>
26 : public ProcessLib::GenericLocalAssemblerFactory<LocalAssemblerInterface,
27 ConstructorArgs...>
28{
29 using Base =
31 ConstructorArgs...>;
32
33 template <typename ShapeFunction>
37 LocalAssemblerImplementation,
38 GlobalDim,
39 ConstructorArgs...>;
40
42 {
43 template <typename ElementTraits>
44 constexpr bool operator()(ElementTraits*) const
45 {
46 return GlobalDim >= ElementTraits::ShapeFunction::DIM;
47 }
48 };
49
51 {
52 template <typename ElementTraits>
53 constexpr bool operator()(ElementTraits*) const
54 {
55 if constexpr (GlobalDim < ElementTraits::ShapeFunction::DIM)
56 {
57 return false;
58 }
59 return ElementTraits::ShapeFunction::ORDER == 2 ||
60 // points are needed for 2nd order, too
61 std::is_same_v<MeshLib::Point,
62 typename ElementTraits::Element>;
63 }
64 };
65
66public:
68 const unsigned shapefunction_order)
69 : Base(dof_table)
70 {
71 if (shapefunction_order < 1 || 2 < shapefunction_order)
72 {
73 OGS_FATAL("The given shape function order {:d} is not supported",
74 shapefunction_order);
75 }
76
77 if (shapefunction_order == 1)
78 {
79 // 1st order is enabled on all elements with suitable dimension
80 using EnabledElementTraits =
81 decltype(BaseLib::TMP::filter<EnabledElementTraitsLagrange>(
82 std::declval<HasSuitableDimension>()));
83
84 BaseLib::TMP::foreach<EnabledElementTraits>(
85 [this]<typename ET>(ET*)
86 {
87 using MeshElement = typename ET::Element;
88 // this will use linear shape functions on higher order
89 // elements and the linear shape function on linear elements
90 using LowerOrderShapeFunction =
91 typename ET::LowerOrderShapeFunction;
92 Base::_builders[std::type_index(typeid(MeshElement))] =
94 });
95 }
96 else if (shapefunction_order == 2)
97 {
98 // 2nd order only on 2nd order elements
99 using EnabledElementTraits =
100 decltype(BaseLib::TMP::filter<EnabledElementTraitsLagrange>(
101 std::declval<Is2ndOrderElementOfSuitableDimension>()));
102
103 BaseLib::TMP::foreach<EnabledElementTraits>(
104 [this]<typename ET>(ET*)
105 {
106 using MeshElement = typename ET::Element;
107 using ShapeFunction2ndOrder = typename ET::ShapeFunction;
108 Base::_builders[std::type_index(typeid(MeshElement))] =
110 });
111 }
112 }
113};
114
115} // namespace BoundaryConditionAndSourceTerm
116} // namespace ProcessLib
#define OGS_FATAL(...)
Definition: Error.h:26
LocalAssemblerFactory(NumLib::LocalToGlobalIndexMap const &dof_table, const unsigned shapefunction_order)
TemplateElement< PointRule1 > Point
Definition: Point.h:20
std::unordered_map< std::type_index, LocAsmBuilder > _builders
Mapping of element types to local assembler builders.