Skip to content

Commit 60e47b6

Browse files
authored
Merge pull request #1933 from su2code/fix_symmetry_logic_with_deform_marker
Fix Symmetry/Euler marker preprocessing logic with deforming markers
2 parents a96176f + 6c04e09 commit 60e47b6

6 files changed

Lines changed: 224 additions & 33 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6559,26 +6559,38 @@ class CConfig {
65596559
* \brief Get the internal index for a moving boundary <i>val_marker</i>.
65606560
* \return Internal index for a moving boundary <i>val_marker</i>.
65616561
*/
6562-
unsigned short GetMarker_Moving(string val_marker) const;
6562+
unsigned short GetMarker_Moving(const string& val_marker) const;
65636563

65646564
/*!
6565-
* \brief Get bool if marker is moving. <i>val_marker</i>.
6566-
* \param[in] val_marker - String of the marker to test.
6567-
* \return Bool if the marker is a moving boundary <i>val_marker</i>.
6565+
* \brief Get a bool for whether a marker is moving. <i>val_marker</i>.
6566+
* \param[in] val_marker - Name of the marker to test.
6567+
* \return True if the marker is a moving boundary <i>val_marker</i>.
65686568
*/
6569-
bool GetMarker_Moving_Bool(string val_marker) const;
6569+
inline bool GetMarker_Moving_Bool(const string& val_marker) const {
6570+
return GetMarker_Moving(val_marker) < nMarker_Moving;
6571+
}
65706572

65716573
/*!
65726574
* \brief Get the internal index for a DEFORM_MESH boundary <i>val_marker</i>.
65736575
* \return Internal index for a DEFORM_MESH boundary <i>val_marker</i>.
65746576
*/
6575-
unsigned short GetMarker_Deform_Mesh(string val_marker) const;
6577+
unsigned short GetMarker_Deform_Mesh(const string& val_marker) const;
65766578

65776579
/*!
65786580
* \brief Get the internal index for a DEFORM_MESH_SYM_PLANE boundary <i>val_marker</i>.
65796581
* \return Internal index for a DEFORM_MESH_SYM_PLANE boundary <i>val_marker</i>.
65806582
*/
6581-
unsigned short GetMarker_Deform_Mesh_Sym_Plane(string val_marker) const;
6583+
unsigned short GetMarker_Deform_Mesh_Sym_Plane(const string& val_marker) const;
6584+
6585+
/*!
6586+
* \brief Get a bool for whether the marker is deformed. <i>val_marker</i>.
6587+
* \param[in] val_marker - Name of the marker to test.
6588+
* \return True if the marker is a deforming boundary <i>val_marker</i>.
6589+
*/
6590+
inline bool GetMarker_Deform_Mesh_Bool(const string& val_marker) const {
6591+
return GetMarker_Deform_Mesh(val_marker) < nMarker_Deform_Mesh ||
6592+
GetMarker_Deform_Mesh_Sym_Plane(val_marker) < nMarker_Deform_Mesh_Sym_Plane;
6593+
}
65826594

65836595
/*!
65846596
* \brief Get the internal index for a Fluid_Load boundary <i>val_marker</i>.

Common/src/CConfig.cpp

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8676,44 +8676,34 @@ bool CConfig::GetSurface_Movement(unsigned short kind_movement) const {
86768676
return false;
86778677
}
86788678

8679-
unsigned short CConfig::GetMarker_Moving(string val_marker) const {
8680-
unsigned short iMarker_Moving;
8679+
unsigned short CConfig::GetMarker_Moving(const string& val_marker) const {
8680+
unsigned short iMarker;
86818681

86828682
/*--- Find the marker for this moving boundary. ---*/
8683-
for (iMarker_Moving = 0; iMarker_Moving < nMarker_Moving; iMarker_Moving++)
8684-
if (Marker_Moving[iMarker_Moving] == val_marker) break;
8683+
for (iMarker = 0; iMarker < nMarker_Moving; iMarker++)
8684+
if (Marker_Moving[iMarker] == val_marker) break;
86858685

8686-
return iMarker_Moving;
8686+
return iMarker;
86878687
}
86888688

