FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
index_set_filler.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/index_set.hpp>
10
11// includes, system
12#include <vector>
13
14namespace FEAT
15{
16 namespace Geometry
17 {
19 namespace Intern
20 {
31 template<int dim>
32 struct IndexSetFiller
33 {
34 template<typename IndexSetHolderType, typename TargetSetHolderType, typename ParentIndexSetHolderType>
35 static void fill_ish(IndexSetHolderType& ish, const TargetSetHolderType& tsh, const ParentIndexSetHolderType& parent_ish)
36 {
37 // Recurse down
38 IndexSetFiller<dim-1>::fill_ish(ish, tsh, parent_ish);
39
40 // The MeshPart's vertex@shape set
41 auto& index_set(ish.template get_index_set<dim, 0>());
42 // The Mesh's vertex@shape set
43 auto& index_set_parent(parent_ish.template get_index_set<dim, 0>());
44
45 auto& target_set_vertex(tsh.template get_target_set<0>());
46 auto& target_set_dim(tsh.template get_target_set<dim>());
47
48 // For every vertex in the parent, this will contain its index in the MeshPart
49 std::vector<Index> inverse_target_map(index_set_parent.get_index_bound());
50
51 // Set every index to something out of range to catch errors
52 for(Index i(0); i < index_set_parent.get_index_bound(); ++i)
53 inverse_target_map[i] = target_set_vertex.get_num_entities() + Index(1);
54
55 for(Index i(0); i < target_set_vertex.get_num_entities(); ++i)
56 inverse_target_map[target_set_vertex[i]] = i;
57
58 // Now we can just iterate over the shapes of the MeshPart
59 for(Index cell(0); cell < target_set_dim.get_num_entities(); ++cell)
60 {
61 // For the shape cell, get its index in the parent. Then get the local vertex' index in the parent and
62 // map that back to the MeshPart with the inverse_target_map. Ez!
63 for(int i(0); i < index_set_parent.get_num_indices(); ++i)
64 index_set[cell][i] = inverse_target_map[index_set_parent[target_set_dim[cell]][i]];
65 }
66 }
67 }; // struct IndexSetFiller<int>
68
72 template<>
73 struct IndexSetFiller<0>
74 {
75 template<typename IndexSetHolderType, typename TargetSetHolderType, typename ParentIndexSetHolderType>
76 static void fill_ish(IndexSetHolderType& DOXY(ish), const TargetSetHolderType& DOXY(tsh), const ParentIndexSetHolderType& DOXY(parent_ish))
77 {
78 }
79 }; // struct IndexSetFiller<0>
80 } // namespace Intern
82 } // namespace Geometry
83} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.