FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
macro_factory.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
9#include <kernel/geometry/conformal_mesh.hpp>
10#include <kernel/geometry/mesh_part.hpp>
11#include <kernel/geometry/intern/macro_index_mapping.hpp>
12
13namespace FEAT
14{
15 namespace Geometry
16 {
18 template<typename Mesh_>
20
22 template<
23 typename Shape_,
24 int num_coords_,
25 typename Coord_>
26 class MacroFactory<ConformalMesh<Shape_, num_coords_, Coord_> > :
27 public Factory<ConformalMesh<Shape_, num_coords_, Coord_> >
28 {
29 public:
33 typedef typename MeshType::VertexSetType VertexSetType;
35 typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
36
37 protected:
38 const MeshType& _base_mesh;
39 const Index _cell_idx;
40
41 public:
42 explicit MacroFactory(const MeshType& base_mesh, Index cell_idx) :
43 _base_mesh(base_mesh),
44 _cell_idx(cell_idx)
45 {
46 XASSERTM(cell_idx < base_mesh.get_num_entities(Shape_::dimension), "cell index out-of-bounds");
47 }
48
49 virtual Index get_num_entities(int dim) override
50 {
51 return Index(Intern::DynamicNumFaces<Shape_>::value(dim));
52 }
53
54 virtual void fill_vertex_set(VertexSetType& vertex_set) override
55 {
56 // fetch the cell's vertex indices
57 typedef typename MeshType::template IndexSet<Shape_::dimension, 0>::Type IndexSetType;
58 const IndexSetType& idx(_base_mesh.template get_index_set<Shape_::dimension, 0>());
59
60 // fetch base-mesh vertex set
61 const VertexSetType& vertex_set_in(_base_mesh.get_vertex_set());
62
63 // loop over all vertices
64 for(Index i(0); i < Index(IndexSetType::num_indices); ++i)
65 {
66 vertex_set[i] = vertex_set_in[idx(_cell_idx, i)];
67 }
68 }
69
70 virtual void fill_index_sets(IndexSetHolderType& index_set_holder) override
71 {
72 Intern::MacroIndexWrapper<Shape_>::build(index_set_holder);
73 }
74 };
75
76 template<typename BaseMesh_>
77 class MacroFactory<MeshPart<BaseMesh_> > :
78 public Factory<MeshPart<BaseMesh_> >
79 {
80 public:
82 typedef MeshPart<BaseMesh_> MeshType;
83 typedef typename MeshType::ShapeType ShapeType;
84
85 typedef typename MeshType::TargetSetHolderType TargetSetHolderType;
86 typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
87 typedef typename MeshType::AttributeSetContainer AttributeSetContainer;
88
89 protected:
90 const BaseMesh_& _base_mesh;
91 const Index _cell_idx;
92
93 public:
94 explicit MacroFactory(const BaseMesh_& base_mesh, Index cell_idx) :
95 _base_mesh(base_mesh),
96 _cell_idx(cell_idx)
97 {
98 XASSERTM(cell_idx < base_mesh.get_num_entities(ShapeType::dimension), "cell index out-of-bounds");
99 }
100
101 virtual Index get_num_entities(int dim) override
102 {
103 return Index(Intern::DynamicNumFaces<ShapeType>::value(dim));
104 }
105
106 virtual void fill_attribute_sets(AttributeSetContainer&) override
107 {
108 // nothing to do here
109 }
110
111 virtual void fill_index_sets(std::unique_ptr<IndexSetHolderType>&) override
112 {
113 // nothing to do here
114 }
115
116 virtual void fill_target_sets(TargetSetHolderType& target_set_holder) override
117 {
118 // set cell index
119 target_set_holder.template get_target_set<ShapeType::dimension>()[0] = _cell_idx;
120 // fill remaining indices
121 Intern::MacroTargetWrapper<ShapeType>::build(target_set_holder, _base_mesh.get_index_set_holder(), _cell_idx);
122 }
123 };
125 } // namespace Geometry
126} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
Conformal mesh class template.
Mesh Factory class template.
Definition: factory.hpp:33
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.