8689-
bool CConfig::GetMarker_Moving_Bool(string val_marker) const {
8690-
unsigned short iMarker_Moving;
8691-
8692-
/*--- Find the marker for this moving boundary, if it exists. ---*/
8693-
for (iMarker_Moving = 0; iMarker_Moving < nMarker_Moving; iMarker_Moving++)
8694-
if (Marker_Moving[iMarker_Moving] == val_marker) return true;
8695-
8696-
return false;
8697-
}
8698-
8699-
unsigned short CConfig::GetMarker_Deform_Mesh(string val_marker) const {
8700-
unsigned short iMarker_Deform_Mesh;
8689+
unsigned short CConfig::GetMarker_Deform_Mesh(const string& val_marker) const {
8690+
unsigned short iMarker;
87018691

87028692
/*--- Find the marker for this interface boundary. ---*/
8703-
for (iMarker_Deform_Mesh = 0; iMarker_Deform_Mesh < nMarker_Deform_Mesh; iMarker_Deform_Mesh++)
8704-
if (Marker_Deform_Mesh[iMarker_Deform_Mesh] == val_marker) break;
8693+
for (iMarker = 0; iMarker < nMarker_Deform_Mesh; iMarker++)
8694+
if (Marker_Deform_Mesh[iMarker] == val_marker) break;
87058695

8706-
return iMarker_Deform_Mesh;
8696+
return iMarker;
87078697
}
87088698

8709-
unsigned short CConfig::GetMarker_Deform_Mesh_Sym_Plane(string val_marker) const {
8710-
unsigned short iMarker_Deform_Mesh_Sym_Plane;
8699+
unsigned short CConfig::GetMarker_Deform_Mesh_Sym_Plane(const string& val_marker) const {
8700+
unsigned short iMarker;
87118701

87128702
/*--- Find the marker for this interface boundary. ---*/
8713-
for (iMarker_Deform_Mesh_Sym_Plane = 0; iMarker_Deform_Mesh_Sym_Plane < nMarker_Deform_Mesh_Sym_Plane; iMarker_Deform_Mesh_Sym_Plane++)
8714-
if (Marker_Deform_Mesh_Sym_Plane[iMarker_Deform_Mesh_Sym_Plane] == val_marker) break;
8703+
for (iMarker = 0; iMarker < nMarker_Deform_Mesh_Sym_Plane; iMarker++)
8704+
if (Marker_Deform_Mesh_Sym_Plane[iMarker] == val_marker) break;
87158705

8716-
return iMarker_Deform_Mesh_Sym_Plane;
8706+
return iMarker;
87178707
}
87188708

87198709
unsigned short CConfig::GetMarker_Fluid_Load(string val_marker) const {

Common/src/geometry/CGeometry.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2592,7 +2592,8 @@ void CGeometry::ComputeSurf_Straightness(CConfig *config,
25922592
other GridMovements are rigid. ---*/
25932593
if ((config->GetMarker_All_KindBC(iMarker) == SYMMETRY_PLANE ||
25942594
config->GetMarker_All_KindBC(iMarker) == EULER_WALL) &&
2595-
!config->GetMarker_Moving_Bool(Local_TagBound)) {
2595+
!config->GetMarker_Moving_Bool(Local_TagBound) &&
2596+
!config->GetMarker_Deform_Mesh_Bool(Local_TagBound)) {
25962597

25972598
/*--- Loop over all global markers, and find the local-global pair via
25982599
matching unique string tags. ---*/

TestCases/parallel_regression.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,16 @@ def main():
13371337
pywrapper_rigidMotion.unsteady = True
13381338
test_list.append(pywrapper_rigidMotion)
13391339

1340+
# Deforming Bump in Channel
1341+
pywrapper_deformingBump = TestCase('pywrapper_deformingBump')
1342+
pywrapper_deformingBump.cfg_dir = "py_wrapper/deforming_bump_in_channel"
1343+
pywrapper_deformingBump.cfg_file = "config.cfg"
1344+
pywrapper_deformingBump.test_iter = 1
1345+
pywrapper_deformingBump.test_vals = [0.5, 0, -2.55436, -1.084594, -0.024882, 2.907803, 8.785498, -0.363585]
1346+
pywrapper_deformingBump.command = TestCase.Command("mpirun -np 2", "python", "run.py")
1347+
pywrapper_deformingBump.unsteady = True
1348+
test_list.append(pywrapper_deformingBump)
1349+
13401350
##############################################
13411351
### Method of Manufactured Solutions (MMS) ###
13421352
##############################################
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
% ------------------------------- SOLVER -------------------------------- %
2+
%
3+
SOLVER= EULER
4+
%
5+
% ----------------------------- FREESTREAM ------------------------------ %
6+
%
7+
MACH_NUMBER= 0.02
8+
AOA= 0.0
9+
FREESTREAM_OPTION= TEMPERATURE_FS
10+
FREESTREAM_PRESSURE= 101325.0
11+
FREESTREAM_TEMPERATURE= 288.15
12+
%
13+
% ------------------------- UNSTEADY SIMULATION ------------------------- %
14+
%
15+
TIME_DOMAIN= YES
16+
TIME_MARCHING= DUAL_TIME_STEPPING-1ST_ORDER
17+
% The time step is ~50x too large to obtain a quasi-steady solution for
18+
% testing.
19+
TIME_STEP= 0.5
20+
MAX_TIME= 5.0
21+
INNER_ITER= 500
22+
TIME_ITER= 2
23+
%
24+
% ------------------------- BOUNDARY CONDITIONS ------------------------- %
25+
%
26+
MARKER_EULER= ( top, slip_bottom, bottom_front, interface, bottom_rear )
27+
MARKER_INLET= ( inlet, 288.6, 101400.0, 1.0, 0.0, 0.0 )
28+
MARKER_OUTLET= ( outlet, 101100.0 )
29+
MARKER_PLOTTING= ( interface )
30+
MARKER_MONITORING= ( interface )
31+
%
32+
% -------------------------- MESH DEFORMATION --------------------------- %
33+
%
34+
DEFORM_MESH= YES
35+
MARKER_DEFORM_MESH = ( interface )
36+
DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME
37+
DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT
38+
DEFORM_LINEAR_SOLVER_PREC= ILU
39+
DEFORM_LINEAR_SOLVER_ITER= 200
40+
DEFORM_LINEAR_SOLVER_ERROR= 1e-9
41+
% DEFORM_CONSOLE_OUTPUT= YES
42+
%
43+
% ----------------------- SPATIAL DISCRETIZATION ------------------------ %
44+
%
45+
NUM_METHOD_GRAD= GREEN_GAUSS
46+
CONV_NUM_METHOD_FLOW= ROE
47+
MUSCL_FLOW= YES
48+
SLOPE_LIMITER_FLOW= NONE
49+
%
50+
% ---------- PSEUDOTIME INTEGRATION / CONVERGENCE ACCELERATION ---------- %
51+
%
52+
TIME_DISCRE_FLOW= EULER_IMPLICIT
53+
CFL_NUMBER= 500
54+
MGLEVEL= 0
55+
LINEAR_SOLVER= FGMRES
56+
LINEAR_SOLVER_PREC= ILU
57+
LINEAR_SOLVER_ERROR= 0.1
58+
LINEAR_SOLVER_ITER= 10
59+
%
60+
% ------------------------ CONVERGENCE CRITERIA ------------------------- %
61+
%
62+
CONV_FIELD= RMS_DENSITY
63+
CONV_RESIDUAL_MINVAL= -8
64+
%
65+
% --------------------------- INPUT / OUTPUT ---------------------------- %
66+
%
67+
RESTART_SOL= NO
68+
SCREEN_OUTPUT= ( TIME_ITER, CUR_TIME, INNER_ITER, RMS_RES, LIFT, DRAG )
69+
MESH_FILENAME= mesh.su2
70+
MESH_FORMAT= SU2
71+
OUTPUT_WRT_FREQ= (5)
72+
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#!/usr/bin/env python
2+
3+
## \file run.py
4+
# \brief Deforming bump in channel.
5+
# \version 7.5.1 "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-2023, 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+
import pysu2
28+
from mpi4py import MPI
29+
import numpy as np
30+
31+
def main():
32+
comm = MPI.COMM_WORLD
33+
rank = comm.Get_rank()
34+
35+
# Initialize the corresponding driver of SU2, this includes solver preprocessing.
36+
try:
37+
SU2Driver = pysu2.CSinglezoneDriver('config.cfg', 1, comm)
38+
except TypeError as exception:
39+
print('A TypeError occured in pysu2.CDriver : ', exception)
40+
raise
41+
42+
# Get the ID of the marker we want to deform.
43+
AllMarkerIDs = SU2Driver.GetMarkerIndices()
44+
MarkerName = 'interface'
45+
MarkerID = AllMarkerIDs[MarkerName] if MarkerName in AllMarkerIDs else -1
46+
47+
# Number of vertices on the specified marker (per rank).
48+
nVertex = SU2Driver.GetNumberMarkerNodes(MarkerID) if MarkerID >= 0 else 0
49+
50+
# Retrieve some control parameters from the driver.
51+
deltaT = SU2Driver.GetUnsteady_TimeStep()
52+
TimeIter = SU2Driver.GetTime_Iter()
53+
nTimeIter = SU2Driver.GetnTimeIter()
54+
time = TimeIter * deltaT
55+
56+
# Extract the initial position of each node on the moving marker.
57+
CoordX = np.zeros(nVertex)
58+
CoordY = np.zeros(nVertex)
59+
for iVertex in range(nVertex):
60+
iPoint = SU2Driver.GetMarkerNode(MarkerID, iVertex)
61+
CoordX[iVertex], CoordY[iVertex] = SU2Driver.GetInitialCoordinates(iPoint)
62+
63+
if rank == 0:
64+
print("\n------------------------------ Begin Solver -----------------------------\n")
65+
66+
# The time loop is defined in Python so that we have acces to SU2 functionalities at each time step.
67+
while (TimeIter < nTimeIter):
68+
# Apply the surface deformation.
69+
for iVertex in range(nVertex):
70+
dy = np.real(DeformFunction(CoordX[iVertex] - 0.9, time))
71+
SU2Driver.SetMarkerDisplacements(MarkerID, iVertex, (0.0, dy))
72+
73+
# Time iteration preprocessing.
74+
SU2Driver.Preprocess(TimeIter)
75+
76+
# Run one time iteration (e.g. dual-time).
77+
SU2Driver.Run()
78+
SU2Driver.Postprocess()
79+
SU2Driver.Update()
80+
81+
# Monitor the solver and output solution to file if required.
82+
stopCalc = SU2Driver.Monitor(TimeIter)
83+
SU2Driver.Output(TimeIter)
84+
85+
if (stopCalc == True):
86+
break
87+
88+
# Update control parameters
89+
TimeIter += 1
90+
time += deltaT
91+
92+
# Postprocess the solver and exit cleanly
93+
SU2Driver.Postprocessing()
94+
95+
96+
# Imposed deformation
97+
def DeformFunction(x,t):
98+
A1 = 0.016
99+
L = 1.0
100+
k1 = 4.730/L
101+
return A1*(np.cosh(k1*x) - np.cos(k1*x) + ((np.cosh(k1*L)-np.cos(k1*L))*(np.sin(k1*x)-np.sinh(k1*x)))/(np.sinh(k1*L) - np.sin(k1*L)))*(np.exp(1j*t*2) + np.exp(-1j*t*2))
102+
103+
104+
if __name__ == '__main__':
105+
main()
106+

0 commit comments

Comments
 (0)