FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
patch_mesh_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/patch_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 PatchMeshFactory<ConformalMesh<Shape_, num_coords_, Coord_> > :
27 public Factory<ConformalMesh<Shape_, num_coords_, Coord_> >
28 {
29 public:
32 typedef MeshPart<MeshType> MeshPartType;
33
35 typedef typename MeshType::VertexSetType VertexSetType;
37 typedef typename MeshType::IndexSetHolderType IndexSetHolderType;
38
39 protected:
40 const MeshType& _base_mesh;
41 const MeshPartType& _patch_part;
42
43 public:
44 explicit PatchMeshFactory(const MeshType& base_mesh, const MeshPartType& patch_part) :
45 _base_mesh(base_mesh),
46 _patch_part(patch_part)
47 {
48 }
49
50 virtual ~PatchMeshFactory()
51 {
52 }
53
54 virtual Index get_num_entities(int dim) override
55 {
56 return _patch_part.get_num_entities(dim);
57 }
58
59 virtual void fill_vertex_set(VertexSetType& vertex_set) override
60 {
61 // fetch vertex-target-indices of the patch mesh
62 const typename MeshPartType::template TargetSet<0>::Type& idx(_patch_part.template get_target_set<0>());
63 typedef typename VertexSetType::VertexType VertexType;
64
65 // fetch base-mesh vertex set
66 const VertexSetType& vertex_set_in(_base_mesh.get_vertex_set());
67
68 // loop over all vertices
69 const Index num_verts(idx.get_num_entities());
70 for(Index i(0); i < num_verts; ++i)
71 {
72 VertexType& vo(vertex_set[i]);
73 const VertexType& vi(vertex_set_in[idx[i]]);
74 for(int j(0); j < num_coords_; ++j)
75 {
76 vo[j] = vi[j];
77 }
78 }
79 }
80
81 virtual void fill_index_sets(IndexSetHolderType& index_set_holder) override
82 {
83 // set up base-mesh num_entities
84 Index num_entities[Shape_::dimension + 1];
85 for(int i(0); i <= Shape_::dimension; ++i)
86 {
87 num_entities[i] = _base_mesh.get_num_entities(i);
88 }
89
90 // build index sets
91 Intern::PatchIndexMapping<Shape_>::apply(
92 index_set_holder,
93 _base_mesh.get_index_set_holder(),
94 _patch_part.get_target_set_holder(),
95 num_entities);
96 }
97 }; // class PatchMeshFactory<ConformalMesh<Shape_, num_coords_, Coord_> >
99 } // namespace Geometry
100} // namespace FEAT
Conformal mesh class template.
Mesh Factory class template.
Definition: factory.hpp:33
Class template for partial meshes.
Definition: mesh_part.hpp:90
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.