Skip to content

Commit 23ab119

Browse files
authored
Merge branch 'develop' into cleanup_orientation_checks
2 parents 49fd280 + abb5243 commit 23ab119

5 files changed

Lines changed: 296 additions & 7 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ void CConfig::SetConfig_Parsing(char case_filename[MAX_STRING_SIZE]) {
28322832
* If there is a statement after a cont. char
28332833
* throw an error. ---*/
28342834

2835-
if (text_line.front() != '%'){
2835+
if (text_line.size() && (text_line.front() != '%')){
28362836
while (text_line.back() == '\\' ||
28372837
(PrintingToolbox::split(text_line, '\\').size() > 1)){
28382838
string tmp;

SU2_CFD/src/solvers/CEulerSolver.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7441,7 +7441,7 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container,
74417441

74427442
case STATIC_PRESSURE:
74437443

7444-
/*--- Retrieve the staic pressure for this boundary. ---*/
7444+
/*--- Retrieve the static pressure for this boundary. ---*/
74457445
Pressure_e = config->GetRiemann_Var1(Marker_Tag);
74467446
Pressure_e /= config->GetPressure_Ref();
74477447
Density_e = Density_i;
@@ -7920,7 +7920,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain
79207920

79217921
case MIXING_OUT:
79227922

7923-
/*--- Retrieve the staic pressure for this boundary. ---*/
7923+
/*--- Retrieve the static pressure for this boundary. ---*/
79247924
Pressure_e = ExtAveragePressure[val_marker][iSpan];
79257925
Density_e = Density_i;
79267926

@@ -7936,7 +7936,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain
79367936

79377937
case STATIC_PRESSURE:
79387938

7939-
/*--- Retrieve the staic pressure for this boundary. ---*/
7939+
/*--- Retrieve the static pressure for this boundary. ---*/
79407940
Pressure_e = config->GetRiemann_Var1(Marker_Tag);
79417941
Pressure_e /= config->GetPressure_Ref();
79427942
Density_e = Density_i;
@@ -7954,7 +7954,7 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain
79547954

79557955
case RADIAL_EQUILIBRIUM:
79567956

7957-
/*--- Retrieve the staic pressure for this boundary. ---*/
7957+
/*--- Retrieve the static pressure for this boundary. ---*/
79587958
Pressure_e = RadialEquilibriumPressure[val_marker][iSpan];
79597959
Density_e = Density_i;
79607960

@@ -12446,7 +12446,8 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC
1244612446
Radius2 = geometry->GetTurboRadius(iMarker,iSpan);
1244712447
Radius1 = geometry->GetTurboRadius(iMarker,iSpan-1);
1244812448
Vt2 = AverageTurboVelocity[iMarker][iSpan - 1][1]*AverageTurboVelocity[iMarker][iSpan - 1][1];
12449-
RadialEquilibriumPressure[iMarker][iSpan -1] = RadialEquilibriumPressure[iMarker][iSpan] - AverageDensity[iMarker][iSpan -1]*Vt2/Radius2*(Radius2 - Radius1);
12449+
Radius1 = (Radius1 > EPS)? Radius1 : Radius2;
12450+
RadialEquilibriumPressure[iMarker][iSpan -1] = RadialEquilibriumPressure[iMarker][iSpan] - AverageDensity[iMarker][iSpan -1]*Vt2/Radius1*(Radius2 - Radius1);
1245012451
}
1245112452
}
1245212453
}
@@ -12463,7 +12464,8 @@ void CEulerSolver::TurboAverageProcess(CSolver **solver, CGeometry *geometry, CC
1246312464
Radius2 = geometry->GetTurboRadius(iMarker,iSpan);
1246412465
Radius1 = geometry->GetTurboRadius(iMarker,iSpan-1);
1246512466
Vt2 = AverageTurboVelocity[iMarker][iSpan -1][1]*AverageTurboVelocity[iMarker][iSpan - 1][1];
12466-
RadialEquilibriumPressure[iMarker][iSpan -1] = RadialEquilibriumPressure[iMarker][iSpan] - AverageDensity[iMarker][iSpan -1]*Vt2/Radius2*(Radius2 - Radius1);
12467+
Radius1 = (Radius1 > EPS)? Radius1 : Radius2;
12468+
RadialEquilibriumPressure[iMarker][iSpan -1] = RadialEquilibriumPressure[iMarker][iSpan] - AverageDensity[iMarker][iSpan -1]*Vt2/Radius1*(Radius2 - Radius1);
1246712469
}
1246812470
}
1246912471
}
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/*!
2+
* \file CGeometry_tests.cpp
3+
* \brief Unit tests for CGeometry.
4+
* \author T. Albring
5+
* \version 7.0.5 "Blackbird"
6+
*
7+
* SU2 Project Website: https://su2code.github.io
8+
*
9+
* The SU2 Project is maintained by the SU2 Foundation
10+
* (http://su2foundation.org)
11+
*
12+
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
13+
*
14+
* SU2 is free software; you can redistribute it and/or
15+
* modify it under the terms of the GNU Lesser General Public
16+
* License as published by the Free Software Foundation; either
17+
* version 2.1 of the License, or (at your option) any later version.
18+
*
19+
* SU2 is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
* Lesser General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU Lesser General Public
25+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
#include "catch.hpp"
29+
#include "../../UnitQuadTestCase.hpp"
30+
31+
std::unique_ptr<UnitQuadTestCase> TestCase;
32+
33+
TEST_CASE("Geometry constructor", "[Geometry]"){
34+
35+
cout.rdbuf(nullptr);
36+
37+
TestCase = std::unique_ptr<UnitQuadTestCase>(new UnitQuadTestCase());
38+
39+
TestCase->InitConfig();
40+
41+
auto aux_geometry = std::unique_ptr<CGeometry>(new CPhysicalGeometry(TestCase->config.get(), 0, 1));
42+
43+
CHECK(aux_geometry->GetnPoint() == 125);
44+
CHECK(aux_geometry->GetnElem() == 64);
45+
CHECK(aux_geometry->GetnElemHexa() == 64);
46+
CHECK(aux_geometry->GetnEdge() == 0);
47+
CHECK(aux_geometry->GetnElem_Bound(0) == 16);
48+
CHECK(aux_geometry->GetnElem_Bound(5) == 16);
49+
50+
TestCase->geometry = std::unique_ptr<CGeometry>(new CPhysicalGeometry(aux_geometry.get(), TestCase->config.get()));
51+
52+
CHECK(TestCase->geometry->GetnPoint() == 125);
53+
CHECK(TestCase->geometry->GetnElem() == 64);
54+
CHECK(TestCase->geometry->GetnElemHexa() == 64);
55+
CHECK(TestCase->geometry->GetnEdge() == 0);
56+
CHECK(TestCase->geometry->GetnElem_Bound(0) == 16);
57+
CHECK(TestCase->geometry->GetnElem_Bound(5) == 16);
58+
59+
cout.rdbuf(TestCase->orig_buf);
60+
61+
}
62+
63+
TEST_CASE("Set Send/Recv", "[Geometry]"){
64+
TestCase->geometry->SetSendReceive(TestCase->config.get());
65+
66+
/*---- No check yet, since unit tests run in serial at the moment ---*/
67+
}
68+
69+
TEST_CASE("Set Boundaries", "[Geometry]"){
70+
71+
TestCase->geometry->SetBoundaries(TestCase->config.get());
72+
73+
CHECK(TestCase->config->GetMarker_All_KindBC(0) == CUSTOM_BOUNDARY);
74+
CHECK(TestCase->config->GetMarker_All_KindBC(2) == HEAT_FLUX);
75+
CHECK(TestCase->config->GetSolid_Wall(2));
76+
CHECK(TestCase->config->GetSolid_Wall(3));
77+
}
78+
79+
TEST_CASE("Set Point Connectivity", "[Geometry]"){
80+
81+
TestCase->geometry->SetPoint_Connectivity();
82+
83+
CHECK(TestCase->geometry->nodes->GetnElem(55) == 4);
84+
CHECK(TestCase->geometry->nodes->GetElem(30, 2) == 16);
85+
CHECK(TestCase->geometry->nodes->GetnNeighbor(3) == 4);
86+
CHECK(TestCase->geometry->nodes->GetPoint(99, 2) == 98);
87+
}
88+
89+
TEST_CASE("Set elem connectivity", "[Geometry]"){
90+
91+
TestCase->geometry->SetElement_Connectivity();
92+
93+
CHECK(TestCase->geometry->elem[14]->GetnNeighbor_Elements() == 6);
94+
CHECK(TestCase->geometry->elem[14]->GetNeighbor_Elements(1) == 15);
95+
96+
}
97+
98+
TEST_CASE("Set bound volume", "[Geometry]"){
99+
100+
TestCase->geometry->SetBoundVolume();
101+
102+
CHECK(TestCase->geometry->bound[0][10]->GetDomainElement() == 40);
103+
CHECK(TestCase->geometry->bound[4][10]->GetDomainElement() == 10);
104+
105+
}
106+
107+
TEST_CASE("Set Edges", "[Geometry]"){
108+
109+
TestCase->geometry->SetEdges();
110+
111+
CHECK(TestCase->geometry->edges->GetnNodes() == 2);
112+
CHECK(TestCase->geometry->edges->GetNode(42,0) == 15);
113+
CHECK(TestCase->geometry->edges->GetNode(87,1) == 57);
114+
115+
}
116+
117+
TEST_CASE("Set vertex", "[Geometry]"){
118+
119+
TestCase->geometry->SetVertex(TestCase->config.get());
120+
121+
CHECK(TestCase->geometry->GetnVertex(0) == 25);
122+
CHECK(TestCase->geometry->vertex[0][20]->GetNode() == 100);
123+
CHECK(TestCase->geometry->nodes->GetVertex(100, 0) == 20);
124+
CHECK(TestCase->geometry->nodes->GetVertex(1, 0) == -1);
125+
126+
}
127+
128+
TEST_CASE("Set center of gravity", "[Geometry]"){
129+
130+
TestCase->geometry->SetCoord_CG();
131+
132+
CHECK(TestCase->geometry->elem[42]->GetCG(0) == 0.625);
133+
CHECK(TestCase->geometry->elem[3]->GetCG(1) == 0.125);
134+
CHECK(TestCase->geometry->elem[25]->GetCG(2) == 0.375);
135+
136+
CHECK(TestCase->geometry->bound[1][4]->GetCG(0) == 1.0);
137+
CHECK(TestCase->geometry->bound[3][2]->GetCG(1) == 1.0);
138+
CHECK(TestCase->geometry->bound[4][3]->GetCG(2) == 0.0);
139+
140+
CHECK(TestCase->geometry->edges->GetCG(10, 0) == 0.75);
141+
CHECK(TestCase->geometry->edges->GetCG(3, 1) == 0.125);
142+
CHECK(TestCase->geometry->edges->GetCG(22, 2) == 0.0);
143+
}
144+
145+
TEST_CASE("Set control volume", "[Geometry]"){
146+
147+
TestCase->geometry->SetControlVolume(TestCase->config.get(), ALLOCATE);
148+
149+
CHECK(TestCase->geometry->nodes->GetVolume(42) == Approx(0.015625));
150+
151+
CHECK(TestCase->geometry->edges->GetNormal(32)[0] == 0.03125);
152+
CHECK(TestCase->geometry->edges->GetNormal(5)[1] == 0.0);
153+
CHECK(TestCase->geometry->edges->GetNormal(10)[2] == 0.03125);
154+
155+
CHECK(TestCase->config->GetDomainVolume() == Approx(1.0));
156+
157+
}
158+
159+
TEST_CASE("Set bound control volume", "[Geometry]"){
160+
161+
TestCase->geometry->SetBoundControlVolume(TestCase->config.get(), ALLOCATE);
162+
163+
CHECK(TestCase->geometry->vertex[0][4]->GetNormal()[0] == -0.0625);
164+
CHECK(TestCase->geometry->vertex[3][2]->GetNormal()[1] == -0.0625);
165+
CHECK(TestCase->geometry->vertex[5][3]->GetNormal()[2] == 0.03125);
166+
167+
}

