Skip to content

Commit d42c8b7

Browse files
authored
Merge pull request #1295 from Nicola-Fonzi/publish
Fix restart logic in python FSI
2 parents 919900a + cf62dcf commit d42c8b7

6 files changed

Lines changed: 25 additions & 19 deletions

File tree

SU2_CFD/include/drivers/CDriver.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,11 @@ class CDriver {
525525
* \param[in] iVertex - Vertex identifier.
526526
* \return Unit normal (vector) at the vertex.
527527
*/
528-
vector<passivedouble> GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const;
528+
vector<passivedouble> GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal = false) const;
529+
530+
inline vector<passivedouble> GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const {
531+
return GetVertexNormal(iMarker, iVertex, true);
532+
}
529533

530534
/*!
531535
* \brief Get all the boundary markers tags.

SU2_CFD/src/python_wrapper_structure.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ vector<passivedouble> CDriver::GetInitialMeshCoord(unsigned short iMarker, unsig
228228
return coord_passive;
229229
}
230230

231-
vector<passivedouble> CDriver::GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const {
231+
vector<passivedouble> CDriver::GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal) const {
232232

233233
su2double *Normal;
234234
su2double Area;
@@ -237,6 +237,15 @@ vector<passivedouble> CDriver::GetVertexUnitNormal(unsigned short iMarker, unsig
237237

238238
Normal = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNormal();
239239

240+
if (!unitNormal) {
241+
242+
ret_Normal_passive[0] = SU2_TYPE::GetValue(Normal[0]);
243+
ret_Normal_passive[1] = SU2_TYPE::GetValue(Normal[1]);
244+
if(nDim>2) ret_Normal_passive[2] = SU2_TYPE::GetValue(Normal[2]);
245+
246+
return ret_Normal_passive;
247+
}
248+
240249
Area = GeometryToolbox::Norm(nDim, Normal);
241250

242251
ret_Normal[0] = Normal[0]/Area;

SU2_CFD/src/solvers/CMeshSolver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ void CMeshSolver::SetMinMaxVolume(CGeometry *geometry, CConfig *config, bool upd
284284
SU2_OMP_BARRIER
285285

286286
AD::EndPassive(wasActive);
287+
287288
}
288289

289290
void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) {

SU2_PY/FSI_tools/FSIInterface.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,8 +1900,8 @@ def UnsteadyFSI(self,FSI_config, FluidSolver, SolidSolver):
19001900

19011901
if FSI_config['RESTART_SOL'] == 'YES':
19021902
NbTimeIter = ((totTime)/deltaT)-1
1903-
time = (FSI_config['RESTART_ITER']+1)*deltaT
1904-
TimeIter = FSI_config['RESTART_ITER']+1
1903+
time = (FSI_config['RESTART_ITER'])*deltaT
1904+
TimeIter = FSI_config['RESTART_ITER']
19051905
else:
19061906
NbTimeIter = (totTime/deltaT)-1 # number of time iterations
19071907
time = 0.0 # initial time
@@ -1922,13 +1922,6 @@ def UnsteadyFSI(self,FSI_config, FluidSolver, SolidSolver):
19221922
TimeIterTreshold = -1
19231923
self.getSolidInterfaceDisplacement(SolidSolver)
19241924
self.displacementPredictor(FSI_config, SolidSolver, deltaT)
1925-
# We need now to update the solution because both restarter functions (solid and fluid)
1926-
# load the files in the solution containers, pushing back the previous solutions. We need
1927-
# then to push it back once more to compute the solution at the next time level
1928-
# Also this is required because in the fluid iteration preprocessor, if we do not update
1929-
# and step to the next time level, there is a flag "fsi" that will initialise the flow
1930-
if myid in self.fluidSolverProcessors:
1931-
FluidSolver.Update()
19321925
if myid in self.solidSolverProcessors:
19331926
SolidSolver.updateSolution()
19341927
#If no restart

SU2_PY/FSI_tools/FSI_config.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,6 @@ def applyDefaults(self):
122122
if self._ConfigContent["CSD_SOLVER"] == "IMPOSED":
123123
self._ConfigContent["AITKEN_RELAX"] = "STATIC"
124124
self._ConfigContent["AITKEN_PARAM"] = 1.0
125+
126+
if self._ConfigContent["RESTART_SOL"] == "YES":
127+
self._ConfigContent["TIME_TRESHOLD"] = -1

SU2_PY/SU2_Nastran/pysu2_nastran.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ def __computeInterfacePosVel(self, initialize):
722722
Y_disp = self.Uy.dot(self.q)
723723
Z_disp = self.Uz.dot(self.q)
724724

725-
for iPoint in range(len(self.node)):
725+
for iPoint in range(self.nPoint):
726726
coord0 = self.node[iPoint].GetCoord0()
727727
self.node[iPoint].SetCoord((X_disp[iPoint]+coord0[0],Y_disp[iPoint]+coord0[1],Z_disp[iPoint]+coord0[2]))
728728
self.node[iPoint].SetVel((X_vel[iPoint],Y_vel[iPoint],Z_vel[iPoint]))
@@ -870,7 +870,7 @@ def __setRestart(self, timeIter):
870870
print("The restart iteration was not found in the structural history")
871871
break
872872
line = line.strip('\r\n').split()
873-
if int(line[1])==(self.Config["RESTART_ITER"]-1):
873+
if int(line[1])==(self.Config["RESTART_ITER"]-2):
874874
break
875875
index = 0
876876
for index_mode in range(self.nDof):
@@ -896,7 +896,7 @@ def __setRestart(self, timeIter):
896896
print("The restart iteration was not found in the structural history")
897897
break
898898
line = line.strip('\r\n').split()
899-
if int(line[1])==self.Config["RESTART_ITER"]:
899+
if int(line[1])==(self.Config["RESTART_ITER"]-1):
900900
break
901901
index = 0
902902
for index_mode in range(self.nDof):
@@ -935,11 +935,7 @@ def updateSolution(self):
935935
self.__reset(self.qddot)
936936
self.__reset(self.a)
937937

938-
makerID = list(self.markers.keys())
939-
makerID = makerID[0]
940-
nodeList = self.markers[makerID]
941-
942-
for iPoint in nodeList:
938+
for iPoint in range(self.nPoint):
943939
self.node[iPoint].updateCoordVel()
944940

945941

0 commit comments

Comments
 (0)