@@ -39,6 +39,7 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
3939 const bool dual_time_2nd = (config[iZone]->GetTime_Marching () == TIME_MARCHING::DT_STEPPING_2ND);
4040 const bool dual_time = (dual_time_1st || dual_time_2nd);
4141 const bool grid_IsMoving = config[iZone]->GetGrid_Movement ();
42+ const bool species = config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE;
4243 const bool heat = config[iZone]->GetWeakly_Coupled_Heat ();
4344
4445 auto solvers0 = solver[iZone][iInst][MESH_0];
@@ -67,6 +68,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
6768 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n ();
6869 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n1 ();
6970 }
71+ if (species) {
72+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n ();
73+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n1 ();
74+ }
7075 if (heat) {
7176 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n ();
7277 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n1 ();
@@ -94,6 +99,9 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
9499 if (turbulent) {
95100 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n ();
96101 }
102+ if (species) {
103+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n ();
104+ }
97105 if (heat) {
98106 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n ();
99107 }
@@ -173,6 +181,9 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
173181 if (turbulent) {
174182 solvers[TURB_SOL]->Set_OldSolution ();
175183 }
184+ if (species) {
185+ solvers[SPECIES_SOL]->Set_OldSolution ();
186+ }
176187 if (heat) {
177188 solvers[HEAT_SOL]->Set_OldSolution ();
178189 }
@@ -195,6 +206,9 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
195206 if (turbulent) {
196207 solvers[TURB_SOL]->GetNodes ()->SetSolution (iPoint, solvers[TURB_SOL]->GetNodes ()->GetSolution_time_n (iPoint));
197208 }
209+ if (species) {
210+ solvers[SPECIES_SOL]->GetNodes ()->SetSolution (iPoint, solvers[SPECIES_SOL]->GetNodes ()->GetSolution_time_n (iPoint));
211+ }
198212 if (heat) {
199213 solvers[HEAT_SOL]->GetNodes ()->SetSolution (iPoint, solvers[HEAT_SOL]->GetNodes ()->GetSolution_time_n (iPoint));
200214 }
@@ -216,6 +230,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
216230 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n (
217231 iPoint, solvers[TURB_SOL]->GetNodes ()->GetSolution_Old (iPoint));
218232 }
233+ if (species) {
234+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n (
235+ iPoint, solvers[SPECIES_SOL]->GetNodes ()->GetSolution_Old (iPoint));
236+ }
219237 if (heat) {
220238 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n (
221239 iPoint, solvers[HEAT_SOL]->GetNodes ()->GetSolution_Old (iPoint));
@@ -239,6 +257,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
239257 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n (
240258 iPoint, solvers[TURB_SOL]->GetNodes ()->GetSolution_time_n1 (iPoint));
241259 }
260+ if (species) {
261+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n (
262+ iPoint, solvers[SPECIES_SOL]->GetNodes ()->GetSolution_time_n1 (iPoint));
263+ }
242264 if (heat) {
243265 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n (
244266 iPoint, solvers[HEAT_SOL]->GetNodes ()->GetSolution_time_n1 (iPoint));
@@ -260,6 +282,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
260282 solvers[TURB_SOL]->GetNodes ()->Set_Solution_time_n1 (
261283 iPoint, solvers[TURB_SOL]->GetNodes ()->GetSolution_Old (iPoint));
262284 }
285+ if (species) {
286+ solvers[SPECIES_SOL]->GetNodes ()->Set_Solution_time_n1 (
287+ iPoint, solvers[SPECIES_SOL]->GetNodes ()->GetSolution_Old (iPoint));
288+ }
263289 if (heat) {
264290 solvers[HEAT_SOL]->GetNodes ()->Set_Solution_time_n1 (
265291 iPoint, solvers[HEAT_SOL]->GetNodes ()->GetSolution_Old (iPoint));
@@ -295,6 +321,12 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
295321 solvers0[ADJTURB_SOL]->GetNodes ()->SetSolution_Direct (iPoint, solvers0[TURB_SOL]->GetNodes ()->GetSolution (iPoint));
296322 END_SU2_OMP_FOR
297323 }
324+ if (species) {
325+ SU2_OMP_FOR_STAT (1024 )
326+ for (auto iPoint = 0ul ; iPoint < geometries[MESH_0]->GetnPoint (); iPoint++)
327+ solvers0[ADJSPECIES_SOL]->GetNodes ()->SetSolution_Direct (iPoint, solvers0[SPECIES_SOL]->GetNodes ()->GetSolution (iPoint));
328+ END_SU2_OMP_FOR
329+ }
298330 if (heat) {
299331 SU2_OMP_FOR_STAT (1024 )
300332 for (auto iPoint = 0ul ; iPoint < geometries[MESH_0]->GetnPoint (); iPoint++)
@@ -316,6 +348,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr
316348 solvers0[ADJTURB_SOL]->Preprocessing (geometries[MESH_0], solvers0, config[iZone],
317349 MESH_0, 0 , RUNTIME_ADJTURB_SYS, false );
318350 }
351+ if (species) {
352+ solvers0[ADJSPECIES_SOL]->Preprocessing (geometries[MESH_0], solvers0, config[iZone],
353+ MESH_0, 0 , RUNTIME_ADJSPECIES_SYS, false );
354+ }
319355 if (heat) {
320356 solvers0[ADJHEAT_SOL]->Preprocessing (geometries[MESH_0], solvers0, config[iZone],
321357 MESH_0, 0 , RUNTIME_ADJHEAT_SYS, false );
@@ -333,6 +369,7 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv
333369 unsigned short iZone, unsigned short iInst, int DirectIter) {
334370
335371 auto solvers = solver[iZone][iInst];
372+ const bool species = config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE;
336373
337374 if (DirectIter >= 0 ) {
338375 if (rank == MASTER_NODE)
@@ -343,6 +380,9 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv
343380 if (turbulent) {
344381 solvers[MESH_0][TURB_SOL]->LoadRestart (geometry[iZone][iInst], solvers, config[iZone], DirectIter, false );
345382 }
383+ if (species) {
384+ solvers[MESH_0][SPECIES_SOL]->LoadRestart (geometry[iZone][iInst], solvers, config[iZone], DirectIter, false );
385+ }
346386 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
347387 solvers[MESH_0][HEAT_SOL]->LoadRestart (geometry[iZone][iInst], solvers, config[iZone], DirectIter, false );
348388 }
@@ -359,6 +399,10 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv
359399 solvers[iMesh][TURB_SOL]->SetFreeStream_Solution (config[iZone]);
360400 solvers[iMesh][TURB_SOL]->Postprocessing (geometry[iZone][iInst][iMesh], solvers[iMesh], config[iZone], iMesh);
361401 }
402+ if (species) {
403+ solvers[iMesh][SPECIES_SOL]->SetFreeStream_Solution (config[iZone]);
404+ solvers[iMesh][SPECIES_SOL]->Postprocessing (geometry[iZone][iInst][iMesh], solvers[iMesh], config[iZone], iMesh);
405+ }
362406 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
363407 solvers[iMesh][HEAT_SOL]->SetFreeStream_Solution (config[iZone]);
364408 solvers[iMesh][HEAT_SOL]->Postprocessing (geometry[iZone][iInst][iMesh], solvers[iMesh], config[iZone], iMesh);
@@ -382,6 +426,9 @@ void CDiscAdjFluidIteration::IterateDiscAdj(CGeometry**** geometry, CSolver*****
382426 if (turbulent && !config[iZone]->GetFrozen_Visc_Disc ()) {
383427 solver[iZone][iInst][MESH_0][ADJTURB_SOL]->ExtractAdjoint_Solution (geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm);
384428 }
429+ if (config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE) {
430+ solver[iZone][iInst][MESH_0][ADJSPECIES_SOL]->ExtractAdjoint_Solution (geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm);
431+ }
385432 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
386433 solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution (geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm);
387434 }
@@ -410,6 +457,10 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry***
410457 solver[iZone][iInst][MESH_0][ADJTURB_SOL]->SetAdjoint_Output (geometry[iZone][iInst][MESH_0], config[iZone]);
411458 }
412459
460+ if (config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE) {
461+ solver[iZone][iInst][MESH_0][ADJSPECIES_SOL]->SetAdjoint_Output (geometry[iZone][iInst][MESH_0], config[iZone]);
462+ }
463+
413464 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
414465 solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->SetAdjoint_Output (geometry[iZone][iInst][MESH_0], config[iZone]);
415466 }
@@ -443,6 +494,9 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge
443494 if (turbulent && !config[iZone]->GetFrozen_Visc_Disc ()) {
444495 solver[iZone][iInst][MESH_0][ADJTURB_SOL]->RegisterSolution (geometry[iZone][iInst][MESH_0], config[iZone]);
445496 }
497+ if (config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE) {
498+ solver[iZone][iInst][MESH_0][ADJSPECIES_SOL]->RegisterSolution (geometry[iZone][iInst][MESH_0], config[iZone]);
499+ }
446500 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
447501 solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->RegisterSolution (geometry[iZone][iInst][MESH_0], config[iZone]);
448502 }
@@ -498,6 +552,12 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry****
498552 solver[iZone][iInst][MESH_0][TURB_SOL]->InitiateComms (geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION);
499553 solver[iZone][iInst][MESH_0][TURB_SOL]->CompleteComms (geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION);
500554 }
555+ if (config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE) {
556+ solver[iZone][iInst][MESH_0][SPECIES_SOL]->Preprocessing (geometry[iZone][iInst][MESH_0], solver[iZone][iInst][MESH_0],
557+ config[iZone], MESH_0, NO_RK_ITER, RUNTIME_FLOW_SYS, true );
558+ solver[iZone][iInst][MESH_0][SPECIES_SOL]->InitiateComms (geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION);
559+ solver[iZone][iInst][MESH_0][SPECIES_SOL]->CompleteComms (geometry[iZone][iInst][MESH_0], config[iZone], SOLUTION);
560+ }
501561
502562 }
503563 END_SU2_OMP_PARALLEL
@@ -532,6 +592,9 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g
532592 if (turbulent && !config[iZone]->GetFrozen_Visc_Disc ()) {
533593 solver[iZone][iInst][MESH_0][ADJTURB_SOL]->RegisterOutput (geometry[iZone][iInst][MESH_0], config[iZone]);
534594 }
595+ if (config[iZone]->GetKind_Species_Model () != SPECIES_MODEL::NONE) {
596+ solver[iZone][iInst][MESH_0][ADJSPECIES_SOL]->RegisterOutput (geometry[iZone][iInst][MESH_0], config[iZone]);
597+ }
535598 if (config[iZone]->GetWeakly_Coupled_Heat ()) {
536599 solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->RegisterOutput (geometry[iZone][iInst][MESH_0], config[iZone]);
537600 }
0 commit comments