UnitTests/UnitQuadTestCase.hpp

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/*!
2+
* \file UnitQuadTestCase.hpp
3+
* \brief Simple unit quad test to be used in unit tests.
4+
* \author T. Albring
5+
* \version 7.0.5 "Blackbird"
6+
*
7+
* SU2 Project Website: https://su2code.github.io
8+
*
9+
* The SU2 Project is maintained by the SU2 Foundation
10+
* (http://su2foundation.org)
11+
*
12+
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
13+
*
14+
* SU2 is free software; you can redistribute it and/or
15+
* modify it under the terms of the GNU Lesser General Public
16+
* License as published by the Free Software Foundation; either
17+
* version 2.1 of the License, or (at your option) any later version.
18+
*
19+
* SU2 is distributed in the hope that it will be useful,
20+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22+
* Lesser General Public License for more details.
23+
*
24+
* You should have received a copy of the GNU Lesser General Public
25+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
26+
*/
27+
28+
#pragma once
29+
30+
#include <string>
31+
32+
#include "../Common/include/geometry/CPhysicalGeometry.hpp"
33+
#include "../SU2_CFD/include/solvers/CSolverFactory.hpp"
34+
#include "../SU2_CFD/include/solvers/CNSSolver.hpp"
35+
36+
struct UnitQuadTestCase {
37+
std::string config_options =
38+
"SOLVER= NAVIER_STOKES\n"
39+
"KIND_VERIFICATION_SOLUTION=MMS_NS_UNIT_QUAD\n"
40+
"MESH_FORMAT= BOX\n"
41+
"INIT_OPTION=TD_CONDITIONS\n"
42+
"MACH_NUMBER=0.5\n"
43+
"MARKER_HEATFLUX= (y_minus, 0.0, y_plus, 0.0)\n"
44+
"MARKER_CUSTOM= ( x_minus, x_plus, z_plus, z_minus)\n"
45+
"VISCOSITY_MODEL= CONSTANT_VISCOSITY\n"
46+
"MESH_BOX_SIZE=5,5,5\n"
47+
"MESH_BOX_LENGTH=1,1,1\n"
48+
"MESH_BOX_OFFSET=0,0,0\n"
49+
"REF_ORIGIN_MOMENT_X=0.0\n"
50+
"REF_ORIGIN_MOMENT_Y=0.0\n"
51+
"REF_ORIGIN_MOMENT_Z=0.0\n";
52+
std::unique_ptr<CConfig> config;
53+
std::unique_ptr<CGeometry> geometry;
54+
CSolver** solver{nullptr};
55+
streambuf* orig_buf{nullptr};
56+
UnitQuadTestCase() : orig_buf(cout.rdbuf()) {}
57+
58+
/*!
59+
* \brief Add a line to the base config string stream
60+
* \param[in] optionLine - String containing the option(s)
61+
*/
62+
void AddOption(const std::string& optionLine) { config_options += optionLine + "\n"; }
63+
64+
/*!
65+
* \brief Initialize the config structure
66+
*/
67+
void InitConfig() {
68+
cout.rdbuf(nullptr);
69+
stringstream ss(config_options);
70+
config = std::unique_ptr<CConfig>(new CConfig(ss, SU2_CFD, false));
71+
cout.rdbuf(orig_buf);
72+
}
73+
74+
/*!
75+
* \brief Initialize the solver array
76+
*/
77+
void InitSolver() {
78+
cout.rdbuf(nullptr);
79+
solver = CSolverFactory::CreateSolverContainer(static_cast<ENUM_MAIN_SOLVER>(config.get()->GetKind_Solver()),
80+
config.get(), geometry.get(), 0);
81+
cout.rdbuf(orig_buf);
82+
}
83+
84+
/*!
85+
* \brief Initialize the geometry
86+
*/
87+
void InitGeometry() {
88+
cout.rdbuf(nullptr);
89+
{
90+
auto aux_geometry = std::unique_ptr<CGeometry>(new CPhysicalGeometry(config.get(), 0, 1));
91+
geometry = std::unique_ptr<CGeometry>(new CPhysicalGeometry(aux_geometry.get(), config.get()));
92+
}
93+
geometry->SetSendReceive(config.get());
94+
geometry->SetBoundaries(config.get());
95+
geometry->SetPoint_Connectivity();
96+
geometry->SetElement_Connectivity();
97+
geometry->SetBoundVolume();
98+
99+
geometry->SetEdges();
100+
geometry->SetVertex(config.get());
101+
geometry->SetCoord_CG();
102+
geometry->SetControlVolume(config.get(), ALLOCATE);
103+
geometry->SetBoundControlVolume(config.get(), ALLOCATE);
104+
geometry->FindNormal_Neighbor(config.get());
105+
geometry->SetGlobal_to_Local_Point();
106+
geometry->PreprocessP2PComms(geometry.get(), config.get());
107+
108+
cout.rdbuf(orig_buf);
109+
}
110+
111+
/*!
112+
* \brief Desctructor
113+
*/
114+
~UnitQuadTestCase() {
115+
if (solver != nullptr)
116+
delete solver[FLOW_SOL];
117+
delete[] solver;
118+
}
119+
};

UnitTests/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# Direct-mode tests:
77
su2_cfd_tests = files(['Common/geometry/primal_grid/CPrimalGrid_tests.cpp',
88
'Common/geometry/dual_grid/CDualGrid_tests.cpp',
9+
'Common/geometry/CGeometry_test.cpp',
910
'Common/toolboxes/CQuasiNewtonInvLeastSquares_tests.cpp',
1011
'SU2_CFD/numerics/CNumerics_tests.cpp'])
1112

0 commit comments

Comments
 (0)