FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
dual_adaptor.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#include <kernel/geometry/conformal_mesh.hpp>
9#include <kernel/geometry/vertex_set.hpp>
10
11namespace FEAT
12{
13 namespace Geometry
14 {
16 namespace Intern
17 {
18 template<typename Mesh_, typename Shape_ = typename Mesh_::ShapeType>
19 struct DualAdaptor
20 {
21 static void adapt(Mesh_&, const Mesh_&)
22 {
23 // do nothing
24 }
25 };
26
27 template<typename Mesh_>
28 struct DualAdaptor<Mesh_, Shape::Hypercube<1> >
29 {
30 static void adapt(Mesh_&, const Mesh_&)
31 {
32 // do nothing
33 }
34 };
35
36 template<typename Mesh_, int shape_dim_>
37 struct DualAdaptor<Mesh_, Shape::Hypercube<shape_dim_> >
38 {
39 static_assert(shape_dim_ > 1, "invalid shape dimension");
40
41 static void adapt(Mesh_& mesh_f, const Mesh_& mesh_c)
42 {
43 typedef typename Mesh_::CoordType CoordType;
44
45 // get number of facets
46 static constexpr int nfe = Shape::FaceTraits<Shape::Hypercube<shape_dim_>, shape_dim_-1>::count;
47
48 // compute scaling factor
49 const CoordType scale = CoordType(1) / CoordType(nfe);
50
51 // get cell count
52 Index num_cells = mesh_c.get_num_entities(shape_dim_);
53
54 // compute facet-vertex and cell-vertex offsets
55 Index fvo = Index(0);
56 for(int i(0); (i+1) < shape_dim_; ++i)
57 {
58 fvo += mesh_c.get_num_entities(i);
59 }
60 Index cvo = fvo + mesh_c.get_num_entities(shape_dim_ - 1);
61
62 // get fine mesh vertex set
63 auto& vtx = mesh_f.get_vertex_set();
64
65 // get coarse mesh facet index set
66 const auto& facet = mesh_c.template get_index_set<shape_dim_, shape_dim_-1>();
67
68 // loop over all coarse mesh quads
69 for(Index i(0); i < num_cells; ++i)
70 {
71 // get the fine mesh vertex
72 auto& v = vtx[cvo + i];
73 v.format();
74
75 // loop over all faces
76 for(int j(0); j < nfe; ++j)
77 v += scale * vtx[fvo + facet(i,j)];
78 }
79 }
80 };
81 } // namespace Intern
83 } // namespace Geometry
84} // namespace FEAT
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.