Skip to content

Commit f7207ac

Browse files
authored
Merge pull request #1199 from su2code/fix_legacy_deformation
Fix grid velocities in dual-time RANS simulations with deforming grids (aeroelastic and legacy FSI)
2 parents 42bb167 + f32e453 commit f7207ac

14 files changed

+205
-158
lines changed

SU2_CFD/include/integration/CIntegration.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,20 @@ class CIntegration {
125125
inline bool GetConvergence_FullMG(void) const { return Convergence_FullMG; }
126126

127127
/*!
128-
* \brief Save the solution, and volume at different time steps.
128+
* \brief Save the geometry at different time steps.
129129
* \param[in] geometry - Geometrical definition of the problem.
130-
* \param[in] solution - Flow solution.
130+
* \param[in] solver - Mesh solver.
131131
* \param[in] config - Definition of the particular problem.
132132
*/
133-
void SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh);
133+
void SetDualTime_Geometry(CGeometry *geometry, CSolver *mesh_solver, const CConfig *config, unsigned short iMesh);
134134

135135
/*!
136-
* \brief Save the structural solution at different time steps.
136+
* \brief Save the solution at different time steps, and reset certain fields for the next timestep.
137137
* \param[in] geometry - Geometrical definition of the problem.
138-
* \param[in] solver_container - Structural solution.
138+
* \param[in] solver - Some solver.
139139
* \param[in] config - Definition of the particular problem.
140140
*/
141-
void SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh);
141+
virtual void SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh);
142142

143143
/*!
144144
* \brief A virtual member.

SU2_CFD/include/integration/CStructuralIntegration.hpp

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ class CStructuralIntegration final : public CIntegration {
5151
CNumerics ******numerics_container, CConfig **config,
5252
unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override;
5353

54+
/*!
55+
* \brief Save the solution at different time steps, and reset certain fields for the next timestep.
56+
* \param[in] geometry - Geometrical definition of the problem.
57+
* \param[in] solver - Structural solver.
58+
* \param[in] config - Definition of the problem.
59+
*/
60+
void SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh) override;
61+
5462
private:
5563
/*!
5664
* \brief Do the space integration of the numerical system on a FEM framework.

SU2_CFD/include/iteration/CFluidIteration.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class CFluidIteration : public CIteration {
115115
CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone,
116116
unsigned short val_iInst) override;
117117

118+
private:
119+
118120
/*!
119121
* \brief Imposes a gust via the grid velocities.
120122
* \author S. Padron
@@ -146,4 +148,11 @@ class CFluidIteration : public CIteration {
146148
* \return Boolean indicating weather calculation should be stopped
147149
*/
148150
bool MonitorFixed_CL(COutput* output, CGeometry* geometry, CSolver** solver, CConfig* config);
151+
152+
/*!
153+
* \brief Store old aeroelastic solutions
154+
* \param[in,out] config - Definition of the particular problem.
155+
*/
156+
void SetDualTime_Aeroelastic(CConfig* config) const;
157+
149158
};

