Line data Source code
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 :
39 : #include "lib_disc/local_finite_element/local_finite_element_provider.h"
40 : #include "lib_disc/local_finite_element/local_dof_set.h"
41 : #include "lib_disc/reference_element/reference_mapping_provider.h"
42 : #include "lib_disc/reference_element/reference_element_util.h"
43 :
44 : namespace ug
45 : {
46 :
47 : //
48 : // Experimental reference mapping test procedures for octahedrons, tetrahedrons and edges
49 : //
50 :
51 0 : 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 0 : std::vector<MathVector<3, number> > vLocPos(1, 0.0);
59 : std::vector<MathVector<3, number> > vGlobPositions;
60 :
61 0 : MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
62 0 : vGlobPositions.push_back(GlobPos);
63 :
64 0 : MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
65 0 : MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
66 0 : MathVector<3> CornerCoord2(vCornerCoord2[0], vCornerCoord2[1], vCornerCoord2[2]);
67 0 : MathVector<3> CornerCoord3(vCornerCoord3[0], vCornerCoord3[1], vCornerCoord3[2]);
68 0 : MathVector<3> CornerCoord4(vCornerCoord4[0], vCornerCoord4[1], vCornerCoord4[2]);
69 0 : MathVector<3> CornerCoord5(vCornerCoord5[0], vCornerCoord5[1], vCornerCoord5[2]);
70 :
71 0 : vCornerCoords.push_back(CornerCoord0);
72 0 : vCornerCoords.push_back(CornerCoord1);
73 0 : vCornerCoords.push_back(CornerCoord2);
74 0 : vCornerCoords.push_back(CornerCoord3);
75 0 : vCornerCoords.push_back(CornerCoord4);
76 0 : vCornerCoords.push_back(CornerCoord5);
77 :
78 : try
79 : {
80 : DimReferenceMapping<3, 3>& map = ReferenceMappingProvider::get<3, 3>(ROID_OCTAHEDRON, vCornerCoords);
81 0 : map.global_to_local(vLocPos, vGlobPositions);
82 : }
83 0 : UG_CATCH_THROW("OctReferenceMappingTest() could not map global to local.");
84 :
85 0 : UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
86 0 : }
87 :
88 :
89 0 : 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 0 : std::vector<MathVector<3, number> > vLocPos(1, 0.0);
96 : std::vector<MathVector<3, number> > vGlobPositions;
97 :
98 0 : MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
99 0 : vGlobPositions.push_back(GlobPos);
100 :
101 0 : MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
102 0 : MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
103 0 : MathVector<3> CornerCoord2(vCornerCoord2[0], vCornerCoord2[1], vCornerCoord2[2]);
104 0 : MathVector<3> CornerCoord3(vCornerCoord3[0], vCornerCoord3[1], vCornerCoord3[2]);
105 :
106 0 : vCornerCoords.push_back(CornerCoord0);
107 0 : vCornerCoords.push_back(CornerCoord1);
108 0 : vCornerCoords.push_back(CornerCoord2);
109 0 : vCornerCoords.push_back(CornerCoord3);
110 :
111 : try
112 : {
113 : DimReferenceMapping<3, 3>& map = ReferenceMappingProvider::get<3, 3>(ROID_TETRAHEDRON, vCornerCoords);
114 0 : map.global_to_local(vLocPos, vGlobPositions);
115 : }
116 0 : UG_CATCH_THROW("TetReferenceMappingTest() could not map global to local.");
117 :
118 0 : UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
119 0 : UG_LOG("PointIsInsideTetrahedron: " << PointIsInsideTetrahedron(GlobPos, CornerCoord0, CornerCoord1, CornerCoord2, CornerCoord3) << std::endl);
120 0 : }
121 :
122 :
123 0 : 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 0 : std::vector<MathVector<1, number> > vLocPos(1, 0.0);
130 : std::vector<MathVector<3, number> > vGlobPositions;
131 :
132 0 : MathVector<3> GlobPos(vGlobPos[0], vGlobPos[1], vGlobPos[2]);
133 0 : vGlobPositions.push_back(GlobPos);
134 :
135 0 : MathVector<3> CornerCoord0(vCornerCoord0[0], vCornerCoord0[1], vCornerCoord0[2]);
136 0 : MathVector<3> CornerCoord1(vCornerCoord1[0], vCornerCoord1[1], vCornerCoord1[2]);
137 :
138 0 : vCornerCoords.push_back(CornerCoord0);
139 0 : vCornerCoords.push_back(CornerCoord1);
140 :
141 : try
142 : {
143 : DimReferenceMapping<1, 3>& map = ReferenceMappingProvider::get<1, 3>(ROID_EDGE, vCornerCoords);
144 0 : map.global_to_local(vLocPos, vGlobPositions);
145 : }
146 0 : UG_CATCH_THROW("EdgeReferenceMappingTest() could not map global to local.");
147 :
148 0 : UG_LOG("Calculated vLocPos: " << vLocPos[0] << std::endl);
149 0 : }
150 :
151 : }// end of namespace
152 :
153 : #endif
|