DUNE PDELab (2.8)

geometries.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4// This header is not part of the official Dune API and might be subject
5// to change. You can use this header to test external finite element
6// implementations, but be warned that your tests might break with future
7// Dune versions.
8
9#ifndef DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
10#define DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
11
12#include <cstddef>
13#include <vector>
14
17
18#include <dune/geometry/type.hh>
19#include <dune/geometry/multilineargeometry.hh>
20
21template<class ctype, std::size_t dim>
22class TestGeometries;
23
24template<class ctype>
25class TestGeometries<ctype, 0> :
26 public std::vector<Dune::MultiLinearGeometry<ctype, 0, 0> >
27{
28 static const std::size_t dim = 0;
29
30public:
32
33 TestGeometries() {
35 std::vector<Dune::FieldVector<ctype, dim> > coords;
36
38 coords.resize(1);
39 this->push_back(Geometry(gt, coords));
40 }
41
42 const Geometry &get(const Dune::GeometryType &gt) const {
43 for(std::size_t i = 0; i < this->size(); ++i)
44 if((*this)[i].type() == gt) return (*this)[i];
45 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
46 "dimension " << dim << " for GeometryType " << gt);
47 }
48};
49
50template<class ctype>
51class TestGeometries<ctype, 1> :
52 public std::vector<Dune::MultiLinearGeometry<ctype, 1, 1> >
53{
54 static const std::size_t dim = 1;
55
56public:
58
59 TestGeometries() {
61 std::vector<Dune::FieldVector<ctype, dim> > coords;
62
64 coords.resize(2);
65 coords[0][0] = -.3;
66 coords[1][0] = .7;
67 this->push_back(Geometry(gt, coords));
68 }
69
70 const Geometry &get(const Dune::GeometryType &gt) const {
71 for(std::size_t i = 0; i < this->size(); ++i)
72 if((*this)[i].type() == gt) return (*this)[i];
73 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
74 "dimension " << dim << " for GeometryType " << gt);
75 }
76};
77
78template<class ctype>
79class TestGeometries<ctype, 2> :
80 public std::vector<Dune::MultiLinearGeometry<ctype, 2, 2> >
81{
82 static const std::size_t dim = 2;
83
84public:
86
87 TestGeometries() {
89 std::vector<Dune::FieldVector<ctype, dim> > coords;
90
92 coords.resize(3);
93 coords[0][0] = -.5; coords[0][1] = -.5;
94 coords[1][0] = .5; coords[1][1] = -.5;
95 coords[2][0] = 0 ; coords[2][1] = .5;
96 this->push_back(Geometry(gt, coords));
97
99 coords.resize(4);
100 coords[0][0] = -.5; coords[0][1] = 0;
101 coords[1][0] = 0 ; coords[1][1] = -.5;
102 coords[2][0] = .5; coords[2][1] = 0;
103 coords[3][0] = 0 ; coords[3][1] = .5;
104 this->push_back(Geometry(gt, coords));
105 }
106
107 const Geometry &get(const Dune::GeometryType &gt) const {
108 for(std::size_t i = 0; i < this->size(); ++i)
109 if((*this)[i].type() == gt) return (*this)[i];
110 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
111 "dimension " << dim << " for GeometryType " << gt);
112 }
113};
114
115template<class ctype>
116class TestGeometries<ctype, 3> :
117 public std::vector<Dune::MultiLinearGeometry<ctype, 3, 3> >
118{
119 static const std::size_t dim = 3;
120
121public:
123
124 TestGeometries() {
126 std::vector<Dune::FieldVector<ctype, dim> > coords;
127
129 coords.resize(4);
130 coords[0][0] = -.5; coords[0][1] = -.5; coords[0][2] = -.5;
131 coords[1][0] = .5; coords[1][1] = -.5; coords[1][2] = -.5;
132 coords[2][0] = 0 ; coords[2][1] = .5; coords[2][2] = -.5;
133 coords[3][0] = 0 ; coords[3][1] = 0 ; coords[3][2] = .5;
134 this->push_back(Geometry(gt, coords));
135
137 coords.resize(5);
138 coords[0][0] = -.5; coords[0][1] = 0; coords[0][2] = -.5;
139 coords[1][0] = 0 ; coords[1][1] = -.5; coords[1][2] = -.5;
140 coords[2][0] = .5; coords[2][1] = 0; coords[2][2] = -.5;
141 coords[3][0] = 0 ; coords[3][1] = .5; coords[3][2] = -.5;
142 coords[4][0] = .1; coords[4][1] = .1; coords[4][2] = .1;
143 this->push_back(Geometry(gt, coords));
144
146 coords.resize(6);
147 coords[0][0] = -.6; coords[0][1] = -.5; coords[0][2] = -.4;
148 coords[1][0] = .5; coords[1][1] = -.6; coords[1][2] = -.5;
149 coords[2][0] = .1; coords[2][1] = .5; coords[2][2] = -.6;
150 coords[3][0] = -.5; coords[3][1] = -.4; coords[3][2] = .5;
151 coords[4][0] = .4; coords[4][1] = -.5; coords[4][2] = .6;
152 coords[5][0] = 0 ; coords[5][1] = .4; coords[5][2] = .5;
153 this->push_back(Geometry(gt, coords));
154
156 coords.resize(8);
157 coords[0][0] = -.7; coords[0][1] = -.6; coords[0][2] = -.5;
158 coords[1][0] = .4; coords[1][1] = -.3; coords[1][2] = -.7;
159 coords[2][0] = -.6; coords[2][1] = .5; coords[2][2] = -.4;
160 coords[3][0] = .3; coords[3][1] = .7; coords[3][2] = -.6;
161 coords[4][0] = -.5; coords[4][1] = -.4; coords[4][2] = .3;
162 coords[5][0] = .7; coords[5][1] = -.6; coords[5][2] = .5;
163 coords[6][0] = -.4; coords[6][1] = .3; coords[6][2] = .7;
164 coords[7][0] = .6; coords[7][1] = .5; coords[7][2] = .4;
165 this->push_back(Geometry(gt, coords));
166 }
167
168 const Geometry &get(const Dune::GeometryType &gt) const {
169 for(std::size_t i = 0; i < this->size(); ++i)
170 if((*this)[i].type() == gt) return (*this)[i];
171 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
172 "dimension " << dim << " for GeometryType " << gt);
173 }
174};
175
176#endif // DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:123
generic geometry implementation based on corner coordinates
Definition: multilineargeometry.hh:179
Default exception for dummy implementations.
Definition: exceptions.hh:261
A few common exception classes.
Implements a vector constructed from a given type representing a field and a compile-time given size.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:156
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:510
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition: type.hh:540
constexpr GeometryType triangle
GeometryType representing a triangle.
Definition: type.hh:516
constexpr GeometryType quadrilateral
GeometryType representing a quadrilateral (a square).
Definition: type.hh:522
constexpr GeometryType hexahedron
GeometryType representing a hexahedron.
Definition: type.hh:546
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition: type.hh:534
constexpr GeometryType tetrahedron
GeometryType representing a tetrahedron.
Definition: type.hh:528
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:504
constexpr HybridTreePath< T..., std::size_t > push_back(const HybridTreePath< T... > &tp, std::size_t i)
Appends a run time index to a HybridTreePath.
Definition: treepath.hh:278
A unique label for each type of element that can occur in a grid.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Dec 22, 23:30, 2024)