SU2_CFD/include/solvers/CFEASolver.hpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class CFEASolver : public CSolver {
314314
* \param[in] numerics - Description of the numerical method.
315315
* \param[in] config - Definition of the particular problem.
316316
*/
317-
void Compute_MassMatrix(CGeometry *geometry,
317+
void Compute_MassMatrix(const CGeometry *geometry,
318318
CNumerics **numerics,
319319
const CConfig *config) final;
320320

@@ -324,7 +324,7 @@ class CFEASolver : public CSolver {
324324
* \param[in] numerics - Description of the numerical method.
325325
* \param[in] config - Definition of the particular problem.
326326
*/
327-
void Compute_MassRes(CGeometry *geometry,
327+
void Compute_MassRes(const CGeometry *geometry,
328328
CNumerics **numerics,
329329
const CConfig *config) final;
330330

@@ -472,7 +472,7 @@ class CFEASolver : public CSolver {
472472
* \param[in] numerics - Numerical methods.
473473
* \param[in] config - Definition of the particular problem.
474474
*/
475-
void ImplicitNewmark_Iteration(CGeometry *geometry,
475+
void ImplicitNewmark_Iteration(const CGeometry *geometry,
476476
CNumerics **numerics,
477477
const CConfig *config) final;
478478

@@ -481,22 +481,22 @@ class CFEASolver : public CSolver {
481481
* \param[in] geometry - Geometrical definition of the problem.
482482
* \param[in] config - Definition of the particular problem.
483483
*/
484-
void ImplicitNewmark_Update(CGeometry *geometry, CConfig *config) final;
484+
void ImplicitNewmark_Update(const CGeometry *geometry, const CConfig *config) final;
485485

486486
/*!
487487
* \brief A virtual member.
488488
* \param[in] geometry - Geometrical definition of the problem.
489489
* \param[in] config - Definition of the particular problem.
490490
*/
491-
void ImplicitNewmark_Relaxation(CGeometry *geometry, CConfig *config) final;
491+
void ImplicitNewmark_Relaxation(const CGeometry *geometry, const CConfig *config) final;
492492

493493
/*!
494494
* \brief Iterate using an implicit Generalized Alpha solver.
495495
* \param[in] geometry - Geometrical definition of the problem.
496496
* \param[in] numerics - Numerical methods.
497497
* \param[in] config - Definition of the particular problem.
498498
*/
499-
void GeneralizedAlpha_Iteration(CGeometry *geometry,
499+
void GeneralizedAlpha_Iteration(const CGeometry *geometry,
500500
CNumerics **numerics,
501501
const CConfig *config) final;
502502

@@ -505,21 +505,21 @@ class CFEASolver : public CSolver {
505505
* \param[in] geometry - Geometrical definition of the problem.
506506
* \param[in] config - Definition of the particular problem.
507507
*/
508-
void GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CConfig *config) final;
508+
void GeneralizedAlpha_UpdateDisp(const CGeometry *geometry, const CConfig *config) final;
509509

510510
/*!
511511
* \brief Update the solution using an implicit Generalized Alpha solver.
512512
* \param[in] geometry - Geometrical definition of the problem.
513513
* \param[in] config - Definition of the particular problem.
514514
*/
515-
void GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CConfig *config) final;
515+
void GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, const CConfig *config) final;
516516

517517
/*!
518518
* \brief Update the solution using an implicit Generalized Alpha solver.
519519
* \param[in] geometry - Geometrical definition of the problem.
520520
* \param[in] config - Definition of the particular problem.
521521
*/
522-
void GeneralizedAlpha_UpdateLoads(CGeometry *geometry, const CConfig *config) final;
522+
void GeneralizedAlpha_UpdateLoads(const CGeometry *geometry, const CConfig *config) final;
523523

524524
/*!
525525
* \brief Postprocessing.

SU2_CFD/include/solvers/CSolver.hpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1557,7 +1557,7 @@ class CSolver {
15571557
* \param[in] numerics - Numerical methods.
15581558
* \param[in] config - Definition of the particular problem.
15591559
*/
1560-
inline virtual void ImplicitNewmark_Iteration(CGeometry *geometry,
1560+
inline virtual void ImplicitNewmark_Iteration(const CGeometry *geometry,
15611561
CNumerics **numerics,
15621562
const CConfig *config) { }
15631563

@@ -1567,25 +1567,25 @@ class CSolver {
15671567
* \param[in] solver_container - Container vector with all the solutions.
15681568
* \param[in] config - Definition of the particular problem.
15691569
*/
1570-
inline virtual void ImplicitNewmark_Update(CGeometry *geometry,
1571-
CConfig *config) { }
1570+
inline virtual void ImplicitNewmark_Update(const CGeometry *geometry,
1571+
const CConfig *config) { }
15721572

15731573
/*!
15741574
* \brief A virtual member.
15751575
* \param[in] geometry - Geometrical definition of the problem.
15761576
* \param[in] solver_container - Container vector with all the solutions.
15771577
* \param[in] config - Definition of the particular problem.
15781578
*/
1579-
inline virtual void ImplicitNewmark_Relaxation(CGeometry *geometry,
1580-
CConfig *config) { }
1579+
inline virtual void ImplicitNewmark_Relaxation(const CGeometry *geometry,
1580+
const CConfig *config) { }
15811581

15821582
/*!
15831583
* \brief A virtual member.
15841584
* \param[in] geometry - Geometrical definition of the problem.
15851585
* \param[in] numerics - Numerical methods.
15861586
* \param[in] config - Definition of the particular problem.
15871587
*/
1588-
inline virtual void GeneralizedAlpha_Iteration(CGeometry *geometry,
1588+
inline virtual void GeneralizedAlpha_Iteration(const CGeometry *geometry,
15891589
CNumerics **numerics,
15901590
const CConfig *config) { }
15911591

@@ -1595,25 +1595,25 @@ class CSolver {
15951595
* \param[in] solver_container - Container vector with all the solutions.
15961596
* \param[in] config - Definition of the particular problem.
15971597
*/
1598-
inline virtual void GeneralizedAlpha_UpdateDisp(CGeometry *geometry,
1599-
CConfig *config) { }
1598+
inline virtual void GeneralizedAlpha_UpdateDisp(const CGeometry *geometry,
1599+
const CConfig *config) { }
16001600

16011601
/*!
16021602
* \brief A virtual member.
16031603
* \param[in] geometry - Geometrical definition of the problem.
16041604
* \param[in] solver_container - Container vector with all the solutions.
16051605
* \param[in] config - Definition of the particular problem.
16061606
*/
1607-
inline virtual void GeneralizedAlpha_UpdateSolution(CGeometry *geometry,
1608-
CConfig *config) { }
1607+
inline virtual void GeneralizedAlpha_UpdateSolution(const CGeometry *geometry,
1608+
const CConfig *config) { }
16091609

16101610
/*!
16111611
* \brief A virtual member.
16121612
* \param[in] geometry - Geometrical definition of the problem.
16131613
* \param[in] solver_container - Container vector with all the solutions.
16141614
* \param[in] config - Definition of the particular problem.
16151615
*/
1616-
inline virtual void GeneralizedAlpha_UpdateLoads(CGeometry *geometry,
1616+
inline virtual void GeneralizedAlpha_UpdateLoads(const CGeometry *geometry,
16171617
const CConfig *config) { }
16181618

16191619
/*!
@@ -3770,7 +3770,7 @@ class CSolver {
37703770
* \param[in] numerics - Description of the numerical method.
37713771
* \param[in] config - Definition of the particular problem.
37723772
*/
3773-
inline virtual void Compute_MassMatrix(CGeometry *geometry,
3773+
inline virtual void Compute_MassMatrix(const CGeometry *geometry,
37743774
CNumerics **numerics,
37753775
const CConfig *config) { }
37763776

@@ -3780,7 +3780,7 @@ class CSolver {
37803780
* \param[in] numerics - Description of the numerical method.
37813781
* \param[in] config - Definition of the particular problem.
37823782
*/
3783-
inline virtual void Compute_MassRes(CGeometry *geometry,
3783+
inline virtual void Compute_MassRes(const CGeometry *geometry,
37843784
CNumerics **numerics,
37853785
const CConfig *config) { }
37863786

SU2_CFD/src/integration/CIntegration.cpp

+14-113
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,10 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai
208208

209209
}
210210

211-
void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) {
211+
void CIntegration::SetDualTime_Geometry(CGeometry *geometry, CSolver *mesh_solver, const CConfig *config, unsigned short iMesh) {
212212

213213
SU2_OMP_PARALLEL
214214
{
215-
/*--- Store old solution, volumes and coordinates (in case there is grid movement). ---*/
216-
217-
solver->GetNodes()->Set_Solution_time_n1();
218-
solver->GetNodes()->Set_Solution_time_n();
219215

220216
geometry->nodes->SetVolume_nM1();
221217
geometry->nodes->SetVolume_n();
@@ -225,6 +221,19 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon
225221
geometry->nodes->SetCoord_n();
226222
}
227223

224+
if ((iMesh==MESH_0) && config->GetDeform_Mesh()) mesh_solver->SetDualTime_Mesh();
225+
226+
} // end SU2_OMP_PARALLEL
227+
}
228+
229+
void CIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh) {
230+
231+
SU2_OMP_PARALLEL
232+
{
233+
/*--- Store old solution ---*/
234+
solver->GetNodes()->Set_Solution_time_n1();
235+
solver->GetNodes()->Set_Solution_time_n();
236+
228237
SU2_OMP_MASTER
229238
solver->ResetCFLAdapt();
230239
SU2_OMP_BARRIER
@@ -239,113 +248,5 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon
239248
solver->GetNodes()->SetLocalCFL(iPoint, config->GetCFL(iMesh));
240249
}
241250

242-
/*--- Store old aeroelastic solutions ---*/
243-
SU2_OMP_MASTER
244-
if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation() && (iMesh == MESH_0)) {
245-
246-
config->SetAeroelastic_n1();
247-
config->SetAeroelastic_n();
248-
249-
/*--- Also communicate plunge and pitch to the master node. Needed for output in case of parallel run ---*/
250-
251-
#ifdef HAVE_MPI
252-
su2double plunge, pitch, *plunge_all = NULL, *pitch_all = NULL;
253-
unsigned short iMarker, iMarker_Monitoring;
254-
unsigned long iProcessor, owner, *owner_all = NULL;
255-
256-
string Marker_Tag, Monitoring_Tag;
257-
int nProcessor = size;
258-
259-
/*--- Only if master node allocate memory ---*/
260-
261-
if (rank == MASTER_NODE) {
262-
plunge_all = new su2double[nProcessor];
263-
pitch_all = new su2double[nProcessor];
264-
owner_all = new unsigned long[nProcessor];
265-
}
266-
267-
/*--- Find marker and give it's plunge and pitch coordinate to the master node ---*/
268-
269-
for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) {
270-
271-
for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
272-
273-
Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring);
274-
Marker_Tag = config->GetMarker_All_TagBound(iMarker);
275-
if (Marker_Tag == Monitoring_Tag) { owner = 1; break;
276-
} else {
277-
owner = 0;
278-
}
279-
280-
}
281-
plunge = config->GetAeroelastic_plunge(iMarker_Monitoring);
282-
pitch = config->GetAeroelastic_pitch(iMarker_Monitoring);
283-
284-
/*--- Gather the data on the master node. ---*/
285-
286-
SU2_MPI::Gather(&plunge, 1, MPI_DOUBLE, plunge_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm());
287-
SU2_MPI::Gather(&pitch, 1, MPI_DOUBLE, pitch_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm());
288-
SU2_MPI::Gather(&owner, 1, MPI_UNSIGNED_LONG, owner_all, 1, MPI_UNSIGNED_LONG, MASTER_NODE, SU2_MPI::GetComm());
289-
290-
/*--- Set plunge and pitch on the master node ---*/
291-
292-
if (rank == MASTER_NODE) {
293-
for (iProcessor = 0; iProcessor < (unsigned long)nProcessor; iProcessor++) {
294-
if (owner_all[iProcessor] == 1) {
295-
config->SetAeroelastic_plunge(iMarker_Monitoring, plunge_all[iProcessor]);
296-
config->SetAeroelastic_pitch(iMarker_Monitoring, pitch_all[iProcessor]);
297-
break;
298-
}
299-
}
300-
}
301-
302-
}
303-
304-
if (rank == MASTER_NODE) {
305-
delete [] plunge_all;
306-
delete [] pitch_all;
307-
delete [] owner_all;
308-
}
309-
#endif
310-
}
311-
SU2_OMP_BARRIER
312-
313251
} // end SU2_OMP_PARALLEL
314-
315-
}
316-
317-
void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) {
318-
319-
bool fsi = config->GetFSI_Simulation();
320-
321-
/*--- Update the solution according to the integration scheme used ---*/
322-
323-
switch (config->GetKind_TimeIntScheme_FEA()) {
324-
case (CD_EXPLICIT):
325-
break;
326-
case (NEWMARK_IMPLICIT):
327-
if (fsi) solver_container[FEA_SOL]->ImplicitNewmark_Relaxation(geometry, config);
328-
break;
329-
case (GENERALIZED_ALPHA):
330-
solver_container[FEA_SOL]->GeneralizedAlpha_UpdateSolution(geometry, config);
331-
solver_container[FEA_SOL]->GeneralizedAlpha_UpdateLoads(geometry, config);
332-
break;
333-
}
334-
335-
/*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/
336-
337-
solver_container[FEA_SOL]->GetNodes()->Set_Solution_time_n();
338-
solver_container[FEA_SOL]->GetNodes()->SetSolution_Vel_time_n();
339-
solver_container[FEA_SOL]->GetNodes()->SetSolution_Accel_time_n();
340-
341-
/*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/
342-
343-
if (fsi) {
344-
345-
su2double WAitk=0.0;
346-
347-
WAitk = solver_container[FEA_SOL]->GetWAitken_Dyn();
348-
solver_container[FEA_SOL]->SetWAitken_Dyn_tn1(WAitk);
349-
350-
}
351252
}

0 commit comments

Comments
 (0)