ug4
reference_mapping_test.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015: G-CSC, Goethe University Frankfurt
3  * Author: Martin Stepniewski
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__REFERENCE_MAPPING_TEST__
34 #define __H__UG__REFERENCE_MAPPING_TEST__
35 
36 #include <vector>
37 #include <cassert>
38 
43 
44 namespace ug
45 {
46 
47 //
48 // Experimental reference mapping test procedures for octahedrons, tetrahedrons and edges
49 //
50 
51 void OctReferenceMappingTest(std::vector<number> vCornerCoord0, std::vector<number> vCornerCoord1, std::vector<number> vCornerCoord2,
52  std::vector<number> vCornerCoord3, std::vector<number> vCornerCoord4, std::vector<number> vCornerCoord5,
53  std::vector<number> vGlobPos)
54 {
55  UG_LOG(">> Starting OctReferenceMappingTest: " << std::endl);
56 
57  std::vector<MathVector<3, number> > vCornerCoords;
58  std::vector<MathVector<3, number> > vLocPos(1, 0.0);
59  std::vector<MathVector<3, number> > vGlobPositions;
60 
61  MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
62  vGlobPositions.push_back(GlobPos);
63 
64  MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
65  MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
66  MathVector<3> CornerCoord2(vCornerCoord2[0], vCornerCoord2[1], vCornerCoord2[2]);
67  MathVector<3> CornerCoord3(vCornerCoord3[0], vCornerCoord3[1], vCornerCoord3[2]);
68  MathVector<3> CornerCoord4(vCornerCoord4[0], vCornerCoord4[1], vCornerCoord4[2]);
69  MathVector<3> CornerCoord5(vCornerCoord5[0], vCornerCoord5[1], vCornerCoord5[2]);
70 
71  vCornerCoords.push_back(CornerCoord0);
72  vCornerCoords.push_back(CornerCoord1);
73  vCornerCoords.push_back(CornerCoord2);
74  vCornerCoords.push_back(CornerCoord3);
75  vCornerCoords.push_back(CornerCoord4);
76  vCornerCoords.push_back(CornerCoord5);
77 
78  try
79  {
80  DimReferenceMapping<3, 3>& map = ReferenceMappingProvider::get<3, 3>(ROID_OCTAHEDRON, vCornerCoords);
81  map.global_to_local(vLocPos, vGlobPositions);
82  }
83  UG_CATCH_THROW("OctReferenceMappingTest() could not map global to local.");
84 
85  UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
86 }
87 
88 
89 void TetReferenceMappingTest(std::vector<number> vCornerCoord0, std::vector<number> vCornerCoord1, std::vector<number> vCornerCoord2,
90  std::vector<number> vCornerCoord3, std::vector<number> vGlobPos)
91 {
92  UG_LOG(">> Starting TetReferenceMappingTest: " << std::endl);
93 
94  std::vector<MathVector<3, number> > vCornerCoords;
95  std::vector<MathVector<3, number> > vLocPos(1, 0.0);
96  std::vector<MathVector<3, number> > vGlobPositions;
97 
98  MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
99  vGlobPositions.push_back(GlobPos);
100 
101  MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
102  MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
103  MathVector<3> CornerCoord2(vCornerCoord2[0], vCornerCoord2[1], vCornerCoord2[2]);
104  MathVector<3> CornerCoord3(vCornerCoord3[0], vCornerCoord3[1], vCornerCoord3[2]);
105 
106  vCornerCoords.push_back(CornerCoord0);
107  vCornerCoords.push_back(CornerCoord1);
108  vCornerCoords.push_back(CornerCoord2);
109  vCornerCoords.push_back(CornerCoord3);
110 
111  try
112  {
113  DimReferenceMapping<3, 3>& map = ReferenceMappingProvider::get<3, 3>(ROID_TETRAHEDRON, vCornerCoords);
114  map.global_to_local(vLocPos, vGlobPositions);
115  }
116  UG_CATCH_THROW("TetReferenceMappingTest() could not map global to local.");
117 
118  UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
119  UG_LOG("PointIsInsideTetrahedron: " << PointIsInsideTetrahedron(GlobPos, CornerCoord0, CornerCoord1, CornerCoord2, CornerCoord3) << std::endl);
120 }
121 
122 
123 void EdgeReferenceMappingTest(std::vector<number> vCornerCoord0, std::vector<number> vCornerCoord1,
124  std::vector<number> vGlobPos)
125 {
126  UG_LOG(">> Starting EdgeReferenceMappingTest: " << std::endl);
127 
128  std::vector<MathVector<3, number> > vCornerCoords;
129  std::vector<MathVector<1, number> > vLocPos(1, 0.0);
130  std::vector<MathVector<3, number> > vGlobPositions;
131 
132  MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
133  vGlobPositions.push_back(GlobPos);
134 
135  MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
136  MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
137 
138  vCornerCoords.push_back(CornerCoord0);
139  vCornerCoords.push_back(CornerCoord1);
140 
141  try
142  {
143  DimReferenceMapping<1, 3>& map = ReferenceMappingProvider::get<1, 3>(ROID_EDGE, vCornerCoords);
144  map.global_to_local(vLocPos, vGlobPositions);
145  }
146  UG_CATCH_THROW("EdgeReferenceMappingTest() could not map global to local.");
147 
148  UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
149 }
150 
151 }// end of namespace
152 
153 #endif
virtual base class for reference mappings
Definition: reference_mapping_provider.h:53
virtual void global_to_local(MathVector< dim > &locPos, const MathVector< worldDim > &globPos, const size_t maxIter=1000, const number tol=1e-10) const =0
map global coordinate to local coordinate
a mathematical Vector with N entries.
Definition: math_vector.h:97
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_LOG(msg)
Definition: log.h:367
bool PointIsInsideTetrahedron(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Returns true if the point lies inside or on the boundary of a tetrahedron.
Definition: math_util_impl.hpp:1110
the ug namespace
@ ROID_TETRAHEDRON
Definition: grid_base_objects.h:80
@ ROID_EDGE
Definition: grid_base_objects.h:77
@ ROID_OCTAHEDRON
Definition: grid_base_objects.h:84
void TetReferenceMappingTest(std::vector< number > vCornerCoord0, std::vector< number > vCornerCoord1, std::vector< number > vCornerCoord2, std::vector< number > vCornerCoord3, std::vector< number > vGlobPos)
Definition: reference_mapping_test.h:89
void OctReferenceMappingTest(std::vector< number > vCornerCoord0, std::vector< number > vCornerCoord1, std::vector< number > vCornerCoord2, std::vector< number > vCornerCoord3, std::vector< number > vCornerCoord4, std::vector< number > vCornerCoord5, std::vector< number > vGlobPos)
Definition: reference_mapping_test.h:51
void EdgeReferenceMappingTest(std::vector< number > vCornerCoord0, std::vector< number > vCornerCoord1, std::vector< number > vGlobPos)
Definition: reference_mapping_test.h:123