89{
90 fs::path path =
91 fs::temp_directory_path() / LibUtilities::UniquePath("bndnormals");
92 fs::create_directories(path);
93 path /= "TestBoundaryNormals.xml";
94
95 std::ofstream stream(path);
96 stream << sessionFile;
97 stream.close();
98
99 std::string pathString = path.string();
100 char executable[] = "MultiRegionsUnitTests";
101 char *argv[] = {executable, pathString.data(), nullptr};
102 auto session = LibUtilities::SessionReader::CreateInstance(2, argv);
103 auto graph = SpatialDomains::MeshGraphIO::Read(
session);
106
108 field->GetBoundaryToElmtMap(elmtId, faceId);
109
110
111
112 bool exercisesMismatchedTrace = false;
113 for (int n = 0; n < field->GetBndCondExpansions()[0]->GetExpSize(); ++n)
114 {
115 auto elmt = field->GetExp(elmtId[n]);
116 auto localNormals = elmt->GetTraceNormal(faceId[n]);
117 int volume01 = elmt->GetBasis(0)->GetNumPoints() *
118 elmt->GetBasis(1)->GetNumPoints();
119 exercisesMismatchedTrace |= localNormals[0].size() != volume01;
120 }
121 BOOST_REQUIRE(exercisesMismatchedTrace);
122
123 Array<OneD, Array<OneD, NekDouble>> normals;
124 field->GetBoundaryNormals(0, normals);
125
126 int npoints = field->GetBndCondExpansions()[0]->GetTotPoints();
127 Array<OneD, Array<OneD, NekDouble>> expected(3);
128 for (int d = 0; d < 3; ++d)
129 {
130 expected[d] = Array<OneD, NekDouble>(npoints, 0.0);
131 }
132
133 for (
int n = 0; n <
field->GetBndCondExpansions()[0]->GetExpSize(); ++n)
134 {
135 auto elmt =
field->GetExp(elmtId[n]);
136 auto localNormals = elmt->GetTraceNormal(faceId[n]);
137
138
139 auto localTrace = elmt->GetAlignedTraceExp(faceId[n]);
140 int offset =
field->GetBndCondExpansions()[0]->GetPhys_Offset(n);
141 Array<OneD, NekDouble> tmp;
142
143 for (
int d = 0;
d < 3; ++
d)
144 {
145 field->GetBndCondExpansions()[0]->GetExp(n)->PhysInterp(
146 localTrace, localNormals[d], tmp = expected[d] + offset);
147 }
148 }
149
150 BOOST_REQUIRE_EQUAL(normals.size(), 3);
151 for (
int d = 0;
d < 3; ++
d)
152 {
153 BOOST_REQUIRE_EQUAL(normals[d].size(), npoints);
154 }
155
156 for (int i = 0; i < npoints; ++i)
157 {
159 for (
int d = 0;
d < 3; ++
d)
160 {
161 BOOST_REQUIRE(std::isfinite(normals[d][i]));
162 BOOST_CHECK_SMALL(normals[d][i] - expected[d][i], 1.0e-12);
163 magnitude += normals[
d][i] * normals[
d][i];
164 }
165 BOOST_CHECK_SMALL(std::sqrt(magnitude) - 1.0, 1.0e-12);
166 }
167
168 fs::remove_all(path.parent_path());
169}
LibUtilities::SessionReaderSharedPtr session
SpatialDomains::MeshGraphSharedPtr graph
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::vector< double > d(NPUPPER *NPUPPER)