Dune Core Modules (2.9.0)

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// SPDX-FileCopyrightInfo: Copyright (C) DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5
6// This header is not part of the official Dune API and might be subject
7// to change. You can use this header to test external finite element
8// implementations, but be warned that your tests might break with future
9// Dune versions.
10
11#ifndef DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
12#define DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
13
14#include <cstddef>
15#include <vector>
16
19
20#include <dune/geometry/type.hh>
21#include <dune/geometry/multilineargeometry.hh>
22
23template<class ctype, std::size_t dim>
24class TestGeometries;
25
26template<class ctype>
27class TestGeometries<ctype, 0> :
28 public std::vector<Dune::MultiLinearGeometry<ctype, 0, 0> >
29{
30 static const std::size_t dim = 0;
31
32public:
34
35 TestGeometries() {
37 std::vector<Dune::FieldVector<ctype, dim> > coords;
38
40 coords.resize(1);
41 this->push_back(Geometry(gt, coords));
42 }
43
44 const Geometry &get(const Dune::GeometryType &gt) const {
45 for(std::size_t i = 0; i < this->size(); ++i)
46 if((*this)[i].type() == gt) return (*this)[i];
47 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
48 "dimension " << dim << " for GeometryType " << gt);
49 }
50};
51
52template<class ctype>
53class TestGeometries<ctype, 1> :
54 public std::vector<Dune::MultiLinearGeometry<ctype, 1, 1> >
55{
56 static const std::size_t dim = 1;
57
58public:
60
61 TestGeometries() {
63 std::vector<Dune::FieldVector<ctype, dim> > coords;
64
66 coords.resize(2);
67 coords[0][0] = -.3;
68 coords[1][0] = .7;
69 this->push_back(Geometry(gt, coords));
70 }
71
72 const Geometry &get(const Dune::GeometryType &gt) const {
73 for(std::size_t i = 0; i < this->size(); ++i)
74 if((*this)[i].type() == gt) return (*this)[i];
75 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
76 "dimension " << dim << " for GeometryType " << gt);
77 }
78};
79
80template<class ctype>
81class TestGeometries<ctype, 2> :
82 public std::vector<Dune::MultiLinearGeometry<ctype, 2, 2> >
83{
84 static const std::size_t dim = 2;
85
86public:
88
89 TestGeometries() {
91 std::vector<Dune::FieldVector<ctype, dim> > coords;
92
94 coords.resize(3);
95 coords[0][0] = -.5; coords[0][1] = -.5;
96 coords[1][0] = .5; coords[1][1] = -.5;
97 coords[2][0] = 0 ; coords[2][1] = .5;
98 this->push_back(Geometry(gt, coords));
99
101 coords.resize(4);
102 coords[0][0] = -.5; coords[0][1] = 0;
103 coords[1][0] = 0 ; coords[1][1] = -.5;
104 coords[2][0] = .5; coords[2][1] = 0;
105 coords[3][0] = 0 ; coords[3][1] = .5;
106 this->push_back(Geometry(gt, coords));
107 }
108
109 const Geometry &get(const Dune::GeometryType &gt) const {
110 for(std::size_t i = 0; i < this->size(); ++i)
111 if((*this)[i].type() == gt) return (*this)[i];
112 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
113 "dimension " << dim << " for GeometryType " << gt);
114 }
115};
116
117template<class ctype>
118class TestGeometries<ctype, 3> :
119 public std::vector<Dune::MultiLinearGeometry<ctype, 3, 3> >
120{
121 static const std::size_t dim = 3;
122
123public:
125
126 TestGeometries() {
128 std::vector<Dune::FieldVector<ctype, dim> > coords;
129
131 coords.resize(4);
132 coords[0][0] = -.5; coords[0][1] = -.5; coords[0][2] = -.5;
133 coords[1][0] = .5; coords[1][1] = -.5; coords[1][2] = -.5;
134 coords[2][0] = 0 ; coords[2][1] = .5; coords[2][2] = -.5;
135 coords[3][0] = 0 ; coords[3][1] = 0 ; coords[3][2] = .5;
136 this->push_back(Geometry(gt, coords));
137
139 coords.resize(5);
140 coords[0][0] = -.5; coords[0][1] = 0; coords[0][2] = -.5;
141 coords[1][0] = 0 ; coords[1][1] = -.5; coords[1][2] = -.5;
142 coords[2][0] = .5; coords[2][1] = 0; coords[2][2] = -.5;
143 coords[3][0] = 0 ; coords[3][1] = .5; coords[3][2] = -.5;
144 coords[4][0] = .1; coords[4][1] = .1; coords[4][2] = .1;
145 this->push_back(Geometry(gt, coords));
146
148 coords.resize(6);
149 coords[0][0] = -.6; coords[0][1] = -.5; coords[0][2] = -.4;
150 coords[1][0] = .5; coords[1][1] = -.6; coords[1][2] = -.5;
151 coords[2][0] = .1; coords[2][1] = .5; coords[2][2] = -.6;
152 coords[3][0] = -.5; coords[3][1] = -.4; coords[3][2] = .5;
153 coords[4][0] = .4; coords[4][1] = -.5; coords[4][2] = .6;
154 coords[5][0] = 0 ; coords[5][1] = .4; coords[5][2] = .5;
155 this->push_back(Geometry(gt, coords));
156
158 coords.resize(8);
159 coords[0][0] = -.7; coords[0][1] = -.6; coords[0][2] = -.5;
160 coords[1][0] = .4; coords[1][1] = -.3; coords[1][2] = -.7;
161 coords[2][0] = -.6; coords[2][1] = .5; coords[2][2] = -.4;
162 coords[3][0] = .3; coords[3][1] = .7; coords[3][2] = -.6;
163 coords[4][0] = -.5; coords[4][1] = -.4; coords[4][2] = .3;
164 coords[5][0] = .7; coords[5][1] = -.6; coords[5][2] = .5;
165 coords[6][0] = -.4; coords[6][1] = .3; coords[6][2] = .7;
166 coords[7][0] = .6; coords[7][1] = .5; coords[7][2] = .4;
167 this->push_back(Geometry(gt, coords));
168 }
169
170 const Geometry &get(const Dune::GeometryType &gt) const {
171 for(std::size_t i = 0; i < this->size(); ++i)
172 if((*this)[i].type() == gt) return (*this)[i];
173 DUNE_THROW(Dune::NotImplemented, "No predefined test-geometry in "
174 "dimension " << dim << " for GeometryType " << gt);
175 }
176};
177
178#endif // DUNE_LOCALFUNCTIONS_TEST_GEOMETRIES_HH
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:125
generic geometry implementation based on corner coordinates
Definition: multilineargeometry.hh:181
Default exception for dummy implementations.
Definition: exceptions.hh:263
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:218
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:512
constexpr GeometryType prism
GeometryType representing a 3D prism.
Definition: type.hh:542
constexpr GeometryType triangle
GeometryType representing a triangle.
Definition: type.hh:518
constexpr GeometryType quadrilateral
GeometryType representing a quadrilateral (a square).
Definition: type.hh:524
constexpr GeometryType hexahedron
GeometryType representing a hexahedron.
Definition: type.hh:548
constexpr GeometryType pyramid
GeometryType representing a 3D pyramid.
Definition: type.hh:536
constexpr GeometryType tetrahedron
GeometryType representing a tetrahedron.
Definition: type.hh:530
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:506
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:281
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 21, 23:30, 2024)