From 8804def361f5b72acf56712dea45df8cc66edad0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 17:43:48 +0000 Subject: [PATCH 001/192] extend driver for time-accurate problems --- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 114 ++++++++++++++---- 1 file changed, 88 insertions(+), 26 deletions(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 61516cce31c..76341b53131 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -122,6 +122,8 @@ CDiscAdjMultizoneDriver::~CDiscAdjMultizoneDriver(){ void CDiscAdjMultizoneDriver::StartSolver() { + bool time_domain = driver_config->GetTime_Domain(); + /*--- Main external loop of the solver. Runs for the number of time steps required. ---*/ if (rank == MASTER_NODE) { @@ -129,42 +131,61 @@ void CDiscAdjMultizoneDriver::StartSolver() { cout << "\nSimulation Run using the Discrete Adjoint Multizone Driver" << endl; - if (driver_config->GetTime_Domain()) - SU2_MPI::Error("The discrete adjoint multizone driver is not ready for unsteady computations yet.", - CURRENT_FUNCTION); + if (time_domain) + cout << "The simulation will run for " << driver_config->GetnTime_Iter() << " time steps." << endl; } - for (iZone = 0; iZone < nZone; iZone++){ + while ( TimeIter < driver_config->GetnTime_Iter()) { + + for (iZone = 0; iZone < nZone; iZone++) { - /*--- Set the value of the external iteration to TimeIter. -------------------------------------*/ - /*--- TODO: This should be generalised for an homogeneous criteria throughout the code. --------*/ - config_container[iZone]->SetTimeIter(0); + /*--- Set current time iteration ---*/ + config_container[iZone]->SetTimeIter(TimeIter); - } + if (time_domain) + config_container[iZone]->SetPhysicalTime(static_cast(TimeIter)*config_container[iZone]->GetDelta_UnstTimeND()); + else + config_container[iZone]->SetPhysicalTime(0.0); + } - /*--- Size and initialize the matrix of cross-terms. ---*/ + /*--- Size and initialize the matrix of cross-terms. ---*/ - InitializeCrossTerms(); + InitializeCrossTerms(); - /*--- We directly start the (steady-state) discrete adjoint computation. ---*/ + /*--- We directly start the discrete adjoint computation. ---*/ - Run(); + Run(); - /*--- Output the solution in files. ---*/ + /*--- Output the solution in files for each time iteration. ---*/ - Output(TimeIter); + Output(TimeIter); + TimeIter++; + } } void CDiscAdjMultizoneDriver::Run() { unsigned long wrt_sol_freq = 9999; unsigned long nOuterIter = driver_config->GetnOuter_Iter(); + bool time_domain = driver_config->GetTime_Domain(); vector > fixPtCorrector(nZone); + /*--- Reset external and solution ---*/ for (iZone = 0; iZone < nZone; iZone++) { + for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; + if (solver != nullptr) { + solver->GetNodes()->SetExternalZero(); + } + } + Set_Solution_To_BGSSolution_k(iZone); + } - wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); + for (iZone = 0; iZone < nZone; iZone++) { + + if (!time_domain) + wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); iteration_container[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, @@ -197,13 +218,13 @@ void CDiscAdjMultizoneDriver::Run() { /*--- Initialize External with the objective function gradient. ---*/ - su2double rhs_norm = 0.0; + su2double rhs_norm = 0.0; for (iZone = 0; iZone < nZone; iZone++) { iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0); + surface_movement, grid_movement, FFDBox, iZone, INST_0, false); Add_Solution_To_External(iZone); for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { @@ -303,10 +324,9 @@ void CDiscAdjMultizoneDriver::Run() { ComputeAdjoints(iZone, eval_transfer); /*--- Extracting adjoints for solvers in iZone w.r.t. to outputs in iZone (diagonal part). ---*/ - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0); + surface_movement, grid_movement, FFDBox, iZone, INST_0, false); /*--- Use QN driver to improve the solution. ---*/ @@ -343,7 +363,7 @@ void CDiscAdjMultizoneDriver::Run() { config_container[jZone]->SetInnerIter(0); iteration_container[jZone][INST_0]->Iterate(output_container[jZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, jZone, INST_0); + surface_movement, grid_movement, FFDBox, jZone, INST_0, true); /*--- Extract the cross-term performing a relaxed update of it and of the sum (External) for jZone. ---*/ @@ -359,7 +379,7 @@ void CDiscAdjMultizoneDriver::Run() { /*--- Set the multizone output. ---*/ - driver_output->SetMultizoneHistory_Output(output_container, config_container, driver_config, 0, iOuterIter); + driver_output->SetMultizoneHistory_Output(output_container, config_container, driver_config, TimeIter, iOuterIter); /*--- Check for convergence. ---*/ @@ -376,6 +396,46 @@ void CDiscAdjMultizoneDriver::Run() { if (checkSensitivity) EvaluateSensitivities(iOuterIter, StopCalc); } + + /*--- Add current time sensitivity ---*/ + /*--- Cumulative sensitivity stored here in order to exclude summation within outer iteration ---*/ + for (iZone = 0; iZone < nZone; iZone++) { + + auto solvers = solver_container[iZone][INST_0][MESH_0]; + auto geometry = geometry_container[iZone][INST_0][MESH_0]; + int IDX_SOL; + + switch (config_container[iZone]->GetKind_Solver()) { + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: + if(config_container[iZone]->GetDeform_Mesh()) IDX_SOL = ADJMESH_SOL; + else IDX_SOL = ADJFLOW_SOL; + break; + case DISC_ADJ_HEAT: + IDX_SOL = ADJHEAT_SOL; + break; + case DISC_ADJ_FEM: + IDX_SOL = ADJFEA_SOL; + break; + } + + su2double Sensitivity; + for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { + for (unsigned short iDim = 0; iDim < nDim; iDim++) { + + /*--- Current time iteration sensitivity ---*/ + Sensitivity = solvers[IDX_SOL]->GetNodes()->GetSensitivity(iPoint, iDim); + + /*--- Update old sensitivity container ---*/ + solvers[IDX_SOL]->GetNodes()->SetSensitivity_Old(iPoint, iDim, Sensitivity + + solvers[IDX_SOL]->GetNodes()->GetSensitivity_Old(iPoint, iDim)); + + /*--- Update sensitivity ---*/ + solvers[IDX_SOL]->GetNodes()->SetSensitivity( + iPoint, iDim, solvers[IDX_SOL]->GetNodes()->GetSensitivity_Old(iPoint, iDim)); + } + } + } } void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long iOuterIter, bool StopCalc) { @@ -455,11 +515,13 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long iOuterIter, bo AD::ClearAdjoints(); - for (iZone = 0; iZone < nZone; iZone++) { + if (!driver_config->GetTime_Domain()) { + for (iZone = 0; iZone < nZone; iZone++) { - output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0], - config_container[iZone], - solver_container[iZone][INST_0][MESH_0], iOuterIter, StopCalc); + output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0], + config_container[iZone], + solver_container[iZone][INST_0][MESH_0], iOuterIter, StopCalc); + } } } @@ -595,7 +657,7 @@ void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, unsigned sho /*--- Iterate the zone as a block a single time ---*/ direct_iteration[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0); + surface_movement, grid_movement, FFDBox, iZone, INST_0, false); /*--- Print residuals in the first iteration ---*/ From 880b8cae0f9488fd6a912c185a56bc8c5b38754d Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 18:30:58 +0000 Subject: [PATCH 002/192] identify and update previous time solutions for diagonal terms only --- SU2_CFD/include/iteration/CAdjFluidIteration.hpp | 2 +- SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp | 3 ++- SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp | 3 ++- SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp | 3 ++- SU2_CFD/include/iteration/CFEAIteration.hpp | 5 ++++- SU2_CFD/include/iteration/CFEMFluidIteration.hpp | 5 ++++- SU2_CFD/include/iteration/CFluidIteration.hpp | 5 ++++- SU2_CFD/include/iteration/CHeatIteration.hpp | 5 ++++- SU2_CFD/include/iteration/CIteration.hpp | 3 ++- SU2_CFD/include/solvers/CDiscAdjSolver.hpp | 3 ++- SU2_CFD/include/solvers/CSolver.hpp | 9 +++++++++ SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp | 4 ++-- SU2_CFD/src/drivers/CDriver.cpp | 6 +++--- SU2_CFD/src/iteration/CAdjFluidIteration.cpp | 2 +- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 6 +++--- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 10 +++++----- SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp | 2 +- SU2_CFD/src/iteration/CFEAIteration.cpp | 4 ++-- SU2_CFD/src/iteration/CFEMFluidIteration.cpp | 2 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 ++-- SU2_CFD/src/iteration/CHeatIteration.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 6 +++--- 22 files changed, 60 insertions(+), 34 deletions(-) diff --git a/SU2_CFD/include/iteration/CAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CAdjFluidIteration.hpp index 68c99d7d0df..0623e643768 100644 --- a/SU2_CFD/include/iteration/CAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CAdjFluidIteration.hpp @@ -67,7 +67,7 @@ class CAdjFluidIteration : public CFluidIteration { void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the adjoint fluid system. diff --git a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp index e2aac672de1..1708ffa905c 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp @@ -86,11 +86,12 @@ class CDiscAdjFEAIteration : public CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the discrete adjoint mean flow system. diff --git a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp index 4545b67b461..25e8c944641 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp @@ -82,11 +82,12 @@ class CDiscAdjFluidIteration : public CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the discrete adjoint fluid system. diff --git a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp index 207c9b7f2d9..28be30a334c 100644 --- a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp @@ -75,11 +75,12 @@ class CDiscAdjHeatIteration : public CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Perform a single iteration of the adjoint fluid system. diff --git a/SU2_CFD/include/iteration/CFEAIteration.hpp b/SU2_CFD/include/iteration/CFEAIteration.hpp index 1194d8fc3e1..a053de8f933 100644 --- a/SU2_CFD/include/iteration/CFEAIteration.hpp +++ b/SU2_CFD/include/iteration/CFEAIteration.hpp @@ -56,11 +56,14 @@ class CFEAIteration : public CIteration { * \param[in] surface_movement - Surface movement classes of the problem. * \param[in] grid_movement - Volume grid movement classes of the problem. * \param[in] FFDBox - FFD FFDBoxes of the problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instance layer. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Iterate the structural system for a number of Inner_Iter iterations. diff --git a/SU2_CFD/include/iteration/CFEMFluidIteration.hpp b/SU2_CFD/include/iteration/CFEMFluidIteration.hpp index ae477336e56..316b32f1d40 100644 --- a/SU2_CFD/include/iteration/CFEMFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFEMFluidIteration.hpp @@ -71,11 +71,14 @@ class CFEMFluidIteration : public CFluidIteration { * \param[in] surface_movement - Surface movement classes of the problem. * \param[in] grid_movement - Volume grid movement classes of the problem. * \param[in] FFDBox - FFD FFDBoxes of the problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instance layer. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the finite element flow system. diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index dc801b1e32c..97bd35ef9dc 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -63,11 +63,14 @@ class CFluidIteration : public CIteration { * \param[in] surface_movement - Surface movement classes of the problem. * \param[in] grid_movement - Volume grid movement classes of the problem. * \param[in] FFDBox - FFD FFDBoxes of the problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instance layer. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Iterate the fluid system for a number of Inner_Iter iterations. diff --git a/SU2_CFD/include/iteration/CHeatIteration.hpp b/SU2_CFD/include/iteration/CHeatIteration.hpp index 6860556e526..fc5eb3e3dc6 100644 --- a/SU2_CFD/include/iteration/CHeatIteration.hpp +++ b/SU2_CFD/include/iteration/CHeatIteration.hpp @@ -54,11 +54,14 @@ class CHeatIteration : public CFluidIteration { * \param[in] surface_movement - Surface movement classes of the problem. * \param[in] grid_movement - Volume grid movement classes of the problem. * \param[in] FFDBox - FFD FFDBoxes of the problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instance layer. + * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) override; + unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the heat system. diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index e20846277db..47c23476f74 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -132,11 +132,12 @@ class CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instantiation. + * \param[in] CrossTerm - Boolean for CrossTerm. */ virtual void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst){} + unsigned short val_iInst, bool CrossTerm){} /*! * \brief A virtual member. diff --git a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp index 52244aafd6c..85366c2435f 100644 --- a/SU2_CFD/include/solvers/CDiscAdjSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjSolver.hpp @@ -129,8 +129,9 @@ class CDiscAdjSolver final : public CSolver { * after tape has been evaluated. * \param[in] geometry - The geometrical definition of the problem. * \param[in] config - The particular config. + * \param[in] CrossTerm - Boolean for CrossTerm. */ - void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config) override; + void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) override; /*! * \brief A virtual member. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index fd37e55262b..22f88a0f356 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3776,6 +3776,15 @@ class CSolver { */ inline virtual void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config){} + /*! + * \brief A virtual member. + * \param[in] geometry - The geometrical definition of the problem. + * \param[in] solver_container - The solver container holding all solutions. + * \param[in] config - The particular config. + * \param[in] CrossTerm - Boolean to determine if this is a cross term extraction. + */ + inline virtual void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){} + /*! * \brief A virtual member. * \param[in] geometry - The geometrical definition of the problem. diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index b1561b048f9..79df952578a 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -188,7 +188,7 @@ void CDiscAdjSinglezoneDriver::Run() { iteration->Iterate(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); + surface_movement, grid_movement, FFDBox, ZONE_0, INST_0, false); /*--- Monitor the pseudo-time ---*/ @@ -464,7 +464,7 @@ void CDiscAdjSinglezoneDriver::DirectRun(unsigned short kind_recording){ /*--- Iterate the direct solver ---*/ - direct_iteration->Iterate(direct_output, integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); + direct_iteration->Iterate(direct_output, integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0, false); /*--- Postprocess the direct solver ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 841a0d6cb82..7b397e994c6 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -3040,7 +3040,7 @@ void CFluidDriver::Run() { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetInnerIter(IntIter); - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); + iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0, false); } /*--- Check convergence in each zone --*/ @@ -3215,7 +3215,7 @@ void CTurbomachineryDriver::Run() { for (iZone = 0; iZone < nZone; iZone++) { iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0); + surface_movement, grid_movement, FFDBox, iZone, INST_0, false); } for (iZone = 0; iZone < nZone; iZone++) { @@ -3458,7 +3458,7 @@ void CHBDriver::Run() { for (iInst = 0; iInst < nInstHB; iInst++) iteration_container[ZONE_0][iInst]->Iterate(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, ZONE_0, iInst); + surface_movement, grid_movement, FFDBox, ZONE_0, iInst, false); /*--- Update the convergence history file (serial and parallel computations). ---*/ diff --git a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp index 0484d9d7654..e24e447fc71 100644 --- a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp @@ -133,7 +133,7 @@ void CAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integratio void CAdjFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { switch (config[val_iZone]->GetKind_Solver()) { case ADJ_EULER: config[val_iZone]->SetGlobalParam(ADJ_EULER, RUNTIME_ADJFLOW_SYS); diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index d889f036b4c..09a89301934 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -161,7 +161,7 @@ void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry**** geometry, CSolver* void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { bool dynamic = (config[val_iZone]->GetTime_Domain()); /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ @@ -207,7 +207,7 @@ void CDiscAdjFEAIteration::SetRecording(COutput* output, CIntegration**** integr /*--- Run one iteration while tape is passive - this clears all indices ---*/ fem_iteration->Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, - FFDBox, val_iZone, val_iInst); + FFDBox, val_iZone, val_iInst, false); } /*--- Prepare for recording ---*/ @@ -236,7 +236,7 @@ void CDiscAdjFEAIteration::SetRecording(COutput* output, CIntegration**** integr /*--- Run the direct iteration ---*/ fem_iteration->Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, - FFDBox, val_iZone, val_iInst); + FFDBox, val_iZone, val_iInst, false); config[val_iZone]->SetTimeIter(TimeIter); diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 22c2b384c5d..eb8ace2f14f 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -342,25 +342,25 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv void CDiscAdjFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst) { + CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst, bool CrossTerm) { bool frozen_visc = config[iZone]->GetFrozen_Visc_Disc(); bool heat = config[iZone]->GetWeakly_Coupled_Heat(); /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ if (config[iZone]->GetFluidProblem()) { - solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); } if (turbulent && !frozen_visc) { - solver[iZone][iInst][MESH_0][ADJTURB_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + solver[iZone][iInst][MESH_0][ADJTURB_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); } if (heat) { - solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); } if (config[iZone]->AddRadiation()) { - solver[iZone][iInst][MESH_0][ADJRAD_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + solver[iZone][iInst][MESH_0][ADJRAD_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); solver[iZone][iInst][MESH_0][ADJRAD_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); } diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 041ea3fcc06..1631259b7ba 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -169,7 +169,7 @@ void CDiscAdjHeatIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolve void CDiscAdjHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone]); } diff --git a/SU2_CFD/src/iteration/CFEAIteration.cpp b/SU2_CFD/src/iteration/CFEAIteration.cpp index 1fd3f093a60..29d54e09da5 100644 --- a/SU2_CFD/src/iteration/CFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CFEAIteration.cpp @@ -31,7 +31,7 @@ void CFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) { + unsigned short val_iInst, bool CrossTerm) { bool StopCalc = false; unsigned long IntIter = 0; @@ -266,7 +266,7 @@ void CFEAIteration::Solve(COutput* output, CIntegration**** integration, CGeomet unsigned short val_iInst) { /*------------------ Structural subiteration ----------------------*/ Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, - val_iInst); + val_iInst, false); if (multizone && !config[val_iZone]->GetTime_Domain()) { Output(output, geometry, solver, config, config[val_iZone]->GetOuterIter(), false, val_iZone, val_iInst); diff --git a/SU2_CFD/src/iteration/CFEMFluidIteration.cpp b/SU2_CFD/src/iteration/CFEMFluidIteration.cpp index cabea1e48c8..4e2049fd442 100644 --- a/SU2_CFD/src/iteration/CFEMFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFEMFluidIteration.cpp @@ -44,7 +44,7 @@ void CFEMFluidIteration::Preprocess(COutput* output, CIntegration**** integratio void CFEMFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { /*--- Update global parameters ---*/ if (config[val_iZone]->GetKind_Solver() == FEM_EULER || config[val_iZone]->GetKind_Solver() == DISC_ADJ_FEM_EULER) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index b53b35f7bc3..f22c7656803 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -55,7 +55,7 @@ void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, void CFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { unsigned long InnerIter, TimeIter; const bool unsteady = (config[val_iZone]->GetTime_Marching() == DT_STEPPING_1ST) || @@ -286,7 +286,7 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom /*--- Run a single iteration of the solver ---*/ Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, - INST_0); + INST_0, false); /*--- Monitor the pseudo-time ---*/ StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, diff --git a/SU2_CFD/src/iteration/CHeatIteration.cpp b/SU2_CFD/src/iteration/CHeatIteration.cpp index 50fcd31140b..2396b0dbb4b 100644 --- a/SU2_CFD/src/iteration/CHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CHeatIteration.cpp @@ -31,7 +31,7 @@ void CHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst) { + unsigned short val_iInst, bool CrossTerm) { /*--- Update global parameters ---*/ config[val_iZone]->SetGlobalParam(HEAT_EQUATION, RUNTIME_HEAT_SYS); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index de7eebe5d27..0dc4a3cdd84 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -475,7 +475,7 @@ void CDiscAdjSolver::SetAdj_ObjFunc(CGeometry *geometry, CConfig *config) { } } -void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config){ +void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ const bool time_n1_needed = config->GetTime_Marching() == DT_STEPPING_2ND; const bool time_n_needed = (config->GetTime_Marching() == DT_STEPPING_1ST) || time_n1_needed; @@ -533,7 +533,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Store the adjoint solution at time n ---*/ - nodes->Set_Solution_time_n(iPoint,Solution); + if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); } } @@ -546,7 +546,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Store the adjoint solution at time n-1 ---*/ - nodes->Set_Solution_time_n1(iPoint,Solution); + if (!CrossTerm) nodes->Set_Solution_time_n1(iPoint,Solution); } } From 2fefad64eecc55dbc94ba82a856eed81f601b0e1 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 18:35:43 +0000 Subject: [PATCH 003/192] create previous time sensitivity variables --- SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp | 15 +++++++++++++++ SU2_CFD/include/variables/CDiscAdjVariable.hpp | 15 +++++++++++++++ SU2_CFD/include/variables/CVariable.hpp | 14 ++++++++++++++ SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 1 + SU2_CFD/src/variables/CDiscAdjVariable.cpp | 1 + 5 files changed, 46 insertions(+) diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index 289bd1dc787..aecb3de4adb 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -39,6 +39,7 @@ class CDiscAdjFEAVariable : public CVariable { protected: MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ + MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ MatrixType Solution_Direct; MatrixType Dynamic_Derivative; @@ -87,6 +88,13 @@ class CDiscAdjFEAVariable : public CVariable { */ inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity(iPoint,iDim) = val; } + /*! + * \brief Set the previous time sensitivity at the node + * \param[in] iDim - dimension + * \param[in] val - value of the Sensitivity + */ + inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity_Old(iPoint,iDim) = val; } + /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component @@ -94,6 +102,13 @@ class CDiscAdjFEAVariable : public CVariable { */ inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity(iPoint,iDim);} + /*! + * \brief Get the previous time sensitivity at the node + * \param[in] iDim - dimension + * \return value of the Sensitivity + */ + inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity_Old(iPoint,iDim);} + inline void SetDynamic_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) final { Dynamic_Derivative(iPoint,iVar) = der; } diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index aa7185b6f75..7afa297c400 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -38,6 +38,7 @@ class CDiscAdjVariable final : public CVariable { private: MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ + MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ MatrixType Solution_Direct; MatrixType DualTime_Derivative; MatrixType DualTime_Derivative_n; @@ -71,6 +72,13 @@ class CDiscAdjVariable final : public CVariable { */ inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) override { Sensitivity(iPoint,iDim) = val;} + /*! + * \brief Set the previous time sensitivity at the node + * \param[in] iDim - dimension + * \param[in] val - value of the Sensitivity + */ + inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) override { Sensitivity_Old(iPoint,iDim) = val;} + /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component @@ -78,6 +86,13 @@ class CDiscAdjVariable final : public CVariable { */ inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const override { return Sensitivity(iPoint,iDim); } + /*! + * \brief Get the previous time sensitivity at the node + * \param[in] iDim - dimension + * \return value of the Sensitivity + */ + inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const override { return Sensitivity_Old(iPoint,iDim); } + inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative(iPoint,iVar) = der; } inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative_n(iPoint,iVar) = der; } diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index b103e17f470..5abbee32e61 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2601,6 +2601,13 @@ class CVariable { */ inline virtual void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) {} + /*! + * \brief Set the previous time sensitivity at the node + * \param[in] iDim - dimension + * \param[in] val - value of the Sensitivity + */ + inline virtual void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) {} + /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component @@ -2608,6 +2615,13 @@ class CVariable { */ inline virtual su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } + /*! + * \brief Get the previous time sensitivity at the node + * \param[in] iDim - dimension + * \return value of the Sensitivity + */ + inline virtual su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const { return 0.0; } + inline virtual void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} inline virtual void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index ea6a9d70852..792c9919f22 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -35,6 +35,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); + Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; iVar++) diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index 25eaf6433c6..bacaffa4325 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -47,6 +47,7 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); + Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; ++iVar) From 80c60deb74ae7a0a224cf5bf66b7c5304467d5b5 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 18:36:46 +0000 Subject: [PATCH 004/192] set sensitivity in domain solver for current time only --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 6 +++++- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 1621d22f12f..4b074ee98e0 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -849,7 +849,11 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo AD::ResetInput(Coord[iDim]); } - nodes->SetSensitivity(iPoint, iDim, Sensitivity); + if (!(config->GetTime_Domain()) || config->GetMultizone_Problem()) { + nodes->SetSensitivity(iPoint, iDim, Sensitivity); + } else { + nodes->SetSensitivity(iPoint, iDim, nodes->GetSensitivity(iPoint, iDim) + Sensitivity); + } } } SetSurface_Sensitivity(geometry, config); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 0dc4a3cdd84..23c805a713f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -771,7 +771,7 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve if ( geometry->nodes->GetSharpEdge_Distance(iPoint) < config->GetAdjSharp_LimiterCoeff()*eps ) Sensitivity = 0.0; } - if (!time_stepping) { + if (!time_stepping || config->GetMultizone_Problem()) { nodes->SetSensitivity(iPoint,iDim, Sensitivity); } else { nodes->SetSensitivity(iPoint, iDim, nodes->GetSensitivity(iPoint,iDim) + Sensitivity); From db4d1750c9d3fd002d3af83384be3d71382a30d5 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 18:47:41 +0000 Subject: [PATCH 005/192] remove error --- Common/src/CConfig.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 41b60c4dd0b..bc8447b3ae0 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4830,16 +4830,10 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ Kind_Linear_Solver = Kind_DiscAdj_Linear_Solver; Kind_Linear_Solver_Prec = Kind_DiscAdj_Linear_Prec; - if (TimeMarching) { + if (Time_Domain) { Restart_Flow = false; - if (GetKind_GridMovement() != RIGID_MOTION && - GetKind_GridMovement() != NO_MOVEMENT) { - SU2_MPI::Error(string("Dynamic mesh movement currently only supported for the discrete adjoint solver for\n") + - string("GRID_MOVEMENT = RIGID_MOTION."), CURRENT_FUNCTION); - } - if (Unst_AdjointIter- long(nTimeIter) < 0){ SU2_MPI::Error(string("Invalid iteration number requested for unsteady adjoint.\n" ) + string("Make sure EXT_ITER is larger or equal than UNST_ADJOINT_ITER."), From 655e7cb45c5d38f36f54f0ace0b6793ab4a25034 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 12:35:15 +0000 Subject: [PATCH 006/192] add call to predicted structural velocity --- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 09a89301934..d2e83ccfe3f 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -368,6 +368,7 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge if (fsi) { /*--- Set relation between solution and predicted displacements, which are the transferred ones. ---*/ dir_solver->PredictStruct_Displacement(structural_geometry, config[iZone]); + if (config[iZone]->GetTime_Domain()) dir_solver->PredictStruct_Velocity(structural_geometry, config[iZone]); } /*--- MPI dependencies. ---*/ From 17519073d843a13699dcae18f216c52872f44616 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 12:39:38 +0000 Subject: [PATCH 007/192] register and extract again --- .../src/iteration/CDiscAdjFluidIteration.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index eb8ace2f14f..73f6690174a 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -352,6 +352,13 @@ void CDiscAdjFluidIteration::Iterate(COutput* output, CIntegration**** integrati solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); + + /*--- If mesh deformation defined in config, extract here as well ---*/ + if (config[iZone]->GetDeform_Mesh()) { + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); + } } if (turbulent && !frozen_visc) { solver[iZone][iInst][MESH_0][ADJTURB_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); @@ -407,6 +414,16 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); + + /*--- If mesh deformation defined in config, register here as well ---*/ + if (config[iZone]->GetDeform_Mesh()) { + + /*--- Undeformed mesh coordinates ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); + + /*--- Boundary displacements ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); + } } if (turbulent && !frozen_visc) { From 42554b6121aa5795ecc23222690eb4ae3391637f Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 12:42:27 +0000 Subject: [PATCH 008/192] do not set previous time structural solutions here again for AD problems --- SU2_CFD/src/solvers/CFEASolver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 9c432add37f..c97b9dc1903 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -3331,11 +3331,11 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c for (unsigned short iVar = 0; iVar < nVar; iVar++) { nodes->SetSolution(iPoint_Local, iVar, Sol[iVar]); if (dynamic) { - nodes->Set_Solution_time_n(iPoint_Local, iVar, Sol[iVar]); + if (!discrete_adjoint) nodes->Set_Solution_time_n(iPoint_Local, iVar, Sol[iVar]); nodes->SetSolution_Vel(iPoint_Local, iVar, Sol[iVar+nVar]); - nodes->SetSolution_Vel_time_n(iPoint_Local, iVar, Sol[iVar+nVar]); + if (!discrete_adjoint) nodes->SetSolution_Vel_time_n(iPoint_Local, iVar, Sol[iVar+nVar]); nodes->SetSolution_Accel(iPoint_Local, iVar, Sol[iVar+2*nVar]); - nodes->SetSolution_Accel_time_n(iPoint_Local, iVar, Sol[iVar+2*nVar]); + if (!discrete_adjoint) nodes->SetSolution_Accel_time_n(iPoint_Local, iVar, Sol[iVar+2*nVar]); } if (fluid_structure) { nodes->SetSolution_Pred(iPoint_Local, iVar, Sol[iVar]); From bed3c059bd66836fe85047f3777e470e1824cc6d Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 12:54:03 +0000 Subject: [PATCH 009/192] set FSI flag correctly for adjoint problems --- Common/src/CConfig.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index bc8447b3ae0..402f0c06131 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -9806,9 +9806,11 @@ void CConfig::SetMultizone(CConfig *driver_config, CConfig **config_container){ case EULER: case NAVIER_STOKES: case RANS: case INC_EULER: case INC_NAVIER_STOKES: case INC_RANS: case NEMO_EULER: case NEMO_NAVIER_STOKES: + case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: + case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: fluid_zone = true; break; - case FEM_ELASTICITY: + case FEM_ELASTICITY: case DISC_ADJ_FEM: structural_zone = true; Relaxation = true; break; From be6757e79f9cbe994694a2bf688117e55ad40037 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 13:07:23 +0000 Subject: [PATCH 010/192] load from adjoint time iteration for AD --- SU2_CFD/src/drivers/CDriver.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 92d7ffb3fa1..c284a00c1e8 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1288,7 +1288,10 @@ void CDriver::Solver_Restart(CSolver ***solver, CGeometry **geometry, solver[MESH_0][RAD_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } if (fem) { - if (time_domain) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + if (time_domain) { + if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + } solver[MESH_0][FEA_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } if (fem_euler || fem_ns) { @@ -1333,7 +1336,8 @@ void CDriver::Solver_Restart(CSolver ***solver, CGeometry **geometry, if ((restart || restart_flow) && config->GetDeform_Mesh() && update_geo){ /*--- Always restart with the last state ---*/ - val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; solver[MESH_0][MESH_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } From a16e9295aed82357af5620b386a262252ee0cf2d Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 14:11:34 +0000 Subject: [PATCH 011/192] reload grid volumes correctly in AD run --- Common/include/geometry/dual_grid/CPoint.hpp | 28 ++++++++++++++ Common/src/geometry/dual_grid/CPoint.cpp | 30 +++++++++++++++ .../src/iteration/CDiscAdjFluidIteration.cpp | 37 +++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 6e504444b19..c1bbac38886 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -60,6 +60,9 @@ class CPoint { su2activevector Volume; /*!< \brief Volume or Area of the control volume in 3D and 2D. */ su2activevector Volume_n; /*!< \brief Volume at time n. */ su2activevector Volume_nM1; /*!< \brief Volume at time n-1. */ + su2activevector Volume_Old; /*!< \brief Old containers for Volume. */ + su2activevector Volume_n_Old; /*!< \brief Old containers for Volume at time n. */ + su2activevector Volume_nM1_Old; /*!< \brief Old containers for Volume at time n-1. */ su2activevector Periodic_Volume; /*!< \brief Missing component of volume or area of a control volume on a periodic marker in 3D and 2D. */ su2vector Domain; /*!< \brief Indicates if a point must be computed or belong to another boundary */ @@ -540,6 +543,31 @@ class CPoint { */ void SetVolume_nM1(); + /*! + * \brief Set the volume of the control volume at time n using n-1. + */ + void SetVolume_n_from_OldnM1(); + + /*! + * \brief Set the volume of the control volume at current time using time n. + */ + void SetVolume_from_Oldn(); + + /*! + * \brief Set the Volume to Volume_Old. + */ + void SetVolume_Old(); + + /*! + * \brief Set the Volume_n to Volume_n_Old. + */ + void SetVolume_n_Old(); + + /*! + * \brief Set the Volume_nM1 to Volume_nM1_Old. + */ + void SetVolume_nM1_Old(); + /*! * \brief Set the parent control volume of an agglomerated control volume. * \param[in] iPoint - Index of the point. diff --git a/Common/src/geometry/dual_grid/CPoint.cpp b/Common/src/geometry/dual_grid/CPoint.cpp index d32c85c5cd0..2c4d47b885a 100644 --- a/Common/src/geometry/dual_grid/CPoint.cpp +++ b/Common/src/geometry/dual_grid/CPoint.cpp @@ -66,6 +66,11 @@ void CPoint::FullAllocation(unsigned short imesh, const CConfig *config) { if (config->GetTime_Marching() != NO) { Volume_n.resize(npoint) = su2double(0.0); Volume_nM1.resize(npoint) = su2double(0.0); + if (config->GetDynamic_Grid() && config->GetDiscrete_Adjoint()) { + Volume_Old.resize(npoint) = su2double(0.0); + Volume_n_Old.resize(npoint) = su2double(0.0); + Volume_nM1_Old.resize(npoint) = su2double(0.0); + } } if(config->GetAD_Mode() && config->GetMultizone_Problem()) { @@ -163,6 +168,31 @@ void CPoint::SetVolume_nM1() { parallelCopy(Volume_n.size(), Volume_n.data(), Volume_nM1.data()); } +void CPoint::SetVolume_Old() { + assert(Volume_Old.size() == Volume.size()); + parallelCopy(Volume.size(), Volume.data(), Volume_Old.data()); +} + +void CPoint::SetVolume_n_Old() { + assert(Volume_n_Old.size() == Volume_n.size()); + parallelCopy(Volume_n.size(), Volume_n.data(), Volume_n_Old.data()); +} + +void CPoint::SetVolume_nM1_Old() { + assert(Volume_nM1_Old.size() == Volume_nM1.size()); + parallelCopy(Volume_nM1.size(), Volume_nM1.data(), Volume_nM1_Old.data()); +} + +void CPoint::SetVolume_n_from_OldnM1() { + assert(Volume_n.size() == Volume_nM1_Old.size()); + parallelCopy(Volume_nM1_Old.size(), Volume_nM1_Old.data(), Volume_n.data()); +} + +void CPoint::SetVolume_from_Oldn() { + assert(Volume.size() == Volume_n_Old.size()); + parallelCopy(Volume_n_Old.size(), Volume_n_Old.data(), Volume.data()); +} + void CPoint::SetCoord_n() { assert(Coord_n.size() == Coord.size()); parallelCopy(Coord.size(), Coord.data(), Coord_n.data()); diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 73f6690174a..2fafb8a4b37 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -87,6 +87,10 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr geometry[val_iZone][val_iInst][iMesh]->nodes->SetCoord_n(); geometry[val_iZone][val_iInst][iMesh]->nodes->SetCoord_n1(); } + if (config[val_iZone]->GetDynamic_Grid()) { + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_n(); + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_nM1(); + } } } if (dual_time) { @@ -106,6 +110,9 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr if (grid_IsMoving) { geometry[val_iZone][val_iInst][iMesh]->nodes->SetCoord_n(); } + if (config[val_iZone]->GetDynamic_Grid()) { + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_n(); + } } } @@ -126,6 +133,16 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr Afterwards the GridVelocity is computed based on the Coordinates. ---*/ + /*--- Temporarily store the loaded volumes in to old containers ---*/ + if (config[val_iZone]->GetDynamic_Grid()) { + for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_Old(); + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_n_Old(); + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_nM1_Old(); + } + } + + /*-- Load mesh solver ---*/ if (config[val_iZone]->GetDeform_Mesh()) { solver[val_iZone][val_iInst][MESH_0][MESH_SOL]->LoadRestart( geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst], config[val_iZone], Direct_Iter, true); @@ -136,6 +153,26 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr LoadUnsteady_Solution(geometry, solver, config, val_iInst, val_iZone, Direct_Iter - 1); } else { LoadUnsteady_Solution(geometry, solver, config, val_iInst, val_iZone, Direct_Iter - 2); + + /*--- Set volumes into correct containers ---*/ + if (config[val_iZone]->GetDynamic_Grid()) { + for (iMesh=0; iMesh<=config[val_iZone]->GetnMGLevels();iMesh++) { + /*--- If negative iteration number, set default ---*/ + if (Direct_Iter - 2 < 0) { + for(iPoint=0; iPointGetnPoint();iPoint++) { + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume(iPoint,0.0); + } + } + + /*--- Set currently loaded volume to Volume_nM1 ---*/ + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_n(); + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_nM1(); + + /*--- Set Volume_n and Volume from old containers ---*/ + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_n_from_OldnM1(); + geometry[val_iZone][val_iInst][iMesh]->nodes->SetVolume_from_Oldn(); + } + } } /*--- Temporarily store the loaded solution in the Solution_Old array ---*/ From 252a3c6b90c465720adaa7073d57d2735652ae9c Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 15:13:14 +0000 Subject: [PATCH 012/192] add velocity source term similar to displacement --- SU2_CFD/include/drivers/CDriver.hpp | 2 ++ SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp | 10 +++++++++- SU2_CFD/include/variables/CVariable.hpp | 2 ++ SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 3 +++ SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp | 1 + 5 files changed, 17 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 2d8d931776a..29e01c54095 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -818,6 +818,8 @@ class CDriver { */ void SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, passivedouble val_AdjointY, passivedouble val_AdjointZ); + void SetSourceTerm_VelAdjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, + passivedouble val_AdjointY, passivedouble val_AdjointZ); /*! * \brief Get the undeformed mesh coordinates diff --git a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp index ede224e14b6..2cccc4d2d44 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp @@ -43,6 +43,7 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { MatrixType FlowTraction_Sens; /*!< \brief Adjoint of the flow tractions. */ MatrixType SourceTerm_DispAdjoint; /*!< \brief Source term applied into the displacement adjoint coming from external solvers. */ + MatrixType SourceTerm_VelAdjoint; CVertexMap VertexMap; /*!< \brief Object that controls accesses to the variables of this class. */ @@ -101,6 +102,10 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { if (!VertexMap.GetVertexIndex(iPoint)) return; SourceTerm_DispAdjoint(iPoint,iDim) = val; } + inline void SetSourceTerm_VelAdjoint(unsigned long iPoint, unsigned long iDim, su2double val) override { + if (!VertexMap.GetVertexIndex(iPoint)) return; + SourceTerm_VelAdjoint(iPoint,iDim) = val; + } /*! * \brief Get the source term applied into the displacement adjoint coming from external solvers @@ -111,7 +116,10 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; return SourceTerm_DispAdjoint(iPoint,iDim); } - + inline su2double GetSourceTerm_VelAdjoint(unsigned long iPoint, unsigned long iDim) const override { + if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; + return SourceTerm_VelAdjoint(iPoint,iDim); + } /*! * \brief Get whether a node is on the boundary */ diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 5b040196f1e..5d18a9aa77c 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2753,6 +2753,7 @@ class CVariable { * \param[in] val - value of the source term */ virtual void SetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim, su2double val) { } + virtual void SetSourceTerm_VelAdjoint(unsigned long iPoint, unsigned long iDim, su2double val) { } /*! * \brief Get the source term applied into the displacement adjoint coming from external solvers @@ -2760,5 +2761,6 @@ class CVariable { * \return value of the source term */ virtual su2double GetSourceTerm_DispAdjoint(unsigned long iPoint, unsigned long iDim) const { return 0.0; } + virtual su2double GetSourceTerm_VelAdjoint(unsigned long iPoint, unsigned long iDim) const { return 0.0; } }; diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 4b074ee98e0..83f74742282 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -762,6 +762,9 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ } for (iVar = 0; iVar < nVar; iVar++){ Solution_Vel[iVar] = nodes->GetSolution_Vel(iPoint,iVar); + if (deform_mesh){ + Solution_Vel[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); + } } for (iVar = 0; iVar < nVar; iVar++){ Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); diff --git a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp index 4e929d4a0fd..a442d0fae68 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp @@ -47,5 +47,6 @@ void CDiscAdjFEABoundVariable::AllocateBoundaryVariables(CConfig *config) { FlowTraction_Sens.resize(nBoundPt,nDim) = su2double(0.0); SourceTerm_DispAdjoint.resize(nBoundPt,nDim) = su2double(0.0); + SourceTerm_VelAdjoint.resize(nBoundPt,nDim) = su2double(0.0); } From 52db11aa06043172e5123093369d5e3eca066875 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 15:57:35 +0000 Subject: [PATCH 013/192] do not set initial conditions again for AD problems --- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index f22c7656803..9d83561de63 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -40,7 +40,7 @@ void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, /*--- Set the initial condition for FSI problems with subiterations ---*/ /*--- This is done only in the first block subiteration.---*/ /*--- From then on, the solver reuses the partially converged solution obtained in the previous subiteration ---*/ - if (fsi && (OuterIter == 0)) { + if (fsi && !config[val_iZone]->GetDiscrete_Adjoint() && (OuterIter == 0)) { solver[val_iZone][val_iInst][MESH_0][FLOW_SOL]->SetInitialCondition( geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst], config[val_iZone], TimeIter); } From 4da496a18f4d96d2760dc901d53037182afaca0a Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 17:54:03 +0000 Subject: [PATCH 014/192] always register coordinates and MPI comms --- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index d2e83ccfe3f..944fdc568e1 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -280,11 +280,10 @@ void CDiscAdjFEAIteration::RegisterInput(CSolver***** solver, CGeometry**** geom /*--- Register topology optimization densities (note direct solver) ---*/ solver[iZone][iInst][MESH_0][FEA_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - - /*--- Register mesh coordinates for geometric sensitivities ---*/ - - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); } + /*--- Register mesh coordinates for geometric sensitivities ---*/ + + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); } void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, @@ -376,10 +375,8 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge dir_solver->InitiateComms(structural_geometry, config[iZone], SOLUTION_FEA); dir_solver->CompleteComms(structural_geometry, config[iZone], SOLUTION_FEA); - if (kind_recording == MESH_COORDS) { - structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); - structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); - } + structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); + structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); /*--- Topology optimization dependencies. ---*/ From f7eb0ae34b6c02653ef101302c26447a6fbbf0c3 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 26 Jan 2021 18:38:07 +0000 Subject: [PATCH 015/192] add indexed calls for time accurate AD variables --- SU2_CFD/include/variables/CFEAVariable.hpp | 41 ++++++- SU2_CFD/include/variables/CVariable.hpp | 34 ++++-- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 51 ++++++-- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 20 +++- SU2_CFD/src/variables/CFEAVariable.cpp | 132 ++++++++++++++++----- SU2_CFD/src/variables/CVariable.cpp | 38 ++++-- 6 files changed, 248 insertions(+), 68 deletions(-) diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 43d99aef8df..518f80072b6 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -59,6 +59,18 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ + su2matrix AD_Vel_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Vel_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + su2matrix AD_Vel_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Vel_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + su2matrix AD_Accel_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Accel_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + su2matrix AD_Accel_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Accel_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + /*! * \brief Constructor of the class. * \note This class is not supposed to be instantiated, it is only a building block for CFEABoundVariable @@ -418,29 +430,29 @@ class CFEAVariable : public CVariable { * \brief Register the variables in the solution time_n array as input/output variable. * \param[in] input - input or output variables. */ - void Register_femSolution_time_n() final; + void Register_femSolution_time_n(bool input, bool push_index) final; /*! * \brief Register the variables in the velocity array as input/output variable. * \param[in] input - input or output variables. */ - void RegisterSolution_Vel(bool input) final; + void RegisterSolution_Vel(bool input, bool push_index) final; /*! * \brief Register the variables in the velocity time_n array as input/output variable. */ - void RegisterSolution_Vel_time_n() final; + void RegisterSolution_Vel_time_n(bool input, bool push_index) final; /*! * \brief Register the variables in the acceleration array as input/output variable. * \param[in] input - input or output variables. */ - void RegisterSolution_Accel(bool input) final; + void RegisterSolution_Accel(bool input, bool push_index) final; /*! * \brief Register the variables in the acceleration time_n array as input/output variable. */ - void RegisterSolution_Accel_time_n() final; + void RegisterSolution_Accel_time_n(bool input, bool push_index) final; /*! * \brief Set the velocity adjoint values of the solution. @@ -460,6 +472,11 @@ class CFEAVariable : public CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel(iPoint,iVar)); } + inline void GetAdjointSolution_Vel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Vel_InputIndex(iPoint,iVar)); + } + /*! * \brief Set the velocity adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. @@ -478,6 +495,11 @@ class CFEAVariable : public CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel_time_n(iPoint,iVar)); } + inline void GetAdjointSolution_Vel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Vel_Time_n_InputIndex(iPoint,iVar)); + } + /*! * \brief Set the acceleration adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. @@ -496,6 +518,11 @@ class CFEAVariable : public CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel(iPoint,iVar)); } + inline void GetAdjointSolution_Accel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Accel_InputIndex(iPoint,iVar)); + } + /*! * \brief Set the acceleration adjoint values of the solution at time n. * \param[in] adj_sol - The adjoint values of the solution. @@ -514,4 +541,8 @@ class CFEAVariable : public CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel_time_n(iPoint,iVar)); } + inline void GetAdjointSolution_Accel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Accel_Time_n_InputIndex(iPoint,iVar)); + } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 5d18a9aa77c..74ab9219c3d 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -98,6 +98,12 @@ class CVariable { su2matrix AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ su2matrix AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + su2matrix AD_Time_n1_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Time_n1_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + unsigned long nPoint = 0; /*!< \brief Number of points in the domain. */ unsigned long nDim = 0; /*!< \brief Number of dimension of the problem. */ unsigned long nVar = 0; /*!< \brief Number of variables of the problem. */ @@ -2481,27 +2487,27 @@ class CVariable { /*! * \brief A virtual member. */ - inline virtual void Register_femSolution_time_n() {} + inline virtual void Register_femSolution_time_n(bool input, bool push_index) {} /*! * \brief A virtual member. */ - inline virtual void RegisterSolution_Vel(bool input) {} + inline virtual void RegisterSolution_Vel(bool input, bool push_index) {} /*! * \brief A virtual member. */ - inline virtual void RegisterSolution_Vel_time_n() {} + inline virtual void RegisterSolution_Vel_time_n(bool input, bool push_index) {} /*! * \brief A virtual member. */ - inline virtual void RegisterSolution_Accel(bool input) {} + inline virtual void RegisterSolution_Accel(bool input, bool push_index) {} /*! * \brief A virtual member. */ - inline virtual void RegisterSolution_Accel_time_n() {} + inline virtual void RegisterSolution_Accel_time_n(bool input, bool push_index) {} /*! * \brief A virtual member. @@ -2522,6 +2528,7 @@ class CVariable { * \brief A virtual member. */ inline virtual void GetAdjointSolution_Vel(unsigned long iPoint, su2double *adj_sol) const {} + inline virtual void GetAdjointSolution_Vel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. @@ -2532,6 +2539,7 @@ class CVariable { * \brief A virtual member. */ inline virtual void GetAdjointSolution_Vel_time_n(unsigned long iPoint, su2double *adj_sol) const {} + inline virtual void GetAdjointSolution_Vel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. @@ -2542,6 +2550,7 @@ class CVariable { * \brief A virtual member. */ inline virtual void GetAdjointSolution_Accel(unsigned long iPoint, su2double *adj_sol) const {} + inline virtual void GetAdjointSolution_Accel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief A virtual member. @@ -2552,6 +2561,7 @@ class CVariable { * \brief A virtual member. */ inline virtual void GetAdjointSolution_Accel_time_n(unsigned long iPoint, su2double *adj_sol) const {} + inline virtual void GetAdjointSolution_Accel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} /*! * \brief Register the variables in the solution array as input/output variable. @@ -2563,12 +2573,12 @@ class CVariable { /*! * \brief Register the variables in the solution_time_n array as input/output variable. */ - void RegisterSolution_time_n(); + void RegisterSolution_time_n(bool push_index); /*! * \brief Register the variables in the solution_time_n1 array as input/output variable. */ - void RegisterSolution_time_n1(); + void RegisterSolution_time_n1(bool push_index); /*! * \brief Set the adjoint values of the solution. @@ -2624,6 +2634,11 @@ class CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n(iPoint,iVar)); } + inline void GetAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); + } + /*! * \brief Set the adjoint values of the solution at time n-1. * \param[in] adj_sol - The adjoint values of the solution. @@ -2642,6 +2657,11 @@ class CVariable { adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n1(iPoint,iVar)); } + inline void GetAdjointSolution_time_n1_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Time_n1_InputIndex(iPoint,iVar)); + } + /*! * \brief Set the sensitivity at the node * \param[in] iDim - spacial component diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 83f74742282..3b222919816 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -350,14 +350,14 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - direct_solver->GetNodes()->RegisterSolution_Accel(input); - direct_solver->GetNodes()->RegisterSolution_Vel(input); + direct_solver->GetNodes()->RegisterSolution_Accel(input, push_index); + direct_solver->GetNodes()->RegisterSolution_Vel(input, push_index); /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ - direct_solver->GetNodes()->Register_femSolution_time_n(); - direct_solver->GetNodes()->RegisterSolution_Accel_time_n(); - direct_solver->GetNodes()->RegisterSolution_Vel_time_n(); + direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index); + direct_solver->GetNodes()->RegisterSolution_Accel_time_n(input, push_index); + direct_solver->GetNodes()->RegisterSolution_Vel_time_n(input, push_index); } @@ -456,8 +456,8 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ if (dynamic) { /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - direct_solver->GetNodes()->RegisterSolution_Accel(input); - direct_solver->GetNodes()->RegisterSolution_Vel(input); + direct_solver->GetNodes()->RegisterSolution_Accel(input, push_index); + direct_solver->GetNodes()->RegisterSolution_Vel(input, push_index); } } @@ -549,7 +549,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution ---*/ - if(config->GetMultizone_Problem()) { + if(multizone) { direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); } else { @@ -575,7 +575,12 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint acceleration solution u'' ---*/ - direct_solver->GetNodes()->GetAdjointSolution_Accel(iPoint,Solution_Accel); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_Accel_LocalIndex(iPoint,Solution_Accel); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_Accel(iPoint,Solution_Accel); + } /*--- Store the adjoint acceleration solution u'' ---*/ @@ -592,7 +597,12 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint velocity solution u'' ---*/ - direct_solver->GetNodes()->GetAdjointSolution_Vel(iPoint,Solution_Vel); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_Vel_LocalIndex(iPoint,Solution_Vel); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_Vel(iPoint,Solution_Vel); + } /*--- Store the adjoint velocity solution u'' ---*/ @@ -605,7 +615,12 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ - direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); + } /*--- Store the adjoint solution at time n ---*/ @@ -617,7 +632,12 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint acceleration solution u'' at time n ---*/ - direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n(iPoint,Solution_Accel); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n_LocalIndex(iPoint,Solution_Accel); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n(iPoint,Solution_Accel); + } /*--- Store the adjoint acceleration solution u'' at time n---*/ @@ -630,7 +650,12 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint velocity solution u' at time n ---*/ - direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n(iPoint,Solution_Vel); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n_LocalIndex(iPoint,Solution_Vel); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n(iPoint,Solution_Vel); + } /*--- Store the adjoint velocity solution u' at time n ---*/ diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 23c805a713f..27b9bc3f1c6 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -261,10 +261,10 @@ void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) { direct_solver->GetNodes()->RegisterSolution(input, push_index); if (time_n_needed) - direct_solver->GetNodes()->RegisterSolution_time_n(); + direct_solver->GetNodes()->RegisterSolution_time_n(push_index); if (time_n1_needed) - direct_solver->GetNodes()->RegisterSolution_time_n1(); + direct_solver->GetNodes()->RegisterSolution_time_n1(push_index); } void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset) { @@ -500,7 +500,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution ---*/ - if(config->GetMultizone_Problem()) { + if(multizone) { direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); } else { @@ -529,7 +529,12 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution at time n ---*/ - direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); + } /*--- Store the adjoint solution at time n ---*/ @@ -542,7 +547,12 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution at time n-1 ---*/ - direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); + if(multizone) { + direct_solver->GetNodes()->GetAdjointSolution_time_n1_LocalIndex(iPoint,Solution); + } + else { + direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); + } /*--- Store the adjoint solution at time n-1 ---*/ diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 455ded50f08..b3f0971da34 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -64,6 +64,17 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } Solution_Vel_time_n = Solution_Vel; Solution_Accel_time_n = Solution_Accel; + + if(config->GetMultizone_Problem() && config->GetAD_Mode()) { + AD_Vel_InputIndex.resize(nPoint,nVar) = -1; + AD_Vel_OutputIndex.resize(nPoint,nVar) = -1; + AD_Vel_Time_n_InputIndex.resize(nPoint,nVar) = -1; + AD_Vel_Time_n_OutputIndex.resize(nPoint,nVar) = -1; + AD_Accel_InputIndex.resize(nPoint,nVar) = -1; + AD_Accel_OutputIndex.resize(nPoint,nVar) = -1; + AD_Accel_Time_n_InputIndex.resize(nPoint,nVar) = -1; + AD_Accel_Time_n_OutputIndex.resize(nPoint,nVar) = -1; + } } if (fsi_analysis) { @@ -99,46 +110,107 @@ void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } -void CFEAVariable::Register_femSolution_time_n() { - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - for (unsigned long iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Solution_time_n(iPoint,iVar)); +void CFEAVariable::Register_femSolution_time_n(bool input, bool push_index) { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for(unsigned long iVar=0; iVarGetMultizone_Problem() && config->GetAD_Mode()) { AD_InputIndex.resize(nPoint,nVar) = -1; AD_OutputIndex.resize(nPoint,nVar) = -1; + if (config->GetTime_Domain()) { + AD_Time_n_InputIndex.resize(nPoint,nVar) = -1; + AD_Time_n_OutputIndex.resize(nPoint,nVar) = -1; + AD_Time_n1_InputIndex.resize(nPoint,nVar) = -1; + AD_Time_n1_OutputIndex.resize(nPoint,nVar) = -1; + } } if (config->GetMultizone_Problem()) @@ -135,14 +141,30 @@ void CVariable::RegisterSolution(bool input, bool push_index) { } } -void CVariable::RegisterSolution_time_n() { - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) - for(unsigned long iVar=0; iVar Date: Tue, 26 Jan 2021 18:46:02 +0000 Subject: [PATCH 016/192] temporary output of structural dv gradient --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 29 +++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 3b222919816..7cb19e3d0c2 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -885,6 +885,35 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo } } SetSurface_Sensitivity(geometry, config); + + // Temporary Output + if (config->GetAdvanced_FEAElementBased()) { + if (rank == MASTER_NODE) { + unsigned short iVar; + + /*--- Header of the temporary dv sensitivity output file ---*/ + ofstream myfile2_res; + bool outputDVFEA = false; + + switch (config->GetDV_FEA()) { + case YOUNG_MODULUS: + myfile2_res.open("grad_young.opt"); + myfile2_res << "INDEX" + << "\t" + << "GRAD" << endl; + myfile2_res.precision(15); + + for (unsigned short iDV = 0; iDV < nDV; iDV++) { + myfile2_res << iDV; + myfile2_res << "\t"; + myfile2_res << scientific << Total_Sens_DV[iDV]; + myfile2_res << endl; + } + myfile2_res.close(); + break; + } + } + } } void CDiscAdjFEASolver::SetSurface_Sensitivity(CGeometry *geometry, CConfig *config){ From a40d9cb62cdd8332013e25d6bd8edae4d7e35c21 Mon Sep 17 00:00:00 2001 From: cvencro Date: Fri, 5 Feb 2021 01:05:38 +0000 Subject: [PATCH 017/192] correct time for adjoint problems with gust --- SU2_CFD/src/iteration/CFluidIteration.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 75680fd2037..5cb2b24e874 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -353,6 +353,8 @@ void CFluidIteration::SetWind_GustField(CConfig* config, CGeometry** geometry, C su2double Physical_dt = config->GetDelta_UnstTime(); unsigned long TimeIter = config->GetTimeIter(); + if (config->GetDiscrete_Adjoint()) TimeIter = config->GetUnst_AdjointIter() - TimeIter - 1; + su2double Physical_t = TimeIter * Physical_dt; su2double Uinf = solver[MESH_0][FLOW_SOL]->GetVelocity_Inf(0); // Assumption gust moves at infinity velocity From 93f2a2c255dea4b19fcc510ac5738c5c871bb286 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 15 Feb 2021 10:17:55 +0000 Subject: [PATCH 018/192] remove reset of grid velocity --- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 5cb2b24e874..e243e1f8919 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -389,10 +389,6 @@ void CFluidIteration::SetWind_GustField(CConfig* config, CGeometry** geometry, C /*--- Loop over each node in the volume mesh ---*/ for (iPoint = 0; iPoint < geometry[iMGlevel]->GetnPoint(); iPoint++) { - /*--- Reset the Grid Velocity to zero if there is no grid movement ---*/ - if (Kind_Grid_Movement == GUST) { - for (iDim = 0; iDim < nDim; iDim++) geometry[iMGlevel]->nodes->SetGridVel(iPoint, iDim, 0.0); - } /*--- initialize the gust and derivatives to zero everywhere ---*/ From 64a6c80c2040492c8a3830fd61ae03026873fa33 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi <60700515+Nicola-Fonzi@users.noreply.github.com> Date: Mon, 22 Feb 2021 10:41:40 +0100 Subject: [PATCH 019/192] Develop (#6) * new function inside existing sst source term class (no new class since never needed alone) * implement function to compute residual * update authors * one more duplicate * fix typo k2 not k1 * fix error * add production * Update AUTHORS.md * update authors - alphabetical, duplication * first attempt complete * add diffusion terms to jacobian * small change * Corrections based on PR comments * cosmetics * remove else * add AD::SetPreaccIn * cleanup, try to make vertex tractions more general * Removing old setInitialMesh * Compute the interface mapping starting from the undeformed mesh * Loads computed for all the solid markers * Tentative modification of test case * Introduced start time for forced motion * Final version of new test case * Updated values in regression * Complete reorganisation of the interface * Fixes to vector data * minor changes and correction * Better initialisation of variables * Small typo in parallel regression * comment out jacobian to conserve diagonal dominance * spaces and comments * error * geometry was modified twice for RANS problems in SetDualTime_Solver * update dual time weakly coupled heat * small fix for aeroelastic, update rigid motion regressions * forgot to save * Fixed regression values after PR#1199 * array deleted twice * Multiple superposed forced motions * Error with array dimension * add test case and regression list entry * remove jacobian contribution and test case config file options * Introduced condition on mesh boundary * Update SU2_CFD/src/solvers/CMeshSolver.cpp * fix_typoLinael * constification, remove legacy python FSI * fix #1202 * more const Co-authored-by: emanresu Co-authored-by: Pedro Gomes Co-authored-by: Florian <55834287+FlorianDm@users.noreply.github.com> Co-authored-by: cvencro Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Co-authored-by: TobiKattmann Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- AUTHORS.md | 27 +- Common/include/CConfig.hpp | 4 +- Common/include/option_structure.hpp | 4 - Common/src/CConfig.cpp | 15 +- SU2_CFD/include/drivers/CDriver.hpp | 285 +------ SU2_CFD/include/integration/CIntegration.hpp | 12 +- .../integration/CStructuralIntegration.hpp | 8 + SU2_CFD/include/iteration/CFluidIteration.hpp | 9 + .../numerics/turbulent/turb_sources.hpp | 43 +- SU2_CFD/include/solvers/CFEASolver.hpp | 18 +- .../include/solvers/CFVMFlowSolverBase.inl | 19 +- SU2_CFD/include/solvers/CSolver.hpp | 36 +- SU2_CFD/src/integration/CIntegration.cpp | 127 +-- .../integration/CStructuralIntegration.cpp | 36 + SU2_CFD/src/iteration/CAdjFluidIteration.cpp | 5 + .../src/iteration/CDiscAdjFluidIteration.cpp | 6 +- SU2_CFD/src/iteration/CFEAIteration.cpp | 5 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 90 +- SU2_CFD/src/iteration/CHeatIteration.cpp | 5 + SU2_CFD/src/iteration/CIteration.cpp | 31 - SU2_CFD/src/iteration/CIterationFactory.cpp | 2 +- .../src/numerics/turbulent/turb_sources.cpp | 16 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 7 - SU2_CFD/src/output/CFlowOutput.cpp | 4 + SU2_CFD/src/output/CNEMOCompOutput.cpp | 7 - SU2_CFD/src/python_wrapper_structure.cpp | 806 +++++------------- SU2_CFD/src/solvers/CFEASolver.cpp | 18 +- SU2_CFD/src/solvers/CMeshSolver.cpp | 4 +- SU2_CFD/src/solvers/CSolver.cpp | 168 ++-- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 7 + SU2_PY/FSI_tools/FSIInterface.py | 12 +- SU2_PY/SU2_Nastran/pysu2_nastran.py | 92 +- .../air_nozzle/air_nozzle.cfg | 214 +++++ .../cont_adj_euler/naca0012/inv_NACA0012.cfg | 2 +- .../naca0012/inv_NACA0012_FD.cfg | 2 +- .../wedge/inv_wedge_ROE_multiobj.cfg | 2 +- .../cont_adj_rans/oneram6/turb_ONERAM6.cfg | 7 +- .../coupled_cht/comp_2d/flow_cylinder.cfg | 2 +- .../coupled_cht/comp_2d/solid_cylinder1.cfg | 2 +- .../coupled_cht/comp_2d/solid_cylinder2.cfg | 2 +- .../coupled_cht/comp_2d/solid_cylinder3.cfg | 2 +- .../disc_adj_incomp_2d/flow_cylinder.cfg | 2 +- .../disc_adj_incomp_2d/solid_cylinder1.cfg | 2 +- .../disc_adj_incomp_2d/solid_cylinder2.cfg | 2 +- .../disc_adj_incomp_2d/solid_cylinder3.cfg | 2 +- .../coupled_cht/incomp_2d/flow_cylinder.cfg | 2 +- .../coupled_cht/incomp_2d/solid_cylinder1.cfg | 2 +- .../coupled_cht/incomp_2d/solid_cylinder2.cfg | 2 +- .../coupled_cht/incomp_2d/solid_cylinder3.cfg | 2 +- .../incomp_2d_unsteady/flow_cylinder.cfg | 2 +- .../incomp_2d_unsteady/solid_cylinder1.cfg | 2 +- .../incomp_2d_unsteady/solid_cylinder2.cfg | 2 +- .../incomp_2d_unsteady/solid_cylinder3.cfg | 2 +- .../disc_adj_euler/arina2k/Arina2KRS.cfg | 2 +- .../cylinder3D/inv_cylinder3D.cfg | 2 +- .../cylinder/heated_cylinder.cfg | 2 +- .../naca0012/turb_naca0012_sa.cfg | 2 +- .../naca0012/turb_naca0012_sst.cfg | 2 +- TestCases/gust/inv_gust_NACA0012.cfg | 2 +- TestCases/hybrid_regression.py | 12 + TestCases/incomp_euler/nozzle/inv_nozzle.cfg | 2 +- .../buoyancy_cavity/lam_buoyancy_cavity.cfg | 2 +- .../cylinder/poly_cylinder.cfg | 2 +- .../rough_flatplate_incomp.cfg | 2 +- .../mms/fvm_incomp_euler/inv_mms_jst.cfg | 2 +- .../fvm_incomp_navierstokes/lam_mms_fds.cfg | 2 +- .../mms/fvm_navierstokes/lam_mms_roe.cfg | 2 +- TestCases/moving_wall/cavity/lam_cavity.cfg | 3 +- .../spinning_cylinder/spinning_cylinder.cfg | 2 +- .../inv_wedge_ROE_2surf_1obj.cfg | 2 +- .../inv_wedge_ROE_multiobj.cfg | 2 +- .../inv_wedge_ROE_multiobj_1surf.cfg | 2 +- .../inv_wedge_ROE_multiobj_combo.cfg | 2 +- .../pitching_NACA64A010.cfg | 2 +- .../pitching_oneram6/pitching_ONERAM6.cfg | 2 +- .../rotating_naca0012/rotating_NACA0012.cfg | 2 +- TestCases/parallel_regression.py | 19 +- .../flatPlate_rigidMotion_Conf.cfg | 310 +------ .../launch_flatPlate_rigidMotion.py | 56 +- .../launch_unsteady_CHT_FlatPlate.py | 48 +- .../unsteady_CHT_FlatPlate_Conf.cfg | 2 +- TestCases/serial_regression.py | 21 +- config_template.cfg | 2 +- 83 files changed, 1010 insertions(+), 1692 deletions(-) create mode 100644 TestCases/axisymmetric_rans/air_nozzle/air_nozzle.cfg diff --git a/AUTHORS.md b/AUTHORS.md index b223314f1cf..9ac39ec05e9 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -43,6 +43,7 @@ Copyright holders might be the individual person or their respective employer. I ``` Akshay.K.R Alejandro +Alessandro Gastaldi Aman uz zaman Baig Amit Sachdeva Ana Lourenco @@ -53,19 +54,23 @@ Antonio Rubino Arne Bachmann Beckett Y. Zhou Benjamin S. Kirk -Brandon Tracey +Brendan Tracey +Brian Munguía Carsten Othmer +Catarina Garbacz +Charanya Venkatesan-Crome Clark Pederson Daumantas Kavolis Dave Taflin Eduardo Molina Ethan Alan Hereth -FlorianDm +Florian Dittmann Francisco D. Palacios Gaurav Bansal Giulio Gori Guillaume Bâty Harichand M V +HL Kline IndianaStokes J. Sinsay JSmith36 @@ -75,13 +80,19 @@ Jayant Mukhopadhaya Jeffrey van Oostrom Jessie Lauzon João Loureiro +Johannes Blühdorn +JonathanSmith1936 Kedar Naik LaSerpe +Lennaert Tol Matteo Pini +Max Aehle Max Le Max Sagebaum Michele Gaffuri Mickael Philit +Mladen Banovic +Nicola Fonzi Ole Burghardt Patrick Mischke Paul Urbanczyk @@ -91,6 +102,7 @@ Pete Bachant RaulFeijo55 Ruben Sanchez Ryan Barrett +SaettaE Salvatore Vitale Samet Cakmakcioglu Scott Imlay @@ -104,25 +116,26 @@ Trent Lukaczyk VivaanKhatri Wally Maier aaronyicongfu +aeroamit anilvar +band-a-prend +bigfootedrockmidget bmunguia chamsolli costat -cr109 -cvencro daniel-linton demanosalvas dmudiger erangit flo -hlkline +fmpmorgado +garcgutierrez +jtneedels juliendm jvanoostrom -koodlyakshay mcolonno minkwankim padronas -sametcaka sravya91 srcopela tobadavid diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index 3aa76c0faa4..91684f20d32 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -657,7 +657,7 @@ class CConfig { nMarker_ZoneInterface, /*!< \brief Number of markers in the zone interface. */ nMarker_Plotting, /*!< \brief Number of markers to plot. */ nMarker_Analyze, /*!< \brief Number of markers to analyze. */ - nMarker_Moving, /*!< \brief Number of markers in motion (DEFORMING, MOVING_WALL, or FLUID_STRUCTURE). */ + nMarker_Moving, /*!< \brief Number of markers in motion (DEFORMING, MOVING_WALL). */ nMarker_PyCustom, /*!< \brief Number of markers that are customizable in Python. */ nMarker_DV, /*!< \brief Number of markers affected by the design variables. */ nMarker_WallFunctions; /*!< \brief Number of markers for which wall functions must be applied. */ @@ -667,7 +667,7 @@ class CConfig { *Marker_Plotting, /*!< \brief Markers to plot. */ *Marker_Analyze, /*!< \brief Markers to analyze. */ *Marker_ZoneInterface, /*!< \brief Markers in the FSI interface. */ - *Marker_Moving, /*!< \brief Markers in motion (DEFORMING, MOVING_WALL, or FLUID_STRUCTURE). */ + *Marker_Moving, /*!< \brief Markers in motion (DEFORMING, MOVING_WALL). */ *Marker_PyCustom, /*!< \brief Markers that are customizable in Python. */ *Marker_DV, /*!< \brief Markers affected by the design variables. */ *Marker_WallFunctions; /*!< \brief Markers for which wall functions must be applied. */ diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 5a3c8213c37..c7044f8b75e 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -176,7 +176,6 @@ enum ENUM_MAIN_SOLVER { INC_NAVIER_STOKES =5, /*!< \brief Definition of the incompressible Navier-Stokes' solver. */ INC_RANS = 6, /*!< \brief Definition of the incompressible Reynolds-averaged Navier-Stokes' (RANS) solver. */ HEAT_EQUATION = 7, /*!< \brief Definition of the finite volume heat solver. */ - FLUID_STRUCTURE_INTERACTION = 8, /*!< \brief Definition of a FSI solver. */ FEM_ELASTICITY = 9, /*!< \brief Definition of a FEM solver. */ ADJ_EULER = 10, /*!< \brief Definition of the continuous adjoint Euler's solver. */ ADJ_NAVIER_STOKES = 11, /*!< \brief Definition of the continuous adjoint Navier-Stokes' solver. */ @@ -231,7 +230,6 @@ static const MapType Solver_Map = { MakePair("DISC_ADJ_FEM_RANS", DISC_ADJ_FEM_RANS) MakePair("DISC_ADJ_FEM_NS", DISC_ADJ_FEM_NS) MakePair("DISC_ADJ_FEM", DISC_ADJ_FEM) - MakePair("FLUID_STRUCTURE_INTERACTION", FLUID_STRUCTURE_INTERACTION) MakePair("TEMPLATE_SOLVER", TEMPLATE_SOLVER) MakePair("MULTIPHYSICS", MULTIPHYSICS) }; @@ -699,7 +697,6 @@ enum ENUM_SURFACEMOVEMENT { MOVING_WALL = 2, /*!< \brief Simulation with moving wall. */ AEROELASTIC = 3, /*!< \brief Simulation with aeroelastic motion. */ AEROELASTIC_RIGID_MOTION = 4, /*!< \brief Simulation with rotation and aeroelastic motion. */ - FLUID_STRUCTURE = 5, /*!< \brief Fluid structure deformation. */ EXTERNAL = 6, /*!< \brief Simulation with external motion. */ EXTERNAL_ROTATION = 7, /*!< \brief Simulation with external rotation motion. */ }; @@ -708,7 +705,6 @@ static const MapType SurfaceMovement_Map = { MakePair("MOVING_WALL", MOVING_WALL) MakePair("AEROELASTIC_RIGID_MOTION", AEROELASTIC_RIGID_MOTION) MakePair("AEROELASTIC", AEROELASTIC) - MakePair("FLUID_STRUCTURE", FLUID_STRUCTURE) MakePair("EXTERNAL", EXTERNAL) MakePair("EXTERNAL_ROTATION", EXTERNAL_ROTATION) }; diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 01137a94aae..b434a2f6edd 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -3114,13 +3114,6 @@ void CConfig::SetnZone(){ } - /*--- Temporary fix until Multizone Disc. Adj. solver is ready ---- */ - - if (Kind_Solver == FLUID_STRUCTURE_INTERACTION){ - - nZone = GetnZone(Mesh_FileName, Mesh_FileFormat); - - } } void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_izone, unsigned short val_nDim) { @@ -3563,11 +3556,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_ } } - if ((nKind_SurfaceMovement > 1) && GetSurface_Movement(FLUID_STRUCTURE)) { - SU2_MPI::Error("FSI in combination with moving surfaces is currently not supported.", CURRENT_FUNCTION); - } - - if ((nKind_SurfaceMovement != nMarker_Moving) && !GetSurface_Movement(FLUID_STRUCTURE)) { + if (nKind_SurfaceMovement != nMarker_Moving) { SU2_MPI::Error("Number of KIND_SURFACE_MOVEMENT must match number of MARKER_MOVING", CURRENT_FUNCTION); } @@ -5590,7 +5579,6 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) { case RIGID_MOTION: cout << "rigid mesh motion." << endl; break; case MOVING_HTP: cout << "HTP moving." << endl; break; case ROTATING_FRAME: cout << "rotating reference frame." << endl; break; - case FLUID_STRUCTURE: cout << "fluid-structure motion." << endl; break; case EXTERNAL: cout << "externally prescribed motion." << endl; break; } } @@ -8302,7 +8290,6 @@ bool CConfig::GetVolumetric_Movement() const { if (GetSurface_Movement(AEROELASTIC) || GetSurface_Movement(AEROELASTIC_RIGID_MOTION)|| - GetSurface_Movement(FLUID_STRUCTURE) || GetSurface_Movement(EXTERNAL) || GetSurface_Movement(EXTERNAL_ROTATION)){ volumetric_movement = true; diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 82bedff1ddc..954f943036f 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -97,10 +97,6 @@ class CDriver { vector > > interpolator_container; /*!< \brief Definition of the interpolation method between non-matching discretizations of the interface. */ CInterface ***interface_container; /*!< \brief Definition of the interface of information and physics. */ - su2double PyWrapVarCoord[3], /*!< \brief This is used to store the VarCoord of each vertex. */ - PyWrapNodalForce[3], /*!< \brief This is used to store the force at each vertex. */ - PyWrapNodalForceDensity[3], /*!< \brief This is used to store the force density at each vertex. */ - PyWrapNodalHeatFlux[3]; /*!< \brief This is used to store the heat flux at each vertex. */ bool dry_run; /*!< \brief Flag if SU2_CFD was started as dry-run via "SU2_CFD -d .cfg" */ public: @@ -360,11 +356,6 @@ class CDriver { */ virtual void DynamicMeshUpdate(unsigned short val_iZone, unsigned long TimeIter) { } - /*! - * \brief Perform a static mesh deformation, without considering grid velocity. - */ - virtual void StaticMeshUpdate() { } - /*! * \brief Perform a mesh deformation as initial condition. */ @@ -373,69 +364,63 @@ class CDriver { /*! * \brief Process the boundary conditions and update the multigrid structure. */ - virtual void BoundaryConditionsUpdate() { } + void BoundaryConditionsUpdate(); /*! * \brief Get the total drag. * \return Total drag. */ - passivedouble Get_Drag(); + passivedouble Get_Drag() const; /*! * \brief Get the total lift. * \return Total lift. */ - passivedouble Get_Lift(); + passivedouble Get_Lift() const; /*! * \brief Get the total x moment. * \return Total x moment. */ - passivedouble Get_Mx(); + passivedouble Get_Mx() const; /*! * \brief Get the total y moment. * \return Total y moment. */ - passivedouble Get_My(); + passivedouble Get_My() const; /*! * \brief Get the total z moment. * \return Total z moment. */ - passivedouble Get_Mz(); + passivedouble Get_Mz() const; /*! * \brief Get the total drag coefficient. * \return Total drag coefficient. */ - passivedouble Get_DragCoeff(); + passivedouble Get_DragCoeff() const; /*! * \brief Get the total lift coefficient. * \return Total lift coefficient. */ - passivedouble Get_LiftCoeff(); - - /*! - * \brief Get the moving marker identifier. - * \return Moving marker identifier. - */ - unsigned short GetMovingMarker(); + passivedouble Get_LiftCoeff() const; /*! * \brief Get the number of vertices (halo nodes included) from a specified marker. * \param[in] iMarker - Marker identifier. * \return Number of vertices. */ - unsigned long GetNumberVertices(unsigned short iMarker); + unsigned long GetNumberVertices(unsigned short iMarker) const; /*! * \brief Get the number of halo vertices from a specified marker. * \param[in] iMarker - Marker identifier. * \return Number of vertices. */ - unsigned long GetNumberHaloVertices(unsigned short iMarker); + unsigned long GetNumberHaloVertices(unsigned short iMarker) const; /*! * \brief Check if a vertex is physical or not (halo node) on a specified marker. @@ -443,13 +428,13 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return True if the specified vertex is a halo node. */ - bool IsAHaloNode(unsigned short iMarker, unsigned long iVertex); + bool IsAHaloNode(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get the number of external iterations. * \return Number of external iterations. */ - unsigned long GetnTimeIter(); + unsigned long GetnTimeIter() const; /*! * \brief Get the current external iteration. @@ -461,7 +446,7 @@ class CDriver { * \brief Get the unsteady time step. * \return Unsteady time step. */ - passivedouble GetUnsteady_TimeStep(); + passivedouble GetUnsteady_TimeStep() const; /*! * \brief Get the global index of a vertex on a specified marker. @@ -469,119 +454,15 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Vertex global index. */ - unsigned long GetVertexGlobalIndex(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the x coordinate of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return x coordinate of the vertex. - */ - passivedouble GetVertexCoordX(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the y coordinate of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return y coordinate of the vertex. - */ - passivedouble GetVertexCoordY(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the z coordinate of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return z coordinate of the vertex. - */ - passivedouble GetVertexCoordZ(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Compute the total force (pressure and shear stress) at a vertex on a specified marker (3 components). - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return True if the vertex is a halo node (non physical force). - */ - bool ComputeVertexForces(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the x component of the force at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return x component of the force at the vertex. - */ - passivedouble GetVertexForceX(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the y component of the force at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return y component of the force at the vertex. - */ - passivedouble GetVertexForceY(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the z component of the force at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return z component of the force at the vertex. - */ - passivedouble GetVertexForceZ(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the x component of the force density at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return x component of the force density at the vertex. - */ - passivedouble GetVertexForceDensityX(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the y component of the force density at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return y component of the force density at the vertex. - */ - passivedouble GetVertexForceDensityY(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the z component of the force density at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return z component of the force density at the vertex. - */ - passivedouble GetVertexForceDensityZ(unsigned short iMarker, unsigned long iVertex); + unsigned long GetVertexGlobalIndex(unsigned short iMarker, unsigned long iVertex) const; /*! - * \brief Set the x coordinate of a vertex on a specified marker. + * \brief Get undeformed coordinates from the mesh solver. * \param[in] iMarker - Marker identifier. * \param[in] iVertex - Vertex identifier. - * \param[in] newPosX - New x coordinate of the vertex. + * \return x,y,z coordinates of the vertex. */ - void SetVertexCoordX(unsigned short iMarker, unsigned long iVertex, passivedouble newPosX); - - /*! - * \brief Set the y coordinate of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] newPosY - New y coordinate of the vertex. - */ - void SetVertexCoordY(unsigned short iMarker, unsigned long iVertex, passivedouble newPosY); - - /*! - * \brief Set the z coordinate of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] newPosZ - New z coordinate of the vertex. - */ - void SetVertexCoordZ(unsigned short iMarker, unsigned long iVertex, passivedouble newPosZ); - - /*! - * \brief Set the VarCoord of a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return Norm of the VarCoord. - */ - passivedouble SetVertexVarCoord(unsigned short iMarker, unsigned long iVertex); + vector GetInitialMeshCoord(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get the temperature at a vertex on a specified marker. @@ -589,7 +470,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Temperature of the vertex. */ - passivedouble GetVertexTemperature(unsigned short iMarker, unsigned long iVertex); + passivedouble GetVertexTemperature(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Set the temperature of a vertex on a specified marker. @@ -600,36 +481,12 @@ class CDriver { void SetVertexTemperature(unsigned short iMarker, unsigned long iVertex, passivedouble val_WallTemp); /*! - * \brief Compute the heat flux at a vertex on a specified marker (3 components). + * \brief Get the heat flux at a vertex on a specified marker (3 components). * \param[in] iMarker - Marker identifier. * \param[in] iVertex - Vertex identifier. * \return True if the vertex is a halo node. */ - bool ComputeVertexHeatFluxes(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the x component of the heat flux at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return x component of the heat flux at the vertex. - */ - passivedouble GetVertexHeatFluxX(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the y component of the heat flux at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return y component of the heat flux at the vertex. - */ - passivedouble GetVertexHeatFluxY(unsigned short iMarker, unsigned long iVertex); - - /*! - * \brief Get the z component of the heat flux at a vertex on a specified marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return z component of the heat flux at the vertex. - */ - passivedouble GetVertexHeatFluxZ(unsigned short iMarker, unsigned long iVertex); + vector GetVertexHeatFluxes(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get the wall normal component of the heat flux at a vertex on a specified marker. @@ -637,7 +494,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Wall normal component of the heat flux at the vertex. */ - passivedouble GetVertexNormalHeatFlux(unsigned short iMarker, unsigned long iVertex); + passivedouble GetVertexNormalHeatFlux(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Set the wall normal component of the heat flux at a vertex on a specified marker. @@ -653,7 +510,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Thermal conductivity at the vertex. */ - passivedouble GetThermalConductivity(unsigned short iMarker, unsigned long iVertex); + passivedouble GetThermalConductivity(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Preprocess the inlets via file input for all solvers. @@ -661,8 +518,7 @@ class CDriver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void Inlet_Preprocessing(CSolver ***solver, CGeometry **geometry, - CConfig *config) const; + void Inlet_Preprocessing(CSolver ***solver, CGeometry **geometry, CConfig *config) const; /*! * \brief Get the unit normal (vector) at a vertex on a specified marker. @@ -670,55 +526,43 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Unit normal (vector) at the vertex. */ - vector GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex); + vector GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get all the boundary markers tags. * \return List of boundary markers tags. */ - vector GetAllBoundaryMarkersTag(); - - /*! - * \brief Get all the moving boundary markers tags. - * \return List of moving boundary markers tags. - */ - vector GetAllMovingMarkersTag(); + vector GetAllBoundaryMarkersTag() const; /*! * \brief Get all the deformable boundary marker tags. * \return List of deformable boundary markers tags. */ - vector GetAllDeformMeshMarkersTag(); - - /*! - * \brief Get all the fluid load boundary marker tags. - * \return List of fluid load boundary markers tags. - */ - vector GetAllFluidLoadMarkersTag(); + vector GetAllDeformMeshMarkersTag() const; /*! * \brief Get all the heat transfer boundary markers tags. * \return List of heat transfer boundary markers tags. */ - vector GetAllCHTMarkersTag(); + vector GetAllCHTMarkersTag() const; /*! * \brief Get all the (subsonic) inlet boundary markers tags. * \return List of inlet boundary markers tags. */ - vector GetAllInletMarkersTag(); + vector GetAllInletMarkersTag() const; /*! * \brief Get all the boundary markers tags with their associated indices. * \return List of boundary markers tags with their indices. */ - map GetAllBoundaryMarkers(); + map GetAllBoundaryMarkers() const; /*! * \brief Get all the boundary markers tags with their associated types. * \return List of boundary markers tags with their types. */ - map GetAllBoundaryMarkersType(); + map GetAllBoundaryMarkersType() const; /*! * \brief Set the mesh displacement for the elasticity mesh solver. @@ -741,7 +585,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Vector of sensitivities. */ - vector GetMeshDisp_Sensitivity(unsigned short iMarker, unsigned long iVertex); + vector GetMeshDisp_Sensitivity(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Set the load in X direction for the structural solver. @@ -760,7 +604,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Vector of displacements. */ - vector GetFEA_Displacements(unsigned short iMarker, unsigned long iVertex); + vector GetFEA_Displacements(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Return the velocities from the FEA Solver. @@ -768,7 +612,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Vector of velocities. */ - vector GetFEA_Velocity(unsigned short iMarker, unsigned long iVertex); + vector GetFEA_Velocity(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Return the velocities from the FEA Solver. @@ -776,7 +620,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Vector of velocities at time n. */ - vector GetFEA_Velocity_n(unsigned short iMarker, unsigned long iVertex); + vector GetFEA_Velocity_n(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get the sensitivity of the flow loads for the structural solver. @@ -786,7 +630,7 @@ class CDriver { * \param[in] LoadX - Value of the load in the direction Y. * \param[in] LoadX - Value of the load in the direction Z. */ - vector GetFlowLoad_Sensitivity(unsigned short iMarker, unsigned long iVertex); + vector GetFlowLoad_Sensitivity(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Get the flow load (from the extra step - the repeated methods should be unified once the postprocessing @@ -794,7 +638,7 @@ class CDriver { * \param[in] iMarker - Marker identifier. * \param[in] iVertex - Vertex identifier. */ - vector GetFlowLoad(unsigned short iMarker, unsigned long iVertex); + vector GetFlowLoad(unsigned short iMarker, unsigned long iVertex) const; /*! * \brief Set the adjoint of the flow tractions (from the extra step - @@ -819,14 +663,6 @@ class CDriver { void SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, passivedouble val_AdjointY, passivedouble val_AdjointZ); - /*! - * \brief Get the undeformed mesh coordinates - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \return Undeformed Vertex Coordinates - */ - vector GetVertex_UndeformedCoord(unsigned short iMarker, unsigned long iVertex); - /*! * \brief Set the position of the heat source. * \param[in] alpha - Angle of rotation respect to Z axis. @@ -962,60 +798,11 @@ class CFluidDriver : public CDriver { */ void DynamicMeshUpdate(unsigned long TimeIter) override; - /*! - * \brief Perform a static mesh deformation, without considering grid velocity (multiple zone). - */ - void StaticMeshUpdate() override; - - /*! - * \brief Perform a mesh deformation as initial condition (multiple zone). - */ - void SetInitialMesh() override; - - /*! - * \brief Process the boundary conditions and update the multigrid structure. - */ - void BoundaryConditionsUpdate() override; - /*! * \brief Transfer data among different zones (multiple zone). */ void Transfer_Data(unsigned short donorZone, unsigned short targetZone); - /*! - * \brief Set the total temperature of a vertex on a specified inlet marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] val_Ttotal - Value of the total (stagnation) temperature. - */ - void SetVertexTtotal(unsigned short iMarker, unsigned long iVertex, passivedouble val_Ttotal); - - /*! - * \brief Set the total pressure of a vertex on a specified inlet marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] val_Ptotal - Value of the total (stagnation) pressure. - */ - void SetVertexPtotal(unsigned short iMarker, unsigned long iVertex, passivedouble val_Ptotal); - - /*! - * \brief Set the flow direction of a vertex on a specified inlet marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] iDim - Index of the flow direction unit vector - * \param[in] val_FlowDir - Component of a unit vector representing the flow direction - */ - void SetVertexFlowDir(unsigned short iMarker, unsigned long iVertex, unsigned short iDim, passivedouble val_FlowDir); - - /*! - * \brief Set a turbulence variable on a specified inlet marker. - * \param[in] iMarker - Marker identifier. - * \param[in] iVertex - Vertex identifier. - * \param[in] iDim - Index of the turbulence variable (i.e. k is 0 in SST) - * \param[in] val_turb_var - Value of the turbulence variable to be used. - */ - void SetVertexTurbVar(unsigned short iMarker, unsigned long iVertex, unsigned short iDim, passivedouble val_tub_var); - }; diff --git a/SU2_CFD/include/integration/CIntegration.hpp b/SU2_CFD/include/integration/CIntegration.hpp index 0c88a5d0559..2062713e718 100644 --- a/SU2_CFD/include/integration/CIntegration.hpp +++ b/SU2_CFD/include/integration/CIntegration.hpp @@ -125,20 +125,20 @@ class CIntegration { inline bool GetConvergence_FullMG(void) const { return Convergence_FullMG; } /*! - * \brief Save the solution, and volume at different time steps. + * \brief Save the geometry at different time steps. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solution - Flow solution. + * \param[in] solver - Mesh solver. * \param[in] config - Definition of the particular problem. */ - void SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh); + void SetDualTime_Geometry(CGeometry *geometry, CSolver *mesh_solver, const CConfig *config, unsigned short iMesh); /*! - * \brief Save the structural solution at different time steps. + * \brief Save the solution at different time steps, and reset certain fields for the next timestep. * \param[in] geometry - Geometrical definition of the problem. - * \param[in] solver_container - Structural solution. + * \param[in] solver - Some solver. * \param[in] config - Definition of the particular problem. */ - void SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh); + virtual void SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh); /*! * \brief A virtual member. diff --git a/SU2_CFD/include/integration/CStructuralIntegration.hpp b/SU2_CFD/include/integration/CStructuralIntegration.hpp index 845167a3d4b..bcd44693580 100644 --- a/SU2_CFD/include/integration/CStructuralIntegration.hpp +++ b/SU2_CFD/include/integration/CStructuralIntegration.hpp @@ -51,6 +51,14 @@ class CStructuralIntegration final : public CIntegration { CNumerics ******numerics_container, CConfig **config, unsigned short RunTime_EqSystem, unsigned short iZone, unsigned short iInst) override; + /*! + * \brief Save the solution at different time steps, and reset certain fields for the next timestep. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Structural solver. + * \param[in] config - Definition of the problem. + */ + void SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh) override; + private: /*! * \brief Do the space integration of the numerical system on a FEM framework. diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index 82cd95628be..9271ef475a1 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -115,6 +115,8 @@ class CFluidIteration : public CIteration { CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) override; + private: + /*! * \brief Imposes a gust via the grid velocities. * \author S. Padron @@ -146,4 +148,11 @@ class CFluidIteration : public CIteration { * \return Boolean indicating weather calculation should be stopped */ bool MonitorFixed_CL(COutput* output, CGeometry* geometry, CSolver** solver, CConfig* config); + + /*! + * \brief Store old aeroelastic solutions + * \param[in,out] config - Definition of the particular problem. + */ + void SetDualTime_Aeroelastic(CConfig* config) const; + }; diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp index f8fa6bab711..55f5ba65842 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -305,8 +305,10 @@ class CSourcePieceWise_TurbSST final : public CNumerics { alfa_2, beta_1, beta_2, - sigma_omega_1, - sigma_omega_2, + sigma_k_1, + sigma_k_2, + sigma_w_1, + sigma_w_2, beta_star, a1; @@ -320,12 +322,49 @@ class CSourcePieceWise_TurbSST final : public CNumerics { bool incompressible; bool sustaining_terms; + bool axisymmetric; /*! * \brief A virtual member. Get strain magnitude based on perturbed reynolds stress matrix * \param[in] turb_ke: turbulent kinetic energy of the node */ void SetPerturbedStrainMag(su2double turb_ke); + + /*! + * \brief Add contribution due to axisymmetric formulation to 2D residual + */ + inline void ResidualAxisymmetric(su2double alfa_blended, su2double zeta){ + + if (Coord_i[1] < EPS) return; + + su2double yinv, rhov, k, w; + su2double sigma_k_i, sigma_w_i; + su2double pk_axi, pw_axi, cdk_axi, cdw_axi; + + AD::SetPreaccIn(Coord_i[1]); + + yinv = 1.0/Coord_i[1]; + rhov = Density_i*V_i[2]; + k = TurbVar_i[0]; + w = TurbVar_i[1]; + + /*--- Compute blended constants ---*/ + sigma_k_i = F1_i*sigma_k_1+(1.0-F1_i)*sigma_k_2; + sigma_w_i = F1_i*sigma_w_1+(1.0-F1_i)*sigma_w_2; + + /*--- Production ---*/ + pk_axi = max(0.0,2.0/3.0*rhov*k*(2.0/zeta*(yinv*V_i[2]-PrimVar_Grad_i[2][1]-PrimVar_Grad_i[1][0])-1.0)); + pw_axi = alfa_blended*zeta/k*pk_axi; + + /*--- Convection-Diffusion ---*/ + cdk_axi = rhov*k-(Laminar_Viscosity_i+sigma_k_i*Eddy_Viscosity_i)*TurbVar_Grad_i[0][1]; + cdw_axi = rhov*w-(Laminar_Viscosity_i+sigma_w_i*Eddy_Viscosity_i)*TurbVar_Grad_i[1][1]; + + /*--- Add terms to the residuals ---*/ + Residual[0] += yinv*Volume*(pk_axi-cdk_axi); + Residual[1] += yinv*Volume*(pw_axi-cdw_axi); + + } public: /*! diff --git a/SU2_CFD/include/solvers/CFEASolver.hpp b/SU2_CFD/include/solvers/CFEASolver.hpp index d845127be60..2e3cee9e5e0 100644 --- a/SU2_CFD/include/solvers/CFEASolver.hpp +++ b/SU2_CFD/include/solvers/CFEASolver.hpp @@ -314,7 +314,7 @@ class CFEASolver : public CSolver { * \param[in] numerics - Description of the numerical method. * \param[in] config - Definition of the particular problem. */ - void Compute_MassMatrix(CGeometry *geometry, + void Compute_MassMatrix(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) final; @@ -324,7 +324,7 @@ class CFEASolver : public CSolver { * \param[in] numerics - Description of the numerical method. * \param[in] config - Definition of the particular problem. */ - void Compute_MassRes(CGeometry *geometry, + void Compute_MassRes(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) final; @@ -472,7 +472,7 @@ class CFEASolver : public CSolver { * \param[in] numerics - Numerical methods. * \param[in] config - Definition of the particular problem. */ - void ImplicitNewmark_Iteration(CGeometry *geometry, + void ImplicitNewmark_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) final; @@ -481,14 +481,14 @@ class CFEASolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void ImplicitNewmark_Update(CGeometry *geometry, CConfig *config) final; + void ImplicitNewmark_Update(const CGeometry *geometry, const CConfig *config) final; /*! * \brief A virtual member. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void ImplicitNewmark_Relaxation(CGeometry *geometry, CConfig *config) final; + void ImplicitNewmark_Relaxation(const CGeometry *geometry, const CConfig *config) final; /*! * \brief Iterate using an implicit Generalized Alpha solver. @@ -496,7 +496,7 @@ class CFEASolver : public CSolver { * \param[in] numerics - Numerical methods. * \param[in] config - Definition of the particular problem. */ - void GeneralizedAlpha_Iteration(CGeometry *geometry, + void GeneralizedAlpha_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) final; @@ -505,21 +505,21 @@ class CFEASolver : public CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CConfig *config) final; + void GeneralizedAlpha_UpdateDisp(const CGeometry *geometry, const CConfig *config) final; /*! * \brief Update the solution using an implicit Generalized Alpha solver. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CConfig *config) final; + void GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, const CConfig *config) final; /*! * \brief Update the solution using an implicit Generalized Alpha solver. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void GeneralizedAlpha_UpdateLoads(CGeometry *geometry, const CConfig *config) final; + void GeneralizedAlpha_UpdateLoads(const CGeometry *geometry, const CConfig *config) final; /*! * \brief Postprocessing. diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index f17b2bb2177..865b6b216a0 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -225,11 +225,20 @@ void CFVMFlowSolverBase::Allocate(const CConfig& config) { } } - /*--- Only initialize when there is a Marker_Fluid_Load defined - *--- (this avoids overhead in all other cases while a more permanent structure is being developed) ---*/ - if ((config.GetnMarker_Fluid_Load() > 0) && (MGLevel == MESH_0)) { - Alloc3D(nMarker, nVertex, nDim, VertexTraction); - if (config.GetDiscrete_Adjoint()) Alloc3D(nMarker, nVertex, nDim, VertexTractionAdjoint); + if (MGLevel == MESH_0) { + VertexTraction.resize(nMarker); + for (iMarker = 0; iMarker < nMarker; iMarker++) { + if (config.GetSolid_Wall(iMarker)) + VertexTraction[iMarker].resize(nVertex[iMarker], nDim) = su2double(0.0); + } + + if (config.GetDiscrete_Adjoint()) { + VertexTractionAdjoint.resize(nMarker); + for (iMarker = 0; iMarker < nMarker; iMarker++) { + if (config.GetSolid_Wall(iMarker)) + VertexTractionAdjoint[iMarker].resize(nVertex[iMarker], nDim) = su2double(0.0); + } + } } /*--- Initialize the BGS residuals in FSI problems. ---*/ diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 062711cb47b..e8d108e6d21 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -133,8 +133,8 @@ class CSolver { bool dynamic_grid; /*!< \brief Flag that determines whether the grid is dynamic (moving or deforming + grid velocities). */ - su2double ***VertexTraction; /*- Temporary, this will be moved to a new postprocessing structure once in place -*/ - su2double ***VertexTractionAdjoint; /*- Also temporary -*/ + vector VertexTraction; /*- Temporary, this will be moved to a new postprocessing structure once in place -*/ + vector VertexTractionAdjoint; /*- Also temporary -*/ string SolverName; /*!< \brief Store the name of the solver for output purposes. */ @@ -1557,7 +1557,7 @@ class CSolver { * \param[in] numerics - Numerical methods. * \param[in] config - Definition of the particular problem. */ - inline virtual void ImplicitNewmark_Iteration(CGeometry *geometry, + inline virtual void ImplicitNewmark_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { } @@ -1567,8 +1567,8 @@ class CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - inline virtual void ImplicitNewmark_Update(CGeometry *geometry, - CConfig *config) { } + inline virtual void ImplicitNewmark_Update(const CGeometry *geometry, + const CConfig *config) { } /*! * \brief A virtual member. @@ -1576,8 +1576,8 @@ class CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - inline virtual void ImplicitNewmark_Relaxation(CGeometry *geometry, - CConfig *config) { } + inline virtual void ImplicitNewmark_Relaxation(const CGeometry *geometry, + const CConfig *config) { } /*! * \brief A virtual member. @@ -1585,7 +1585,7 @@ class CSolver { * \param[in] numerics - Numerical methods. * \param[in] config - Definition of the particular problem. */ - inline virtual void GeneralizedAlpha_Iteration(CGeometry *geometry, + inline virtual void GeneralizedAlpha_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { } @@ -1595,8 +1595,8 @@ class CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - inline virtual void GeneralizedAlpha_UpdateDisp(CGeometry *geometry, - CConfig *config) { } + inline virtual void GeneralizedAlpha_UpdateDisp(const CGeometry *geometry, + const CConfig *config) { } /*! * \brief A virtual member. @@ -1604,8 +1604,8 @@ class CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - inline virtual void GeneralizedAlpha_UpdateSolution(CGeometry *geometry, - CConfig *config) { } + inline virtual void GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, + const CConfig *config) { } /*! * \brief A virtual member. @@ -1613,7 +1613,7 @@ class CSolver { * \param[in] solver_container - Container vector with all the solutions. * \param[in] config - Definition of the particular problem. */ - inline virtual void GeneralizedAlpha_UpdateLoads(CGeometry *geometry, + inline virtual void GeneralizedAlpha_UpdateLoads(const CGeometry *geometry, const CConfig *config) { } /*! @@ -3770,7 +3770,7 @@ class CSolver { * \param[in] numerics - Description of the numerical method. * \param[in] config - Definition of the particular problem. */ - inline virtual void Compute_MassMatrix(CGeometry *geometry, + inline virtual void Compute_MassMatrix(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { } @@ -3780,7 +3780,7 @@ class CSolver { * \param[in] numerics - Description of the numerical method. * \param[in] config - Definition of the particular problem. */ - inline virtual void Compute_MassRes(CGeometry *geometry, + inline virtual void Compute_MassRes(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { } @@ -4339,7 +4339,7 @@ class CSolver { * \param[in] geometry - Geometrical definition. * \param[in] config - Definition of the particular problem. */ - void ComputeVertexTractions(CGeometry *geometry, CConfig *config); + void ComputeVertexTractions(CGeometry *geometry, const CConfig *config); /*! * \brief Set the adjoints of the vertex tractions. @@ -4356,7 +4356,7 @@ class CSolver { * \param[in] geometry - Geometrical definition. * \param[in] config - Definition of the particular problem. */ - void RegisterVertexTractions(CGeometry *geometry, CConfig *config); + void RegisterVertexTractions(CGeometry *geometry, const CConfig *config); /*! * \brief Store the adjoints of the vertex tractions. @@ -4377,7 +4377,7 @@ class CSolver { * \param[in] geometry - Geometrical definition. * \param[in] config - Definition of the particular problem. */ - void SetVertexTractionsAdjoint(CGeometry *geometry, CConfig *config); + void SetVertexTractionsAdjoint(CGeometry *geometry, const CConfig *config); /*! * \brief Get minimun volume in the mesh diff --git a/SU2_CFD/src/integration/CIntegration.cpp b/SU2_CFD/src/integration/CIntegration.cpp index 811b1b5608c..c2699c9eb56 100644 --- a/SU2_CFD/src/integration/CIntegration.cpp +++ b/SU2_CFD/src/integration/CIntegration.cpp @@ -208,14 +208,10 @@ void CIntegration::Time_Integration(CGeometry *geometry, CSolver **solver_contai } -void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CConfig *config, unsigned short iMesh) { +void CIntegration::SetDualTime_Geometry(CGeometry *geometry, CSolver *mesh_solver, const CConfig *config, unsigned short iMesh) { SU2_OMP_PARALLEL { - /*--- Store old solution, volumes and coordinates (in case there is grid movement). ---*/ - - solver->GetNodes()->Set_Solution_time_n1(); - solver->GetNodes()->Set_Solution_time_n(); geometry->nodes->SetVolume_nM1(); geometry->nodes->SetVolume_n(); @@ -225,6 +221,19 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon geometry->nodes->SetCoord_n(); } + if ((iMesh==MESH_0) && config->GetDeform_Mesh()) mesh_solver->SetDualTime_Mesh(); + + } // end SU2_OMP_PARALLEL +} + +void CIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh) { + + SU2_OMP_PARALLEL + { + /*--- Store old solution ---*/ + solver->GetNodes()->Set_Solution_time_n1(); + solver->GetNodes()->Set_Solution_time_n(); + SU2_OMP_MASTER solver->ResetCFLAdapt(); SU2_OMP_BARRIER @@ -239,113 +248,5 @@ void CIntegration::SetDualTime_Solver(CGeometry *geometry, CSolver *solver, CCon solver->GetNodes()->SetLocalCFL(iPoint, config->GetCFL(iMesh)); } - /*--- Store old aeroelastic solutions ---*/ - SU2_OMP_MASTER - if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation() && (iMesh == MESH_0)) { - - config->SetAeroelastic_n1(); - config->SetAeroelastic_n(); - - /*--- Also communicate plunge and pitch to the master node. Needed for output in case of parallel run ---*/ - -#ifdef HAVE_MPI - su2double plunge, pitch, *plunge_all = NULL, *pitch_all = NULL; - unsigned short iMarker, iMarker_Monitoring; - unsigned long iProcessor, owner, *owner_all = NULL; - - string Marker_Tag, Monitoring_Tag; - int nProcessor = size; - - /*--- Only if master node allocate memory ---*/ - - if (rank == MASTER_NODE) { - plunge_all = new su2double[nProcessor]; - pitch_all = new su2double[nProcessor]; - owner_all = new unsigned long[nProcessor]; - } - - /*--- Find marker and give it's plunge and pitch coordinate to the master node ---*/ - - for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { - - for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - - Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); - Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if (Marker_Tag == Monitoring_Tag) { owner = 1; break; - } else { - owner = 0; - } - - } - plunge = config->GetAeroelastic_plunge(iMarker_Monitoring); - pitch = config->GetAeroelastic_pitch(iMarker_Monitoring); - - /*--- Gather the data on the master node. ---*/ - - SU2_MPI::Gather(&plunge, 1, MPI_DOUBLE, plunge_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm()); - SU2_MPI::Gather(&pitch, 1, MPI_DOUBLE, pitch_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm()); - SU2_MPI::Gather(&owner, 1, MPI_UNSIGNED_LONG, owner_all, 1, MPI_UNSIGNED_LONG, MASTER_NODE, SU2_MPI::GetComm()); - - /*--- Set plunge and pitch on the master node ---*/ - - if (rank == MASTER_NODE) { - for (iProcessor = 0; iProcessor < (unsigned long)nProcessor; iProcessor++) { - if (owner_all[iProcessor] == 1) { - config->SetAeroelastic_plunge(iMarker_Monitoring, plunge_all[iProcessor]); - config->SetAeroelastic_pitch(iMarker_Monitoring, pitch_all[iProcessor]); - break; - } - } - } - - } - - if (rank == MASTER_NODE) { - delete [] plunge_all; - delete [] pitch_all; - delete [] owner_all; - } -#endif - } - SU2_OMP_BARRIER - } // end SU2_OMP_PARALLEL - -} - -void CIntegration::SetStructural_Solver(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh) { - - bool fsi = config->GetFSI_Simulation(); - - /*--- Update the solution according to the integration scheme used ---*/ - - switch (config->GetKind_TimeIntScheme_FEA()) { - case (CD_EXPLICIT): - break; - case (NEWMARK_IMPLICIT): - if (fsi) solver_container[FEA_SOL]->ImplicitNewmark_Relaxation(geometry, config); - break; - case (GENERALIZED_ALPHA): - solver_container[FEA_SOL]->GeneralizedAlpha_UpdateSolution(geometry, config); - solver_container[FEA_SOL]->GeneralizedAlpha_UpdateLoads(geometry, config); - break; - } - - /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ - - solver_container[FEA_SOL]->GetNodes()->Set_Solution_time_n(); - solver_container[FEA_SOL]->GetNodes()->SetSolution_Vel_time_n(); - solver_container[FEA_SOL]->GetNodes()->SetSolution_Accel_time_n(); - - /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ - - if (fsi) { - - su2double WAitk=0.0; - - WAitk = solver_container[FEA_SOL]->GetWAitken_Dyn(); - solver_container[FEA_SOL]->SetWAitken_Dyn_tn1(WAitk); - - } } diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index 3667eba307a..52fb4177ceb 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -190,3 +190,39 @@ void CStructuralIntegration::Time_Integration_FEM(CGeometry *geometry, CSolver * } } + +void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolver *solver, const CConfig *config, unsigned short iMesh) { + + bool fsi = config->GetFSI_Simulation(); + + /*--- Update the solution according to the integration scheme used ---*/ + + switch (config->GetKind_TimeIntScheme_FEA()) { + case (CD_EXPLICIT): + break; + case (NEWMARK_IMPLICIT): + if (fsi) solver->ImplicitNewmark_Relaxation(geometry, config); + break; + case (GENERALIZED_ALPHA): + solver->GeneralizedAlpha_UpdateSolution(geometry, config); + solver->GeneralizedAlpha_UpdateLoads(geometry, config); + break; + } + + /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ + + solver->GetNodes()->Set_Solution_time_n(); + solver->GetNodes()->SetSolution_Vel_time_n(); + solver->GetNodes()->SetSolution_Accel_time_n(); + + /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ + + if (fsi) { + + su2double WAitk=0.0; + + WAitk = solver->GetWAitken_Dyn(); + solver->SetWAitken_Dyn_tn1(WAitk); + + } +} diff --git a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp index 315b0d40be6..870d6b00d2d 100644 --- a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp @@ -181,6 +181,11 @@ void CAdjFluidIteration::Update(COutput* output, CIntegration**** integration, C integration[val_iZone][val_iInst][ADJFLOW_SOL]->SetDualTime_Solver( geometry[val_iZone][val_iInst][iMesh], solver[val_iZone][val_iInst][iMesh][ADJFLOW_SOL], config[val_iZone], iMesh); + + integration[val_iZone][val_iInst][ADJFLOW_SOL]->SetDualTime_Geometry( + geometry[val_iZone][val_iInst][iMesh], solver[val_iZone][val_iInst][iMesh][MESH_SOL], config[val_iZone], + iMesh); + integration[val_iZone][val_iInst][ADJFLOW_SOL]->SetConvergence(false); } diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 9153084ae11..94bfab7dc34 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -370,7 +370,6 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry*** unsigned short iZone, unsigned short iInst) { bool frozen_visc = config[iZone]->GetFrozen_Visc_Disc(); bool heat = config[iZone]->GetWeakly_Coupled_Heat(); - bool interface_boundary = (config[iZone]->GetnMarker_Fluid_Load() > 0); /*--- Initialize the adjoints the conservative variables ---*/ @@ -390,7 +389,7 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry*** solver[iZone][iInst][MESH_0][ADJRAD_SOL]->SetAdjoint_Output(geometry[iZone][iInst][MESH_0], config[iZone]); } - if (interface_boundary) { + if (config[iZone]->GetFluidProblem()) { solver[iZone][iInst][MESH_0][FLOW_SOL]->SetVertexTractionsAdjoint(geometry[iZone][iInst][MESH_0], config[iZone]); } } @@ -510,7 +509,6 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g COutput* output, unsigned short iZone, unsigned short iInst) { bool frozen_visc = config[iZone]->GetFrozen_Visc_Disc(); bool heat = config[iZone]->GetWeakly_Coupled_Heat(); - bool interface_boundary = (config[iZone]->GetnMarker_Fluid_Load() > 0); /*--- Register conservative variables as output of the iteration ---*/ @@ -526,7 +524,7 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g if (config[iZone]->AddRadiation()) { solver[iZone][iInst][MESH_0][ADJRAD_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], config[iZone]); } - if (interface_boundary) { + if (config[iZone]->GetFluidProblem()) { solver[iZone][iInst][MESH_0][FLOW_SOL]->RegisterVertexTractions(geometry[iZone][iInst][MESH_0], config[iZone]); } } diff --git a/SU2_CFD/src/iteration/CFEAIteration.cpp b/SU2_CFD/src/iteration/CFEAIteration.cpp index 11b553134d6..1263c41b36e 100644 --- a/SU2_CFD/src/iteration/CFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CFEAIteration.cpp @@ -196,8 +196,9 @@ void CFEAIteration::Update(COutput* output, CIntegration**** integration, CGeome /*----------------- Update structural solver ----------------------*/ if (dynamic) { - integration[val_iZone][val_iInst][FEA_SOL]->SetStructural_Solver( - geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0], config[val_iZone], MESH_0); + integration[val_iZone][val_iInst][FEA_SOL]->SetDualTime_Solver( + geometry[val_iZone][val_iInst][MESH_0], solver[val_iZone][val_iInst][MESH_0][FEA_SOL], config[val_iZone], + MESH_0); integration[val_iZone][val_iInst][FEA_SOL]->SetConvergence(false); /*--- Verify convergence criteria (based on total time) ---*/ diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 47a6f2625bb..539252c7671 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -172,13 +172,15 @@ void CFluidIteration::Update(COutput* output, CIntegration**** integration, CGeo integration[val_iZone][val_iInst][FLOW_SOL]->SetDualTime_Solver(geometry[val_iZone][val_iInst][iMesh], solver[val_iZone][val_iInst][iMesh][FLOW_SOL], config[val_iZone], iMesh); + + integration[val_iZone][val_iInst][FLOW_SOL]->SetDualTime_Geometry(geometry[val_iZone][val_iInst][iMesh], + solver[val_iZone][val_iInst][iMesh][MESH_SOL], + config[val_iZone], iMesh); + integration[val_iZone][val_iInst][FLOW_SOL]->SetConvergence(false); } - /*--- Update dual time solver for the dynamic mesh solver ---*/ - if (config[val_iZone]->GetDeform_Mesh()) { - solver[val_iZone][val_iInst][MESH_0][MESH_SOL]->SetDualTime_Mesh(); - } + SetDualTime_Aeroelastic(config[val_iZone]); /*--- Update dual time solver for the turbulence model ---*/ @@ -199,6 +201,15 @@ void CFluidIteration::Update(COutput* output, CIntegration**** integration, CGeo config[val_iZone], MESH_0); integration[val_iZone][val_iInst][TRANS_SOL]->SetConvergence(false); } + + /*--- Update dual time solver for the weakly coupled energy equation ---*/ + + if (config[val_iZone]->GetWeakly_Coupled_Heat()) { + integration[val_iZone][val_iInst][HEAT_SOL]->SetDualTime_Solver(geometry[val_iZone][val_iInst][MESH_0], + solver[val_iZone][val_iInst][MESH_0][HEAT_SOL], + config[val_iZone], MESH_0); + integration[val_iZone][val_iInst][HEAT_SOL]->SetConvergence(false); + } } } @@ -557,3 +568,74 @@ bool CFluidIteration::MonitorFixed_CL(COutput *output, CGeometry *geometry, CSol /* --- Set convergence based on fixed CL convergence --- */ return fixed_cl_convergence; } + +void CFluidIteration::SetDualTime_Aeroelastic(CConfig* config) const { + + /*--- Store old aeroelastic solutions ---*/ + + if (config->GetGrid_Movement() && config->GetAeroelastic_Simulation()) { + + config->SetAeroelastic_n1(); + config->SetAeroelastic_n(); + + /*--- Also communicate plunge and pitch to the master node. Needed for output in case of parallel run ---*/ + +#ifdef HAVE_MPI + su2double plunge, pitch, *plunge_all = nullptr, *pitch_all = nullptr; + unsigned short iMarker, iMarker_Monitoring; + unsigned long iProcessor, owner, *owner_all = nullptr; + + string Marker_Tag, Monitoring_Tag; + int nProcessor = size; + + /*--- Only if master node allocate memory ---*/ + + if (rank == MASTER_NODE) { + plunge_all = new su2double[nProcessor]; + pitch_all = new su2double[nProcessor]; + owner_all = new unsigned long[nProcessor]; + } + + /*--- Find marker and give it's plunge and pitch coordinate to the master node ---*/ + + for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { + + for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { + + Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); + Marker_Tag = config->GetMarker_All_TagBound(iMarker); + if (Marker_Tag == Monitoring_Tag) { owner = 1; break; + } else { + owner = 0; + } + + } + plunge = config->GetAeroelastic_plunge(iMarker_Monitoring); + pitch = config->GetAeroelastic_pitch(iMarker_Monitoring); + + /*--- Gather the data on the master node. ---*/ + + SU2_MPI::Gather(&plunge, 1, MPI_DOUBLE, plunge_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm()); + SU2_MPI::Gather(&pitch, 1, MPI_DOUBLE, pitch_all, 1, MPI_DOUBLE, MASTER_NODE, SU2_MPI::GetComm()); + SU2_MPI::Gather(&owner, 1, MPI_UNSIGNED_LONG, owner_all, 1, MPI_UNSIGNED_LONG, MASTER_NODE, SU2_MPI::GetComm()); + + /*--- Set plunge and pitch on the master node ---*/ + + if (rank == MASTER_NODE) { + for (iProcessor = 0; iProcessor < (unsigned long)nProcessor; iProcessor++) { + if (owner_all[iProcessor] == 1) { + config->SetAeroelastic_plunge(iMarker_Monitoring, plunge_all[iProcessor]); + config->SetAeroelastic_pitch(iMarker_Monitoring, pitch_all[iProcessor]); + break; + } + } + } + } + + delete [] plunge_all; + delete [] pitch_all; + delete [] owner_all; +#endif + } + +} diff --git a/SU2_CFD/src/iteration/CHeatIteration.cpp b/SU2_CFD/src/iteration/CHeatIteration.cpp index dbdd69ce22d..adf02634aa1 100644 --- a/SU2_CFD/src/iteration/CHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CHeatIteration.cpp @@ -56,6 +56,11 @@ void CHeatIteration::Update(COutput* output, CIntegration**** integration, CGeom integration[val_iZone][val_iInst][HEAT_SOL]->SetDualTime_Solver(geometry[val_iZone][val_iInst][iMesh], solver[val_iZone][val_iInst][iMesh][HEAT_SOL], config[val_iZone], iMesh); + + integration[val_iZone][val_iInst][HEAT_SOL]->SetDualTime_Geometry(geometry[val_iZone][val_iInst][iMesh], + solver[val_iZone][val_iInst][iMesh][MESH_SOL], + config[val_iZone], iMesh); + integration[val_iZone][val_iInst][HEAT_SOL]->SetConvergence(false); } } diff --git a/SU2_CFD/src/iteration/CIteration.cpp b/SU2_CFD/src/iteration/CIteration.cpp index b33b39131f9..d76b49ef187 100644 --- a/SU2_CFD/src/iteration/CIteration.cpp +++ b/SU2_CFD/src/iteration/CIteration.cpp @@ -34,13 +34,8 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac CVolumetricMovement* grid_movement, CSolver*** solver, CConfig* config, unsigned long IntIter, unsigned long TimeIter) { unsigned short Kind_Grid_Movement = config->GetKind_GridMovement(); - unsigned long nIterMesh; - bool stat_mesh = true; bool adjoint = config->GetContinuous_Adjoint(); - /*--- Only write to screen if this option is enabled ---*/ - bool Screen_Output = config->GetDeform_Output(); - unsigned short val_iZone = config->GetiZone(); /*--- Perform mesh movement depending on specified type ---*/ @@ -120,32 +115,6 @@ void CIteration::SetGrid_Movement(CGeometry** geometry, CSurfaceMovement* surfac } } - if (config->GetSurface_Movement(FLUID_STRUCTURE)) { - if (rank == MASTER_NODE && Screen_Output) - cout << endl << "Deforming the grid for Fluid-Structure Interaction applications." << endl; - - /*--- Deform the volume grid around the new boundary locations ---*/ - - if (rank == MASTER_NODE && Screen_Output) cout << "Deforming the volume grid." << endl; - grid_movement->SetVolume_Deformation(geometry[MESH_0], config, true, false); - - nIterMesh = grid_movement->Get_nIterMesh(); - stat_mesh = (nIterMesh == 0); - - if (!adjoint && !stat_mesh) { - if (rank == MASTER_NODE && Screen_Output) cout << "Computing grid velocities by finite differencing." << endl; - geometry[MESH_0]->SetGridVelocity(config, TimeIter); - } else if (stat_mesh) { - if (rank == MASTER_NODE && Screen_Output) - cout << "The mesh is up-to-date. Using previously stored grid velocities." << endl; - } - - /*--- Update the multigrid structure after moving the finest grid, - including computing the grid velocities on the coarser levels. ---*/ - - grid_movement->UpdateMultiGrid(geometry, config); - } - if (config->GetSurface_Movement(EXTERNAL) || config->GetSurface_Movement(EXTERNAL_ROTATION)) { /*--- Apply rigid rotation to entire grid first, if necessary ---*/ diff --git a/SU2_CFD/src/iteration/CIterationFactory.cpp b/SU2_CFD/src/iteration/CIterationFactory.cpp index d55188cf2ab..e330c9434e6 100644 --- a/SU2_CFD/src/iteration/CIterationFactory.cpp +++ b/SU2_CFD/src/iteration/CIterationFactory.cpp @@ -112,7 +112,7 @@ CIteration* CIterationFactory::CreateIteration(ENUM_MAIN_SOLVER kindSolver, cons iteration = new CDiscAdjHeatIteration(config); break; - case NO_SOLVER: case FLUID_STRUCTURE_INTERACTION: case TEMPLATE_SOLVER: case MULTIPHYSICS: + case NO_SOLVER: case TEMPLATE_SOLVER: case MULTIPHYSICS: SU2_MPI::Error("No iteration found for specified solver.", CURRENT_FUNCTION); break; } diff --git a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp index 7aa25cfaf27..0f6379ee926 100644 --- a/SU2_CFD/src/numerics/turbulent/turb_sources.cpp +++ b/SU2_CFD/src/numerics/turbulent/turb_sources.cpp @@ -760,16 +760,19 @@ CSourcePieceWise_TurbSST::CSourcePieceWise_TurbSST(unsigned short val_nDim, incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE); sustaining_terms = (config->GetKind_Turb_Model() == SST_SUST); + axisymmetric = config->GetAxisymmetric(); /*--- Closure constants ---*/ - beta_star = constants[6]; - sigma_omega_1 = constants[2]; - sigma_omega_2 = constants[3]; + sigma_k_1 = constants[0]; + sigma_k_2 = constants[1]; + sigma_w_1 = constants[2]; + sigma_w_2 = constants[3]; beta_1 = constants[4]; beta_2 = constants[5]; + beta_star = constants[6]; + a1 = constants[7]; alfa_1 = constants[8]; alfa_2 = constants[9]; - a1 = constants[7]; /*--- Set the ambient values of k and omega to the free stream values. ---*/ kAmb = val_kine_Inf; @@ -845,7 +848,6 @@ CNumerics::ResidualType<> CSourcePieceWise_TurbSST::ComputeResidual(const CConfi pk = Eddy_Viscosity_i*StrainMag_i*StrainMag_i - 2.0/3.0*Density_i*TurbVar_i[0]*diverg; } - pk = min(pk,20.0*beta_star*Density_i*TurbVar_i[1]*TurbVar_i[0]); pk = max(pk,0.0); @@ -889,6 +891,10 @@ CNumerics::ResidualType<> CSourcePieceWise_TurbSST::ComputeResidual(const CConfi /*--- Cross diffusion ---*/ Residual[1] += (1.0 - F1_i)*CDkw_i*Volume; + + /*--- Contribution due to 2D axisymmetric formulation ---*/ + + if (axisymmetric) ResidualAxisymmetric(alfa_blended,zeta); /*--- Implicit part ---*/ diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 3b6f328b533..14240f53105 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -279,9 +279,6 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ Add_CpInverseDesignOutput(config); - /*--- Add combo obj value --- */ - - AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT); } void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ @@ -718,10 +715,6 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol Set_CpInverseDesign(flow_solver, geometry, config); - /*--- Set combo obj value --- */ - - SetHistoryOutputValue("COMBO", flow_solver->GetTotal_ComboObj()); - } bool CFlowCompOutput::SetInit_Residuals(CConfig *config){ diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index e0b28799cf5..4c33d0354a2 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -638,6 +638,8 @@ void CFlowOutput::AddAerodynamicCoefficients(CConfig *config){ /// DESCRIPTION: Angle of attack AddHistoryOutput("AOA", "AoA", ScreenOutputFormat::FIXED, "AOA", "Angle of attack"); + + AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT); } void CFlowOutput::SetAerodynamicCoefficients(CConfig *config, CSolver *flow_solver){ @@ -680,6 +682,8 @@ void CFlowOutput::SetAerodynamicCoefficients(CConfig *config, CSolver *flow_solv } SetHistoryOutputValue("AOA", config->GetAoA()); + + SetHistoryOutputValue("COMBO", flow_solver->GetTotal_ComboObj()); } void CFlowOutput::SetRotatingFrameCoefficients(CConfig *config, CSolver *flow_solver) { diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 917823fa4fd..43686451a96 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -279,9 +279,6 @@ void CNEMOCompOutput::SetHistoryOutputFields(CConfig *config){ Add_CpInverseDesignOutput(config); - /*--- Add combo obj value --- */ - - AddHistoryOutput("COMBO", "ComboObj", ScreenOutputFormat::SCIENTIFIC, "COMBO", "Combined obj. function value.", HistoryFieldType::COEFFICIENT); } void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ @@ -686,10 +683,6 @@ void CNEMOCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol Set_CpInverseDesign(NEMO_solver, geometry, config); - /*--- Set combo obj value --- */ - - SetHistoryOutputValue("COMBO", NEMO_solver->GetTotal_ComboObj()); - } bool CNEMOCompOutput::SetInit_Residuals(CConfig *config){ diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index fde9093bc58..ebf9a926d5d 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -33,10 +33,7 @@ void CDriver::PythonInterface_Preprocessing(CConfig **config, CGeometry ****geometry, CSolver *****solver){ int rank = MASTER_NODE; - -#ifdef HAVE_MPI - MPI_Comm_rank(SU2_MPI::GetComm(), &rank); -#endif + SU2_MPI::Comm_rank(SU2_MPI::GetComm(), &rank); /* --- Initialize boundary conditions customization, this is achieve through the Python wrapper --- */ for(iZone=0; iZone < nZone; iZone++){ @@ -59,39 +56,21 @@ void CDriver::PythonInterface_Preprocessing(CConfig **config, CGeometry ****geom } } } - /*--- Initialize some variables used for external communications trough the Py wrapper. ---*/ - PyWrapVarCoord[0] = 0.0; - PyWrapVarCoord[1] = 0.0; - PyWrapVarCoord[2] = 0.0; - PyWrapNodalForce[0] = 0.0; - PyWrapNodalForce[1] = 0.0; - PyWrapNodalForce[2] = 0.0; - PyWrapNodalForceDensity[0] = 0.0; - PyWrapNodalForceDensity[1] = 0.0; - PyWrapNodalForceDensity[2] = 0.0; - PyWrapNodalHeatFlux[0] = 0.0; - PyWrapNodalHeatFlux[1] = 0.0; - PyWrapNodalHeatFlux[2] = 0.0; } -passivedouble CDriver::Get_Drag() { +///////////////////////////////////////////////////////////////////////////// +/* Functions related to the global performance indices (Lift, Drag, ecc..) */ +///////////////////////////////////////////////////////////////////////////// + +passivedouble CDriver::Get_Drag() const { unsigned short val_iZone = ZONE_0; unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CDrag, RefDensity, RefArea, RefVel2, factor, val_Drag; - - /*--- Export free-stream density and reference area ---*/ - RefDensity = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetDensity_Inf(); - RefArea = config_container[val_iZone]->GetRefArea(); - - /*--- Calculate free-stream velocity (squared) ---*/ - RefVel2 = 0.0; - for(unsigned short iDim = 0; iDim < nDim; iDim++) - RefVel2 += pow(solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetVelocity_Inf(iDim),2); + su2double CDrag, factor, val_Drag; /*--- Calculate drag force based on drag coefficient ---*/ - factor = 0.5*RefDensity*RefArea*RefVel2; + factor = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAeroCoeffsReferenceForce(); CDrag = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CD(); val_Drag = CDrag*factor; @@ -99,23 +78,14 @@ passivedouble CDriver::Get_Drag() { return SU2_TYPE::GetValue(val_Drag); } -passivedouble CDriver::Get_Lift() { +passivedouble CDriver::Get_Lift() const { unsigned short val_iZone = ZONE_0; unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CLift, RefDensity, RefArea, RefVel2, factor, val_Lift; - - /*--- Export free-stream density and reference area ---*/ - RefDensity = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetDensity_Inf(); - RefArea = config_container[val_iZone]->GetRefArea(); - - /*--- Calculate free-stream velocity (squared) ---*/ - RefVel2 = 0.0; - for(unsigned short iDim = 0; iDim < nDim; iDim++) - RefVel2 += pow(solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetVelocity_Inf(iDim),2); + su2double CLift, factor, val_Lift; /*--- Calculate drag force based on drag coefficient ---*/ - factor = 0.5*RefDensity*RefArea*RefVel2; + factor = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAeroCoeffsReferenceForce(); CLift = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CL(); val_Lift = CLift*factor; @@ -123,137 +93,90 @@ passivedouble CDriver::Get_Lift() { return SU2_TYPE::GetValue(val_Lift); } -passivedouble CDriver::Get_Mx(){ +passivedouble CDriver::Get_Mx() const { unsigned short val_iZone = ZONE_0; unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CMx, RefDensity, RefArea, RefLengthCoeff, RefVel2, factor, val_Mx; + su2double CMx, RefLengthCoeff, factor, val_Mx; - /*--- Export free-stream density and reference area ---*/ - RefDensity = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetDensity_Inf(); - RefArea = config_container[val_iZone]->GetRefArea(); RefLengthCoeff = config_container[val_iZone]->GetRefLength(); - /*--- Calculate free-stream velocity (squared) ---*/ - RefVel2 = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - RefVel2 += pow(solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetVelocity_Inf(iDim),2); - /*--- Calculate moment around x-axis based on coefficients ---*/ - factor = 0.5*RefDensity*RefArea*RefVel2; + factor = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAeroCoeffsReferenceForce(); CMx = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CMx(); val_Mx = CMx*factor*RefLengthCoeff; return SU2_TYPE::GetValue(val_Mx); - } -passivedouble CDriver::Get_My(){ +passivedouble CDriver::Get_My() const { unsigned short val_iZone = ZONE_0; unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CMy, RefDensity, RefArea, RefLengthCoeff, RefVel2, factor, val_My; + su2double CMy, RefLengthCoeff, factor, val_My; - /*--- Export free-stream density and reference area ---*/ - RefDensity = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetDensity_Inf(); - RefArea = config_container[val_iZone]->GetRefArea(); RefLengthCoeff = config_container[val_iZone]->GetRefLength(); - /*--- Calculate free-stream velocity (squared) ---*/ - RefVel2 = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) - RefVel2 += pow(solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetVelocity_Inf(iDim),2); - /*--- Calculate moment around x-axis based on coefficients ---*/ - factor = 0.5*RefDensity*RefArea*RefVel2; + factor = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAeroCoeffsReferenceForce(); CMy = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CMy(); val_My = CMy*factor*RefLengthCoeff; return SU2_TYPE::GetValue(val_My); - } -passivedouble CDriver::Get_Mz() { +passivedouble CDriver::Get_Mz() const { unsigned short val_iZone = ZONE_0; unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CMz, RefDensity, RefArea, RefLengthCoeff, RefVel2, factor, val_Mz; + su2double CMz, RefLengthCoeff, factor, val_Mz; - /*--- Export free-stream density and reference area ---*/ - RefDensity = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetDensity_Inf(); - RefArea = config_container[val_iZone]->GetRefArea(); RefLengthCoeff = config_container[val_iZone]->GetRefLength(); - /*--- Calculate free-stream velocity (squared) ---*/ - RefVel2 = 0.0; - for(unsigned short iDim = 0; iDim < nDim; iDim++) - RefVel2 += pow(solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetVelocity_Inf(iDim),2); - /*--- Calculate moment around z-axis based on coefficients ---*/ - factor = 0.5*RefDensity*RefArea*RefVel2; + factor = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetAeroCoeffsReferenceForce(); CMz = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CMz(); val_Mz = CMz*factor*RefLengthCoeff; return SU2_TYPE::GetValue(val_Mz); - } -passivedouble CDriver::Get_DragCoeff() { +passivedouble CDriver::Get_DragCoeff() const { - unsigned short val_iZone = ZONE_0; - unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CDrag; + unsigned short val_iZone = ZONE_0; + unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); + su2double CDrag; - CDrag = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CD(); + CDrag = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CD(); - return SU2_TYPE::GetValue(CDrag); + return SU2_TYPE::GetValue(CDrag); } -passivedouble CDriver::Get_LiftCoeff() { +passivedouble CDriver::Get_LiftCoeff() const { - unsigned short val_iZone = ZONE_0; - unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); - su2double CLift; + unsigned short val_iZone = ZONE_0; + unsigned short FinestMesh = config_container[val_iZone]->GetFinestMesh(); + su2double CLift; - CLift = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CL(); + CLift = solver_container[val_iZone][INST_0][FinestMesh][FLOW_SOL]->GetTotal_CL(); - return SU2_TYPE::GetValue(CLift); + return SU2_TYPE::GetValue(CLift); } -unsigned short CDriver::GetMovingMarker() { - - unsigned short IDtoSend,iMarker, jMarker, Moving; - string Marker_Tag, Moving_Tag; - - IDtoSend = 0; - for (iMarker = 0; iMarker < config_container[ZONE_0]->GetnMarker_All(); iMarker++) { - Moving = config_container[ZONE_0]->GetMarker_All_Moving(iMarker); - if (Moving == YES) { - for (jMarker = 0; jMarkerGetnMarker_Moving(); jMarker++) { - Moving_Tag = config_container[ZONE_0]->GetMarker_Moving_TagBound(jMarker); - Marker_Tag = config_container[ZONE_0]->GetMarker_All_TagBound(iMarker); - if (Marker_Tag == Moving_Tag) { - IDtoSend = iMarker; - break; - } - } - } - } - - return IDtoSend; - -} +///////////////////////////////////////////////////////////////////////////// +/* Functions to obtain information from the geometry/mesh */ +///////////////////////////////////////////////////////////////////////////// -unsigned long CDriver::GetNumberVertices(unsigned short iMarker){ +unsigned long CDriver::GetNumberVertices(unsigned short iMarker) const { return geometry_container[ZONE_0][INST_0][MESH_0]->nVertex[iMarker]; } -unsigned long CDriver::GetNumberHaloVertices(unsigned short iMarker){ +unsigned long CDriver::GetNumberHaloVertices(unsigned short iMarker) const { unsigned long nHaloVertices, iVertex, iPoint; @@ -267,7 +190,7 @@ unsigned long CDriver::GetNumberHaloVertices(unsigned short iMarker){ } -unsigned long CDriver::GetVertexGlobalIndex(unsigned short iMarker, unsigned long iVertex) { +unsigned long CDriver::GetVertexGlobalIndex(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint, GlobalIndex; @@ -278,7 +201,7 @@ unsigned long CDriver::GetVertexGlobalIndex(unsigned short iMarker, unsigned lon } -bool CDriver::IsAHaloNode(unsigned short iMarker, unsigned long iVertex) { +bool CDriver::IsAHaloNode(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; @@ -288,212 +211,69 @@ bool CDriver::IsAHaloNode(unsigned short iMarker, unsigned long iVertex) { } -unsigned long CDriver::GetnTimeIter() { - - return config_container[ZONE_0]->GetnTime_Iter(); -} - -unsigned long CDriver::GetTime_Iter() const{ - - return TimeIter; -} - -passivedouble CDriver::GetUnsteady_TimeStep(){ - - return SU2_TYPE::GetValue(config_container[ZONE_0]->GetTime_Step()); -} - -passivedouble CDriver::GetVertexCoordX(unsigned short iMarker, unsigned long iVertex) { - - su2double* Coord; - unsigned long iPoint; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); - return SU2_TYPE::GetValue(Coord[0]); - -} - -passivedouble CDriver::GetVertexCoordY(unsigned short iMarker, unsigned long iVertex) { - - su2double* Coord; - unsigned long iPoint; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); - return SU2_TYPE::GetValue(Coord[1]); -} +vector CDriver::GetInitialMeshCoord(unsigned short iMarker, unsigned long iVertex) const { -passivedouble CDriver::GetVertexCoordZ(unsigned short iMarker, unsigned long iVertex) { + vector coord(3,0.0); + vector coord_passive(3, 0.0); - su2double* Coord; - unsigned long iPoint; - - if(nDim == 3) { - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); - return SU2_TYPE::GetValue(Coord[2]); + auto iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); + for (auto iDim = 0 ; iDim < nDim ; iDim++){ + coord[iDim] = solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->GetMesh_Coord(iPoint,iDim); } - else { - return 0.0; - } - -} - -bool CDriver::ComputeVertexForces(unsigned short iMarker, unsigned long iVertex) { - - unsigned long iPoint; - unsigned short iDim, jDim; - su2double *Normal, AreaSquare, Area; - bool halo; - - unsigned short FinestMesh = config_container[ZONE_0]->GetFinestMesh(); - - /*--- Check the kind of fluid problem ---*/ - bool compressible = (config_container[ZONE_0]->GetKind_Regime() == COMPRESSIBLE); - bool incompressible = (config_container[ZONE_0]->GetKind_Regime() == INCOMPRESSIBLE); - bool viscous_flow = ((config_container[ZONE_0]->GetKind_Solver() == NAVIER_STOKES) || - (config_container[ZONE_0]->GetKind_Solver() == RANS) ); - - /*--- Parameters for the calculations ---*/ - // Pn: Pressure - // Pinf: Pressure_infinite - su2double Pn = 0.0; - su2double Viscosity = 0.0; - su2double Tau[3][3] = {{0.0}}; - su2double Pinf = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetPressure_Inf(); - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - - /*--- It is necessary to distinguish the halo nodes from the others, since they introduce non physical forces. ---*/ - if(geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetDomain(iPoint)) { - /*--- Get the normal at the vertex: this normal goes inside the fluid domain. ---*/ - Normal = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNormal(); - AreaSquare = 0.0; - for(iDim = 0; iDim < nDim; iDim++) { - AreaSquare += Normal[iDim]*Normal[iDim]; - } - Area = sqrt(AreaSquare); - - /*--- Get the values of pressure and viscosity ---*/ - Pn = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetPressure(iPoint); - if (viscous_flow) { - Viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); - } - - /*--- Calculate the inviscid (pressure) part of tn in the fluid nodes (force units) ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - PyWrapNodalForce[iDim] = -(Pn-Pinf)*Normal[iDim]; //NB : norm(Normal) = Area - } - - /*--- Calculate the viscous (shear stress) part of tn in the fluid nodes (force units) ---*/ - if ((incompressible || compressible) && viscous_flow) { - CNumerics::ComputeStressTensor(nDim, Tau, - solver_container[ZONE_0][INST_0][FinestMesh][FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint)+1, Viscosity); - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0 ; jDim < nDim; jDim++) { - PyWrapNodalForce[iDim] += Tau[iDim][jDim]*Normal[jDim]; - } - } - } - - //Divide by local are in case of force density communication. - for(iDim = 0; iDim < nDim; iDim++) { - PyWrapNodalForceDensity[iDim] = PyWrapNodalForce[iDim]/Area; - } - - halo = false; - } - else { - halo = true; - } - - return halo; + coord_passive[0] = SU2_TYPE::GetValue(coord[0]); + coord_passive[1] = SU2_TYPE::GetValue(coord[1]); + coord_passive[2] = SU2_TYPE::GetValue(coord[2]); + return coord_passive; } -passivedouble CDriver::GetVertexForceX(unsigned short iMarker, unsigned long iVertex) { +vector CDriver::GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const { - return SU2_TYPE::GetValue(PyWrapNodalForce[0]); - -} - -passivedouble CDriver::GetVertexForceY(unsigned short iMarker, unsigned long iVertex) { - - return SU2_TYPE::GetValue(PyWrapNodalForce[1]); - -} - -passivedouble CDriver::GetVertexForceZ(unsigned short iMarker, unsigned long iVertex) { + su2double *Normal; + su2double Area; + vector ret_Normal(3, 0.0); + vector ret_Normal_passive(3, 0.0); - return SU2_TYPE::GetValue(PyWrapNodalForce[2]); + Normal = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNormal(); -} + Area = GeometryToolbox::Norm(nDim, Normal); -passivedouble CDriver::GetVertexForceDensityX(unsigned short iMarker, unsigned long iVertex) { - return SU2_TYPE::GetValue(PyWrapNodalForceDensity[0]); -} + ret_Normal[0] = Normal[0]/Area; + ret_Normal[1] = Normal[1]/Area; + if(nDim>2) ret_Normal[2] = Normal[2]/Area; -passivedouble CDriver::GetVertexForceDensityY(unsigned short iMarker, unsigned long iVertex) { - return SU2_TYPE::GetValue(PyWrapNodalForceDensity[1]); -} + ret_Normal_passive[0] = SU2_TYPE::GetValue(ret_Normal[0]); + ret_Normal_passive[1] = SU2_TYPE::GetValue(ret_Normal[1]); + ret_Normal_passive[2] = SU2_TYPE::GetValue(ret_Normal[2]); -passivedouble CDriver::GetVertexForceDensityZ(unsigned short iMarker, unsigned long iVertex) { - return SU2_TYPE::GetValue(PyWrapNodalForceDensity[2]); + return ret_Normal_passive; } -void CDriver::SetVertexCoordX(unsigned short iMarker, unsigned long iVertex, passivedouble newPosX) { +////////////////////////////////////////////////////////////////////////////////// +/* Functions to obtain global parameters from SU2 (time steps, delta t, ecc...) */ +////////////////////////////////////////////////////////////////////////////////// - unsigned long iPoint; - su2double *Coord; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); - - PyWrapVarCoord[0] = newPosX - Coord[0]; +unsigned long CDriver::GetnTimeIter() const { + return config_container[ZONE_0]->GetnTime_Iter(); } -void CDriver::SetVertexCoordY(unsigned short iMarker, unsigned long iVertex, passivedouble newPosY) { - - unsigned long iPoint; - su2double *Coord; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); +unsigned long CDriver::GetTime_Iter() const{ - PyWrapVarCoord[1] = newPosY - Coord[1]; + return TimeIter; } -void CDriver::SetVertexCoordZ(unsigned short iMarker, unsigned long iVertex, passivedouble newPosZ) { - - unsigned long iPoint; - su2double *Coord; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - Coord = geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetCoord(iPoint); +passivedouble CDriver::GetUnsteady_TimeStep() const { - if(nDim > 2) { - PyWrapVarCoord[2] = newPosZ - Coord[2]; - } - else { - PyWrapVarCoord[2] = 0.0; - } + return SU2_TYPE::GetValue(config_container[ZONE_0]->GetTime_Step()); } -passivedouble CDriver::SetVertexVarCoord(unsigned short iMarker, unsigned long iVertex) { - - su2double nodalVarCoordNorm; +/////////////////////////////////////////////////////////////////////////////// +/* Functions related to CHT solver */ +/////////////////////////////////////////////////////////////////////////////// - geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->SetVarCoord(PyWrapVarCoord); - nodalVarCoordNorm = sqrt((PyWrapVarCoord[0])*(PyWrapVarCoord[0]) + (PyWrapVarCoord[1])*(PyWrapVarCoord[1]) + (PyWrapVarCoord[2])*(PyWrapVarCoord[2])); - - return SU2_TYPE::GetValue(nodalVarCoordNorm); - -} - -passivedouble CDriver::GetVertexTemperature(unsigned short iMarker, unsigned long iVertex){ +passivedouble CDriver::GetVertexTemperature(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; su2double vertexWallTemp(0.0); @@ -515,7 +295,7 @@ void CDriver::SetVertexTemperature(unsigned short iMarker, unsigned long iVertex geometry_container[ZONE_0][INST_0][MESH_0]->SetCustomBoundaryTemperature(iMarker, iVertex, val_WallTemp); } -bool CDriver::ComputeVertexHeatFluxes(unsigned short iMarker, unsigned long iVertex){ +vector CDriver::GetVertexHeatFluxes(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; unsigned short iDim; @@ -525,48 +305,31 @@ bool CDriver::ComputeVertexHeatFluxes(unsigned short iMarker, unsigned long iVer su2double Gamma_Minus_One = Gamma - 1.0; su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; su2double laminar_viscosity, thermal_conductivity; - su2double GradT[3] = {0.0,0.0,0.0}; + vector GradT (3,0.0); + vector HeatFlux (3,0.0); + vector HeatFluxPassive (3,0.0); bool compressible = (config_container[ZONE_0]->GetKind_Regime() == COMPRESSIBLE); - bool halo; iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - if(geometry_container[ZONE_0][INST_0][MESH_0]->nodes->GetDomain(iPoint)){ - halo = false; - } - else{ - halo = true; - } - - if(!halo && compressible){ + if(compressible){ laminar_viscosity = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); thermal_conductivity = Cp * (laminar_viscosity/Prandtl_Lam); for(iDim=0; iDim < nDim; iDim++){ GradT[iDim] = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->GetNodes()->GetGradient_Primitive(iPoint, 0, iDim); - PyWrapNodalHeatFlux[iDim] = -thermal_conductivity*GradT[iDim]; + HeatFlux[iDim] = -thermal_conductivity*GradT[iDim]; } } - return halo; -} - -passivedouble CDriver::GetVertexHeatFluxX(unsigned short iMarker, unsigned long iVertex){ - - return SU2_TYPE::GetValue(PyWrapNodalHeatFlux[0]); -} - -passivedouble CDriver::GetVertexHeatFluxY(unsigned short iMarker, unsigned long iVertex){ + HeatFluxPassive[0] = SU2_TYPE::GetValue(HeatFlux[0]); + HeatFluxPassive[1] = SU2_TYPE::GetValue(HeatFlux[1]); + HeatFluxPassive[2] = SU2_TYPE::GetValue(HeatFlux[2]); - return SU2_TYPE::GetValue(PyWrapNodalHeatFlux[1]); + return HeatFluxPassive; } -passivedouble CDriver::GetVertexHeatFluxZ(unsigned short iMarker, unsigned long iVertex){ - - return SU2_TYPE::GetValue(PyWrapNodalHeatFlux[2]); -} - -passivedouble CDriver::GetVertexNormalHeatFlux(unsigned short iMarker, unsigned long iVertex){ +passivedouble CDriver::GetVertexNormalHeatFlux(unsigned short iMarker, unsigned long iVertex) const{ unsigned long iPoint; unsigned short iDim; @@ -614,7 +377,7 @@ void CDriver::SetVertexNormalHeatFlux(unsigned short iMarker, unsigned long iVer geometry_container[ZONE_0][INST_0][MESH_0]->SetCustomBoundaryHeatFlux(iMarker, iVertex, val_WallHeatFlux); } -passivedouble CDriver::GetThermalConductivity(unsigned short iMarker, unsigned long iVertex){ +passivedouble CDriver::GetThermalConductivity(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; su2double Prandtl_Lam = config_container[ZONE_0]->GetPrandtl_Lam(); @@ -632,31 +395,11 @@ passivedouble CDriver::GetThermalConductivity(unsigned short iMarker, unsigned l } -vector CDriver::GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex){ - - su2double *Normal; - su2double Area; - vector ret_Normal(3, 0.0); - vector ret_Normal_passive(3, 0.0); - - Normal = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNormal(); +//////////////////////////////////////////////////////////////////////////////// +/* Functions related to the management of markers */ +//////////////////////////////////////////////////////////////////////////////// - Area = GeometryToolbox::Norm(nDim, Normal); - - ret_Normal[0] = Normal[0]/Area; - ret_Normal[1] = Normal[1]/Area; - if(nDim>2) ret_Normal[2] = Normal[2]/Area; - - ret_Normal_passive[0] = SU2_TYPE::GetValue(ret_Normal[0]); - ret_Normal_passive[1] = SU2_TYPE::GetValue(ret_Normal[1]); - ret_Normal_passive[2] = SU2_TYPE::GetValue(ret_Normal[2]); - - return ret_Normal_passive; - - -} - -vector CDriver::GetAllBoundaryMarkersTag(){ +vector CDriver::GetAllBoundaryMarkersTag() const { vector boundariesTagList; unsigned short iMarker,nBoundariesMarkers; @@ -673,24 +416,7 @@ vector CDriver::GetAllBoundaryMarkersTag(){ return boundariesTagList; } -vector CDriver::GetAllMovingMarkersTag(){ - - vector movingBoundariesTagList; - unsigned short iMarker, nBoundariesMarker; - string Marker_Tag; - - nBoundariesMarker = config_container[ZONE_0]->GetnMarker_Moving(); - movingBoundariesTagList.resize(nBoundariesMarker); - - for(iMarker=0; iMarker < nBoundariesMarker; iMarker++){ - Marker_Tag = config_container[ZONE_0]->GetMarker_Moving_TagBound(iMarker); - movingBoundariesTagList[iMarker] = Marker_Tag; - } - - return movingBoundariesTagList; -} - -vector CDriver::GetAllDeformMeshMarkersTag(){ +vector CDriver::GetAllDeformMeshMarkersTag() const { vector interfaceBoundariesTagList; unsigned short iMarker, nBoundariesMarker; @@ -707,31 +433,13 @@ vector CDriver::GetAllDeformMeshMarkersTag(){ return interfaceBoundariesTagList; } -vector CDriver::GetAllFluidLoadMarkersTag(){ - - vector interfaceBoundariesTagList; - unsigned short iMarker, nBoundariesMarker; - string Marker_Tag; - - nBoundariesMarker = config_container[ZONE_0]->GetnMarker_Fluid_Load(); - interfaceBoundariesTagList.resize(nBoundariesMarker); - - for(iMarker=0; iMarker < nBoundariesMarker; iMarker++){ - Marker_Tag = config_container[ZONE_0]->GetMarker_Fluid_Load_TagBound(iMarker); - interfaceBoundariesTagList[iMarker] = Marker_Tag; - } - - return interfaceBoundariesTagList; -} - -vector CDriver::GetAllCHTMarkersTag(){ +vector CDriver::GetAllCHTMarkersTag() const { vector CHTBoundariesTagList; unsigned short iMarker, nBoundariesMarker; string Marker_Tag; nBoundariesMarker = config_container[ZONE_0]->GetnMarker_All(); - //CHTBoundariesTagList.resize(nBoundariesMarker); //The CHT markers can be identified as the markers that are customizable with a BC type HEAT_FLUX or ISOTHERMAL. for(iMarker=0; iMarker CDriver::GetAllCHTMarkersTag(){ return CHTBoundariesTagList; } -vector CDriver::GetAllInletMarkersTag(){ +vector CDriver::GetAllInletMarkersTag() const { vector BoundariesTagList; unsigned short iMarker, nBoundariesMarker; @@ -764,7 +472,7 @@ vector CDriver::GetAllInletMarkersTag(){ return BoundariesTagList; } -map CDriver::GetAllBoundaryMarkers(){ +map CDriver::GetAllBoundaryMarkers() const { map allBoundariesMap; unsigned short iMarker, nBoundaryMarkers; @@ -780,7 +488,7 @@ map CDriver::GetAllBoundaryMarkers(){ return allBoundariesMap; } -map CDriver::GetAllBoundaryMarkersType(){ +map CDriver::GetAllBoundaryMarkersType() const { map allBoundariesTypeMap; unsigned short iMarker, KindBC; @@ -823,6 +531,34 @@ map CDriver::GetAllBoundaryMarkersType(){ return allBoundariesTypeMap; } +void CDriver::SetHeatSource_Position(passivedouble alpha, passivedouble pos_x, passivedouble pos_y, passivedouble pos_z){ + + CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][RAD_SOL]; + + config_container[ZONE_0]->SetHeatSource_Rot_Z(alpha); + config_container[ZONE_0]->SetHeatSource_Center(pos_x, pos_y, pos_z); + + solver->SetVolumetricHeatSource(geometry_container[ZONE_0][INST_0][MESH_0], config_container[ZONE_0]); + +} + +void CDriver::SetInlet_Angle(unsigned short iMarker, passivedouble alpha){ + + su2double alpha_rad = alpha * PI_NUMBER/180.0; + + unsigned long iVertex; + + for (iVertex = 0; iVertex < geometry_container[ZONE_0][INST_0][MESH_0]->nVertex[iMarker]; iVertex++){ + solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 0, cos(alpha_rad)); + solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 1, sin(alpha_rad)); + } + +} + +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// +/* Functions related to simulation control, high level functions (reset convergence, set initial mesh, ecc...) */ +///////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void CDriver::ResetConvergence() { for(iZone = 0; iZone < nZone; iZone++) { @@ -850,44 +586,6 @@ void CDriver::ResetConvergence() { } -void CFluidDriver::StaticMeshUpdate() { - - int rank = MASTER_NODE; - -#ifdef HAVE_MPI - MPI_Comm_rank(SU2_MPI::GetComm(), &rank); -#endif - - for(iZone = 0; iZone < nZone; iZone++) { - if(rank == MASTER_NODE) cout << " Deforming the volume grid." << endl; - grid_movement[iZone][INST_0]->SetVolume_Deformation(geometry_container[iZone][INST_0][MESH_0], config_container[iZone], true); - - if(rank == MASTER_NODE) cout << "No grid velocity to be computde : static grid deformation." << endl; - - if(rank == MASTER_NODE) cout << " Updating multigrid structure." << endl; - grid_movement[iZone][INST_0]->UpdateMultiGrid(geometry_container[iZone][INST_0], config_container[iZone]); - } -} - -void CFluidDriver::SetInitialMesh() { - - StaticMeshUpdate(); - - /*--- Propagate the initial deformation to the past ---*/ - //if (!restart) { - for(iZone = 0; iZone < nZone; iZone++) { - for (iMesh = 0; iMesh <= config_container[iZone]->GetnMGLevels(); iMesh++) { - //solver_container[iZone][iMesh][FLOW_SOL]->nodes->Set_Solution_time_n(iPoint); - //solver_container[iZone][iMesh][FLOW_SOL]->nodes->Set_Solution_time_n1(iPoint); - geometry_container[iZone][INST_0][iMesh]->nodes->SetVolume_n(); - geometry_container[iZone][INST_0][iMesh]->nodes->SetVolume_nM1(); - geometry_container[iZone][INST_0][iMesh]->nodes->SetCoord_n(); - geometry_container[iZone][INST_0][iMesh]->nodes->SetCoord_n1(); - } - } - //} -} - void CSinglezoneDriver::SetInitialMesh() { DynamicMeshUpdate(0); @@ -914,52 +612,12 @@ void CSinglezoneDriver::SetInitialMesh() { } } -void CFluidDriver::SetVertexTtotal(unsigned short iMarker, unsigned long iVertex, passivedouble val_Ttotal_passive){ - - su2double val_Ttotal = val_Ttotal_passive; - - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_Ttotal(iMarker, iVertex, val_Ttotal); - -} - -void CFluidDriver::SetVertexPtotal(unsigned short iMarker, unsigned long iVertex, passivedouble val_Ptotal_passive){ - - su2double val_Ptotal = val_Ptotal_passive; - - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_Ptotal(iMarker, iVertex, val_Ptotal); - -} - -void CFluidDriver::SetVertexFlowDir(unsigned short iMarker, unsigned long iVertex, unsigned short iDim, passivedouble val_FlowDir_passive){ - - su2double val_FlowDir = val_FlowDir_passive; - - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, iDim, val_FlowDir); - -} - -void CFluidDriver::SetVertexTurbVar(unsigned short iMarker, unsigned long iVertex, unsigned short iDim, passivedouble val_turb_var_passive){ - - su2double val_turb_var = val_turb_var_passive; - - if (solver_container[ZONE_0][INST_0] == nullptr || - solver_container[ZONE_0][INST_0][MESH_0] == nullptr) { - SU2_MPI::Error("Could not find an appropriate solver.", CURRENT_FUNCTION); - } else if (solver_container[ZONE_0][INST_0][MESH_0][TURB_SOL] == nullptr) { - SU2_MPI::Error("Tried to set turbulence variables without a turbulence solver.", CURRENT_FUNCTION); - } - solver_container[ZONE_0][INST_0][MESH_0][TURB_SOL]->SetInlet_TurbVar(iMarker, iVertex, iDim, val_turb_var); - -} - -void CFluidDriver::BoundaryConditionsUpdate(){ +void CDriver::BoundaryConditionsUpdate(){ int rank = MASTER_NODE; unsigned short iZone; -#ifdef HAVE_MPI - MPI_Comm_rank(SU2_MPI::GetComm(), &rank); -#endif + SU2_MPI::Comm_rank(SU2_MPI::GetComm(), &rank); if(rank == MASTER_NODE) cout << "Updating boundary conditions." << endl; for(iZone = 0; iZone < nZone; iZone++){ @@ -967,67 +625,25 @@ void CFluidDriver::BoundaryConditionsUpdate(){ } } -void CDriver::SetMeshDisplacement(unsigned short iMarker, unsigned long iVertex, passivedouble DispX, passivedouble DispY, passivedouble DispZ) { - - unsigned long iPoint; - PyWrapVarCoord[0] = DispX; - PyWrapVarCoord[1] = DispY; - PyWrapVarCoord[2] = DispZ; - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->SetBound_Disp(iPoint,PyWrapVarCoord); - -} - -void CDriver::CommunicateMeshDisplacement(void) { - - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->InitiateComms(geometry_container[ZONE_0][INST_0][MESH_0], - config_container[ZONE_0], MESH_DISPLACEMENTS); - solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->CompleteComms(geometry_container[ZONE_0][INST_0][MESH_0], - config_container[ZONE_0], MESH_DISPLACEMENTS); - -} - -vector CDriver::GetMeshDisp_Sensitivity(unsigned short iMarker, unsigned long iVertex) { - - unsigned long iPoint; - vector Disp_Sens(3, 0.0); - vector Disp_Sens_passive(3, 0.0); - - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJMESH_SOL]; - CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - - Disp_Sens[0] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 0); - Disp_Sens[1] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 1); - if (geometry->GetnDim() == 3) - Disp_Sens[2] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 2); - else - Disp_Sens[2] = 0.0; - - Disp_Sens_passive[0] = SU2_TYPE::GetValue(Disp_Sens[0]); - Disp_Sens_passive[1] = SU2_TYPE::GetValue(Disp_Sens[1]); - Disp_Sens_passive[2] = SU2_TYPE::GetValue(Disp_Sens[2]); - - return Disp_Sens_passive; - -} +//////////////////////////////////////////////////////////////////////////////// +/* Functions related to finite elements */ +//////////////////////////////////////////////////////////////////////////////// void CDriver::SetFEA_Loads(unsigned short iMarker, unsigned long iVertex, passivedouble LoadX, passivedouble LoadY, passivedouble LoadZ) { unsigned long iPoint; - PyWrapNodalForce[0] = LoadX; - PyWrapNodalForce[1] = LoadY; - PyWrapNodalForce[2] = LoadZ; + su2double NodalForce[3] = {0.0,0.0,0.0}; + NodalForce[0] = LoadX; + NodalForce[1] = LoadY; + NodalForce[2] = LoadZ; iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL]->GetNodes()->Set_FlowTraction(iPoint,PyWrapNodalForce); + solver_container[ZONE_0][INST_0][MESH_0][FEA_SOL]->GetNodes()->Set_FlowTraction(iPoint,NodalForce); } -vector CDriver::GetFEA_Displacements(unsigned short iMarker, unsigned long iVertex) { +vector CDriver::GetFEA_Displacements(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; vector Displacements(3, 0.0); @@ -1052,7 +668,7 @@ vector CDriver::GetFEA_Displacements(unsigned short iMarker, unsi } -vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned long iVertex) { +vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; vector Velocity(3, 0.0); @@ -1070,11 +686,6 @@ vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned else Velocity[2] = 0.0; } - else{ - Velocity[0] = 0.0; - Velocity[1] = 0.0; - Velocity[2] = 0.0; - } Velocity_passive[0] = SU2_TYPE::GetValue(Velocity[0]); Velocity_passive[1] = SU2_TYPE::GetValue(Velocity[1]); @@ -1083,7 +694,7 @@ vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned return Velocity_passive; } -vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigned long iVertex) { +vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; vector Velocity_n(3, 0.0); @@ -1101,11 +712,6 @@ vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigne else Velocity_n[2] = 0.0; } - else{ - Velocity_n[0] = 0.0; - Velocity_n[1] = 0.0; - Velocity_n[2] = 0.0; - } Velocity_n_passive[0] = SU2_TYPE::GetValue(Velocity_n[0]); Velocity_n_passive[1] = SU2_TYPE::GetValue(Velocity_n[1]); @@ -1115,7 +721,36 @@ vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigne } -vector CDriver::GetFlowLoad_Sensitivity(unsigned short iMarker, unsigned long iVertex) { +//////////////////////////////////////////////////////////////////////////////// +/* Functions related to adjoint simulations */ +//////////////////////////////////////////////////////////////////////////////// + +vector CDriver::GetMeshDisp_Sensitivity(unsigned short iMarker, unsigned long iVertex) const { + + unsigned long iPoint; + vector Disp_Sens(3, 0.0); + vector Disp_Sens_passive(3, 0.0); + + iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); + CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJMESH_SOL]; + CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; + + Disp_Sens[0] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 0); + Disp_Sens[1] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 1); + if (geometry->GetnDim() == 3) + Disp_Sens[2] = solver->GetNodes()->GetBoundDisp_Sens(iPoint, 2); + else + Disp_Sens[2] = 0.0; + + Disp_Sens_passive[0] = SU2_TYPE::GetValue(Disp_Sens[0]); + Disp_Sens_passive[1] = SU2_TYPE::GetValue(Disp_Sens[1]); + Disp_Sens_passive[2] = SU2_TYPE::GetValue(Disp_Sens[2]); + + return Disp_Sens_passive; + +} + +vector CDriver::GetFlowLoad_Sensitivity(unsigned short iMarker, unsigned long iVertex) const { unsigned long iPoint; vector FlowLoad_Sens(3, 0.0); @@ -1140,36 +775,6 @@ vector CDriver::GetFlowLoad_Sensitivity(unsigned short iMarker, u } -vector CDriver::GetFlowLoad(unsigned short iMarker, unsigned long iVertex) { - - vector FlowLoad(3, 0.0); - vector FlowLoad_passive(3, 0.0); - - CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]; - CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - - if (config_container[ZONE_0]->GetMarker_All_Fluid_Load(iMarker) == YES) { - FlowLoad[0] = solver->GetVertexTractions(iMarker, iVertex, 0); - FlowLoad[1] = solver->GetVertexTractions(iMarker, iVertex, 1); - if (geometry->GetnDim() == 3) - FlowLoad[2] = solver->GetVertexTractions(iMarker, iVertex, 2); - else - FlowLoad[2] = 0.0; - } - else{ - FlowLoad[0] = 0.0; - FlowLoad[1] = 0.0; - FlowLoad[2] = 0.0; - } - - FlowLoad_passive[0] = SU2_TYPE::GetValue(FlowLoad[0]); - FlowLoad_passive[1] = SU2_TYPE::GetValue(FlowLoad[1]); - FlowLoad_passive[2] = SU2_TYPE::GetValue(FlowLoad[2]); - - return FlowLoad_passive; - -} - void CDriver::SetFlowLoad_Adjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, passivedouble val_AdjointY, passivedouble val_AdjointZ) { @@ -1199,58 +804,59 @@ void CDriver::SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned long iV } -vector CDriver::GetVertex_UndeformedCoord(unsigned short iMarker, unsigned long iVertex) { +//////////////////////////////////////////////////////////////////////////////// +/* Functions related to mesh deformation */ +//////////////////////////////////////////////////////////////////////////////// - unsigned long iPoint; - vector MeshCoord(3, 0.0); - vector MeshCoord_passive(3, 0.0); +void CDriver::SetMeshDisplacement(unsigned short iMarker, unsigned long iVertex, passivedouble DispX, passivedouble DispY, passivedouble DispZ) { - CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]; - CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); + unsigned long iPoint; + su2double MeshDispl[3] = {0.0,0.0,0.0}; - if (solver != nullptr) { - MeshCoord[0] = solver->GetNodes()->GetMesh_Coord(iPoint,0); - MeshCoord[1] = solver->GetNodes()->GetMesh_Coord(iPoint,1); - if (geometry->GetnDim() == 3) - MeshCoord[2] = solver->GetNodes()->GetMesh_Coord(iPoint,2); - else - MeshCoord[2] = 0.0; - } - else{ - MeshCoord[0] = 0.0; - MeshCoord[1] = 0.0; - MeshCoord[2] = 0.0; - } + MeshDispl[0] = DispX; + MeshDispl[1] = DispY; + MeshDispl[2] = DispZ; - MeshCoord_passive[0] = SU2_TYPE::GetValue(MeshCoord[0]); - MeshCoord_passive[1] = SU2_TYPE::GetValue(MeshCoord[1]); - MeshCoord_passive[2] = SU2_TYPE::GetValue(MeshCoord[2]); + iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); - return MeshCoord_passive; + solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->GetNodes()->SetBound_Disp(iPoint,MeshDispl); } -void CDriver::SetHeatSource_Position(passivedouble alpha, passivedouble pos_x, passivedouble pos_y, passivedouble pos_z){ - - CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][RAD_SOL]; - - config_container[ZONE_0]->SetHeatSource_Rot_Z(alpha); - config_container[ZONE_0]->SetHeatSource_Center(pos_x, pos_y, pos_z); +void CDriver::CommunicateMeshDisplacement(void) { - solver->SetVolumetricHeatSource(geometry_container[ZONE_0][INST_0][MESH_0], config_container[ZONE_0]); + solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->InitiateComms(geometry_container[ZONE_0][INST_0][MESH_0], + config_container[ZONE_0], MESH_DISPLACEMENTS); + solver_container[ZONE_0][INST_0][MESH_0][MESH_SOL]->CompleteComms(geometry_container[ZONE_0][INST_0][MESH_0], + config_container[ZONE_0], MESH_DISPLACEMENTS); } -void CDriver::SetInlet_Angle(unsigned short iMarker, passivedouble alpha){ +//////////////////////////////////////////////////////////////////////////////// +/* Functions related to flow loads */ +//////////////////////////////////////////////////////////////////////////////// - su2double alpha_rad = alpha * PI_NUMBER/180.0; +vector CDriver::GetFlowLoad(unsigned short iMarker, unsigned long iVertex) const { - unsigned long iVertex; + vector FlowLoad(3, 0.0); + vector FlowLoad_passive(3, 0.0); - for (iVertex = 0; iVertex < geometry_container[ZONE_0][INST_0][MESH_0]->nVertex[iMarker]; iVertex++){ - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 0, cos(alpha_rad)); - solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]->SetInlet_FlowDir(iMarker, iVertex, 1, sin(alpha_rad)); + CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][FLOW_SOL]; + CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; + + if (config_container[ZONE_0]->GetSolid_Wall(iMarker)) { + FlowLoad[0] = solver->GetVertexTractions(iMarker, iVertex, 0); + FlowLoad[1] = solver->GetVertexTractions(iMarker, iVertex, 1); + if (geometry->GetnDim() == 3) + FlowLoad[2] = solver->GetVertexTractions(iMarker, iVertex, 2); + else + FlowLoad[2] = 0.0; } + FlowLoad_passive[0] = SU2_TYPE::GetValue(FlowLoad[0]); + FlowLoad_passive[1] = SU2_TYPE::GetValue(FlowLoad[1]); + FlowLoad_passive[2] = SU2_TYPE::GetValue(FlowLoad[2]); + + return FlowLoad_passive; + } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index c54b3bb9706..66fe4d41ba5 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -936,7 +936,7 @@ void CFEASolver::Compute_StiffMatrix_NodalStressRes(CGeometry *geometry, CNumeri } -void CFEASolver::Compute_MassMatrix(CGeometry *geometry, CNumerics **numerics, const CConfig *config) { +void CFEASolver::Compute_MassMatrix(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { const bool topology_mode = config->GetTopology_Optimization(); const su2double simp_minstiff = config->GetSIMP_MinStiffness(); @@ -1021,7 +1021,7 @@ void CFEASolver::Compute_MassMatrix(CGeometry *geometry, CNumerics **numerics, c } -void CFEASolver::Compute_MassRes(CGeometry *geometry, CNumerics **numerics, const CConfig *config) { +void CFEASolver::Compute_MassRes(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { const bool topology_mode = config->GetTopology_Optimization(); const su2double simp_minstiff = config->GetSIMP_MinStiffness(); @@ -2183,7 +2183,7 @@ su2double CFEASolver::Compute_LoadCoefficient(su2double CurrentTime, su2double R } -void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CNumerics **numerics, const CConfig *config) { +void CFEASolver::ImplicitNewmark_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { const bool first_iter = (config->GetInnerIter() == 0); const bool dynamic = (config->GetTime_Domain()); @@ -2267,7 +2267,7 @@ void CFEASolver::ImplicitNewmark_Iteration(CGeometry *geometry, CNumerics **nume } -void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CConfig *config) { +void CFEASolver::ImplicitNewmark_Update(const CGeometry *geometry, const CConfig *config) { const bool dynamic = (config->GetTime_Domain()); @@ -2314,7 +2314,7 @@ void CFEASolver::ImplicitNewmark_Update(CGeometry *geometry, CConfig *config) { } // end SU2_OMP_PARALLEL } -void CFEASolver::ImplicitNewmark_Relaxation(CGeometry *geometry, CConfig *config) { +void CFEASolver::ImplicitNewmark_Relaxation(const CGeometry *geometry, const CConfig *config) { const bool dynamic = (config->GetTime_Domain()); @@ -2362,7 +2362,7 @@ void CFEASolver::ImplicitNewmark_Relaxation(CGeometry *geometry, CConfig *config } -void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CNumerics **numerics, const CConfig *config) { +void CFEASolver::GeneralizedAlpha_Iteration(const CGeometry *geometry, CNumerics **numerics, const CConfig *config) { const bool first_iter = (config->GetInnerIter() == 0); const bool dynamic = (config->GetTime_Domain()); @@ -2470,7 +2470,7 @@ void CFEASolver::GeneralizedAlpha_Iteration(CGeometry *geometry, CNumerics **num } -void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CConfig *config) { +void CFEASolver::GeneralizedAlpha_UpdateDisp(const CGeometry *geometry, const CConfig *config) { /*--- Update displacement components of the solution. ---*/ @@ -2481,7 +2481,7 @@ void CFEASolver::GeneralizedAlpha_UpdateDisp(CGeometry *geometry, CConfig *confi } -void CFEASolver::GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CConfig *config) { +void CFEASolver::GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, const CConfig *config) { const su2double alpha_f = config->Get_Int_Coeffs(2); const su2double alpha_m = config->Get_Int_Coeffs(3); @@ -2535,7 +2535,7 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(CGeometry *geometry, CConfig *c } -void CFEASolver::GeneralizedAlpha_UpdateLoads(CGeometry *geometry, const CConfig *config) { +void CFEASolver::GeneralizedAlpha_UpdateLoads(const CGeometry *geometry, const CConfig *config) { /*--- Set the load conditions of the time step n+1 as the load conditions for time step n ---*/ nodes->Set_SurfaceLoad_Res_n(); diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index b2ceac739d4..07748237afd 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -298,7 +298,7 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { unsigned long nVertex_SolidWall = 0; for(auto iMarker=0u; iMarkerGetnMarker_All(); ++iMarker) { - if(config->GetSolid_Wall(iMarker)) { + if(config->GetSolid_Wall(iMarker) && !config->GetMarker_All_Deform_Mesh_Sym_Plane(iMarker)) { nVertex_SolidWall += geometry->GetnVertex(iMarker); } } @@ -315,7 +315,7 @@ void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { for (unsigned long iMarker=0, ii=0, jj=0; iMarkerGetnMarker_All(); ++iMarker) { - if (!config->GetSolid_Wall(iMarker)) continue; + if (!config->GetSolid_Wall(iMarker) || config->GetMarker_All_Deform_Mesh_Sym_Plane(iMarker)) continue; for (auto iVertex=0u; iVertexGetnVertex(iMarker); ++iVertex) { auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index f608da29138..a29ab35b1fe 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -119,10 +119,6 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { /*--- Flags for the dynamic grid (rigid movement or unsteady deformation). ---*/ dynamic_grid = false; - /*--- Container to store the vertex tractions. ---*/ - VertexTraction = nullptr; - VertexTractionAdjoint = nullptr; - /*--- Auxiliary data needed for CFL adaption. ---*/ Old_Func = 0; @@ -137,7 +133,6 @@ CSolver::CSolver(bool mesh_deform_mode) : System(mesh_deform_mode) { CSolver::~CSolver(void) { unsigned short iVar; - unsigned long iMarker, iVertex; /*--- Public variables, may be accessible outside ---*/ @@ -222,24 +217,6 @@ CSolver::~CSolver(void) { delete [] Jacobian_jj; } - if (VertexTraction != nullptr) { - for (iMarker = 0; iMarker < nMarker; iMarker++) { - for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) - delete [] VertexTraction[iMarker][iVertex]; - delete [] VertexTraction[iMarker]; - } - delete [] VertexTraction; - } - - if (VertexTractionAdjoint != nullptr) { - for (iMarker = 0; iMarker < nMarker; iMarker++) { - for (iVertex = 0; iVertex < nVertex[iMarker]; iVertex++) - delete [] VertexTractionAdjoint[iMarker][iVertex]; - delete [] VertexTractionAdjoint[iMarker]; - } - delete [] VertexTractionAdjoint; - } - delete [] nVertex; delete [] Restart_Vars; @@ -4014,24 +3991,17 @@ void CSolver::LoadInletProfile(CGeometry **geometry, } -void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ +void CSolver::ComputeVertexTractions(CGeometry *geometry, const CConfig *config){ /*--- Compute the constant factor to dimensionalize pressure and shear stress. ---*/ - su2double *Velocity_ND, *Velocity_Real; + const su2double *Velocity_ND, *Velocity_Real; su2double Density_ND, Density_Real, Velocity2_Real, Velocity2_ND; su2double factor; - unsigned short iDim, jDim; + unsigned short iDim; // Check whether the problem is viscous - bool viscous_flow = ((config->GetKind_Solver() == NAVIER_STOKES) || - (config->GetKind_Solver() == INC_NAVIER_STOKES) || - (config->GetKind_Solver() == RANS) || - (config->GetKind_Solver() == INC_RANS) || - (config->GetKind_Solver() == DISC_ADJ_NAVIER_STOKES) || - (config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES) || - (config->GetKind_Solver() == DISC_ADJ_INC_RANS) || - (config->GetKind_Solver() == DISC_ADJ_RANS)); + bool viscous_flow = config->GetViscous(); // Parameters for the calculations su2double Pn = 0.0; @@ -4039,7 +4009,7 @@ void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ unsigned short iMarker; unsigned long iVertex, iPoint; - su2double const *iNormal; + const su2double* iNormal; su2double Pressure_Inf = config->GetPressure_FreeStreamND(); @@ -4049,59 +4019,52 @@ void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ Velocity_ND = config->GetVelocity_FreeStreamND(); Density_ND = config->GetDensity_FreeStreamND(); - Velocity2_Real = 0.0; - Velocity2_ND = 0.0; - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - Velocity2_Real += Velocity_Real[iDim]*Velocity_Real[iDim]; - Velocity2_ND += Velocity_ND[iDim]*Velocity_ND[iDim]; - } + Velocity2_Real = GeometryToolbox::SquaredNorm(nDim, Velocity_Real); + Velocity2_ND = GeometryToolbox::SquaredNorm(nDim, Velocity_ND); factor = Density_Real * Velocity2_Real / ( Density_ND * Velocity2_ND ); for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - /*--- If this is defined as an interface marker ---*/ - if (config->GetMarker_All_Fluid_Load(iMarker) == YES) { + /*--- If this is defined as a wall ---*/ + if (!config->GetSolid_Wall(iMarker)) continue; - // Loop over the vertices - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + // Loop over the vertices + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - // Recover the point index - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - // Get the normal at the vertex: this normal goes inside the fluid domain. - iNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + // Recover the point index + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + // Get the normal at the vertex: this normal goes inside the fluid domain. + iNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - if (geometry->nodes->GetDomain(iPoint)) { + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + if (geometry->nodes->GetDomain(iPoint)) { - // Retrieve the values of pressure - Pn = base_nodes->GetPressure(iPoint); + // Retrieve the values of pressure + Pn = base_nodes->GetPressure(iPoint); - // Calculate tn in the fluid nodes for the inviscid term --> Units of force (non-dimensional). - for (iDim = 0; iDim < nDim; iDim++) - auxForce[iDim] = -(Pn-Pressure_Inf)*iNormal[iDim]; + // Calculate tn in the fluid nodes for the inviscid term --> Units of force (non-dimensional). + for (iDim = 0; iDim < nDim; iDim++) + auxForce[iDim] = -(Pn-Pressure_Inf)*iNormal[iDim]; - // Calculate tn in the fluid nodes for the viscous term - if (viscous_flow) { - su2double Viscosity = base_nodes->GetLaminarViscosity(iPoint); - su2double Tau[3][3]; - CNumerics::ComputeStressTensor(nDim, Tau, base_nodes->GetGradient_Primitive(iPoint)+1, Viscosity); - for (iDim = 0; iDim < nDim; iDim++) { - for (jDim = 0 ; jDim < nDim; jDim++) { - auxForce[iDim] += Tau[iDim][jDim]*iNormal[jDim]; - } - } - } - - // Redimensionalize the forces + // Calculate tn in the fluid nodes for the viscous term + if (viscous_flow) { + su2double Viscosity = base_nodes->GetLaminarViscosity(iPoint); + su2double Tau[3][3]; + CNumerics::ComputeStressTensor(nDim, Tau, base_nodes->GetGradient_Primitive(iPoint)+1, Viscosity); for (iDim = 0; iDim < nDim; iDim++) { - VertexTraction[iMarker][iVertex][iDim] = factor * auxForce[iDim]; + auxForce[iDim] += GeometryToolbox::DotProduct(nDim, Tau[iDim], iNormal); } } - else{ - for (iDim = 0; iDim < nDim; iDim++) { - VertexTraction[iMarker][iVertex][iDim] = 0.0; - } + + // Redimensionalize the forces + for (iDim = 0; iDim < nDim; iDim++) { + VertexTraction[iMarker][iVertex][iDim] = factor * auxForce[iDim]; + } + } + else{ + for (iDim = 0; iDim < nDim; iDim++) { + VertexTraction[iMarker][iVertex][iDim] = 0.0; } } } @@ -4109,7 +4072,7 @@ void CSolver::ComputeVertexTractions(CGeometry *geometry, CConfig *config){ } -void CSolver::RegisterVertexTractions(CGeometry *geometry, CConfig *config){ +void CSolver::RegisterVertexTractions(CGeometry *geometry, const CConfig *config){ unsigned short iMarker, iDim; unsigned long iVertex, iPoint; @@ -4117,31 +4080,28 @@ void CSolver::RegisterVertexTractions(CGeometry *geometry, CConfig *config){ /*--- Loop over all the markers ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - /*--- If this is defined as an interface marker ---*/ - if (config->GetMarker_All_Fluid_Load(iMarker) == YES) { + /*--- If this is defined as a wall ---*/ + if (!config->GetSolid_Wall(iMarker)) continue; - /*--- Loop over the vertices ---*/ - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { + /*--- Loop over the vertices ---*/ + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - /*--- Recover the point index ---*/ - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + /*--- Recover the point index ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - if (geometry->nodes->GetDomain(iPoint)) { - - /*--- Register the vertex traction as output ---*/ - for (iDim = 0; iDim < nDim; iDim++) { - AD::RegisterOutput(VertexTraction[iMarker][iVertex][iDim]); - } + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + if (!geometry->nodes->GetDomain(iPoint)) continue; - } + /*--- Register the vertex traction as output ---*/ + for (iDim = 0; iDim < nDim; iDim++) { + AD::RegisterOutput(VertexTraction[iMarker][iVertex][iDim]); } } } } -void CSolver::SetVertexTractionsAdjoint(CGeometry *geometry, CConfig *config){ +void CSolver::SetVertexTractionsAdjoint(CGeometry *geometry, const CConfig *config){ unsigned short iMarker, iDim; unsigned long iVertex, iPoint; @@ -4149,26 +4109,22 @@ void CSolver::SetVertexTractionsAdjoint(CGeometry *geometry, CConfig *config){ /*--- Loop over all the markers ---*/ for (iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - /*--- If this is defined as an interface marker ---*/ - if (config->GetMarker_All_Fluid_Load(iMarker) == YES) { - - /*--- Loop over the vertices ---*/ - for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - - /*--- Recover the point index ---*/ - iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + /*--- If this is defined as a wall ---*/ + if (!config->GetSolid_Wall(iMarker)) continue; - /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - if (geometry->nodes->GetDomain(iPoint)) { + /*--- Loop over the vertices ---*/ + for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { - /*--- Set the adjoint of the vertex traction from the value received ---*/ - for (iDim = 0; iDim < nDim; iDim++) { + /*--- Recover the point index ---*/ + iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); - SU2_TYPE::SetDerivative(VertexTraction[iMarker][iVertex][iDim], - SU2_TYPE::GetValue(VertexTractionAdjoint[iMarker][iVertex][iDim])); - } + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ + if (!geometry->nodes->GetDomain(iPoint)) continue; - } + /*--- Set the adjoint of the vertex traction from the value received ---*/ + for (iDim = 0; iDim < nDim; iDim++) { + SU2_TYPE::SetDerivative(VertexTraction[iMarker][iVertex][iDim], + SU2_TYPE::GetValue(VertexTractionAdjoint[iMarker][iVertex][iDim])); } } } diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 0a560888d9f..b3884d2c4b1 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -322,6 +322,8 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container, CConfig *config, unsigned short iMesh) { + + bool axisymmetric = config->GetAxisymmetric(); CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes(); @@ -372,6 +374,11 @@ void CTurbSSTSolver::Source_Residual(CGeometry *geometry, CSolver **solver_conta numerics->SetCrossDiff(nodes->GetCrossDiff(iPoint),0.0); + if (axisymmetric){ + /*--- Set y coordinate ---*/ + numerics->SetCoord(geometry->nodes->GetCoord(iPoint), geometry->nodes->GetCoord(iPoint)); + } + /*--- Compute the source term ---*/ auto residual = numerics->ComputeResidual(config); diff --git a/SU2_PY/FSI_tools/FSIInterface.py b/SU2_PY/FSI_tools/FSIInterface.py index aa542398014..9fe034d1e1f 100644 --- a/SU2_PY/FSI_tools/FSIInterface.py +++ b/SU2_PY/FSI_tools/FSIInterface.py @@ -565,10 +565,8 @@ def interfaceMapping(self,FluidSolver, SolidSolver, FSI_config): # Note that the fluid solver is separated in more processors outside the python script # thus when, from a core, we request for the vertices on the interface, we only obtain # those in that node - GlobalIndex = FluidSolver.GetVertexGlobalIndex(self.fluidInterfaceIdentifier, iVertex) #TODO obtain here the undeformed mesh - posx = FluidSolver.GetVertexCoordX(self.fluidInterfaceIdentifier, iVertex) - posy = FluidSolver.GetVertexCoordY(self.fluidInterfaceIdentifier, iVertex) - posz = FluidSolver.GetVertexCoordZ(self.fluidInterfaceIdentifier, iVertex) + GlobalIndex = FluidSolver.GetVertexGlobalIndex(self.fluidInterfaceIdentifier, iVertex) + posx, posy, posz = FluidSolver.GetInitialMeshCoord(self.fluidInterfaceIdentifier, iVertex) if GlobalIndex not in self.FluidHaloNodeList[myid].keys(): fluidIndexing_temp[GlobalIndex] = self.__getGlobalIndex('fluid', myid, localIndex) self.localFluidInterface_array_X_init[localIndex] = posx @@ -1394,9 +1392,7 @@ def interpolateFluidLoadsOnSolidMesh(self, FSI_config): del sendBuff_X del sendBuff_Y del sendBuff_Z - del self.solidLoads_array_X_recon - del self.solidLoads_array_Y_recon - del self.solidLoads_array_Z_recon + self.comm.barrier() else: self.localSolidLoads_array_X = self.solidLoads_array_X.getArray().copy() self.localSolidLoads_array_Y = self.solidLoads_array_Y.getArray().copy() @@ -2094,7 +2090,7 @@ def SteadyFSI(self, FSI_config,FluidSolver, SolidSolver): # mesh pushing back the solution to avoid spurious velocities, as the velocity is not computed at all self.MPIPrint('\nPerforming static mesh deformation...\n') FluidSolver.Preprocess(0)# This will attempt to always set the initial condition, but there is a flag on the unsteady computation that will avoid it - FluidSolver.Run() #TODO check how the preprocess work if fsi is false + FluidSolver.Run() FluidSolver.Postprocess() FluidSolver.Monitor(0) #This is actually not needed, it only saves the fact that the fluid solver converged innerly or reached max iterations FluidSolver.Output(0) diff --git a/SU2_PY/SU2_Nastran/pysu2_nastran.py b/SU2_PY/SU2_Nastran/pysu2_nastran.py index cf28f42a5eb..aa83f44c5dd 100644 --- a/SU2_PY/SU2_Nastran/pysu2_nastran.py +++ b/SU2_PY/SU2_Nastran/pysu2_nastran.py @@ -41,21 +41,26 @@ # Config class # ---------------------------------------------------------------------- -class ImposedMotionFunction: +class ImposedMotionClass: + + def __init__(self,time0,typeOfMotion,parameters,mode): - def __init__(self,time0,tipo,parameters): self.time0 = time0 - self.tipo = tipo - if self.tipo == "SINUSOIDAL": - self.bias = parameters[0] - self.amplitude = parameters[1] - self.frequency = parameters[2] - - elif self.tipo == "BLENDED_STEP": - self.kmax = parameters[0] - self.vinf = parameters[1] - self.lref = parameters[2] - self.amplitude = parameters[3] + self.typeOfMotion = typeOfMotion + self.mode = mode + + if self.typeOfMotion == "SINUSOIDAL": + self.bias = parameters["BIAS"] + self.amplitude = parameters["AMPLITUDE"] + self.frequency = parameters["FREQUENCY"] + self.timeStart = parameters["TIME_0"] + + elif self.typeOfMotion == "BLENDED_STEP": + self.kmax = parameters["K_MAX"] + self.vinf = parameters["V_INF"] + self.lref = parameters["L_REF"] + self.amplitude = parameters["AMPLITUDE"] + self.timeStart = parameters["TIME_0"] self.tmax = 2*pi/self.kmax*self.lref/self.vinf self.omega0 = 1/2*self.kmax @@ -64,35 +69,41 @@ def __init__(self,time0,tipo,parameters): def GetDispl(self,time): - time = time - self.time0 - if self.tipo == "SINUSOIDAL": + time = time - self.time0 - self.timeStart + if self.typeOfMotion == "SINUSOIDAL": return self.bias+self.amplitude*sin(2*pi*self.frequency*time) - if self.tipo == "BLENDED_STEP": - if time < self.tmax: + if self.typeOfMotion == "BLENDED_STEP": + if time < 0: + return 0.0 + elif time < self.tmax: return self.amplitude/2.0*(1.0-cos(self.omega0*time*self.vinf/self.lref)) return self.amplitude def GetVel(self,time): - time = time - self.time0 + time = time - self.time0 - self.timeStart - if self.tipo == "SINUSOIDAL": + if self.typeOfMotion == "SINUSOIDAL": return self.amplitude*cos(2*pi*self.frequency*time)*2*pi*self.frequency - if self.tipo == "BLENDED_STEP": - if time < self.tmax: + if self.typeOfMotion == "BLENDED_STEP": + if time < 0: + return 0.0 + elif time < self.tmax: return self.amplitude/2.0*sin(self.omega0*time*self.vinf/self.lref)*(self.omega0*self.vinf/self.lref) return 0.0 def GetAcc(self,time): - time = time - self.time0 + time = time - self.time0 - self.timeStart - if self.tipo == "SINUSOIDAL": + if self.typeOfMotion == "SINUSOIDAL": return -self.amplitude*sin(2*pi*self.frequency*time)*(2*pi*self.frequency)**2 - if self.tipo == "BLENDED_STEP": - if time < self.tmax: + if self.typeOfMotion == "BLENDED_STEP": + if time < 0: + return 0.0 + elif time < self.tmax: return self.amplitude/2.0*cos(self.omega0*time*self.vinf/self.lref)*(self.omega0*self.vinf/self.lref)**2 return 0.0 @@ -281,7 +292,7 @@ def __init__(self, config_fileName, ImposedMotion): self.markers = {} self.refsystems = [] self.ImposedMotionToSet = True - self.ImposedMotionFunction = {} + self.ImposedMotionFunction = [] print("\n") print(" Reading the mesh ".center(80,"-")) @@ -725,14 +736,17 @@ def __temporalIteration(self,time): This method integrates in time the solution. """ + self.__reset(self.q) + self.__reset(self.qdot) + self.__reset(self.qddot) + self.__reset(self.a) + if not self.ImposedMotion: eps = 1e-6 self.__SetLoads() # Prediction step - self.__reset(self.qddot) - self.__reset(self.a) self.a += (self.alpha_f)/(1-self.alpha_m)*self.qddot_n self.a -= (self.alpha_m)/(1-self.alpha_m)*self.a_n @@ -760,14 +774,20 @@ def __temporalIteration(self,time): self.a += (1-self.alpha_f)/(1-self.alpha_m)*self.qddot else: if self.ImposedMotionToSet: - for imode in self.Config["IMPOSED_MODES"].keys(): - self.ImposedMotionFunction[imode] = ImposedMotionFunction(time,self.Config["IMPOSED_MODES"][imode],self.Config["IMPOSED_PARAMETERS"][imode]) - self.ImposedMotionToSet = False - for imode in self.Config["IMPOSED_MODES"].keys(): - self.q[imode] = self.ImposedMotionFunction[imode].GetDispl(time) - self.qdot[imode] = self.ImposedMotionFunction[imode].GetVel(time) - self.qddot[imode] = self.ImposedMotionFunction[imode].GetAcc(time) - self.a = np.copy(self.qddot) + iImposedFunc = 0 + for imode in self.Config["IMPOSED_MODES"].keys(): + for isuperposed in range(len(self.Config["IMPOSED_MODES"][imode])): + typeOfMotion = self.Config["IMPOSED_MODES"][imode][isuperposed] + parameters = self.Config["IMPOSED_PARAMETERS"][imode][isuperposed] + self.ImposedMotionFunction.append(ImposedMotionClass(time, typeOfMotion, parameters, imode)) + iImposedFunc += 1 + self.ImposedMotionToSet = False + for iImposedFunc in range(len(self.ImposedMotionFunction)): + imode = self.ImposedMotionFunction[iImposedFunc].mode + self.q[imode] += self.ImposedMotionFunction[iImposedFunc].GetDispl(time) + self.qdot[imode] += self.ImposedMotionFunction[iImposedFunc].GetVel(time) + self.qddot[imode] += self.ImposedMotionFunction[iImposedFunc].GetAcc(time) + self.a = np.copy(self.qddot) def __SetLoads(self): diff --git a/TestCases/axisymmetric_rans/air_nozzle/air_nozzle.cfg b/TestCases/axisymmetric_rans/air_nozzle/air_nozzle.cfg new file mode 100644 index 00000000000..f40f1775b49 --- /dev/null +++ b/TestCases/axisymmetric_rans/air_nozzle/air_nozzle.cfg @@ -0,0 +1,214 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % +% SU2 configuration file % +% Case description: Axisymmetric supersonic converging-diverging air nozzle % +% Author: Florian Dittmann % +% Date: 2021.12.02 % +% File Version 7.10 "Blackbird" % +% % +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% +% +% Physical governing equations (EULER, NAVIER_STOKES, +% FEM_EULER, FEM_NAVIER_STOKES, FEM_RANS, FEM_LES, +% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY, +% POISSON_EQUATION) +SOLVER= RANS +% +% Specify turbulence model (NONE, SA, SA_NEG, SST, SA_E, SA_COMP, SA_E_COMP) +KIND_TURB_MODEL= SST +% +% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT, DISCRETE_ADJOINT) +MATH_PROBLEM= DIRECT +% +% Restart solution (NO, YES) +RESTART_SOL= YES +% +% System of measurements (SI, US) +% International system of units (SI): ( meters, kilograms, Kelvins, +% Newtons = kg m/s^2, Pascals = N/m^2, +% Density = kg/m^3, Speed = m/s, +% Equiv. Area = m^2 ) +% United States customary units (US): ( inches, slug, Rankines, lbf = slug ft/s^2, +% psf = lbf/ft^2, Density = slug/ft^3, +% Speed = ft/s, Equiv. Area = ft^2 ) +SYSTEM_MEASUREMENTS= SI +% +AXISYMMETRIC= YES +% +% -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% +% +% Mach number (non-dimensional, based on the free-stream values) +MACH_NUMBER= 1E-9 +% +% Angle of attack (degrees, only for compressible flows) +AOA= 0.0 +% +% Side-slip angle (degrees, only for compressible flows) +SIDESLIP_ANGLE= 0.0 +% +% Init option to choose between Reynolds (default) or thermodynamics quantities +% for initializing the solution (REYNOLDS, TD_CONDITIONS) +INIT_OPTION= TD_CONDITIONS +% +% Free-stream option to choose between density and temperature (default) for +% initializing the solution (TEMPERATURE_FS, DENSITY_FS) +FREESTREAM_OPTION= TEMPERATURE_FS +% +% Free-stream pressure (101325.0 N/m^2, 2116.216 psf by default) +FREESTREAM_PRESSURE= 1400000 +% +% Free-stream temperature (288.15 K, 518.67 R by default) +FREESTREAM_TEMPERATURE= 373.15 +% +% Compressible flow non-dimensionalization (DIMENSIONAL, FREESTREAM_PRESS_EQ_ONE, +% FREESTREAM_VEL_EQ_MACH, FREESTREAM_VEL_EQ_ONE) +REF_DIMENSIONALIZATION= DIMENSIONAL + +% ---- IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS -------% +% +% Fluid model (STANDARD_AIR, IDEAL_GAS, VW_GAS, PR_GAS, +% CONSTANT_DENSITY, INC_IDEAL_GAS, INC_IDEAL_GAS_POLY) +FLUID_MODEL= STANDARD_AIR + +% --------------------------- VISCOSITY MODEL ---------------------------------% +% +% Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY, POLYNOMIAL_VISCOSITY). +VISCOSITY_MODEL= CONSTANT_VISCOSITY +% +% Molecular Viscosity that would be constant (1.716E-5 by default) +MU_CONSTANT= 1.716E-5 + +% --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% +% +% Laminar Conductivity model (CONSTANT_CONDUCTIVITY, CONSTANT_PRANDTL, +% POLYNOMIAL_CONDUCTIVITY). +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +% +% Laminar Prandtl number (0.72 (air), only for CONSTANT_PRANDTL) +PRANDTL_LAM= 0.72 +% +% Turbulent Prandtl number (0.9 (air) by default) +PRANDTL_TURB= 0.90 + +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +% Navier-Stokes (no-slip), constant heat flux wall marker(s) (NONE = no marker) +% Format: ( marker name, constant heat flux (J/m^2), ... ) +MARKER_HEATFLUX= ( WALL, 0.0 ) +% +% Symmetry boundary marker(s) (NONE = no marker) +MARKER_SYM= ( SYMMETRY ) +% +% Riemann boundary marker(s) (NONE = no marker) +% Format: (marker, data kind flag, list of data) +MARKER_RIEMANN= ( INFLOW, TOTAL_CONDITIONS_PT, 1400000.0, 373.15, 1.0, 0.0, 0.0, OUTFLOW, STATIC_PRESSURE, 100000.0, 0.0, 0.0, 0.0, 0.0 ) + +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +% Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) +NUM_METHOD_GRAD= GREEN_GAUSS +% +% CFL number (initial value for the adaptive CFL number) +CFL_NUMBER= 1000.0 +% +% Adaptive CFL number (NO, YES) +CFL_ADAPT= NO +% +% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, +% CFL max value ) +CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1000.0 ) +% +% Maximum Delta Time in local time stepping simulations +MAX_DELTA_TIME= 1E6 + +% ----------- SLOPE LIMITER AND DISSIPATION SENSOR DEFINITION -----------------% +% +% Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. +% Required for 2nd order upwind schemes (NO, YES) +MUSCL_FLOW= YES +% +% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, +% BARTH_JESPERSEN, VAN_ALBADA_EDGE) +SLOPE_LIMITER_FLOW= NONE + +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +% Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER_JACOBI, +% SMOOTHER_ILU, SMOOTHER_LUSGS, +% SMOOTHER_LINELET) +LINEAR_SOLVER= FGMRES +% +% Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) +LINEAR_SOLVER_PREC= ILU +% +% Linear solver ILU preconditioner fill-in level (0 by default) +LINEAR_SOLVER_ILU_FILL_IN= 0 +% +% Minimum error of the linear solver for implicit formulations +LINEAR_SOLVER_ERROR= 0.01 +% +% Max number of iterations of the linear solver for the implicit formulation +LINEAR_SOLVER_ITER= 10 + +% -------------------------- MULTIGRID PARAMETERS -----------------------------% +% +% Multi-grid levels (0 = no multi-grid) +MGLEVEL= 0 + +% -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% +% +% Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, AUSMPLUSUP, AUSMPLUSUP2, HLLC, +% TURKEL_PREC, MSW, FDS) +CONV_NUM_METHOD_FLOW= ROE +% +% Entropy fix coefficient (0.0 implies no entropy fixing, 1.0 implies scalar +% artificial dissipation) +ENTROPY_FIX_COEFF= 0.1 +% +% Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% + +% -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% +% +% Convective numerical method (SCALAR_UPWIND) +CONV_NUM_METHOD_TURB= SCALAR_UPWIND +% +% Time discretization (EULER_IMPLICIT) +TIME_DISCRE_TURB= EULER_IMPLICIT +% +% Reduction factor of the CFL coefficient in the turbulence problem +CFL_REDUCTION_TURB= 1.0 + +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +% Number of total iterations +ITER= 1000 +% +% Convergence criteria (CAUCHY, RESIDUAL) +CONV_CRITERIA= RESIDUAL +% +% Min value of the residual (log10 of the residual) +CONV_RESIDUAL_MINVAL= -12 +% +% Start convergence criteria at iteration number +CONV_STARTITER= 10 + +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +% Mesh input file +MESH_FILENAME= nozzle.su2 +% +% Mesh input file format (SU2, CGNS) +MESH_FORMAT= SU2 +% +% Restart flow input file +SOLUTION_FILENAME= solution_flow.dat +% +% Writing solution file frequency +OUTPUT_WRT_FREQ= 1000 +% +% Screen output +SCREEN_OUTPUT= (INNER_ITER, RMS_DENSITY, RMS_ENERGY, RMS_TKE, RMS_DISSIPATION) diff --git a/TestCases/cont_adj_euler/naca0012/inv_NACA0012.cfg b/TestCases/cont_adj_euler/naca0012/inv_NACA0012.cfg index e519891a2a1..fa9cadd19f2 100644 --- a/TestCases/cont_adj_euler/naca0012/inv_NACA0012.cfg +++ b/TestCases/cont_adj_euler/naca0012/inv_NACA0012.cfg @@ -112,7 +112,7 @@ LINEAR_SOLVER_ERROR= 1E-6 % Max number of iterations of the linear solver for the implicit formulation LINEAR_SOLVER_ITER= 5 % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % -------------------------- MULTIGRID PARAMETERS -----------------------------% diff --git a/TestCases/cont_adj_euler/naca0012/inv_NACA0012_FD.cfg b/TestCases/cont_adj_euler/naca0012/inv_NACA0012_FD.cfg index d5e37789b0c..81a4e80be47 100644 --- a/TestCases/cont_adj_euler/naca0012/inv_NACA0012_FD.cfg +++ b/TestCases/cont_adj_euler/naca0012/inv_NACA0012_FD.cfg @@ -110,7 +110,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % -------------------------- MULTIGRID PARAMETERS -----------------------------% diff --git a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg index 88ba1cf853b..7b90ced501c 100644 --- a/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg +++ b/TestCases/cont_adj_euler/wedge/inv_wedge_ROE_multiobj.cfg @@ -112,7 +112,7 @@ LINEAR_SOLVER_ITER= 5 % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 diff --git a/TestCases/cont_adj_rans/oneram6/turb_ONERAM6.cfg b/TestCases/cont_adj_rans/oneram6/turb_ONERAM6.cfg index 5c7f5c8dcdd..ebfc62d342c 100644 --- a/TestCases/cont_adj_rans/oneram6/turb_ONERAM6.cfg +++ b/TestCases/cont_adj_rans/oneram6/turb_ONERAM6.cfg @@ -11,12 +11,7 @@ % ------------- DIRECT, ADJOINT, AND LINEARIZED PROBLEM DEFINITION ------------% % -% Physical governing equations (EULER, NAVIER_STOKES, -% PLASMA_EULER, PLASMA_NAVIER_STOKES, -% FREE_SURFACE_EULER, FREE_SURFACE_NAVIER_STOKES, -% FLUID_STRUCTURE_EULER, FLUID_STRUCTURE_NAVIER_STOKES, -% AEROACOUSTIC_EULER, AEROACOUSTIC_NAVIER_STOKES, -% WAVE_EQUATION, HEAT_EQUATION, FEM_ELASTICITY) +% Physical governing equations (EULER, NAVIER_STOKES, etc.) SOLVER= NAVIER_STOKES % % Specify turbulence model (NONE, SA, SA_NEG, SST) diff --git a/TestCases/coupled_cht/comp_2d/flow_cylinder.cfg b/TestCases/coupled_cht/comp_2d/flow_cylinder.cfg index c15f371c0d4..bbc1ffd9c49 100644 --- a/TestCases/coupled_cht/comp_2d/flow_cylinder.cfg +++ b/TestCases/coupled_cht/comp_2d/flow_cylinder.cfg @@ -97,7 +97,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/comp_2d/solid_cylinder1.cfg b/TestCases/coupled_cht/comp_2d/solid_cylinder1.cfg index 06325af0a5e..9f8ec43f71e 100644 --- a/TestCases/coupled_cht/comp_2d/solid_cylinder1.cfg +++ b/TestCases/coupled_cht/comp_2d/solid_cylinder1.cfg @@ -89,7 +89,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/comp_2d/solid_cylinder2.cfg b/TestCases/coupled_cht/comp_2d/solid_cylinder2.cfg index 05756d60471..bca1647b7df 100644 --- a/TestCases/coupled_cht/comp_2d/solid_cylinder2.cfg +++ b/TestCases/coupled_cht/comp_2d/solid_cylinder2.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/comp_2d/solid_cylinder3.cfg b/TestCases/coupled_cht/comp_2d/solid_cylinder3.cfg index 22ee243c51b..e834d1134be 100644 --- a/TestCases/coupled_cht/comp_2d/solid_cylinder3.cfg +++ b/TestCases/coupled_cht/comp_2d/solid_cylinder3.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg index aba99dce051..c4c66039fd9 100644 --- a/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/flow_cylinder.cfg @@ -151,7 +151,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg index 5e45bd1daad..feccb6c2413 100644 --- a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder1.cfg @@ -89,7 +89,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg index 6dcccea2606..b9a20fa95db 100644 --- a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder2.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg index 47d064accbc..f7576060b5d 100644 --- a/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg +++ b/TestCases/coupled_cht/disc_adj_incomp_2d/solid_cylinder3.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg b/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg index c587d6907b3..072923c45e3 100644 --- a/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg +++ b/TestCases/coupled_cht/incomp_2d/flow_cylinder.cfg @@ -148,7 +148,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg index df303ab245e..ea93e593514 100644 --- a/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder1.cfg @@ -89,7 +89,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg index 3f2a7a5d5f6..4b296aedbc5 100644 --- a/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder2.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg b/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg index 3e33cbe1a98..201c4f681e7 100644 --- a/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg +++ b/TestCases/coupled_cht/incomp_2d/solid_cylinder3.cfg @@ -98,7 +98,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d_unsteady/flow_cylinder.cfg b/TestCases/coupled_cht/incomp_2d_unsteady/flow_cylinder.cfg index 75f4590a481..a12beaa28d9 100644 --- a/TestCases/coupled_cht/incomp_2d_unsteady/flow_cylinder.cfg +++ b/TestCases/coupled_cht/incomp_2d_unsteady/flow_cylinder.cfg @@ -135,7 +135,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder1.cfg b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder1.cfg index c424aca3245..56f56418c63 100644 --- a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder1.cfg +++ b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder1.cfg @@ -76,7 +76,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder2.cfg b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder2.cfg index 379a6eaf380..1013307d8f4 100644 --- a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder2.cfg +++ b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder2.cfg @@ -76,7 +76,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder3.cfg b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder3.cfg index 439aa0f77e4..2f5cdfd50cd 100644 --- a/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder3.cfg +++ b/TestCases/coupled_cht/incomp_2d_unsteady/solid_cylinder3.cfg @@ -76,7 +76,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg b/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg index 501f16e9429..d201209a652 100644 --- a/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg +++ b/TestCases/disc_adj_euler/arina2k/Arina2KRS.cfg @@ -288,7 +288,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= LU_SGS % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg b/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg index fe1b637bbba..0ca25328f85 100644 --- a/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg +++ b/TestCases/disc_adj_euler/cylinder3D/inv_cylinder3D.cfg @@ -206,7 +206,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg b/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg index e54a8b04703..69485bc41d9 100644 --- a/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg +++ b/TestCases/disc_adj_incomp_navierstokes/cylinder/heated_cylinder.cfg @@ -212,7 +212,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sa.cfg b/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sa.cfg index 3ebb6e30fbc..b6591fef723 100755 --- a/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sa.cfg +++ b/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sa.cfg @@ -131,7 +131,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sst.cfg b/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sst.cfg index 1b7577fe53e..d615f549ff2 100755 --- a/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sst.cfg +++ b/TestCases/disc_adj_incomp_rans/naca0012/turb_naca0012_sst.cfg @@ -131,7 +131,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/gust/inv_gust_NACA0012.cfg b/TestCases/gust/inv_gust_NACA0012.cfg index 61950875cf1..c3d44d24692 100644 --- a/TestCases/gust/inv_gust_NACA0012.cfg +++ b/TestCases/gust/inv_gust_NACA0012.cfg @@ -72,7 +72,7 @@ INNER_ITER= 100 % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% % % Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, ELASTICITY, +% MOVING_WALL, AEROELASTIC, ELASTICITY, % EXTERNAL, AEROELASTIC_RIGID_MOTION) GRID_MOVEMENT= GUST % diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index f1ea011f4f5..d69473c646f 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -210,6 +210,18 @@ def main(): propeller.test_vals = [-3.389576, -8.409529, 0.000048, 0.056329] test_list.append(propeller) + ####################################### + ### Axisymmetric Compressible RANS ### + ####################################### + + # Axisymmetric air nozzle (transonic) + axi_rans_air_nozzle = TestCase('axi_rans_air_nozzle') + axi_rans_air_nozzle.cfg_dir = "axisymmetric_rans/air_nozzle" + axi_rans_air_nozzle.cfg_file = "air_nozzle.cfg" + axi_rans_air_nozzle.test_iter = 10 + axi_rans_air_nozzle.test_vals = [-12.094937, -6.622043, -8.814412, -2.393288] + test_list.append(axi_rans_air_nozzle) + ################################# ## Compressible RANS Restart ### ################################# diff --git a/TestCases/incomp_euler/nozzle/inv_nozzle.cfg b/TestCases/incomp_euler/nozzle/inv_nozzle.cfg index fc9eb30d4ed..c5b6e21df54 100644 --- a/TestCases/incomp_euler/nozzle/inv_nozzle.cfg +++ b/TestCases/incomp_euler/nozzle/inv_nozzle.cfg @@ -119,7 +119,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/incomp_navierstokes/buoyancy_cavity/lam_buoyancy_cavity.cfg b/TestCases/incomp_navierstokes/buoyancy_cavity/lam_buoyancy_cavity.cfg index 52371510ccc..8f07b27a064 100644 --- a/TestCases/incomp_navierstokes/buoyancy_cavity/lam_buoyancy_cavity.cfg +++ b/TestCases/incomp_navierstokes/buoyancy_cavity/lam_buoyancy_cavity.cfg @@ -144,7 +144,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Min error of the linear solver for the implicit formulation diff --git a/TestCases/incomp_navierstokes/cylinder/poly_cylinder.cfg b/TestCases/incomp_navierstokes/cylinder/poly_cylinder.cfg index c9b8c73ca42..99f14c72867 100644 --- a/TestCases/incomp_navierstokes/cylinder/poly_cylinder.cfg +++ b/TestCases/incomp_navierstokes/cylinder/poly_cylinder.cfg @@ -195,7 +195,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/incomp_rans/rough_flatplate/rough_flatplate_incomp.cfg b/TestCases/incomp_rans/rough_flatplate/rough_flatplate_incomp.cfg index ce00494b14d..8b50e4df8e2 100644 --- a/TestCases/incomp_rans/rough_flatplate/rough_flatplate_incomp.cfg +++ b/TestCases/incomp_rans/rough_flatplate/rough_flatplate_incomp.cfg @@ -155,7 +155,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/mms/fvm_incomp_euler/inv_mms_jst.cfg b/TestCases/mms/fvm_incomp_euler/inv_mms_jst.cfg index a7017d93c38..d8331a7080a 100755 --- a/TestCases/mms/fvm_incomp_euler/inv_mms_jst.cfg +++ b/TestCases/mms/fvm_incomp_euler/inv_mms_jst.cfg @@ -111,7 +111,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/mms/fvm_incomp_navierstokes/lam_mms_fds.cfg b/TestCases/mms/fvm_incomp_navierstokes/lam_mms_fds.cfg index cfabd77e730..20a25bbd8aa 100755 --- a/TestCases/mms/fvm_incomp_navierstokes/lam_mms_fds.cfg +++ b/TestCases/mms/fvm_incomp_navierstokes/lam_mms_fds.cfg @@ -129,7 +129,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/mms/fvm_navierstokes/lam_mms_roe.cfg b/TestCases/mms/fvm_navierstokes/lam_mms_roe.cfg index 011294a777b..a55057a7b20 100755 --- a/TestCases/mms/fvm_navierstokes/lam_mms_roe.cfg +++ b/TestCases/mms/fvm_navierstokes/lam_mms_roe.cfg @@ -146,7 +146,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (JACOBI, LINELET, LU_SGS) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/moving_wall/cavity/lam_cavity.cfg b/TestCases/moving_wall/cavity/lam_cavity.cfg index 545e44b297b..f6f7378821e 100644 --- a/TestCases/moving_wall/cavity/lam_cavity.cfg +++ b/TestCases/moving_wall/cavity/lam_cavity.cfg @@ -48,8 +48,7 @@ REYNOLDS_LENGTH= 1.0 % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% % % Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, ELASTICITY, -% EXTERNAL) +% MOVING_WALL, AEROELASTIC, ELASTICITY, EXTERNAL) SURFACE_MOVEMENT= MOVING_WALL % % Motion mach number (non-dimensional). Used for initializing a viscous flow diff --git a/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg b/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg index 4dc1a80d0a7..534193074e4 100644 --- a/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg +++ b/TestCases/moving_wall/spinning_cylinder/spinning_cylinder.cfg @@ -48,7 +48,7 @@ REYNOLDS_LENGTH= 1.0 % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% % % Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, EXTERNAL) +% MOVING_WALL, AEROELASTIC, EXTERNAL) SURFACE_MOVEMENT= MOVING_WALL % % Motion mach number (non-dimensional). Used for intitializing a viscous flow diff --git a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_2surf_1obj.cfg b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_2surf_1obj.cfg index 30f8b9432d1..41cd1505c4e 100644 --- a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_2surf_1obj.cfg +++ b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_2surf_1obj.cfg @@ -111,7 +111,7 @@ LINEAR_SOLVER_ITER= 5 % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 diff --git a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj.cfg b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj.cfg index 24171325ad6..40d5597280d 100644 --- a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj.cfg +++ b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj.cfg @@ -112,7 +112,7 @@ LINEAR_SOLVER_ITER= 5 % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 diff --git a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_1surf.cfg b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_1surf.cfg index 09bc08fd865..a4165b7d9dc 100644 --- a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_1surf.cfg +++ b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_1surf.cfg @@ -112,7 +112,7 @@ LINEAR_SOLVER_ITER= 5 % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 diff --git a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_combo.cfg b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_combo.cfg index 767b543cac4..8affe19a7db 100644 --- a/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_combo.cfg +++ b/TestCases/optimization_euler/multiobjective_wedge/inv_wedge_ROE_multiobj_combo.cfg @@ -114,7 +114,7 @@ LINEAR_SOLVER_ITER= 5 % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (1 by default) +% Linear solver ILU preconditioner fill-in level (1 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 diff --git a/TestCases/optimization_euler/pitching_naca64a010/pitching_NACA64A010.cfg b/TestCases/optimization_euler/pitching_naca64a010/pitching_NACA64A010.cfg index 8d22b650744..f5fa022f1b4 100644 --- a/TestCases/optimization_euler/pitching_naca64a010/pitching_NACA64A010.cfg +++ b/TestCases/optimization_euler/pitching_naca64a010/pitching_NACA64A010.cfg @@ -51,7 +51,7 @@ UNST_ADJOINT_ITER= 251 % Dynamic mesh simulation (NO, YES) GRID_MOVEMENT= YES % -% Type of mesh motion (NONE, FLUTTER, RIGID_MOTION, FLUID_STRUCTURE) +% Type of mesh motion (NONE, FLUTTER, RIGID_MOTION) GRID_MOVEMENT_KIND= RIGID_MOTION % % Motion mach number (non-dimensional). Used for initializing a viscous flow diff --git a/TestCases/optimization_euler/pitching_oneram6/pitching_ONERAM6.cfg b/TestCases/optimization_euler/pitching_oneram6/pitching_ONERAM6.cfg index 8a1ab1851c2..d9ca2a72dd7 100644 --- a/TestCases/optimization_euler/pitching_oneram6/pitching_ONERAM6.cfg +++ b/TestCases/optimization_euler/pitching_oneram6/pitching_ONERAM6.cfg @@ -65,7 +65,7 @@ UNST_ADJOINT_ITER= 251 GRID_MOVEMENT= YES % % Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, EXTERNAL) +% MOVING_WALL, AEROELASTIC, EXTERNAL) GRID_MOVEMENT_KIND= RIGID_MOTION % % Motion mach number (non-dimensional). Used for intitializing a viscous flow diff --git a/TestCases/optimization_euler/rotating_naca0012/rotating_NACA0012.cfg b/TestCases/optimization_euler/rotating_naca0012/rotating_NACA0012.cfg index ff3a00c420f..83801d29d8c 100644 --- a/TestCases/optimization_euler/rotating_naca0012/rotating_NACA0012.cfg +++ b/TestCases/optimization_euler/rotating_naca0012/rotating_NACA0012.cfg @@ -58,7 +58,7 @@ REF_AREA= 1.0 GRID_MOVEMENT= YES % % Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, FLUID_STRUCTURE, AEROELASTIC, EXTERNAL) +% MOVING_WALL, AEROELASTIC, EXTERNAL) GRID_MOVEMENT_KIND= ROTATING_FRAME % % Motion mach number (non-dimensional). Used for intitializing a viscous flow diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index c7ec41d0a58..68dc0e3c29d 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -59,7 +59,7 @@ def main(): thermalbath_frozen.cfg_dir = "nonequilibrium/thermalbath/frozen" thermalbath_frozen.cfg_file = "thermalbath_frozen.cfg" thermalbath_frozen.test_iter = 10 - thermalbath_frozen.test_vals = [ -32.000000, -32.000000, -11.92359, -11.962329, -32.000000, 10.813864] + thermalbath_frozen.test_vals = [ -32.000000, -32.000000, -11.92359, -11.962329, -32.000000, 10.813864] thermalbath_frozen.su2_exec = "mpirun -n 2 SU2_CFD" thermalbath_frozen.timeout = 1600 thermalbath_frozen.new_output = True @@ -347,6 +347,21 @@ def main(): propeller.tol = 0.00001 test_list.append(propeller) + ####################################### + ### Axisymmetric Compressible RANS ### + ####################################### + + # Axisymmetric air nozzle (transonic) + axi_rans_air_nozzle = TestCase('axi_rans_air_nozzle') + axi_rans_air_nozzle.cfg_dir = "axisymmetric_rans/air_nozzle" + axi_rans_air_nozzle.cfg_file = "air_nozzle.cfg" + axi_rans_air_nozzle.test_iter = 10 + axi_rans_air_nozzle.test_vals = [ -12.096569, -6.625843, -8.807541, -2.393279] + axi_rans_air_nozzle.su2_exec = "mpirun -n 2 SU2_CFD" + axi_rans_air_nozzle.timeout = 1600 + axi_rans_air_nozzle.tol = 0.0001 + test_list.append(axi_rans_air_nozzle) + ################################# ## Compressible RANS Restart ### ################################# @@ -1298,7 +1313,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.614165, 2.242641, -0.038307, 0.173866] + pywrapper_rigidMotion.test_vals = [-1.551335, 2.295594, 0.350036, 0.093081] pywrapper_rigidMotion.su2_exec = "mpirun -np 2 python launch_flatPlate_rigidMotion.py --parallel -f" pywrapper_rigidMotion.timeout = 1600 pywrapper_rigidMotion.tol = 0.00001 diff --git a/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg b/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg index 0ebe07328e1..faece71a8ed 100644 --- a/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg +++ b/TestCases/py_wrapper/flatPlate_rigidMotion/flatPlate_rigidMotion_Conf.cfg @@ -22,29 +22,9 @@ KIND_TURB_MODEL= SST % Mathematical problem (DIRECT, CONTINUOUS_ADJOINT, DISCRETE_ADJOINT) MATH_PROBLEM= DIRECT % -% -% Axisymmetric simulation, only compressible flows (NO, YES) -AXISYMMETRIC= NO -% % Restart solution (NO, YES) RESTART_SOL= NO % -% Discard the data storaged in the solution and geometry files -% e.g. AOA, dCL/dAoA, dCD/dCL, iter, etc. -% Note that AoA in the solution and geometry files is critical -% to aero design using AoA as a variable. (NO, YES) -DISCARD_INFILES= NO -% -% System of measurements (SI, US) -% International system of units (SI): ( meters, kilograms, Kelvins, -% Newtons = kg m/s^2, Pascals = N/m^2, -% Density = kg/m^3, Speed = m/s, -% Equiv. Area = m^2 ) -% United States customary units (US): ( inches, slug, Rankines, lbf = slug ft/s^2, -% psf = lbf/ft^2, Density = slug/ft^3, -% Speed = ft/s, Equiv. Area = ft^2 ) -SYSTEM_MEASUREMENTS= SI - % -------------------- COMPRESSIBLE FREE-STREAM DEFINITION --------------------% % % Mach number (non-dimensional, based on the free-stream values) @@ -53,9 +33,6 @@ MACH_NUMBER= 0.03059 % Angle of attack (degrees, only for compressible flows) AOA= 0.0 % -% Side-slip angle (degrees, only for compressible flows) -SIDESLIP_ANGLE= 0.0 -% % Init option to choose between Reynolds (default) or thermodynamics quantities % for initializing the solution (REYNOLDS, TD_CONDITIONS) INIT_OPTION= REYNOLDS @@ -64,9 +41,6 @@ INIT_OPTION= REYNOLDS % initializing the solution (TEMPERATURE_FS, DENSITY_FS) FREESTREAM_OPTION= TEMPERATURE_FS % -% Free-stream pressure (101325.0 N/m^2, 2116.216 psf by default) -FREESTREAM_PRESSURE= 101325.0 -% % Free-stream temperature (288.15 K, 518.67 R by default) FREESTREAM_TEMPERATURE= 293.15 % @@ -75,18 +49,7 @@ REYNOLDS_NUMBER= 24407.25244 % % Reynolds length (1 m, 1 inch by default) REYNOLDS_LENGTH= 0.035 - -% -------------------- INCOMPRESSIBLE FREE-STREAM DEFINITION ------------------% % -% Free-stream density (1.2886 Kg/m^3, 0.0025 slug/ft^3 by default) -FREESTREAM_DENSITY= 1.204 -% -% Free-stream velocity (1.0 m/s, 1.0 ft/s by default) -FREESTREAM_VELOCITY= ( 1.0, 0.00, 0.00 ) -% -% Free-stream viscosity (1.853E-5 N s/m^2, 3.87E-7 lbf s/ft^2 by default) -FREESTREAM_VISCOSITY= 1.82E-5 - % ---------------------- REFERENCE VALUE DEFINITION ---------------------------% % % Reference origin for moment computation (m or in) @@ -101,60 +64,25 @@ REF_LENGTH= 0.035 % calculation) (m^2 or in^2) REF_AREA= 0.035 % -% Aircraft semi-span (0 implies automatic calculation) (m or in) -SEMI_SPAN= 0.0 -% % Flow non-dimensionalization (DIMENSIONAL, FREESTREAM_PRESS_EQ_ONE, % FREESTREAM_VEL_EQ_MACH, FREESTREAM_VEL_EQ_ONE) REF_DIMENSIONALIZATION= DIMENSIONAL - +% % ---- IDEAL GAS, POLYTROPIC, VAN DER WAALS AND PENG ROBINSON CONSTANTS -------% % % Different gas model (STANDARD_AIR, IDEAL_GAS, VW_GAS, PR_GAS) FLUID_MODEL= STANDARD_AIR % -% Ratio of specific heats (1.4 default and the value is hardcoded -% for the model STANDARD_AIR) -GAMMA_VALUE= 1.4 -% -% Specific gas constant (287.058 J/kg*K default and this value is hardcoded -% for the model STANDARD_AIR) -GAS_CONSTANT= 287.058 -% -% Critical Temperature (131.00 K by default) -CRITICAL_TEMPERATURE= 131.00 -% -% Critical Pressure (3588550.0 N/m^2 by default) -CRITICAL_PRESSURE= 3588550.0 -% -% Acentri factor (0.035 (air)) -ACENTRIC_FACTOR= 0.035 - % --------------------------- VISCOSITY MODEL ---------------------------------% % % Viscosity model (SUTHERLAND, CONSTANT_VISCOSITY). VISCOSITY_MODEL= SUTHERLAND % -% Molecular Viscosity that would be constant (1.716E-5 by default) -MU_CONSTANT= 1.716E-5 -% -% Sutherland Viscosity Ref (1.716E-5 default value for AIR SI) -MU_REF= 1.716E-5 -% -% Sutherland Temperature Ref (273.15 K default value for AIR SI) -MU_T_REF= 273.15 -% -% Sutherland constant (110.4 default value for AIR SI) -SUTHERLAND_CONSTANT= 110.4 - % --------------------------- THERMAL CONDUCTIVITY MODEL ----------------------% % % Conductivity model (CONSTANT_CONDUCTIVITY, CONSTANT_PRANDTL). CONDUCTIVITY_MODEL= CONSTANT_PRANDTL % -% Molecular Thermal Conductivity that would be constant (0.0257 by default) -KT_CONSTANT= 0.0257 - % ------------------------- UNSTEADY SIMULATION -------------------------------% % TIME_DOMAIN=YES @@ -167,54 +95,20 @@ TIME_STEP= 0.003 % % Total Physical Time for dual time stepping simulations (s) MAX_TIME= 1.0 -% -% Unsteady Courant-Friedrichs-Lewy number of the finest grid -UNST_CFL_NUMBER= 0.0 +TIME_ITER = 9999 % % Number of internal iterations (dual time method) INNER_ITER= 10 % % Iteration number to begin unsteady restarts RESTART_ITER= 0 - -TIME_ITER=9999 % ----------------------- DYNAMIC MESH DEFINITION -----------------------------% -% Type of dynamic mesh (NONE, RIGID_MOTION, DEFORMING, ROTATING_FRAME, -% MOVING_WALL, STEADY_TRANSLATION, FLUID_STRUCTURE, -% AEROELASTIC, ELASTICITY, EXTERNAL, -% AEROELASTIC_RIGID_MOTION, GUST) -SURFACE_MOVEMENT= FLUID_STRUCTURE -% -% Motion mach number (non-dimensional). Used for initializing a viscous flow -% with the Reynolds number and for computing force coeffs. with dynamic meshes. -MACH_MOTION= 0.03059 -% -% Moving wall boundary marker(s) (NONE = no marker, ignored for RIGID_MOTION) -MARKER_MOVING= ( plate ) -% -% Coordinates of the motion origin -SURFACE_MOTION_ORIGIN= -0.0028 0.0 0.0 -% -% Move Motion Origin for marker moving (1 or 0) -MOVE_MOTION_ORIGIN = 1 - -% ----------------------- BODY FORCE DEFINITION -------------------------------% % -% Apply a body force as a source term (NO, YES) -BODY_FORCE= NO +DEFORM_MESH = YES +MARKER_DEFORM_MESH = (plate) % -% Vector of body force values (BodyForce_X, BodyForce_Y, BodyForce_Z) -BODY_FORCE_VECTOR= ( 0.0, 0.0, 0.0 ) - % -------------------- BOUNDARY CONDITION DEFINITION --------------------------% % -% Euler wall boundary marker(s) (NONE = no marker) -MARKER_EULER= ( NONE ) -% -% Navier-Stokes (no-slip), constant heat flux wall marker(s) (NONE = no marker) -% Format: ( marker name, constant heat flux (J/m^2), ... ) -%MARKER_HEATFLUX= ( plate, 1000.0 ) -% % Navier-Stokes (no-slip), isothermal wall marker(s) (NONE = no marker) % Format: ( marker name, constant wall temperature (K), ... ) MARKER_ISOTHERMAL= ( plate, 293 ) @@ -230,22 +124,6 @@ MARKER_PLOTTING = ( plate ) % Marker(s) of the surface where the non-dimensional coefficients are evaluated. MARKER_MONITORING = ( plate ) % -% Viscous wall markers for which wall functions must be applied. (NONE = no marker) -% Format: ( marker name, wall function type, ... ) -MARKER_WALL_FUNCTIONS= ( plate, NO_WALL_FUNCTION ) -% -% Marker(s) of the surface where custom thermal BC's are defined. -MARKER_PYTHON_CUSTOM = (NONE) -% -% Marker(s) of the surface where obj. func. (design problem) will be evaluated -MARKER_DESIGNING = ( NONE ) -% -% Marker(s) of the surface that is going to be analyzed in detail (massflow, average pressure, distortion, etc) -MARKER_ANALYZE = ( NONE ) -% -% Method to compute the average value in MARKER_ANALYZE (AREA, MASSFLUX). -MARKER_ANALYZE_AVERAGE = MASSFLUX - % ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% % % Numerical method for spatial gradients (GREEN_GAUSS, WEIGHTED_LEAST_SQUARES) @@ -254,99 +132,16 @@ NUM_METHOD_GRAD= WEIGHTED_LEAST_SQUARES % CFL number (initial value for the adaptive CFL number) CFL_NUMBER= 7.0 % -% Adaptive CFL number (NO, YES) -CFL_ADAPT= NO -% -% Parameters of the adaptive CFL number (factor down, factor up, CFL min value, -% CFL max value ) -CFL_ADAPT_PARAM= ( 1.5, 0.5, 1.25, 50.0 ) -% -% Maximum Delta Time in local time stepping simulations -MAX_DELTA_TIME= 1E6 -% -% Runge-Kutta alpha coefficients -RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) -% -% Objective function in gradient evaluation (DRAG, LIFT, SIDEFORCE, MOMENT_X, -% MOMENT_Y, MOMENT_Z, EFFICIENCY, -% EQUIVALENT_AREA, NEARFIELD_PRESSURE, -% FORCE_X, FORCE_Y, FORCE_Z, THRUST, -% TORQUE, TOTAL_HEATFLUX, -% MAXIMUM_HEATFLUX, INVERSE_DESIGN_PRESSURE, -% INVERSE_DESIGN_HEATFLUX, SURFACE_TOTAL_PRESSURE, -% SURFACE_MASSFLOW, SURFACE_STATIC_PRESSURE, SURFACE_MACH) -% For a weighted sum of objectives: separate by commas, add OBJECTIVE_WEIGHT and MARKER_MONITORING in matching order. -OBJECTIVE_FUNCTION= DRAG -% -% List of weighting values when using more than one OBJECTIVE_FUNCTION. Separate by commas and match with MARKER_MONITORING. -OBJECTIVE_WEIGHT = 1.0 -% -% Reference coefficient (sensitivity) for detecting sharp edges. -REF_SHARP_EDGES= 3.0 -% -% Remove sharp edges from the sensitivity evaluation (NO, YES) -SENS_REMOVE_SHARP= NO - % ----------- SLOPE LIMITER AND DISSIPATION SENSOR DEFINITION -----------------% % % Monotonic Upwind Scheme for Conservation Laws (TVD) in the flow equations. % Required for 2nd order upwind schemes (NO, YES) -MUSCL_FLOW= YES -% -% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, -% BARTH_JESPERSEN, VAN_ALBADA_EDGE) -SLOPE_LIMITER_FLOW= VENKATAKRISHNAN +MUSCL_FLOW= NO % % Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence equations. % Required for 2nd order upwind schemes (NO, YES) MUSCL_TURB= NO % -% Slope limiter (NONE, VENKATAKRISHNAN, VENKATAKRISHNAN_WANG, -% BARTH_JESPERSEN, VAN_ALBADA_EDGE) -SLOPE_LIMITER_TURB= VENKATAKRISHNAN -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the adjoint flow equations. -% Required for 2nd order upwind schemes (NO, YES) -MUSCL_ADJFLOW= YES -% -% Slope limiter (NONE, VENKATAKRISHNAN, BARTH_JESPERSEN, VAN_ALBADA_EDGE, -% SHARP_EDGES, WALL_DISTANCE) -SLOPE_LIMITER_ADJFLOW= VENKATAKRISHNAN -% -% Monotonic Upwind Scheme for Conservation Laws (TVD) in the turbulence adjoint equations. -% Required for 2nd order upwind schemes (NO, YES) -MUSCL_ADJTURB= NO -% -% Slope limiter (NONE, VENKATAKRISHNAN, BARTH_JESPERSEN, VAN_ALBADA_EDGE) -SLOPE_LIMITER_ADJTURB= VENKATAKRISHNAN -% -% Coefficient for the Venkat's limiter (upwind scheme). A larger values decrease -% the extent of limiting, values approaching zero cause -% lower-order approximation to the solution (0.05 by default) -VENKAT_LIMITER_COEFF= 0.05 -% -% Coefficient for the adjoint sharp edges limiter (3.0 by default). -ADJ_SHARP_LIMITER_COEFF= 3.0 -% -% Freeze the value of the limiter after a number of iterations -LIMITER_ITER= 999999 -% -% 1st order artificial dissipation coefficients for -% the Lax–Friedrichs method ( 0.15 by default ) -LAX_SENSOR_COEFF= 0.15 -% -% 2nd and 4th order artificial dissipation coefficients for -% the JST method ( 0.5, 0.02 by default ) -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -% -% 1st order artificial dissipation coefficients for -% the adjoint Lax–Friedrichs method ( 0.15 by default ) -ADJ_LAX_SENSOR_COEFF= 0.15 -% -% 2nd, and 4th order artificial dissipation coefficients for -% the adjoint JST method ( 0.5, 0.02 by default ) -ADJ_JST_SENSOR_COEFF= ( 0.5, 0.02 ) - % ------------------------ LINEAR SOLVER DEFINITION ---------------------------% % % Linear solver or smoother for implicit formulations (BCGSTAB, FGMRES, SMOOTHER) @@ -355,7 +150,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations @@ -367,26 +162,8 @@ LINEAR_SOLVER_ITER= 10 % -------------------------- MULTIGRID PARAMETERS -----------------------------% % % Multi-grid levels (0 = no multi-grid) -MGLEVEL= 3 -% -% Multi-grid cycle (V_CYCLE, W_CYCLE, FULLMG_CYCLE) -MGCYCLE= W_CYCLE -% -% Multi-grid pre-smoothing level -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -% -% Multi-grid post-smoothing level -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -% -% Jacobi implicit smoothing of the correction -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MGLEVEL= 0 % -% Damping factor for the residual restriction -MG_DAMP_RESTRICTION= 0.75 -% -% Damping factor for the correction prolongation -MG_DAMP_PROLONGATION= 0.75 - % -------------------- FLOW NUMERICAL METHOD DEFINITION -----------------------% % % Convective numerical method (JST, LAX-FRIEDRICH, CUSP, ROE, AUSM, HLLC, @@ -397,8 +174,7 @@ CONV_NUM_METHOD_FLOW= JST % Time discretization (RUNGE-KUTTA_EXPLICIT, EULER_IMPLICIT, EULER_EXPLICIT) TIME_DISCRE_FLOW= EULER_IMPLICIT % -% Relaxation coefficient - +% % -------------------- TURBULENT NUMERICAL METHOD DEFINITION ------------------% % % Convective numerical method (SCALAR_UPWIND) @@ -407,11 +183,6 @@ CONV_NUM_METHOD_TURB= SCALAR_UPWIND % Time discretization (EULER_IMPLICIT) TIME_DISCRE_TURB= EULER_IMPLICIT % -% Reduction factor of the CFL coefficient in the turbulence problem -CFL_REDUCTION_TURB= 1.0 -% -% Relaxation coefficient - % ------------------------ GRID DEFORMATION PARAMETERS ------------------------% % % Linear solver or smoother for implicit formulations (FGMRES, RESTARTED_FGMRES, BCGSTAB) @@ -432,38 +203,11 @@ DEFORM_CONSOLE_OUTPUT= YES % Minimum residual criteria for the linear solver convergence of grid deformation DEFORM_LINEAR_SOLVER_ERROR= 1E-14 % -% Deformation coefficient (linear elasticity limits from -1.0 to 0.5, a larger -% value is also possible) -DEFORM_COEFF = 1E6 % % Type of element stiffness imposed for FEA mesh deformation (INVERSE_VOLUME, % WALL_DISTANCE, CONSTANT_STIFFNESS) -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME -% -% Deform the grid only close to the surface. It is possible to specify how much -% of the volumetric grid is going to be deformed in meters or inches (1E6 by default) -DEFORM_LIMIT = 1E6 - -% --------------------------- CONVERGENCE PARAMETERS --------------------------% -% Convergence criteria (CAUCHY, RESIDUAL) -% -CONV_CRITERIA= CAUCHY -% -% -% Min value of the residual (log10 of the residual) -CONV_RESIDUAL_MINVAL= -10 +DEFORM_STIFFNESS_TYPE= WALL_DISTANCE % -% Start convergence criteria at iteration number -CONV_STARTITER= 4 -% -% Number of elements to apply the criteria -CONV_CAUCHY_ELEMS= 10 -% -% Epsilon to control the series convergence -CONV_CAUCHY_EPS= 1E-6 -% -% - % ------------------------- INPUT/OUTPUT INFORMATION --------------------------% % % Mesh input file @@ -472,55 +216,23 @@ MESH_FILENAME= 2D_FlatPlate_Rounded.su2 % Mesh input file format (SU2, CGNS) MESH_FORMAT= SU2 % -% Mesh output file -MESH_OUT_FILENAME= mesh_out.su2 -% -% Restart flow input file -SOLUTION_FILENAME= restart_flow.dat -% -% Restart adjoint input file -SOLUTION_ADJ_FILENAME= solution_adj.dat % % Output file format (TECPLOT, TECPLOT_BINARY, PARAVIEW, % FIELDVIEW, FIELDVIEW_BINARY) -TABULAR_FORMAT= CSV +TABULAR_FORMAT= TECPLOT % % Output file convergence history (w/o extension) CONV_FILENAME= history % -% Output file with the forces breakdown -BREAKDOWN_FILENAME= forces_breakdown.dat -% -% Output file restart flow -RESTART_FILENAME= restart_flow.dat -% -% Output file restart adjoint -RESTART_ADJ_FILENAME= restart_adj.dat -% % Output file flow (w/o extension) variables VOLUME_FILENAME= flow % -% Output file adjoint (w/o extension) variables -VOLUME_ADJ_FILENAME= adjoint -% -% Output Objective function -VALUE_OBJFUNC_FILENAME= of_eval.dat -% -% Output objective function gradient (using continuous adjoint) -GRAD_OBJFUNC_FILENAME= of_grad.dat -% % Output file surface flow coefficient (w/o extension) SURFACE_FILENAME= surface_flow % -% Output file surface adjoint coefficient (w/o extension) -SURFACE_ADJ_FILENAME= surface_adjoint -% % Writing solution file frequency for physical time steps (dual time) OUTPUT_WRT_FREQ= 3 % -% -% Read binary restart files (YES, NO) -READ_BINARY_RESTART= YES -% % Screen output SCREEN_OUTPUT= (TIME_ITER, INNER_ITER, RMS_DENSITY, RMS_TKE, RMS_DISSIPATION, LIFT, DRAG) +HISTORY_OUTPUT=(ITER,RMS_RES,AERO_COEFF) diff --git a/TestCases/py_wrapper/flatPlate_rigidMotion/launch_flatPlate_rigidMotion.py b/TestCases/py_wrapper/flatPlate_rigidMotion/launch_flatPlate_rigidMotion.py index 6c6a97a8f1f..a611e6554d7 100755 --- a/TestCases/py_wrapper/flatPlate_rigidMotion/launch_flatPlate_rigidMotion.py +++ b/TestCases/py_wrapper/flatPlate_rigidMotion/launch_flatPlate_rigidMotion.py @@ -46,7 +46,7 @@ import numpy as np # ------------------------------------------------------------------- -# Main +# Main # ------------------------------------------------------------------- def main(): @@ -54,38 +54,12 @@ def main(): # Command line options parser=OptionParser() parser.add_option("-f", "--file", dest="filename", help="Read config from FILE", metavar="FILE") - parser.add_option("--nDim", dest="nDim", default=2, help="Define the number of DIMENSIONS", - metavar="DIMENSIONS") - parser.add_option("--nZone", dest="nZone", default=1, help="Define the number of ZONES", - metavar="ZONES") parser.add_option("--parallel", action="store_true", help="Specify if we need to initialize MPI", dest="with_MPI", default=False) - parser.add_option("--fsi", dest="fsi", default="False", help="Launch the FSI driver", metavar="FSI") - - parser.add_option("--fem", dest="fem", default="False", help="Launch the FEM driver (General driver)", metavar="FEM") - - parser.add_option("--harmonic_balance", dest="harmonic_balance", default="False", - help="Launch the Harmonic Balance (HB) driver", metavar="HB") - - parser.add_option("--poisson_equation", dest="poisson_equation", default="False", - help="Launch the poisson equation driver (General driver)", metavar="POIS_EQ") - - parser.add_option("--wave_equation", dest="wave_equation", default="False", - help="Launch the wave equation driver (General driver)", metavar="WAVE_EQ") - - parser.add_option("--heat_equation", dest="heat_equation", default="False", - help="Launch the heat equation driver (General driver)", metavar="HEAT_EQ") - (options, args) = parser.parse_args() - options.nDim = int( options.nDim ) - options.nZone = int( options.nZone ) - options.fsi = options.fsi.upper() == 'TRUE' - options.fem = options.fem.upper() == 'TRUE' - options.harmonic_balance = options.harmonic_balance.upper() == 'TRUE' - options.poisson_equation = options.poisson_equation.upper() == 'TRUE' - options.wave_equation = options.wave_equation.upper() == 'TRUE' - options.heat_equation = options.heat_equation.upper() == 'TRUE' + options.nDim = int(2) + options.nZone = int(1) # Import mpi4py for parallel run if options.with_MPI == True: @@ -98,13 +72,6 @@ def main(): # Initialize the corresponding driver of SU2, this includes solver preprocessing try: - if (options.nZone == 1) and ( options.fem or options.poisson_equation or options.wave_equation or options.heat_equation ): - SU2Driver = pysu2.CSinglezoneDriver(options.filename, options.nZone, comm); - elif options.harmonic_balance: - SU2Driver = pysu2.CHBDriver(options.filename, options.nZone, comm); - elif (options.nZone == 2) and (options.fsi): - SU2Driver = pysu2.CFSIDriver(options.filename, options.nZone, comm); - else: SU2Driver = pysu2.CSinglezoneDriver(options.filename, options.nZone, comm); except TypeError as exception: print('A TypeError occured in pysu2.CDriver : ',exception) @@ -119,7 +86,7 @@ def main(): MovingMarker = 'plate' #specified by the user # Get all the tags with the moving option - MovingMarkerList = SU2Driver.GetAllMovingMarkersTag() + MovingMarkerList = SU2Driver.GetAllDeformMeshMarkersTag() # Get all the markers defined on this rank and their associated indices. allMarkerIDs = SU2Driver.GetAllBoundaryMarkers() @@ -147,9 +114,9 @@ def main(): # Extract the initial position of each node on the moving marker CoordX = np.zeros(nVertex_MovingMarker) CoordY = np.zeros(nVertex_MovingMarker) + CoordZ = np.zeros(nVertex_MovingMarker) for iVertex in range(nVertex_MovingMarker): - CoordX[iVertex] = SU2Driver.GetVertexCoordX(MovingMarkerID, iVertex) - CoordY[iVertex] = SU2Driver.GetVertexCoordY(MovingMarkerID, iVertex) + CoordX[iVertex], CoordY[iVertex], CoordZ[iVertex] = SU2Driver.GetInitialMeshCoord(MovingMarkerID, iVertex) # Time loop is defined in Python so that we have acces to SU2 functionalities at each time step if rank == 0: @@ -162,16 +129,13 @@ def main(): # Define the rigid body displacement and set the new coords of each node on the marker d_y = 0.0175*sin(2*pi*time) for iVertex in range(nVertex_MovingMarker): - newCoordX = CoordX[iVertex] - newCoordY = CoordY[iVertex] + d_y - SU2Driver.SetVertexCoordX(MovingMarkerID, iVertex, newCoordX) - SU2Driver.SetVertexCoordY(MovingMarkerID, iVertex, newCoordY) - SU2Driver.SetVertexCoordZ(MovingMarkerID, iVertex, 0.0) - SU2Driver.SetVertexVarCoord(MovingMarkerID, iVertex) + SU2Driver.SetMeshDisplacement(MovingMarkerID, int(iVertex), 0.0, d_y, 0.0) # Time iteration preprocessing SU2Driver.Preprocess(TimeIter) # Run one time iteration (e.g. dual-time) SU2Driver.Run() + # Postprocess the solver + SU2Driver.Postprocess() # Update the solver for the next time iteration SU2Driver.Update() # Monitor the solver and output solution to file if required @@ -195,4 +159,4 @@ def main(): # this is only accessed if running from command prompt if __name__ == '__main__': - main() + main() diff --git a/TestCases/py_wrapper/flatPlate_unsteady_CHT/launch_unsteady_CHT_FlatPlate.py b/TestCases/py_wrapper/flatPlate_unsteady_CHT/launch_unsteady_CHT_FlatPlate.py index 1ed717dd697..06a3edd2b7e 100755 --- a/TestCases/py_wrapper/flatPlate_unsteady_CHT/launch_unsteady_CHT_FlatPlate.py +++ b/TestCases/py_wrapper/flatPlate_unsteady_CHT/launch_unsteady_CHT_FlatPlate.py @@ -45,7 +45,7 @@ from math import * # ------------------------------------------------------------------- -# Main +# Main # ------------------------------------------------------------------- def main(): @@ -53,38 +53,12 @@ def main(): # Command line options parser=OptionParser() parser.add_option("-f", "--file", dest="filename", help="Read config from FILE", metavar="FILE") - parser.add_option("--nDim", dest="nDim", default=2, help="Define the number of DIMENSIONS", - metavar="DIMENSIONS") - parser.add_option("--nZone", dest="nZone", default=1, help="Define the number of ZONES", - metavar="ZONES") parser.add_option("--parallel", action="store_true", help="Specify if we need to initialize MPI", dest="with_MPI", default=False) - parser.add_option("--fsi", dest="fsi", default="False", help="Launch the FSI driver", metavar="FSI") - - parser.add_option("--fem", dest="fem", default="False", help="Launch the FEM driver (General driver)", metavar="FEM") - - parser.add_option("--harmonic_balance", dest="harmonic_balance", default="False", - help="Launch the Harmonic Balance (HB) driver", metavar="HB") - - parser.add_option("--poisson_equation", dest="poisson_equation", default="False", - help="Launch the poisson equation driver (General driver)", metavar="POIS_EQ") - - parser.add_option("--wave_equation", dest="wave_equation", default="False", - help="Launch the wave equation driver (General driver)", metavar="WAVE_EQ") - - parser.add_option("--heat_equation", dest="heat_equation", default="False", - help="Launch the heat equation driver (General driver)", metavar="HEAT_EQ") - (options, args) = parser.parse_args() - options.nDim = int( options.nDim ) - options.nZone = int( options.nZone ) - options.fsi = options.fsi.upper() == 'TRUE' - options.fem = options.fem.upper() == 'TRUE' - options.harmonic_balance = options.harmonic_balance.upper() == 'TRUE' - options.poisson_equation = options.poisson_equation.upper() == 'TRUE' - options.wave_equation = options.wave_equation.upper() == 'TRUE' - options.heat_equation = options.heat_equation.upper() == 'TRUE' + options.nDim = int(2) + options.nZone = int(1) # Import mpi4py for parallel run if options.with_MPI == True: @@ -92,18 +66,11 @@ def main(): comm = MPI.COMM_WORLD rank = comm.Get_rank() else: - comm = 0 + comm = 0 rank = 0 # Initialize the corresponding driver of SU2, this includes solver preprocessing try: - if (options.nZone == 1) and ( options.fem or options.poisson_equation or options.wave_equation or options.heat_equation ): - SU2Driver = pysu2.CGeneralDriver(options.filename, options.nZone, comm); - elif options.harmonic_balance: - SU2Driver = pysu2.CHBDriver(options.filename, options.nZone, comm); - elif (options.nZone == 2) and (options.fsi): - SU2Driver = pysu2.CFSIDriver(options.filename, options.nZone, comm); - else: SU2Driver = pysu2.CSinglezoneDriver(options.filename, options.nZone, comm); except TypeError as exception: print('A TypeError occured in pysu2.CDriver : ',exception) @@ -162,6 +129,8 @@ def main(): SU2Driver.BoundaryConditionsUpdate() # Run one time iteration (e.g. dual-time) SU2Driver.Run() + # Postprocess the solver and exit cleanly + SU2Driver.Postprocess() # Update the solver for the next time iteration SU2Driver.Update() # Monitor the solver and output solution to file if required @@ -173,9 +142,6 @@ def main(): TimeIter += 1 time += deltaT - # Postprocess the solver and exit cleanly - SU2Driver.Postprocessing() - if SU2Driver != None: del SU2Driver @@ -185,4 +151,4 @@ def main(): # this is only accessed if running from command prompt if __name__ == '__main__': - main() + main() diff --git a/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg b/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg index 9454f923fbb..e6f06d2b805 100644 --- a/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg +++ b/TestCases/py_wrapper/flatPlate_unsteady_CHT/unsteady_CHT_FlatPlate_Conf.cfg @@ -335,7 +335,7 @@ LINEAR_SOLVER= FGMRES % Preconditioner of the Krylov linear solver (ILU, LU_SGS, LINELET, JACOBI) LINEAR_SOLVER_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 55ffcd722dc..6c33afd0bea 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -86,8 +86,8 @@ def main(): viscwedge.timeout = 1600 viscwedge.new_output = True viscwedge.tol = 0.00001 - test_list.append(viscwedge) - + test_list.append(viscwedge) + ######################### ## Compressible Euler ### ######################### @@ -375,6 +375,21 @@ def main(): propeller.tol = 0.00001 test_list.append(propeller) + ####################################### + ### Axisymmetric Compressible RANS ### + ####################################### + + # Axisymmetric air nozzle (transonic) + axi_rans_air_nozzle = TestCase('axi_rans_air_nozzle') + axi_rans_air_nozzle.cfg_dir = "axisymmetric_rans/air_nozzle" + axi_rans_air_nozzle.cfg_file = "air_nozzle.cfg" + axi_rans_air_nozzle.test_iter = 10 + axi_rans_air_nozzle.test_vals = [ -12.093130, -6.619801, -8.806060, -2.393278] + axi_rans_air_nozzle.su2_exec = "SU2_CFD" + axi_rans_air_nozzle.timeout = 1600 + axi_rans_air_nozzle.tol = 0.0001 + test_list.append(axi_rans_air_nozzle) + ################################# ## Compressible RANS Restart ### ################################# @@ -1877,7 +1892,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.614167, 2.242632, -0.037871, 0.173912] + pywrapper_rigidMotion.test_vals = [-1.551335, 2.295594, 0.350050, 0.093081] pywrapper_rigidMotion.su2_exec = "python launch_flatPlate_rigidMotion.py -f" pywrapper_rigidMotion.new_output = True pywrapper_rigidMotion.timeout = 1600 diff --git a/config_template.cfg b/config_template.cfg index 937c13a8cb1..9d5d4299623 100644 --- a/config_template.cfg +++ b/config_template.cfg @@ -1019,7 +1019,7 @@ LINEAR_SOLVER_PREC= ILU % Same for discrete adjoint (JACOBI or ILU), replaces LINEAR_SOLVER_PREC in SU2_*_AD codes. DISCADJ_LIN_PREC= ILU % -% Linael solver ILU preconditioner fill-in level (0 by default) +% Linear solver ILU preconditioner fill-in level (0 by default) LINEAR_SOLVER_ILU_FILL_IN= 0 % % Minimum error of the linear solver for implicit formulations From 1bdc1edd0158080d3c7cea02767f406e028ae48b Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 24 Feb 2021 18:15:30 +0000 Subject: [PATCH 020/192] reset still needed for fluid only problems --- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index e243e1f8919..2e6e63d718b 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -389,6 +389,10 @@ void CFluidIteration::SetWind_GustField(CConfig* config, CGeometry** geometry, C /*--- Loop over each node in the volume mesh ---*/ for (iPoint = 0; iPoint < geometry[iMGlevel]->GetnPoint(); iPoint++) { + /*--- Reset the Grid Velocity to zero if there is no grid movement ---*/ + if (Kind_Grid_Movement == GUST && !(config->GetFSI_Simulation())) { + for (iDim = 0; iDim < nDim; iDim++) geometry[iMGlevel]->nodes->SetGridVel(iPoint, iDim, 0.0); + } /*--- initialize the gust and derivatives to zero everywhere ---*/ From 06cfde0e4a23f5a33e8feb1316f5d41f5d4c7dfb Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Wed, 10 Mar 2021 17:01:33 +0100 Subject: [PATCH 021/192] More output for debug --- SU2_CFD/src/solvers/CMeshSolver.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 6985488f3e5..3750cf2703e 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -277,6 +277,8 @@ void CMeshSolver::SetMinMaxVolume(CGeometry *geometry, CConfig *config, bool upd } SU2_OMP_BARRIER AD::EndPassive(wasActive); + + geometry->ComputeMeshQualityStatistics(config); // Only used for debug purpose } void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { From 97c45dafa11d4112e338f7a663e7dd2783c13ace Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Mon, 22 Mar 2021 14:55:09 +0100 Subject: [PATCH 022/192] Allow to extract the normal with info on the area and the unit normal --- SU2_CFD/include/drivers/CDriver.hpp | 2 +- SU2_CFD/src/python_wrapper_structure.cpp | 11 ++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index 8a0b597365b..cf0993f8393 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -526,7 +526,7 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Unit normal (vector) at the vertex. */ - vector GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const; + vector GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal) const; /*! * \brief Get all the boundary markers tags. diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 6125d80966e..0d427c3938f 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -228,7 +228,7 @@ vector CDriver::GetInitialMeshCoord(unsigned short iMarker, unsig return coord_passive; } -vector CDriver::GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const { +vector CDriver::GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal) const { su2double *Normal; su2double Area; @@ -237,6 +237,15 @@ vector CDriver::GetVertexUnitNormal(unsigned short iMarker, unsig Normal = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNormal(); + if (!unitNormal) { + + ret_Normal_passive[0] = SU2_TYPE::GetValue(Normal[0]); + ret_Normal_passive[1] = SU2_TYPE::GetValue(Normal[1]); + if(nDim>2) ret_Normal_passive[2] = SU2_TYPE::GetValue(Normal[2]); + + return ret_Normal_passive: + } + Area = GeometryToolbox::Norm(nDim, Normal); ret_Normal[0] = Normal[0]/Area; From 34884c49a6ed931e9dfd9eae585ad397b1538209 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Sat, 27 Mar 2021 11:31:07 +0100 Subject: [PATCH 023/192] small typo --- SU2_CFD/src/python_wrapper_structure.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 0d427c3938f..2e94c8fa0fd 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -243,7 +243,7 @@ vector CDriver::GetVertexNormal(unsigned short iMarker, unsigned ret_Normal_passive[1] = SU2_TYPE::GetValue(Normal[1]); if(nDim>2) ret_Normal_passive[2] = SU2_TYPE::GetValue(Normal[2]); - return ret_Normal_passive: + return ret_Normal_passive; } Area = GeometryToolbox::Norm(nDim, Normal); From b6958d9c55ff96a0f7add26e6e8061de27c63db0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 11 Apr 2021 13:51:16 +0100 Subject: [PATCH 024/192] switch on/off grid velocity --- SU2_CFD/src/solvers/CMeshSolver.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 046c2334f6d..47dadc33329 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -605,6 +605,9 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri /*--- Non-dimensionalize velocity ---*/ val_vel = val_vel/config->GetVelocity_Ref(); + // Debug: Force zero grid velocity + if (config->GetWrt_Performance()) val_vel = 0.0; + geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, val_vel); } } From a9c1a08617eb1830b080cd8986acbd53966252a9 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 11 Apr 2021 15:35:20 +0100 Subject: [PATCH 025/192] Add test case --- .../disc_adj_fsi/dyn_fsi/Adjoint/config.cfg | 28 ++ .../dyn_fsi/Adjoint/configFEA.cfg | 65 +++ .../dyn_fsi/Adjoint/configFlow.cfg | 105 +++++ .../disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt | 9 + .../dyn_fsi/Adjoint/element_properties_1.dat | 369 ++++++++++++++++++ .../disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg | 28 ++ .../dyn_fsi/FD_DV_0/configFEA.cfg | 65 +++ .../dyn_fsi/FD_DV_0/configFlow.cfg | 105 +++++ .../disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt | 9 + .../dyn_fsi/FD_DV_0/element_properties_1.dat | 369 ++++++++++++++++++ .../disc_adj_fsi/dyn_fsi/Primal/config.cfg | 28 ++ .../disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg | 65 +++ .../dyn_fsi/Primal/configFlow.cfg | 105 +++++ .../disc_adj_fsi/dyn_fsi/Primal/dv_young.opt | 9 + .../dyn_fsi/Primal/element_properties_1.dat | 369 ++++++++++++++++++ 15 files changed, 1728 insertions(+) create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg new file mode 100755 index 00000000000..8ed8339070c --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg @@ -0,0 +1,28 @@ +SOLVER= MULTIPHYSICS +MATH_PROBLEM= DISCRETE_ADJOINT +CONFIG_LIST=(configFlow.cfg, configFEA.cfg) + +MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) + +CONSERVATIVE_INTERPOLATION= NO + +READ_BINARY_RESTART= NO + +OUTER_ITER= 40 +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 + +TIME_DOMAIN = YES +TIME_ITER = 10 +TIME_STEP = 0.01 +UNST_ADJOINT_ITER= 10 +ITER_AVERAGE_OBJ= 10 + +OBJECTIVE_FUNCTION= REFERENCE_NODE + +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] + +WRT_ZONE_HIST=YES +%WRT_ZONE_CONV=YES + +% Debug: Force Zero Grid Velocity = NO +WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg new file mode 100755 index 00000000000..612823c7556 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg @@ -0,0 +1,65 @@ +% Physics -------------------------------------------------------------- % +SOLVER= ELASTICITY +% +% Time settings --------------------------------------------------------- % +TIME_DISCRE_FEA= NEWMARK_IMPLICIT +NEWMARK_BETA=0.2601 +NEWMARK_GAMMA=0.52 +% +% Optimization --------------------------------------------------------- % +FEA_ADVANCED_MODE= YES +FEA_FILENAME= element_properties.dat +GRAD_OBJFUNC_FILENAME= of_grad.dat +REFERENCE_NODE= 234 +REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) +REFERENCE_NODE_PENALTY= 1.0 +DESIGN_VARIABLE_FEA= YOUNG_MODULUS +% +% Solid properties ----------------------------------------------------- % +MATERIAL_MODEL= NEO_HOOKEAN +ELASTICITY_MODULUS= 7E8 +POISSON_RATIO= 0.35 +MATERIAL_DENSITY= 2700.0 +% +% Boundary conditions -------------------------------------------------- % +MARKER_CLAMPED= ( clamped ) +MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) +% +% Solid numerics ------------------------------------------------------- % +GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS +FORMULATION_ELASTICITY_2D= PLANE_STRESS +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= CONJUGATE_GRADIENT +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT +DISCADJ_LIN_PREC= ILU +% +% Convergence criteria ------------------------------------------------- % +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +INNER_ITER= 11 +% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. +INCREMENTAL_LOAD= NO +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_solid.dat +SOLUTION_ADJ_FILENAME= adjoint_solid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_solid.dat +RESTART_ADJ_FILENAME= adjoint_solid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= solid +VOLUME_ADJ_FILENAME= adjoint_solid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF +OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg new file mode 100755 index 00000000000..b83b3ecc111 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg @@ -0,0 +1,105 @@ +% Physics -------------------------------------------------------------- % +SOLVER= EULER +KIND_TURB_MODEL= NONE +% +% Time settings --------------------------------------------------------- % +TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER +% +% Optimization --------------------------------------------------------- % +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Compressible free-stream conditions ---------------------------------- % +MACH_NUMBER= 0.8 +AOA= 5.0 +INIT_OPTION= TD_CONDITIONS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_PRESSURE= 101325.0 +FREESTREAM_TEMPERATURE= 273.15 +REYNOLDS_LENGTH= 0.5 +% +% Fluid properties ----------------------------------------------------- % +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.87 +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.716E-5 +% +% Boundary conditions -------------------------------------------------- % +MARKER_FAR= ( farfield ) +MARKER_EULER= ( leading_edge, pressure_side, suction_side) +MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) +DEFORM_MESH= YES +% +% Post processing and monitoring --------------------------------------- % +REF_ORIGIN_MOMENT_X= -0.125 +REF_ORIGIN_MOMENT_Y= 0.00 +REF_ORIGIN_MOMENT_Z= 0.00 +REF_LENGTH= 0.5 +REF_AREA= 0.5 +MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) +MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) +MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) +% +% Common numerics settings --------------------------------------------- % +REF_DIMENSIONALIZATION= DIMENSIONAL +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 15.0 +% +% Flow numerics -------------------------------------------------------- % +CONV_NUM_METHOD_FLOW= JST +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= BCGSTAB +DISCADJ_LIN_PREC= ILU +% Multigrid +MGLEVEL= 2 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.75 +MG_DAMP_PROLONGATION= 0.75 +% +DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ERROR= 1e-8 +DEFORM_LINEAR_SOLVER_ITER= 1000 +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +DEFORM_POISSONS_RATIO= 1e6 +% +% Convergence criteria ------------------------------------------------- % +% interaction +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +% fluid +INNER_ITER= 51 +CONV_STARTITER= 0 +CONV_RESIDUAL_MINVAL= -9 +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_fluid.dat +SOLUTION_ADJ_FILENAME= adjoint_fluid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_fluid.dat +RESTART_ADJ_FILENAME= adjoint_fluid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= fluid +VOLUME_ADJ_FILENAME= adjoint_fluid +SURFACE_FILENAME= surface_fluid +SURFACE_ADJ_FILENAME= adjoint_surface_fluid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF +OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt new file mode 100644 index 00000000000..3c691471847 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt @@ -0,0 +1,9 @@ +INDEX VAL SCALE LOWER_BOUND UPPER_BOUND +0 1 1 0.01 100.0 +1 1 1 0.01 100.0 +2 1 1 0.01 100.0 +3 1 1 0.01 100.0 +4 1 1 0.01 100.0 +5 1 1 0.01 100.0 +6 1 1 0.01 100.0 +7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat new file mode 100644 index 00000000000..90421c13042 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat @@ -0,0 +1,369 @@ +INDEX MMOD MPROP ELPROP DV DENSITY +0 0 0 0 0 1.0 +1 0 0 0 0 1.0 +2 0 0 0 0 1.0 +3 0 0 0 0 1.0 +4 0 0 0 0 1.0 +5 0 0 0 0 1.0 +6 0 0 0 0 1.0 +7 0 0 0 0 1.0 +8 0 0 0 0 1.0 +9 0 0 0 0 1.0 +10 0 0 0 0 1.0 +11 0 0 0 0 1.0 +12 0 0 0 0 1.0 +13 0 0 0 0 1.0 +14 0 0 0 0 1.0 +15 0 0 0 0 1.0 +16 0 0 0 0 1.0 +17 0 0 0 0 1.0 +18 0 0 0 0 1.0 +19 0 0 0 0 1.0 +20 0 0 0 0 1.0 +21 0 0 0 0 1.0 +22 0 0 0 0 1.0 +23 0 0 0 0 1.0 +24 0 0 0 0 1.0 +25 0 0 0 0 1.0 +26 0 0 0 0 1.0 +27 0 0 0 0 1.0 +28 0 0 0 0 1.0 +29 0 0 0 0 1.0 +30 0 0 0 0 1.0 +31 0 0 0 0 1.0 +32 0 0 0 0 1.0 +33 0 0 0 0 1.0 +34 0 0 0 0 1.0 +35 0 0 0 0 1.0 +36 0 0 0 0 1.0 +37 0 0 0 0 1.0 +38 0 0 0 0 1.0 +39 0 0 0 0 1.0 +40 0 0 0 0 1.0 +41 0 0 0 0 1.0 +42 0 0 0 0 1.0 +43 0 0 0 0 1.0 +44 0 0 0 0 1.0 +45 0 0 0 0 1.0 +46 0 0 0 1 1.0 +47 0 0 0 1 1.0 +48 0 0 0 1 1.0 +49 0 0 0 1 1.0 +50 0 0 0 1 1.0 +51 0 0 0 1 1.0 +52 0 0 0 1 1.0 +53 0 0 0 1 1.0 +54 0 0 0 1 1.0 +55 0 0 0 1 1.0 +56 0 0 0 1 1.0 +57 0 0 0 1 1.0 +58 0 0 0 1 1.0 +59 0 0 0 1 1.0 +60 0 0 0 1 1.0 +61 0 0 0 1 1.0 +62 0 0 0 1 1.0 +63 0 0 0 1 1.0 +64 0 0 0 1 1.0 +65 0 0 0 1 1.0 +66 0 0 0 1 1.0 +67 0 0 0 1 1.0 +68 0 0 0 1 1.0 +69 0 0 0 1 1.0 +70 0 0 0 1 1.0 +71 0 0 0 1 1.0 +72 0 0 0 1 1.0 +73 0 0 0 1 1.0 +74 0 0 0 1 1.0 +75 0 0 0 1 1.0 +76 0 0 0 1 1.0 +77 0 0 0 1 1.0 +78 0 0 0 1 1.0 +79 0 0 0 1 1.0 +80 0 0 0 1 1.0 +81 0 0 0 1 1.0 +82 0 0 0 1 1.0 +83 0 0 0 1 1.0 +84 0 0 0 1 1.0 +85 0 0 0 1 1.0 +86 0 0 0 1 1.0 +87 0 0 0 1 1.0 +88 0 0 0 1 1.0 +89 0 0 0 1 1.0 +90 0 0 0 1 1.0 +91 0 0 0 1 1.0 +92 0 0 0 2 1.0 +93 0 0 0 2 1.0 +94 0 0 0 2 1.0 +95 0 0 0 2 1.0 +96 0 0 0 2 1.0 +97 0 0 0 2 1.0 +98 0 0 0 2 1.0 +99 0 0 0 2 1.0 +100 0 0 0 2 1.0 +101 0 0 0 2 1.0 +102 0 0 0 2 1.0 +103 0 0 0 2 1.0 +104 0 0 0 2 1.0 +105 0 0 0 2 1.0 +106 0 0 0 2 1.0 +107 0 0 0 2 1.0 +108 0 0 0 2 1.0 +109 0 0 0 2 1.0 +110 0 0 0 2 1.0 +111 0 0 0 2 1.0 +112 0 0 0 2 1.0 +113 0 0 0 2 1.0 +114 0 0 0 2 1.0 +115 0 0 0 2 1.0 +116 0 0 0 2 1.0 +117 0 0 0 2 1.0 +118 0 0 0 2 1.0 +119 0 0 0 2 1.0 +120 0 0 0 2 1.0 +121 0 0 0 2 1.0 +122 0 0 0 2 1.0 +123 0 0 0 2 1.0 +124 0 0 0 2 1.0 +125 0 0 0 2 1.0 +126 0 0 0 2 1.0 +127 0 0 0 2 1.0 +128 0 0 0 2 1.0 +129 0 0 0 2 1.0 +130 0 0 0 2 1.0 +131 0 0 0 2 1.0 +132 0 0 0 2 1.0 +133 0 0 0 2 1.0 +134 0 0 0 2 1.0 +135 0 0 0 2 1.0 +136 0 0 0 2 1.0 +137 0 0 0 2 1.0 +138 0 0 0 3 1.0 +139 0 0 0 3 1.0 +140 0 0 0 3 1.0 +141 0 0 0 3 1.0 +142 0 0 0 3 1.0 +143 0 0 0 3 1.0 +144 0 0 0 3 1.0 +145 0 0 0 3 1.0 +146 0 0 0 3 1.0 +147 0 0 0 3 1.0 +148 0 0 0 3 1.0 +149 0 0 0 3 1.0 +150 0 0 0 3 1.0 +151 0 0 0 3 1.0 +152 0 0 0 3 1.0 +153 0 0 0 3 1.0 +154 0 0 0 3 1.0 +155 0 0 0 3 1.0 +156 0 0 0 3 1.0 +157 0 0 0 3 1.0 +158 0 0 0 3 1.0 +159 0 0 0 3 1.0 +160 0 0 0 3 1.0 +161 0 0 0 3 1.0 +162 0 0 0 3 1.0 +163 0 0 0 3 1.0 +164 0 0 0 3 1.0 +165 0 0 0 3 1.0 +166 0 0 0 3 1.0 +167 0 0 0 3 1.0 +168 0 0 0 3 1.0 +169 0 0 0 3 1.0 +170 0 0 0 3 1.0 +171 0 0 0 3 1.0 +172 0 0 0 3 1.0 +173 0 0 0 3 1.0 +174 0 0 0 3 1.0 +175 0 0 0 3 1.0 +176 0 0 0 3 1.0 +177 0 0 0 3 1.0 +178 0 0 0 3 1.0 +179 0 0 0 3 1.0 +180 0 0 0 3 1.0 +181 0 0 0 3 1.0 +182 0 0 0 3 1.0 +183 0 0 0 3 1.0 +184 0 0 0 4 1.0 +185 0 0 0 4 1.0 +186 0 0 0 4 1.0 +187 0 0 0 4 1.0 +188 0 0 0 4 1.0 +189 0 0 0 4 1.0 +190 0 0 0 4 1.0 +191 0 0 0 4 1.0 +192 0 0 0 4 1.0 +193 0 0 0 4 1.0 +194 0 0 0 4 1.0 +195 0 0 0 4 1.0 +196 0 0 0 4 1.0 +197 0 0 0 4 1.0 +198 0 0 0 4 1.0 +199 0 0 0 4 1.0 +200 0 0 0 4 1.0 +201 0 0 0 4 1.0 +202 0 0 0 4 1.0 +203 0 0 0 4 1.0 +204 0 0 0 4 1.0 +205 0 0 0 4 1.0 +206 0 0 0 4 1.0 +207 0 0 0 4 1.0 +208 0 0 0 4 1.0 +209 0 0 0 4 1.0 +210 0 0 0 4 1.0 +211 0 0 0 4 1.0 +212 0 0 0 4 1.0 +213 0 0 0 4 1.0 +214 0 0 0 4 1.0 +215 0 0 0 4 1.0 +216 0 0 0 4 1.0 +217 0 0 0 4 1.0 +218 0 0 0 4 1.0 +219 0 0 0 4 1.0 +220 0 0 0 4 1.0 +221 0 0 0 4 1.0 +222 0 0 0 4 1.0 +223 0 0 0 4 1.0 +224 0 0 0 4 1.0 +225 0 0 0 4 1.0 +226 0 0 0 4 1.0 +227 0 0 0 4 1.0 +228 0 0 0 4 1.0 +229 0 0 0 4 1.0 +230 0 0 0 5 1.0 +231 0 0 0 5 1.0 +232 0 0 0 5 1.0 +233 0 0 0 5 1.0 +234 0 0 0 5 1.0 +235 0 0 0 5 1.0 +236 0 0 0 5 1.0 +237 0 0 0 5 1.0 +238 0 0 0 5 1.0 +239 0 0 0 5 1.0 +240 0 0 0 5 1.0 +241 0 0 0 5 1.0 +242 0 0 0 5 1.0 +243 0 0 0 5 1.0 +244 0 0 0 5 1.0 +245 0 0 0 5 1.0 +246 0 0 0 5 1.0 +247 0 0 0 5 1.0 +248 0 0 0 5 1.0 +249 0 0 0 5 1.0 +250 0 0 0 5 1.0 +251 0 0 0 5 1.0 +252 0 0 0 5 1.0 +253 0 0 0 5 1.0 +254 0 0 0 5 1.0 +255 0 0 0 5 1.0 +256 0 0 0 5 1.0 +257 0 0 0 5 1.0 +258 0 0 0 5 1.0 +259 0 0 0 5 1.0 +260 0 0 0 5 1.0 +261 0 0 0 5 1.0 +262 0 0 0 5 1.0 +263 0 0 0 5 1.0 +264 0 0 0 5 1.0 +265 0 0 0 5 1.0 +266 0 0 0 5 1.0 +267 0 0 0 5 1.0 +268 0 0 0 5 1.0 +269 0 0 0 5 1.0 +270 0 0 0 5 1.0 +271 0 0 0 5 1.0 +272 0 0 0 5 1.0 +273 0 0 0 5 1.0 +274 0 0 0 5 1.0 +275 0 0 0 5 1.0 +276 0 0 0 6 1.0 +277 0 0 0 6 1.0 +278 0 0 0 6 1.0 +279 0 0 0 6 1.0 +280 0 0 0 6 1.0 +281 0 0 0 6 1.0 +282 0 0 0 6 1.0 +283 0 0 0 6 1.0 +284 0 0 0 6 1.0 +285 0 0 0 6 1.0 +286 0 0 0 6 1.0 +287 0 0 0 6 1.0 +288 0 0 0 6 1.0 +289 0 0 0 6 1.0 +290 0 0 0 6 1.0 +291 0 0 0 6 1.0 +292 0 0 0 6 1.0 +293 0 0 0 6 1.0 +294 0 0 0 6 1.0 +295 0 0 0 6 1.0 +296 0 0 0 6 1.0 +297 0 0 0 6 1.0 +298 0 0 0 6 1.0 +299 0 0 0 6 1.0 +300 0 0 0 6 1.0 +301 0 0 0 6 1.0 +302 0 0 0 6 1.0 +303 0 0 0 6 1.0 +304 0 0 0 6 1.0 +305 0 0 0 6 1.0 +306 0 0 0 6 1.0 +307 0 0 0 6 1.0 +308 0 0 0 6 1.0 +309 0 0 0 6 1.0 +310 0 0 0 6 1.0 +311 0 0 0 6 1.0 +312 0 0 0 6 1.0 +313 0 0 0 6 1.0 +314 0 0 0 6 1.0 +315 0 0 0 6 1.0 +316 0 0 0 6 1.0 +317 0 0 0 6 1.0 +318 0 0 0 6 1.0 +319 0 0 0 6 1.0 +320 0 0 0 6 1.0 +321 0 0 0 6 1.0 +322 0 0 0 7 1.0 +323 0 0 0 7 1.0 +324 0 0 0 7 1.0 +325 0 0 0 7 1.0 +326 0 0 0 7 1.0 +327 0 0 0 7 1.0 +328 0 0 0 7 1.0 +329 0 0 0 7 1.0 +330 0 0 0 7 1.0 +331 0 0 0 7 1.0 +332 0 0 0 7 1.0 +333 0 0 0 7 1.0 +334 0 0 0 7 1.0 +335 0 0 0 7 1.0 +336 0 0 0 7 1.0 +337 0 0 0 7 1.0 +338 0 0 0 7 1.0 +339 0 0 0 7 1.0 +340 0 0 0 7 1.0 +341 0 0 0 7 1.0 +342 0 0 0 7 1.0 +343 0 0 0 7 1.0 +344 0 0 0 7 1.0 +345 0 0 0 7 1.0 +346 0 0 0 7 1.0 +347 0 0 0 7 1.0 +348 0 0 0 7 1.0 +349 0 0 0 7 1.0 +350 0 0 0 7 1.0 +351 0 0 0 7 1.0 +352 0 0 0 7 1.0 +353 0 0 0 7 1.0 +354 0 0 0 7 1.0 +355 0 0 0 7 1.0 +356 0 0 0 7 1.0 +357 0 0 0 7 1.0 +358 0 0 0 7 1.0 +359 0 0 0 7 1.0 +360 0 0 0 7 1.0 +361 0 0 0 7 1.0 +362 0 0 0 7 1.0 +363 0 0 0 7 1.0 +364 0 0 0 7 1.0 +365 0 0 0 7 1.0 +366 0 0 0 7 1.0 +367 0 0 0 7 1.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg new file mode 100755 index 00000000000..1a5d2889b95 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg @@ -0,0 +1,28 @@ +SOLVER= MULTIPHYSICS +MATH_PROBLEM= DIRECT +CONFIG_LIST=(configFlow.cfg, configFEA.cfg) + +MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) + +CONSERVATIVE_INTERPOLATION= NO + +READ_BINARY_RESTART= NO + +OUTER_ITER= 40 +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 + +TIME_DOMAIN = YES +TIME_ITER = 10 +TIME_STEP = 0.01 +UNST_ADJOINT_ITER= 10 +ITER_AVERAGE_OBJ= 10 + +OBJECTIVE_FUNCTION= REFERENCE_NODE + +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] + +WRT_ZONE_HIST=YES +%WRT_ZONE_CONV=YES + +% Debug: Force Zero Grid Velocity = NO +WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg new file mode 100755 index 00000000000..612823c7556 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg @@ -0,0 +1,65 @@ +% Physics -------------------------------------------------------------- % +SOLVER= ELASTICITY +% +% Time settings --------------------------------------------------------- % +TIME_DISCRE_FEA= NEWMARK_IMPLICIT +NEWMARK_BETA=0.2601 +NEWMARK_GAMMA=0.52 +% +% Optimization --------------------------------------------------------- % +FEA_ADVANCED_MODE= YES +FEA_FILENAME= element_properties.dat +GRAD_OBJFUNC_FILENAME= of_grad.dat +REFERENCE_NODE= 234 +REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) +REFERENCE_NODE_PENALTY= 1.0 +DESIGN_VARIABLE_FEA= YOUNG_MODULUS +% +% Solid properties ----------------------------------------------------- % +MATERIAL_MODEL= NEO_HOOKEAN +ELASTICITY_MODULUS= 7E8 +POISSON_RATIO= 0.35 +MATERIAL_DENSITY= 2700.0 +% +% Boundary conditions -------------------------------------------------- % +MARKER_CLAMPED= ( clamped ) +MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) +% +% Solid numerics ------------------------------------------------------- % +GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS +FORMULATION_ELASTICITY_2D= PLANE_STRESS +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= CONJUGATE_GRADIENT +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT +DISCADJ_LIN_PREC= ILU +% +% Convergence criteria ------------------------------------------------- % +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +INNER_ITER= 11 +% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. +INCREMENTAL_LOAD= NO +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_solid.dat +SOLUTION_ADJ_FILENAME= adjoint_solid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_solid.dat +RESTART_ADJ_FILENAME= adjoint_solid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= solid +VOLUME_ADJ_FILENAME= adjoint_solid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF +OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg new file mode 100755 index 00000000000..b83b3ecc111 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg @@ -0,0 +1,105 @@ +% Physics -------------------------------------------------------------- % +SOLVER= EULER +KIND_TURB_MODEL= NONE +% +% Time settings --------------------------------------------------------- % +TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER +% +% Optimization --------------------------------------------------------- % +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Compressible free-stream conditions ---------------------------------- % +MACH_NUMBER= 0.8 +AOA= 5.0 +INIT_OPTION= TD_CONDITIONS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_PRESSURE= 101325.0 +FREESTREAM_TEMPERATURE= 273.15 +REYNOLDS_LENGTH= 0.5 +% +% Fluid properties ----------------------------------------------------- % +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.87 +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.716E-5 +% +% Boundary conditions -------------------------------------------------- % +MARKER_FAR= ( farfield ) +MARKER_EULER= ( leading_edge, pressure_side, suction_side) +MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) +DEFORM_MESH= YES +% +% Post processing and monitoring --------------------------------------- % +REF_ORIGIN_MOMENT_X= -0.125 +REF_ORIGIN_MOMENT_Y= 0.00 +REF_ORIGIN_MOMENT_Z= 0.00 +REF_LENGTH= 0.5 +REF_AREA= 0.5 +MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) +MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) +MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) +% +% Common numerics settings --------------------------------------------- % +REF_DIMENSIONALIZATION= DIMENSIONAL +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 15.0 +% +% Flow numerics -------------------------------------------------------- % +CONV_NUM_METHOD_FLOW= JST +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= BCGSTAB +DISCADJ_LIN_PREC= ILU +% Multigrid +MGLEVEL= 2 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.75 +MG_DAMP_PROLONGATION= 0.75 +% +DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ERROR= 1e-8 +DEFORM_LINEAR_SOLVER_ITER= 1000 +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +DEFORM_POISSONS_RATIO= 1e6 +% +% Convergence criteria ------------------------------------------------- % +% interaction +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +% fluid +INNER_ITER= 51 +CONV_STARTITER= 0 +CONV_RESIDUAL_MINVAL= -9 +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_fluid.dat +SOLUTION_ADJ_FILENAME= adjoint_fluid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_fluid.dat +RESTART_ADJ_FILENAME= adjoint_fluid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= fluid +VOLUME_ADJ_FILENAME= adjoint_fluid +SURFACE_FILENAME= surface_fluid +SURFACE_ADJ_FILENAME= adjoint_surface_fluid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF +OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt new file mode 100644 index 00000000000..4cff5b6d58b --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt @@ -0,0 +1,9 @@ +INDEX VAL SCALE LOWER_BOUND UPPER_BOUND +0 1.001 1 0.01 100.0 +1 1 1 0.01 100.0 +2 1 1 0.01 100.0 +3 1 1 0.01 100.0 +4 1 1 0.01 100.0 +5 1 1 0.01 100.0 +6 1 1 0.01 100.0 +7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat new file mode 100644 index 00000000000..90421c13042 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat @@ -0,0 +1,369 @@ +INDEX MMOD MPROP ELPROP DV DENSITY +0 0 0 0 0 1.0 +1 0 0 0 0 1.0 +2 0 0 0 0 1.0 +3 0 0 0 0 1.0 +4 0 0 0 0 1.0 +5 0 0 0 0 1.0 +6 0 0 0 0 1.0 +7 0 0 0 0 1.0 +8 0 0 0 0 1.0 +9 0 0 0 0 1.0 +10 0 0 0 0 1.0 +11 0 0 0 0 1.0 +12 0 0 0 0 1.0 +13 0 0 0 0 1.0 +14 0 0 0 0 1.0 +15 0 0 0 0 1.0 +16 0 0 0 0 1.0 +17 0 0 0 0 1.0 +18 0 0 0 0 1.0 +19 0 0 0 0 1.0 +20 0 0 0 0 1.0 +21 0 0 0 0 1.0 +22 0 0 0 0 1.0 +23 0 0 0 0 1.0 +24 0 0 0 0 1.0 +25 0 0 0 0 1.0 +26 0 0 0 0 1.0 +27 0 0 0 0 1.0 +28 0 0 0 0 1.0 +29 0 0 0 0 1.0 +30 0 0 0 0 1.0 +31 0 0 0 0 1.0 +32 0 0 0 0 1.0 +33 0 0 0 0 1.0 +34 0 0 0 0 1.0 +35 0 0 0 0 1.0 +36 0 0 0 0 1.0 +37 0 0 0 0 1.0 +38 0 0 0 0 1.0 +39 0 0 0 0 1.0 +40 0 0 0 0 1.0 +41 0 0 0 0 1.0 +42 0 0 0 0 1.0 +43 0 0 0 0 1.0 +44 0 0 0 0 1.0 +45 0 0 0 0 1.0 +46 0 0 0 1 1.0 +47 0 0 0 1 1.0 +48 0 0 0 1 1.0 +49 0 0 0 1 1.0 +50 0 0 0 1 1.0 +51 0 0 0 1 1.0 +52 0 0 0 1 1.0 +53 0 0 0 1 1.0 +54 0 0 0 1 1.0 +55 0 0 0 1 1.0 +56 0 0 0 1 1.0 +57 0 0 0 1 1.0 +58 0 0 0 1 1.0 +59 0 0 0 1 1.0 +60 0 0 0 1 1.0 +61 0 0 0 1 1.0 +62 0 0 0 1 1.0 +63 0 0 0 1 1.0 +64 0 0 0 1 1.0 +65 0 0 0 1 1.0 +66 0 0 0 1 1.0 +67 0 0 0 1 1.0 +68 0 0 0 1 1.0 +69 0 0 0 1 1.0 +70 0 0 0 1 1.0 +71 0 0 0 1 1.0 +72 0 0 0 1 1.0 +73 0 0 0 1 1.0 +74 0 0 0 1 1.0 +75 0 0 0 1 1.0 +76 0 0 0 1 1.0 +77 0 0 0 1 1.0 +78 0 0 0 1 1.0 +79 0 0 0 1 1.0 +80 0 0 0 1 1.0 +81 0 0 0 1 1.0 +82 0 0 0 1 1.0 +83 0 0 0 1 1.0 +84 0 0 0 1 1.0 +85 0 0 0 1 1.0 +86 0 0 0 1 1.0 +87 0 0 0 1 1.0 +88 0 0 0 1 1.0 +89 0 0 0 1 1.0 +90 0 0 0 1 1.0 +91 0 0 0 1 1.0 +92 0 0 0 2 1.0 +93 0 0 0 2 1.0 +94 0 0 0 2 1.0 +95 0 0 0 2 1.0 +96 0 0 0 2 1.0 +97 0 0 0 2 1.0 +98 0 0 0 2 1.0 +99 0 0 0 2 1.0 +100 0 0 0 2 1.0 +101 0 0 0 2 1.0 +102 0 0 0 2 1.0 +103 0 0 0 2 1.0 +104 0 0 0 2 1.0 +105 0 0 0 2 1.0 +106 0 0 0 2 1.0 +107 0 0 0 2 1.0 +108 0 0 0 2 1.0 +109 0 0 0 2 1.0 +110 0 0 0 2 1.0 +111 0 0 0 2 1.0 +112 0 0 0 2 1.0 +113 0 0 0 2 1.0 +114 0 0 0 2 1.0 +115 0 0 0 2 1.0 +116 0 0 0 2 1.0 +117 0 0 0 2 1.0 +118 0 0 0 2 1.0 +119 0 0 0 2 1.0 +120 0 0 0 2 1.0 +121 0 0 0 2 1.0 +122 0 0 0 2 1.0 +123 0 0 0 2 1.0 +124 0 0 0 2 1.0 +125 0 0 0 2 1.0 +126 0 0 0 2 1.0 +127 0 0 0 2 1.0 +128 0 0 0 2 1.0 +129 0 0 0 2 1.0 +130 0 0 0 2 1.0 +131 0 0 0 2 1.0 +132 0 0 0 2 1.0 +133 0 0 0 2 1.0 +134 0 0 0 2 1.0 +135 0 0 0 2 1.0 +136 0 0 0 2 1.0 +137 0 0 0 2 1.0 +138 0 0 0 3 1.0 +139 0 0 0 3 1.0 +140 0 0 0 3 1.0 +141 0 0 0 3 1.0 +142 0 0 0 3 1.0 +143 0 0 0 3 1.0 +144 0 0 0 3 1.0 +145 0 0 0 3 1.0 +146 0 0 0 3 1.0 +147 0 0 0 3 1.0 +148 0 0 0 3 1.0 +149 0 0 0 3 1.0 +150 0 0 0 3 1.0 +151 0 0 0 3 1.0 +152 0 0 0 3 1.0 +153 0 0 0 3 1.0 +154 0 0 0 3 1.0 +155 0 0 0 3 1.0 +156 0 0 0 3 1.0 +157 0 0 0 3 1.0 +158 0 0 0 3 1.0 +159 0 0 0 3 1.0 +160 0 0 0 3 1.0 +161 0 0 0 3 1.0 +162 0 0 0 3 1.0 +163 0 0 0 3 1.0 +164 0 0 0 3 1.0 +165 0 0 0 3 1.0 +166 0 0 0 3 1.0 +167 0 0 0 3 1.0 +168 0 0 0 3 1.0 +169 0 0 0 3 1.0 +170 0 0 0 3 1.0 +171 0 0 0 3 1.0 +172 0 0 0 3 1.0 +173 0 0 0 3 1.0 +174 0 0 0 3 1.0 +175 0 0 0 3 1.0 +176 0 0 0 3 1.0 +177 0 0 0 3 1.0 +178 0 0 0 3 1.0 +179 0 0 0 3 1.0 +180 0 0 0 3 1.0 +181 0 0 0 3 1.0 +182 0 0 0 3 1.0 +183 0 0 0 3 1.0 +184 0 0 0 4 1.0 +185 0 0 0 4 1.0 +186 0 0 0 4 1.0 +187 0 0 0 4 1.0 +188 0 0 0 4 1.0 +189 0 0 0 4 1.0 +190 0 0 0 4 1.0 +191 0 0 0 4 1.0 +192 0 0 0 4 1.0 +193 0 0 0 4 1.0 +194 0 0 0 4 1.0 +195 0 0 0 4 1.0 +196 0 0 0 4 1.0 +197 0 0 0 4 1.0 +198 0 0 0 4 1.0 +199 0 0 0 4 1.0 +200 0 0 0 4 1.0 +201 0 0 0 4 1.0 +202 0 0 0 4 1.0 +203 0 0 0 4 1.0 +204 0 0 0 4 1.0 +205 0 0 0 4 1.0 +206 0 0 0 4 1.0 +207 0 0 0 4 1.0 +208 0 0 0 4 1.0 +209 0 0 0 4 1.0 +210 0 0 0 4 1.0 +211 0 0 0 4 1.0 +212 0 0 0 4 1.0 +213 0 0 0 4 1.0 +214 0 0 0 4 1.0 +215 0 0 0 4 1.0 +216 0 0 0 4 1.0 +217 0 0 0 4 1.0 +218 0 0 0 4 1.0 +219 0 0 0 4 1.0 +220 0 0 0 4 1.0 +221 0 0 0 4 1.0 +222 0 0 0 4 1.0 +223 0 0 0 4 1.0 +224 0 0 0 4 1.0 +225 0 0 0 4 1.0 +226 0 0 0 4 1.0 +227 0 0 0 4 1.0 +228 0 0 0 4 1.0 +229 0 0 0 4 1.0 +230 0 0 0 5 1.0 +231 0 0 0 5 1.0 +232 0 0 0 5 1.0 +233 0 0 0 5 1.0 +234 0 0 0 5 1.0 +235 0 0 0 5 1.0 +236 0 0 0 5 1.0 +237 0 0 0 5 1.0 +238 0 0 0 5 1.0 +239 0 0 0 5 1.0 +240 0 0 0 5 1.0 +241 0 0 0 5 1.0 +242 0 0 0 5 1.0 +243 0 0 0 5 1.0 +244 0 0 0 5 1.0 +245 0 0 0 5 1.0 +246 0 0 0 5 1.0 +247 0 0 0 5 1.0 +248 0 0 0 5 1.0 +249 0 0 0 5 1.0 +250 0 0 0 5 1.0 +251 0 0 0 5 1.0 +252 0 0 0 5 1.0 +253 0 0 0 5 1.0 +254 0 0 0 5 1.0 +255 0 0 0 5 1.0 +256 0 0 0 5 1.0 +257 0 0 0 5 1.0 +258 0 0 0 5 1.0 +259 0 0 0 5 1.0 +260 0 0 0 5 1.0 +261 0 0 0 5 1.0 +262 0 0 0 5 1.0 +263 0 0 0 5 1.0 +264 0 0 0 5 1.0 +265 0 0 0 5 1.0 +266 0 0 0 5 1.0 +267 0 0 0 5 1.0 +268 0 0 0 5 1.0 +269 0 0 0 5 1.0 +270 0 0 0 5 1.0 +271 0 0 0 5 1.0 +272 0 0 0 5 1.0 +273 0 0 0 5 1.0 +274 0 0 0 5 1.0 +275 0 0 0 5 1.0 +276 0 0 0 6 1.0 +277 0 0 0 6 1.0 +278 0 0 0 6 1.0 +279 0 0 0 6 1.0 +280 0 0 0 6 1.0 +281 0 0 0 6 1.0 +282 0 0 0 6 1.0 +283 0 0 0 6 1.0 +284 0 0 0 6 1.0 +285 0 0 0 6 1.0 +286 0 0 0 6 1.0 +287 0 0 0 6 1.0 +288 0 0 0 6 1.0 +289 0 0 0 6 1.0 +290 0 0 0 6 1.0 +291 0 0 0 6 1.0 +292 0 0 0 6 1.0 +293 0 0 0 6 1.0 +294 0 0 0 6 1.0 +295 0 0 0 6 1.0 +296 0 0 0 6 1.0 +297 0 0 0 6 1.0 +298 0 0 0 6 1.0 +299 0 0 0 6 1.0 +300 0 0 0 6 1.0 +301 0 0 0 6 1.0 +302 0 0 0 6 1.0 +303 0 0 0 6 1.0 +304 0 0 0 6 1.0 +305 0 0 0 6 1.0 +306 0 0 0 6 1.0 +307 0 0 0 6 1.0 +308 0 0 0 6 1.0 +309 0 0 0 6 1.0 +310 0 0 0 6 1.0 +311 0 0 0 6 1.0 +312 0 0 0 6 1.0 +313 0 0 0 6 1.0 +314 0 0 0 6 1.0 +315 0 0 0 6 1.0 +316 0 0 0 6 1.0 +317 0 0 0 6 1.0 +318 0 0 0 6 1.0 +319 0 0 0 6 1.0 +320 0 0 0 6 1.0 +321 0 0 0 6 1.0 +322 0 0 0 7 1.0 +323 0 0 0 7 1.0 +324 0 0 0 7 1.0 +325 0 0 0 7 1.0 +326 0 0 0 7 1.0 +327 0 0 0 7 1.0 +328 0 0 0 7 1.0 +329 0 0 0 7 1.0 +330 0 0 0 7 1.0 +331 0 0 0 7 1.0 +332 0 0 0 7 1.0 +333 0 0 0 7 1.0 +334 0 0 0 7 1.0 +335 0 0 0 7 1.0 +336 0 0 0 7 1.0 +337 0 0 0 7 1.0 +338 0 0 0 7 1.0 +339 0 0 0 7 1.0 +340 0 0 0 7 1.0 +341 0 0 0 7 1.0 +342 0 0 0 7 1.0 +343 0 0 0 7 1.0 +344 0 0 0 7 1.0 +345 0 0 0 7 1.0 +346 0 0 0 7 1.0 +347 0 0 0 7 1.0 +348 0 0 0 7 1.0 +349 0 0 0 7 1.0 +350 0 0 0 7 1.0 +351 0 0 0 7 1.0 +352 0 0 0 7 1.0 +353 0 0 0 7 1.0 +354 0 0 0 7 1.0 +355 0 0 0 7 1.0 +356 0 0 0 7 1.0 +357 0 0 0 7 1.0 +358 0 0 0 7 1.0 +359 0 0 0 7 1.0 +360 0 0 0 7 1.0 +361 0 0 0 7 1.0 +362 0 0 0 7 1.0 +363 0 0 0 7 1.0 +364 0 0 0 7 1.0 +365 0 0 0 7 1.0 +366 0 0 0 7 1.0 +367 0 0 0 7 1.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg new file mode 100755 index 00000000000..1a5d2889b95 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg @@ -0,0 +1,28 @@ +SOLVER= MULTIPHYSICS +MATH_PROBLEM= DIRECT +CONFIG_LIST=(configFlow.cfg, configFEA.cfg) + +MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) + +CONSERVATIVE_INTERPOLATION= NO + +READ_BINARY_RESTART= NO + +OUTER_ITER= 40 +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 + +TIME_DOMAIN = YES +TIME_ITER = 10 +TIME_STEP = 0.01 +UNST_ADJOINT_ITER= 10 +ITER_AVERAGE_OBJ= 10 + +OBJECTIVE_FUNCTION= REFERENCE_NODE + +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] + +WRT_ZONE_HIST=YES +%WRT_ZONE_CONV=YES + +% Debug: Force Zero Grid Velocity = NO +WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg new file mode 100755 index 00000000000..3f9b2f174c9 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg @@ -0,0 +1,65 @@ +% Physics -------------------------------------------------------------- % +SOLVER= ELASTICITY +% +% Time settings --------------------------------------------------------- % +TIME_DISCRE_FEA= NEWMARK_IMPLICIT +NEWMARK_BETA=0.2601 +NEWMARK_GAMMA=0.52 +% +% Optimization --------------------------------------------------------- % +FEA_ADVANCED_MODE= YES +FEA_FILENAME= element_properties.dat +GRAD_OBJFUNC_FILENAME= of_grad.dat +REFERENCE_NODE= 234 +REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) +REFERENCE_NODE_PENALTY= 1.0 +DESIGN_VARIABLE_FEA= YOUNG_MODULUS +% +% Solid properties ----------------------------------------------------- % +MATERIAL_MODEL= NEO_HOOKEAN +ELASTICITY_MODULUS= 7E8 +POISSON_RATIO= 0.35 +MATERIAL_DENSITY= 2700.0 +% +% Boundary conditions -------------------------------------------------- % +MARKER_CLAMPED= ( clamped ) +MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) +% +% Solid numerics ------------------------------------------------------- % +GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS +FORMULATION_ELASTICITY_2D= PLANE_STRESS +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= CONJUGATE_GRADIENT +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT +DISCADJ_LIN_PREC= ILU +% +% Convergence criteria ------------------------------------------------- % +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +INNER_ITER= 11 +% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. +INCREMENTAL_LOAD= NO +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_solid.dat +SOLUTION_ADJ_FILENAME= adjoint_solid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_solid.dat +RESTART_ADJ_FILENAME= adjoint_solid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= solid +VOLUME_ADJ_FILENAME= adjoint_solid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF +OUTPUT_FILES= RESTART_ASCII diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg new file mode 100755 index 00000000000..9f0eddf9c23 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg @@ -0,0 +1,105 @@ +% Physics -------------------------------------------------------------- % +SOLVER= EULER +KIND_TURB_MODEL= NONE +% +% Time settings --------------------------------------------------------- % +TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER +% +% Optimization --------------------------------------------------------- % +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Compressible free-stream conditions ---------------------------------- % +MACH_NUMBER= 0.8 +AOA= 5.0 +INIT_OPTION= TD_CONDITIONS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_PRESSURE= 101325.0 +FREESTREAM_TEMPERATURE= 273.15 +REYNOLDS_LENGTH= 0.5 +% +% Fluid properties ----------------------------------------------------- % +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.87 +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.716E-5 +% +% Boundary conditions -------------------------------------------------- % +MARKER_FAR= ( farfield ) +MARKER_EULER= ( leading_edge, pressure_side, suction_side) +MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) +DEFORM_MESH= YES +% +% Post processing and monitoring --------------------------------------- % +REF_ORIGIN_MOMENT_X= -0.125 +REF_ORIGIN_MOMENT_Y= 0.00 +REF_ORIGIN_MOMENT_Z= 0.00 +REF_LENGTH= 0.5 +REF_AREA= 0.5 +MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) +MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) +MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) +% +% Common numerics settings --------------------------------------------- % +REF_DIMENSIONALIZATION= DIMENSIONAL +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 15.0 +% +% Flow numerics -------------------------------------------------------- % +CONV_NUM_METHOD_FLOW= JST +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= BCGSTAB +DISCADJ_LIN_PREC= ILU +% Multigrid +MGLEVEL= 2 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.75 +MG_DAMP_PROLONGATION= 0.75 +% +DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ERROR= 1e-8 +DEFORM_LINEAR_SOLVER_ITER= 1000 +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +DEFORM_POISSONS_RATIO= 1e6 +% +% Convergence criteria ------------------------------------------------- % +% interaction +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +% fluid +INNER_ITER= 51 +CONV_STARTITER= 0 +CONV_RESIDUAL_MINVAL= -9 +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= ../../Airfoil_2d/mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_fluid.dat +SOLUTION_ADJ_FILENAME= adjoint_fluid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_fluid.dat +RESTART_ADJ_FILENAME= adjoint_fluid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= fluid +VOLUME_ADJ_FILENAME= adjoint_fluid +SURFACE_FILENAME= surface_fluid +SURFACE_ADJ_FILENAME= adjoint_surface_fluid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF +OUTPUT_FILES= RESTART_ASCII diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt new file mode 100644 index 00000000000..3c691471847 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt @@ -0,0 +1,9 @@ +INDEX VAL SCALE LOWER_BOUND UPPER_BOUND +0 1 1 0.01 100.0 +1 1 1 0.01 100.0 +2 1 1 0.01 100.0 +3 1 1 0.01 100.0 +4 1 1 0.01 100.0 +5 1 1 0.01 100.0 +6 1 1 0.01 100.0 +7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat new file mode 100644 index 00000000000..90421c13042 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat @@ -0,0 +1,369 @@ +INDEX MMOD MPROP ELPROP DV DENSITY +0 0 0 0 0 1.0 +1 0 0 0 0 1.0 +2 0 0 0 0 1.0 +3 0 0 0 0 1.0 +4 0 0 0 0 1.0 +5 0 0 0 0 1.0 +6 0 0 0 0 1.0 +7 0 0 0 0 1.0 +8 0 0 0 0 1.0 +9 0 0 0 0 1.0 +10 0 0 0 0 1.0 +11 0 0 0 0 1.0 +12 0 0 0 0 1.0 +13 0 0 0 0 1.0 +14 0 0 0 0 1.0 +15 0 0 0 0 1.0 +16 0 0 0 0 1.0 +17 0 0 0 0 1.0 +18 0 0 0 0 1.0 +19 0 0 0 0 1.0 +20 0 0 0 0 1.0 +21 0 0 0 0 1.0 +22 0 0 0 0 1.0 +23 0 0 0 0 1.0 +24 0 0 0 0 1.0 +25 0 0 0 0 1.0 +26 0 0 0 0 1.0 +27 0 0 0 0 1.0 +28 0 0 0 0 1.0 +29 0 0 0 0 1.0 +30 0 0 0 0 1.0 +31 0 0 0 0 1.0 +32 0 0 0 0 1.0 +33 0 0 0 0 1.0 +34 0 0 0 0 1.0 +35 0 0 0 0 1.0 +36 0 0 0 0 1.0 +37 0 0 0 0 1.0 +38 0 0 0 0 1.0 +39 0 0 0 0 1.0 +40 0 0 0 0 1.0 +41 0 0 0 0 1.0 +42 0 0 0 0 1.0 +43 0 0 0 0 1.0 +44 0 0 0 0 1.0 +45 0 0 0 0 1.0 +46 0 0 0 1 1.0 +47 0 0 0 1 1.0 +48 0 0 0 1 1.0 +49 0 0 0 1 1.0 +50 0 0 0 1 1.0 +51 0 0 0 1 1.0 +52 0 0 0 1 1.0 +53 0 0 0 1 1.0 +54 0 0 0 1 1.0 +55 0 0 0 1 1.0 +56 0 0 0 1 1.0 +57 0 0 0 1 1.0 +58 0 0 0 1 1.0 +59 0 0 0 1 1.0 +60 0 0 0 1 1.0 +61 0 0 0 1 1.0 +62 0 0 0 1 1.0 +63 0 0 0 1 1.0 +64 0 0 0 1 1.0 +65 0 0 0 1 1.0 +66 0 0 0 1 1.0 +67 0 0 0 1 1.0 +68 0 0 0 1 1.0 +69 0 0 0 1 1.0 +70 0 0 0 1 1.0 +71 0 0 0 1 1.0 +72 0 0 0 1 1.0 +73 0 0 0 1 1.0 +74 0 0 0 1 1.0 +75 0 0 0 1 1.0 +76 0 0 0 1 1.0 +77 0 0 0 1 1.0 +78 0 0 0 1 1.0 +79 0 0 0 1 1.0 +80 0 0 0 1 1.0 +81 0 0 0 1 1.0 +82 0 0 0 1 1.0 +83 0 0 0 1 1.0 +84 0 0 0 1 1.0 +85 0 0 0 1 1.0 +86 0 0 0 1 1.0 +87 0 0 0 1 1.0 +88 0 0 0 1 1.0 +89 0 0 0 1 1.0 +90 0 0 0 1 1.0 +91 0 0 0 1 1.0 +92 0 0 0 2 1.0 +93 0 0 0 2 1.0 +94 0 0 0 2 1.0 +95 0 0 0 2 1.0 +96 0 0 0 2 1.0 +97 0 0 0 2 1.0 +98 0 0 0 2 1.0 +99 0 0 0 2 1.0 +100 0 0 0 2 1.0 +101 0 0 0 2 1.0 +102 0 0 0 2 1.0 +103 0 0 0 2 1.0 +104 0 0 0 2 1.0 +105 0 0 0 2 1.0 +106 0 0 0 2 1.0 +107 0 0 0 2 1.0 +108 0 0 0 2 1.0 +109 0 0 0 2 1.0 +110 0 0 0 2 1.0 +111 0 0 0 2 1.0 +112 0 0 0 2 1.0 +113 0 0 0 2 1.0 +114 0 0 0 2 1.0 +115 0 0 0 2 1.0 +116 0 0 0 2 1.0 +117 0 0 0 2 1.0 +118 0 0 0 2 1.0 +119 0 0 0 2 1.0 +120 0 0 0 2 1.0 +121 0 0 0 2 1.0 +122 0 0 0 2 1.0 +123 0 0 0 2 1.0 +124 0 0 0 2 1.0 +125 0 0 0 2 1.0 +126 0 0 0 2 1.0 +127 0 0 0 2 1.0 +128 0 0 0 2 1.0 +129 0 0 0 2 1.0 +130 0 0 0 2 1.0 +131 0 0 0 2 1.0 +132 0 0 0 2 1.0 +133 0 0 0 2 1.0 +134 0 0 0 2 1.0 +135 0 0 0 2 1.0 +136 0 0 0 2 1.0 +137 0 0 0 2 1.0 +138 0 0 0 3 1.0 +139 0 0 0 3 1.0 +140 0 0 0 3 1.0 +141 0 0 0 3 1.0 +142 0 0 0 3 1.0 +143 0 0 0 3 1.0 +144 0 0 0 3 1.0 +145 0 0 0 3 1.0 +146 0 0 0 3 1.0 +147 0 0 0 3 1.0 +148 0 0 0 3 1.0 +149 0 0 0 3 1.0 +150 0 0 0 3 1.0 +151 0 0 0 3 1.0 +152 0 0 0 3 1.0 +153 0 0 0 3 1.0 +154 0 0 0 3 1.0 +155 0 0 0 3 1.0 +156 0 0 0 3 1.0 +157 0 0 0 3 1.0 +158 0 0 0 3 1.0 +159 0 0 0 3 1.0 +160 0 0 0 3 1.0 +161 0 0 0 3 1.0 +162 0 0 0 3 1.0 +163 0 0 0 3 1.0 +164 0 0 0 3 1.0 +165 0 0 0 3 1.0 +166 0 0 0 3 1.0 +167 0 0 0 3 1.0 +168 0 0 0 3 1.0 +169 0 0 0 3 1.0 +170 0 0 0 3 1.0 +171 0 0 0 3 1.0 +172 0 0 0 3 1.0 +173 0 0 0 3 1.0 +174 0 0 0 3 1.0 +175 0 0 0 3 1.0 +176 0 0 0 3 1.0 +177 0 0 0 3 1.0 +178 0 0 0 3 1.0 +179 0 0 0 3 1.0 +180 0 0 0 3 1.0 +181 0 0 0 3 1.0 +182 0 0 0 3 1.0 +183 0 0 0 3 1.0 +184 0 0 0 4 1.0 +185 0 0 0 4 1.0 +186 0 0 0 4 1.0 +187 0 0 0 4 1.0 +188 0 0 0 4 1.0 +189 0 0 0 4 1.0 +190 0 0 0 4 1.0 +191 0 0 0 4 1.0 +192 0 0 0 4 1.0 +193 0 0 0 4 1.0 +194 0 0 0 4 1.0 +195 0 0 0 4 1.0 +196 0 0 0 4 1.0 +197 0 0 0 4 1.0 +198 0 0 0 4 1.0 +199 0 0 0 4 1.0 +200 0 0 0 4 1.0 +201 0 0 0 4 1.0 +202 0 0 0 4 1.0 +203 0 0 0 4 1.0 +204 0 0 0 4 1.0 +205 0 0 0 4 1.0 +206 0 0 0 4 1.0 +207 0 0 0 4 1.0 +208 0 0 0 4 1.0 +209 0 0 0 4 1.0 +210 0 0 0 4 1.0 +211 0 0 0 4 1.0 +212 0 0 0 4 1.0 +213 0 0 0 4 1.0 +214 0 0 0 4 1.0 +215 0 0 0 4 1.0 +216 0 0 0 4 1.0 +217 0 0 0 4 1.0 +218 0 0 0 4 1.0 +219 0 0 0 4 1.0 +220 0 0 0 4 1.0 +221 0 0 0 4 1.0 +222 0 0 0 4 1.0 +223 0 0 0 4 1.0 +224 0 0 0 4 1.0 +225 0 0 0 4 1.0 +226 0 0 0 4 1.0 +227 0 0 0 4 1.0 +228 0 0 0 4 1.0 +229 0 0 0 4 1.0 +230 0 0 0 5 1.0 +231 0 0 0 5 1.0 +232 0 0 0 5 1.0 +233 0 0 0 5 1.0 +234 0 0 0 5 1.0 +235 0 0 0 5 1.0 +236 0 0 0 5 1.0 +237 0 0 0 5 1.0 +238 0 0 0 5 1.0 +239 0 0 0 5 1.0 +240 0 0 0 5 1.0 +241 0 0 0 5 1.0 +242 0 0 0 5 1.0 +243 0 0 0 5 1.0 +244 0 0 0 5 1.0 +245 0 0 0 5 1.0 +246 0 0 0 5 1.0 +247 0 0 0 5 1.0 +248 0 0 0 5 1.0 +249 0 0 0 5 1.0 +250 0 0 0 5 1.0 +251 0 0 0 5 1.0 +252 0 0 0 5 1.0 +253 0 0 0 5 1.0 +254 0 0 0 5 1.0 +255 0 0 0 5 1.0 +256 0 0 0 5 1.0 +257 0 0 0 5 1.0 +258 0 0 0 5 1.0 +259 0 0 0 5 1.0 +260 0 0 0 5 1.0 +261 0 0 0 5 1.0 +262 0 0 0 5 1.0 +263 0 0 0 5 1.0 +264 0 0 0 5 1.0 +265 0 0 0 5 1.0 +266 0 0 0 5 1.0 +267 0 0 0 5 1.0 +268 0 0 0 5 1.0 +269 0 0 0 5 1.0 +270 0 0 0 5 1.0 +271 0 0 0 5 1.0 +272 0 0 0 5 1.0 +273 0 0 0 5 1.0 +274 0 0 0 5 1.0 +275 0 0 0 5 1.0 +276 0 0 0 6 1.0 +277 0 0 0 6 1.0 +278 0 0 0 6 1.0 +279 0 0 0 6 1.0 +280 0 0 0 6 1.0 +281 0 0 0 6 1.0 +282 0 0 0 6 1.0 +283 0 0 0 6 1.0 +284 0 0 0 6 1.0 +285 0 0 0 6 1.0 +286 0 0 0 6 1.0 +287 0 0 0 6 1.0 +288 0 0 0 6 1.0 +289 0 0 0 6 1.0 +290 0 0 0 6 1.0 +291 0 0 0 6 1.0 +292 0 0 0 6 1.0 +293 0 0 0 6 1.0 +294 0 0 0 6 1.0 +295 0 0 0 6 1.0 +296 0 0 0 6 1.0 +297 0 0 0 6 1.0 +298 0 0 0 6 1.0 +299 0 0 0 6 1.0 +300 0 0 0 6 1.0 +301 0 0 0 6 1.0 +302 0 0 0 6 1.0 +303 0 0 0 6 1.0 +304 0 0 0 6 1.0 +305 0 0 0 6 1.0 +306 0 0 0 6 1.0 +307 0 0 0 6 1.0 +308 0 0 0 6 1.0 +309 0 0 0 6 1.0 +310 0 0 0 6 1.0 +311 0 0 0 6 1.0 +312 0 0 0 6 1.0 +313 0 0 0 6 1.0 +314 0 0 0 6 1.0 +315 0 0 0 6 1.0 +316 0 0 0 6 1.0 +317 0 0 0 6 1.0 +318 0 0 0 6 1.0 +319 0 0 0 6 1.0 +320 0 0 0 6 1.0 +321 0 0 0 6 1.0 +322 0 0 0 7 1.0 +323 0 0 0 7 1.0 +324 0 0 0 7 1.0 +325 0 0 0 7 1.0 +326 0 0 0 7 1.0 +327 0 0 0 7 1.0 +328 0 0 0 7 1.0 +329 0 0 0 7 1.0 +330 0 0 0 7 1.0 +331 0 0 0 7 1.0 +332 0 0 0 7 1.0 +333 0 0 0 7 1.0 +334 0 0 0 7 1.0 +335 0 0 0 7 1.0 +336 0 0 0 7 1.0 +337 0 0 0 7 1.0 +338 0 0 0 7 1.0 +339 0 0 0 7 1.0 +340 0 0 0 7 1.0 +341 0 0 0 7 1.0 +342 0 0 0 7 1.0 +343 0 0 0 7 1.0 +344 0 0 0 7 1.0 +345 0 0 0 7 1.0 +346 0 0 0 7 1.0 +347 0 0 0 7 1.0 +348 0 0 0 7 1.0 +349 0 0 0 7 1.0 +350 0 0 0 7 1.0 +351 0 0 0 7 1.0 +352 0 0 0 7 1.0 +353 0 0 0 7 1.0 +354 0 0 0 7 1.0 +355 0 0 0 7 1.0 +356 0 0 0 7 1.0 +357 0 0 0 7 1.0 +358 0 0 0 7 1.0 +359 0 0 0 7 1.0 +360 0 0 0 7 1.0 +361 0 0 0 7 1.0 +362 0 0 0 7 1.0 +363 0 0 0 7 1.0 +364 0 0 0 7 1.0 +365 0 0 0 7 1.0 +366 0 0 0 7 1.0 +367 0 0 0 7 1.0 From 1fc2345fc20b7b0cdf9df6398747c26b931600c7 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 12 Apr 2021 00:40:02 +0100 Subject: [PATCH 026/192] tidy up --- .../src/iteration/CDiscAdjFEAIteration.cpp | 81 ------------------- 1 file changed, 81 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 54d9a9456a6..c239f706355 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -173,87 +173,6 @@ void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration } } -// void CDiscAdjFEAIteration::SetRecording(COutput* output, CIntegration**** integration, CGeometry**** geometry, -// CSolver***** solver, CNumerics****** numerics, CConfig** config, -// CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, -// CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, -// unsigned short kind_recording) { -// unsigned long InnerIter = config[ZONE_0]->GetInnerIter(); -// unsigned long TimeIter = config[val_iZone]->GetTimeIter(), DirectTimeIter; -// bool dynamic = (config[val_iZone]->GetTime_Domain()); - -// DirectTimeIter = 0; -// if (dynamic) { -// DirectTimeIter = SU2_TYPE::Int(config[val_iZone]->GetUnst_AdjointIter()) - SU2_TYPE::Int(TimeIter) - 1; -// } - -// /*--- Reset the tape ---*/ - -// AD::Reset(); - -// /*--- We only need to reset the indices if the current recording is different from the recording we want to have ---*/ - -// if (CurrentRecording != kind_recording && (CurrentRecording != NONE)) { -// solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->SetRecording(geometry[val_iZone][val_iInst][MESH_0], -// config[val_iZone]); - -// /*--- Clear indices of coupling variables ---*/ - -// SetDependencies(solver, geometry, numerics, config, val_iZone, val_iInst, SOLUTION_AND_MESH); - -// /*--- Run one iteration while tape is passive - this clears all indices ---*/ - -// fem_iteration->Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, -// FFDBox, val_iZone, val_iInst, false); -// } - -// /*--- Prepare for recording ---*/ - -// solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->SetRecording(geometry[val_iZone][val_iInst][MESH_0], -// config[val_iZone]); - -// /*--- Start the recording of all operations ---*/ - -// AD::StartRecording(); - -// /*--- Register FEA variables ---*/ - -// RegisterInput(solver, geometry, config, val_iZone, val_iInst, kind_recording); - -// /*--- Compute coupling or update the geometry ---*/ - -// SetDependencies(solver, geometry, numerics, config, val_iZone, val_iInst, kind_recording); - -// /*--- Set the correct direct iteration number ---*/ - -// if (dynamic) { -// config[val_iZone]->SetTimeIter(DirectTimeIter); -// } - -// /*--- Run the direct iteration ---*/ - -// fem_iteration->Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, -// FFDBox, val_iZone, val_iInst, false); - -// config[val_iZone]->SetTimeIter(TimeIter); - -// /*--- Register structural variables and objective function as output ---*/ - -// RegisterOutput(solver, geometry, config, val_iZone, val_iInst); - -// /*--- Stop the recording ---*/ - -// AD::StopRecording(); - -// /*--- Set the recording status ---*/ - -// CurrentRecording = kind_recording; - -// /* --- Reset the number of the internal iterations---*/ - -// config[ZONE_0]->SetInnerIter(InnerIter); -// } - void CDiscAdjFEAIteration::SetRecording(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short val_iZone, unsigned short val_iInst, unsigned short kind_recording) { From d9121324804ce5dfef0e74378a8fc4ebef639e66 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 13 Apr 2021 20:56:33 +0100 Subject: [PATCH 027/192] update time averaging values - add for new time or replace for existing time iteration --- SU2_CFD/include/output/tools/CWindowingTools.hpp | 5 +++-- SU2_CFD/src/output/tools/CWindowingTools.cpp | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/include/output/tools/CWindowingTools.hpp b/SU2_CFD/include/output/tools/CWindowingTools.hpp index 89bb350771d..e1e6613f629 100644 --- a/SU2_CFD/include/output/tools/CWindowingTools.hpp +++ b/SU2_CFD/include/output/tools/CWindowingTools.hpp @@ -66,8 +66,9 @@ class CWindowingTools{ class CWindowedAverage:CWindowingTools{ private: - su2double val; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ - std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ + su2double val; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ + std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ + std::vector winTimeIter; /*!< \brief Vector of windowed time iterations.*/ public: CWindowedAverage(); diff --git a/SU2_CFD/src/output/tools/CWindowingTools.cpp b/SU2_CFD/src/output/tools/CWindowingTools.cpp index ae85afda06c..7f5352ce0c7 100644 --- a/SU2_CFD/src/output/tools/CWindowingTools.cpp +++ b/SU2_CFD/src/output/tools/CWindowingTools.cpp @@ -74,7 +74,20 @@ void CWindowedAverage::Reset(){ } void CWindowedAverage::addValue(su2double valIn, unsigned long curTimeIter,unsigned long startIter){ - if(curTimeIter >= startIter)values.push_back(valIn); + if(curTimeIter >= startIter) { + + /*--- Remove last element if this is still the same time iteration ---*/ + if (winTimeIter.size() > 0) { + if (winTimeIter[winTimeIter.size()-1] == curTimeIter) { + values.pop_back(); + winTimeIter.pop_back(); + } + } + + /*--- Update time iteration and value ---*/ + winTimeIter.push_back(curTimeIter); + values.push_back(valIn); + } } su2double CWindowedAverage::WindowedUpdate(WINDOW_FUNCTION windowId){ From 04cc74b87310f8c43aab4b201a4d9aee0f19ff69 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 13 Apr 2021 21:01:45 +0100 Subject: [PATCH 028/192] Revert "update time averaging values - add for new time or replace for existing time iteration" This reverts commit d9121324804ce5dfef0e74378a8fc4ebef639e66. --- SU2_CFD/include/output/tools/CWindowingTools.hpp | 5 ++--- SU2_CFD/src/output/tools/CWindowingTools.cpp | 15 +-------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/SU2_CFD/include/output/tools/CWindowingTools.hpp b/SU2_CFD/include/output/tools/CWindowingTools.hpp index e1e6613f629..89bb350771d 100644 --- a/SU2_CFD/include/output/tools/CWindowingTools.hpp +++ b/SU2_CFD/include/output/tools/CWindowingTools.hpp @@ -66,9 +66,8 @@ class CWindowingTools{ class CWindowedAverage:CWindowingTools{ private: - su2double val; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ - std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ - std::vector winTimeIter; /*!< \brief Vector of windowed time iterations.*/ + su2double val; /*!< \brief Value of the windowed-time average (of the instantaneous output) from starting time to the current time iteration. */ + std::vector values; /*!< \brief Vector of instantatneous output values from starting time to the current time iteration.*/ public: CWindowedAverage(); diff --git a/SU2_CFD/src/output/tools/CWindowingTools.cpp b/SU2_CFD/src/output/tools/CWindowingTools.cpp index 7f5352ce0c7..ae85afda06c 100644 --- a/SU2_CFD/src/output/tools/CWindowingTools.cpp +++ b/SU2_CFD/src/output/tools/CWindowingTools.cpp @@ -74,20 +74,7 @@ void CWindowedAverage::Reset(){ } void CWindowedAverage::addValue(su2double valIn, unsigned long curTimeIter,unsigned long startIter){ - if(curTimeIter >= startIter) { - - /*--- Remove last element if this is still the same time iteration ---*/ - if (winTimeIter.size() > 0) { - if (winTimeIter[winTimeIter.size()-1] == curTimeIter) { - values.pop_back(); - winTimeIter.pop_back(); - } - } - - /*--- Update time iteration and value ---*/ - winTimeIter.push_back(curTimeIter); - values.push_back(valIn); - } + if(curTimeIter >= startIter)values.push_back(valIn); } su2double CWindowedAverage::WindowedUpdate(WINDOW_FUNCTION windowId){ From 425c87e905c20cd31b9bbba301c0b2998f86fff5 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Thu, 15 Apr 2021 10:27:37 +0200 Subject: [PATCH 029/192] Update nodal solution for all points --- SU2_PY/SU2_Nastran/pysu2_nastran.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/SU2_PY/SU2_Nastran/pysu2_nastran.py b/SU2_PY/SU2_Nastran/pysu2_nastran.py index 6c9aebe1d2c..d8f37de6f6d 100644 --- a/SU2_PY/SU2_Nastran/pysu2_nastran.py +++ b/SU2_PY/SU2_Nastran/pysu2_nastran.py @@ -722,7 +722,7 @@ def __computeInterfacePosVel(self, initialize): Y_disp = self.Uy.dot(self.q) Z_disp = self.Uz.dot(self.q) - for iPoint in range(len(self.node)): + for iPoint in range(self.nPoint): coord0 = self.node[iPoint].GetCoord0() self.node[iPoint].SetCoord((X_disp[iPoint]+coord0[0],Y_disp[iPoint]+coord0[1],Z_disp[iPoint]+coord0[2])) self.node[iPoint].SetVel((X_vel[iPoint],Y_vel[iPoint],Z_vel[iPoint])) @@ -935,11 +935,7 @@ def updateSolution(self): self.__reset(self.qddot) self.__reset(self.a) - makerID = list(self.markers.keys()) - makerID = makerID[0] - nodeList = self.markers[makerID] - - for iPoint in nodeList: + for iPoint in range(self.nPoint): self.node[iPoint].updateCoordVel() From 12345a6313fd77f8eae188228a28dfdc8a0a0aed Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 18 Apr 2021 22:40:31 +0100 Subject: [PATCH 030/192] build fixes --- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 6 +++--- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 2 -- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 455a0dbc812..d60c2cff329 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -157,7 +157,7 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr for (auto iMesh=0; iMesh<=config[iZone]->GetnMGLevels();iMesh++) { /*--- If negative iteration number, set default ---*/ if (Direct_Iter - 2 < 0) { - for(auto iPoint=0; iPointGetnPoint();iPoint++) { + for(auto iPoint=0ul; iPointGetnPoint();iPoint++) { geometry[iZone][iInst][iMesh]->nodes->SetVolume(iPoint,0.0); } } @@ -344,7 +344,7 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolver***** solver, CConfig** config, unsigned short iZone, unsigned short iInst, int DirectIter) { - unsigned short iMesh; + bool heat = config[iZone]->GetWeakly_Coupled_Heat(); auto solvers = solver[iZone][iInst]; @@ -366,7 +366,7 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv if (rank == MASTER_NODE && iZone == ZONE_0) cout << " Setting freestream conditions at direct iteration " << DirectIter << "." << endl; - for (auto iMesh = 0; iMesh <= config[iZone]->GetnMGLevels(); iMesh++) { + for (auto iMesh = 0u; iMesh <= config[iZone]->GetnMGLevels(); iMesh++) { solvers[iMesh][FLOW_SOL]->SetFreeStream_Solution(config[iZone]); solvers[iMesh][FLOW_SOL]->Preprocessing(geometry[iZone][iInst][iMesh], solvers[iMesh], config[iZone], iMesh, DirectIter, RUNTIME_FLOW_SYS, false); diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 69c97380968..f0c557e7ede 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -596,11 +596,9 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo // Temporary Output if (config->GetAdvanced_FEAElementBased()) { if (rank == MASTER_NODE) { - unsigned short iVar; /*--- Header of the temporary dv sensitivity output file ---*/ ofstream myfile2_res; - bool outputDVFEA = false; switch (config->GetDV_FEA()) { case YOUNG_MODULUS: From 191a1d09608d8db99f7521ad51de1fe14e7ae924 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 18 Apr 2021 23:07:04 +0100 Subject: [PATCH 031/192] more build fixes --- SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp | 3 +++ SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index b5feeb7b695..81ae8ae11fc 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -489,6 +489,9 @@ void CDiscAdjMultizoneDriver::Run() { case DISC_ADJ_FEM: IDX_SOL = ADJFEA_SOL; break; + default: + SU2_MPI::Error("Chosen discrete adjoint solver not yet supported for calculation of sensitivities", CURRENT_FUNCTION); + break; } su2double Sensitivity; diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index c239f706355..fa0c587440a 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -159,7 +159,6 @@ void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { - bool dynamic = (config[val_iZone]->GetTime_Domain()); /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ From 4191e4521157001faded0cbe7ada5fc8e8ad3d04 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 18 Apr 2021 23:26:10 +0100 Subject: [PATCH 032/192] try build fix - initialize with no solver --- SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 81ae8ae11fc..90001a72d96 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -475,7 +475,7 @@ void CDiscAdjMultizoneDriver::Run() { auto solvers = solver_container[iZone][INST_0][MESH_0]; auto geometry = geometry_container[iZone][INST_0][MESH_0]; - int IDX_SOL; + int IDX_SOL = NO_SOLVER; switch (config_container[iZone]->GetKind_Solver()) { case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: From b35208ec075061a68fa6d79774745964845086c3 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 19 Apr 2021 01:50:42 +0100 Subject: [PATCH 033/192] build fix - add missing reference --- SU2_CFD/src/python_wrapper_structure.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 97237e680a7..f7f8499963a 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -806,6 +806,22 @@ void CDriver::SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned long iV } +void CDriver::SetSourceTerm_VelAdjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, + passivedouble val_AdjointY, passivedouble val_AdjointZ) { + + unsigned long iPoint; + + CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJFEA_SOL]; + CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; + iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); + + solver->GetNodes()->SetSourceTerm_VelAdjoint(iPoint, 0, val_AdjointX); + solver->GetNodes()->SetSourceTerm_VelAdjoint(iPoint, 1, val_AdjointY); + if (geometry->GetnDim() == 3) + solver->GetNodes()->SetSourceTerm_VelAdjoint(iPoint, 2, val_AdjointZ); + +} + //////////////////////////////////////////////////////////////////////////////// /* Functions related to mesh deformation */ //////////////////////////////////////////////////////////////////////////////// From 0986437c90edbb75a44ceff854aa40834ec89f10 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 19 Apr 2021 21:12:31 +0100 Subject: [PATCH 034/192] remove separate predict velocity call --- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index fa0c587440a..a6e74f4e0df 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -304,7 +304,6 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge if (fsi) { /*--- Set relation between solution and predicted displacements, which are the transferred ones. ---*/ dir_solver->PredictStruct_Displacement(structural_geometry, config[iZone]); - if (config[iZone]->GetTime_Domain()) dir_solver->PredictStruct_Velocity(structural_geometry, config[iZone]); } /*--- Topology optimization dependencies. ---*/ From a9c17de871e5e89a46a224b37e234fd3453125be Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 21 Apr 2021 01:13:49 +0100 Subject: [PATCH 035/192] fixes for disc adj cht reg test --- SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp | 2 +- SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp | 2 +- SU2_CFD/include/solvers/CSolver.hpp | 8 -------- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 2 +- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 2 +- SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp | 4 ++-- 8 files changed, 8 insertions(+), 16 deletions(-) diff --git a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp index 48c29f76dc7..c35e0f4951c 100644 --- a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp @@ -181,7 +181,7 @@ class CDiscAdjFEASolver final : public CSolver { * \param[in] geometry - The geometrical definition of the problem. * \param[in] config - The particular config. */ - void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config) override; + void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) override; /*! * \brief Extract and set the geometrical sensitivity. diff --git a/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp b/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp index d7ba9d80b75..e120ed5cbf9 100644 --- a/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjMeshSolver.hpp @@ -90,7 +90,7 @@ class CDiscAdjMeshSolver final : public CSolver { * \param[in] geometry - The geometrical definition of the problem. * \param[in] config - The particular config. */ - void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config) override; + void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) override; /*! * \brief Extract and set the geometrical sensitivity. diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 98c1f553fca..31193cf40d3 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3605,14 +3605,6 @@ class CSolver { */ inline virtual void SetAdjoint_Output(CGeometry *geometry, CConfig *config){} - /*! - * \brief A virtual member. - * \param[in] geometry - The geometrical definition of the problem. - * \param[in] solver_container - The solver container holding all solutions. - * \param[in] config - The particular config. - */ - inline virtual void ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config){} - /*! * \brief A virtual member. * \param[in] geometry - The geometrical definition of the problem. diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index a6e74f4e0df..d9e92d1a7c7 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -163,7 +163,7 @@ void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Solution(geometry[val_iZone][val_iInst][MESH_0], - config[val_iZone]); + config[val_iZone], CrossTerm); solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Variables(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone]); diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index d60c2cff329..c658955b8d5 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -401,7 +401,7 @@ void CDiscAdjFluidIteration::Iterate(COutput* output, CIntegration**** integrati /*--- If mesh deformation defined in config, extract here as well ---*/ if (config[iZone]->GetDeform_Mesh()) { - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone]); + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); } diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 3f6159cbdc0..5258293b110 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -171,7 +171,7 @@ void CDiscAdjHeatIteration::Iterate(COutput* output, CIntegration**** integratio CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution(geometry[val_iZone][val_iInst][MESH_0], - config[val_iZone]); + config[val_iZone], CrossTerm); } void CDiscAdjHeatIteration::InitializeAdjoint(CSolver***** solver, CGeometry**** geometry, CConfig** config, diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index f0c557e7ede..1fb642bbe3a 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -290,7 +290,7 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ } -void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config){ +void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ const bool dynamic = config->GetTime_Domain(); const bool multizone = config->GetMultizone_Problem(); diff --git a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp index 90dbc69d2d9..2995b97b3a5 100644 --- a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp @@ -119,7 +119,7 @@ void CDiscAdjMeshSolver::RegisterVariables(CGeometry *geometry, CConfig *config, SU2_OMP_BARRIER } -void CDiscAdjMeshSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config){ +void CDiscAdjMeshSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ /*--- Extract the sensitivities of the mesh coordinates ---*/ @@ -169,7 +169,7 @@ void CDiscAdjMeshSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CS const auto eps = config->GetAdjSharp_LimiterCoeff()*config->GetRefElemLength(); /*--- Extract the sensitivities ---*/ - ExtractAdjoint_Solution(geometry, config); + ExtractAdjoint_Solution(geometry, config, false); /*--- Extract the adjoint variables: sensitivities of the boundary displacements ---*/ ExtractAdjoint_Variables(geometry, config); From 1c171f39678e32a6ac0bf4129bf517446126b065 Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 21 Apr 2021 21:27:34 +0100 Subject: [PATCH 036/192] update test to match zero disp for negative time steps --- TestCases/serial_regression_AD.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/serial_regression_AD.py b/TestCases/serial_regression_AD.py index 2595dc80540..6b24acb58da 100644 --- a/TestCases/serial_regression_AD.py +++ b/TestCases/serial_regression_AD.py @@ -210,7 +210,7 @@ def main(): unst_deforming_naca0012.cfg_dir = "disc_adj_euler/naca0012_pitching_def" unst_deforming_naca0012.cfg_file = "inv_NACA0012_pitching_deform_ad.cfg" unst_deforming_naca0012.test_iter = 4 - unst_deforming_naca0012.test_vals = [-1.864178, -1.742176, 1090.300000, 0.000006] + unst_deforming_naca0012.test_vals = [-1.958006, -1.841808, 1081.700000, 0.000004] unst_deforming_naca0012.su2_exec = "SU2_CFD_AD" unst_deforming_naca0012.timeout = 1600 unst_deforming_naca0012.tol = 0.00001 From 7eb05f95a505130664e35e81d99f2171b5fdbea7 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 2 May 2021 23:02:22 +0100 Subject: [PATCH 037/192] combine disp, vel, accel into solution for dynamic problems --- .../include/variables/CDiscAdjFEAVariable.hpp | 135 --------- SU2_CFD/include/variables/CFEAVariable.hpp | 259 +----------------- SU2_CFD/include/variables/CVariable.hpp | 213 -------------- .../integration/CStructuralIntegration.cpp | 2 - .../src/iteration/CDiscAdjFEAIteration.cpp | 18 -- SU2_CFD/src/output/CElasticityOutput.cpp | 12 +- SU2_CFD/src/python_wrapper_structure.cpp | 12 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 155 +---------- SU2_CFD/src/solvers/CFEASolver.cpp | 105 ++++--- SU2_CFD/src/solvers/CSolver.cpp | 8 - SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 44 +-- SU2_CFD/src/variables/CFEAVariable.cpp | 124 +-------- 12 files changed, 98 insertions(+), 989 deletions(-) diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index 85e0e565418..08bfe8d9400 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -44,22 +44,6 @@ class CDiscAdjFEAVariable : public CVariable { MatrixType Dynamic_Derivative; MatrixType Dynamic_Derivative_n; - MatrixType Dynamic_Derivative_Vel; - MatrixType Dynamic_Derivative_Vel_n; - MatrixType Dynamic_Derivative_Accel; - MatrixType Dynamic_Derivative_Accel_n; - - MatrixType Solution_Vel; - MatrixType Solution_Accel; - - MatrixType Solution_Vel_time_n; - MatrixType Solution_Accel_time_n; - - MatrixType Solution_Old_Vel; - MatrixType Solution_Old_Accel; - - MatrixType Solution_Direct_Vel; - MatrixType Solution_Direct_Accel; /*! * \brief Constructor of the class. @@ -125,129 +109,10 @@ class CDiscAdjFEAVariable : public CVariable { return Dynamic_Derivative_n(iPoint,iVar); } - inline void SetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative_Vel(iPoint,iVar) = der; - } - - inline void SetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative_Vel_n(iPoint,iVar) = der; - } - - inline su2double GetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative_Vel(iPoint,iVar); - } - - inline su2double GetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative_Vel_n(iPoint,iVar); - } - - inline void SetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative_Accel(iPoint,iVar) = der; - } - - inline void SetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative_Accel_n(iPoint,iVar) = der; - } - - inline su2double GetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative_Accel(iPoint,iVar); - } - - inline su2double GetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative_Accel_n(iPoint,iVar); - } - inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; - } - - inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; - } - inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } - inline su2double* GetSolution_Vel_Direct(unsigned long iPoint) final { return Solution_Direct_Vel[iPoint]; } - - inline su2double* GetSolution_Accel_Direct(unsigned long iPoint) final { return Solution_Direct_Accel[iPoint]; } - - inline su2double GetSolution_Old_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Old_Vel(iPoint,iVar); } - - inline su2double GetSolution_Old_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Old_Accel(iPoint,iVar); } - - /*! - * \brief Get the acceleration (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } - - /*! - * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel_time_n(iPoint,iVar); } - - /*! - * \brief Get the velocity (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } - - /*! - * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel_time_n(iPoint,iVar); } - - /*! - * \brief Set the value of the acceleration (Structural Analysis - adjoint). - * \param[in] val_solution - Solution of the problem (acceleration). - */ - inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; - } - - /*! - * \brief Set the value of the velocity (Structural Analysis - adjoint). - * \param[in] val_solution - Solution of the problem (velocity). - */ - inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; - } - - /*! - * \brief Set the value of the adjoint acceleration (Structural Analysis) at time n. - * \param[in] val_solution_old - Pointer to the residual vector. - */ - inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; - } - - /*! - * \brief Set the value of the adjoint velocity (Structural Analysis) at time n. - * \param[in] val_solution_old - Pointer to the residual vector. - */ - inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; - } - - /*! - * \brief Set the value of the old acceleration (Structural Analysis - adjoint). - */ - void Set_OldSolution_Accel() final; - - /*! - * \brief Set the value of the old velocity (Structural Analysis - adjoint). - */ - void Set_OldSolution_Vel() final; - }; diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 46f24ccbbcc..969d9b523c3 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -45,12 +45,6 @@ class CFEAVariable : public CVariable { VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ - MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ - MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ - - MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ - MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ - MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ @@ -128,147 +122,13 @@ class CFEAVariable : public CVariable { */ inline su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final { return Residual_Ext_Body(iPoint,iVar); } - /*! - * \brief Set the value of the velocity (Structural Analysis). - * \param[in] val_solution_vel - Solution of the problem (velocity). - */ - inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; - } - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] val_solution_vel - Value of the solution for the index iVar. - */ - inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final { - Solution_Vel(iPoint,iVar) = val_solution_vel; - } - - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] val_solution - Solution of the problem (acceleration). - */ - void SetSolution_Vel_time_n() final; - - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] val_solution_vel_time_n - Pointer to the residual vector. - */ - inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; - } - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] val_solution_vel_time_n - Value of the old solution for the index iVar. - */ - inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final { - Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n; - } - - /*! - * \brief Get the velocity (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } - - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } - - /*! - * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_Vel_time_n(iPoint,iVar); - } - - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } - - /*! - * \brief Set the value of the acceleration (Structural Analysis). - * \param[in] val_solution_accel - Solution of the problem (acceleration). - */ - inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; - } - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] val_solution_accel - Value of the solution for the index iVar. - */ - inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final { - Solution_Accel(iPoint,iVar) = val_solution_accel; - } - - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - * \param[in] val_solution_old - Pointer to the residual vector. - */ - inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; - } - - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - */ - void SetSolution_Accel_time_n() final; - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] val_solution_accel_time_n - Value of the old solution for the index iVar. - */ - inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final { - Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n; - } - - /*! - * \brief Get the acceleration (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } - - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } - - /*! - * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_Accel_time_n(iPoint,iVar); - } - - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } - /*! * \brief Set the value of the solution velocity predictor. */ inline void SetSolution_Vel_Pred(unsigned long iPoint) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution_Vel(iPoint,iVar); + for (unsigned long iVar = 0; iVar < nDim; iVar++) { + Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); + } } /*! @@ -353,117 +213,4 @@ class CFEAVariable : public CVariable { */ void Register_femSolution_time_n(bool input, bool push_index) final; - /*! - * \brief Register the variables in the velocity array as input/output variable. - * \param[in] input - input or output variables. - */ - void RegisterSolution_Vel(bool input, bool push_index) final; - - /*! - * \brief Register the variables in the velocity time_n array as input/output variable. - */ - void RegisterSolution_Vel_time_n(bool input, bool push_index) final; - - /*! - * \brief Register the variables in the acceleration array as input/output variable. - * \param[in] input - input or output variables. - */ - void RegisterSolution_Accel(bool input, bool push_index) final; - - /*! - * \brief Register the variables in the acceleration time_n array as input/output variable. - */ - void RegisterSolution_Accel_time_n(bool input, bool push_index) final; - - /*! - * \brief Set the velocity adjoint values of the solution. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void SetAdjointSolution_Vel(unsigned long iPoint, const su2double *adj_sol) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Vel(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - - /*! - * \brief Get the velocity adjoint values of the solution. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void GetAdjointSolution_Vel(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel(iPoint,iVar)); - } - - inline void GetAdjointSolution_Vel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Vel_InputIndex(iPoint,iVar)); - } - - /*! - * \brief Set the velocity adjoint values of the solution at time n. - * \param[in] adj_sol - The adjoint values of the solution. - */ - void SetAdjointSolution_Vel_time_n(unsigned long iPoint, const su2double *adj_sol) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Vel_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - - /*! - * \brief Get the velocity adjoint values of the solution at time n. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void GetAdjointSolution_Vel_time_n(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Vel_time_n(iPoint,iVar)); - } - - inline void GetAdjointSolution_Vel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Vel_Time_n_InputIndex(iPoint,iVar)); - } - - /*! - * \brief Set the acceleration adjoint values of the solution. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void SetAdjointSolution_Accel(unsigned long iPoint, const su2double *adj_sol) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Accel(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - - /*! - * \brief Get the acceleration adjoint values of the solution. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void GetAdjointSolution_Accel(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel(iPoint,iVar)); - } - - inline void GetAdjointSolution_Accel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Accel_InputIndex(iPoint,iVar)); - } - - /*! - * \brief Set the acceleration adjoint values of the solution at time n. - * \param[in] adj_sol - The adjoint values of the solution. - */ - void SetAdjointSolution_Accel_time_n(unsigned long iPoint, const su2double *adj_sol) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_Accel_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - - /*! - * \brief Get the acceleration adjoint values of the solution at time n. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void GetAdjointSolution_Accel_time_n(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_Accel_time_n(iPoint,iVar)); - } - - inline void GetAdjointSolution_Accel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Accel_Time_n_InputIndex(iPoint,iVar)); - } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 709b023bdd2..d646208c5ee 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1807,61 +1807,6 @@ class CVariable { return Solution_BGS_k(iPoint,iVar); } - /*! - * \brief A virtual member. Set the direct velocity solution for the adjoint solver. - * \param[in] solution_direct - Value of the direct velocity solution. - */ - inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} - - /*! - * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. - * \param[in] solution_direct - Value of the direct acceleration solution. - */ - inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} - - /*! - * \brief A virtual member. Get the direct velocity solution for the adjoint solver. - * \return Pointer to the direct velocity solution vector. - */ - inline virtual su2double* GetSolution_Vel_Direct(unsigned long iPoint) { return nullptr; } - - /*! - * \brief A virtual member. Get the direct acceleraction solution for the adjoint solver. - * \return Pointer to the direct acceleraction solution vector. - */ - inline virtual su2double* GetSolution_Accel_Direct(unsigned long iPoint) { return nullptr; } - - /*! - * \brief Set the value of the velocity (Structural Analysis). - * \param[in] solution - Solution of the problem (velocity). - */ - inline virtual void SetSolution_Vel(unsigned long iPoint, const su2double *solution) {} - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] solution_vel - Value of the solution for the index iVar. - */ - inline virtual void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double solution_vel) {} - - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] solution_vel_time_n - Value of the old solution. - */ - inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *solution_vel_time_n) {} - - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - */ - inline virtual void SetSolution_Vel_time_n() {} - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] solution_vel_time_n - Value of the old solution for the index iVar. - */ - inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_vel_time_n) {} - /*! * \brief Get the solution at time n. * \param[in] iVar - Index of the variable. @@ -1876,100 +1821,6 @@ class CVariable { */ inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } - /*! - * \brief Get the velocity (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline virtual su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } - - /*! - * \brief Get the velocity of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline virtual su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } - - - /*! - * \brief Set the value of the acceleration (Structural Analysis). - * \param[in] solution_accel - Solution of the problem (acceleration). - */ - inline virtual void SetSolution_Accel(unsigned long iPoint, const su2double *solution_accel) {} - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] solution_accel - Value of the solution for the index iVar. - */ - inline virtual void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double solution_accel) {} - - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - * \param[in] solution_accel_time_n - Pointer to the residual vector. - */ - inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *solution_accel_time_n) {} - - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - */ - inline virtual void SetSolution_Accel_time_n() {} - - /*! - * \overload - * \param[in] iVar - Index of the variable. - * \param[in] solution_accel_time_n - Value of the old solution for the index iVar. - */ - inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_accel_time_n) {} - - /*! - * \brief Get the acceleration (Structural Analysis). - * \param[in] iVar - Index of the variable. - * \return Value of the solution for the index iVar. - */ - inline virtual su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } - - /*! - * \brief Get the acceleration of the nodes (Structural Analysis) at time n. - * \param[in] iVar - Index of the variable. - * \return Pointer to the old solution vector. - */ - inline virtual su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } - - /*! - * \brief A virtual member. - */ - inline virtual void Set_OldSolution_Vel() {} - - /*! - * \brief A virtual member. - */ - inline virtual void Set_OldSolution_Accel() {} - /*! * \brief A virtual member. Set the value of the velocity solution predictor. */ @@ -2153,31 +2004,6 @@ class CVariable { */ inline virtual void Register_femSolution_time_n(bool input, bool push_index) {} - /*! - * \brief A virtual member. - */ - inline virtual void RegisterSolution_Vel(bool input, bool push_index) {} - - /*! - * \brief A virtual member. - */ - inline virtual void RegisterSolution_Vel_time_n(bool input, bool push_index) {} - - /*! - * \brief A virtual member. - */ - inline virtual void RegisterSolution_Accel(bool input, bool push_index) {} - - /*! - * \brief A virtual member. - */ - inline virtual void RegisterSolution_Accel_time_n(bool input, bool push_index) {} - - /*! - * \brief A virtual member. - */ - inline virtual void SetAdjointSolution_Vel(unsigned long iPoint, const su2double *adj_sol) {} - /*! * \brief A virtual member. */ @@ -2188,45 +2014,6 @@ class CVariable { */ inline virtual su2double ExtractFlowTraction_Sensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - /*! - * \brief A virtual member. - */ - inline virtual void GetAdjointSolution_Vel(unsigned long iPoint, su2double *adj_sol) const {} - inline virtual void GetAdjointSolution_Vel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} - - /*! - * \brief A virtual member. - */ - inline virtual void SetAdjointSolution_Vel_time_n(unsigned long iPoint, const su2double *adj_sol) {} - - /*! - * \brief A virtual member. - */ - inline virtual void GetAdjointSolution_Vel_time_n(unsigned long iPoint, su2double *adj_sol) const {} - inline virtual void GetAdjointSolution_Vel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} - - /*! - * \brief A virtual member. - */ - inline virtual void SetAdjointSolution_Accel(unsigned long iPoint, const su2double *adj_sol) {} - - /*! - * \brief A virtual member. - */ - inline virtual void GetAdjointSolution_Accel(unsigned long iPoint, su2double *adj_sol) const {} - inline virtual void GetAdjointSolution_Accel_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} - - /*! - * \brief A virtual member. - */ - inline virtual void SetAdjointSolution_Accel_time_n(unsigned long iPoint, const su2double *adj_sol) {} - - /*! - * \brief A virtual member. - */ - inline virtual void GetAdjointSolution_Accel_time_n(unsigned long iPoint, su2double *adj_sol) const {} - inline virtual void GetAdjointSolution_Accel_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const {} - /*! * \brief Register the variables in the solution array as input/output variable. * \param[in] input - input or output variables. diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index a82763629ff..31be9b7e8bd 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -212,8 +212,6 @@ void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolv /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ solver->GetNodes()->Set_Solution_time_n(); - solver->GetNodes()->SetSolution_Vel_time_n(); - solver->GetNodes()->SetSolution_Accel_time_n(); /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index b0eea71aaf2..9036a822ffd 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -90,14 +90,6 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat dirNodes->Set_Solution_time_n(); - /*--- Push solution back to correct array ---*/ - - dirNodes->SetSolution_Accel_time_n(); - - /*--- Push solution back to correct array ---*/ - - dirNodes->SetSolution_Vel_time_n(); - /*--- Load solution timestep n ---*/ LoadDynamic_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter); @@ -108,14 +100,6 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); } - for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Accel_Direct(iPoint, dirNodes->GetSolution_Accel(iPoint)); - } - - for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Vel_Direct(iPoint, dirNodes->GetSolution_Vel(iPoint)); - } - } else { /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ @@ -148,8 +132,6 @@ void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry**** geometry, CSolver* for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetnVar(); iVar++) { solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel(iPoint, iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel(iPoint, iVar, 0.0); } } } diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index 55d2f9f84a0..77e81a665e9 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -202,13 +202,13 @@ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo if (nDim == 3) SetVolumeOutputValue("DISPLACEMENT-Z", iPoint, Node_Struc->GetSolution(iPoint, 2)); if(dynamic){ - SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution_Vel(iPoint, 0)); - SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution_Vel(iPoint, 1)); - if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution_Vel(iPoint, 2)); + SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution(iPoint, 0+nDim)); + SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution(iPoint, 1+nDim)); + if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution(iPoint, 3+nDim)); - SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution_Accel(iPoint, 0)); - SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution_Accel(iPoint, 1)); - if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution_Accel(iPoint, 2)); + SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution(iPoint, 0+2*nDim)); + SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution(iPoint, 1+2*nDim)); + if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution(iPoint, 2+2*nDim)); } SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM(iPoint)[0]); diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index f7f8499963a..65b1141ea37 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -681,10 +681,10 @@ vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity[0] = solver->GetNodes()->GetSolution_Vel(iPoint, 0); - Velocity[1] = solver->GetNodes()->GetSolution_Vel(iPoint, 1); + Velocity[0] = solver->GetNodes()->GetSolution(iPoint, 0+geometry->GetnDim()); + Velocity[1] = solver->GetNodes()->GetSolution(iPoint, 1+geometry->GetnDim()); if (geometry->GetnDim() == 3) - Velocity[2] = solver->GetNodes()->GetSolution_Vel(iPoint, 2); + Velocity[2] = solver->GetNodes()->GetSolution(iPoint, 2+geometry->GetnDim()); else Velocity[2] = 0.0; } @@ -707,10 +707,10 @@ vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigne CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity_n[0] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 0); - Velocity_n[1] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 1); + Velocity_n[0] = solver->GetNodes()->GetSolution_time_n(iPoint, 0+geometry->GetnDim()); + Velocity_n[1] = solver->GetNodes()->GetSolution_time_n(iPoint, 1+geometry->GetnDim()); if (geometry->GetnDim() == 3) - Velocity_n[2] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 2); + Velocity_n[2] = solver->GetNodes()->GetSolution_time_n(iPoint, 2+geometry->GetnDim()); else Velocity_n[2] = 0.0; } diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 1fb642bbe3a..ce31eabc5e3 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -39,6 +39,7 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv nVar = direct_solver->GetnVar(); nDim = geometry->GetnDim(); + if (dynamic) nVar = 3*nDim; /*-- Store some information about direct solver ---*/ this->KindDirect_Solver = Kind_Solver; @@ -143,15 +144,6 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ } if (config->GetTime_Domain()){ - /*--- Reset the solution to the initial (converged) solution ---*/ - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->GetNodes()->SetSolution_Accel(iPoint, nodes->GetSolution_Accel_Direct(iPoint)); - } - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->GetNodes()->SetSolution_Vel(iPoint, nodes->GetSolution_Vel_Direct(iPoint)); - } /*--- Reset the input for time n ---*/ @@ -160,16 +152,6 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); } } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->GetNodes()->GetSolution_Accel_time_n(iPoint)[iVar]); - } - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->GetNodes()->GetSolution_Vel_time_n(iPoint)[iVar]); - } - } } @@ -196,16 +178,9 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ if (dynamic) { - /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - - direct_solver->GetNodes()->RegisterSolution_Accel(input, push_index); - direct_solver->GetNodes()->RegisterSolution_Vel(input, push_index); - - /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ + /*--- Register solution at time step n-1 ---*/ direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index); - direct_solver->GetNodes()->RegisterSolution_Accel_time_n(input, push_index); - direct_solver->GetNodes()->RegisterSolution_Vel_time_n(input, push_index); } @@ -282,12 +257,6 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ direct_solver->GetNodes()->RegisterSolution(input, push_index); - if (dynamic) { - /*--- Register acceleration (u'') and velocity (u') at time step n ---*/ - direct_solver->GetNodes()->RegisterSolution_Accel(input, push_index); - direct_solver->GetNodes()->RegisterSolution_Vel(input, push_index); - } - } void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ @@ -299,7 +268,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co unsigned long iPoint; su2double residual; - su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}; /*--- Set Residuals to zero ---*/ @@ -332,50 +301,6 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co if (dynamic){ - /*--- FIRST: The acceleration solution ---*/ - - /*--- Set the old acceleration solution ---*/ - nodes->Set_OldSolution_Accel(); - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Extract the adjoint acceleration solution u'' ---*/ - - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_Accel_LocalIndex(iPoint,Solution_Accel); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_Accel(iPoint,Solution_Accel); - } - - /*--- Store the adjoint acceleration solution u'' ---*/ - - nodes->SetSolution_Accel(iPoint,Solution_Accel); - - } - - /*--- NEXT: The velocity solution ---*/ - - /*--- Set the old velocity solution ---*/ - nodes->Set_OldSolution_Vel(); - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Extract the adjoint velocity solution u'' ---*/ - - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_Vel_LocalIndex(iPoint,Solution_Vel); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_Vel(iPoint,Solution_Vel); - } - - /*--- Store the adjoint velocity solution u'' ---*/ - - nodes->SetSolution_Vel(iPoint,Solution_Vel); - - } - /*--- NOW: The solution at time n ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ @@ -393,42 +318,6 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co nodes->Set_Solution_time_n(iPoint,Solution); } - /*--- The acceleration solution at time n... ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Extract the adjoint acceleration solution u'' at time n ---*/ - - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n_LocalIndex(iPoint,Solution_Accel); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_Accel_time_n(iPoint,Solution_Accel); - } - - /*--- Store the adjoint acceleration solution u'' at time n---*/ - - nodes->SetSolution_Accel_time_n(iPoint,Solution_Accel); - - } - - /*--- ... and the velocity solution at time n ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Extract the adjoint velocity solution u' at time n ---*/ - - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n_LocalIndex(iPoint,Solution_Vel); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_Vel_time_n(iPoint,Solution_Vel); - } - - /*--- Store the adjoint velocity solution u' at time n ---*/ - - nodes->SetSolution_Vel_time_n(iPoint,Solution_Vel); - - } - } /*--- TODO: Need to set the MPI solution in the previous TS ---*/ @@ -442,20 +331,6 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co Residual_RMS[iVar] += residual*residual; AddRes_Max(iVar,fabs(residual),geometry->nodes->GetGlobalIndex(iPoint),geometry->nodes->GetCoord(iPoint)); } - if (dynamic){ - for (iVar = 0; iVar < nVar; iVar++){ - residual = nodes->GetSolution_Accel(iPoint, iVar) - nodes->GetSolution_Old_Accel(iPoint, iVar); - - Residual_RMS[iVar] += residual*residual; - AddRes_Max(iVar,fabs(residual),geometry->nodes->GetGlobalIndex(iPoint),geometry->nodes->GetCoord(iPoint)); - } - for (iVar = 0; iVar < nVar; iVar++){ - residual = nodes->GetSolution_Vel(iPoint, iVar) - nodes->GetSolution_Old_Vel(iPoint, iVar); - - Residual_RMS[iVar] += residual*residual; - AddRes_Max(iVar,fabs(residual),geometry->nodes->GetGlobalIndex(iPoint),geometry->nodes->GetCoord(iPoint)); - } - } } SetResidual_RMS(geometry, config); @@ -496,7 +371,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ const bool dynamic = (config->GetTime_Domain()); const bool deform_mesh = (config->GetnMarker_Deform_Mesh() > 0); - su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}; unsigned short iVar; @@ -505,7 +380,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ Solution[iVar] = nodes->GetSolution(iPoint,iVar); } if(deform_mesh){ - for (iVar = 0; iVar < nVar; iVar++){ + for (iVar = 0; iVar < nDim; iVar++){ Solution[iVar] += nodes->GetSourceTerm_DispAdjoint(iPoint,iVar); } } @@ -513,21 +388,13 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ for (iVar = 0; iVar < nVar; iVar++){ Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); } - for (iVar = 0; iVar < nVar; iVar++){ - Solution_Accel[iVar] = nodes->GetSolution_Accel(iPoint,iVar) + nodes->GetDynamic_Derivative_Accel_n(iPoint,iVar); - } - for (iVar = 0; iVar < nVar; iVar++){ - Solution_Vel[iVar] = nodes->GetSolution_Vel(iPoint,iVar) + nodes->GetDynamic_Derivative_Vel_n(iPoint,iVar); - } if (deform_mesh){ - Solution_Vel[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); + for (iVar = 0; iVar < nDim; iVar++){ + Solution[iVar+nDim] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); + } } } direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); - if (dynamic){ - direct_solver->GetNodes()->SetAdjointSolution_Accel(iPoint,Solution_Accel); - direct_solver->GetNodes()->SetAdjointSolution_Vel(iPoint,Solution_Vel); - } } @@ -542,12 +409,6 @@ void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_cont for (iVar=0; iVar < nVar; iVar++){ nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); } - for (iVar=0; iVar < nVar; iVar++){ - nodes->SetDynamic_Derivative_Accel_n(iPoint, iVar, nodes->GetSolution_Accel_time_n(iPoint, iVar)); - } - for (iVar=0; iVar < nVar; iVar++){ - nodes->SetDynamic_Derivative_Vel_n(iPoint, iVar, nodes->GetSolution_Vel_time_n(iPoint, iVar)); - } } } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 1e243f73550..d20475a1dbd 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -127,6 +127,7 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { SetFSI_ConvValue(1,0.0); nVar = nDim; + if (dynamic) nVar = 3*nDim; /*--- Define some auxiliary vectors related to the residual ---*/ @@ -1408,12 +1409,12 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) + a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) } } @@ -1614,11 +1615,7 @@ void CFEASolver::BC_Clamped(CGeometry *geometry, const CConfig *config, unsigned nodes->SetSolution(iPoint, zeros); if (dynamic) { - nodes->SetSolution_Vel(iPoint, zeros); - nodes->SetSolution_Accel(iPoint, zeros); nodes->Set_Solution_time_n(iPoint, zeros); - nodes->SetSolution_Vel_time_n(iPoint, zeros); - nodes->SetSolution_Accel_time_n(iPoint, zeros); } /*--- Set and enforce 0 solution for mesh deformation ---*/ @@ -1645,11 +1642,6 @@ void CFEASolver::BC_Clamped_Post(CGeometry *geometry, const CConfig *config, uns nodes->SetSolution(iPoint, zeros); - if (dynamic) { - nodes->SetSolution_Vel(iPoint, zeros); - nodes->SetSolution_Accel(iPoint, zeros); - } - } } @@ -1695,11 +1687,7 @@ void CFEASolver::BC_Sym_Plane(CGeometry *geometry, const CConfig *config, unsign /*--- Set and enforce solution at current and previous time-step ---*/ nodes->SetSolution(iPoint, axis, 0.0); if (dynamic) { - nodes->SetSolution_Vel(iPoint, axis, 0.0); - nodes->SetSolution_Accel(iPoint, axis, 0.0); nodes->Set_Solution_time_n(iPoint, axis, 0.0); - nodes->SetSolution_Vel_time_n(iPoint, axis, 0.0); - nodes->SetSolution_Accel_time_n(iPoint, axis, 0.0); } /*--- Set and enforce 0 solution for mesh deformation ---*/ @@ -2092,8 +2080,8 @@ void CFEASolver::BC_Damper(CGeometry *geometry, const CConfig *config, unsigned /*--- Writing over the normal. --*/ su2double* force = normal; - for (iDim = 0; iDim < nVar; iDim++) - force[iDim] = dampCoeff * nodes->GetSolution_Vel(iPoint, iDim); + for (iDim = 0; iDim < nDim; iDim++) + force[iDim] = dampCoeff * nodes->GetSolution(iPoint, iDim+nDim);//Vel Solution nodes->Add_SurfaceLoad_Res(iPoint, force); } @@ -2242,12 +2230,12 @@ void CFEASolver::ImplicitNewmark_Iteration(const CGeometry *geometry, CNumerics /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) + a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) } } END_SU2_OMP_FOR @@ -2284,26 +2272,26 @@ void CFEASolver::ImplicitNewmark_Update(const CGeometry *geometry, const CConfig if (dynamic) { SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { /*--- Acceleration component of the solution. ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double sol = a_dt[0]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - - a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); + a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel + a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel - nodes->SetSolution_Accel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+2*nDim, sol); /*--- Velocity component of the solution. ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ - a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + - a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); + sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel + a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel + a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel - nodes->SetSolution_Vel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+nDim, sol); } } END_SU2_OMP_FOR @@ -2332,26 +2320,26 @@ void CFEASolver::ImplicitNewmark_Relaxation(const CGeometry *geometry, const CCo if (dynamic) { SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double sol = a_dt[0]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - - a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); + a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel + a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel - nodes->SetSolution_Accel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+2*nDim, sol);//Accel /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ - a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + - a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); + sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel + a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel + a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel - nodes->SetSolution_Vel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+nDim, sol); } } END_SU2_OMP_FOR @@ -2426,12 +2414,12 @@ void CFEASolver::GeneralizedAlpha_Iteration(const CGeometry *geometry, CNumerics /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) + a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) } } END_SU2_OMP_FOR @@ -2510,31 +2498,31 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, cons nodes->SetSolution(iPoint, iVar, sol); } - for (iVar = 0; iVar < nVar; iVar++) { + for (iVar = 0; iVar < nDim; iVar++) { /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt-alpha_m) = a8*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double tmp = a_dt[8]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - - a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); + a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel + a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel /*--- Compute the solution from the previous time step and the solution computed at t+1-alpha_f ---*/ /*--- U''(t+dt) = 1/alpha_m*(U''(t+1-alpha_m)-alpha_m*U''(t)) ---*/ - su2double sol = (1/(1-alpha_m)) * (tmp - alpha_m*nodes->GetSolution_Accel_time_n(iPoint,iVar)); + su2double sol = (1/(1-alpha_m)) * (tmp - alpha_m*nodes->GetSolution_time_n(iPoint,iVar+2*nDim)); - nodes->SetSolution_Accel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+2*nDim, sol);//Accel /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ - a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + - a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); + sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel + a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel + a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel - nodes->SetSolution_Vel(iPoint, iVar, sol); + nodes->SetSolution(iPoint, iVar+nDim, sol);//Vel } } @@ -2602,23 +2590,20 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * switch (predOrder) { case 1: { const su2double* solDisp = nodes->GetSolution(iPoint); - const su2double* solVel = nodes->GetSolution_Vel(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + Delta_t*solVel[iDim]; + valPred[iDim] = solDisp[iDim] + Delta_t*nodes->GetSolution(iPoint, iDim+nDim); nodes->SetSolution_Pred(iPoint, valPred); } break; case 2: { const su2double* solDisp = nodes->GetSolution(iPoint); - const su2double* solVel = nodes->GetSolution_Vel(iPoint); - const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*solVel[iDim]-solVel_tn[iDim]); + valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*nodes->GetSolution(iPoint, iDim+nDim)-nodes->GetSolution_time_n(iPoint, iDim+nDim)); nodes->SetSolution_Pred(iPoint, valPred); } break; @@ -3160,14 +3145,18 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c const auto index = counter*Restart_Vars[1] + skipVars; const passivedouble* Sol = &Restart_Data[index]; - for (unsigned short iVar = 0; iVar < nVar; iVar++) { + for (unsigned short iVar = 0; iVar < nDim; iVar++) { nodes->SetSolution(iPoint_Local, iVar, Sol[iVar]); if (dynamic) { - nodes->SetSolution_Vel(iPoint_Local, iVar, Sol[iVar+nVar]); - nodes->SetSolution_Accel(iPoint_Local, iVar, Sol[iVar+2*nVar]); + nodes->SetSolution(iPoint_Local, iVar+nDim, Sol[iVar+nVar]); + nodes->SetSolution(iPoint_Local, iVar+2*nDim, Sol[iVar+2*nVar]); } if (fluid_structure && discrete_adjoint){ nodes->SetSolution_Old(iPoint_Local, iVar, Sol[iVar]); + if (dynamic) { + nodes->SetSolution_Old(iPoint_Local, iVar+nDim, Sol[iVar+nVar]); + nodes->SetSolution_Old(iPoint_Local, iVar+2*nDim, Sol[iVar+2*nVar]); + } } } @@ -3191,8 +3180,6 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c if (dynamic) { nodes->Set_Solution_time_n(); - nodes->SetSolution_Vel_time_n(); - nodes->SetSolution_Accel_time_n(); } if (fluid_structure) { diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index d1db5557656..c443ef351f7 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -1500,10 +1500,6 @@ void CSolver::InitiateComms(CGeometry *geometry, case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); - if (config->GetTime_Domain()) { - bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Vel(iPoint, iVar); - bufDSend[buf_offset+nVar*2+iVar] = base_nodes->GetSolution_Accel(iPoint, iVar); - } } break; case MESH_DISPLACEMENTS: @@ -1651,10 +1647,6 @@ void CSolver::CompleteComms(CGeometry *geometry, case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); - if (config->GetTime_Domain()) { - base_nodes->SetSolution_Vel(iPoint, iVar, bufDRecv[buf_offset+nVar+iVar]); - base_nodes->SetSolution_Accel(iPoint, iVar, bufDRecv[buf_offset+nVar*2+iVar]); - } } break; case MESH_DISPLACEMENTS: diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index 4c95b416641..5588ecb4b9a 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -37,9 +37,20 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double Sensitivity.resize(nPoint,nDim) = su2double(0.0); Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) - for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution(iPoint,iVar) = disp[iVar]; + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + if (config->GetTime_Domain()) { + for (unsigned long iVar = 0; iVar < nDim; iVar++) + Solution(iPoint,iVar) = disp[iVar]; + for (unsigned long iVar = nDim; iVar < 2*nDim; iVar++) + Solution(iPoint,iVar) = vel[iVar]; + for (unsigned long iVar = 2*nDim; iVar < 3*nDim; iVar++) + Solution(iPoint,iVar) = accel[iVar]; + } + else { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = disp[iVar]; + } + } if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { External.resize(nPoint,nVar) = su2double(0.0); @@ -51,32 +62,5 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double Dynamic_Derivative.resize(nPoint,nVar) = su2double(0.0); Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); - Dynamic_Derivative_Vel.resize(nPoint,nVar) = su2double(0.0); - Dynamic_Derivative_Vel_n.resize(nPoint,nVar) = su2double(0.0); - Dynamic_Derivative_Accel.resize(nPoint,nVar) = su2double(0.0); - Dynamic_Derivative_Accel_n.resize(nPoint,nVar) = su2double(0.0); - - Solution_Direct_Vel.resize(nPoint,nVar) = su2double(0.0); - Solution_Direct_Accel.resize(nPoint,nVar) = su2double(0.0); - - Solution_Vel.resize(nPoint,nVar); - Solution_Accel.resize(nPoint,nVar); - - Solution_Old_Vel.resize(nPoint,nVar) = su2double(0.0); - Solution_Old_Accel.resize(nPoint,nVar) = su2double(0.0); - - Solution_Vel_time_n.resize(nPoint,nVar) = su2double(0.0); - Solution_Accel_time_n.resize(nPoint,nVar) = su2double(0.0); - - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_Vel(iPoint,iVar) = vel[iVar]; - Solution_Accel(iPoint,iVar) = accel[iVar]; - } - } } - -void CDiscAdjFEAVariable::Set_OldSolution_Vel() { Solution_Old_Vel = Solution_Vel; } - -void CDiscAdjFEAVariable::Set_OldSolution_Accel() { Solution_Old_Accel = Solution_Accel; } diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 9ce54e9d9ab..1d5b33460cf 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -47,40 +47,34 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig if (nDim==2) Stress.resize(nPoint,3); else Stress.resize(nPoint,6); + Solution_Vel_Pred.resize(nPoint,nDim); + /*--- Initialization of variables ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < nDim; iVar++) Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { - Solution_Vel.resize(nPoint,nVar); - Solution_Accel.resize(nPoint,nVar); - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; - Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; + for (unsigned long iVar = nDim; iVar < 2*nDim; iVar++) { + Solution(iPoint,iVar) = val_fea[iVar+nDim]; + } + for (unsigned long iVar = 2*nDim; iVar < 3*nDim; iVar++) { + Solution(iPoint,iVar) = val_fea[iVar+2*nDim]; } - } - Solution_Vel_time_n = Solution_Vel; - Solution_Accel_time_n = Solution_Accel; - - if(config->GetMultizone_Problem() && config->GetAD_Mode()) { - AD_Vel_InputIndex.resize(nPoint,nVar) = -1; - AD_Vel_OutputIndex.resize(nPoint,nVar) = -1; - AD_Vel_Time_n_InputIndex.resize(nPoint,nVar) = -1; - AD_Vel_Time_n_OutputIndex.resize(nPoint,nVar) = -1; - AD_Accel_InputIndex.resize(nPoint,nVar) = -1; - AD_Accel_OutputIndex.resize(nPoint,nVar) = -1; - AD_Accel_Time_n_InputIndex.resize(nPoint,nVar) = -1; - AD_Accel_Time_n_OutputIndex.resize(nPoint,nVar) = -1; } } if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; - if (dynamic_analysis) Solution_Vel_Pred = Solution_Vel; + if (dynamic_analysis) { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nDim; iVar++) { + Solution_Vel_Pred(iPoint, iVar) = Solution(iPoint,iVar+nDim); + } + } + } } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ @@ -106,10 +100,6 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } } -void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } - -void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } - void CFEAVariable::Register_femSolution_time_n(bool input, bool push_index) { for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for(unsigned long iVar=0; iVar Date: Sun, 2 May 2021 23:33:14 +0100 Subject: [PATCH 038/192] remove unused variables --- SU2_CFD/include/variables/CFEAVariable.hpp | 12 ------------ SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 1 - 2 files changed, 13 deletions(-) diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 969d9b523c3..d8750992c7d 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -53,18 +53,6 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ - su2matrix AD_Vel_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Vel_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Vel_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Vel_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Accel_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Accel_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Accel_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Accel_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - /*! * \brief Constructor of the class. * \note This class is not supposed to be instantiated, it is only a building block for CFEABoundVariable diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index ce31eabc5e3..779691cef1f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -250,7 +250,6 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; - const bool dynamic = config->GetTime_Domain(); const bool push_index = !config->GetMultizone_Problem(); /*--- Register variables as output of the solver iteration ---*/ From d9da2ee0e44bdf5b878fe618dea6eed2605d59c8 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 2 May 2021 23:42:42 +0100 Subject: [PATCH 039/192] remove more unused variables --- SU2_CFD/src/solvers/CFEASolver.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index d20475a1dbd..cd23ed15be3 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -1631,8 +1631,6 @@ void CFEASolver::BC_Clamped(CGeometry *geometry, const CConfig *config, unsigned void CFEASolver::BC_Clamped_Post(CGeometry *geometry, const CConfig *config, unsigned short val_marker) { - bool dynamic = config->GetTime_Domain(); - su2double zeros[MAXNVAR] = {0.0}; for (auto iVertex = 0ul; iVertex < geometry->nVertex[val_marker]; iVertex++) { From df2ef6d2825e6c77245e0247761d7b1019268626 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 11:07:28 +0100 Subject: [PATCH 040/192] update predicted solution to include velocity --- SU2_CFD/include/variables/CFEAVariable.hpp | 16 ------------- SU2_CFD/include/variables/CVariable.hpp | 11 --------- .../fsi/CDisplacementsInterface.cpp | 24 +++++++++---------- SU2_CFD/src/solvers/CFEASolver.cpp | 10 -------- SU2_CFD/src/variables/CFEAVariable.cpp | 9 ------- 5 files changed, 12 insertions(+), 58 deletions(-) diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index d8750992c7d..20eb82f3643 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -47,7 +47,6 @@ class CFEAVariable : public CVariable { MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ - MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ MatrixType Reference_Geometry; /*!< \brief Reference solution for optimization problems */ @@ -110,15 +109,6 @@ class CFEAVariable : public CVariable { */ inline su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final { return Residual_Ext_Body(iPoint,iVar); } - /*! - * \brief Set the value of the solution velocity predictor. - */ - inline void SetSolution_Vel_Pred(unsigned long iPoint) final { - for (unsigned long iVar = 0; iVar < nDim; iVar++) { - Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); - } - } - /*! * \brief Set the value of the old solution. * \param[in] val_solution_pred - Pointer to the residual vector. @@ -127,12 +117,6 @@ class CFEAVariable : public CVariable { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred(iPoint,iVar) = val_solution_pred[iVar]; } - /*! - * \brief Get the velocity solution. - * \return Pointer to velocity solution vector. - */ - inline const su2double *GetSolution_Vel_Pred(unsigned long iPoint) const final { return Solution_Vel_Pred[iPoint]; } - /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index d646208c5ee..b367a5d62b9 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1821,23 +1821,12 @@ class CVariable { */ inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } - /*! - * \brief A virtual member. Set the value of the velocity solution predictor. - */ - inline virtual void SetSolution_Vel_Pred(unsigned long iPoint) {} - /*! * \brief A virtual member. Set the value of the old solution. * \param[in] solution_pred - Pointer to the residual vector. */ inline virtual void SetSolution_Pred(unsigned long iPoint, const su2double *solution_pred) {} - /*! - * \brief A virtual member. Get the velocity solution predictor. - * \return Pointer to the velocity solution vector. - */ - inline virtual const su2double *GetSolution_Vel_Pred(unsigned long iPoint) const {return nullptr; } - /*! * \brief A virtual member. Get the solution at time n. * \return Pointer to the solution (at time n) vector. diff --git a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp index 56d5d895152..f98eb9247c5 100644 --- a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp @@ -40,14 +40,12 @@ void CDisplacementsInterface::GetDonor_Variable(CSolver *struct_solution, CGeome unsigned long Vertex_Struct, unsigned long Point_Struct) { /*--- The displacements come from the predicted solution, but they are no longer incremental ---*/ auto DisplacementDonor = struct_solution->GetNodes()->GetSolution_Pred(Point_Struct); + unsigned short nDim = struct_geometry->GetnDim(); - for (auto iVar = 0u; iVar < nVar; iVar++) - Donor_Variable[iVar] = DisplacementDonor[iVar]; - - if (struct_config->GetTime_Domain()) { - auto VelocityDonor = struct_solution->GetNodes()->GetSolution_Vel_Pred(Point_Struct); - for (auto iVar = nVar/2; iVar < nVar; iVar++)//Assuming dynamic interface always has nVar = 2*nDim, 2D: 4, 3D: 6 - Donor_Variable[iVar] = VelocityDonor[iVar-nVar/2]; + for (auto iDim = 0u; iDim < nDim; iDim++) { + Donor_Variable[iDim] = DisplacementDonor[iDim]; + if (struct_config->GetTime_Domain()) + Donor_Variable[iDim+nDim] = DisplacementDonor[iDim+nDim]; } } @@ -59,12 +57,14 @@ void CDisplacementsInterface::SetTarget_Variable(CSolver *mesh_solver, CGeometry /*--- Impose the boundary displacements ---*/ mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,Target_Variable); } else { + unsigned short nDim = flow_geometry->GetnDim(); + /*--- Impose the boundary displacements ---*/ - for (auto iVar = 0u; iVar < nVar/2; iVar++) - mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,iVar,Target_Variable[iVar]); + for (auto iDim = 0u; iDim < nDim; iDim++) { + mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,iDim,Target_Variable[iDim]); - /*--- Impose the boundary velocities ---*/ - for (auto iVar = nVar/2; iVar < nVar; iVar++) - mesh_solver->GetNodes()->SetBound_Vel(Point_Mesh,iVar-nVar/2,Target_Variable[iVar]); + /*--- Impose the boundary velocities ---*/ + mesh_solver->GetNodes()->SetBound_Vel(Point_Mesh,iDim,Target_Variable[iDim+nDim]); + } } } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index cd23ed15be3..44e715e90a8 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2611,8 +2611,6 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * } break; } - if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); - } END_SU2_OMP_PARALLEL @@ -2727,9 +2725,6 @@ void CFEASolver::SetAitken_Relaxation(CGeometry *geometry, const CConfig *config /*--- Set calculated solution as the old solution (needed for dynamic Aitken relaxation) ---*/ nodes->SetSolution_Old(iPoint, dispCalc); - /*--- Set predicted velocity to update in multizone iterations ---*/ - if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); - /*--- Apply the Aitken relaxation ---*/ su2double newDispPred[MAXNVAR] = {0.0}; for (unsigned short iDim=0; iDim < nDim; iDim++) @@ -3186,11 +3181,6 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c nodes->SetSolution_Pred_Old(iPoint, nodes->GetSolution(iPoint)); } - if (dynamic) { - for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) - nodes->SetSolution_Vel_Pred(iPoint); - } - if (discrete_adjoint) { for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) nodes->SetSolution_Old(iPoint, nodes->GetSolution(iPoint)); diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 1d5b33460cf..a9381f723c2 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -47,8 +47,6 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig if (nDim==2) Stress.resize(nPoint,3); else Stress.resize(nPoint,6); - Solution_Vel_Pred.resize(nPoint,nDim); - /*--- Initialization of variables ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nDim; iVar++) @@ -68,13 +66,6 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; - if (dynamic_analysis) { - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nDim; iVar++) { - Solution_Vel_Pred(iPoint, iVar) = Solution(iPoint,iVar+nDim); - } - } - } } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ From eee4f17ccc57c50238c59a5999697a458d192684 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 11:14:20 +0100 Subject: [PATCH 041/192] missed dynamic flag --- SU2_CFD/src/solvers/CFEASolver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 44e715e90a8..c2c67c7f648 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2709,7 +2709,6 @@ void CFEASolver::ComputeAitken_Coefficient(CGeometry *geometry, const CConfig *c void CFEASolver::SetAitken_Relaxation(CGeometry *geometry, const CConfig *config) { const su2double WAitken = GetWAitken_Dyn(); - const bool dynamic = config->GetTime_Domain(); /*--- To nPoint to avoid communication. ---*/ SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) From 6ebed520cbbfb9483525290cf91f54694214d7ed Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 11:22:18 +0100 Subject: [PATCH 042/192] another missed dynamic flag --- SU2_CFD/src/solvers/CFEASolver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index c2c67c7f648..1955abf066f 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2574,7 +2574,6 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * const unsigned short predOrder = config->GetPredictorOrder(); const su2double Delta_t = config->GetDelta_DynTime(); - const bool dynamic = config->GetTime_Domain(); if(predOrder > 2 && rank == MASTER_NODE) cout << "Higher order predictor not implemented. Solving with order 0." << endl; From 61d98831ad2712d82db808299295a020c7696f40 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 14:01:21 +0100 Subject: [PATCH 043/192] undo changes to the primal variables --- .../include/variables/CDiscAdjFEAVariable.hpp | 15 ++ SU2_CFD/include/variables/CFEAVariable.hpp | 156 ++++++++++++++++ SU2_CFD/include/variables/CVariable.hpp | 166 ++++++++++++++++-- .../integration/CStructuralIntegration.cpp | 2 + .../src/iteration/CDiscAdjFEAIteration.cpp | 18 ++ SU2_CFD/src/output/CElasticityOutput.cpp | 12 +- SU2_CFD/src/python_wrapper_structure.cpp | 12 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 42 +++-- SU2_CFD/src/solvers/CFEASolver.cpp | 119 ++++++++----- SU2_CFD/src/solvers/CSolver.cpp | 8 + SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 5 +- SU2_CFD/src/variables/CFEAVariable.cpp | 21 ++- 12 files changed, 485 insertions(+), 91 deletions(-) diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index 08bfe8d9400..c2396d5ecfe 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -45,6 +45,9 @@ class CDiscAdjFEAVariable : public CVariable { MatrixType Dynamic_Derivative; MatrixType Dynamic_Derivative_n; + MatrixType Solution_Direct_Vel; + MatrixType Solution_Direct_Accel; + /*! * \brief Constructor of the class. * \param[in] disp - Pointer to the adjoint value (initialization value). @@ -113,6 +116,18 @@ class CDiscAdjFEAVariable : public CVariable { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } + inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; + } + + inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; + } + inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } + inline su2double* GetSolution_Vel_Direct(unsigned long iPoint) final { return Solution_Direct_Vel[iPoint]; } + + inline su2double* GetSolution_Accel_Direct(unsigned long iPoint) final { return Solution_Direct_Accel[iPoint]; } + }; diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 20eb82f3643..e74d1a549dc 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -45,8 +45,15 @@ class CFEAVariable : public CVariable { VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ + MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ + MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ + + MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ + MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ + MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ + MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ MatrixType Reference_Geometry; /*!< \brief Reference solution for optimization problems */ @@ -109,6 +116,149 @@ class CFEAVariable : public CVariable { */ inline su2double Get_BodyForces_Res(unsigned long iPoint, unsigned long iVar) const final { return Residual_Ext_Body(iPoint,iVar); } + /*! + * \brief Set the value of the velocity (Structural Analysis). + * \param[in] val_solution_vel - Solution of the problem (velocity). + */ + inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; + } + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_vel - Value of the solution for the index iVar. + */ + inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final { + Solution_Vel(iPoint,iVar) = val_solution_vel; + } + + /*! + * \brief Set the value of the velocity (Structural Analysis) at time n. + * \param[in] val_solution - Solution of the problem (acceleration). + */ + void SetSolution_Vel_time_n() final; + + /*! + * \brief Set the value of the velocity (Structural Analysis) at time n. + * \param[in] val_solution_vel_time_n - Pointer to the residual vector. + */ + inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; + } + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_vel_time_n - Value of the old solution for the index iVar. + */ + inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final { + Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n; + } + + /*! + * \brief Get the velocity (Structural Analysis). + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. + */ + inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } + + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } + + /*! + * \brief Get the velocity of the nodes (Structural Analysis) at time n. + * \param[in] iVar - Index of the variable. + * \return Pointer to the old solution vector. + */ + inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { + return Solution_Vel_time_n(iPoint,iVar); + } + + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } + + /*! + * \brief Set the value of the acceleration (Structural Analysis). + * \param[in] val_solution_accel - Solution of the problem (acceleration). + */ + inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; + } + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_accel - Value of the solution for the index iVar. + */ + inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final { + Solution_Accel(iPoint,iVar) = val_solution_accel; + } + + /*! + * \brief Set the value of the acceleration (Structural Analysis) at time n. + * \param[in] val_solution_old - Pointer to the residual vector. + */ + inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; + } + + /*! + * \brief Set the value of the acceleration (Structural Analysis) at time n. + */ + void SetSolution_Accel_time_n() final; + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] val_solution_accel_time_n - Value of the old solution for the index iVar. + */ + inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final { + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n; + } + + /*! + * \brief Get the acceleration (Structural Analysis). + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. + */ + inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } + + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } + + /*! + * \brief Get the acceleration of the nodes (Structural Analysis) at time n. + * \param[in] iVar - Index of the variable. + * \return Pointer to the old solution vector. + */ + inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { + return Solution_Accel_time_n(iPoint,iVar); + } + + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } + + /*! + * \brief Set the value of the solution velocity predictor. + */ + inline void SetSolution_Vel_Pred(unsigned long iPoint) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution_Vel(iPoint,iVar); + } + /*! * \brief Set the value of the old solution. * \param[in] val_solution_pred - Pointer to the residual vector. @@ -117,6 +267,12 @@ class CFEAVariable : public CVariable { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Pred(iPoint,iVar) = val_solution_pred[iVar]; } + /*! + * \brief Get the velocity solution. + * \return Pointer to velocity solution vector. + */ + inline const su2double *GetSolution_Vel_Pred(unsigned long iPoint) const final { return Solution_Vel_Pred[iPoint]; } + /*! * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index b367a5d62b9..59b3b125715 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1807,6 +1807,61 @@ class CVariable { return Solution_BGS_k(iPoint,iVar); } + /*! + * \brief A virtual member. Set the direct velocity solution for the adjoint solver. + * \param[in] solution_direct - Value of the direct velocity solution. + */ + inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} + + /*! + * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. + * \param[in] solution_direct - Value of the direct acceleration solution. + */ + inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} + + /*! + * \brief A virtual member. Get the direct velocity solution for the adjoint solver. + * \return Pointer to the direct velocity solution vector. + */ + inline virtual su2double* GetSolution_Vel_Direct(unsigned long iPoint) { return nullptr; } + + /*! + * \brief A virtual member. Get the direct acceleraction solution for the adjoint solver. + * \return Pointer to the direct acceleraction solution vector. + */ + inline virtual su2double* GetSolution_Accel_Direct(unsigned long iPoint) { return nullptr; } + + /*! + * \brief Set the value of the velocity (Structural Analysis). + * \param[in] solution - Solution of the problem (velocity). + */ + inline virtual void SetSolution_Vel(unsigned long iPoint, const su2double *solution) {} + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] solution_vel - Value of the solution for the index iVar. + */ + inline virtual void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double solution_vel) {} + + /*! + * \brief Set the value of the velocity (Structural Analysis) at time n. + * \param[in] solution_vel_time_n - Value of the old solution. + */ + inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *solution_vel_time_n) {} + + /*! + * \brief Set the value of the velocity (Structural Analysis) at time n. + */ + inline virtual void SetSolution_Vel_time_n() {} + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] solution_vel_time_n - Value of the old solution for the index iVar. + */ + inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_vel_time_n) {} + /*! * \brief Get the solution at time n. * \param[in] iVar - Index of the variable. @@ -1821,12 +1876,107 @@ class CVariable { */ inline su2double GetSolution_time_n1(unsigned long iPoint, unsigned long iVar) const { return Solution_time_n1(iPoint,iVar); } + /*! + * \brief Get the velocity (Structural Analysis). + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. + */ + inline virtual su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } + + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } + + /*! + * \brief Get the velocity of the nodes (Structural Analysis) at time n. + * \param[in] iVar - Index of the variable. + * \return Pointer to the old solution vector. + */ + inline virtual su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } + + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } + + + /*! + * \brief Set the value of the acceleration (Structural Analysis). + * \param[in] solution_accel - Solution of the problem (acceleration). + */ + inline virtual void SetSolution_Accel(unsigned long iPoint, const su2double *solution_accel) {} + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] solution_accel - Value of the solution for the index iVar. + */ + inline virtual void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double solution_accel) {} + + /*! + * \brief Set the value of the acceleration (Structural Analysis) at time n. + * \param[in] solution_accel_time_n - Pointer to the residual vector. + */ + inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *solution_accel_time_n) {} + + /*! + * \brief Set the value of the acceleration (Structural Analysis) at time n. + */ + inline virtual void SetSolution_Accel_time_n() {} + + /*! + * \overload + * \param[in] iVar - Index of the variable. + * \param[in] solution_accel_time_n - Value of the old solution for the index iVar. + */ + inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double solution_accel_time_n) {} + + /*! + * \brief Get the acceleration (Structural Analysis). + * \param[in] iVar - Index of the variable. + * \return Value of the solution for the index iVar. + */ + inline virtual su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } + + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } + + /*! + * \brief Get the acceleration of the nodes (Structural Analysis) at time n. + * \param[in] iVar - Index of the variable. + * \return Pointer to the old solution vector. + */ + inline virtual su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } + + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } + + /*! + * \brief A virtual member. Set the value of the velocity solution predictor. + */ + inline virtual void SetSolution_Vel_Pred(unsigned long iPoint) {} + /*! * \brief A virtual member. Set the value of the old solution. * \param[in] solution_pred - Pointer to the residual vector. */ inline virtual void SetSolution_Pred(unsigned long iPoint, const su2double *solution_pred) {} + /*! + * \brief A virtual member. Get the velocity solution predictor. + * \return Pointer to the velocity solution vector. + */ + inline virtual const su2double *GetSolution_Vel_Pred(unsigned long iPoint) const {return nullptr; } + /*! * \brief A virtual member. Get the solution at time n. * \return Pointer to the solution (at time n) vector. @@ -2155,22 +2305,6 @@ class CVariable { inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual void SetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual void SetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual su2double GetDynamic_Derivative_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - inline virtual su2double GetDynamic_Derivative_Vel_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - inline virtual void SetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual void SetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual su2double GetDynamic_Derivative_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - inline virtual su2double GetDynamic_Derivative_Accel_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetSolution_Old_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } inline virtual su2double GetSolution_Old_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index 31be9b7e8bd..a82763629ff 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -212,6 +212,8 @@ void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolv /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ solver->GetNodes()->Set_Solution_time_n(); + solver->GetNodes()->SetSolution_Vel_time_n(); + solver->GetNodes()->SetSolution_Accel_time_n(); /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 9036a822ffd..b0eea71aaf2 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -90,6 +90,14 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat dirNodes->Set_Solution_time_n(); + /*--- Push solution back to correct array ---*/ + + dirNodes->SetSolution_Accel_time_n(); + + /*--- Push solution back to correct array ---*/ + + dirNodes->SetSolution_Vel_time_n(); + /*--- Load solution timestep n ---*/ LoadDynamic_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter); @@ -100,6 +108,14 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); } + for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { + adjNodes->SetSolution_Accel_Direct(iPoint, dirNodes->GetSolution_Accel(iPoint)); + } + + for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { + adjNodes->SetSolution_Vel_Direct(iPoint, dirNodes->GetSolution_Vel(iPoint)); + } + } else { /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ @@ -132,6 +148,8 @@ void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry**** geometry, CSolver* for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { for (iVar = 0; iVar < solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetnVar(); iVar++) { solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, iVar, 0.0); + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel(iPoint, iVar, 0.0); + solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel(iPoint, iVar, 0.0); } } } diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index 77e81a665e9..55d2f9f84a0 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -202,13 +202,13 @@ void CElasticityOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSo if (nDim == 3) SetVolumeOutputValue("DISPLACEMENT-Z", iPoint, Node_Struc->GetSolution(iPoint, 2)); if(dynamic){ - SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution(iPoint, 0+nDim)); - SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution(iPoint, 1+nDim)); - if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution(iPoint, 3+nDim)); + SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Struc->GetSolution_Vel(iPoint, 0)); + SetVolumeOutputValue("VELOCITY-Y", iPoint, Node_Struc->GetSolution_Vel(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("VELOCITY-Z", iPoint, Node_Struc->GetSolution_Vel(iPoint, 2)); - SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution(iPoint, 0+2*nDim)); - SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution(iPoint, 1+2*nDim)); - if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution(iPoint, 2+2*nDim)); + SetVolumeOutputValue("ACCELERATION-X", iPoint, Node_Struc->GetSolution_Accel(iPoint, 0)); + SetVolumeOutputValue("ACCELERATION-Y", iPoint, Node_Struc->GetSolution_Accel(iPoint, 1)); + if (nDim == 3) SetVolumeOutputValue("ACCELERATION-Z", iPoint, Node_Struc->GetSolution_Accel(iPoint, 2)); } SetVolumeOutputValue("STRESS-XX", iPoint, Node_Struc->GetStress_FEM(iPoint)[0]); diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index 65b1141ea37..f7f8499963a 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -681,10 +681,10 @@ vector CDriver::GetFEA_Velocity(unsigned short iMarker, unsigned CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity[0] = solver->GetNodes()->GetSolution(iPoint, 0+geometry->GetnDim()); - Velocity[1] = solver->GetNodes()->GetSolution(iPoint, 1+geometry->GetnDim()); + Velocity[0] = solver->GetNodes()->GetSolution_Vel(iPoint, 0); + Velocity[1] = solver->GetNodes()->GetSolution_Vel(iPoint, 1); if (geometry->GetnDim() == 3) - Velocity[2] = solver->GetNodes()->GetSolution(iPoint, 2+geometry->GetnDim()); + Velocity[2] = solver->GetNodes()->GetSolution_Vel(iPoint, 2); else Velocity[2] = 0.0; } @@ -707,10 +707,10 @@ vector CDriver::GetFEA_Velocity_n(unsigned short iMarker, unsigne CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; if (config_container[ZONE_0]->GetDynamic_Analysis() == DYNAMIC){ - Velocity_n[0] = solver->GetNodes()->GetSolution_time_n(iPoint, 0+geometry->GetnDim()); - Velocity_n[1] = solver->GetNodes()->GetSolution_time_n(iPoint, 1+geometry->GetnDim()); + Velocity_n[0] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 0); + Velocity_n[1] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 1); if (geometry->GetnDim() == 3) - Velocity_n[2] = solver->GetNodes()->GetSolution_time_n(iPoint, 2+geometry->GetnDim()); + Velocity_n[2] = solver->GetNodes()->GetSolution_Vel_time_n(iPoint, 2); else Velocity_n[2] = 0.0; } diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 779691cef1f..2d6b756a922 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -39,7 +39,6 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv nVar = direct_solver->GetnVar(); nDim = geometry->GetnDim(); - if (dynamic) nVar = 3*nDim; /*-- Store some information about direct solver ---*/ this->KindDirect_Solver = Kind_Solver; @@ -144,6 +143,15 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ } if (config->GetTime_Domain()){ + /*--- Reset the solution to the initial (converged) solution ---*/ + + for (iPoint = 0; iPoint < nPoint; iPoint++){ + direct_solver->GetNodes()->SetSolution_Accel(iPoint, nodes->GetSolution_Accel_Direct(iPoint)); + } + + for (iPoint = 0; iPoint < nPoint; iPoint++){ + direct_solver->GetNodes()->SetSolution_Vel(iPoint, nodes->GetSolution_Vel_Direct(iPoint)); + } /*--- Reset the input for time n ---*/ @@ -152,6 +160,16 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); } } + for (iPoint = 0; iPoint < nPoint; iPoint++){ + for (iVar = 0; iVar < nVar; iVar++){ + AD::ResetInput(direct_solver->GetNodes()->GetSolution_Accel_time_n(iPoint)[iVar]); + } + } + for (iPoint = 0; iPoint < nPoint; iPoint++){ + for (iVar = 0; iVar < nVar; iVar++){ + AD::ResetInput(direct_solver->GetNodes()->GetSolution_Vel_time_n(iPoint)[iVar]); + } + } } @@ -178,10 +196,9 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ if (dynamic) { - /*--- Register solution at time step n-1 ---*/ + /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index); - } } @@ -250,6 +267,7 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; + const bool dynamic = config->GetTime_Domain(); const bool push_index = !config->GetMultizone_Problem(); /*--- Register variables as output of the solver iteration ---*/ @@ -267,7 +285,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co unsigned long iPoint; su2double residual; - su2double Solution[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; /*--- Set Residuals to zero ---*/ @@ -370,7 +388,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ const bool dynamic = (config->GetTime_Domain()); const bool deform_mesh = (config->GetnMarker_Deform_Mesh() > 0); - su2double Solution[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; unsigned short iVar; @@ -379,18 +397,22 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ Solution[iVar] = nodes->GetSolution(iPoint,iVar); } if(deform_mesh){ - for (iVar = 0; iVar < nDim; iVar++){ + for (iVar = 0; iVar < nVar; iVar++){ Solution[iVar] += nodes->GetSourceTerm_DispAdjoint(iPoint,iVar); } } if (dynamic){ - for (iVar = 0; iVar < nVar; iVar++){ + for (iVar = 0; iVar < nDim; iVar++){ Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); } + for (iVar = 0; iVar < nDim; iVar++){ + Solution_Accel[iVar] = nodes->GetSolution_Accel(iPoint,iVar) + nodes->GetDynamic_Derivative_n(iPoint,iVar+2*nDim); + } + for (iVar = 0; iVar < nDim; iVar++){ + Solution_Vel[iVar] = nodes->GetSolution_Vel(iPoint,iVar) + nodes->GetDynamic_Derivative_n(iPoint,iVar+nDim); + } if (deform_mesh){ - for (iVar = 0; iVar < nDim; iVar++){ - Solution[iVar+nDim] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); - } + Solution_Vel[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); } } direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 1955abf066f..1e243f73550 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -127,7 +127,6 @@ CFEASolver::CFEASolver(CGeometry *geometry, CConfig *config) : CSolver() { SetFSI_ConvValue(1,0.0); nVar = nDim; - if (dynamic) nVar = 3*nDim; /*--- Define some auxiliary vectors related to the residual ---*/ @@ -1409,12 +1408,12 @@ void CFEASolver::Compute_NodalStress(CGeometry *geometry, CNumerics **numerics, /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) } } @@ -1615,7 +1614,11 @@ void CFEASolver::BC_Clamped(CGeometry *geometry, const CConfig *config, unsigned nodes->SetSolution(iPoint, zeros); if (dynamic) { + nodes->SetSolution_Vel(iPoint, zeros); + nodes->SetSolution_Accel(iPoint, zeros); nodes->Set_Solution_time_n(iPoint, zeros); + nodes->SetSolution_Vel_time_n(iPoint, zeros); + nodes->SetSolution_Accel_time_n(iPoint, zeros); } /*--- Set and enforce 0 solution for mesh deformation ---*/ @@ -1631,6 +1634,8 @@ void CFEASolver::BC_Clamped(CGeometry *geometry, const CConfig *config, unsigned void CFEASolver::BC_Clamped_Post(CGeometry *geometry, const CConfig *config, unsigned short val_marker) { + bool dynamic = config->GetTime_Domain(); + su2double zeros[MAXNVAR] = {0.0}; for (auto iVertex = 0ul; iVertex < geometry->nVertex[val_marker]; iVertex++) { @@ -1640,6 +1645,11 @@ void CFEASolver::BC_Clamped_Post(CGeometry *geometry, const CConfig *config, uns nodes->SetSolution(iPoint, zeros); + if (dynamic) { + nodes->SetSolution_Vel(iPoint, zeros); + nodes->SetSolution_Accel(iPoint, zeros); + } + } } @@ -1685,7 +1695,11 @@ void CFEASolver::BC_Sym_Plane(CGeometry *geometry, const CConfig *config, unsign /*--- Set and enforce solution at current and previous time-step ---*/ nodes->SetSolution(iPoint, axis, 0.0); if (dynamic) { + nodes->SetSolution_Vel(iPoint, axis, 0.0); + nodes->SetSolution_Accel(iPoint, axis, 0.0); nodes->Set_Solution_time_n(iPoint, axis, 0.0); + nodes->SetSolution_Vel_time_n(iPoint, axis, 0.0); + nodes->SetSolution_Accel_time_n(iPoint, axis, 0.0); } /*--- Set and enforce 0 solution for mesh deformation ---*/ @@ -2078,8 +2092,8 @@ void CFEASolver::BC_Damper(CGeometry *geometry, const CConfig *config, unsigned /*--- Writing over the normal. --*/ su2double* force = normal; - for (iDim = 0; iDim < nDim; iDim++) - force[iDim] = dampCoeff * nodes->GetSolution(iPoint, iDim+nDim);//Vel Solution + for (iDim = 0; iDim < nVar; iDim++) + force[iDim] = dampCoeff * nodes->GetSolution_Vel(iPoint, iDim); nodes->Add_SurfaceLoad_Res(iPoint, force); } @@ -2228,12 +2242,12 @@ void CFEASolver::ImplicitNewmark_Iteration(const CGeometry *geometry, CNumerics /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) } } END_SU2_OMP_FOR @@ -2270,26 +2284,26 @@ void CFEASolver::ImplicitNewmark_Update(const CGeometry *geometry, const CConfig if (dynamic) { SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { /*--- Acceleration component of the solution. ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double sol = a_dt[0]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel - a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); - nodes->SetSolution(iPoint, iVar+2*nDim, sol); + nodes->SetSolution_Accel(iPoint, iVar, sol); /*--- Velocity component of the solution. ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel - a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel - a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel + sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); - nodes->SetSolution(iPoint, iVar+nDim, sol); + nodes->SetSolution_Vel(iPoint, iVar, sol); } } END_SU2_OMP_FOR @@ -2318,26 +2332,26 @@ void CFEASolver::ImplicitNewmark_Relaxation(const CGeometry *geometry, const CCo if (dynamic) { SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt) = a0*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double sol = a_dt[0]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel - a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); - nodes->SetSolution(iPoint, iVar+2*nDim, sol);//Accel + nodes->SetSolution_Accel(iPoint, iVar, sol); /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel - a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel - a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel + sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); - nodes->SetSolution(iPoint, iVar+nDim, sol); + nodes->SetSolution_Vel(iPoint, iVar, sol); } } END_SU2_OMP_FOR @@ -2412,12 +2426,12 @@ void CFEASolver::GeneralizedAlpha_Iteration(const CGeometry *geometry, CNumerics /*--- Loop over all points, and set aux vector TimeRes_Aux = a0*U+a2*U'+a3*U'' ---*/ SU2_OMP_FOR_STAT(omp_chunk_size) for (iPoint = 0; iPoint < nPoint; iPoint++) { - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { TimeRes_Aux(iPoint,iVar) = a_dt[0]*nodes->GetSolution_time_n(iPoint,iVar) - // a0*U(t) a_dt[0]*nodes->GetSolution(iPoint,iVar) + // a0*U(t+dt)(k-1) - a_dt[2]*nodes->GetSolution_time_n(iPoint,iVar+nDim) + // a2*U'(t) - a_dt[3]*nodes->GetSolution_time_n(iPoint,iVar+2*nDim); // a3*U''(t) + a_dt[2]*nodes->GetSolution_Vel_time_n(iPoint,iVar) + // a2*U'(t) + a_dt[3]*nodes->GetSolution_Accel_time_n(iPoint,iVar); // a3*U''(t) } } END_SU2_OMP_FOR @@ -2496,31 +2510,31 @@ void CFEASolver::GeneralizedAlpha_UpdateSolution(const CGeometry *geometry, cons nodes->SetSolution(iPoint, iVar, sol); } - for (iVar = 0; iVar < nDim; iVar++) { + for (iVar = 0; iVar < nVar; iVar++) { /*--- Acceleration component of the solution ---*/ /*--- U''(t+dt-alpha_m) = a8*(U(t+dt)-U(t))+a2*(U'(t))+a3*(U''(t)) ---*/ su2double tmp = a_dt[8]*(nodes->GetSolution(iPoint,iVar) - nodes->GetSolution_time_n(iPoint,iVar)) - - a_dt[2]* nodes->GetSolution_time_n(iPoint,iVar+nDim) -//Vel - a_dt[3]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim);//Accel + a_dt[2]* nodes->GetSolution_Vel_time_n(iPoint,iVar) - + a_dt[3]* nodes->GetSolution_Accel_time_n(iPoint,iVar); /*--- Compute the solution from the previous time step and the solution computed at t+1-alpha_f ---*/ /*--- U''(t+dt) = 1/alpha_m*(U''(t+1-alpha_m)-alpha_m*U''(t)) ---*/ - su2double sol = (1/(1-alpha_m)) * (tmp - alpha_m*nodes->GetSolution_time_n(iPoint,iVar+2*nDim)); + su2double sol = (1/(1-alpha_m)) * (tmp - alpha_m*nodes->GetSolution_Accel_time_n(iPoint,iVar)); - nodes->SetSolution(iPoint, iVar+2*nDim, sol);//Accel + nodes->SetSolution_Accel(iPoint, iVar, sol); /*--- Velocity component of the solution ---*/ /*--- U'(t+dt) = U'(t)+ a6*(U''(t)) + a7*(U''(t+dt)) ---*/ - sol = nodes->GetSolution_time_n(iPoint,iVar+nDim)+//Vel - a_dt[6]* nodes->GetSolution_time_n(iPoint,iVar+2*nDim) +//Accel - a_dt[7]* nodes->GetSolution(iPoint,iVar+2*nDim);//Accel + sol = nodes->GetSolution_Vel_time_n(iPoint,iVar)+ + a_dt[6]* nodes->GetSolution_Accel_time_n(iPoint,iVar) + + a_dt[7]* nodes->GetSolution_Accel(iPoint,iVar); - nodes->SetSolution(iPoint, iVar+nDim, sol);//Vel + nodes->SetSolution_Vel(iPoint, iVar, sol); } } @@ -2574,6 +2588,7 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * const unsigned short predOrder = config->GetPredictorOrder(); const su2double Delta_t = config->GetDelta_DynTime(); + const bool dynamic = config->GetTime_Domain(); if(predOrder > 2 && rank == MASTER_NODE) cout << "Higher order predictor not implemented. Solving with order 0." << endl; @@ -2587,20 +2602,23 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * switch (predOrder) { case 1: { const su2double* solDisp = nodes->GetSolution(iPoint); + const su2double* solVel = nodes->GetSolution_Vel(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + Delta_t*nodes->GetSolution(iPoint, iDim+nDim); + valPred[iDim] = solDisp[iDim] + Delta_t*solVel[iDim]; nodes->SetSolution_Pred(iPoint, valPred); } break; case 2: { const su2double* solDisp = nodes->GetSolution(iPoint); + const su2double* solVel = nodes->GetSolution_Vel(iPoint); + const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*nodes->GetSolution(iPoint, iDim+nDim)-nodes->GetSolution_time_n(iPoint, iDim+nDim)); + valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*solVel[iDim]-solVel_tn[iDim]); nodes->SetSolution_Pred(iPoint, valPred); } break; @@ -2610,6 +2628,8 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * } break; } + if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); + } END_SU2_OMP_PARALLEL @@ -2708,6 +2728,7 @@ void CFEASolver::ComputeAitken_Coefficient(CGeometry *geometry, const CConfig *c void CFEASolver::SetAitken_Relaxation(CGeometry *geometry, const CConfig *config) { const su2double WAitken = GetWAitken_Dyn(); + const bool dynamic = config->GetTime_Domain(); /*--- To nPoint to avoid communication. ---*/ SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) @@ -2723,6 +2744,9 @@ void CFEASolver::SetAitken_Relaxation(CGeometry *geometry, const CConfig *config /*--- Set calculated solution as the old solution (needed for dynamic Aitken relaxation) ---*/ nodes->SetSolution_Old(iPoint, dispCalc); + /*--- Set predicted velocity to update in multizone iterations ---*/ + if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); + /*--- Apply the Aitken relaxation ---*/ su2double newDispPred[MAXNVAR] = {0.0}; for (unsigned short iDim=0; iDim < nDim; iDim++) @@ -3136,18 +3160,14 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c const auto index = counter*Restart_Vars[1] + skipVars; const passivedouble* Sol = &Restart_Data[index]; - for (unsigned short iVar = 0; iVar < nDim; iVar++) { + for (unsigned short iVar = 0; iVar < nVar; iVar++) { nodes->SetSolution(iPoint_Local, iVar, Sol[iVar]); if (dynamic) { - nodes->SetSolution(iPoint_Local, iVar+nDim, Sol[iVar+nVar]); - nodes->SetSolution(iPoint_Local, iVar+2*nDim, Sol[iVar+2*nVar]); + nodes->SetSolution_Vel(iPoint_Local, iVar, Sol[iVar+nVar]); + nodes->SetSolution_Accel(iPoint_Local, iVar, Sol[iVar+2*nVar]); } if (fluid_structure && discrete_adjoint){ nodes->SetSolution_Old(iPoint_Local, iVar, Sol[iVar]); - if (dynamic) { - nodes->SetSolution_Old(iPoint_Local, iVar+nDim, Sol[iVar+nVar]); - nodes->SetSolution_Old(iPoint_Local, iVar+2*nDim, Sol[iVar+2*nVar]); - } } } @@ -3171,6 +3191,8 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c if (dynamic) { nodes->Set_Solution_time_n(); + nodes->SetSolution_Vel_time_n(); + nodes->SetSolution_Accel_time_n(); } if (fluid_structure) { @@ -3179,6 +3201,11 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c nodes->SetSolution_Pred_Old(iPoint, nodes->GetSolution(iPoint)); } + if (dynamic) { + for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) + nodes->SetSolution_Vel_Pred(iPoint); + } + if (discrete_adjoint) { for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) nodes->SetSolution_Old(iPoint, nodes->GetSolution(iPoint)); diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index c443ef351f7..d1db5557656 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -1500,6 +1500,10 @@ void CSolver::InitiateComms(CGeometry *geometry, case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { bufDSend[buf_offset+iVar] = base_nodes->GetSolution(iPoint, iVar); + if (config->GetTime_Domain()) { + bufDSend[buf_offset+nVar+iVar] = base_nodes->GetSolution_Vel(iPoint, iVar); + bufDSend[buf_offset+nVar*2+iVar] = base_nodes->GetSolution_Accel(iPoint, iVar); + } } break; case MESH_DISPLACEMENTS: @@ -1647,6 +1651,10 @@ void CSolver::CompleteComms(CGeometry *geometry, case SOLUTION_FEA: for (iVar = 0; iVar < nVar; iVar++) { base_nodes->SetSolution(iPoint, iVar, bufDRecv[buf_offset+iVar]); + if (config->GetTime_Domain()) { + base_nodes->SetSolution_Vel(iPoint, iVar, bufDRecv[buf_offset+nVar+iVar]); + base_nodes->SetSolution_Accel(iPoint, iVar, bufDRecv[buf_offset+nVar*2+iVar]); + } } break; case MESH_DISPLACEMENTS: diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index 5588ecb4b9a..f4fb5e3ec34 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -32,7 +32,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double *vel, const su2double *accel, unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : CVariable(npoint, ndim, nvar, config) { - Solution_Direct.resize(nPoint,nVar); + Solution_Direct.resize(nPoint,nDim); Sensitivity.resize(nPoint,nDim) = su2double(0.0); Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); @@ -63,4 +63,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double Dynamic_Derivative.resize(nPoint,nVar) = su2double(0.0); Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); + Solution_Direct_Vel.resize(nPoint,nDim) = su2double(0.0); + Solution_Direct_Accel.resize(nPoint,nDim) = su2double(0.0); + } diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index a9381f723c2..2c966777245 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -49,23 +49,28 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig /*--- Initialization of variables ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) - for (unsigned long iVar = 0; iVar < nDim; iVar++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { + Solution_Vel.resize(nPoint,nVar); + Solution_Accel.resize(nPoint,nVar); + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = nDim; iVar < 2*nDim; iVar++) { - Solution(iPoint,iVar) = val_fea[iVar+nDim]; - } - for (unsigned long iVar = 2*nDim; iVar < 3*nDim; iVar++) { - Solution(iPoint,iVar) = val_fea[iVar+2*nDim]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; + Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; } } + Solution_Vel_time_n = Solution_Vel; + Solution_Accel_time_n = Solution_Accel; + } if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; + if (dynamic_analysis) Solution_Vel_Pred = Solution_Vel; } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ @@ -91,6 +96,10 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } } +void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } + +void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } + void CFEAVariable::Register_femSolution_time_n(bool input, bool push_index) { for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for(unsigned long iVar=0; iVar Date: Mon, 3 May 2021 14:12:07 +0100 Subject: [PATCH 044/192] fix modified variables and indices --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 29 ++++++----------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 2d6b756a922..2ec438dda62 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -160,17 +160,6 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); } } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->GetNodes()->GetSolution_Accel_time_n(iPoint)[iVar]); - } - } - for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - AD::ResetInput(direct_solver->GetNodes()->GetSolution_Vel_time_n(iPoint)[iVar]); - } - } - } /*--- Set the Jacobian to zero since this is not done inside the meanflow iteration @@ -285,7 +274,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co unsigned long iPoint; su2double residual; - su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}; /*--- Set Residuals to zero ---*/ @@ -388,7 +377,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ const bool dynamic = (config->GetTime_Domain()); const bool deform_mesh = (config->GetnMarker_Deform_Mesh() > 0); - su2double Solution[MAXNVAR] = {0.0}, Solution_Vel[MAXNVAR] = {0.0}, Solution_Accel[MAXNVAR] = {0.0}; + su2double Solution[MAXNVAR] = {0.0}; unsigned short iVar; @@ -397,22 +386,18 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ Solution[iVar] = nodes->GetSolution(iPoint,iVar); } if(deform_mesh){ - for (iVar = 0; iVar < nVar; iVar++){ + for (iVar = 0; iVar < nDim; iVar++){ Solution[iVar] += nodes->GetSourceTerm_DispAdjoint(iPoint,iVar); } } if (dynamic){ - for (iVar = 0; iVar < nDim; iVar++){ + for (iVar = 0; iVar < nVar; iVar++){ Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); } - for (iVar = 0; iVar < nDim; iVar++){ - Solution_Accel[iVar] = nodes->GetSolution_Accel(iPoint,iVar) + nodes->GetDynamic_Derivative_n(iPoint,iVar+2*nDim); - } - for (iVar = 0; iVar < nDim; iVar++){ - Solution_Vel[iVar] = nodes->GetSolution_Vel(iPoint,iVar) + nodes->GetDynamic_Derivative_n(iPoint,iVar+nDim); - } if (deform_mesh){ - Solution_Vel[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); + for (iVar = nDim; iVar < 2*nDim; iVar++){ + Solution[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar-nDim); + } } } direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); From 8c26d1b98a5ff7d94f36eb7dde2606507376689a Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 14:20:43 +0100 Subject: [PATCH 045/192] unused dynamic flag --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 2ec438dda62..3134498010f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -256,7 +256,6 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; - const bool dynamic = config->GetTime_Domain(); const bool push_index = !config->GetMultizone_Problem(); /*--- Register variables as output of the solver iteration ---*/ From cb3ff26e779003e90249d7863aad8b10a40e38ac Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 3 May 2021 14:40:44 +0100 Subject: [PATCH 046/192] undo changes to interface --- .../fsi/CDisplacementsInterface.cpp | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp index f98eb9247c5..56d5d895152 100644 --- a/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp +++ b/SU2_CFD/src/interfaces/fsi/CDisplacementsInterface.cpp @@ -40,12 +40,14 @@ void CDisplacementsInterface::GetDonor_Variable(CSolver *struct_solution, CGeome unsigned long Vertex_Struct, unsigned long Point_Struct) { /*--- The displacements come from the predicted solution, but they are no longer incremental ---*/ auto DisplacementDonor = struct_solution->GetNodes()->GetSolution_Pred(Point_Struct); - unsigned short nDim = struct_geometry->GetnDim(); - for (auto iDim = 0u; iDim < nDim; iDim++) { - Donor_Variable[iDim] = DisplacementDonor[iDim]; - if (struct_config->GetTime_Domain()) - Donor_Variable[iDim+nDim] = DisplacementDonor[iDim+nDim]; + for (auto iVar = 0u; iVar < nVar; iVar++) + Donor_Variable[iVar] = DisplacementDonor[iVar]; + + if (struct_config->GetTime_Domain()) { + auto VelocityDonor = struct_solution->GetNodes()->GetSolution_Vel_Pred(Point_Struct); + for (auto iVar = nVar/2; iVar < nVar; iVar++)//Assuming dynamic interface always has nVar = 2*nDim, 2D: 4, 3D: 6 + Donor_Variable[iVar] = VelocityDonor[iVar-nVar/2]; } } @@ -57,14 +59,12 @@ void CDisplacementsInterface::SetTarget_Variable(CSolver *mesh_solver, CGeometry /*--- Impose the boundary displacements ---*/ mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,Target_Variable); } else { - unsigned short nDim = flow_geometry->GetnDim(); - /*--- Impose the boundary displacements ---*/ - for (auto iDim = 0u; iDim < nDim; iDim++) { - mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,iDim,Target_Variable[iDim]); + for (auto iVar = 0u; iVar < nVar/2; iVar++) + mesh_solver->GetNodes()->SetBound_Disp(Point_Mesh,iVar,Target_Variable[iVar]); - /*--- Impose the boundary velocities ---*/ - mesh_solver->GetNodes()->SetBound_Vel(Point_Mesh,iDim,Target_Variable[iDim+nDim]); - } + /*--- Impose the boundary velocities ---*/ + for (auto iVar = nVar/2; iVar < nVar; iVar++) + mesh_solver->GetNodes()->SetBound_Vel(Point_Mesh,iVar-nVar/2,Target_Variable[iVar]); } } From 84f446b398a94776e7f0f8998c6bebb111d0a404 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 4 May 2021 08:16:36 +0100 Subject: [PATCH 047/192] try halfway with updated primal solution with small solver changes --- SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp | 4 +- .../include/variables/CDiscAdjFEAVariable.hpp | 12 +-- SU2_CFD/include/variables/CFEAVariable.hpp | 93 +++++++++++-------- SU2_CFD/include/variables/CVariable.hpp | 50 +++++----- .../integration/CStructuralIntegration.cpp | 4 +- .../src/iteration/CDiscAdjFEAIteration.cpp | 20 ++-- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 19 ++-- SU2_CFD/src/solvers/CFEASolver.cpp | 18 ++-- SU2_CFD/src/variables/CFEAVariable.cpp | 67 ++++++++++--- 9 files changed, 182 insertions(+), 105 deletions(-) diff --git a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp index c35e0f4951c..2163e78e593 100644 --- a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp @@ -38,8 +38,8 @@ */ class CDiscAdjFEASolver final : public CSolver { private: - static constexpr size_t MAXNVAR = 3; /*!< \brief Max number of variables, for static arrays. */ - + static constexpr size_t MAXNVAR = 9; /*!< \brief Max number of variables, for static arrays. */ +//CVC: How to only set to 9 for dynamic? unsigned short KindDirect_Solver = 0; CSolver *direct_solver = nullptr; diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index c2396d5ecfe..6e5a0f35b98 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -112,16 +112,16 @@ class CDiscAdjFEAVariable : public CVariable { return Dynamic_Derivative_n(iPoint,iVar); } - inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; + inline void SetSolution_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { + Solution_Direct(iPoint,iVar) = val_solution_direct; } - inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; + inline void SetSolution_Vel_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { + Solution_Direct_Vel(iPoint,iVar) = val_solution_direct; } - inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; + inline void SetSolution_Accel_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { + Solution_Direct_Accel(iPoint,iVar) = val_solution_direct; } inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index e74d1a549dc..22c74615a1f 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -45,12 +45,6 @@ class CFEAVariable : public CVariable { VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ - MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ - MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ - - MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ - MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ - MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ @@ -59,6 +53,12 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ + su2matrix AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + + su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + /*! * \brief Constructor of the class. * \note This class is not supposed to be instantiated, it is only a building block for CFEABoundVariable @@ -121,7 +121,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel - Solution of the problem (velocity). */ inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar+nDim) = val_solution_vel[iVar]; } /*! @@ -130,7 +130,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel - Value of the solution for the index iVar. */ inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final { - Solution_Vel(iPoint,iVar) = val_solution_vel; + Solution(iPoint,iVar+nDim) = val_solution_vel; } /*! @@ -144,7 +144,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel_time_n - Pointer to the residual vector. */ inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_time_n(iPoint,iVar+nDim) = val_solution_vel_time_n[iVar]; } /*! @@ -153,7 +153,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel_time_n - Value of the old solution for the index iVar. */ inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final { - Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n; + Solution_time_n(iPoint,iVar+nDim) = val_solution_vel_time_n; } /*! @@ -161,13 +161,13 @@ class CFEAVariable : public CVariable { * \param[in] iVar - Index of the variable. * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } + inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution(iPoint,iVar+nDim); } - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } + // /*! + // * \brief Get the solution of the problem. + // * \return Pointer to the solution vector. + // */ + // inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution(iPoint,nDim); } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. @@ -175,21 +175,21 @@ class CFEAVariable : public CVariable { * \return Pointer to the old solution vector. */ inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_Vel_time_n(iPoint,iVar); + return Solution_time_n(iPoint,iVar+nDim); } - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } + // /*! + // * \brief Get the solution at time n. + // * \return Pointer to the solution (at time n) vector. + // */ + // inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_time_n(iPoint,nDim); } /*! * \brief Set the value of the acceleration (Structural Analysis). * \param[in] val_solution_accel - Solution of the problem (acceleration). */ inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar+2*nDim) = val_solution_accel[iVar]; } /*! @@ -198,7 +198,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_accel - Value of the solution for the index iVar. */ inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final { - Solution_Accel(iPoint,iVar) = val_solution_accel; + Solution(iPoint,iVar+2*nDim) = val_solution_accel; } /*! @@ -207,7 +207,7 @@ class CFEAVariable : public CVariable { */ inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; + Solution_time_n(iPoint,iVar+2*nDim) = val_solution_accel_time_n[iVar]; } /*! @@ -221,7 +221,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_accel_time_n - Value of the old solution for the index iVar. */ inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final { - Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n; + Solution_time_n(iPoint,iVar+2*nDim) = val_solution_accel_time_n; } /*! @@ -229,13 +229,13 @@ class CFEAVariable : public CVariable { * \param[in] iVar - Index of the variable. * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } + inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution(iPoint,iVar+2*nDim); } - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } + // /*! + // * \brief Get the solution of the problem. + // * \return Pointer to the solution vector. + // */ + // inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution(iPoint,2*nDim); } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. @@ -243,20 +243,20 @@ class CFEAVariable : public CVariable { * \return Pointer to the old solution vector. */ inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_Accel_time_n(iPoint,iVar); + return Solution_time_n(iPoint,iVar+2*nDim); } - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } + // /*! + // * \brief Get the solution at time n. + // * \return Pointer to the solution (at time n) vector. + // */ + // inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_time_n(iPoint, 2*nDim); } /*! * \brief Set the value of the solution velocity predictor. */ inline void SetSolution_Vel_Pred(unsigned long iPoint) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution_Vel(iPoint,iVar); + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); } /*! @@ -340,5 +340,20 @@ class CFEAVariable : public CVariable { * \param[in] input - input or output variables. */ void Register_femSolution_time_n(bool input, bool push_index) final; + void Register_femSolution(bool input, bool push_index) final; + inline void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_InputIndex(iPoint,iVar)); + } + + inline void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { + for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) + adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); + } + + inline void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) { + for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) + SU2_TYPE::SetDerivative(Solution(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); + } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 59b3b125715..8af45bcdb80 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1718,6 +1718,7 @@ class CVariable { * \param[in] solution_direct - Value of the direct solution. */ inline virtual void SetSolution_Direct(unsigned long iPoint, const su2double *solution_direct) {} + inline virtual void SetSolution_Direct(unsigned long iPoint, unsigned long iVar, const su2double solution_direct) {} /*! * \brief A virtual member. Get the direct solution for the adjoint solver. @@ -1811,13 +1812,13 @@ class CVariable { * \brief A virtual member. Set the direct velocity solution for the adjoint solver. * \param[in] solution_direct - Value of the direct velocity solution. */ - inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} + inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, unsigned long iVar, const su2double sol) {} /*! * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. * \param[in] solution_direct - Value of the direct acceleration solution. */ - inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} + inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, unsigned long iVar, const su2double sol) {} /*! * \brief A virtual member. Get the direct velocity solution for the adjoint solver. @@ -1883,11 +1884,11 @@ class CVariable { */ inline virtual su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } + // /*! + // * \brief Get the solution of the problem. + // * \return Pointer to the solution vector. + // */ + // inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. @@ -1896,11 +1897,11 @@ class CVariable { */ inline virtual su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } + // /*! + // * \brief Get the solution at time n. + // * \return Pointer to the solution (at time n) vector. + // */ + // inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } /*! @@ -1941,11 +1942,11 @@ class CVariable { */ inline virtual su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! - * \brief Get the solution of the problem. - * \return Pointer to the solution vector. - */ - inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } + // /*! + // * \brief Get the solution of the problem. + // * \return Pointer to the solution vector. + // */ + // inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. @@ -1954,11 +1955,11 @@ class CVariable { */ inline virtual su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! - * \brief Get the solution at time n. - * \return Pointer to the solution (at time n) vector. - */ - inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } + // /*! + // * \brief Get the solution at time n. + // * \return Pointer to the solution (at time n) vector. + // */ + // inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Set the value of the velocity solution predictor. @@ -2142,7 +2143,10 @@ class CVariable { * \brief A virtual member. */ inline virtual void Register_femSolution_time_n(bool input, bool push_index) {} - + inline virtual void Register_femSolution(bool input, bool push_index) {} + inline virtual void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) {} + inline virtual void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) {} + inline virtual void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) {} /*! * \brief A virtual member. */ diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index a82763629ff..980255840a3 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -212,8 +212,8 @@ void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolv /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ solver->GetNodes()->Set_Solution_time_n(); - solver->GetNodes()->SetSolution_Vel_time_n(); - solver->GetNodes()->SetSolution_Accel_time_n(); + // solver->GetNodes()->SetSolution_Vel_time_n(); + // solver->GetNodes()->SetSolution_Accel_time_n(); /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index b0eea71aaf2..ef081adbc6f 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -90,13 +90,13 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat dirNodes->Set_Solution_time_n(); - /*--- Push solution back to correct array ---*/ + // /*--- Push solution back to correct array ---*/ - dirNodes->SetSolution_Accel_time_n(); + // dirNodes->SetSolution_Accel_time_n(); - /*--- Push solution back to correct array ---*/ + // /*--- Push solution back to correct array ---*/ - dirNodes->SetSolution_Vel_time_n(); + // dirNodes->SetSolution_Vel_time_n(); /*--- Load solution timestep n ---*/ @@ -105,15 +105,21 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); + for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ + adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); + } } for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Accel_Direct(iPoint, dirNodes->GetSolution_Accel(iPoint)); + for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ + adjNodes->SetSolution_Accel_Direct(iPoint, iVar, dirNodes->GetSolution_Accel(iPoint, iVar)); + } } for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Vel_Direct(iPoint, dirNodes->GetSolution_Vel(iPoint)); + for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ + adjNodes->SetSolution_Vel_Direct(iPoint, iVar, dirNodes->GetSolution_Vel(iPoint, iVar)); + } } } else { diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 3134498010f..579f5f3e6f8 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -181,9 +181,10 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - direct_solver->GetNodes()->RegisterSolution(input, push_index); + if (!dynamic) direct_solver->GetNodes()->RegisterSolution(input, push_index); if (dynamic) { + direct_solver->GetNodes()->Register_femSolution(input, push_index); /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ @@ -290,7 +291,8 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution ---*/ if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); + // direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution_LocalIndex(iPoint,Solution); } else { direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); @@ -312,7 +314,8 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); + // direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution_time_n_LocalIndex(iPoint,Solution); } else { direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); @@ -399,8 +402,12 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ } } } - direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); - + if (config->GetMultizone_Problem()) { + direct_solver->GetNodes()->SetfemAdjointSolution_LocalIndex(iPoint,Solution); + } + else { + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); + } } } @@ -411,7 +418,7 @@ void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_cont if (config_container->GetTime_Domain()){ for (auto iPoint = 0ul; iPoint < nPoint; iPoint++){ - for (iVar=0; iVar < nVar; iVar++){ + for (iVar=0; iVar < 3*nDim; iVar++){ nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); } } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 1e243f73550..a9365826fad 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2601,24 +2601,24 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * switch (predOrder) { case 1: { - const su2double* solDisp = nodes->GetSolution(iPoint); - const su2double* solVel = nodes->GetSolution_Vel(iPoint); + // const su2double* solDisp = nodes->GetSolution(iPoint); + // const su2double* solVel = nodes->GetSolution_Vel(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + Delta_t*solVel[iDim]; + valPred[iDim] = nodes->GetSolution(iPoint,iDim) + Delta_t*nodes->GetSolution_Vel(iPoint,iDim); nodes->SetSolution_Pred(iPoint, valPred); } break; case 2: { - const su2double* solDisp = nodes->GetSolution(iPoint); - const su2double* solVel = nodes->GetSolution_Vel(iPoint); - const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); + // const su2double* solDisp = nodes->GetSolution(iPoint); + // const su2double* solVel = nodes->GetSolution_Vel(iPoint); + // const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*solVel[iDim]-solVel_tn[iDim]); + valPred[iDim] = nodes->GetSolution(iPoint,iDim) + 0.5*Delta_t*(3*nodes->GetSolution_Vel(iPoint,iDim)-nodes->GetSolution_Vel_time_n(iPoint,iDim)); nodes->SetSolution_Pred(iPoint, valPred); } break; @@ -3191,8 +3191,8 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c if (dynamic) { nodes->Set_Solution_time_n(); - nodes->SetSolution_Vel_time_n(); - nodes->SetSolution_Accel_time_n(); + // nodes->SetSolution_Vel_time_n(); + // nodes->SetSolution_Accel_time_n(); } if (fluid_structure) { diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 2c966777245..718804f5ede 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -47,30 +47,42 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig if (nDim==2) Stress.resize(nPoint,3); else Stress.resize(nPoint,6); + // if (dynamic_analysis) Solution.resize(nPoint,3*nDim); /*--- Initialization of variables ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { - Solution_Vel.resize(nPoint,nVar); - Solution_Accel.resize(nPoint,nVar); - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; - Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; + Solution(iPoint,iVar+nDim) = val_fea[iVar+nVar]; + Solution(iPoint,iVar+2*nDim) = val_fea[iVar+2*nVar]; } } - Solution_Vel_time_n = Solution_Vel; - Solution_Accel_time_n = Solution_Accel; + Solution_time_n = Solution; + if(config->GetMultizone_Problem() && config->GetAD_Mode()) { + AD_InputIndex.resize(nPoint,3*nDim) = -1; + AD_OutputIndex.resize(nPoint,3*nDim) = -1; + if (config->GetTime_Domain()) { + AD_Time_n_InputIndex.resize(nPoint,3*nDim) = -1; + AD_Time_n_OutputIndex.resize(nPoint,3*nDim) = -1; + } + } } if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; - if (dynamic_analysis) Solution_Vel_Pred = Solution_Vel; + if (dynamic_analysis) { + Solution_Vel_Pred.resize(nPoint,nVar); + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); + } + } + } } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ @@ -96,13 +108,46 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } } -void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } +void CFEAVariable::SetSolution_Vel_time_n() { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_time_n(iPoint,iVar+nDim) = Solution(iPoint,iVar+nDim); + } + } +} + +void CFEAVariable::SetSolution_Accel_time_n() { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for (unsigned long iVar = 0; iVar < nVar; iVar++) { + Solution_time_n(iPoint,iVar+2*nDim) = Solution(iPoint,iVar+2*nDim); + } + } +} -void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } +void CFEAVariable::Register_femSolution(bool input, bool push_index) { + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for(unsigned long iVar=0; iVar Date: Tue, 4 May 2021 08:54:04 +0100 Subject: [PATCH 048/192] alternative approach with combining dynamic structural solution for adjoints only --- .../include/variables/CDiscAdjFEAVariable.hpp | 12 +- SU2_CFD/include/variables/CFEAVariable.hpp | 112 +++++++------ SU2_CFD/include/variables/CVariable.hpp | 66 ++++---- .../integration/CStructuralIntegration.cpp | 4 +- .../src/iteration/CDiscAdjFEAIteration.cpp | 20 +-- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 27 ++- SU2_CFD/src/solvers/CFEASolver.cpp | 18 +- SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 4 +- SU2_CFD/src/variables/CFEAVariable.cpp | 157 ++++++++++++++---- 9 files changed, 258 insertions(+), 162 deletions(-) diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index 6e5a0f35b98..c2396d5ecfe 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -112,16 +112,16 @@ class CDiscAdjFEAVariable : public CVariable { return Dynamic_Derivative_n(iPoint,iVar); } - inline void SetSolution_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { - Solution_Direct(iPoint,iVar) = val_solution_direct; + inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Vel_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { - Solution_Direct_Vel(iPoint,iVar) = val_solution_direct; + inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Accel_Direct(unsigned long iPoint, unsigned long iVar, const su2double val_solution_direct) final { - Solution_Direct_Accel(iPoint,iVar) = val_solution_direct; + inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; } inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 22c74615a1f..9f9d4e91f46 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -45,6 +45,12 @@ class CFEAVariable : public CVariable { VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ + MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ + MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ + + MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ + MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ + MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ @@ -53,11 +59,14 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ - su2matrix AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + su2matrix AD_Vel_InputIndex; + su2matrix AD_Vel_OutputIndex; + su2matrix AD_Vel_Time_n_InputIndex; + su2matrix AD_Vel_Time_n_OutputIndex; + su2matrix AD_Accel_InputIndex; + su2matrix AD_Accel_OutputIndex; + su2matrix AD_Accel_Time_n_InputIndex; + su2matrix AD_Accel_Time_n_OutputIndex; /*! * \brief Constructor of the class. @@ -121,7 +130,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel - Solution of the problem (velocity). */ inline void SetSolution_Vel(unsigned long iPoint, const su2double *val_solution_vel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar+nDim) = val_solution_vel[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel(iPoint,iVar) = val_solution_vel[iVar]; } /*! @@ -130,7 +139,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel - Value of the solution for the index iVar. */ inline void SetSolution_Vel(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel) final { - Solution(iPoint,iVar+nDim) = val_solution_vel; + Solution_Vel(iPoint,iVar) = val_solution_vel; } /*! @@ -144,7 +153,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel_time_n - Pointer to the residual vector. */ inline void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *val_solution_vel_time_n) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_time_n(iPoint,iVar+nDim) = val_solution_vel_time_n[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n[iVar]; } /*! @@ -153,7 +162,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_vel_time_n - Value of the old solution for the index iVar. */ inline void SetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_vel_time_n) final { - Solution_time_n(iPoint,iVar+nDim) = val_solution_vel_time_n; + Solution_Vel_time_n(iPoint,iVar) = val_solution_vel_time_n; } /*! @@ -161,13 +170,13 @@ class CFEAVariable : public CVariable { * \param[in] iVar - Index of the variable. * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution(iPoint,iVar+nDim); } + inline su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Vel(iPoint,iVar); } - // /*! - // * \brief Get the solution of the problem. - // * \return Pointer to the solution vector. - // */ - // inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution(iPoint,nDim); } + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. @@ -175,21 +184,21 @@ class CFEAVariable : public CVariable { * \return Pointer to the old solution vector. */ inline su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_time_n(iPoint,iVar+nDim); + return Solution_Vel_time_n(iPoint,iVar); } - // /*! - // * \brief Get the solution at time n. - // * \return Pointer to the solution (at time n) vector. - // */ - // inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_time_n(iPoint,nDim); } + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } /*! * \brief Set the value of the acceleration (Structural Analysis). * \param[in] val_solution_accel - Solution of the problem (acceleration). */ inline void SetSolution_Accel(unsigned long iPoint, const su2double *val_solution_accel) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar+2*nDim) = val_solution_accel[iVar]; + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Accel(iPoint,iVar) = val_solution_accel[iVar]; } /*! @@ -198,7 +207,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_accel - Value of the solution for the index iVar. */ inline void SetSolution_Accel(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel) final { - Solution(iPoint,iVar+2*nDim) = val_solution_accel; + Solution_Accel(iPoint,iVar) = val_solution_accel; } /*! @@ -207,7 +216,7 @@ class CFEAVariable : public CVariable { */ inline void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *val_solution_accel_time_n) final { for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution_time_n(iPoint,iVar+2*nDim) = val_solution_accel_time_n[iVar]; + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; } /*! @@ -221,7 +230,7 @@ class CFEAVariable : public CVariable { * \param[in] val_solution_accel_time_n - Value of the old solution for the index iVar. */ inline void SetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar, su2double val_solution_accel_time_n) final { - Solution_time_n(iPoint,iVar+2*nDim) = val_solution_accel_time_n; + Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n; } /*! @@ -229,13 +238,13 @@ class CFEAVariable : public CVariable { * \param[in] iVar - Index of the variable. * \return Value of the solution for the index iVar. */ - inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution(iPoint,iVar+2*nDim); } + inline su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const final { return Solution_Accel(iPoint,iVar); } - // /*! - // * \brief Get the solution of the problem. - // * \return Pointer to the solution vector. - // */ - // inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution(iPoint,2*nDim); } + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. @@ -243,20 +252,20 @@ class CFEAVariable : public CVariable { * \return Pointer to the old solution vector. */ inline su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const final { - return Solution_time_n(iPoint,iVar+2*nDim); + return Solution_Accel_time_n(iPoint,iVar); } - // /*! - // * \brief Get the solution at time n. - // * \return Pointer to the solution (at time n) vector. - // */ - // inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_time_n(iPoint, 2*nDim); } + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } /*! * \brief Set the value of the solution velocity predictor. */ inline void SetSolution_Vel_Pred(unsigned long iPoint) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution_Vel(iPoint,iVar); } /*! @@ -339,21 +348,20 @@ class CFEAVariable : public CVariable { * \brief Register the variables in the solution time_n array as input/output variable. * \param[in] input - input or output variables. */ - void Register_femSolution_time_n(bool input, bool push_index) final; - void Register_femSolution(bool input, bool push_index) final; + void Register_femSolution_time_n(bool input, bool push_index, bool dynamic) final; - inline void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_InputIndex(iPoint,iVar)); - } + void Register_femSolution(bool input, bool push_index, bool dynamic) final; - inline void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); - } + void SetfemAdjointSolution(unsigned long iPoint, const su2double *adj_sol, bool dynamic) final; + + void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol, bool dynamic) final; + + void GetfemAdjointSolution(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; + + void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; + + void GetfemAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; + + void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; - inline void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < 3*nDim; iVar++) - SU2_TYPE::SetDerivative(Solution(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 8af45bcdb80..6d4e32d5cb8 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1718,7 +1718,6 @@ class CVariable { * \param[in] solution_direct - Value of the direct solution. */ inline virtual void SetSolution_Direct(unsigned long iPoint, const su2double *solution_direct) {} - inline virtual void SetSolution_Direct(unsigned long iPoint, unsigned long iVar, const su2double solution_direct) {} /*! * \brief A virtual member. Get the direct solution for the adjoint solver. @@ -1812,13 +1811,13 @@ class CVariable { * \brief A virtual member. Set the direct velocity solution for the adjoint solver. * \param[in] solution_direct - Value of the direct velocity solution. */ - inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, unsigned long iVar, const su2double sol) {} + inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} /*! * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. * \param[in] solution_direct - Value of the direct acceleration solution. */ - inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, unsigned long iVar, const su2double sol) {} + inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} /*! * \brief A virtual member. Get the direct velocity solution for the adjoint solver. @@ -1884,11 +1883,11 @@ class CVariable { */ inline virtual su2double GetSolution_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - // /*! - // * \brief Get the solution of the problem. - // * \return Pointer to the solution vector. - // */ - // inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline virtual su2double *GetSolution_Vel(unsigned long iPoint) {return nullptr; } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. @@ -1897,11 +1896,11 @@ class CVariable { */ inline virtual su2double GetSolution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - // /*! - // * \brief Get the solution at time n. - // * \return Pointer to the solution (at time n) vector. - // */ - // inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline virtual su2double *GetSolution_Vel_time_n(unsigned long iPoint) { return nullptr; } /*! @@ -1942,11 +1941,11 @@ class CVariable { */ inline virtual su2double GetSolution_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - // /*! - // * \brief Get the solution of the problem. - // * \return Pointer to the solution vector. - // */ - // inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } + /*! + * \brief Get the solution of the problem. + * \return Pointer to the solution vector. + */ + inline virtual su2double *GetSolution_Accel(unsigned long iPoint) { return nullptr; } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. @@ -1955,11 +1954,11 @@ class CVariable { */ inline virtual su2double GetSolution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - // /*! - // * \brief Get the solution at time n. - // * \return Pointer to the solution (at time n) vector. - // */ - // inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } + /*! + * \brief Get the solution at time n. + * \return Pointer to the solution (at time n) vector. + */ + inline virtual su2double *GetSolution_Accel_time_n(unsigned long iPoint) { return nullptr; } /*! * \brief A virtual member. Set the value of the velocity solution predictor. @@ -2142,11 +2141,22 @@ class CVariable { /*! * \brief A virtual member. */ - inline virtual void Register_femSolution_time_n(bool input, bool push_index) {} - inline virtual void Register_femSolution(bool input, bool push_index) {} - inline virtual void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) {} - inline virtual void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) {} - inline virtual void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) {} + inline virtual void Register_femSolution(bool input, bool push_index, bool dynamic) {} + + inline virtual void Register_femSolution_time_n(bool input, bool push_index, bool dynamic) {} + + inline virtual void SetfemAdjointSolution(unsigned long iPoint, const su2double *adj_sol, bool dynamic) {} + + inline virtual void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol, bool dynamic) {} + + inline virtual void GetfemAdjointSolution(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} + + inline virtual void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} + + inline virtual void GetfemAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} + + inline virtual void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} + /*! * \brief A virtual member. */ diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index 980255840a3..a82763629ff 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -212,8 +212,8 @@ void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolv /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ solver->GetNodes()->Set_Solution_time_n(); - // solver->GetNodes()->SetSolution_Vel_time_n(); - // solver->GetNodes()->SetSolution_Accel_time_n(); + solver->GetNodes()->SetSolution_Vel_time_n(); + solver->GetNodes()->SetSolution_Accel_time_n(); /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index ef081adbc6f..b0eea71aaf2 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -90,13 +90,13 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat dirNodes->Set_Solution_time_n(); - // /*--- Push solution back to correct array ---*/ + /*--- Push solution back to correct array ---*/ - // dirNodes->SetSolution_Accel_time_n(); + dirNodes->SetSolution_Accel_time_n(); - // /*--- Push solution back to correct array ---*/ + /*--- Push solution back to correct array ---*/ - // dirNodes->SetSolution_Vel_time_n(); + dirNodes->SetSolution_Vel_time_n(); /*--- Load solution timestep n ---*/ @@ -105,21 +105,15 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ - adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); - } + adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); } for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ - adjNodes->SetSolution_Accel_Direct(iPoint, iVar, dirNodes->GetSolution_Accel(iPoint, iVar)); - } + adjNodes->SetSolution_Accel_Direct(iPoint, dirNodes->GetSolution_Accel(iPoint)); } for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - for (unsigned short iVar = 0; iVar < solvers0[FEA_SOL]->GetnVar(); iVar++){ - adjNodes->SetSolution_Vel_Direct(iPoint, iVar, dirNodes->GetSolution_Vel(iPoint, iVar)); - } + adjNodes->SetSolution_Vel_Direct(iPoint, dirNodes->GetSolution_Vel(iPoint)); } } else { diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 579f5f3e6f8..394ae74edbc 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -181,14 +181,13 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - if (!dynamic) direct_solver->GetNodes()->RegisterSolution(input, push_index); + direct_solver->GetNodes()->Register_femSolution(input, push_index, dynamic); if (dynamic) { - direct_solver->GetNodes()->Register_femSolution(input, push_index); /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ - direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index); + direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index, dynamic); } } @@ -258,10 +257,11 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; const bool push_index = !config->GetMultizone_Problem(); + const bool dynamic = config->GetTime_Domain(); /*--- Register variables as output of the solver iteration ---*/ - direct_solver->GetNodes()->RegisterSolution(input, push_index); + direct_solver->GetNodes()->Register_femSolution(input, push_index, dynamic); } @@ -291,11 +291,10 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution ---*/ if(multizone) { - // direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); - direct_solver->GetNodes()->GetfemAdjointSolution_LocalIndex(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution_LocalIndex(iPoint,Solution,dynamic); } else { - direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution(iPoint,Solution,dynamic); } /*--- Store the adjoint solution ---*/ @@ -314,11 +313,10 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ if(multizone) { - // direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); - direct_solver->GetNodes()->GetfemAdjointSolution_time_n_LocalIndex(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution_time_n_LocalIndex(iPoint,Solution,dynamic); } else { - direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); + direct_solver->GetNodes()->GetfemAdjointSolution_time_n(iPoint,Solution,dynamic); } /*--- Store the adjoint solution at time n ---*/ @@ -402,12 +400,13 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ } } } - if (config->GetMultizone_Problem()) { - direct_solver->GetNodes()->SetfemAdjointSolution_LocalIndex(iPoint,Solution); + if(config->GetMultizone_Problem()) { + direct_solver->GetNodes()->SetfemAdjointSolution_LocalIndex(iPoint,Solution,dynamic); } else { - direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); + direct_solver->GetNodes()->SetfemAdjointSolution(iPoint,Solution,dynamic); } + } } @@ -418,7 +417,7 @@ void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_cont if (config_container->GetTime_Domain()){ for (auto iPoint = 0ul; iPoint < nPoint; iPoint++){ - for (iVar=0; iVar < 3*nDim; iVar++){ + for (iVar=0; iVar < nVar; iVar++){ nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); } } diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index a9365826fad..1e243f73550 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2601,24 +2601,24 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * switch (predOrder) { case 1: { - // const su2double* solDisp = nodes->GetSolution(iPoint); - // const su2double* solVel = nodes->GetSolution_Vel(iPoint); + const su2double* solDisp = nodes->GetSolution(iPoint); + const su2double* solVel = nodes->GetSolution_Vel(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = nodes->GetSolution(iPoint,iDim) + Delta_t*nodes->GetSolution_Vel(iPoint,iDim); + valPred[iDim] = solDisp[iDim] + Delta_t*solVel[iDim]; nodes->SetSolution_Pred(iPoint, valPred); } break; case 2: { - // const su2double* solDisp = nodes->GetSolution(iPoint); - // const su2double* solVel = nodes->GetSolution_Vel(iPoint); - // const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); + const su2double* solDisp = nodes->GetSolution(iPoint); + const su2double* solVel = nodes->GetSolution_Vel(iPoint); + const su2double* solVel_tn = nodes->GetSolution_Vel_time_n(iPoint); su2double valPred[MAXNVAR] = {0.0}; for (iDim=0; iDim < nDim; iDim++) - valPred[iDim] = nodes->GetSolution(iPoint,iDim) + 0.5*Delta_t*(3*nodes->GetSolution_Vel(iPoint,iDim)-nodes->GetSolution_Vel_time_n(iPoint,iDim)); + valPred[iDim] = solDisp[iDim] + 0.5*Delta_t*(3*solVel[iDim]-solVel_tn[iDim]); nodes->SetSolution_Pred(iPoint, valPred); } break; @@ -3191,8 +3191,8 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c if (dynamic) { nodes->Set_Solution_time_n(); - // nodes->SetSolution_Vel_time_n(); - // nodes->SetSolution_Accel_time_n(); + nodes->SetSolution_Vel_time_n(); + nodes->SetSolution_Accel_time_n(); } if (fluid_structure) { diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index f4fb5e3ec34..2a7b78c1d8b 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -33,7 +33,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : CVariable(npoint, ndim, nvar, config) { Solution_Direct.resize(nPoint,nDim); - + if (config->GetTime_Domain()) nVar = 3*nDim; Sensitivity.resize(nPoint,nDim) = su2double(0.0); Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); @@ -59,7 +59,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double /*--- Nothing else to allocate ---*/ if (!unsteady) return; - +cout << "CVC: Debug: nVar = " << nVar << endl; Dynamic_Derivative.resize(nPoint,nVar) = su2double(0.0); Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 718804f5ede..baa25e95798 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -47,42 +47,40 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig if (nDim==2) Stress.resize(nPoint,3); else Stress.resize(nPoint,6); - // if (dynamic_analysis) Solution.resize(nPoint,3*nDim); /*--- Initialization of variables ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { + Solution_Vel.resize(nPoint,nVar); + Solution_Accel.resize(nPoint,nVar); + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution(iPoint,iVar+nDim) = val_fea[iVar+nVar]; - Solution(iPoint,iVar+2*nDim) = val_fea[iVar+2*nVar]; + Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; + Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; } } + Solution_Vel_time_n = Solution_Vel; + Solution_Accel_time_n = Solution_Accel; - Solution_time_n = Solution; if(config->GetMultizone_Problem() && config->GetAD_Mode()) { - AD_InputIndex.resize(nPoint,3*nDim) = -1; - AD_OutputIndex.resize(nPoint,3*nDim) = -1; - if (config->GetTime_Domain()) { - AD_Time_n_InputIndex.resize(nPoint,3*nDim) = -1; - AD_Time_n_OutputIndex.resize(nPoint,3*nDim) = -1; - } + AD_Vel_InputIndex.resize(nPoint,nDim) = -1; + AD_Vel_OutputIndex.resize(nPoint,nDim) = -1; + AD_Vel_Time_n_InputIndex.resize(nPoint,nDim) = -1; + AD_Vel_Time_n_OutputIndex.resize(nPoint,nDim) = -1; + AD_Accel_InputIndex.resize(nPoint,nDim) = -1; + AD_Accel_OutputIndex.resize(nPoint,nDim) = -1; + AD_Accel_Time_n_InputIndex.resize(nPoint,nDim) = -1; + AD_Accel_Time_n_OutputIndex.resize(nPoint,nDim) = -1; } } if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; - if (dynamic_analysis) { - Solution_Vel_Pred.resize(nPoint,nVar); - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_Vel_Pred(iPoint,iVar) = Solution(iPoint,iVar+nDim); - } - } - } + if (dynamic_analysis) Solution_Vel_Pred = Solution_Vel; } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ @@ -108,60 +106,147 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } } -void CFEAVariable::SetSolution_Vel_time_n() { - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_time_n(iPoint,iVar+nDim) = Solution(iPoint,iVar+nDim); - } - } -} +void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } -void CFEAVariable::SetSolution_Accel_time_n() { - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_time_n(iPoint,iVar+2*nDim) = Solution(iPoint,iVar+2*nDim); - } - } -} +void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } -void CFEAVariable::Register_femSolution(bool input, bool push_index) { +void CFEAVariable::Register_femSolution(bool input, bool push_index, bool dynamic) { + SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for(unsigned long iVar=0; iVar Date: Tue, 4 May 2021 11:49:08 +0100 Subject: [PATCH 049/192] more general treatment of FEA adjoint state --- SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp | 1 - .../variables/CDiscAdjFEABoundVariable.hpp | 8 +- .../include/variables/CDiscAdjFEAVariable.hpp | 34 +-- .../include/variables/CDiscAdjVariable.hpp | 64 ------ SU2_CFD/include/variables/CFEAVariable.hpp | 82 +++----- SU2_CFD/include/variables/CVariable.hpp | 95 +-------- .../integration/CStructuralIntegration.cpp | 2 - .../src/iteration/CDiscAdjFEAIteration.cpp | 16 -- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 91 ++++----- SU2_CFD/src/solvers/CFEASolver.cpp | 6 +- .../variables/CDiscAdjFEABoundVariable.cpp | 7 +- SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 29 +-- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 14 -- SU2_CFD/src/variables/CFEAVariable.cpp | 193 ++---------------- SU2_CFD/src/variables/CVariable.cpp | 8 +- 15 files changed, 111 insertions(+), 539 deletions(-) diff --git a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp index 2163e78e593..613b5a7fb35 100644 --- a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp @@ -39,7 +39,6 @@ class CDiscAdjFEASolver final : public CSolver { private: static constexpr size_t MAXNVAR = 9; /*!< \brief Max number of variables, for static arrays. */ -//CVC: How to only set to 9 for dynamic? unsigned short KindDirect_Solver = 0; CSolver *direct_solver = nullptr; diff --git a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp index e816483a18a..cfe8dfe9e26 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp @@ -50,17 +50,15 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { public: /*! * \overload - * \param[in] disp - Pointer to the adjoint value (initialization value). - * \param[in] vel - Pointer to the adjoint value (initialization value). - * \param[in] accel - Pointer to the adjoint value (initialization value). + * \param[in] sol - Pointer to the adjoint value (initialization value). * \param[in] npoint - Number of points/nodes/vertices in the domain. * \param[in] ndim - Number of dimensions of the problem. * \param[in] nvar - Number of variables of the problem. * \param[in] unsteady - Allocate velocity and acceleration. * \param[in] config - Definition of the particular problem. */ - CDiscAdjFEABoundVariable(const su2double *disp, const su2double *vel, const su2double *accel, - unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config); + CDiscAdjFEABoundVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, + unsigned long nvar, bool unsteady, CConfig *config); /*! * \brief Destructor of the class. diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp index c2396d5ecfe..663ee094a3a 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp @@ -40,27 +40,21 @@ class CDiscAdjFEAVariable : public CVariable { protected: MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ - MatrixType Solution_Direct; - MatrixType Dynamic_Derivative; + MatrixType Solution_Direct; MatrixType Dynamic_Derivative_n; - MatrixType Solution_Direct_Vel; - MatrixType Solution_Direct_Accel; - /*! * \brief Constructor of the class. - * \param[in] disp - Pointer to the adjoint value (initialization value). - * \param[in] vel - Pointer to the adjoint value (initialization value). - * \param[in] accel - Pointer to the adjoint value (initialization value). + * \param[in] sol - Pointer to the adjoint value (initialization value). * \param[in] npoint - Number of points/nodes/vertices in the domain. * \param[in] ndim - Number of dimensions of the problem. * \param[in] nvar - Number of variables of the problem. * \param[in] unsteady - Allocate velocity and acceleration. * \param[in] config - Definition of the particular problem. */ - CDiscAdjFEAVariable(const su2double *disp, const su2double *vel, const su2double *accel, - unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config); + CDiscAdjFEAVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, + unsigned long nvar, bool unsteady, CConfig *config); public: /*! @@ -96,18 +90,10 @@ class CDiscAdjFEAVariable : public CVariable { */ inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity_Old(iPoint,iDim);} - inline void SetDynamic_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative(iPoint,iVar) = der; - } - inline void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) final { Dynamic_Derivative_n(iPoint,iVar) = der; } - inline su2double GetDynamic_Derivative(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative(iPoint,iVar); - } - inline su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const final { return Dynamic_Derivative_n(iPoint,iVar); } @@ -116,18 +102,6 @@ class CDiscAdjFEAVariable : public CVariable { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Vel(iPoint,iVar) = val_solution_direct[iVar]; - } - - inline void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct_Accel(iPoint,iVar) = val_solution_direct[iVar]; - } - inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } - inline su2double* GetSolution_Vel_Direct(unsigned long iPoint) final { return Solution_Direct_Vel[iPoint]; } - - inline su2double* GetSolution_Accel_Direct(unsigned long iPoint) final { return Solution_Direct_Accel[iPoint]; } - }; diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index cf0548abbbb..6c4cfccef2e 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -43,12 +43,6 @@ class CDiscAdjVariable final : public CVariable { MatrixType DualTime_Derivative; MatrixType DualTime_Derivative_n; - MatrixType Solution_Geometry; - MatrixType Solution_Geometry_Old; - MatrixType Geometry_Direct; - - MatrixType Solution_Geometry_BGS_k; - public: /*! * \brief Constructor of the class. @@ -108,62 +102,4 @@ class CDiscAdjVariable final : public CVariable { inline su2double* GetSolution_Direct(unsigned long iPoint) override { return Solution_Direct[iPoint]; } - /*! - * \brief Set the restart geometry (coordinate of the converged solution) - * \param[in] val_geometry_direct - Value of the restart coordinate. - */ - inline void SetGeometry_Direct(unsigned long iPoint, const su2double *val_geometry_direct) override { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - Geometry_Direct(iPoint,iDim) = val_geometry_direct[iDim]; - } - - /*! - * \brief Get the restart geometry (coordinate of the converged solution). - * \return Pointer to the restart coordinate vector. - */ - inline su2double *GetGeometry_Direct(unsigned long iPoint) override { return Geometry_Direct[iPoint]; } - - /*! - * \brief Get the restart geometry (coordinate of the converged solution). - * \return Coordinate iDim of the geometry_direct vector. - */ - inline su2double GetGeometry_Direct(unsigned long iPoint, unsigned long iDim) const override { return Geometry_Direct(iPoint,iDim); } - - /*! - * \brief Get the geometry solution. - * \param[in] iDim - Index of the coordinate. - * \return Value of the solution for the index iDim. - */ - inline su2double GetSolution_Geometry(unsigned long iPoint, unsigned long iDim) const override { return Solution_Geometry(iPoint,iDim); } - - /*! - * \brief Set the value of the mesh solution (adjoint). - * \param[in] val_solution_geometry - Solution of the problem (acceleration). - */ - inline void SetSolution_Geometry(unsigned long iPoint, const su2double *val_solution_geometry) override { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - Solution_Geometry(iPoint,iDim) = val_solution_geometry[iDim]; - } - - /*! - * \brief A virtual member. Set the value of the mesh solution (adjoint). - * \param[in] val_solution_geometry - Solution of the problem (acceleration). - */ - inline void SetSolution_Geometry(unsigned long iPoint, unsigned long iVar, su2double val_solution_geometry) override { - Solution_Geometry(iPoint,iVar) = val_solution_geometry; - } - - /*! - * \brief Set the value of the mesh solution (adjoint). - */ - void Set_OldSolution_Geometry() override; - - /*! - * \brief Get the value of the old geometry solution (adjoint). - * \param[out] val_solution - old adjoint solution for coordinate iDim - */ - inline su2double Get_OldSolution_Geometry(unsigned long iPoint, unsigned long iDim) const override { - return Solution_Geometry_Old(iPoint,iDim); - } - }; diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 9f9d4e91f46..a4f773b7b2e 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -45,12 +45,6 @@ class CFEAVariable : public CVariable { VectorType VonMises_Stress; /*!< \brief Von Mises stress. */ - MatrixType Solution_Vel; /*!< \brief Velocity of the nodes. */ - MatrixType Solution_Vel_time_n; /*!< \brief Velocity of the nodes at time n. */ - - MatrixType Solution_Accel; /*!< \brief Acceleration of the nodes. */ - MatrixType Solution_Accel_time_n; /*!< \brief Acceleration of the nodes at time n. */ - MatrixType Solution_Pred; /*!< \brief Predictor of the solution for FSI purposes */ MatrixType Solution_Pred_Old; /*!< \brief Predictor of the solution at time n for FSI purposes */ MatrixType Solution_Vel_Pred; /*!< \brief Predictor of the velocity solution for FSI purposes */ @@ -59,14 +53,35 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ - su2matrix AD_Vel_InputIndex; - su2matrix AD_Vel_OutputIndex; - su2matrix AD_Vel_Time_n_InputIndex; - su2matrix AD_Vel_Time_n_OutputIndex; - su2matrix AD_Accel_InputIndex; - su2matrix AD_Accel_OutputIndex; - su2matrix AD_Accel_Time_n_InputIndex; - su2matrix AD_Accel_Time_n_OutputIndex; + const bool dynamic_analysis = false; /*!< \brief True in dynamic problems */ + + /*! + * \brief Wrappers to solution to access velocity and acceleration by name. + */ + FORCEINLINE su2double& Solution_Vel(unsigned long iPoint, unsigned long iVar) { + return Solution(iPoint,iVar+nVar); + } + FORCEINLINE const su2double& Solution_Vel(unsigned long iPoint, unsigned long iVar) const { + return Solution(iPoint,iVar+nVar); + } + FORCEINLINE su2double& Solution_Accel(unsigned long iPoint, unsigned long iVar) { + return Solution(iPoint,iVar+2*nVar); + } + FORCEINLINE const su2double& Solution_Accel(unsigned long iPoint, unsigned long iVar) const { + return Solution(iPoint,iVar+2*nVar); + } + FORCEINLINE su2double& Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar) { + return Solution_time_n(iPoint,iVar+nVar); + } + FORCEINLINE const su2double& Solution_Vel_time_n(unsigned long iPoint, unsigned long iVar) const { + return Solution_time_n(iPoint,iVar+nVar); + } + FORCEINLINE su2double& Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar) { + return Solution_time_n(iPoint,iVar+2*nVar); + } + FORCEINLINE const su2double& Solution_Accel_time_n(unsigned long iPoint, unsigned long iVar) const { + return Solution_time_n(iPoint,iVar+2*nVar); + } /*! * \brief Constructor of the class. @@ -142,12 +157,6 @@ class CFEAVariable : public CVariable { Solution_Vel(iPoint,iVar) = val_solution_vel; } - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - * \param[in] val_solution - Solution of the problem (acceleration). - */ - void SetSolution_Vel_time_n() final; - /*! * \brief Set the value of the velocity (Structural Analysis) at time n. * \param[in] val_solution_vel_time_n - Pointer to the residual vector. @@ -176,7 +185,7 @@ class CFEAVariable : public CVariable { * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline su2double *GetSolution_Vel(unsigned long iPoint) final { return Solution_Vel[iPoint]; } + inline su2double *GetSolution_Vel(unsigned long iPoint) final { return &Solution_Vel(iPoint,0); } /*! * \brief Get the velocity of the nodes (Structural Analysis) at time n. @@ -191,7 +200,7 @@ class CFEAVariable : public CVariable { * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return Solution_Vel_time_n[iPoint]; } + inline su2double *GetSolution_Vel_time_n(unsigned long iPoint) final { return &Solution_Vel_time_n(iPoint,0); } /*! * \brief Set the value of the acceleration (Structural Analysis). @@ -219,11 +228,6 @@ class CFEAVariable : public CVariable { Solution_Accel_time_n(iPoint,iVar) = val_solution_accel_time_n[iVar]; } - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - */ - void SetSolution_Accel_time_n() final; - /*! * \overload * \param[in] iVar - Index of the variable. @@ -244,7 +248,7 @@ class CFEAVariable : public CVariable { * \brief Get the solution of the problem. * \return Pointer to the solution vector. */ - inline su2double *GetSolution_Accel(unsigned long iPoint) final { return Solution_Accel[iPoint]; } + inline su2double *GetSolution_Accel(unsigned long iPoint) final { return &Solution_Accel(iPoint,0); } /*! * \brief Get the acceleration of the nodes (Structural Analysis) at time n. @@ -259,7 +263,7 @@ class CFEAVariable : public CVariable { * \brief Get the solution at time n. * \return Pointer to the solution (at time n) vector. */ - inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return Solution_Accel_time_n[iPoint]; } + inline su2double *GetSolution_Accel_time_n(unsigned long iPoint) final { return &Solution_Accel_time_n(iPoint,0); } /*! * \brief Set the value of the solution velocity predictor. @@ -344,24 +348,4 @@ class CFEAVariable : public CVariable { */ inline const su2double* GetReference_Geometry(unsigned long iPoint) const final { return Reference_Geometry[iPoint]; } - /*! - * \brief Register the variables in the solution time_n array as input/output variable. - * \param[in] input - input or output variables. - */ - void Register_femSolution_time_n(bool input, bool push_index, bool dynamic) final; - - void Register_femSolution(bool input, bool push_index, bool dynamic) final; - - void SetfemAdjointSolution(unsigned long iPoint, const su2double *adj_sol, bool dynamic) final; - - void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol, bool dynamic) final; - - void GetfemAdjointSolution(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; - - void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; - - void GetfemAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; - - void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) final; - }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 6d4e32d5cb8..0f3ee5cb335 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -95,12 +95,8 @@ class CVariable { su2matrix AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ su2matrix AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Time_n_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - - su2matrix AD_Time_n1_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Time_n1_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ + su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ + su2matrix AD_Time_n1_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ unsigned long nPoint = 0; /*!< \brief Number of points in the domain. */ unsigned long nDim = 0; /*!< \brief Number of dimension of the problem. */ @@ -1807,30 +1803,6 @@ class CVariable { return Solution_BGS_k(iPoint,iVar); } - /*! - * \brief A virtual member. Set the direct velocity solution for the adjoint solver. - * \param[in] solution_direct - Value of the direct velocity solution. - */ - inline virtual void SetSolution_Vel_Direct(unsigned long iPoint, const su2double *sol) {} - - /*! - * \brief A virtual member. Set the direct acceleration solution for the adjoint solver. - * \param[in] solution_direct - Value of the direct acceleration solution. - */ - inline virtual void SetSolution_Accel_Direct(unsigned long iPoint, const su2double *sol) {} - - /*! - * \brief A virtual member. Get the direct velocity solution for the adjoint solver. - * \return Pointer to the direct velocity solution vector. - */ - inline virtual su2double* GetSolution_Vel_Direct(unsigned long iPoint) { return nullptr; } - - /*! - * \brief A virtual member. Get the direct acceleraction solution for the adjoint solver. - * \return Pointer to the direct acceleraction solution vector. - */ - inline virtual su2double* GetSolution_Accel_Direct(unsigned long iPoint) { return nullptr; } - /*! * \brief Set the value of the velocity (Structural Analysis). * \param[in] solution - Solution of the problem (velocity). @@ -1850,11 +1822,6 @@ class CVariable { */ inline virtual void SetSolution_Vel_time_n(unsigned long iPoint, const su2double *solution_vel_time_n) {} - /*! - * \brief Set the value of the velocity (Structural Analysis) at time n. - */ - inline virtual void SetSolution_Vel_time_n() {} - /*! * \overload * \param[in] iVar - Index of the variable. @@ -1922,11 +1889,6 @@ class CVariable { */ inline virtual void SetSolution_Accel_time_n(unsigned long iPoint, const su2double *solution_accel_time_n) {} - /*! - * \brief Set the value of the acceleration (Structural Analysis) at time n. - */ - inline virtual void SetSolution_Accel_time_n() {} - /*! * \overload * \param[in] iVar - Index of the variable. @@ -2138,25 +2100,6 @@ class CVariable { */ inline virtual void GetAdjoint_BoundDisp(unsigned long iPoint, su2double *adj_disp) const { } - /*! - * \brief A virtual member. - */ - inline virtual void Register_femSolution(bool input, bool push_index, bool dynamic) {} - - inline virtual void Register_femSolution_time_n(bool input, bool push_index, bool dynamic) {} - - inline virtual void SetfemAdjointSolution(unsigned long iPoint, const su2double *adj_sol, bool dynamic) {} - - inline virtual void SetfemAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol, bool dynamic) {} - - inline virtual void GetfemAdjointSolution(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} - - inline virtual void GetfemAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} - - inline virtual void GetfemAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} - - inline virtual void GetfemAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol, bool dynamic) {} - /*! * \brief A virtual member. */ @@ -2207,7 +2150,7 @@ class CVariable { * \param[out] adj_sol - The adjoint values of the solution. */ inline void GetAdjointSolution(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < Solution.cols(); iVar++) adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution(iPoint,iVar)); } @@ -2216,42 +2159,24 @@ class CVariable { * \param[in] adj_sol - The adjoint values of the solution. */ inline void GetAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < AD_InputIndex.cols(); iVar++) adj_sol[iVar] = AD::GetDerivative(AD_InputIndex(iPoint,iVar)); } - /*! - * \brief Set the adjoint values of the solution at time n. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void SetAdjointSolution_time_n(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_time_n(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - /*! * \brief Get the adjoint values of the solution at time n. * \param[out] adj_sol - The adjoint values of the solution. */ inline void GetAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < Solution_time_n.cols(); iVar++) adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n(iPoint,iVar)); } inline void GetAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < AD_Time_n_InputIndex.cols(); iVar++) adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); } - /*! - * \brief Set the adjoint values of the solution at time n-1. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void SetAdjointSolution_time_n1(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - SU2_TYPE::SetDerivative(Solution_time_n1(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - /*! * \brief Get the adjoint values of the solution at time n-1. * \param[out] adj_sol - The adjoint values of the solution. @@ -2311,18 +2236,10 @@ class CVariable { inline virtual su2double GetVortex_Tilting(unsigned long iPoint) const { return 0.0; } - inline virtual void SetDynamic_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - inline virtual su2double GetDynamic_Derivative(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual su2double GetSolution_Old_Vel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - - inline virtual su2double GetSolution_Old_Accel(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! * \brief A virtual member: Set the recovered pressure for streamwise periodic flow. * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/integration/CStructuralIntegration.cpp b/SU2_CFD/src/integration/CStructuralIntegration.cpp index a82763629ff..31be9b7e8bd 100644 --- a/SU2_CFD/src/integration/CStructuralIntegration.cpp +++ b/SU2_CFD/src/integration/CStructuralIntegration.cpp @@ -212,8 +212,6 @@ void CStructuralIntegration::SetDualTime_Solver(const CGeometry *geometry, CSolv /*--- Store the solution at t+1 as solution at t, both for the local points and for the halo points ---*/ solver->GetNodes()->Set_Solution_time_n(); - solver->GetNodes()->SetSolution_Vel_time_n(); - solver->GetNodes()->SetSolution_Accel_time_n(); /*--- If FSI problem, save the last Aitken relaxation parameter of the previous time step ---*/ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index b0eea71aaf2..8bfc68d684b 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -90,14 +90,6 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat dirNodes->Set_Solution_time_n(); - /*--- Push solution back to correct array ---*/ - - dirNodes->SetSolution_Accel_time_n(); - - /*--- Push solution back to correct array ---*/ - - dirNodes->SetSolution_Vel_time_n(); - /*--- Load solution timestep n ---*/ LoadDynamic_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter); @@ -108,14 +100,6 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat adjNodes->SetSolution_Direct(iPoint, dirNodes->GetSolution(iPoint)); } - for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Accel_Direct(iPoint, dirNodes->GetSolution_Accel(iPoint)); - } - - for (iPoint = 0; iPoint < geometry0->GetnPoint(); iPoint++) { - adjNodes->SetSolution_Vel_Direct(iPoint, dirNodes->GetSolution_Vel(iPoint)); - } - } else { /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 394ae74edbc..cd162329dd2 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -37,7 +37,7 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv const bool dynamic = (config->GetTime_Domain()); - nVar = direct_solver->GetnVar(); + nVar = dynamic? 3*direct_solver->GetnVar() : direct_solver->GetnVar(); nDim = geometry->GetnDim(); /*-- Store some information about direct solver ---*/ @@ -68,7 +68,7 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv /*--- Initialize the adjoint solution. ---*/ vector init(nVar,1e-16); - nodes = new CDiscAdjFEABoundVariable(init.data(), init.data(), init.data(), nPoint, nDim, nVar, dynamic, config); + nodes = new CDiscAdjFEABoundVariable(init.data(), nPoint, nDim, nVar, dynamic, config); SetBaseClassPointerToNodes(); /*--- Set which points are vertices and allocate boundary data. ---*/ @@ -138,28 +138,16 @@ void CDiscAdjFEASolver::SetRecording(CGeometry* geometry, CConfig *config){ /*--- Reset the solution to the initial (converged) solution ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->GetNodes()->SetSolution(iPoint, nodes->GetSolution_Direct(iPoint)); - } - - if (config->GetTime_Domain()){ - /*--- Reset the solution to the initial (converged) solution ---*/ - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->GetNodes()->SetSolution_Accel(iPoint, nodes->GetSolution_Accel_Direct(iPoint)); - } - - for (iPoint = 0; iPoint < nPoint; iPoint++){ - direct_solver->GetNodes()->SetSolution_Vel(iPoint, nodes->GetSolution_Vel_Direct(iPoint)); - } + for (iPoint = 0; iPoint < nPoint; iPoint++) + for (iVar = 0; iVar < nVar; iVar++) + direct_solver->GetNodes()->SetSolution(iPoint, iVar, nodes->GetSolution_Direct(iPoint)[iVar]); - /*--- Reset the input for time n ---*/ + /*--- Reset the input for time n ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ + if (config->GetTime_Domain()) { + for (iPoint = 0; iPoint < nPoint; iPoint++) + for (iVar = 0; iVar < nVar; iVar++) AD::ResetInput(direct_solver->GetNodes()->GetSolution_time_n(iPoint)[iVar]); - } - } } /*--- Set the Jacobian to zero since this is not done inside the meanflow iteration @@ -181,13 +169,13 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - direct_solver->GetNodes()->Register_femSolution(input, push_index, dynamic); + direct_solver->GetNodes()->RegisterSolution(input, push_index); if (dynamic) { /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ - direct_solver->GetNodes()->Register_femSolution_time_n(input, push_index, dynamic); + direct_solver->GetNodes()->RegisterSolution_time_n(push_index); } } @@ -257,11 +245,10 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; const bool push_index = !config->GetMultizone_Problem(); - const bool dynamic = config->GetTime_Domain(); /*--- Register variables as output of the solver iteration ---*/ - direct_solver->GetNodes()->Register_femSolution(input, push_index, dynamic); + direct_solver->GetNodes()->RegisterSolution(input, push_index); } @@ -291,10 +278,10 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution ---*/ if(multizone) { - direct_solver->GetNodes()->GetfemAdjointSolution_LocalIndex(iPoint,Solution,dynamic); + direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); } else { - direct_solver->GetNodes()->GetfemAdjointSolution(iPoint,Solution,dynamic); + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); } /*--- Store the adjoint solution ---*/ @@ -313,10 +300,10 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ if(multizone) { - direct_solver->GetNodes()->GetfemAdjointSolution_time_n_LocalIndex(iPoint,Solution,dynamic); + direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); } else { - direct_solver->GetNodes()->GetfemAdjointSolution_time_n(iPoint,Solution,dynamic); + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); } /*--- Store the adjoint solution at time n ---*/ @@ -382,47 +369,39 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ unsigned short iVar; for (auto iPoint = 0ul; iPoint < nPoint; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ + for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = nodes->GetSolution(iPoint,iVar); + + if (dynamic) { + for (iVar = 0; iVar < nVar; iVar++) + Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); } - if(deform_mesh){ - for (iVar = 0; iVar < nDim; iVar++){ + + if (deform_mesh) { + for (iVar = 0; iVar < nDim; iVar++) Solution[iVar] += nodes->GetSourceTerm_DispAdjoint(iPoint,iVar); + + if (dynamic) { + for (iVar = 0; iVar < nDim; iVar++) + Solution[nDim+iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar); } } - if (dynamic){ - for (iVar = 0; iVar < nVar; iVar++){ - Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); - } - if (deform_mesh){ - for (iVar = nDim; iVar < 2*nDim; iVar++){ - Solution[iVar] += nodes->GetSourceTerm_VelAdjoint(iPoint,iVar-nDim); - } - } - } - if(config->GetMultizone_Problem()) { - direct_solver->GetNodes()->SetfemAdjointSolution_LocalIndex(iPoint,Solution,dynamic); - } - else { - direct_solver->GetNodes()->SetfemAdjointSolution(iPoint,Solution,dynamic); - } + if (config->GetMultizone_Problem()) + direct_solver->GetNodes()->SetAdjointSolution_LocalIndex(iPoint,Solution); + else + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); } } void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config_container, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output){ - unsigned short iVar; - - if (config_container->GetTime_Domain()){ - for (auto iPoint = 0ul; iPoint < nPoint; iPoint++){ - for (iVar=0; iVar < nVar; iVar++){ + if (config_container->GetTime_Domain()) { + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) + for (auto iVar=0u; iVar < nVar; iVar++) nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); - } - } } - } void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolver*){ diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 1e243f73550..30307741607 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -3189,11 +3189,7 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c InitiateComms(geometry[MESH_0], config, SOLUTION_FEA); CompleteComms(geometry[MESH_0], config, SOLUTION_FEA); - if (dynamic) { - nodes->Set_Solution_time_n(); - nodes->SetSolution_Vel_time_n(); - nodes->SetSolution_Accel_time_n(); - } + if (dynamic) nodes->Set_Solution_time_n(); if (fluid_structure) { for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) { diff --git a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp index 0f8727a2876..d55e9a9619c 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp @@ -25,12 +25,11 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CDiscAdjFEABoundVariable.hpp" -CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable(const su2double *disp, const su2double *vel, - const su2double *accel, unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : - CDiscAdjFEAVariable(disp, vel, accel, npoint, ndim, nvar, unsteady, config) { +CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, + unsigned long nvar, bool unsteady, CConfig *config) : + CDiscAdjFEAVariable(sol, npoint, ndim, nvar, unsteady, config) { VertexMap.Reset(nPoint); } diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index 2a7b78c1d8b..6cd75f74136 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -25,31 +25,19 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CDiscAdjFEAVariable.hpp" +CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, + unsigned long nvar, bool unsteady, CConfig *config) : + CVariable(npoint, ndim, nvar, config) { -CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double *vel, const su2double *accel, unsigned long npoint, - unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : CVariable(npoint, ndim, nvar, config) { - - Solution_Direct.resize(nPoint,nDim); - if (config->GetTime_Domain()) nVar = 3*nDim; + Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - if (config->GetTime_Domain()) { - for (unsigned long iVar = 0; iVar < nDim; iVar++) - Solution(iPoint,iVar) = disp[iVar]; - for (unsigned long iVar = nDim; iVar < 2*nDim; iVar++) - Solution(iPoint,iVar) = vel[iVar]; - for (unsigned long iVar = 2*nDim; iVar < 3*nDim; iVar++) - Solution(iPoint,iVar) = accel[iVar]; - } - else { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution(iPoint,iVar) = disp[iVar]; - } + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution(iPoint,iVar) = sol[iVar]; } if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { @@ -59,11 +47,6 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *disp, const su2double /*--- Nothing else to allocate ---*/ if (!unsteady) return; -cout << "CVC: Debug: nVar = " << nVar << endl; - Dynamic_Derivative.resize(nPoint,nVar) = su2double(0.0); Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); - Solution_Direct_Vel.resize(nPoint,nDim) = su2double(0.0); - Solution_Direct_Accel.resize(nPoint,nDim) = su2double(0.0); - } diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index e2ece345d8d..bccb5d157db 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -25,18 +25,14 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CDiscAdjVariable.hpp" - CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, nvar, config) { bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); - bool fsi = config->GetFSI_Simulation(); - if (dual_time) { DualTime_Derivative.resize(nPoint,nVar) = su2double(0.0); DualTime_Derivative_n.resize(nPoint,nVar) = su2double(0.0); @@ -53,17 +49,7 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u for (unsigned long iVar = 0; iVar < nVar; ++iVar) Solution(iPoint,iVar) = sol[iVar]; - if (fsi) { - Geometry_Direct.resize(nPoint,nDim) = su2double(0.0); - Solution_Geometry.resize(nPoint,nDim) = su2double(1e-16); - Solution_Geometry_Old.resize(nPoint,nDim) = su2double(0.0); - - Solution_Geometry_BGS_k.resize(nPoint,nDim) = su2double(0.0); - } - if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { External.resize(nPoint,nVar) = su2double(0.0); } } - -void CDiscAdjVariable::Set_OldSolution_Geometry() { Solution_Geometry_Old = Solution_Geometry; } diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index baa25e95798..405083afc09 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -25,22 +25,24 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CFEAVariable.hpp" +CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, + unsigned long nvar, CConfig *config) : + CVariable(npoint, ndim, config->GetTime_Domain()? 3*nvar : nvar, config), + dynamic_analysis(config->GetTime_Domain()) { -CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) - : CVariable(npoint, ndim, nvar, config) { + /*--- In time domain CVariable::nVar is mult. by 3 ^^^ (for vel. and accel.) and the original value then restored. ---*/ + nVar = nvar; - bool nonlinear_analysis = (config->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE); - bool body_forces = config->GetDeadLoad(); - bool incremental_load = config->GetIncrementalLoad(); - bool prestretch_fem = config->GetPrestretch(); // Structure is prestretched - bool discrete_adjoint = config->GetDiscrete_Adjoint(); - bool refgeom = config->GetRefGeom(); // Reference geometry needs to be stored - bool dynamic_analysis = config->GetTime_Domain(); - bool multizone = config->GetMultizone_Problem(); - bool fsi_analysis = config->GetFSI_Simulation() || multizone; + const bool nonlinear_analysis = (config->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE); + const bool body_forces = config->GetDeadLoad(); + const bool incremental_load = config->GetIncrementalLoad(); + const bool prestretch_fem = config->GetPrestretch(); // Structure is prestretched + const bool discrete_adjoint = config->GetDiscrete_Adjoint(); + const bool refgeom = config->GetRefGeom(); // Reference geometry needs to be stored + const bool multizone = config->GetMultizone_Problem(); + const bool fsi_analysis = config->GetFSI_Simulation() || multizone; VonMises_Stress.resize(nPoint) = su2double(0.0); @@ -53,34 +55,18 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig Solution(iPoint,iVar) = val_fea[iVar]; if (dynamic_analysis) { - Solution_Vel.resize(nPoint,nVar); - Solution_Accel.resize(nPoint,nVar); - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for (unsigned long iVar = 0; iVar < nVar; iVar++) { - Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; - Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; + Solution_Vel_time_n(iPoint,iVar) = Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; + Solution_Accel_time_n(iPoint,iVar) = Solution_Accel(iPoint,iVar) = val_fea[iVar+2*nVar]; + if (fsi_analysis) Solution_Vel_Pred(iPoint,iVar) = val_fea[iVar+nVar]; } } - Solution_Vel_time_n = Solution_Vel; - Solution_Accel_time_n = Solution_Accel; - - if(config->GetMultizone_Problem() && config->GetAD_Mode()) { - AD_Vel_InputIndex.resize(nPoint,nDim) = -1; - AD_Vel_OutputIndex.resize(nPoint,nDim) = -1; - AD_Vel_Time_n_InputIndex.resize(nPoint,nDim) = -1; - AD_Vel_Time_n_OutputIndex.resize(nPoint,nDim) = -1; - AD_Accel_InputIndex.resize(nPoint,nDim) = -1; - AD_Accel_OutputIndex.resize(nPoint,nDim) = -1; - AD_Accel_Time_n_InputIndex.resize(nPoint,nDim) = -1; - AD_Accel_Time_n_OutputIndex.resize(nPoint,nDim) = -1; - } } if (fsi_analysis) { Solution_Pred = Solution; Solution_Pred_Old = Solution; - if (dynamic_analysis) Solution_Vel_Pred = Solution_Vel; } /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ @@ -105,148 +91,3 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig AuxVar.resize(nPoint); } } - -void CFEAVariable::SetSolution_Vel_time_n() { Solution_Vel_time_n = Solution_Vel; } - -void CFEAVariable::SetSolution_Accel_time_n() { Solution_Accel_time_n = Solution_Accel; } - -void CFEAVariable::Register_femSolution(bool input, bool push_index, bool dynamic) { - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for(unsigned long iVar=0; iVarGetTime_Domain()) { AD_Time_n_InputIndex.resize(nPoint,nVar) = -1; - AD_Time_n_OutputIndex.resize(nPoint,nVar) = -1; AD_Time_n1_InputIndex.resize(nPoint,nVar) = -1; - AD_Time_n1_OutputIndex.resize(nPoint,nVar) = -1; } } @@ -117,7 +115,7 @@ void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.d void CVariable::RegisterSolution(bool input, bool push_index) { SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for(unsigned long iVar=0; iVar Date: Tue, 4 May 2021 17:32:58 +0100 Subject: [PATCH 050/192] fix issues --- .../iteration/CDiscAdjFEAIteration.hpp | 5 +- .../iteration/CDiscAdjFluidIteration.hpp | 2 +- .../iteration/CDiscAdjHeatIteration.hpp | 2 +- SU2_CFD/include/iteration/CIteration.hpp | 2 +- SU2_CFD/include/variables/CFEAVariable.hpp | 2 - SU2_CFD/include/variables/CVariable.hpp | 15 +++-- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 13 ++-- .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 2 +- .../src/iteration/CDiscAdjFEAIteration.cpp | 13 ++-- .../src/iteration/CDiscAdjFluidIteration.cpp | 43 ++++-------- .../src/iteration/CDiscAdjHeatIteration.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 5 +- SU2_CFD/src/solvers/CMeshSolver.cpp | 3 - SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 2 +- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 2 +- SU2_CFD/src/variables/CFEAVariable.cpp | 30 ++++----- SU2_CFD/src/variables/CVariable.cpp | 66 ++++++------------- 17 files changed, 81 insertions(+), 128 deletions(-) diff --git a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp index 1de2974fa08..f88c3417c5a 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp @@ -159,9 +159,8 @@ class CDiscAdjFEAIteration final : public CIteration { * \param[in] iZone - Index of the zone. * \param[in] iInst - Index of the zone. */ - void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, - unsigned short iInst); - using CIteration::RegisterOutput; + void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, + unsigned short iZone, unsigned short iInst) override; /*! * \brief Initializes the adjoints of the output variables of the FEM iteration. diff --git a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp index 6c4ec3a6fe7..b8eacda6cbe 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp @@ -170,7 +170,7 @@ class CDiscAdjFluidIteration final : public CIteration { * \param[in] iZone - Index of the zone. * \param[in] iInst - Index of the instance. */ - void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, COutput* output, + void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) override; /*! diff --git a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp index 07d1a19340e..a9667c93c1c 100644 --- a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp @@ -153,7 +153,7 @@ class CDiscAdjHeatIteration final : public CIteration { * \param[in] iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. */ - void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, COutput* output, + void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) override; /*! diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index 693240d3301..18bbb14ab0c 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -278,7 +278,7 @@ class CIteration { virtual void SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, CConfig** config, unsigned short iZone, unsigned short iInst, RECORDING kind_recording) {} - virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, COutput* output, + virtual void RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short iZone, unsigned short iInst) {} virtual void SetRecording(CSolver***** solver, CGeometry**** geometry, CConfig** config, unsigned short val_iZone, diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index a4f773b7b2e..5dc26957717 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -53,8 +53,6 @@ class CFEAVariable : public CVariable { MatrixType Prestretch; /*!< \brief Prestretch geometry */ - const bool dynamic_analysis = false; /*!< \brief True in dynamic problems */ - /*! * \brief Wrappers to solution to access velocity and acceleration by name. */ diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 0f3ee5cb335..52bb1a2cbf9 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -135,8 +135,9 @@ class CVariable { * \param[in] ndim - Number of dimensions of the problem. * \param[in] nvar - Number of variables of the problem. * \param[in] config - Definition of the particular problem. + * \param[in] adjoint - True if derived class is an adjoint variable. */ - CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config); + CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config, bool adjoint = false); /*! * \brief Destructor of the class. @@ -2132,7 +2133,7 @@ class CVariable { * \param[in] adj_sol - The adjoint values of the solution. */ inline void SetAdjointSolution(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < Solution.cols(); iVar++) SU2_TYPE::SetDerivative(Solution(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } @@ -2141,7 +2142,7 @@ class CVariable { * \param[in] adj_sol - The adjoint values of the solution. */ inline void SetAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) + for (unsigned long iVar = 0; iVar < AD_OutputIndex.cols(); iVar++) AD::SetDerivative(AD_OutputIndex(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } @@ -2227,6 +2228,10 @@ class CVariable { inline virtual su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const {return 0.0;} + inline virtual void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} + + inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } + inline virtual void SetTauWall(unsigned long iPoint, su2double val_tau_wall) {} inline virtual su2double GetTauWall(unsigned long iPoint) const { return 0.0; } @@ -2236,10 +2241,6 @@ class CVariable { inline virtual su2double GetVortex_Tilting(unsigned long iPoint) const { return 0.0; } - inline virtual void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - /*! * \brief A virtual member: Set the recovered pressure for streamwise periodic flow. * \param[in] iPoint - Point index. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index e917c122ce9..4c611bac2e3 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -209,16 +209,15 @@ bool CDiscAdjMultizoneDriver::Iterate(unsigned short iZone, unsigned long iInner void CDiscAdjMultizoneDriver::Run() { unsigned long wrt_sol_freq = 9999; - unsigned long nOuterIter = driver_config->GetnOuter_Iter(); - bool time_domain = driver_config->GetTime_Domain(); + const unsigned long nOuterIter = driver_config->GetnOuter_Iter(); + const bool time_domain = driver_config->GetTime_Domain(); /*--- Reset external and solution ---*/ for (iZone = 0; iZone < nZone; iZone++) { for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; - if (solver != nullptr) { + if (solver && solver->GetAdjoint()) solver->GetNodes()->SetExternalZero(); - } } Set_Solution_To_BGSSolution_k(iZone); } @@ -697,7 +696,7 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t DirectIteration(iZone, kind_recording); iteration_container[iZone][INST_0]->RegisterOutput(solver_container, geometry_container, - config_container, output_container[iZone], iZone, INST_0); + config_container, iZone, INST_0); AD::Push_TapePosition(); /// leave_zone } } @@ -946,7 +945,9 @@ void CDiscAdjMultizoneDriver::ComputeAdjoints(unsigned short iZone, bool eval_tr void CDiscAdjMultizoneDriver::InitializeCrossTerms() { - Cross_Terms.resize(nZone, vector >(nZone)); + if (Cross_Terms.empty()) { + Cross_Terms.resize(nZone, vector >(nZone)); + } for(unsigned short iZone = 0; iZone < nZone; iZone++) { for (unsigned short jZone = 0; jZone < nZone; jZone++) { diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index db7d74099da..e342d007e6f 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -285,7 +285,7 @@ void CDiscAdjSinglezoneDriver::SetRecording(RECORDING kind_recording){ /*--- Register Output of the iteration ---*/ - iteration->RegisterOutput(solver_container, geometry_container, config_container, output_container[ZONE_0], ZONE_0, INST_0); + iteration->RegisterOutput(solver_container, geometry_container, config_container, ZONE_0, INST_0); /*--- Extract the objective function and store it --- */ diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 8bfc68d684b..24de5f5b1b3 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -179,10 +179,11 @@ void CDiscAdjFEAIteration::RegisterInput(CSolver***** solver, CGeometry**** geom /*--- Register topology optimization densities (note direct solver) ---*/ solver[iZone][iInst][MESH_0][FEA_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - } - /*--- Register mesh coordinates for geometric sensitivities ---*/ - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); + /*--- Register mesh coordinates for geometric sensitivities ---*/ + + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); + } } void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, @@ -278,8 +279,10 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge dir_solver->InitiateComms(structural_geometry, config[iZone], SOLUTION_FEA); dir_solver->CompleteComms(structural_geometry, config[iZone], SOLUTION_FEA); - structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); - structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); + if (kind_recording == RECORDING::MESH_COORDS) { + structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); + structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); + } } END_SU2_OMP_PARALLEL diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 22bac262f93..6d627328f32 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -86,8 +86,8 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr geometries[iMesh]->nodes->SetCoord_n1(); } if (config[iZone]->GetDynamic_Grid()) { - geometry[iZone][iInst][iMesh]->nodes->SetVolume_n(); - geometry[iZone][iInst][iMesh]->nodes->SetVolume_nM1(); + geometries[iMesh]->nodes->SetVolume_n(); + geometries[iMesh]->nodes->SetVolume_nM1(); } } } @@ -111,7 +111,7 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr geometries[iMesh]->nodes->SetCoord_n(); } if (config[iZone]->GetDynamic_Grid()) { - geometry[iZone][iInst][iMesh]->nodes->SetVolume_n(); + geometries[iMesh]->nodes->SetVolume_n(); } } } @@ -135,9 +135,9 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr /*--- Temporarily store the loaded volumes in to old containers ---*/ if (config[iZone]->GetDynamic_Grid()) { for (auto iMesh=0; iMesh<=config[iZone]->GetnMGLevels();iMesh++) { - geometry[iZone][iInst][iMesh]->nodes->SetVolume_Old(); - geometry[iZone][iInst][iMesh]->nodes->SetVolume_n_Old(); - geometry[iZone][iInst][iMesh]->nodes->SetVolume_nM1_Old(); + geometries[iMesh]->nodes->SetVolume_Old(); + geometries[iMesh]->nodes->SetVolume_n_Old(); + geometries[iMesh]->nodes->SetVolume_nM1_Old(); } } @@ -157,18 +157,18 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr for (auto iMesh=0; iMesh<=config[iZone]->GetnMGLevels();iMesh++) { /*--- If negative iteration number, set default ---*/ if (Direct_Iter - 2 < 0) { - for(auto iPoint=0ul; iPointGetnPoint();iPoint++) { - geometry[iZone][iInst][iMesh]->nodes->SetVolume(iPoint,0.0); + for(auto iPoint=0ul; iPointGetnPoint();iPoint++) { + geometries[iMesh]->nodes->SetVolume(iPoint,0.0); } } /*--- Set currently loaded volume to Volume_nM1 ---*/ - geometry[iZone][iInst][iMesh]->nodes->SetVolume_n(); - geometry[iZone][iInst][iMesh]->nodes->SetVolume_nM1(); + geometries[iMesh]->nodes->SetVolume_n(); + geometries[iMesh]->nodes->SetVolume_nM1(); /*--- Set Volume_n and Volume from old containers ---*/ - geometry[iZone][iInst][iMesh]->nodes->SetVolume_n_from_OldnM1(); - geometry[iZone][iInst][iMesh]->nodes->SetVolume_from_Oldn(); + geometries[iMesh]->nodes->SetVolume_n_from_OldnM1(); + geometries[iMesh]->nodes->SetVolume_from_Oldn(); } } } @@ -398,13 +398,6 @@ void CDiscAdjFluidIteration::Iterate(COutput* output, CIntegration**** integrati solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); - - /*--- If mesh deformation defined in config, extract here as well ---*/ - if (config[iZone]->GetDeform_Mesh()) { - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); - - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); - } } if (turbulent && !frozen_visc) { solver[iZone][iInst][MESH_0][ADJTURB_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], CrossTerm); @@ -469,16 +462,6 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - - /*--- If mesh deformation defined in config, register here as well ---*/ - if (config[iZone]->GetDeform_Mesh()) { - - /*--- Undeformed mesh coordinates ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); - - /*--- Boundary displacements ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - } } if (turbulent && !frozen_visc) { @@ -591,7 +574,7 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** } void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, - COutput* output, unsigned short iZone, unsigned short iInst) { + unsigned short iZone, unsigned short iInst) { SU2_OMP_PARALLEL_(if(solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->GetHasHybridParallel())) { diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 7a8a6147fd3..8ecbf6411a5 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -228,7 +228,7 @@ void CDiscAdjHeatIteration::SetDependencies(CSolver***** solver, CGeometry**** g } void CDiscAdjHeatIteration::RegisterOutput(CSolver***** solver, CGeometry**** geometry, CConfig** config, - COutput* output, unsigned short iZone, unsigned short iInst) { + unsigned short iZone, unsigned short iInst) { solver[iZone][iInst][MESH_0][ADJHEAT_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], config[iZone]); } diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index cd162329dd2..48b3202d782 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -308,7 +308,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Store the adjoint solution at time n ---*/ - nodes->Set_Solution_time_n(iPoint,Solution); + if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); } } @@ -361,7 +361,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *c void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ - const bool dynamic = (config->GetTime_Domain()); + const bool dynamic = config->GetTime_Domain(); const bool deform_mesh = (config->GetnMarker_Deform_Mesh() > 0); su2double Solution[MAXNVAR] = {0.0}; @@ -392,7 +392,6 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ else direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); } - } void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config_container, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output){ diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 1478a4b559e..06af9b8408c 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -614,9 +614,6 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri /*--- Non-dimensionalize velocity ---*/ val_vel /= config->GetVelocity_Ref(); - // Debug: Force zero grid velocity - if (config->GetWrt_Performance()) val_vel = 0.0; - geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, val_vel); } } diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp index 6cd75f74136..28604822ab3 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp @@ -29,7 +29,7 @@ CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, bool unsteady, CConfig *config) : - CVariable(npoint, ndim, nvar, config) { + CVariable(npoint, ndim, nvar, config, true) { Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index bccb5d157db..574500805bf 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -28,7 +28,7 @@ #include "../../include/variables/CDiscAdjVariable.hpp" CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) - : CVariable(npoint, ndim, nvar, config) { + : CVariable(npoint, ndim, nvar, config, true) { bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 405083afc09..27c9c405dee 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -29,15 +29,13 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) : - CVariable(npoint, ndim, config->GetTime_Domain()? 3*nvar : nvar, config), - dynamic_analysis(config->GetTime_Domain()) { + CVariable(npoint, ndim, config->GetTime_Domain()? 3*nvar : nvar, config) { /*--- In time domain CVariable::nVar is mult. by 3 ^^^ (for vel. and accel.) and the original value then restored. ---*/ nVar = nvar; - const bool nonlinear_analysis = (config->GetGeometricConditions() == STRUCT_DEFORMATION::LARGE); + const bool dynamic_analysis = config->GetTime_Domain(); const bool body_forces = config->GetDeadLoad(); - const bool incremental_load = config->GetIncrementalLoad(); const bool prestretch_fem = config->GetPrestretch(); // Structure is prestretched const bool discrete_adjoint = config->GetDiscrete_Adjoint(); const bool refgeom = config->GetRefGeom(); // Reference geometry needs to be stored @@ -54,7 +52,18 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution(iPoint,iVar) = val_fea[iVar]; + if (fsi_analysis) { + Solution_Pred.resize(nPoint,nVar); + Solution_Pred_Old.resize(nPoint,nVar); + + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + Solution_Pred(iPoint,iVar) = Solution_Pred_Old(iPoint,iVar) = val_fea[iVar]; + } + if (dynamic_analysis) { + if (fsi_analysis) Solution_Vel_Pred.resize(nPoint,nVar); + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for (unsigned long iVar = 0; iVar < nVar; iVar++) { Solution_Vel_time_n(iPoint,iVar) = Solution_Vel(iPoint,iVar) = val_fea[iVar+nVar]; @@ -64,18 +73,7 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig } } - if (fsi_analysis) { - Solution_Pred = Solution; - Solution_Pred_Old = Solution; - } - - /*--- If we are going to use incremental analysis, we need a way to store the old solution ---*/ - - if (incremental_load && nonlinear_analysis) Solution_Old.resize(nPoint,nVar) = su2double(0.0); - - /*--- If we are running a discrete adjoint iteration, we need this vector for cross-dependencies ---*/ - - else if (discrete_adjoint && fsi_analysis) Solution_Old = Solution; + if (discrete_adjoint && fsi_analysis) Solution_Old = Solution; /*--- Body residual ---*/ if (body_forces) Residual_Ext_Body.resize(nPoint,nVar) = su2double(0.0); diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 9e75f99d7f5..30f35a58bcf 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -46,7 +46,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long nvar, CConfig *config) } -CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) { +CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config, bool adjoint) { /*--- Initializate the number of dimension and number of variables ---*/ nPoint = npoint; @@ -67,7 +67,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva Solution_time_n.resize(nPoint,nVar) = su2double(0.0); } - if(config->GetMultizone_Problem() && config->GetAD_Mode()) { + if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint() && !adjoint) { AD_InputIndex.resize(nPoint,nVar) = -1; AD_OutputIndex.resize(nPoint,nVar) = -1; if (config->GetTime_Domain()) { @@ -112,57 +112,31 @@ void CVariable::Restore_BGSSolution_k() { void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.data()); } -void CVariable::RegisterSolution(bool input, bool push_index) { - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for(unsigned long iVar=0; iVar& ad_index) { + const auto nPoint = variable.rows(); + SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for(unsigned long iVar=0; iVar Date: Wed, 5 May 2021 11:41:31 +0100 Subject: [PATCH 051/192] CDiscAdjFEAVariable replaced by CDiscAdjVariable --- .../variables/CDiscAdjFEABoundVariable.hpp | 7 +- .../include/variables/CDiscAdjFEAVariable.hpp | 107 ------------------ .../include/variables/CDiscAdjVariable.hpp | 22 ++-- SU2_CFD/include/variables/CVariable.hpp | 12 -- SU2_CFD/obj/Makefile.am | 1 - SU2_CFD/src/meson.build | 1 - SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 7 +- .../variables/CDiscAdjFEABoundVariable.cpp | 4 +- SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp | 52 --------- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 20 +--- SU2_CFD/src/variables/CVariable.cpp | 29 +++-- 11 files changed, 42 insertions(+), 220 deletions(-) delete mode 100644 SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp delete mode 100644 SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp diff --git a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp index cfe8dfe9e26..d7ac26f88f2 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp @@ -27,7 +27,7 @@ #pragma once -#include "CDiscAdjFEAVariable.hpp" +#include "CDiscAdjVariable.hpp" #include "../../../Common/include/containers/CVertexMap.hpp" /*! @@ -37,7 +37,7 @@ * \author R. Sanchez. * \version 7.1.1 "Blackbird" */ -class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { +class CDiscAdjFEABoundVariable final : public CDiscAdjVariable { private: MatrixType FlowTraction_Sens; /*!< \brief Adjoint of the flow tractions. */ @@ -54,11 +54,10 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjFEAVariable { * \param[in] npoint - Number of points/nodes/vertices in the domain. * \param[in] ndim - Number of dimensions of the problem. * \param[in] nvar - Number of variables of the problem. - * \param[in] unsteady - Allocate velocity and acceleration. * \param[in] config - Definition of the particular problem. */ CDiscAdjFEABoundVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, - unsigned long nvar, bool unsteady, CConfig *config); + unsigned long nvar, CConfig *config); /*! * \brief Destructor of the class. diff --git a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp deleted file mode 100644 index 663ee094a3a..00000000000 --- a/SU2_CFD/include/variables/CDiscAdjFEAVariable.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/*! - * \file CDiscAdjFEAVariable.hpp - * \brief Main class for defining the variables of the adjoint FEA solver. - * \author T. Albring, R. Sanchez. - * \version 7.1.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#pragma once - -#include "CVariable.hpp" - -/*! - * \class CDiscAdjFEAVariable - * \brief Main class for defining the variables of the adjoint solver. - * \ingroup Discrete_Adjoint - * \author T. Albring, R. Sanchez. - * \version 7.1.1 "Blackbird" - */ -class CDiscAdjFEAVariable : public CVariable { -protected: - MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ - MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ - - MatrixType Solution_Direct; - MatrixType Dynamic_Derivative_n; - - /*! - * \brief Constructor of the class. - * \param[in] sol - Pointer to the adjoint value (initialization value). - * \param[in] npoint - Number of points/nodes/vertices in the domain. - * \param[in] ndim - Number of dimensions of the problem. - * \param[in] nvar - Number of variables of the problem. - * \param[in] unsteady - Allocate velocity and acceleration. - * \param[in] config - Definition of the particular problem. - */ - CDiscAdjFEAVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, - unsigned long nvar, bool unsteady, CConfig *config); - -public: - /*! - * \brief Destructor of the class. - */ - ~CDiscAdjFEAVariable() override = default; - - /*! - * \brief Set the sensitivity at the node - * \param[in] iDim - spacial component - * \param[in] val - value of the Sensitivity - */ - inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity(iPoint,iDim) = val; } - - /*! - * \brief Set the previous time sensitivity at the node - * \param[in] iDim - dimension - * \param[in] val - value of the Sensitivity - */ - inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity_Old(iPoint,iDim) = val; } - - /*! - * \brief Get the Sensitivity at the node - * \param[in] iDim - spacial component - * \return value of the Sensitivity - */ - inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity(iPoint,iDim);} - - /*! - * \brief Get the previous time sensitivity at the node - * \param[in] iDim - dimension - * \return value of the Sensitivity - */ - inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity_Old(iPoint,iDim);} - - inline void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) final { - Dynamic_Derivative_n(iPoint,iVar) = der; - } - - inline su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const final { - return Dynamic_Derivative_n(iPoint,iVar); - } - - inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; - } - - inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } - -}; diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 6c4cfccef2e..002199d3d91 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -35,7 +35,7 @@ * \ingroup Discrete_Adjoint * \author T. Albring. */ -class CDiscAdjVariable final : public CVariable { +class CDiscAdjVariable : public CVariable { private: MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ @@ -64,42 +64,42 @@ class CDiscAdjVariable final : public CVariable { * \param[in] iDim - spacial component * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) override { Sensitivity(iPoint,iDim) = val;} + inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity(iPoint,iDim) = val;} /*! * \brief Set the previous time sensitivity at the node * \param[in] iDim - dimension * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) override { Sensitivity_Old(iPoint,iDim) = val;} + inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity_Old(iPoint,iDim) = val;} /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component * \return value of the Sensitivity */ - inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const override { return Sensitivity(iPoint,iDim); } + inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity(iPoint,iDim); } /*! * \brief Get the previous time sensitivity at the node * \param[in] iDim - dimension * \return value of the Sensitivity */ - inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const override { return Sensitivity_Old(iPoint,iDim); } + inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity_Old(iPoint,iDim); } - inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative(iPoint,iVar) = der; } + inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) { DualTime_Derivative(iPoint,iVar) = der; } - inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) override { DualTime_Derivative_n(iPoint,iVar) = der; } + inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) { DualTime_Derivative_n(iPoint,iVar) = der; } - inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const override { return DualTime_Derivative(iPoint,iVar); } + inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const { return DualTime_Derivative(iPoint,iVar); } - inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const override { return DualTime_Derivative_n(iPoint,iVar); } + inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return DualTime_Derivative_n(iPoint,iVar); } - inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) override { + inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline su2double* GetSolution_Direct(unsigned long iPoint) override { return Solution_Direct[iPoint]; } + inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 52bb1a2cbf9..1201893ba15 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2220,18 +2220,6 @@ class CVariable { */ inline virtual su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - inline virtual void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const {return 0.0;} - - inline virtual su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const {return 0.0;} - - inline virtual void SetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) {} - - inline virtual su2double GetDynamic_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return 0.0; } - inline virtual void SetTauWall(unsigned long iPoint, su2double val_tau_wall) {} inline virtual su2double GetTauWall(unsigned long iPoint) const { return 0.0; } diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 054df6fa267..5f7975302eb 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -203,7 +203,6 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/variables/CAdjTurbVariable.cpp \ ../src/variables/CTransLMVariable.cpp \ ../src/variables/CDiscAdjFEABoundVariable.cpp \ - ../src/variables/CDiscAdjFEAVariable.cpp \ ../src/variables/CIncEulerVariable.cpp \ ../src/variables/CTurbVariable.cpp \ ../src/variables/CNSVariable.cpp \ diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index 53de4efdb1d..ee288818ef4 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -55,7 +55,6 @@ su2_cfd_src += files(['variables/CIncNSVariable.cpp', 'variables/CTurbVariable.cpp', 'variables/CAdjNSVariable.cpp', 'variables/CBaselineVariable.cpp', - 'variables/CDiscAdjFEAVariable.cpp', 'variables/CDiscAdjFEABoundVariable.cpp', 'variables/CDiscAdjMeshBoundVariable.cpp', 'variables/CFEABoundVariable.cpp', diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 48b3202d782..928e01c075f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -26,7 +26,6 @@ */ #include "../../include/solvers/CDiscAdjFEASolver.hpp" -#include "../../include/variables/CDiscAdjFEAVariable.hpp" CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolver *direct_solver, unsigned short Kind_Solver, unsigned short iMesh) : CSolver() { @@ -68,7 +67,7 @@ CDiscAdjFEASolver::CDiscAdjFEASolver(CGeometry *geometry, CConfig *config, CSolv /*--- Initialize the adjoint solution. ---*/ vector init(nVar,1e-16); - nodes = new CDiscAdjFEABoundVariable(init.data(), nPoint, nDim, nVar, dynamic, config); + nodes = new CDiscAdjFEABoundVariable(init.data(), nPoint, nDim, nVar, config); SetBaseClassPointerToNodes(); /*--- Set which points are vertices and allocate boundary data. ---*/ @@ -374,7 +373,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ if (dynamic) { for (iVar = 0; iVar < nVar; iVar++) - Solution[iVar] += nodes->GetDynamic_Derivative_n(iPoint,iVar); + Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } if (deform_mesh) { @@ -399,7 +398,7 @@ void CDiscAdjFEASolver::Preprocessing(CGeometry *geometry, CSolver **solver_cont if (config_container->GetTime_Domain()) { for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) for (auto iVar=0u; iVar < nVar; iVar++) - nodes->SetDynamic_Derivative_n(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); + nodes->SetDual_Time_Derivative(iPoint, iVar, nodes->GetSolution_time_n(iPoint, iVar)); } } diff --git a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp index d55e9a9619c..09234c1c67e 100644 --- a/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjFEABoundVariable.cpp @@ -28,8 +28,8 @@ #include "../../include/variables/CDiscAdjFEABoundVariable.hpp" CDiscAdjFEABoundVariable::CDiscAdjFEABoundVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, - unsigned long nvar, bool unsteady, CConfig *config) : - CDiscAdjFEAVariable(sol, npoint, ndim, nvar, unsteady, config) { + unsigned long nvar, CConfig *config) : + CDiscAdjVariable(sol, npoint, ndim, nvar, config) { VertexMap.Reset(nPoint); } diff --git a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp b/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp deleted file mode 100644 index 28604822ab3..00000000000 --- a/SU2_CFD/src/variables/CDiscAdjFEAVariable.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/*! - * \file CDiscAdjFEAVariable.cpp - * \brief Definition of the variables for FEM adjoint elastic structural problems. - * \author R. Sanchez - * \version 7.1.1 "Blackbird" - * - * SU2 Project Website: https://su2code.github.io - * - * The SU2 Project is maintained by the SU2 Foundation - * (http://su2foundation.org) - * - * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) - * - * SU2 is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * SU2 is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with SU2. If not, see . - */ - -#include "../../include/variables/CDiscAdjFEAVariable.hpp" - -CDiscAdjFEAVariable::CDiscAdjFEAVariable(const su2double *sol, unsigned long npoint, unsigned long ndim, - unsigned long nvar, bool unsteady, CConfig *config) : - CVariable(npoint, ndim, nvar, config, true) { - - Solution_Direct.resize(nPoint,nVar); - Sensitivity.resize(nPoint,nDim) = su2double(0.0); - Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); - - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - Solution(iPoint,iVar) = sol[iVar]; - } - - if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { - External.resize(nPoint,nVar) = su2double(0.0); - } - - /*--- Nothing else to allocate ---*/ - if (!unsteady) return; - - Dynamic_Derivative_n.resize(nPoint,nVar) = su2double(0.0); - -} diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index 574500805bf..39f254f2585 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -27,19 +27,15 @@ #include "../../include/variables/CDiscAdjVariable.hpp" -CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, unsigned long nvar, CConfig *config) - : CVariable(npoint, ndim, nvar, config, true) { +CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, unsigned long ndim, + unsigned long nvar, CConfig *config) : + CVariable(npoint, ndim, nvar, config, true) { - bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || - (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); - - if (dual_time) { + if (config->GetTime_Domain()) DualTime_Derivative.resize(nPoint,nVar) = su2double(0.0); - DualTime_Derivative_n.resize(nPoint,nVar) = su2double(0.0); - Solution_time_n.resize(nPoint,nVar) = su2double(0.0); - Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); - } + if (config->GetTime_Marching() != TIME_MARCHING::STEADY) + DualTime_Derivative_n.resize(nPoint,nVar) = su2double(0.0); Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); @@ -48,8 +44,4 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; ++iVar) Solution(iPoint,iVar) = sol[iVar]; - - if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { - External.resize(nPoint,nVar) = su2double(0.0); - } } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 30f35a58bcf..37622e12441 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -59,20 +59,25 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva Solution_Old.resize(nPoint,nVar) = su2double(0.0); - if (config->GetTime_Marching() != TIME_MARCHING::STEADY) { - Solution_time_n.resize(nPoint,nVar); - Solution_time_n1.resize(nPoint,nVar); - } - else if (config->GetTime_Domain()) { + if (config->GetTime_Domain()) Solution_time_n.resize(nPoint,nVar) = su2double(0.0); - } - if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint() && !adjoint) { - AD_InputIndex.resize(nPoint,nVar) = -1; - AD_OutputIndex.resize(nPoint,nVar) = -1; - if (config->GetTime_Domain()) { - AD_Time_n_InputIndex.resize(nPoint,nVar) = -1; - AD_Time_n1_InputIndex.resize(nPoint,nVar) = -1; + if (config->GetTime_Marching() != TIME_MARCHING::STEADY) + Solution_time_n1.resize(nPoint,nVar); + + if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { + if (adjoint) { + External.resize(nPoint,nVar) = su2double(0.0); + } + else { + AD_InputIndex.resize(nPoint,nVar) = -1; + AD_OutputIndex.resize(nPoint,nVar) = -1; + + if (config->GetTime_Domain()) + AD_Time_n_InputIndex.resize(nPoint,nVar) = -1; + + if (config->GetTime_Marching() != TIME_MARCHING::STEADY) + AD_Time_n1_InputIndex.resize(nPoint,nVar) = -1; } } From 2fc6555bcb6e1f7380371c8f8aa9a3fa57d41d00 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 6 May 2021 13:23:02 +0200 Subject: [PATCH 052/192] Fix build --- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 5f1d0878501..90c135af199 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -326,7 +326,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution ---*/ - if(multizone) { + if(config->GetMultizone_Problem()) { direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); } else { @@ -374,7 +374,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - if(multizone) { + if(config->GetMultizone_Problem()) { direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); } else { @@ -391,7 +391,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - if(multizone) { + if(config->GetMultizone_Problem()) { direct_solver->GetNodes()->GetAdjointSolution_time_n1_LocalIndex(iPoint,Solution); } else { From 8f8e00797142c404394a1cb901bfcad61cb9a118 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 6 May 2021 13:43:58 +0200 Subject: [PATCH 053/192] Clean CDiscAdjVar.hpp: Added briefs, deleted superfluous inputs, line breaks --- .../include/variables/CDiscAdjVariable.hpp | 74 +++++++++++++------ 1 file changed, 52 insertions(+), 22 deletions(-) diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 002199d3d91..83464efcfb8 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -37,11 +37,11 @@ */ class CDiscAdjVariable : public CVariable { private: - MatrixType Sensitivity; /* Vector holding the derivative of target functional with respect to the coordinates at this node*/ - MatrixType Sensitivity_Old; /* Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity*/ - MatrixType Solution_Direct; - MatrixType DualTime_Derivative; - MatrixType DualTime_Derivative_n; + MatrixType Sensitivity; /*!< \brief Vector holding the derivative of target functional with respect to the coordinates at this node. */ + MatrixType Sensitivity_Old; /*!< \brief Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity. */ + MatrixType Solution_Direct; /*!< \brief Stores the primal solution of the current timestep in order to be able to reset. */ + MatrixType DualTime_Derivative; /*!< \brief Container holding all/sum-of dual time contributions to the adjoint variable. */ + MatrixType DualTime_Derivative_n; /*!< \brief Container holding dual time contributions to the adjoint variable used in the next timestep. */ public: /*! @@ -61,45 +61,75 @@ class CDiscAdjVariable : public CVariable { /*! * \brief Set the sensitivity at the node - * \param[in] iDim - spacial component - * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity(iPoint,iDim) = val;} + inline void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) final { + Sensitivity(iPoint,iDim) = val; + } /*! * \brief Set the previous time sensitivity at the node - * \param[in] iDim - dimension - * \param[in] val - value of the Sensitivity */ - inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { Sensitivity_Old(iPoint,iDim) = val;} + inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { + Sensitivity_Old(iPoint,iDim) = val; + } /*! * \brief Get the Sensitivity at the node - * \param[in] iDim - spacial component - * \return value of the Sensitivity */ - inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity(iPoint,iDim); } + inline su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const final { + return Sensitivity(iPoint,iDim); + } /*! * \brief Get the previous time sensitivity at the node - * \param[in] iDim - dimension - * \return value of the Sensitivity */ - inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { return Sensitivity_Old(iPoint,iDim); } + inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { + return Sensitivity_Old(iPoint,iDim); + } - inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) { DualTime_Derivative(iPoint,iVar) = der; } + /*! + * \brief Set/store the dual time contributions to the adjoint variable. + * Contains sum of contributions from 2 timesteps for dual time 2nd order. + */ + inline void SetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar, su2double der) { + DualTime_Derivative(iPoint,iVar) = der; + } - inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) { DualTime_Derivative_n(iPoint,iVar) = der; } + /*! + * \brief Set/store the dual time contributions to the adjoint variable for upcoming timestep. + */ + inline void SetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar, su2double der) { + DualTime_Derivative_n(iPoint,iVar) = der; + } - inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const { return DualTime_Derivative(iPoint,iVar); } + /*! + * \brief Return the dual time contributions to the adjoint variable. + * Contains sum of contributions from 2 timesteps for dual time 2nd order. + */ + inline su2double GetDual_Time_Derivative(unsigned long iPoint, unsigned long iVar) const { + return DualTime_Derivative(iPoint,iVar); + } - inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const { return DualTime_Derivative_n(iPoint,iVar); } + /*! + * \brief Return the dual time contributions to the adjoint variable for upcoming timestep. + */ + inline su2double GetDual_Time_Derivative_n(unsigned long iPoint, unsigned long iVar) const { + return DualTime_Derivative_n(iPoint,iVar); + } + /*! + * \brief Set/store the primal solution for all variables of one point. + */ inline void SetSolution_Direct(unsigned long iPoint, const su2double *val_solution_direct) final { for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Direct(iPoint,iVar) = val_solution_direct[iVar]; } - inline su2double* GetSolution_Direct(unsigned long iPoint) final { return Solution_Direct[iPoint]; } + /*! + * \brief Returns the primal solution for all variables of one point. + */ + inline su2double* GetSolution_Direct(unsigned long iPoint) final { + return Solution_Direct[iPoint]; + } }; From 64897d3f89d5c76c671c001e667ed81b73a8339f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Thu, 6 May 2021 20:35:46 +0100 Subject: [PATCH 054/192] some cleanup --- .../drivers/CDiscAdjMultizoneDriver.hpp | 4 +- .../include/variables/CDiscAdjVariable.hpp | 15 --- SU2_CFD/include/variables/CVariable.hpp | 14 --- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 103 ++++++------------ .../src/iteration/CDiscAdjFEAIteration.cpp | 6 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 2 +- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 1 - TestCases/disc_adj_fsi/Airfoil_2d/config.cfg | 4 +- .../disc_adj_fsi/Airfoil_2d/configFEA.cfg | 1 - .../disc_adj_fsi/Airfoil_2d/configFlow.cfg | 1 - 11 files changed, 41 insertions(+), 112 deletions(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index fa11c9ee7f4..5a5e9bd5ebe 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -151,10 +151,10 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { /*! * \brief Evaluate sensitivites for the current adjoint solution and output files. - * \param[in] iOuterIter - Current outer iteration. + * \param[in] Iter - Current outer or time iteration. * \param[in] StopCalc - Final iteration flag (converged or reached max number of iters). */ - void EvaluateSensitivities(unsigned long iOuterIter, bool StopCalc); + void EvaluateSensitivities(unsigned long Iter, bool StopCalc); /*! * \brief Setup the matrix of cross-terms. Allocate necessary memory and initialize to zero. diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 83464efcfb8..306df11896f 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -38,7 +38,6 @@ class CDiscAdjVariable : public CVariable { private: MatrixType Sensitivity; /*!< \brief Vector holding the derivative of target functional with respect to the coordinates at this node. */ - MatrixType Sensitivity_Old; /*!< \brief Previous time sensitivity holder since inner iterations in FSI problems overwrite sensitivity. */ MatrixType Solution_Direct; /*!< \brief Stores the primal solution of the current timestep in order to be able to reset. */ MatrixType DualTime_Derivative; /*!< \brief Container holding all/sum-of dual time contributions to the adjoint variable. */ MatrixType DualTime_Derivative_n; /*!< \brief Container holding dual time contributions to the adjoint variable used in the next timestep. */ @@ -66,13 +65,6 @@ class CDiscAdjVariable : public CVariable { Sensitivity(iPoint,iDim) = val; } - /*! - * \brief Set the previous time sensitivity at the node - */ - inline void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) final { - Sensitivity_Old(iPoint,iDim) = val; - } - /*! * \brief Get the Sensitivity at the node */ @@ -80,13 +72,6 @@ class CDiscAdjVariable : public CVariable { return Sensitivity(iPoint,iDim); } - /*! - * \brief Get the previous time sensitivity at the node - */ - inline su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const final { - return Sensitivity_Old(iPoint,iDim); - } - /*! * \brief Set/store the dual time contributions to the adjoint variable. * Contains sum of contributions from 2 timesteps for dual time 2nd order. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index af6c101185d..08a0977c4a8 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2199,13 +2199,6 @@ class CVariable { */ inline virtual void SetSensitivity(unsigned long iPoint, unsigned long iDim, su2double val) {} - /*! - * \brief Set the previous time sensitivity at the node - * \param[in] iDim - dimension - * \param[in] val - value of the Sensitivity - */ - inline virtual void SetSensitivity_Old(unsigned long iPoint, unsigned long iDim, su2double val) {} - /*! * \brief Get the Sensitivity at the node * \param[in] iDim - spacial component @@ -2213,13 +2206,6 @@ class CVariable { */ inline virtual su2double GetSensitivity(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - /*! - * \brief Get the previous time sensitivity at the node - * \param[in] iDim - dimension - * \return value of the Sensitivity - */ - inline virtual su2double GetSensitivity_Old(unsigned long iPoint, unsigned long iDim) const { return 0.0; } - inline virtual void SetTauWall(unsigned long iPoint, su2double val_tau_wall) {} inline virtual su2double GetTauWall(unsigned long iPoint) const { return 0.0; } diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 8e07eb4fef7..02eb4ec5e2b 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -140,7 +140,11 @@ void CDiscAdjMultizoneDriver::StartSolver() { cout << "The simulation will run for " << driver_config->GetnTime_Iter() << " time steps." << endl; } - while ( TimeIter < driver_config->GetnTime_Iter()) { + /*--- Size and initialize the matrix of cross-terms. ---*/ + + InitializeCrossTerms(); + + while (TimeIter < driver_config->GetnTime_Iter()) { for (iZone = 0; iZone < nZone; iZone++) { @@ -153,18 +157,28 @@ void CDiscAdjMultizoneDriver::StartSolver() { config_container[iZone]->SetPhysicalTime(0.0); } - /*--- Size and initialize the matrix of cross-terms. ---*/ - - InitializeCrossTerms(); + if (TimeIter) { + /*--- Reset cross-terms before new time iterations. ---*/ + for (auto& matOfMat : Cross_Terms) + for (auto& vecOfMat : matOfMat) + for (auto& mat : vecOfMat) + mat = 0.0; + + /*--- Reset external and solution ---*/ + /// TODO: Init with dual time derivative instead. + for (iZone = 0; iZone < nZone; iZone++) { + for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; + if (solver && solver->GetAdjoint()) solver->GetNodes()->SetExternalZero(); + } + Set_Solution_To_BGSSolution_k(iZone); + } + } /*--- We directly start the discrete adjoint computation. ---*/ Run(); - /*--- Output the solution in files for each time iteration. ---*/ - - Output(TimeIter); - TimeIter++; } } @@ -208,24 +222,13 @@ bool CDiscAdjMultizoneDriver::Iterate(unsigned short iZone, unsigned long iInner void CDiscAdjMultizoneDriver::Run() { - unsigned long wrt_sol_freq = 9999; + unsigned long wrt_sol_freq = 99999; const unsigned long nOuterIter = driver_config->GetnOuter_Iter(); const bool time_domain = driver_config->GetTime_Domain(); - /*--- Reset external and solution ---*/ - for (iZone = 0; iZone < nZone; iZone++) { - for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { - auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; - if (solver && solver->GetAdjoint()) - solver->GetNodes()->SetExternalZero(); - } - Set_Solution_To_BGSSolution_k(iZone); - } - for (iZone = 0; iZone < nZone; iZone++) { - if (!time_domain) - wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); + wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); iteration_container[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, @@ -464,55 +467,17 @@ void CDiscAdjMultizoneDriver::Run() { bool checkSensitivity = StopCalc || ((iOuterIter % wrt_sol_freq == 0) && (iOuterIter != 0)); - if (checkSensitivity) + if (checkSensitivity && !time_domain) EvaluateSensitivities(iOuterIter, StopCalc); } - /*--- Add current time sensitivity ---*/ - /*--- Cumulative sensitivity stored here in order to exclude summation within outer iteration ---*/ - for (iZone = 0; iZone < nZone; iZone++) { - - auto solvers = solver_container[iZone][INST_0][MESH_0]; - auto geometry = geometry_container[iZone][INST_0][MESH_0]; - int IDX_SOL = NO_SOLVER; - - switch (config_container[iZone]->GetKind_Solver()) { - case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: - case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: - if(config_container[iZone]->GetDeform_Mesh()) IDX_SOL = ADJMESH_SOL; - else IDX_SOL = ADJFLOW_SOL; - break; - case DISC_ADJ_HEAT: - IDX_SOL = ADJHEAT_SOL; - break; - case DISC_ADJ_FEM: - IDX_SOL = ADJFEA_SOL; - break; - default: - SU2_MPI::Error("Chosen discrete adjoint solver not yet supported for calculation of sensitivities", CURRENT_FUNCTION); - break; - } - - su2double Sensitivity; - for (unsigned long iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - - /*--- Current time iteration sensitivity ---*/ - Sensitivity = solvers[IDX_SOL]->GetNodes()->GetSensitivity(iPoint, iDim); - - /*--- Update old sensitivity container ---*/ - solvers[IDX_SOL]->GetNodes()->SetSensitivity_Old(iPoint, iDim, Sensitivity + - solvers[IDX_SOL]->GetNodes()->GetSensitivity_Old(iPoint, iDim)); - - /*--- Update sensitivity ---*/ - solvers[IDX_SOL]->GetNodes()->SetSensitivity( - iPoint, iDim, solvers[IDX_SOL]->GetNodes()->GetSensitivity_Old(iPoint, iDim)); - } - } + if (time_domain) { + EvaluateSensitivities(TimeIter, false); } + } -void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long iOuterIter, bool StopCalc) { +void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool StopCalc) { /*--- SetRecording stores the computational graph on one iteration of the direct problem. Calling it with NONE * as argument ensures that all information from a previous recording is removed. ---*/ @@ -589,14 +554,10 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long iOuterIter, bo AD::ClearAdjoints(); - if (!driver_config->GetTime_Domain()) { - for (iZone = 0; iZone < nZone; iZone++) { + /*--- Output files. ---*/ + + Output(Iter); - output_container[iZone]->SetResult_Files(geometry_container[iZone][INST_0][MESH_0], - config_container[iZone], - solver_container[iZone][INST_0][MESH_0], iOuterIter, StopCalc); - } - } } void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape tape_type, unsigned short record_zone) { diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 24de5f5b1b3..75b1080ac23 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -279,10 +279,8 @@ void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** ge dir_solver->InitiateComms(structural_geometry, config[iZone], SOLUTION_FEA); dir_solver->CompleteComms(structural_geometry, config[iZone], SOLUTION_FEA); - if (kind_recording == RECORDING::MESH_COORDS) { - structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); - structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); - } + structural_geometry->InitiateComms(structural_geometry, config[iZone], COORDINATES); + structural_geometry->CompleteComms(structural_geometry, config[iZone], COORDINATES); } END_SU2_OMP_PARALLEL diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 928e01c075f..e73635704e4 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -434,7 +434,7 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo AD::ResetInput(Coord[iDim]); } - if (!(config->GetTime_Domain()) || config->GetMultizone_Problem()) { + if (!config->GetTime_Domain()) { nodes->SetSensitivity(iPoint, iDim, Sensitivity); } else { nodes->SetSensitivity(iPoint, iDim, nodes->GetSensitivity(iPoint, iDim) + Sensitivity); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 90c135af199..fa6673e00ce 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -536,7 +536,7 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve if (config->GetSens_Remove_Sharp() && geometry->nodes->GetSharpEdge_Distance(iPoint) < eps) { Sensitivity = 0.0; } - if (!time_stepping || config->GetMultizone_Problem()) { + if (!time_stepping) { nodes->SetSensitivity(iPoint,iDim, Sensitivity); } else { nodes->SetSensitivity(iPoint,iDim, nodes->GetSensitivity(iPoint,iDim) + Sensitivity); diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index 39f254f2585..315d6318e87 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -39,7 +39,6 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u Solution_Direct.resize(nPoint,nVar); Sensitivity.resize(nPoint,nDim) = su2double(0.0); - Sensitivity_Old.resize(nPoint,nDim) = su2double(0.0); for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) for (unsigned long iVar = 0; iVar < nVar; ++iVar) diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg index f545d1bfb53..e76d811427e 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg @@ -7,10 +7,12 @@ MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side CONSERVATIVE_INTERPOLATION= NO OUTER_ITER= 9 +OUTPUT_WRT_FREQ= 99999 + MESH_FILENAME= mesh.su2 OBJECTIVE_FUNCTION= REFERENCE_NODE SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] -%WRT_ZONE_CONV=YES +WRT_ZONE_CONV=YES diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/configFEA.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/configFEA.cfg index 30dbb2dc246..b69b6d08132 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/configFEA.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/configFEA.cfg @@ -44,7 +44,6 @@ MESH_FORMAT= SU2 RESTART_SOL= NO SOLUTION_FILENAME= solution_solid.dat SOLUTION_ADJ_FILENAME= adjoint_solid.dat -OUTPUT_WRT_FREQ= 999999 RESTART_FILENAME= solution_solid.dat RESTART_ADJ_FILENAME= adjoint_solid.dat % diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg index 03ae5b6d85e..2dbad80c7b7 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/configFlow.cfg @@ -87,7 +87,6 @@ MESH_FORMAT= SU2 RESTART_SOL= NO SOLUTION_FILENAME= solution_fluid.dat SOLUTION_ADJ_FILENAME= adjoint_fluid.dat -OUTPUT_WRT_FREQ= 999999 RESTART_FILENAME= solution_fluid.dat RESTART_ADJ_FILENAME= adjoint_fluid.dat % From b282d20b3b5f8f0fd243dcb1f56469b95fbc40ee Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Thu, 6 May 2021 22:25:05 +0100 Subject: [PATCH 055/192] more cleaning of old things --- .../include/variables/CMeshBoundVariable.hpp | 3 +-- SU2_CFD/include/variables/CMeshVariable.hpp | 3 +-- SU2_CFD/include/variables/CVariable.hpp | 6 ++---- SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp | 8 +++---- SU2_CFD/src/variables/CMeshBoundVariable.cpp | 16 ++++---------- SU2_CFD/src/variables/CMeshVariable.cpp | 21 ++++++------------- 6 files changed, 17 insertions(+), 40 deletions(-) diff --git a/SU2_CFD/include/variables/CMeshBoundVariable.hpp b/SU2_CFD/include/variables/CMeshBoundVariable.hpp index ae054174566..0ed2738d8a5 100644 --- a/SU2_CFD/include/variables/CMeshBoundVariable.hpp +++ b/SU2_CFD/include/variables/CMeshBoundVariable.hpp @@ -117,9 +117,8 @@ class CMeshBoundVariable final : public CMeshVariable { /*! * \brief Register the boundary displacements of the mesh. - * \param[in] input - Defines whether we are registering the variable as input or as output. */ - void Register_BoundDisp(bool input) override; + void Register_BoundDisp() override; /*! * \brief Recover the value of the adjoint of the boundary displacements. diff --git a/SU2_CFD/include/variables/CMeshVariable.hpp b/SU2_CFD/include/variables/CMeshVariable.hpp index 1501d1bfc10..7b917f51ffc 100644 --- a/SU2_CFD/include/variables/CMeshVariable.hpp +++ b/SU2_CFD/include/variables/CMeshVariable.hpp @@ -87,9 +87,8 @@ class CMeshVariable : public CVariable { /*! * \brief Register the reference coordinates of the mesh. - * \param[in] input - Defines whether we are registering the variable as input or as output. */ - void Register_MeshCoord(bool input) final; + void Register_MeshCoord() final; /*! * \brief Recover the value of the adjoint of the mesh coordinates. diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 08a0977c4a8..576abe81315 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2018,9 +2018,8 @@ class CVariable { /*! * \brief A virtual member. Register the reference coordinates of the mesh. - * \param[in] input - Defines whether we are registering the variable as input or as output. */ - inline virtual void Register_MeshCoord(bool input) { } + inline virtual void Register_MeshCoord() { } /*! * \brief A virtual member. Recover the value of the adjoint of the mesh coordinates. @@ -2092,9 +2091,8 @@ class CVariable { /*! * \brief A virtual member. Register the boundary displacements of the mesh. - * \param[in] input - Defines whether we are registering the variable as input or as output. */ - inline virtual void Register_BoundDisp(bool input) { } + inline virtual void Register_BoundDisp() { } /*! * \brief A virtual member. Recover the value of the adjoint of the boundary displacements. diff --git a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp index 2995b97b3a5..cc1a57b6684 100644 --- a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp @@ -103,17 +103,15 @@ void CDiscAdjMeshSolver::SetRecording(CGeometry* geometry, CConfig *config){ void CDiscAdjMeshSolver::RegisterSolution(CGeometry *geometry, CConfig *config){ /*--- Register reference mesh coordinates ---*/ - bool input = true; - direct_solver->GetNodes()->Register_MeshCoord(input); + direct_solver->GetNodes()->Register_MeshCoord(); } void CDiscAdjMeshSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset){ SU2_OMP_MASTER { - /*--- Register boundary displacements as input ---*/ - bool input = true; - direct_solver->GetNodes()->Register_BoundDisp(input); + /*--- Register boundary displacements as input. ---*/ + direct_solver->GetNodes()->Register_BoundDisp(); } END_SU2_OMP_MASTER SU2_OMP_BARRIER diff --git a/SU2_CFD/src/variables/CMeshBoundVariable.cpp b/SU2_CFD/src/variables/CMeshBoundVariable.cpp index 9460543d374..3330f7e885d 100644 --- a/SU2_CFD/src/variables/CMeshBoundVariable.cpp +++ b/SU2_CFD/src/variables/CMeshBoundVariable.cpp @@ -25,7 +25,6 @@ * License along with SU2. If not, see . */ - #include "../../include/variables/CMeshBoundVariable.hpp" CMeshBoundVariable::CMeshBoundVariable(unsigned long npoint, unsigned long ndim, CConfig *config) : @@ -48,15 +47,8 @@ void CMeshBoundVariable::AllocateBoundaryVariables(CConfig *config) { if (config->GetTime_Domain()) Boundary_Velocity.resize(nBoundPt,nDim) = su2double(0.0); } -void CMeshBoundVariable::Register_BoundDisp(bool input) { - if (input) { - for (unsigned long iVertex = 0; iVertex < Boundary_Displacement.rows(); iVertex++) - for (unsigned long iVar = 0; iVar < nVar; iVar++) - AD::RegisterInput(Boundary_Displacement(iVertex,iVar)); - } - else { - for (unsigned long iVertex = 0; iVertex < Boundary_Displacement.rows(); iVertex++) - for (unsigned long iVar = 0; iVar < nVar; iVar++) - AD::RegisterOutput(Boundary_Displacement(iVertex,iVar)); - } +void CMeshBoundVariable::Register_BoundDisp() { + for (unsigned long iVertex = 0; iVertex < Boundary_Displacement.rows(); iVertex++) + for (unsigned long iVar = 0; iVar < nVar; iVar++) + AD::RegisterInput(Boundary_Displacement(iVertex,iVar)); } diff --git a/SU2_CFD/src/variables/CMeshVariable.cpp b/SU2_CFD/src/variables/CMeshVariable.cpp index d4786c3ed75..ea3a86a1513 100644 --- a/SU2_CFD/src/variables/CMeshVariable.cpp +++ b/SU2_CFD/src/variables/CMeshVariable.cpp @@ -48,19 +48,10 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig * } } -void CMeshVariable::Register_MeshCoord(bool input) { - if (input) { - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - for (unsigned long iDim = 0; iDim < nDim; iDim++) - AD::RegisterInput(Mesh_Coord(iPoint,iDim)); - END_SU2_OMP_FOR - } - else { - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - for (unsigned long iDim = 0; iDim < nDim; iDim++) - AD::RegisterOutput(Mesh_Coord(iPoint,iDim)); - END_SU2_OMP_FOR - } +void CMeshVariable::Register_MeshCoord() { + SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned long iDim = 0; iDim < nDim; iDim++) + AD::RegisterInput(Mesh_Coord(iPoint,iDim)); + END_SU2_OMP_FOR } From d8ef5f39b522833714ec411de3ae179893c62f24 Mon Sep 17 00:00:00 2001 From: cvencro Date: Fri, 7 May 2021 01:51:08 +0100 Subject: [PATCH 056/192] multizone output only for reg test compare --- TestCases/disc_adj_fsi/Airfoil_2d/config.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg index e76d811427e..012ad702857 100755 --- a/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg +++ b/TestCases/disc_adj_fsi/Airfoil_2d/config.cfg @@ -15,4 +15,4 @@ OBJECTIVE_FUNCTION= REFERENCE_NODE SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] -WRT_ZONE_CONV=YES +%WRT_ZONE_CONV=YES From 34061a662f4a46fb7582519a30e69299a239a2be Mon Sep 17 00:00:00 2001 From: cvencro Date: Fri, 7 May 2021 02:56:22 +0100 Subject: [PATCH 057/192] fix for dynamic AD convergence --- SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp | 6 +++--- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 75b1080ac23..7e30516309d 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -180,10 +180,10 @@ void CDiscAdjFEAIteration::RegisterInput(CSolver***** solver, CGeometry**** geom solver[iZone][iInst][MESH_0][FEA_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - /*--- Register mesh coordinates for geometric sensitivities ---*/ - - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); } + /*--- Register mesh coordinates for geometric sensitivities ---*/ + + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); } void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 0d23ec5167d..dbc6a0dff53 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -462,13 +462,11 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge } /*--- Register the variables of the mesh deformation ---*/ - if (kind_recording == RECORDING::MESH_DEFORM) { - /*--- Undeformed mesh coordinates ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); + /*--- Undeformed mesh coordinates ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); - /*--- Boundary displacements ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - } + /*--- Boundary displacements ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); } END_SU2_OMP_PARALLEL From 97ba004570af3deb0b2fd03cac4db3939115299d Mon Sep 17 00:00:00 2001 From: cvencro Date: Fri, 7 May 2021 03:15:21 +0100 Subject: [PATCH 058/192] only for deformation problems --- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index dbc6a0dff53..0f20cf2d6c5 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -461,13 +461,14 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); } - /*--- Register the variables of the mesh deformation ---*/ - /*--- Undeformed mesh coordinates ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); - - /*--- Boundary displacements ---*/ - solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); + if (config[iZone]->GetDeform_Mesh()) { + /*--- Register the variables of the mesh deformation ---*/ + /*--- Undeformed mesh coordinates ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); + /*--- Boundary displacements ---*/ + solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); + } } END_SU2_OMP_PARALLEL } From 04b8a6e300f23a2457e6d9d25b350150972e7493 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Fri, 7 May 2021 12:32:31 +0100 Subject: [PATCH 059/192] move some chunks out of CDiscAdjMultizoneDriver::Run to make it more readable --- .../drivers/CDiscAdjMultizoneDriver.hpp | 16 ++ .../include/variables/CDiscAdjVariable.hpp | 5 + SU2_CFD/include/variables/CVariable.hpp | 4 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 195 ++++++++++-------- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 5 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 14 +- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 5 + SU2_CFD/src/variables/CFEAVariable.cpp | 13 +- 8 files changed, 160 insertions(+), 97 deletions(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index 5a5e9bd5ebe..fdbeb839c5a 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -149,6 +149,17 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { */ bool Iterate(unsigned short iZone, unsigned long iInnerIter, bool KrylovMode = false); + /*! + * \brief Run inner iterations using a Krylov method (GMRES atm). + */ + void KrylovInnerIters(unsigned short iZone); + + /*! + * \brief Evaluate the gradient of the objective function and add to "External". + * \return "True" if the gradient is numerically 0. + */ + bool EvaluateObjectiveFunctionGradient(); + /*! * \brief Evaluate sensitivites for the current adjoint solution and output files. * \param[in] Iter - Current outer or time iteration. @@ -217,6 +228,11 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { */ void Add_Solution_To_External(unsigned short iZone); + /*! + * \brief Puts dual time derivative vector to External. + */ + void Set_DualTimeDer_To_External(); + /*! * \brief Add External_Old vector to Solution. * \param[in] iZone - Zone index. diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 306df11896f..7d136ffa0b8 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -117,4 +117,9 @@ class CDiscAdjVariable : public CVariable { return Solution_Direct[iPoint]; } + /*! + * \brief Set Dual-time derivative contributions to the external. + */ + void Set_DualTimeDer_To_External() final; + }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 576abe81315..98b3f32d305 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -370,9 +370,9 @@ class CVariable { void SetExternalZero(); /*! - * \brief Set old External to the value of the current variables. + * \brief Set Dual-time derivative contributions to the external. */ - void Set_OldExternal(); + inline virtual void Set_DualTimeDer_To_External() { SetExternalZero(); } /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 02eb4ec5e2b..6cf2cdd8cb0 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -164,15 +164,13 @@ void CDiscAdjMultizoneDriver::StartSolver() { for (auto& mat : vecOfMat) mat = 0.0; - /*--- Reset external and solution ---*/ - /// TODO: Init with dual time derivative instead. - for (iZone = 0; iZone < nZone; iZone++) { - for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { - auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; - if (solver && solver->GetAdjoint()) solver->GetNodes()->SetExternalZero(); - } - Set_Solution_To_BGSSolution_k(iZone); - } + /*--- Init external with dual time derivative. ---*/ + Set_DualTimeDer_To_External(); + +// // PG: Why this? +// for (iZone = 0; iZone < nZone; iZone++) { +// Set_Solution_To_BGSSolution_k(iZone); +// } } /*--- We directly start the discrete adjoint computation. ---*/ @@ -220,6 +218,57 @@ bool CDiscAdjMultizoneDriver::Iterate(unsigned short iZone, unsigned long iInner surface_movement, grid_movement, FFDBox, iZone, INST_0); } +void CDiscAdjMultizoneDriver::KrylovInnerIters(unsigned short iZone) { + + /*--- Use FGMRES to solve the adjoint system, the RHS is -External, + * the solution are the iZone adjoint variables + External, + * Recall that External also contains the OF gradient. ---*/ + + GetAdjointRHS(iZone, AdjRHS[iZone]); + + Add_External_To_Solution(iZone); + + GetAllSolutions(iZone, true, AdjSol[iZone]); + + const bool monitor = config_container[iZone]->GetWrt_ZoneConv(); + const auto product = AdjointProduct(this, iZone); + + /*--- Manipulate the screen output frequency to avoid printing garbage. ---*/ + const auto wrtFreq = config_container[iZone]->GetScreen_Wrt_Freq(2); + config_container[iZone]->SetScreen_Wrt_Freq(2, nInnerIter[iZone]); + LinSolver[iZone].SetMonitoringFrequency(wrtFreq); + + Scalar eps = 1.0; + for (auto totalIter = nInnerIter[iZone]; totalIter >= KrylovMinIters && eps > KrylovTol;) { + Scalar eps_l = 0.0; + Scalar tol_l = KrylovTol / eps; + auto iter = min(totalIter-2ul, config_container[iZone]->GetnQuasiNewtonSamples()-2ul); + iter = LinSolver[iZone].FGMRES_LinSolver(AdjRHS[iZone], AdjSol[iZone], product, Identity(), + tol_l, iter, eps_l, monitor, config_container[iZone]); + totalIter -= iter+1; + eps *= eps_l; + } + + /*--- Store the solution and restore user settings. ---*/ + SetAllSolutions(iZone, true, AdjSol[iZone]); + config_container[iZone]->SetScreen_Wrt_Freq(2, wrtFreq); + + /*--- Set the old solution such that iterating gives meaningful residuals. ---*/ + AdjSol[iZone] += AdjRHS[iZone]; + SetAllSolutionsOld(iZone, true, AdjSol[iZone]); + + /*--- Iterate to evaluate cross terms and residuals, this cannot happen within GMRES + * because the vectors it multiplies by the Jacobian are not the actual solution. ---*/ + eval_transfer = true; + Iterate(iZone, product.iInnerIter); + + /*--- Set the solution as obtained from GMRES, otherwise it would be GMRES+Iterate once. + * This is set without the "External" (by adding RHS above) so that it can be added + * again in the next outer iteration with new contributions from other zones. ---*/ + SetAllSolutions(iZone, true, AdjSol[iZone]); + +} + void CDiscAdjMultizoneDriver::Run() { unsigned long wrt_sol_freq = 99999; @@ -256,38 +305,12 @@ void CDiscAdjMultizoneDriver::Run() { } } - /*--- Evaluate the objective function gradient w.r.t. the solutions of all zones. ---*/ - - SetRecording(RECORDING::CLEAR_INDICES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); - SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); - RecordingState = RECORDING::CLEAR_INDICES; - - AD::ClearAdjoints(); - SetAdj_ObjFunction(); - AD::ComputeAdjoint(OBJECTIVE_FUNCTION, START); - - /*--- Initialize External with the objective function gradient. ---*/ - - su2double rhs_norm = 0.0; - - for (iZone = 0; iZone < nZone; iZone++) { - - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, - solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0, false); - Add_Solution_To_External(iZone); - - for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { - auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; - if (solver && solver->GetAdjoint()) - for (unsigned short iVar=0; iVar < solver->GetnVar(); ++iVar) - rhs_norm += solver->GetRes_RMS(iVar); - } - } + /*--- If the gradient of the objective function is 0 so are the adjoint variables. + * Unless in unsteady problems where there are other contributions to the RHS. ---*/ - /*--- If the gradient of the objective function is 0 so are the adjoint variables. ---*/ + const auto zeroGrad = EvaluateObjectiveFunctionGradient(); - if (rhs_norm < EPS) { + if (zeroGrad && !time_domain) { if (rank == MASTER_NODE) { cout << "\nThe gradient of the objective function is numerically 0."; cout << "\nThis implies that the adjoint variables are also 0.\n\n"; @@ -376,52 +399,9 @@ void CDiscAdjMultizoneDriver::Run() { } } else { - /*--- Use FGMRES to solve the adjoint system, the RHS is -External, - * the solution are the iZone adjoint variables + External, - * Recall that External also contains the OF gradient. ---*/ - - GetAdjointRHS(iZone, AdjRHS[iZone]); - - Add_External_To_Solution(iZone); + /*--- Use Krylov method to drive inner iterations of this zone. ---*/ - GetAllSolutions(iZone, true, AdjSol[iZone]); - - const bool monitor = config_container[iZone]->GetWrt_ZoneConv(); - const auto product = AdjointProduct(this, iZone); - - /*--- Manipulate the screen output frequency to avoid printing garbage. ---*/ - const auto wrtFreq = config_container[iZone]->GetScreen_Wrt_Freq(2); - config_container[iZone]->SetScreen_Wrt_Freq(2, nInnerIter[iZone]); - LinSolver[iZone].SetMonitoringFrequency(wrtFreq); - - Scalar eps = 1.0; - for (auto totalIter = nInnerIter[iZone]; totalIter >= KrylovMinIters && eps > KrylovTol;) { - Scalar eps_l = 0.0; - Scalar tol_l = KrylovTol / eps; - auto iter = min(totalIter-2ul, config_container[iZone]->GetnQuasiNewtonSamples()-2ul); - iter = LinSolver[iZone].FGMRES_LinSolver(AdjRHS[iZone], AdjSol[iZone], product, Identity(), - tol_l, iter, eps_l, monitor, config_container[iZone]); - totalIter -= iter+1; - eps *= eps_l; - } - - /*--- Store the solution and restore user settings. ---*/ - SetAllSolutions(iZone, true, AdjSol[iZone]); - config_container[iZone]->SetScreen_Wrt_Freq(2, wrtFreq); - - /*--- Set the old solution such that iterating gives meaningful residuals. ---*/ - AdjSol[iZone] += AdjRHS[iZone]; - SetAllSolutionsOld(iZone, true, AdjSol[iZone]); - - /*--- Iterate to evaluate cross terms and residuals, this cannot happen within GMRES - * because the vectors it multiplies by the Jacobian are not the actual solution. ---*/ - eval_transfer = true; - Iterate(iZone, product.iInnerIter); - - /*--- Set the solution as obtained from GMRES, otherwise it would be GMRES+Iterate once. - * This is set without the "External" (by adding RHS above) so that it can be added - * again in the next outer iteration with new contributions from other zones. ---*/ - SetAllSolutions(iZone, true, AdjSol[iZone]); + KrylovInnerIters(iZone); } /*--- Off-diagonal (coupling term) BGS update. ---*/ @@ -477,6 +457,40 @@ void CDiscAdjMultizoneDriver::Run() { } +bool CDiscAdjMultizoneDriver::EvaluateObjectiveFunctionGradient() { + + /*--- Evaluate the objective function gradient w.r.t. the solutions of all zones. ---*/ + + SetRecording(RECORDING::CLEAR_INDICES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + SetRecording(RECORDING::SOLUTION_VARIABLES, Kind_Tape::OBJECTIVE_FUNCTION_TAPE, ZONE_0); + RecordingState = RECORDING::CLEAR_INDICES; + + AD::ClearAdjoints(); + SetAdj_ObjFunction(); + AD::ComputeAdjoint(OBJECTIVE_FUNCTION, START); + + /*--- Initialize External with the objective function gradient. ---*/ + + su2double rhs_norm = 0.0; + + for (iZone = 0; iZone < nZone; iZone++) { + + iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, + surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + Add_Solution_To_External(iZone); + + for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; + if (solver && solver->GetAdjoint()) + for (unsigned short iVar=0; iVar < solver->GetnVar(); ++iVar) + rhs_norm += solver->GetRes_RMS(iVar); + } + } + + return rhs_norm < EPS; +} + void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool StopCalc) { /*--- SetRecording stores the computational graph on one iteration of the direct problem. Calling it with NONE @@ -580,7 +594,7 @@ void CDiscAdjMultizoneDriver::SetRecording(RECORDING kind_recording, Kind_Tape t if (rank == MASTER_NODE) { cout << "\n-------------------------------------------------------------------------\n"; switch(kind_recording) { - case RECORDING::CLEAR_INDICES: cout << "Clearing the computational graph." << endl; break; + case RECORDING::CLEAR_INDICES: cout << "Clearing the computational graph." << endl; break; case RECORDING::MESH_COORDS: cout << "Storing computational graph wrt MESH COORDINATES." << endl; break; case RECORDING::SOLUTION_VARIABLES: cout << "Storing computational graph wrt CONSERVATIVE VARIABLES." << endl; break; default: break; @@ -965,6 +979,17 @@ void CDiscAdjMultizoneDriver::Add_Solution_To_External(unsigned short iZone) { } } +void CDiscAdjMultizoneDriver::Set_DualTimeDer_To_External() { + + for (unsigned short iZone = 0; iZone < nZone; iZone++) { + for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; + if (solver && solver->GetAdjoint()) + solver->GetNodes()->Set_DualTimeDer_To_External(); + } + } +} + void CDiscAdjMultizoneDriver::Add_External_To_Solution(unsigned short iZone) { for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index e73635704e4..749fa322644 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -362,6 +362,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ const bool dynamic = config->GetTime_Domain(); const bool deform_mesh = (config->GetnMarker_Deform_Mesh() > 0); + const bool multizone = config->GetMultizone_Problem(); su2double Solution[MAXNVAR] = {0.0}; @@ -371,7 +372,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = nodes->GetSolution(iPoint,iVar); - if (dynamic) { + if (dynamic && !multizone) { for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } @@ -386,7 +387,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ } } - if (config->GetMultizone_Problem()) + if (multizone) direct_solver->GetNodes()->SetAdjointSolution_LocalIndex(iPoint,Solution); else direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index fa6673e00ce..ce0dc2fff6f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -475,8 +475,10 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST || config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); + const bool multizone = config->GetMultizone_Problem(); - su2double Solution[MAXNVAR] = {0.0}; /*!< \brief Local container to manipulate the adjoint solution. */ + /*--- Local container to manipulate the adjoint solution. ---*/ + su2double Solution[MAXNVAR] = {0.0}; SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { @@ -487,20 +489,18 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { } /*--- Add dual time contributions to the adjoint solution. Two terms stored for DT-2nd-order. ---*/ - if (dual_time) { + if (dual_time && !multizone) { for (auto iVar = 0u; iVar < nVar; iVar++) { Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } } /*--- Set the adjoint values of the primal solution. ---*/ - if(config->GetMultizone_Problem()) { + if (multizone) direct_solver->GetNodes()->SetAdjointSolution_LocalIndex(iPoint,Solution); - } - else { + else direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); - } - } // for iPoint + } END_SU2_OMP_FOR } diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index 315d6318e87..bf048fea187 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -44,3 +44,8 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u for (unsigned long iVar = 0; iVar < nVar; ++iVar) Solution(iPoint,iVar) = sol[iVar]; } + +void CDiscAdjVariable::Set_DualTimeDer_To_External() { + assert(External.size() == DualTime_Derivative.size()); + parallelCopy(External.size(), DualTime_Derivative.data(), External.data()); +} diff --git a/SU2_CFD/src/variables/CFEAVariable.cpp b/SU2_CFD/src/variables/CFEAVariable.cpp index 27c9c405dee..abe6e408ba9 100644 --- a/SU2_CFD/src/variables/CFEAVariable.cpp +++ b/SU2_CFD/src/variables/CFEAVariable.cpp @@ -31,8 +31,19 @@ CFEAVariable::CFEAVariable(const su2double *val_fea, unsigned long npoint, unsig unsigned long nvar, CConfig *config) : CVariable(npoint, ndim, config->GetTime_Domain()? 3*nvar : nvar, config) { - /*--- In time domain CVariable::nVar is mult. by 3 ^^^ (for vel. and accel.) and the original value then restored. ---*/ + /*--- In time domain CVariable::nVar is mult. by 3 ^^^ (for vel. and accel.) + * and the original value then restored (below). ---*/ nVar = nvar; + /*--- This simplifies the discrete adjoint of this solver, as it allows an abstract + * treatment of the "state" (disp. vel. accel.) whose details are only important + * for the primal solver. In time domain the primal "believes" it has nVar variables, + * which it uses for linear solvers, and then handles velocity and acceleration + * explicitly (for time integration). Whereas the discrete adjoint "thinks" the + * primal solution has 3*nVar variables. This is a little different from simply + * giving names to parts of the solution, it requires the methods of CVariable that + * deal with adjoints to deduce "nVar" from the container, rather than relying on + * the nVar member (which is manipulated above, so that CVariable::SetSolution, etc. + * still work as expected for the primal solver). ---*/ const bool dynamic_analysis = config->GetTime_Domain(); const bool body_forces = config->GetDeadLoad(); From ee29c33fe7ebd593ecfd1132d2a1cd26ad5714a3 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sat, 8 May 2021 12:48:25 +0100 Subject: [PATCH 060/192] temporarily revert dualtime derivative changes to external --- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 18 +++++++++++------- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 6 +++--- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 6cf2cdd8cb0..f6050f6da53 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -164,13 +164,17 @@ void CDiscAdjMultizoneDriver::StartSolver() { for (auto& mat : vecOfMat) mat = 0.0; - /*--- Init external with dual time derivative. ---*/ - Set_DualTimeDer_To_External(); - -// // PG: Why this? -// for (iZone = 0; iZone < nZone; iZone++) { -// Set_Solution_To_BGSSolution_k(iZone); -// } + /*--- Reset external and solution ---*/ + /// TODO: Init with dual time derivative instead. + for (iZone = 0; iZone < nZone; iZone++) { + for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { + auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; + if (solver && solver->GetAdjoint()) solver->GetNodes()->SetExternalZero(); + } + Set_Solution_To_BGSSolution_k(iZone); + } + // /*--- Init external with dual time derivative. ---*/ + // Set_DualTimeDer_To_External(); } /*--- We directly start the discrete adjoint computation. ---*/ diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 749fa322644..85f7199b5af 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -372,7 +372,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = nodes->GetSolution(iPoint,iVar); - if (dynamic && !multizone) { + if (dynamic) { for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } @@ -451,8 +451,8 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo ofstream myfile2_res; switch (config->GetDV_FEA()) { - case YOUNG_MODULUS: - myfile2_res.open("grad_young.opt"); + case YOUNG_MODULUS: case DENSITY_VAL: + myfile2_res.open("grad_dv.opt"); myfile2_res << "INDEX" << "\t" << "GRAD" << endl; diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index ce0dc2fff6f..1151adf7a7d 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -489,7 +489,7 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { } /*--- Add dual time contributions to the adjoint solution. Two terms stored for DT-2nd-order. ---*/ - if (dual_time && !multizone) { + if (dual_time) { for (auto iVar = 0u; iVar < nVar; iVar++) { Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } From a0a68adb17fabf29b932c74d73652c28ce02f161 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 May 2021 14:41:12 +0100 Subject: [PATCH 061/192] fix potential issue when registering mesh coordinates --- SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp | 13 ++++++------- SU2_CFD/src/variables/CMeshVariable.cpp | 2 -- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp index cc1a57b6684..0c81be0c379 100644 --- a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp @@ -94,17 +94,16 @@ void CDiscAdjMeshSolver::SetRecording(CGeometry* geometry, CConfig *config){ } END_SU2_OMP_FOR - /*--- Set indices to zero ---*/ - - RegisterVariables(geometry, config, true); - } void CDiscAdjMeshSolver::RegisterSolution(CGeometry *geometry, CConfig *config){ - /*--- Register reference mesh coordinates ---*/ - direct_solver->GetNodes()->Register_MeshCoord(); - + SU2_OMP_MASTER { + /*--- Register reference mesh coordinates ---*/ + direct_solver->GetNodes()->Register_MeshCoord(); + } + END_SU2_OMP_MASTER + SU2_OMP_BARRIER } void CDiscAdjMeshSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset){ diff --git a/SU2_CFD/src/variables/CMeshVariable.cpp b/SU2_CFD/src/variables/CMeshVariable.cpp index ea3a86a1513..95aa08ab1aa 100644 --- a/SU2_CFD/src/variables/CMeshVariable.cpp +++ b/SU2_CFD/src/variables/CMeshVariable.cpp @@ -49,9 +49,7 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig * } void CMeshVariable::Register_MeshCoord() { - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) for (unsigned long iDim = 0; iDim < nDim; iDim++) AD::RegisterInput(Mesh_Coord(iPoint,iDim)); - END_SU2_OMP_FOR } From 7f07000f05bf01635197b366b81fa5a230eaa953 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 May 2021 17:36:52 +0100 Subject: [PATCH 062/192] dual time in external, now without breaking it --- .../drivers/CDiscAdjMultizoneDriver.hpp | 8 +- .../include/variables/CDiscAdjVariable.hpp | 2 +- SU2_CFD/include/variables/CVariable.hpp | 2 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 172 ++++++++---------- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 2 +- SU2_CFD/src/variables/CDiscAdjVariable.cpp | 2 +- 7 files changed, 90 insertions(+), 100 deletions(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index fdbeb839c5a..e919dd66ffa 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -98,6 +98,7 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { COutput** direct_output; /*!< \brief Array of pointers to the direct outputs. */ vector direct_nInst; /*!< \brief Total number of instances in the direct problem. */ vector nInnerIter; /*!< \brief Number of inner iterations for each zone. */ + unsigned long wrt_sol_freq = 99999; /*!< \brief File output frequency. */ su2vector Has_Deformation; /*!< \brief True if iZone has mesh deformation (used for lazy evaluation of TRANSFER tape section). */ @@ -138,6 +139,11 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { protected: + /*! + * \brief Preprocess the multizone iteration + */ + void Preprocess(unsigned long TimeIter) override; + /*! * \brief [Overload] Run an discrete adjoint update of all solvers within multiple zones. */ @@ -231,7 +237,7 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { /*! * \brief Puts dual time derivative vector to External. */ - void Set_DualTimeDer_To_External(); + void Set_External_To_DualTimeDer(); /*! * \brief Add External_Old vector to Solution. diff --git a/SU2_CFD/include/variables/CDiscAdjVariable.hpp b/SU2_CFD/include/variables/CDiscAdjVariable.hpp index 7d136ffa0b8..51a9a9a2812 100644 --- a/SU2_CFD/include/variables/CDiscAdjVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjVariable.hpp @@ -120,6 +120,6 @@ class CDiscAdjVariable : public CVariable { /*! * \brief Set Dual-time derivative contributions to the external. */ - void Set_DualTimeDer_To_External() final; + void Set_External_To_DualTimeDer() final; }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 98b3f32d305..db37de80848 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -372,7 +372,7 @@ class CVariable { /*! * \brief Set Dual-time derivative contributions to the external. */ - inline virtual void Set_DualTimeDer_To_External() { SetExternalZero(); } + inline virtual void Set_External_To_DualTimeDer() { SetExternalZero(); } /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index f6050f6da53..53acd84f1b3 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -125,9 +125,42 @@ CDiscAdjMultizoneDriver::~CDiscAdjMultizoneDriver(){ } +void CDiscAdjMultizoneDriver::Preprocess(unsigned long TimeIter) { + + const bool time_domain = driver_config->GetTime_Domain(); + + for (iZone = 0; iZone < nZone; iZone++) { + /*--- Set current time iteration ---*/ + config_container[iZone]->SetTimeIter(TimeIter); + + if (time_domain) + config_container[iZone]->SetPhysicalTime(static_cast(TimeIter)*config_container[iZone]->GetDelta_UnstTimeND()); + else + config_container[iZone]->SetPhysicalTime(0.0); + + /*--- Preprocess the iteration of each zone. ---*/ + + iteration_container[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, surface_movement, + grid_movement, FFDBox, iZone, INST_0); + } + + if (TimeIter) { + /*--- Reset cross-terms before new time iterations. ---*/ + for (auto& matOfMat : Cross_Terms) + for (auto& vecOfMat : matOfMat) + for (auto& mat : vecOfMat) + mat = 0.0; + + /*--- Initialize external with dynamic contributions. ---*/ + Set_External_To_DualTimeDer(); + } + +} + void CDiscAdjMultizoneDriver::StartSolver() { - bool time_domain = driver_config->GetTime_Domain(); + const bool time_domain = driver_config->GetTime_Domain(); /*--- Main external loop of the solver. Runs for the number of time steps required. ---*/ @@ -140,49 +173,48 @@ void CDiscAdjMultizoneDriver::StartSolver() { cout << "The simulation will run for " << driver_config->GetnTime_Iter() << " time steps." << endl; } - /*--- Size and initialize the matrix of cross-terms. ---*/ + /*--- General setup. ---*/ - InitializeCrossTerms(); + for (iZone = 0; iZone < nZone; iZone++) { + wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); - while (TimeIter < driver_config->GetnTime_Iter()) { + /*--- Set BGS_Solution_k to Solution, this is needed to restart + * correctly as the first OF gradient will overwrite the solution. ---*/ - for (iZone = 0; iZone < nZone; iZone++) { + Set_BGSSolution_k_To_Solution(iZone); - /*--- Set current time iteration ---*/ - config_container[iZone]->SetTimeIter(TimeIter); + /*--- Prepare Krylov or quasi-Newton methods. ---*/ - if (time_domain) - config_container[iZone]->SetPhysicalTime(static_cast(TimeIter)*config_container[iZone]->GetDelta_UnstTimeND()); - else - config_container[iZone]->SetPhysicalTime(0.0); - } + const auto nPoint = geometry_container[iZone][INST_0][MESH_0]->GetnPoint(); + const auto nPointDomain = geometry_container[iZone][INST_0][MESH_0]->GetnPointDomain(); + const auto nVar = GetTotalNumberOfVariables(iZone, true); - if (TimeIter) { - /*--- Reset cross-terms before new time iterations. ---*/ - for (auto& matOfMat : Cross_Terms) - for (auto& vecOfMat : matOfMat) - for (auto& mat : vecOfMat) - mat = 0.0; - - /*--- Reset external and solution ---*/ - /// TODO: Init with dual time derivative instead. - for (iZone = 0; iZone < nZone; iZone++) { - for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { - auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; - if (solver && solver->GetAdjoint()) solver->GetNodes()->SetExternalZero(); - } - Set_Solution_To_BGSSolution_k(iZone); - } - // /*--- Init external with dual time derivative. ---*/ - // Set_DualTimeDer_To_External(); + if (config_container[iZone]->GetNewtonKrylov() && + config_container[iZone]->GetnQuasiNewtonSamples() >= KrylovMinIters) { + AdjRHS[iZone].Initialize(nPoint, nPointDomain, nVar, nullptr); + AdjSol[iZone].Initialize(nPoint, nPointDomain, nVar, nullptr); + LinSolver[iZone].SetToleranceType(LinearToleranceType::RELATIVE); } + else if (config_container[iZone]->GetnQuasiNewtonSamples() > 1) { + FixPtCorrector[iZone].resize(config_container[iZone]->GetnQuasiNewtonSamples(), nPoint, nVar, nPointDomain); + } + } + + /*--- Size and initialize the matrix of cross-terms. ---*/ - /*--- We directly start the discrete adjoint computation. ---*/ + InitializeCrossTerms(); + + /*--- Run time iterations. ---*/ + + while (TimeIter < driver_config->GetnTime_Iter()) { + + Preprocess(TimeIter); Run(); TimeIter++; } + } bool CDiscAdjMultizoneDriver::Iterate(unsigned short iZone, unsigned long iInnerIter, bool KrylovMode) { @@ -275,40 +307,9 @@ void CDiscAdjMultizoneDriver::KrylovInnerIters(unsigned short iZone) { void CDiscAdjMultizoneDriver::Run() { - unsigned long wrt_sol_freq = 99999; const unsigned long nOuterIter = driver_config->GetnOuter_Iter(); const bool time_domain = driver_config->GetTime_Domain(); - for (iZone = 0; iZone < nZone; iZone++) { - - wrt_sol_freq = min(wrt_sol_freq, config_container[iZone]->GetVolume_Wrt_Freq()); - - iteration_container[iZone][INST_0]->Preprocess(output_container[iZone], integration_container, geometry_container, - solver_container, numerics_container, config_container, surface_movement, - grid_movement, FFDBox, iZone, INST_0); - - /*--- Set BGS_Solution_k to Solution, this is needed to restart - * correctly as the OF gradient will overwrite the solution. ---*/ - - Set_BGSSolution_k_To_Solution(iZone); - - /*--- Prepare Krylov or quasi-Newton methods. ---*/ - - const auto nPoint = geometry_container[iZone][INST_0][MESH_0]->GetnPoint(); - const auto nPointDomain = geometry_container[iZone][INST_0][MESH_0]->GetnPointDomain(); - const auto nVar = GetTotalNumberOfVariables(iZone, true); - - if (config_container[iZone]->GetNewtonKrylov() && - config_container[iZone]->GetnQuasiNewtonSamples() >= KrylovMinIters) { - AdjRHS[iZone].Initialize(nPoint, nPointDomain, nVar, nullptr); - AdjSol[iZone].Initialize(nPoint, nPointDomain, nVar, nullptr); - LinSolver[iZone].SetToleranceType(LinearToleranceType::RELATIVE); - } - else if (config_container[iZone]->GetnQuasiNewtonSamples() > 1) { - FixPtCorrector[iZone].resize(config_container[iZone]->GetnQuasiNewtonSamples(), nPoint, nVar, nPointDomain); - } - } - /*--- If the gradient of the objective function is 0 so are the adjoint variables. * Unless in unsteady problems where there are other contributions to the RHS. ---*/ @@ -535,37 +536,20 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool Sto auto solvers = solver_container[iZone][INST_0][MESH_0]; auto geometry = geometry_container[iZone][INST_0][MESH_0]; - switch (config_container[iZone]->GetKind_Solver()) { - - case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_RANS: - case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES: case DISC_ADJ_INC_RANS: - - if(Has_Deformation(iZone)) { - solvers[ADJMESH_SOL]->SetSensitivity(geometry, config, solvers[ADJFLOW_SOL]); - } else { - solvers[ADJFLOW_SOL]->SetSensitivity(geometry, config); - } - break; - - case DISC_ADJ_HEAT: - - if(Has_Deformation(iZone)) { - solvers[ADJMESH_SOL]->SetSensitivity(geometry, config, solvers[ADJHEAT_SOL]); - } else { - solvers[ADJHEAT_SOL]->SetSensitivity(geometry, config); - } - break; - - case DISC_ADJ_FEM: - - solvers[ADJFEA_SOL]->SetSensitivity(geometry, config); - break; - - default: - if (rank == MASTER_NODE) - cout << "WARNING: Sensitivities not set for one of the specified discrete adjoint solvers!" << endl; - break; + int IDX_SOL = -1; + if (config->GetFluidProblem()) IDX_SOL = ADJFLOW_SOL; + else if (config->GetHeatProblem()) IDX_SOL = ADJHEAT_SOL; + else if (config->GetStructuralProblem()) IDX_SOL = ADJFEA_SOL; + else { + if (rank == MASTER_NODE) + cout << "WARNING: Sensitivities not set for one of the specified discrete adjoint solvers!" << endl; + continue; } + + if (Has_Deformation(iZone)) + solvers[ADJMESH_SOL]->SetSensitivity(geometry, config, solvers[IDX_SOL]); + else + solvers[IDX_SOL]->SetSensitivity(geometry, config); } /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ @@ -983,13 +967,13 @@ void CDiscAdjMultizoneDriver::Add_Solution_To_External(unsigned short iZone) { } } -void CDiscAdjMultizoneDriver::Set_DualTimeDer_To_External() { +void CDiscAdjMultizoneDriver::Set_External_To_DualTimeDer() { for (unsigned short iZone = 0; iZone < nZone; iZone++) { for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { auto solver = solver_container[iZone][INST_0][MESH_0][iSol]; if (solver && solver->GetAdjoint()) - solver->GetNodes()->Set_DualTimeDer_To_External(); + solver->GetNodes()->Set_External_To_DualTimeDer(); } } } diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 85f7199b5af..11148489c3b 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -372,7 +372,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] = nodes->GetSolution(iPoint,iVar); - if (dynamic) { + if (dynamic && !multizone) { for (iVar = 0; iVar < nVar; iVar++) Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 1151adf7a7d..ce0dc2fff6f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -489,7 +489,7 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { } /*--- Add dual time contributions to the adjoint solution. Two terms stored for DT-2nd-order. ---*/ - if (dual_time) { + if (dual_time && !multizone) { for (auto iVar = 0u; iVar < nVar; iVar++) { Solution[iVar] += nodes->GetDual_Time_Derivative(iPoint,iVar); } diff --git a/SU2_CFD/src/variables/CDiscAdjVariable.cpp b/SU2_CFD/src/variables/CDiscAdjVariable.cpp index bf048fea187..d6e697f3005 100644 --- a/SU2_CFD/src/variables/CDiscAdjVariable.cpp +++ b/SU2_CFD/src/variables/CDiscAdjVariable.cpp @@ -45,7 +45,7 @@ CDiscAdjVariable::CDiscAdjVariable(const su2double* sol, unsigned long npoint, u Solution(iPoint,iVar) = sol[iVar]; } -void CDiscAdjVariable::Set_DualTimeDer_To_External() { +void CDiscAdjVariable::Set_External_To_DualTimeDer() { assert(External.size() == DualTime_Derivative.size()); parallelCopy(External.size(), DualTime_Derivative.data(), External.data()); } From 5eafa5a59e147b512acaa22a2ec64218511b8bbc Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 8 May 2021 22:49:22 +0100 Subject: [PATCH 063/192] special "iterate" for discrete adjoint iterations --- .../include/iteration/CAdjFluidIteration.hpp | 2 +- .../iteration/CDiscAdjFEAIteration.hpp | 32 ++++++++----------- .../iteration/CDiscAdjFluidIteration.hpp | 14 ++------ .../iteration/CDiscAdjHeatIteration.hpp | 22 ++++--------- SU2_CFD/include/iteration/CFEAIteration.hpp | 3 +- .../include/iteration/CFEMFluidIteration.hpp | 3 +- SU2_CFD/include/iteration/CFluidIteration.hpp | 3 +- SU2_CFD/include/iteration/CHeatIteration.hpp | 3 +- SU2_CFD/include/iteration/CIteration.hpp | 15 +++++++-- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 17 ++++------ .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 7 ++-- SU2_CFD/src/drivers/CDriver.cpp | 7 ++-- SU2_CFD/src/iteration/CAdjFluidIteration.cpp | 2 +- .../src/iteration/CDiscAdjFEAIteration.cpp | 9 ++---- .../src/iteration/CDiscAdjFluidIteration.cpp | 6 ++-- .../src/iteration/CDiscAdjHeatIteration.cpp | 6 ++-- SU2_CFD/src/iteration/CFEAIteration.cpp | 4 +-- SU2_CFD/src/iteration/CFEMFluidIteration.cpp | 2 +- SU2_CFD/src/iteration/CFluidIteration.cpp | 4 +-- SU2_CFD/src/iteration/CHeatIteration.cpp | 2 +- 20 files changed, 69 insertions(+), 94 deletions(-) diff --git a/SU2_CFD/include/iteration/CAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CAdjFluidIteration.hpp index 9690ab40b9e..9513449abe0 100644 --- a/SU2_CFD/include/iteration/CAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CAdjFluidIteration.hpp @@ -67,7 +67,7 @@ class CAdjFluidIteration : public CFluidIteration { void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + unsigned short val_iInst) override; /*! * \brief Updates the containers for the adjoint fluid system. diff --git a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp index f88c3417c5a..0170ed57496 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFEAIteration.hpp @@ -86,27 +86,19 @@ class CDiscAdjFEAIteration final : public CIteration { unsigned short val_iInst) override; /*! - * \brief Perform a single iteration of the adjoint mean flow system. - * \param[in] output - Pointer to the COutput class. - * \param[in] integration - Container vector with all the integration methods. + * \brief Perform a single iteration of the adjoint FEA problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method (the way in which the equations are solved). * \param[in] config - Definition of the particular problem. - * \param[in] surface_movement - Surface movement classes of the problem. - * \param[in] grid_movement - Volume grid movement classes of the problem. - * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance. * \param[in] CrossTerm - Boolean for CrossTerm. */ - void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, - CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, - CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + void IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) override; /*! - * \brief Monitors the convergence and other metrics for the discrete adjoint mean flow system. + * \brief Monitors the convergence and other metrics for the discrete adjoint FEA problem. * \param[in] output - Pointer to the COutput class. * \param[in] integration - Container vector with all the integration methods. * \param[in] geometry - Geometrical definition of the problem. @@ -125,12 +117,16 @@ class CDiscAdjFEAIteration final : public CIteration { unsigned short val_iInst) override; /*! - * \brief Postprocesses the discrete adjoint mean flow system before heading to another physics system or the next - * iteration. \param[in] output - Pointer to the COutput class. \param[in] integration - Container vector with all the - * integration methods. \param[in] geometry - Geometrical definition of the problem. \param[in] solver - Container - * vector with all the solutions. \param[in] numerics - Description of the numerical method (the way in which the - * equations are solved). \param[in] config - Definition of the particular problem. \param[in] surface_movement - - * Surface movement classes of the problem. \param[in] grid_movement - Volume grid movement classes of the problem. + * \brief Postprocesses the discrete adjoint FEA problem before heading to another physics system or the next + * iteration. + * \param[in] output - Pointer to the COutput class. + * \param[in] integration - Container vector with all the integration methods. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Container vector with all the solutions. + * \param[in] numerics - Description of the numerical method (the way in which the equations are solved). + * \param[in] config - Definition of the particular problem. + * \param[in] surface_movement - Surface movement classes of the problem. + * \param[in] grid_movement - Volume grid movement classes of the problem. * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance. diff --git a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp index b8eacda6cbe..1e9c0666ac2 100644 --- a/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjFluidIteration.hpp @@ -83,23 +83,15 @@ class CDiscAdjFluidIteration final : public CIteration { /*! * \brief Perform a single iteration of the adjoint fluid system. - * \param[in] output - Pointer to the COutput class. - * \param[in] integration - Container vector with all the integration methods. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method (the way in which the equations are solved). * \param[in] config - Definition of the particular problem. - * \param[in] surface_movement - Surface movement classes of the problem. - * \param[in] grid_movement - Volume grid movement classes of the problem. - * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. - * \param[in] val_iInst - Index of the instance + * \param[in] val_iInst - Index of the instance. * \param[in] CrossTerm - Boolean for CrossTerm. */ - void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, - CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, - CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + void IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) override; /*! * \brief Updates the containers for the discrete adjoint fluid system. diff --git a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp index a9667c93c1c..02268b19a4e 100644 --- a/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp +++ b/SU2_CFD/include/iteration/CDiscAdjHeatIteration.hpp @@ -57,7 +57,7 @@ class CDiscAdjHeatIteration final : public CIteration { explicit CDiscAdjHeatIteration(const CConfig *config) : CIteration(config) {} /*! - * \brief Perform a single iteration of the adjoint fluid system. + * \brief Perform a single iteration of the adjoint heat problem. * \param[in] output - Pointer to the COutput class. * \param[in] integration - Container vector with all the integration methods. * \param[in] geometry - Geometrical definition of the problem. @@ -76,27 +76,19 @@ class CDiscAdjHeatIteration final : public CIteration { unsigned short val_iInst) override; /*! - * \brief Perform a single iteration of the adjoint fluid system. - * \param[in] output - Pointer to the COutput class. - * \param[in] integration - Container vector with all the integration methods. + * \brief Perform a single iteration of the adjoint heat problem. * \param[in] geometry - Geometrical definition of the problem. * \param[in] solver - Container vector with all the solutions. - * \param[in] numerics - Description of the numerical method (the way in which the equations are solved). * \param[in] config - Definition of the particular problem. - * \param[in] surface_movement - Surface movement classes of the problem. - * \param[in] grid_movement - Volume grid movement classes of the problem. - * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. - * \param[in] val_iInst - Index of the instance layer. + * \param[in] val_iInst - Index of the instance. * \param[in] CrossTerm - Boolean for CrossTerm. */ - void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, - CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, - CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + void IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) override; /*! - * \brief Perform a single iteration of the adjoint fluid system. + * \brief Perform a single iteration of the adjoint heat problem. * \param[in] output - Pointer to the COutput class. * \param[in] integration - Container vector with all the integration methods. * \param[in] geometry - Geometrical definition of the problem. @@ -115,7 +107,7 @@ class CDiscAdjHeatIteration final : public CIteration { unsigned short val_iInst) override; /*! - * \brief Monitors the convergence and other metrics for the discrete adjoint fluid system. + * \brief Monitors the convergence and other metrics for the discrete adjoint heat problem. */ bool Monitor(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, diff --git a/SU2_CFD/include/iteration/CFEAIteration.hpp b/SU2_CFD/include/iteration/CFEAIteration.hpp index 5cc760c7db4..da1add90248 100644 --- a/SU2_CFD/include/iteration/CFEAIteration.hpp +++ b/SU2_CFD/include/iteration/CFEAIteration.hpp @@ -58,12 +58,11 @@ class CFEAIteration : public CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. - * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + unsigned short val_iInst) override; /*! * \brief Iterate the structural system for a number of Inner_Iter iterations. diff --git a/SU2_CFD/include/iteration/CFEMFluidIteration.hpp b/SU2_CFD/include/iteration/CFEMFluidIteration.hpp index 327c8696b37..3a111035791 100644 --- a/SU2_CFD/include/iteration/CFEMFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFEMFluidIteration.hpp @@ -73,12 +73,11 @@ class CFEMFluidIteration : public CFluidIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. - * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + unsigned short val_iInst) override; /*! * \brief Updates the containers for the finite element flow system. diff --git a/SU2_CFD/include/iteration/CFluidIteration.hpp b/SU2_CFD/include/iteration/CFluidIteration.hpp index bfd9f0be9d0..72979a1804f 100644 --- a/SU2_CFD/include/iteration/CFluidIteration.hpp +++ b/SU2_CFD/include/iteration/CFluidIteration.hpp @@ -65,12 +65,11 @@ class CFluidIteration : public CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. - * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + unsigned short val_iInst) override; /*! * \brief Iterate the fluid system for a number of Inner_Iter iterations. diff --git a/SU2_CFD/include/iteration/CHeatIteration.hpp b/SU2_CFD/include/iteration/CHeatIteration.hpp index 320016b17f9..9908d439c8e 100644 --- a/SU2_CFD/include/iteration/CHeatIteration.hpp +++ b/SU2_CFD/include/iteration/CHeatIteration.hpp @@ -56,12 +56,11 @@ class CHeatIteration : public CFluidIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instance layer. - * \param[in] CrossTerm - Boolean for CrossTerm. */ void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) override; + unsigned short val_iInst) override; /*! * \brief Updates the containers for the heat system. diff --git a/SU2_CFD/include/iteration/CIteration.hpp b/SU2_CFD/include/iteration/CIteration.hpp index 18bbb14ab0c..7ccdffc45d4 100644 --- a/SU2_CFD/include/iteration/CIteration.hpp +++ b/SU2_CFD/include/iteration/CIteration.hpp @@ -132,12 +132,23 @@ class CIteration { * \param[in] FFDBox - FFD FFDBoxes of the problem. * \param[in] val_iZone - Index of the zone. * \param[in] val_iInst - Index of the instantiation. - * \param[in] CrossTerm - Boolean for CrossTerm. */ virtual void Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm){} + unsigned short val_iInst){} + + /*! + * \brief A virtual member. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + * \param[in] val_iZone - Index of the zone. + * \param[in] val_iInst - Index of the instantiation. + * \param[in] CrossTerm - Boolean for CrossTerm. + */ + virtual void IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) {} /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index 53acd84f1b3..d18a33b2333 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -230,9 +230,8 @@ bool CDiscAdjMultizoneDriver::Iterate(unsigned short iZone, unsigned long iInner /*--- Extracting adjoints for solvers in iZone w.r.t. to outputs in iZone (diagonal part). ---*/ - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, - solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + iteration_container[iZone][INST_0]->IterateDiscAdj(geometry_container, solver_container, + config_container, iZone, INST_0, false); /*--- Use QN driver to improve the solution. ---*/ @@ -419,9 +418,8 @@ void CDiscAdjMultizoneDriver::Run() { * that is, for the cases iZone != jZone we are evaluating cross derivatives between zones. ---*/ config_container[jZone]->SetInnerIter(0); - iteration_container[jZone][INST_0]->Iterate(output_container[jZone], integration_container, geometry_container, - solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, jZone, INST_0, true); + iteration_container[jZone][INST_0]->IterateDiscAdj(geometry_container, solver_container, + config_container, jZone, INST_0, true); /*--- Extract the cross-term performing a relaxed update of it and of the sum (External) for jZone. ---*/ @@ -480,9 +478,8 @@ bool CDiscAdjMultizoneDriver::EvaluateObjectiveFunctionGradient() { for (iZone = 0; iZone < nZone; iZone++) { - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, - solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + iteration_container[iZone][INST_0]->IterateDiscAdj(geometry_container, solver_container, + config_container, iZone, INST_0, false); Add_Solution_To_External(iZone); for (unsigned short iSol=0; iSol < MAX_SOLS; iSol++) { @@ -695,7 +692,7 @@ void CDiscAdjMultizoneDriver::DirectIteration(unsigned short iZone, RECORDING ki /*--- Iterate the zone as a block a single time ---*/ direct_iteration[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + surface_movement, grid_movement, FFDBox, iZone, INST_0); /*--- Print residuals in the first iteration ---*/ diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index a146e9d3dbf..885d155fb2b 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -178,9 +178,8 @@ void CDiscAdjSinglezoneDriver::Run() { /*--- Extract the computed adjoint values of the input variables and store them for the next iteration. ---*/ - iteration->Iterate(output_container[ZONE_0], integration_container, geometry_container, - solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, ZONE_0, INST_0, false); + iteration->IterateDiscAdj(geometry_container, solver_container, + config_container, ZONE_0, INST_0, false); /*--- Monitor the pseudo-time ---*/ @@ -438,7 +437,7 @@ void CDiscAdjSinglezoneDriver::DirectRun(RECORDING kind_recording){ /*--- Iterate the direct solver ---*/ - direct_iteration->Iterate(direct_output, integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0, false); + direct_iteration->Iterate(direct_output, integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); /*--- Postprocess the direct solver ---*/ diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index cb460c84406..e78890f1fd6 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -2999,7 +2999,8 @@ void CFluidDriver::Run() { for (iZone = 0; iZone < nZone; iZone++) { config_container[iZone]->SetInnerIter(IntIter); - iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, + config_container, surface_movement, grid_movement, FFDBox, iZone, INST_0); } /*--- Check convergence in each zone --*/ @@ -3174,7 +3175,7 @@ void CTurbomachineryDriver::Run() { for (iZone = 0; iZone < nZone; iZone++) { iteration_container[iZone][INST_0]->Iterate(output_container[iZone], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, iZone, INST_0, false); + surface_movement, grid_movement, FFDBox, iZone, INST_0); } for (iZone = 0; iZone < nZone; iZone++) { @@ -3417,7 +3418,7 @@ void CHBDriver::Run() { for (iInst = 0; iInst < nInstHB; iInst++) iteration_container[ZONE_0][iInst]->Iterate(output_container[ZONE_0], integration_container, geometry_container, solver_container, numerics_container, config_container, - surface_movement, grid_movement, FFDBox, ZONE_0, iInst, false); + surface_movement, grid_movement, FFDBox, ZONE_0, iInst); /*--- Update the convergence history file (serial and parallel computations). ---*/ diff --git a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp index 964f6884c0f..37c2a8779c7 100644 --- a/SU2_CFD/src/iteration/CAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CAdjFluidIteration.cpp @@ -133,7 +133,7 @@ void CAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integratio void CAdjFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { switch (config[val_iZone]->GetKind_Solver()) { case ADJ_EULER: config[val_iZone]->SetGlobalParam(ADJ_EULER, RUNTIME_ADJFLOW_SYS); diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index 7e30516309d..de4b30d7ee7 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -139,10 +139,8 @@ void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry**** geometry, CSolver* } } -void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, - CSolver***** solver, CNumerics****** numerics, CConfig** config, - CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { +void CDiscAdjFEAIteration::IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ @@ -151,9 +149,6 @@ void CDiscAdjFEAIteration::Iterate(COutput* output, CIntegration**** integration solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Variables(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone]); - if (config[val_iZone]->GetTime_Domain()) { - integration[val_iZone][val_iInst][ADJFEA_SOL]->SetConvergence(false); - } } void CDiscAdjFEAIteration::SetRecording(CSolver***** solver, CGeometry**** geometry, CConfig** config, diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 0f20cf2d6c5..9016d1e03fe 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -367,10 +367,8 @@ void CDiscAdjFluidIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolv } } -void CDiscAdjFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, - CSolver***** solver, CNumerics****** numerics, CConfig** config, - CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst, bool CrossTerm) { +void CDiscAdjFluidIteration::IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short iZone, unsigned short iInst, bool CrossTerm) { SU2_OMP_PARALLEL_(if(solver[iZone][iInst][MESH_0][ADJFLOW_SOL]->GetHasHybridParallel())) { diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 89147bd70eb..987ca9a48a8 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -160,10 +160,8 @@ void CDiscAdjHeatIteration::LoadUnsteady_Solution(CGeometry**** geometry, CSolve } } -void CDiscAdjHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, - CSolver***** solver, CNumerics****** numerics, CConfig** config, - CSurfaceMovement** surface_movement, CVolumetricMovement*** volume_grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { +void CDiscAdjHeatIteration::IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, + unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { solver[val_iZone][val_iInst][MESH_0][ADJHEAT_SOL]->ExtractAdjoint_Solution(geometry[val_iZone][val_iInst][MESH_0], config[val_iZone], CrossTerm); diff --git a/SU2_CFD/src/iteration/CFEAIteration.cpp b/SU2_CFD/src/iteration/CFEAIteration.cpp index c57956f0cc6..b73fcafed6a 100644 --- a/SU2_CFD/src/iteration/CFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CFEAIteration.cpp @@ -31,7 +31,7 @@ void CFEAIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) { + unsigned short val_iInst) { bool StopCalc = false; unsigned long IntIter = 0; @@ -267,7 +267,7 @@ void CFEAIteration::Solve(COutput* output, CIntegration**** integration, CGeomet unsigned short val_iInst) { /*------------------ Structural subiteration ----------------------*/ Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, - val_iInst, false); + val_iInst); if (multizone && !config[val_iZone]->GetTime_Domain()) { Output(output, geometry, solver, config, config[val_iZone]->GetOuterIter(), false, val_iZone, val_iInst); diff --git a/SU2_CFD/src/iteration/CFEMFluidIteration.cpp b/SU2_CFD/src/iteration/CFEMFluidIteration.cpp index 7bcd1b5d5aa..c3b21187646 100644 --- a/SU2_CFD/src/iteration/CFEMFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFEMFluidIteration.cpp @@ -44,7 +44,7 @@ void CFEMFluidIteration::Preprocess(COutput* output, CIntegration**** integratio void CFEMFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { /*--- Update global parameters ---*/ if (config[val_iZone]->GetKind_Solver() == FEM_EULER || config[val_iZone]->GetKind_Solver() == DISC_ADJ_FEM_EULER) diff --git a/SU2_CFD/src/iteration/CFluidIteration.cpp b/SU2_CFD/src/iteration/CFluidIteration.cpp index 212dc1d133e..dccc2149752 100644 --- a/SU2_CFD/src/iteration/CFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CFluidIteration.cpp @@ -55,7 +55,7 @@ void CFluidIteration::Preprocess(COutput* output, CIntegration**** integration, void CFluidIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { + CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { unsigned long InnerIter, TimeIter; const bool unsteady = (config[val_iZone]->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || @@ -286,7 +286,7 @@ void CFluidIteration::Solve(COutput* output, CIntegration**** integration, CGeom /*--- Run a single iteration of the solver ---*/ Iterate(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, val_iZone, - INST_0, false); + INST_0); /*--- Monitor the pseudo-time ---*/ StopCalc = Monitor(output, integration, geometry, solver, numerics, config, surface_movement, grid_movement, FFDBox, diff --git a/SU2_CFD/src/iteration/CHeatIteration.cpp b/SU2_CFD/src/iteration/CHeatIteration.cpp index 9a3cbeeac5e..0d58a423e11 100644 --- a/SU2_CFD/src/iteration/CHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CHeatIteration.cpp @@ -31,7 +31,7 @@ void CHeatIteration::Iterate(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, CFreeFormDefBox*** FFDBox, unsigned short val_iZone, - unsigned short val_iInst, bool CrossTerm) { + unsigned short val_iInst) { /*--- Update global parameters ---*/ config[val_iZone]->SetGlobalParam(HEAT_EQUATION, RUNTIME_HEAT_SYS); From f7f1b967c3e6cec4ca7635eda6862436d139ae60 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 9 May 2021 10:46:37 +0100 Subject: [PATCH 064/192] local indices to allow parallel registration --- Common/include/geometry/CGeometry.hpp | 3 +- Common/include/geometry/dual_grid/CPoint.hpp | 59 ++++------------ Common/src/geometry/CGeometry.cpp | 10 +-- Common/src/geometry/dual_grid/CPoint.cpp | 13 +--- SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp | 19 ++--- SU2_CFD/include/variables/CVariable.hpp | 45 ++---------- .../src/iteration/CDiscAdjFEAIteration.cpp | 2 +- .../src/iteration/CDiscAdjFluidIteration.cpp | 2 +- .../src/iteration/CDiscAdjHeatIteration.cpp | 2 +- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 69 +++++-------------- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 53 +++----------- SU2_CFD/src/variables/CVariable.cpp | 26 +++---- 12 files changed, 71 insertions(+), 232 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index cc8aa2867b2..ad4f6d80e67 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1250,9 +1250,8 @@ class CGeometry { /*! * \brief Register the coordinates of the mesh nodes. - * \param[in] config */ - void RegisterCoordinates(const CConfig *config) const; + void RegisterCoordinates() const; /*! * \brief Update the multi-grid structure and the wall-distance. diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 1ef38f5cd24..83f1b89b7ad 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -811,50 +811,21 @@ class CPoint { } /*! - * \brief Set the adjoint values of the coordinates. - * \param[in] iPoint - Index of the point. - * \param[in] adj_sol - The adjoint values of the coordinates. - */ - inline void SetAdjointCoord(unsigned long iPoint, const su2double *adj_coor) { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - SU2_TYPE::SetDerivative(Coord(iPoint,iDim), SU2_TYPE::GetValue(adj_coor[iDim])); + * \brief Register coordinates of a point. + * \param[in] iPoint - Index of the point. + * \param[in] input - Register as input or output. + */ + inline void RegisterCoordinates(unsigned long iPoint, bool input) { + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + if(input) { + AD::RegisterInput(Coord(iPoint,iDim),false); + AD::SetIndex(AD_InputIndex(iPoint,iDim), Coord(iPoint,iDim)); + } + else { + AD::RegisterOutput(Coord(iPoint,iDim)); + AD::SetIndex(AD_OutputIndex(iPoint,iDim), Coord(iPoint,iDim)); + } + } } - /*! - * \brief Set the adjoint values of the coordinates. - * \param[in] iPoint - Index of the point. - * \param[in] adj_sol - The adjoint values of the coordinates. - */ - inline void SetAdjointCoord_LocalIndex(unsigned long iPoint, const su2double *adj_coor) { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - AD::SetDerivative(AD_OutputIndex(iPoint,iDim), SU2_TYPE::GetValue(adj_coor[iDim])); - } - - /*! - * \brief Get the adjoint values of the coordinates. - * \param[in] iPoint - Index of the point. - * \param[in] adj_sol - The adjoint values of the coordinates. - */ - inline void GetAdjointCoord(unsigned long iPoint, su2double *adj_coor) const { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - adj_coor[iDim] = SU2_TYPE::GetDerivative(Coord(iPoint,iDim)); - } - - /*! - * \brief Get the adjoint values of the coordinates. - * \param[in] iPoint - Index of the point. - * \param[in] adj_sol - The adjoint values of the coordinates. - */ - inline void GetAdjointCoord_LocalIndex(unsigned long iPoint, su2double *adj_coor) const { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - adj_coor[iDim] = AD::GetDerivative(AD_InputIndex(iPoint,iDim)); - } - - /*! - * \brief Set the adjoint vector indices of Coord vector. - * \param[in] iPoint - Index of the point. - * \param[in] input - Save them to the input or output indices vector. - */ - void SetIndex(unsigned long iPoint, bool input); - }; diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index cf708b8a112..d4aab89d4c0 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -2475,18 +2475,12 @@ void CGeometry::ComputeAirfoil_Section(su2double *Plane_P0, su2double *Plane_Nor } -void CGeometry::RegisterCoordinates(const CConfig *config) const { +void CGeometry::RegisterCoordinates() const { const bool input = true; - const bool push_index = config->GetMultizone_Problem()? false : true; SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - for (auto iDim = 0u; iDim < nDim; iDim++) { - AD::RegisterInput(nodes->GetCoord(iPoint)[iDim], push_index); - } - if(!push_index) { - nodes->SetIndex(iPoint, input); - } + nodes->RegisterCoordinates(iPoint, input); } END_SU2_OMP_FOR } diff --git a/Common/src/geometry/dual_grid/CPoint.cpp b/Common/src/geometry/dual_grid/CPoint.cpp index bc568662729..0c5e1714252 100644 --- a/Common/src/geometry/dual_grid/CPoint.cpp +++ b/Common/src/geometry/dual_grid/CPoint.cpp @@ -73,7 +73,7 @@ void CPoint::FullAllocation(unsigned short imesh, const CConfig *config) { } } - if(config->GetAD_Mode() && config->GetMultizone_Problem()) { + if (config->GetDiscrete_Adjoint()) { AD_InputIndex.resize(npoint,nDim) = 0; AD_OutputIndex.resize(npoint,nDim) = 0; } @@ -147,17 +147,6 @@ void CPoint::SetPoints(const vector >& pointsMatrix) { Edge = CCompressedSparsePatternL(Point.outerPtr(), Point.outerPtr()+Point.getOuterSize()+1, long(-1)); } -void CPoint::SetIndex(unsigned long iPoint, bool input) { - for (unsigned long iDim = 0; iDim < nDim; iDim++) { - if(input) { - AD::SetIndex(AD_InputIndex(iPoint,iDim), Coord(iPoint,iDim)); - } - else { - AD::SetIndex(AD_OutputIndex(iPoint,iDim), Coord(iPoint,iDim)); - } - } -} - void CPoint::SetVolume_n() { assert(Volume_n.size() == Volume.size()); parallelCopy(Volume.size(), Volume.data(), Volume_n.data()); diff --git a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp index 613b5a7fb35..e81ac660eb2 100644 --- a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp @@ -49,7 +49,6 @@ class CDiscAdjFEASolver final : public CSolver { unsigned short size = 0; su2double* val = nullptr; /*!< \brief Value of the variable. */ int* AD_Idx = nullptr; /*!< \brief Derivative index in the AD tape. */ - bool localIdx = false; su2double* LocalSens = nullptr; /*!< \brief Local sensitivity (domain). */ su2double* GlobalSens = nullptr; /*!< \brief Global sensitivity (mpi). */ su2double* TotalSens = nullptr; /*!< \brief Total sensitivity (time domain). */ @@ -69,7 +68,6 @@ class CDiscAdjFEASolver final : public CSolver { void clear() { size = 0; - localIdx = false; delete [] val; delete [] AD_Idx; delete [] LocalSens; @@ -77,20 +75,15 @@ class CDiscAdjFEASolver final : public CSolver { delete [] TotalSens; } - void Register(bool push_index) { - for (auto i = 0u; i < size; ++i) AD::RegisterInput(val[i], push_index); - } - - void SetIndex() { - for (auto i = 0u; i < size; ++i) AD::SetIndex(AD_Idx[i], val[i]); - localIdx = true; + void Register() { + for (auto i = 0u; i < size; ++i) { + AD::RegisterInput(val[i], false); + AD::SetIndex(AD_Idx[i], val[i]); + } } void GetDerivative() { - if (localIdx) - for (auto i = 0u; i < size; ++i) LocalSens[i] = AD::GetDerivative(AD_Idx[i]); - else - for (auto i = 0u; i < size; ++i) LocalSens[i] = SU2_TYPE::GetDerivative(val[i]); + for (auto i = 0u; i < size; ++i) LocalSens[i] = AD::GetDerivative(AD_Idx[i]); SU2_MPI::Allreduce(LocalSens, GlobalSens, size, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); } diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index db37de80848..12826d23988 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -2112,80 +2112,43 @@ class CVariable { /*! * \brief Register the variables in the solution array as input/output variable. * \param[in] input - input or output variables. - * \param[in] push_index - boolean whether we want to push the index or save it in a member variable. */ - void RegisterSolution(bool input, bool push_index = true); + void RegisterSolution(bool input); /*! * \brief Register the variables in the solution_time_n array as input/output variable. */ - void RegisterSolution_time_n(bool push_index); + void RegisterSolution_time_n(); /*! * \brief Register the variables in the solution_time_n1 array as input/output variable. */ - void RegisterSolution_time_n1(bool push_index); + void RegisterSolution_time_n1(); /*! * \brief Set the adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ inline void SetAdjointSolution(unsigned long iPoint, const su2double *adj_sol) { - for (unsigned long iVar = 0; iVar < Solution.cols(); iVar++) - SU2_TYPE::SetDerivative(Solution(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); - } - - /*! - * \brief Set the adjoint values of the solution. - * \param[in] adj_sol - The adjoint values of the solution. - */ - inline void SetAdjointSolution_LocalIndex(unsigned long iPoint, const su2double *adj_sol) { for (unsigned long iVar = 0; iVar < AD_OutputIndex.cols(); iVar++) AD::SetDerivative(AD_OutputIndex(iPoint,iVar), SU2_TYPE::GetValue(adj_sol[iVar])); } - /*! - * \brief Get the adjoint values of the solution. - * \param[out] adj_sol - The adjoint values of the solution. - */ - inline void GetAdjointSolution(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < Solution.cols(); iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution(iPoint,iVar)); - } - /*! * \brief Get the adjoint values of the solution. * \param[in] adj_sol - The adjoint values of the solution. */ - inline void GetAdjointSolution_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { + inline void GetAdjointSolution(unsigned long iPoint, su2double *adj_sol) const { for (unsigned long iVar = 0; iVar < AD_InputIndex.cols(); iVar++) adj_sol[iVar] = AD::GetDerivative(AD_InputIndex(iPoint,iVar)); } - /*! - * \brief Get the adjoint values of the solution at time n. - * \param[out] adj_sol - The adjoint values of the solution. - */ inline void GetAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < Solution_time_n.cols(); iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n(iPoint,iVar)); - } - - inline void GetAdjointSolution_time_n_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { for (unsigned long iVar = 0; iVar < AD_Time_n_InputIndex.cols(); iVar++) adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); } - /*! - * \brief Get the adjoint values of the solution at time n-1. - * \param[out] adj_sol - The adjoint values of the solution. - */ inline void GetAdjointSolution_time_n1(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n1(iPoint,iVar)); - } - - inline void GetAdjointSolution_time_n1_LocalIndex(unsigned long iPoint, su2double *adj_sol) const { for (unsigned long iVar = 0; iVar < nVar; iVar++) adj_sol[iVar] = AD::GetDerivative(AD_Time_n1_InputIndex(iPoint,iVar)); } diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index de4b30d7ee7..fdd5a885e17 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -178,7 +178,7 @@ void CDiscAdjFEAIteration::RegisterInput(CSolver***** solver, CGeometry**** geom } /*--- Register mesh coordinates for geometric sensitivities ---*/ - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); } void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 9016d1e03fe..1c3ac43204e 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -456,7 +456,7 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge if (kind_recording == RECORDING::MESH_COORDS) { /*--- Register node coordinates as input ---*/ - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); } if (config[iZone]->GetDeform_Mesh()) { diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index 987ca9a48a8..a60cf7bb23e 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -187,7 +187,7 @@ void CDiscAdjHeatIteration::RegisterInput(CSolver***** solver, CGeometry**** geo else if (kind_recording == RECORDING::MESH_COORDS) { /*--- Register node coordinates as input ---*/ - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(config[iZone]); + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); } else if (kind_recording == RECORDING::MESH_DEFORM) { /*--- Register the variables of the mesh deformation ---*/ diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 11148489c3b..ab8b9fb3b5c 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -164,17 +164,16 @@ void CDiscAdjFEASolver::RegisterSolution(CGeometry *geometry, CConfig *config){ const bool input = true; const bool dynamic = config->GetTime_Domain(); - const bool push_index = !config->GetMultizone_Problem(); /*--- Register solution at all necessary time instances and other variables on the tape ---*/ - direct_solver->GetNodes()->RegisterSolution(input, push_index); + direct_solver->GetNodes()->RegisterSolution(input); if (dynamic) { /*--- Register solution (u), acceleration (u'') and velocity (u') at time step n-1 ---*/ - direct_solver->GetNodes()->RegisterSolution_time_n(push_index); + direct_solver->GetNodes()->RegisterSolution_time_n(); } } @@ -208,25 +207,12 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, } if (!reset) { - const bool local_index = config->GetMultizone_Problem(); - const bool push_index = !local_index; - - E.Register(push_index); - Nu.Register(push_index); - Rho.Register(push_index); - Rho_DL.Register(push_index); - if (de_effects) EField.Register(push_index); - if (fea_dv) DV.Register(push_index); - - /*--- Explicitly store the tape indices for when we extract the derivatives ---*/ - if (local_index) { - E.SetIndex(); - Nu.SetIndex(); - Rho.SetIndex(); - Rho_DL.SetIndex(); - if (de_effects) EField.SetIndex(); - if (fea_dv) DV.SetIndex(); - } + E.Register(); + Nu.Register(); + Rho.Register(); + Rho_DL.Register(); + if (de_effects) EField.Register(); + if (fea_dv) DV.Register(); /*--- Register the flow tractions ---*/ if (config->GetnMarker_Fluid_Load() > 0) @@ -243,11 +229,10 @@ void CDiscAdjFEASolver::RegisterVariables(CGeometry *geometry, CConfig *config, void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ const bool input = false; - const bool push_index = !config->GetMultizone_Problem(); /*--- Register variables as output of the solver iteration ---*/ - direct_solver->GetNodes()->RegisterSolution(input, push_index); + direct_solver->GetNodes()->RegisterSolution(input); } @@ -276,12 +261,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution ---*/ - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); - } - else { - direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); - } + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); /*--- Store the adjoint solution ---*/ @@ -298,12 +278,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Extract the adjoint solution at time n ---*/ - if(multizone) { - direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); - } + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); /*--- Store the adjoint solution at time n ---*/ @@ -387,10 +362,7 @@ void CDiscAdjFEASolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config){ } } - if (multizone) - direct_solver->GetNodes()->SetAdjointSolution_LocalIndex(iPoint,Solution); - else - direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); } } @@ -418,24 +390,15 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo /*--- Extract the geometric sensitivities ---*/ - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { + const bool time_domain = config->GetTime_Domain(); - su2double *Coord = geometry->nodes->GetCoord(iPoint); + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { for (unsigned short iDim = 0; iDim < nDim; iDim++) { - su2double Sensitivity; - - if(config->GetMultizone_Problem()) { - Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); - } - else { - Sensitivity = SU2_TYPE::GetDerivative(Coord[iDim]); - /*--- Set the index manually to zero. ---*/ - AD::ResetInput(Coord[iDim]); - } + su2double Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); - if (!config->GetTime_Domain()) { + if (!time_domain) { nodes->SetSensitivity(iPoint, iDim, Sensitivity); } else { nodes->SetSensitivity(iPoint, iDim, nodes->GetSensitivity(iPoint, iDim) + Sensitivity); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index ce0dc2fff6f..9f590a2522f 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -154,18 +154,17 @@ void CDiscAdjSolver::RegisterSolution(CGeometry *geometry, CConfig *config) { const bool time_n1_needed = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND); const bool time_n_needed = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || time_n1_needed; - const bool push_index = !config->GetMultizone_Problem(); /*--- Register solution at all necessary time instances and other variables on the tape ---*/ /*--- Boolean true indicates that an input is registered ---*/ - direct_solver->GetNodes()->RegisterSolution(true, push_index); + direct_solver->GetNodes()->RegisterSolution(true); if (time_n_needed) - direct_solver->GetNodes()->RegisterSolution_time_n(push_index); + direct_solver->GetNodes()->RegisterSolution_time_n(); if (time_n1_needed) - direct_solver->GetNodes()->RegisterSolution_time_n1(push_index); + direct_solver->GetNodes()->RegisterSolution_time_n1(); } void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset) { @@ -293,11 +292,9 @@ void CDiscAdjSolver::RegisterVariables(CGeometry *geometry, CConfig *config, boo void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { - const bool push_index = !config->GetMultizone_Problem(); - /*--- Register variables as output of the solver iteration. Boolean false indicates that an output is registered ---*/ - direct_solver->GetNodes()->RegisterSolution(false, push_index); + direct_solver->GetNodes()->RegisterSolution(false); } void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ @@ -326,12 +323,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Extract the adjoint solution ---*/ - if(config->GetMultizone_Problem()) { - direct_solver->GetNodes()->GetAdjointSolution_LocalIndex(iPoint,Solution); - } - else { - direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); - } + direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); /*--- Relax and store the adjoint solution, compute the residuals. ---*/ @@ -374,12 +366,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - if(config->GetMultizone_Problem()) { - direct_solver->GetNodes()->GetAdjointSolution_time_n_LocalIndex(iPoint,Solution); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); - } + direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); } @@ -391,12 +378,7 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - if(config->GetMultizone_Problem()) { - direct_solver->GetNodes()->GetAdjointSolution_time_n1_LocalIndex(iPoint,Solution); - } - else { - direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); - } + direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); if (!CrossTerm) nodes->Set_Solution_time_n1(iPoint,Solution); } @@ -496,10 +478,8 @@ void CDiscAdjSolver::SetAdjoint_Output(CGeometry *geometry, CConfig *config) { } /*--- Set the adjoint values of the primal solution. ---*/ - if (multizone) - direct_solver->GetNodes()->SetAdjointSolution_LocalIndex(iPoint,Solution); - else - direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); + + direct_solver->GetNodes()->SetAdjointSolution(iPoint,Solution); } END_SU2_OMP_FOR } @@ -514,22 +494,9 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - auto Coord = geometry->nodes->GetCoord(iPoint); - for (auto iDim = 0u; iDim < nDim; iDim++) { - su2double Sensitivity = 0.0; - - if(config->GetMultizone_Problem()) { - Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); - } - else { - Sensitivity = SU2_TYPE::GetDerivative(Coord[iDim]); - } - - /*--- Set the index manually to zero. ---*/ - - AD::ResetInput(Coord[iDim]); + su2double Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); /*--- If sharp edge, set the sensitivity to 0 on that region ---*/ diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 37622e12441..e66991aa0a1 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -65,11 +65,11 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva if (config->GetTime_Marching() != TIME_MARCHING::STEADY) Solution_time_n1.resize(nPoint,nVar); - if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { - if (adjoint) { + if (config->GetDiscrete_Adjoint()) { + if (adjoint && config->GetMultizone_Problem()) External.resize(nPoint,nVar) = su2double(0.0); - } - else { + + if (!adjoint) { AD_InputIndex.resize(nPoint,nVar) = -1; AD_OutputIndex.resize(nPoint,nVar) = -1; @@ -118,30 +118,30 @@ void CVariable::Restore_BGSSolution_k() { void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.data()); } namespace { - void RegisterContainer(bool input, bool push_index, su2activematrix& variable, su2matrix& ad_index) { + void RegisterContainer(bool input, su2activematrix& variable, su2matrix& ad_index) { const auto nPoint = variable.rows(); SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for(unsigned long iVar=0; iVar Date: Sun, 9 May 2021 12:50:17 +0100 Subject: [PATCH 065/192] reset inputs as they are extracted --- SU2_CFD/include/variables/CMeshVariable.hpp | 8 ++++--- SU2_CFD/include/variables/CVariable.hpp | 17 +++++++++++++- .../src/iteration/CDiscAdjFEAIteration.cpp | 6 ++--- .../src/iteration/CDiscAdjFluidIteration.cpp | 7 +++--- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 3 +++ SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp | 23 +++++++++---------- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 3 +++ SU2_CFD/src/variables/CMeshVariable.cpp | 12 ++++------ SU2_CFD/src/variables/CVariable.cpp | 17 -------------- TestCases/disc_adj_fsi/Airfoil_2d/config.cfg | 2 +- 10 files changed, 50 insertions(+), 48 deletions(-) diff --git a/SU2_CFD/include/variables/CMeshVariable.hpp b/SU2_CFD/include/variables/CMeshVariable.hpp index 7b917f51ffc..c420e523206 100644 --- a/SU2_CFD/include/variables/CMeshVariable.hpp +++ b/SU2_CFD/include/variables/CMeshVariable.hpp @@ -93,9 +93,11 @@ class CMeshVariable : public CVariable { /*! * \brief Recover the value of the adjoint of the mesh coordinates. */ - inline void GetAdjoint_MeshCoord(unsigned long iPoint, su2double *adj_mesh) const final { - for (unsigned long iDim = 0; iDim < nDim; iDim++) - adj_mesh[iDim] = SU2_TYPE::GetDerivative(Mesh_Coord(iPoint,iDim)); + inline void GetAdjoint_MeshCoord(unsigned long iPoint, su2double *adj_mesh) final { + for (unsigned long iDim = 0; iDim < nDim; iDim++) { + adj_mesh[iDim] = AD::GetDerivative(AD_InputIndex(iPoint,iDim)); + AD::ResetInput(Mesh_Coord(iPoint,iDim)); + } } }; diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 12826d23988..567e453021f 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -114,6 +114,21 @@ class CVariable { assert(false && "A base method of CVariable was used, but it should have been overridden by the derived class."); } + void RegisterContainer(bool input, su2activematrix& variable, su2matrix& ad_index) { + const auto nPoint = variable.rows(); + SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { + for(unsigned long iVar=0; iVarRegisterVariables(geometry[iZone][iInst][MESH_0], config[iZone]); - } - /*--- Register mesh coordinates for geometric sensitivities ---*/ + /*--- Register mesh coordinates for geometric sensitivities ---*/ - geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); + geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); + } } void CDiscAdjFEAIteration::SetDependencies(CSolver***** solver, CGeometry**** geometry, CNumerics****** numerics, diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 1c3ac43204e..0e6f8a5a37d 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -418,7 +418,7 @@ void CDiscAdjFluidIteration::InitializeAdjoint(CSolver***** solver, CGeometry*** solver[iZone][iInst][MESH_0][ADJRAD_SOL]->SetAdjoint_Output(geometry[iZone][iInst][MESH_0], config[iZone]); } - if (config[iZone]->GetFluidProblem()) { + if (config[iZone]->GetFluidProblem() && config[iZone]->GetSinglezone_Driver()) { solver[iZone][iInst][MESH_0][FLOW_SOL]->SetVertexTractionsAdjoint(geometry[iZone][iInst][MESH_0], config[iZone]); } @@ -459,8 +459,7 @@ void CDiscAdjFluidIteration::RegisterInput(CSolver***** solver, CGeometry**** ge geometry[iZone][iInst][MESH_0]->RegisterCoordinates(); } - if (config[iZone]->GetDeform_Mesh()) { - /*--- Register the variables of the mesh deformation ---*/ + if (kind_recording == RECORDING::MESH_DEFORM) { /*--- Undeformed mesh coordinates ---*/ solver[iZone][iInst][MESH_0][ADJMESH_SOL]->RegisterSolution(geometry[iZone][iInst][MESH_0], config[iZone]); @@ -563,7 +562,7 @@ void CDiscAdjFluidIteration::RegisterOutput(CSolver***** solver, CGeometry**** g if (config[iZone]->AddRadiation()) { solver[iZone][iInst][MESH_0][ADJRAD_SOL]->RegisterOutput(geometry[iZone][iInst][MESH_0], config[iZone]); } - if (config[iZone]->GetFluidProblem()) { + if (config[iZone]->GetFluidProblem() && config[iZone]->GetSinglezone_Driver()) { solver[iZone][iInst][MESH_0][FLOW_SOL]->RegisterVertexTractions(geometry[iZone][iInst][MESH_0], config[iZone]); } diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index ab8b9fb3b5c..8115e187d0e 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -394,9 +394,12 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { + auto Coord = geometry->nodes->GetCoord(iPoint); + for (unsigned short iDim = 0; iDim < nDim; iDim++) { su2double Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); + AD::ResetInput(Coord[iDim]); if (!time_domain) { nodes->SetSensitivity(iPoint, iDim, Sensitivity); diff --git a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp index 0c81be0c379..98a93919dc0 100644 --- a/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjMeshSolver.cpp @@ -98,18 +98,19 @@ void CDiscAdjMeshSolver::SetRecording(CGeometry* geometry, CConfig *config){ void CDiscAdjMeshSolver::RegisterSolution(CGeometry *geometry, CConfig *config){ - SU2_OMP_MASTER { - /*--- Register reference mesh coordinates ---*/ - direct_solver->GetNodes()->Register_MeshCoord(); - } - END_SU2_OMP_MASTER - SU2_OMP_BARRIER + /*--- Register reference mesh coordinates ---*/ + direct_solver->GetNodes()->Register_MeshCoord(); + } void CDiscAdjMeshSolver::RegisterVariables(CGeometry *geometry, CConfig *config, bool reset){ + /*--- Register boundary displacements as input. + * Except for FSI, where they are determined by the FEA solver. ---*/ + + if (config->GetFSI_Simulation()) return; + SU2_OMP_MASTER { - /*--- Register boundary displacements as input. ---*/ direct_solver->GetNodes()->Register_BoundDisp(); } END_SU2_OMP_MASTER @@ -139,18 +140,16 @@ void CDiscAdjMeshSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *c void CDiscAdjMeshSolver::ExtractAdjoint_Variables(CGeometry *geometry, CConfig *config){ - /*--- Extract the sensitivities of the boundary displacements ---*/ + /*--- Extract the sensitivities of the boundary displacements, except for FSI. ---*/ + + if (config->GetFSI_Simulation()) return; SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++){ - /*--- Extract the adjoint solution of the boundary displacements ---*/ - su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjoint_BoundDisp(iPoint,Solution); - /*--- Store the sensitivities of the boundary displacements ---*/ - nodes->SetBoundDisp_Sens(iPoint,Solution); } diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 9f590a2522f..31259d78856 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -494,9 +494,12 @@ void CDiscAdjSolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSolve SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { + auto Coord = geometry->nodes->GetCoord(iPoint); + for (auto iDim = 0u; iDim < nDim; iDim++) { su2double Sensitivity = geometry->nodes->GetAdjointSolution(iPoint, iDim); + AD::ResetInput(Coord[iDim]); /*--- If sharp edge, set the sensitivity to 0 on that region ---*/ diff --git a/SU2_CFD/src/variables/CMeshVariable.cpp b/SU2_CFD/src/variables/CMeshVariable.cpp index 95aa08ab1aa..aed8430db5e 100644 --- a/SU2_CFD/src/variables/CMeshVariable.cpp +++ b/SU2_CFD/src/variables/CMeshVariable.cpp @@ -31,9 +31,6 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig *config) : CVariable(npoint, ndim, config) { - /*--- Booleans that determine the kind of problems ---*/ - bool time_domain = config->GetTime_Domain(); - /*--- Store the dimensionality of the problem ---*/ nDim = ndim; @@ -41,15 +38,16 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig * Mesh_Coord.resize(nPoint,nDim) = su2double(0.0); WallDistance.resize(nPoint) = su2double(1e-9); + if (config->GetDiscrete_Adjoint()) + AD_InputIndex.resize(nPoint,nDim) = -1; + /*--- Initialize the variables necessary when the problem is time domain ---*/ - if (time_domain) { + if (config->GetTime_Domain()) { Solution_time_n.resize(nPoint,nDim) = su2double(0.0); Solution_time_n1.resize(nPoint,nDim) = su2double(0.0); } } void CMeshVariable::Register_MeshCoord() { - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - for (unsigned long iDim = 0; iDim < nDim; iDim++) - AD::RegisterInput(Mesh_Coord(iPoint,iDim)); + RegisterContainer(true, Mesh_Coord, AD_InputIndex); } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index e66991aa0a1..bd39065c7a4 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -117,23 +117,6 @@ void CVariable::Restore_BGSSolution_k() { void CVariable::SetExternalZero() { parallelSet(External.size(), 0.0, External.data()); } -namespace { - void RegisterContainer(bool input, su2activematrix& variable, su2matrix& ad_index) { - const auto nPoint = variable.rows(); - SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) - for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { - for(unsigned long iVar=0; iVar Date: Mon, 10 May 2021 11:07:34 +0100 Subject: [PATCH 066/192] fix #1285 --- SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index d18a33b2333..ae9f2dd8487 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -943,7 +943,7 @@ void CDiscAdjMultizoneDriver::HandleDataTransfer() { for (unsigned short jZone = 0; jZone < nZone; jZone++){ /*--- The target zone is iZone ---*/ if (jZone != iZone && interface_container[jZone][iZone] != nullptr) { - DeformMesh = DeformMesh || Transfer_Data(jZone, iZone); + DeformMesh |= Transfer_Data(jZone, iZone); } } From 7f9f6479040eb2de9e3b490c1da6c6045c3c742f Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 10 May 2021 11:15:09 +0100 Subject: [PATCH 067/192] address #1273 --- Common/include/code_config.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Common/include/code_config.hpp b/Common/include/code_config.hpp index 377432ee945..17315154c34 100644 --- a/Common/include/code_config.hpp +++ b/Common/include/code_config.hpp @@ -116,9 +116,13 @@ using su2mixedfloat = passivedouble; /*--- Detect if OpDiLib has to be used. ---*/ #if defined(HAVE_OMP) && defined(CODI_REVERSE_TYPE) +#ifndef __INTEL_COMPILER #define HAVE_OPDI +#else +#warning Hybrid parallel reverse mode AD cannot be used with Intel compilers. #endif #if (_OPENMP >= 201811 && !defined(FORCE_OPDI_MACRO_BACKEND)) || defined(FORCE_OPDI_OMPT_BACKEND) #define HAVE_OMPT #endif +#endif From 7e0867890d6ca364a2d5ac33594189bdfebdf27f Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:15:02 +0100 Subject: [PATCH 068/192] indentation Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/include/solvers/CSolver.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 2a860f64f26..946c4e36502 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -3612,7 +3612,7 @@ class CSolver { */ inline virtual void SetAdjoint_Output(CGeometry *geometry, CConfig *config){} - /*! + /*! * \brief A virtual member. * \param[in] geometry - The geometrical definition of the problem. * \param[in] solver_container - The solver container holding all solutions. From ee76b68fae2f3078f43c33217f991ed343094496 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:16:36 +0100 Subject: [PATCH 069/192] numeric limits instead of large number Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index e919dd66ffa..2a754973798 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -98,7 +98,7 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { COutput** direct_output; /*!< \brief Array of pointers to the direct outputs. */ vector direct_nInst; /*!< \brief Total number of instances in the direct problem. */ vector nInnerIter; /*!< \brief Number of inner iterations for each zone. */ - unsigned long wrt_sol_freq = 99999; /*!< \brief File output frequency. */ + unsigned long wrt_sol_freq = std::numeric_limits::max(); /*!< \brief File output frequency. */ su2vector Has_Deformation; /*!< \brief True if iZone has mesh deformation (used for lazy evaluation of TRANSFER tape section). */ From c8b094f0391854e8c7a29b449c5e469afb40be4e Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:17:48 +0100 Subject: [PATCH 070/192] spacing Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp index d7ac26f88f2..955b5a04d16 100644 --- a/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp +++ b/SU2_CFD/include/variables/CDiscAdjFEABoundVariable.hpp @@ -117,6 +117,7 @@ class CDiscAdjFEABoundVariable final : public CDiscAdjVariable { if (!VertexMap.GetVertexIndex(iPoint)) return 0.0; return SourceTerm_VelAdjoint(iPoint,iDim); } + /*! * \brief Get whether a node is on the boundary */ From e6a9a3ae29191eedfce7e7b950c09cab4cf1f846 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:25:53 +0100 Subject: [PATCH 071/192] Apply suggestions from code review Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/drivers/CDriver.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index e78890f1fd6..f9e5a25956d 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -1239,8 +1239,8 @@ void CDriver::Solver_Restart(CSolver ***solver, CGeometry **geometry, } if (fem) { if (time_domain) { - if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + if (config->GetRestart()) val_iter = config->GetRestart_Iter()-1; + else val_iter = config->GetUnst_AdjointIter()-1; } solver[MESH_0][FEA_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } @@ -1286,8 +1286,8 @@ void CDriver::Solver_Restart(CSolver ***solver, CGeometry **geometry, if ((restart || restart_flow) && config->GetDeform_Mesh() && update_geo){ /*--- Always restart with the last state ---*/ - if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + if (config->GetRestart()) val_iter = config->GetRestart_Iter()-1; + else val_iter = config->GetUnst_AdjointIter()-1; solver[MESH_0][MESH_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } From d64d7ee08281d171e907a9108c4b5a8bf984f6cb Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:26:50 +0100 Subject: [PATCH 072/192] typo Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 9016d1e03fe..f464da1a2e5 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -123,7 +123,7 @@ void CDiscAdjFluidIteration::Preprocess(COutput* output, CIntegration**** integr Afterwards the GridVelocity is computed based on the Coordinates. ---*/ - /*--- Temporarily store the loaded volumes in to old containers ---*/ + /*--- Temporarily store the loaded volumes into old containers ---*/ if (config[iZone]->GetDynamic_Grid()) { for (auto iMesh=0; iMesh<=config[iZone]->GetnMGLevels();iMesh++) { geometries[iMesh]->nodes->SetVolume_Old(); From 947fdfad6b31f62da3189d51575c10853ccd02fd Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:27:33 +0100 Subject: [PATCH 073/192] Update SU2_CFD/src/python_wrapper_structure.cpp Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/python_wrapper_structure.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/SU2_CFD/src/python_wrapper_structure.cpp b/SU2_CFD/src/python_wrapper_structure.cpp index f7f8499963a..0617674ec78 100644 --- a/SU2_CFD/src/python_wrapper_structure.cpp +++ b/SU2_CFD/src/python_wrapper_structure.cpp @@ -809,11 +809,9 @@ void CDriver::SetSourceTerm_DispAdjoint(unsigned short iMarker, unsigned long iV void CDriver::SetSourceTerm_VelAdjoint(unsigned short iMarker, unsigned long iVertex, passivedouble val_AdjointX, passivedouble val_AdjointY, passivedouble val_AdjointZ) { - unsigned long iPoint; - CSolver *solver = solver_container[ZONE_0][INST_0][MESH_0][ADJFEA_SOL]; CGeometry *geometry = geometry_container[ZONE_0][INST_0][MESH_0]; - iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); + const auto iPoint = geometry_container[ZONE_0][INST_0][MESH_0]->vertex[iMarker][iVertex]->GetNode(); solver->GetNodes()->SetSourceTerm_VelAdjoint(iPoint, 0, val_AdjointX); solver->GetNodes()->SetSourceTerm_VelAdjoint(iPoint, 1, val_AdjointY); From 34b53875d94a99b8d363d1b47a1740f4f16817e0 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Mon, 10 May 2021 14:38:36 +0100 Subject: [PATCH 074/192] Update SU2_CFD/src/variables/CVariable.cpp Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/variables/CVariable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index 37622e12441..5882fd2189b 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -63,7 +63,7 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva Solution_time_n.resize(nPoint,nVar) = su2double(0.0); if (config->GetTime_Marching() != TIME_MARCHING::STEADY) - Solution_time_n1.resize(nPoint,nVar); + Solution_time_n1.resize(nPoint,nVar) = su2double(0.0); if (config->GetMultizone_Problem() && config->GetDiscrete_Adjoint()) { if (adjoint) { From 89b67007f672e13a238b30c50f4a039c90b7bdf9 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Tue, 11 May 2021 19:48:21 +0200 Subject: [PATCH 075/192] Fix rough wall treatment for multizone setup --- Common/include/fem/fem_geometry_structure.hpp | 11 +++++++---- Common/include/geometry/CGeometry.hpp | 16 ++++++++++++---- Common/include/geometry/CPhysicalGeometry.hpp | 17 +++++++++++------ Common/src/fem/fem_wall_distance.cpp | 2 +- Common/src/geometry/CGeometry.cpp | 9 +++++++-- Common/src/geometry/CPhysicalGeometry.cpp | 18 +++++++++--------- 6 files changed, 47 insertions(+), 26 deletions(-) diff --git a/Common/include/fem/fem_geometry_structure.hpp b/Common/include/fem/fem_geometry_structure.hpp index fb4787d645c..b6116755a3f 100644 --- a/Common/include/fem/fem_geometry_structure.hpp +++ b/Common/include/fem/fem_geometry_structure.hpp @@ -1227,11 +1227,14 @@ class CMeshFEM_DG: public CMeshFEM { void SetWallDistance(su2double val) override; /*! - * \brief Set the wall distance based on an previously constructed ADT - * \param[in] config - Definition of the particular problem. - * \param[in] WallADT - The ADT to compute the wall distance + * \brief Reduce the wall distance based on an previously constructed ADT. + * \details The ADT might belong to another zone, giving rise to lower wall distances + * than those already stored. + * \param[in] WallADT - The ADT to reduce the wall distance + * \param[in] geometry - ignored + * \param[in] config - ignored */ - void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override; + virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry = nullptr) override; }; /*! diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index cc8aa2867b2..a9f938bd108 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1683,11 +1683,14 @@ class CGeometry { virtual std::unique_ptr ComputeViscousWallADT(const CConfig *config) const { return nullptr; } /*! - * \brief Set the wall distance based on an previously constructed ADT - * \param[in] config - Definition of the particular problem. - * \param[in] WallADT - The ADT to compute the wall distance + * \brief Reduce the wall distance based on an previously constructed ADT. + * \details The ADT might belong to another zone, giving rise to lower wall distances + * than those already stored. + * \param[in] WallADT - The ADT to reduce the wall distance + * \param[in] geometry - Geometry associated to the ADT + * \param[in] config - Config associated to the ADT */ - virtual void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) {} + virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) {} /*! * \brief Set wall distances a specific value @@ -1702,6 +1705,11 @@ class CGeometry { */ static void ComputeWallDistance(const CConfig * const *config_container, CGeometry ****geometry_container); + /*! + * \brief Virtual function to set roughness values. + */ + virtual void SetGlobalMarkerRoughness(const CConfig* config) {} + /*! * \brief Set the amount of nonconvex elements in the mesh. * \param[in] nonconvex_elems - amount of nonconvex elements in the mesh diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 4f8866adca3..4de68a8477f 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -104,11 +104,12 @@ class CPhysicalGeometry final : public CGeometry { unsigned long *Elem_ID_BoundTria_Linear{nullptr}; unsigned long *Elem_ID_BoundQuad_Linear{nullptr}; + su2double Streamwise_Periodic_RefNode[MAXNDIM] = {0}; /*!< \brief Coordinates of the reference node [m] on the receiving periodic marker, for recovered pressure/temperature computation only.*/ + +public: vector GlobalMarkerStorageDispl; vector GlobalRoughness_Height; - su2double Streamwise_Periodic_RefNode[MAXNDIM] = {0}; /*!< \brief Coordinates of the reference node [m] on the receiving periodic marker, for recovered pressure/temperature computation only.*/ - public: /*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/ using CGeometry::SetVertex; @@ -767,10 +768,14 @@ class CPhysicalGeometry final : public CGeometry { std::unique_ptr ComputeViscousWallADT(const CConfig *config) const override; /*! - * \brief Set the wall distance based on an previously constructed ADT - * \param[in] WallADT - The ADT to compute the wall distance + * \brief Reduce the wall distance based on an previously constructed ADT. + * \details The ADT might belong to another zone, giving rise to lower wall distances + * than those already stored. + * \param[in] WallADT - The ADT to reduce the wall distance + * \param[in] geometry - Physical geometry associated to the ADT + * \param[in] config - Config associated to the ADT */ - void SetWallDistance(const CConfig *config, CADTElemClass* WallADT) override; + virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) override; /*! * \brief Set wall distances a specific value @@ -784,7 +789,7 @@ class CPhysicalGeometry final : public CGeometry { /*! * \brief Set roughness values for markers in a global array. */ - void SetGlobalMarkerRoughness(const CConfig* config); + virtual void SetGlobalMarkerRoughness(const CConfig* config) override; /*! * \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet. diff --git a/Common/src/fem/fem_wall_distance.cpp b/Common/src/fem/fem_wall_distance.cpp index b4d2c70c1a0..5273732594c 100644 --- a/Common/src/fem/fem_wall_distance.cpp +++ b/Common/src/fem/fem_wall_distance.cpp @@ -172,7 +172,7 @@ void CMeshFEM_DG::SetWallDistance(su2double val){ } } -void CMeshFEM_DG::SetWallDistance(const CConfig *config, CADTElemClass *WallADT){ +void CMeshFEM_DG::SetWallDistance(CADTElemClass *WallADT, const CConfig *config, const CGeometry* geometry){ /*--------------------------------------------------------------------------*/ /*--- Step 3: Determine the wall distance of the integration points of ---*/ diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index cf708b8a112..ffa96bce168 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3923,14 +3923,19 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo /*--- Loop over all zones and compute the ADT based on the viscous walls in that zone ---*/ for (int iZone = 0; iZone < nZone; iZone++){ CGeometry *geometry = geometry_container[iZone][iInst][MESH_0]; - unique_ptr WallADT = geometry->ComputeViscousWallADT(config_container[iZone]); + const CConfig *config = config_container[iZone]; + unique_ptr WallADT = geometry->ComputeViscousWallADT(config); if (WallADT && !WallADT->IsEmpty()){ allEmpty = false; + /*--- Along with finding the closest walls, we collect their roughnesses. ---*/ + if (config_container[iZone]->GetnRoughWall() > 0) + geometry->SetGlobalMarkerRoughness(config); + /*--- Inner loop over all zones to update the wall distances. * It might happen that there is a closer viscous wall in zone iZone for points in zone jZone. ---*/ for (int jZone = 0; jZone < nZone; jZone++){ if (wallDistanceNeeded[jZone]) - geometry_container[jZone][iInst][MESH_0]->SetWallDistance(config_container[jZone], WallADT.get()); + geometry_container[jZone][iInst][MESH_0]->SetWallDistance(WallADT.get(), config, geometry); } } } diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 75db70bc909..c2cc183420b 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -11017,16 +11017,13 @@ std::unique_ptr CPhysicalGeometry::ComputeViscousWallADT(const CC } -void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *WallADT) { +void CPhysicalGeometry::SetWallDistance(CADTElemClass* WallADT, const CConfig *config, const CGeometry* geometry) { /*--------------------------------------------------------------------------*/ /*--- Step 3: Loop over all interior mesh nodes and compute minimum ---*/ /*--- distance to a solid wall element ---*/ /*--------------------------------------------------------------------------*/ - /*--- Store marker list and roughness in a global array. ---*/ - if (config->GetnRoughWall() > 0) SetGlobalMarkerRoughness(config); - SU2_OMP_PARALLEL if (!WallADT->IsEmpty()) { /*--- Solid wall boundary nodes are present. Compute the wall @@ -11041,12 +11038,15 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa WallADT->DetermineNearestElement(nodes->GetCoord(iPoint), dist, markerID, elemID, rankID); - nodes->SetWall_Distance(iPoint, min(dist,nodes->GetWall_Distance(iPoint))); + if(dist < nodes->GetWall_Distance(iPoint)){ + nodes->SetWall_Distance(iPoint, dist); - if (config->GetnRoughWall() > 0) { - auto index = GlobalMarkerStorageDispl[rankID] + markerID; - auto localRoughness = GlobalRoughness_Height[index]; - nodes->SetRoughnessHeight(iPoint, localRoughness); + if (config->GetnRoughWall() > 0) { + const CPhysicalGeometry* ph_geometry = dynamic_cast(geometry); + auto index = ph_geometry->GlobalMarkerStorageDispl[rankID] + markerID; + su2double localRoughness = ph_geometry->GlobalRoughness_Height[index]; + nodes->SetRoughnessHeight(iPoint, localRoughness); + } } } END_SU2_OMP_FOR From e7306269153c74aa5c82f673ce69f293c3354ec0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 11 May 2021 23:13:20 +0100 Subject: [PATCH 076/192] add regression test --- TestCases/disc_adj_fsi/dyn_fsi/config.cfg | 28 +++++ TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg | 65 +++++++++++ TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg | 105 ++++++++++++++++++ 3 files changed, 198 insertions(+) create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/config.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg create mode 100755 TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg diff --git a/TestCases/disc_adj_fsi/dyn_fsi/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg new file mode 100755 index 00000000000..02bad468d23 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg @@ -0,0 +1,28 @@ +SOLVER= MULTIPHYSICS +MATH_PROBLEM= DISCRETE_ADJOINT +CONFIG_LIST=(configFlow.cfg, configFEA.cfg) + +MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) + +CONSERVATIVE_INTERPOLATION= NO + +READ_BINARY_RESTART= NO + +OUTER_ITER= 10 +MESH_FILENAME= mesh.su2 + +TIME_DOMAIN = YES +TIME_ITER = 3 +TIME_STEP = 0.01 +UNST_ADJOINT_ITER= 10 +ITER_AVERAGE_OBJ= 3 + +OBJECTIVE_FUNCTION= REFERENCE_NODE + +SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0] + +WRT_ZONE_HIST=YES +%WRT_ZONE_CONV=YES + +% Debug: Force Zero Grid Velocity = NO +WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg new file mode 100755 index 00000000000..c657a817932 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFEA.cfg @@ -0,0 +1,65 @@ +% Physics -------------------------------------------------------------- % +SOLVER= ELASTICITY +% +% Time settings --------------------------------------------------------- % +TIME_DISCRE_FEA= NEWMARK_IMPLICIT +NEWMARK_BETA=0.2601 +NEWMARK_GAMMA=0.52 +% +% Optimization --------------------------------------------------------- % +FEA_ADVANCED_MODE= YES +FEA_FILENAME= element_properties.dat +GRAD_OBJFUNC_FILENAME= of_grad.dat +REFERENCE_NODE= 234 +REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) +REFERENCE_NODE_PENALTY= 1.0 +DESIGN_VARIABLE_FEA= YOUNG_MODULUS +% +% Solid properties ----------------------------------------------------- % +MATERIAL_MODEL= NEO_HOOKEAN +ELASTICITY_MODULUS= 7E8 +POISSON_RATIO= 0.35 +MATERIAL_DENSITY= 2700.0 +% +% Boundary conditions -------------------------------------------------- % +MARKER_CLAMPED= ( clamped ) +MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) +% +% Solid numerics ------------------------------------------------------- % +GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS +FORMULATION_ELASTICITY_2D= PLANE_STRESS +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= CONJUGATE_GRADIENT +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT +DISCADJ_LIN_PREC= ILU +% +% Convergence criteria ------------------------------------------------- % +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +INNER_ITER= 11 +% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. +INCREMENTAL_LOAD= NO +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_solid.dat +SOLUTION_ADJ_FILENAME= adjoint_solid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_solid.dat +RESTART_ADJ_FILENAME= adjoint_solid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= solid +VOLUME_ADJ_FILENAME= adjoint_solid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF +OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg new file mode 100755 index 00000000000..e5fb7fcd096 --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg @@ -0,0 +1,105 @@ +% Physics -------------------------------------------------------------- % +SOLVER= EULER +KIND_TURB_MODEL= NONE +% +% Time settings --------------------------------------------------------- % +TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER +% +% Optimization --------------------------------------------------------- % +GRAD_OBJFUNC_FILENAME= of_grad.dat +% +% Compressible free-stream conditions ---------------------------------- % +MACH_NUMBER= 0.8 +AOA= 5.0 +INIT_OPTION= TD_CONDITIONS +FREESTREAM_OPTION= TEMPERATURE_FS +FREESTREAM_PRESSURE= 101325.0 +FREESTREAM_TEMPERATURE= 273.15 +REYNOLDS_LENGTH= 0.5 +% +% Fluid properties ----------------------------------------------------- % +FLUID_MODEL= IDEAL_GAS +GAMMA_VALUE= 1.4 +GAS_CONSTANT= 287.87 +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.716E-5 +% +% Boundary conditions -------------------------------------------------- % +MARKER_FAR= ( farfield ) +MARKER_EULER= ( leading_edge, pressure_side, suction_side) +MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) +DEFORM_MESH= YES +% +% Post processing and monitoring --------------------------------------- % +REF_ORIGIN_MOMENT_X= -0.125 +REF_ORIGIN_MOMENT_Y= 0.00 +REF_ORIGIN_MOMENT_Z= 0.00 +REF_LENGTH= 0.5 +REF_AREA= 0.5 +MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) +MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) +MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) +% +% Common numerics settings --------------------------------------------- % +REF_DIMENSIONALIZATION= DIMENSIONAL +NUM_METHOD_GRAD= GREEN_GAUSS +CFL_NUMBER= 15.0 +% +% Flow numerics -------------------------------------------------------- % +CONV_NUM_METHOD_FLOW= JST +JST_SENSOR_COEFF= ( 0.5, 0.02 ) +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% Linear solvers ------------------------------------------------------- % +LINEAR_SOLVER= BCGSTAB +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-3 +LINEAR_SOLVER_ITER= 1000 +DISCADJ_LIN_SOLVER= BCGSTAB +DISCADJ_LIN_PREC= ILU +% Multigrid +MGLEVEL= 2 +MGCYCLE= V_CYCLE +MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) +MG_POST_SMOOTH= ( 0, 0, 0, 0 ) +MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) +MG_DAMP_RESTRICTION= 0.75 +MG_DAMP_PROLONGATION= 0.75 +% +DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ERROR= 1e-8 +DEFORM_LINEAR_SOLVER_ITER= 1000 +DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME +DEFORM_POISSONS_RATIO= 1e6 +% +% Convergence criteria ------------------------------------------------- % +% interaction +BGS_RELAXATION= FIXED_PARAMETER +STAT_RELAX_PARAMETER= 1.0 +% fluid +INNER_ITER= 51 +CONV_STARTITER= 0 +CONV_RESIDUAL_MINVAL= -9 +% +% In\Out --------------------------------------------------------------- % +MESH_FILENAME= mesh.su2 +MESH_FORMAT= SU2 +% +RESTART_SOL= NO +SOLUTION_FILENAME= solution_fluid.dat +SOLUTION_ADJ_FILENAME= adjoint_fluid.dat +OUTPUT_WRT_FREQ= 1 +RESTART_FILENAME= solution_fluid.dat +RESTART_ADJ_FILENAME= adjoint_fluid.dat +% +TABULAR_FORMAT= CSV +VOLUME_FILENAME= fluid +VOLUME_ADJ_FILENAME= adjoint_fluid +SURFACE_FILENAME= surface_fluid +SURFACE_ADJ_FILENAME= adjoint_surface_fluid +% +SCREEN_WRT_FREQ_INNER= 10 +CONV_FILENAME= history +HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF +OUTPUT_FILES= NONE From 8ed0250c96f9ad6d36e6f041f51e13f3bcc58e27 Mon Sep 17 00:00:00 2001 From: Charanya <33747655+cvencro@users.noreply.github.com> Date: Tue, 11 May 2021 23:23:30 +0100 Subject: [PATCH 077/192] Update parallel_regression_AD.py for dynamic fsi --- TestCases/parallel_regression_AD.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 481838842eb..8688cc2d455 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -308,6 +308,19 @@ def main(): discadj_fsi2.tol = 1e-16 test_list.append(discadj_fsi2) + ## Unsteady multi physics framework + #dyn_discadj_fsi = TestCase('dyn_discadj_fsi') + #dyn_discadj_fsi.cfg_dir = "disc_adj_fsi/dyn_fsi" + #dyn_discadj_fsi.cfg_file = "config.cfg" + #dyn_discadj_fsi.test_iter = 2 + #dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" + #dyn_discadj_fsi.timeout = 1600 + #dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" + #dyn_discadj_fsi.test_file = "grad_dv.opt" + #dyn_discadj_fsi.unsteady = True + #pass_list.append(dyn_discadj_fsi.run_filediff()) + #test_list.append(dyn_discadj_fsi) + ################################### ### Coupled CHT Adjoint ### ################################### From 188869f500001587048fee03ad53e0ab91a95391 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Wed, 12 May 2021 07:48:10 +0200 Subject: [PATCH 078/192] removed redundant "virtual" CodeFactor: "virtual" is redundant since function is already declared as "override" --- Common/include/fem/fem_geometry_structure.hpp | 2 +- Common/include/geometry/CPhysicalGeometry.hpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/include/fem/fem_geometry_structure.hpp b/Common/include/fem/fem_geometry_structure.hpp index b6116755a3f..210f3e2a7a2 100644 --- a/Common/include/fem/fem_geometry_structure.hpp +++ b/Common/include/fem/fem_geometry_structure.hpp @@ -1234,7 +1234,7 @@ class CMeshFEM_DG: public CMeshFEM { * \param[in] geometry - ignored * \param[in] config - ignored */ - virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry = nullptr) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry = nullptr) override; }; /*! diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 4de68a8477f..98d8b8bc604 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -775,7 +775,7 @@ class CPhysicalGeometry final : public CGeometry { * \param[in] geometry - Physical geometry associated to the ADT * \param[in] config - Config associated to the ADT */ - virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) override; /*! * \brief Set wall distances a specific value @@ -789,7 +789,7 @@ class CPhysicalGeometry final : public CGeometry { /*! * \brief Set roughness values for markers in a global array. */ - virtual void SetGlobalMarkerRoughness(const CConfig* config) override; + void SetGlobalMarkerRoughness(const CConfig* config) override; /*! * \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet. From 1fab0e3b2968863a93ed7cfa8ba3b94b8dddc74a Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 12 May 2021 19:59:42 +0100 Subject: [PATCH 079/192] read binary restart files --- TestCases/disc_adj_fsi/dyn_fsi/config.cfg | 2 -- 1 file changed, 2 deletions(-) diff --git a/TestCases/disc_adj_fsi/dyn_fsi/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg index 02bad468d23..2f8810526ad 100755 --- a/TestCases/disc_adj_fsi/dyn_fsi/config.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/config.cfg @@ -6,8 +6,6 @@ MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side CONSERVATIVE_INTERPOLATION= NO -READ_BINARY_RESTART= NO - OUTER_ITER= 10 MESH_FILENAME= mesh.su2 From afbb3438faef58c942daa2f6c3cd7db3b3902497 Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 12 May 2021 20:14:51 +0100 Subject: [PATCH 080/192] remove test cases --- .../disc_adj_fsi/dyn_fsi/Adjoint/config.cfg | 28 -- .../dyn_fsi/Adjoint/configFEA.cfg | 65 --- .../dyn_fsi/Adjoint/configFlow.cfg | 105 ----- .../disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt | 9 - .../dyn_fsi/Adjoint/element_properties_1.dat | 369 ------------------ .../disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg | 28 -- .../dyn_fsi/FD_DV_0/configFEA.cfg | 65 --- .../dyn_fsi/FD_DV_0/configFlow.cfg | 105 ----- .../disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt | 9 - .../dyn_fsi/FD_DV_0/element_properties_1.dat | 369 ------------------ .../disc_adj_fsi/dyn_fsi/Primal/config.cfg | 28 -- .../disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg | 65 --- .../dyn_fsi/Primal/configFlow.cfg | 105 ----- .../disc_adj_fsi/dyn_fsi/Primal/dv_young.opt | 9 - .../dyn_fsi/Primal/element_properties_1.dat | 369 ------------------ 15 files changed, 1728 deletions(-) delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg delete mode 100755 TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt delete mode 100644 TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg deleted file mode 100755 index 8ed8339070c..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/config.cfg +++ /dev/null @@ -1,28 +0,0 @@ -SOLVER= MULTIPHYSICS -MATH_PROBLEM= DISCRETE_ADJOINT -CONFIG_LIST=(configFlow.cfg, configFEA.cfg) - -MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) - -CONSERVATIVE_INTERPOLATION= NO - -READ_BINARY_RESTART= NO - -OUTER_ITER= 40 -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 - -TIME_DOMAIN = YES -TIME_ITER = 10 -TIME_STEP = 0.01 -UNST_ADJOINT_ITER= 10 -ITER_AVERAGE_OBJ= 10 - -OBJECTIVE_FUNCTION= REFERENCE_NODE - -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] - -WRT_ZONE_HIST=YES -%WRT_ZONE_CONV=YES - -% Debug: Force Zero Grid Velocity = NO -WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg deleted file mode 100755 index 612823c7556..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFEA.cfg +++ /dev/null @@ -1,65 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= ELASTICITY -% -% Time settings --------------------------------------------------------- % -TIME_DISCRE_FEA= NEWMARK_IMPLICIT -NEWMARK_BETA=0.2601 -NEWMARK_GAMMA=0.52 -% -% Optimization --------------------------------------------------------- % -FEA_ADVANCED_MODE= YES -FEA_FILENAME= element_properties.dat -GRAD_OBJFUNC_FILENAME= of_grad.dat -REFERENCE_NODE= 234 -REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) -REFERENCE_NODE_PENALTY= 1.0 -DESIGN_VARIABLE_FEA= YOUNG_MODULUS -% -% Solid properties ----------------------------------------------------- % -MATERIAL_MODEL= NEO_HOOKEAN -ELASTICITY_MODULUS= 7E8 -POISSON_RATIO= 0.35 -MATERIAL_DENSITY= 2700.0 -% -% Boundary conditions -------------------------------------------------- % -MARKER_CLAMPED= ( clamped ) -MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) -% -% Solid numerics ------------------------------------------------------- % -GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS -FORMULATION_ELASTICITY_2D= PLANE_STRESS -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= CONJUGATE_GRADIENT -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-8 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT -DISCADJ_LIN_PREC= ILU -% -% Convergence criteria ------------------------------------------------- % -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -INNER_ITER= 11 -% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. -INCREMENTAL_LOAD= NO -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_solid.dat -SOLUTION_ADJ_FILENAME= adjoint_solid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_solid.dat -RESTART_ADJ_FILENAME= adjoint_solid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= solid -VOLUME_ADJ_FILENAME= adjoint_solid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF -OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg deleted file mode 100755 index b83b3ecc111..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/configFlow.cfg +++ /dev/null @@ -1,105 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= EULER -KIND_TURB_MODEL= NONE -% -% Time settings --------------------------------------------------------- % -TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER -% -% Optimization --------------------------------------------------------- % -GRAD_OBJFUNC_FILENAME= of_grad.dat -% -% Compressible free-stream conditions ---------------------------------- % -MACH_NUMBER= 0.8 -AOA= 5.0 -INIT_OPTION= TD_CONDITIONS -FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 101325.0 -FREESTREAM_TEMPERATURE= 273.15 -REYNOLDS_LENGTH= 0.5 -% -% Fluid properties ----------------------------------------------------- % -FLUID_MODEL= IDEAL_GAS -GAMMA_VALUE= 1.4 -GAS_CONSTANT= 287.87 -VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 1.716E-5 -% -% Boundary conditions -------------------------------------------------- % -MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, pressure_side, suction_side) -MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) -DEFORM_MESH= YES -% -% Post processing and monitoring --------------------------------------- % -REF_ORIGIN_MOMENT_X= -0.125 -REF_ORIGIN_MOMENT_Y= 0.00 -REF_ORIGIN_MOMENT_Z= 0.00 -REF_LENGTH= 0.5 -REF_AREA= 0.5 -MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) -MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) -MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) -% -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 15.0 -% -% Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-3 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= BCGSTAB -DISCADJ_LIN_PREC= ILU -% Multigrid -MGLEVEL= 2 -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) -MG_DAMP_RESTRICTION= 0.75 -MG_DAMP_PROLONGATION= 0.75 -% -DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT -DEFORM_LINEAR_SOLVER_PREC= ILU -DEFORM_LINEAR_SOLVER_ERROR= 1e-8 -DEFORM_LINEAR_SOLVER_ITER= 1000 -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME -DEFORM_POISSONS_RATIO= 1e6 -% -% Convergence criteria ------------------------------------------------- % -% interaction -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -% fluid -INNER_ITER= 51 -CONV_STARTITER= 0 -CONV_RESIDUAL_MINVAL= -9 -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_fluid.dat -SOLUTION_ADJ_FILENAME= adjoint_fluid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_fluid.dat -RESTART_ADJ_FILENAME= adjoint_fluid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= fluid -VOLUME_ADJ_FILENAME= adjoint_fluid -SURFACE_FILENAME= surface_fluid -SURFACE_ADJ_FILENAME= adjoint_surface_fluid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF -OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt deleted file mode 100644 index 3c691471847..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/dv_young.opt +++ /dev/null @@ -1,9 +0,0 @@ -INDEX VAL SCALE LOWER_BOUND UPPER_BOUND -0 1 1 0.01 100.0 -1 1 1 0.01 100.0 -2 1 1 0.01 100.0 -3 1 1 0.01 100.0 -4 1 1 0.01 100.0 -5 1 1 0.01 100.0 -6 1 1 0.01 100.0 -7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat deleted file mode 100644 index 90421c13042..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Adjoint/element_properties_1.dat +++ /dev/null @@ -1,369 +0,0 @@ -INDEX MMOD MPROP ELPROP DV DENSITY -0 0 0 0 0 1.0 -1 0 0 0 0 1.0 -2 0 0 0 0 1.0 -3 0 0 0 0 1.0 -4 0 0 0 0 1.0 -5 0 0 0 0 1.0 -6 0 0 0 0 1.0 -7 0 0 0 0 1.0 -8 0 0 0 0 1.0 -9 0 0 0 0 1.0 -10 0 0 0 0 1.0 -11 0 0 0 0 1.0 -12 0 0 0 0 1.0 -13 0 0 0 0 1.0 -14 0 0 0 0 1.0 -15 0 0 0 0 1.0 -16 0 0 0 0 1.0 -17 0 0 0 0 1.0 -18 0 0 0 0 1.0 -19 0 0 0 0 1.0 -20 0 0 0 0 1.0 -21 0 0 0 0 1.0 -22 0 0 0 0 1.0 -23 0 0 0 0 1.0 -24 0 0 0 0 1.0 -25 0 0 0 0 1.0 -26 0 0 0 0 1.0 -27 0 0 0 0 1.0 -28 0 0 0 0 1.0 -29 0 0 0 0 1.0 -30 0 0 0 0 1.0 -31 0 0 0 0 1.0 -32 0 0 0 0 1.0 -33 0 0 0 0 1.0 -34 0 0 0 0 1.0 -35 0 0 0 0 1.0 -36 0 0 0 0 1.0 -37 0 0 0 0 1.0 -38 0 0 0 0 1.0 -39 0 0 0 0 1.0 -40 0 0 0 0 1.0 -41 0 0 0 0 1.0 -42 0 0 0 0 1.0 -43 0 0 0 0 1.0 -44 0 0 0 0 1.0 -45 0 0 0 0 1.0 -46 0 0 0 1 1.0 -47 0 0 0 1 1.0 -48 0 0 0 1 1.0 -49 0 0 0 1 1.0 -50 0 0 0 1 1.0 -51 0 0 0 1 1.0 -52 0 0 0 1 1.0 -53 0 0 0 1 1.0 -54 0 0 0 1 1.0 -55 0 0 0 1 1.0 -56 0 0 0 1 1.0 -57 0 0 0 1 1.0 -58 0 0 0 1 1.0 -59 0 0 0 1 1.0 -60 0 0 0 1 1.0 -61 0 0 0 1 1.0 -62 0 0 0 1 1.0 -63 0 0 0 1 1.0 -64 0 0 0 1 1.0 -65 0 0 0 1 1.0 -66 0 0 0 1 1.0 -67 0 0 0 1 1.0 -68 0 0 0 1 1.0 -69 0 0 0 1 1.0 -70 0 0 0 1 1.0 -71 0 0 0 1 1.0 -72 0 0 0 1 1.0 -73 0 0 0 1 1.0 -74 0 0 0 1 1.0 -75 0 0 0 1 1.0 -76 0 0 0 1 1.0 -77 0 0 0 1 1.0 -78 0 0 0 1 1.0 -79 0 0 0 1 1.0 -80 0 0 0 1 1.0 -81 0 0 0 1 1.0 -82 0 0 0 1 1.0 -83 0 0 0 1 1.0 -84 0 0 0 1 1.0 -85 0 0 0 1 1.0 -86 0 0 0 1 1.0 -87 0 0 0 1 1.0 -88 0 0 0 1 1.0 -89 0 0 0 1 1.0 -90 0 0 0 1 1.0 -91 0 0 0 1 1.0 -92 0 0 0 2 1.0 -93 0 0 0 2 1.0 -94 0 0 0 2 1.0 -95 0 0 0 2 1.0 -96 0 0 0 2 1.0 -97 0 0 0 2 1.0 -98 0 0 0 2 1.0 -99 0 0 0 2 1.0 -100 0 0 0 2 1.0 -101 0 0 0 2 1.0 -102 0 0 0 2 1.0 -103 0 0 0 2 1.0 -104 0 0 0 2 1.0 -105 0 0 0 2 1.0 -106 0 0 0 2 1.0 -107 0 0 0 2 1.0 -108 0 0 0 2 1.0 -109 0 0 0 2 1.0 -110 0 0 0 2 1.0 -111 0 0 0 2 1.0 -112 0 0 0 2 1.0 -113 0 0 0 2 1.0 -114 0 0 0 2 1.0 -115 0 0 0 2 1.0 -116 0 0 0 2 1.0 -117 0 0 0 2 1.0 -118 0 0 0 2 1.0 -119 0 0 0 2 1.0 -120 0 0 0 2 1.0 -121 0 0 0 2 1.0 -122 0 0 0 2 1.0 -123 0 0 0 2 1.0 -124 0 0 0 2 1.0 -125 0 0 0 2 1.0 -126 0 0 0 2 1.0 -127 0 0 0 2 1.0 -128 0 0 0 2 1.0 -129 0 0 0 2 1.0 -130 0 0 0 2 1.0 -131 0 0 0 2 1.0 -132 0 0 0 2 1.0 -133 0 0 0 2 1.0 -134 0 0 0 2 1.0 -135 0 0 0 2 1.0 -136 0 0 0 2 1.0 -137 0 0 0 2 1.0 -138 0 0 0 3 1.0 -139 0 0 0 3 1.0 -140 0 0 0 3 1.0 -141 0 0 0 3 1.0 -142 0 0 0 3 1.0 -143 0 0 0 3 1.0 -144 0 0 0 3 1.0 -145 0 0 0 3 1.0 -146 0 0 0 3 1.0 -147 0 0 0 3 1.0 -148 0 0 0 3 1.0 -149 0 0 0 3 1.0 -150 0 0 0 3 1.0 -151 0 0 0 3 1.0 -152 0 0 0 3 1.0 -153 0 0 0 3 1.0 -154 0 0 0 3 1.0 -155 0 0 0 3 1.0 -156 0 0 0 3 1.0 -157 0 0 0 3 1.0 -158 0 0 0 3 1.0 -159 0 0 0 3 1.0 -160 0 0 0 3 1.0 -161 0 0 0 3 1.0 -162 0 0 0 3 1.0 -163 0 0 0 3 1.0 -164 0 0 0 3 1.0 -165 0 0 0 3 1.0 -166 0 0 0 3 1.0 -167 0 0 0 3 1.0 -168 0 0 0 3 1.0 -169 0 0 0 3 1.0 -170 0 0 0 3 1.0 -171 0 0 0 3 1.0 -172 0 0 0 3 1.0 -173 0 0 0 3 1.0 -174 0 0 0 3 1.0 -175 0 0 0 3 1.0 -176 0 0 0 3 1.0 -177 0 0 0 3 1.0 -178 0 0 0 3 1.0 -179 0 0 0 3 1.0 -180 0 0 0 3 1.0 -181 0 0 0 3 1.0 -182 0 0 0 3 1.0 -183 0 0 0 3 1.0 -184 0 0 0 4 1.0 -185 0 0 0 4 1.0 -186 0 0 0 4 1.0 -187 0 0 0 4 1.0 -188 0 0 0 4 1.0 -189 0 0 0 4 1.0 -190 0 0 0 4 1.0 -191 0 0 0 4 1.0 -192 0 0 0 4 1.0 -193 0 0 0 4 1.0 -194 0 0 0 4 1.0 -195 0 0 0 4 1.0 -196 0 0 0 4 1.0 -197 0 0 0 4 1.0 -198 0 0 0 4 1.0 -199 0 0 0 4 1.0 -200 0 0 0 4 1.0 -201 0 0 0 4 1.0 -202 0 0 0 4 1.0 -203 0 0 0 4 1.0 -204 0 0 0 4 1.0 -205 0 0 0 4 1.0 -206 0 0 0 4 1.0 -207 0 0 0 4 1.0 -208 0 0 0 4 1.0 -209 0 0 0 4 1.0 -210 0 0 0 4 1.0 -211 0 0 0 4 1.0 -212 0 0 0 4 1.0 -213 0 0 0 4 1.0 -214 0 0 0 4 1.0 -215 0 0 0 4 1.0 -216 0 0 0 4 1.0 -217 0 0 0 4 1.0 -218 0 0 0 4 1.0 -219 0 0 0 4 1.0 -220 0 0 0 4 1.0 -221 0 0 0 4 1.0 -222 0 0 0 4 1.0 -223 0 0 0 4 1.0 -224 0 0 0 4 1.0 -225 0 0 0 4 1.0 -226 0 0 0 4 1.0 -227 0 0 0 4 1.0 -228 0 0 0 4 1.0 -229 0 0 0 4 1.0 -230 0 0 0 5 1.0 -231 0 0 0 5 1.0 -232 0 0 0 5 1.0 -233 0 0 0 5 1.0 -234 0 0 0 5 1.0 -235 0 0 0 5 1.0 -236 0 0 0 5 1.0 -237 0 0 0 5 1.0 -238 0 0 0 5 1.0 -239 0 0 0 5 1.0 -240 0 0 0 5 1.0 -241 0 0 0 5 1.0 -242 0 0 0 5 1.0 -243 0 0 0 5 1.0 -244 0 0 0 5 1.0 -245 0 0 0 5 1.0 -246 0 0 0 5 1.0 -247 0 0 0 5 1.0 -248 0 0 0 5 1.0 -249 0 0 0 5 1.0 -250 0 0 0 5 1.0 -251 0 0 0 5 1.0 -252 0 0 0 5 1.0 -253 0 0 0 5 1.0 -254 0 0 0 5 1.0 -255 0 0 0 5 1.0 -256 0 0 0 5 1.0 -257 0 0 0 5 1.0 -258 0 0 0 5 1.0 -259 0 0 0 5 1.0 -260 0 0 0 5 1.0 -261 0 0 0 5 1.0 -262 0 0 0 5 1.0 -263 0 0 0 5 1.0 -264 0 0 0 5 1.0 -265 0 0 0 5 1.0 -266 0 0 0 5 1.0 -267 0 0 0 5 1.0 -268 0 0 0 5 1.0 -269 0 0 0 5 1.0 -270 0 0 0 5 1.0 -271 0 0 0 5 1.0 -272 0 0 0 5 1.0 -273 0 0 0 5 1.0 -274 0 0 0 5 1.0 -275 0 0 0 5 1.0 -276 0 0 0 6 1.0 -277 0 0 0 6 1.0 -278 0 0 0 6 1.0 -279 0 0 0 6 1.0 -280 0 0 0 6 1.0 -281 0 0 0 6 1.0 -282 0 0 0 6 1.0 -283 0 0 0 6 1.0 -284 0 0 0 6 1.0 -285 0 0 0 6 1.0 -286 0 0 0 6 1.0 -287 0 0 0 6 1.0 -288 0 0 0 6 1.0 -289 0 0 0 6 1.0 -290 0 0 0 6 1.0 -291 0 0 0 6 1.0 -292 0 0 0 6 1.0 -293 0 0 0 6 1.0 -294 0 0 0 6 1.0 -295 0 0 0 6 1.0 -296 0 0 0 6 1.0 -297 0 0 0 6 1.0 -298 0 0 0 6 1.0 -299 0 0 0 6 1.0 -300 0 0 0 6 1.0 -301 0 0 0 6 1.0 -302 0 0 0 6 1.0 -303 0 0 0 6 1.0 -304 0 0 0 6 1.0 -305 0 0 0 6 1.0 -306 0 0 0 6 1.0 -307 0 0 0 6 1.0 -308 0 0 0 6 1.0 -309 0 0 0 6 1.0 -310 0 0 0 6 1.0 -311 0 0 0 6 1.0 -312 0 0 0 6 1.0 -313 0 0 0 6 1.0 -314 0 0 0 6 1.0 -315 0 0 0 6 1.0 -316 0 0 0 6 1.0 -317 0 0 0 6 1.0 -318 0 0 0 6 1.0 -319 0 0 0 6 1.0 -320 0 0 0 6 1.0 -321 0 0 0 6 1.0 -322 0 0 0 7 1.0 -323 0 0 0 7 1.0 -324 0 0 0 7 1.0 -325 0 0 0 7 1.0 -326 0 0 0 7 1.0 -327 0 0 0 7 1.0 -328 0 0 0 7 1.0 -329 0 0 0 7 1.0 -330 0 0 0 7 1.0 -331 0 0 0 7 1.0 -332 0 0 0 7 1.0 -333 0 0 0 7 1.0 -334 0 0 0 7 1.0 -335 0 0 0 7 1.0 -336 0 0 0 7 1.0 -337 0 0 0 7 1.0 -338 0 0 0 7 1.0 -339 0 0 0 7 1.0 -340 0 0 0 7 1.0 -341 0 0 0 7 1.0 -342 0 0 0 7 1.0 -343 0 0 0 7 1.0 -344 0 0 0 7 1.0 -345 0 0 0 7 1.0 -346 0 0 0 7 1.0 -347 0 0 0 7 1.0 -348 0 0 0 7 1.0 -349 0 0 0 7 1.0 -350 0 0 0 7 1.0 -351 0 0 0 7 1.0 -352 0 0 0 7 1.0 -353 0 0 0 7 1.0 -354 0 0 0 7 1.0 -355 0 0 0 7 1.0 -356 0 0 0 7 1.0 -357 0 0 0 7 1.0 -358 0 0 0 7 1.0 -359 0 0 0 7 1.0 -360 0 0 0 7 1.0 -361 0 0 0 7 1.0 -362 0 0 0 7 1.0 -363 0 0 0 7 1.0 -364 0 0 0 7 1.0 -365 0 0 0 7 1.0 -366 0 0 0 7 1.0 -367 0 0 0 7 1.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg deleted file mode 100755 index 1a5d2889b95..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/config.cfg +++ /dev/null @@ -1,28 +0,0 @@ -SOLVER= MULTIPHYSICS -MATH_PROBLEM= DIRECT -CONFIG_LIST=(configFlow.cfg, configFEA.cfg) - -MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) - -CONSERVATIVE_INTERPOLATION= NO - -READ_BINARY_RESTART= NO - -OUTER_ITER= 40 -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 - -TIME_DOMAIN = YES -TIME_ITER = 10 -TIME_STEP = 0.01 -UNST_ADJOINT_ITER= 10 -ITER_AVERAGE_OBJ= 10 - -OBJECTIVE_FUNCTION= REFERENCE_NODE - -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] - -WRT_ZONE_HIST=YES -%WRT_ZONE_CONV=YES - -% Debug: Force Zero Grid Velocity = NO -WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg deleted file mode 100755 index 612823c7556..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFEA.cfg +++ /dev/null @@ -1,65 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= ELASTICITY -% -% Time settings --------------------------------------------------------- % -TIME_DISCRE_FEA= NEWMARK_IMPLICIT -NEWMARK_BETA=0.2601 -NEWMARK_GAMMA=0.52 -% -% Optimization --------------------------------------------------------- % -FEA_ADVANCED_MODE= YES -FEA_FILENAME= element_properties.dat -GRAD_OBJFUNC_FILENAME= of_grad.dat -REFERENCE_NODE= 234 -REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) -REFERENCE_NODE_PENALTY= 1.0 -DESIGN_VARIABLE_FEA= YOUNG_MODULUS -% -% Solid properties ----------------------------------------------------- % -MATERIAL_MODEL= NEO_HOOKEAN -ELASTICITY_MODULUS= 7E8 -POISSON_RATIO= 0.35 -MATERIAL_DENSITY= 2700.0 -% -% Boundary conditions -------------------------------------------------- % -MARKER_CLAMPED= ( clamped ) -MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) -% -% Solid numerics ------------------------------------------------------- % -GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS -FORMULATION_ELASTICITY_2D= PLANE_STRESS -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= CONJUGATE_GRADIENT -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-8 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT -DISCADJ_LIN_PREC= ILU -% -% Convergence criteria ------------------------------------------------- % -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -INNER_ITER= 11 -% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. -INCREMENTAL_LOAD= NO -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_solid.dat -SOLUTION_ADJ_FILENAME= adjoint_solid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_solid.dat -RESTART_ADJ_FILENAME= adjoint_solid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= solid -VOLUME_ADJ_FILENAME= adjoint_solid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF -OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg deleted file mode 100755 index b83b3ecc111..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/configFlow.cfg +++ /dev/null @@ -1,105 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= EULER -KIND_TURB_MODEL= NONE -% -% Time settings --------------------------------------------------------- % -TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER -% -% Optimization --------------------------------------------------------- % -GRAD_OBJFUNC_FILENAME= of_grad.dat -% -% Compressible free-stream conditions ---------------------------------- % -MACH_NUMBER= 0.8 -AOA= 5.0 -INIT_OPTION= TD_CONDITIONS -FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 101325.0 -FREESTREAM_TEMPERATURE= 273.15 -REYNOLDS_LENGTH= 0.5 -% -% Fluid properties ----------------------------------------------------- % -FLUID_MODEL= IDEAL_GAS -GAMMA_VALUE= 1.4 -GAS_CONSTANT= 287.87 -VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 1.716E-5 -% -% Boundary conditions -------------------------------------------------- % -MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, pressure_side, suction_side) -MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) -DEFORM_MESH= YES -% -% Post processing and monitoring --------------------------------------- % -REF_ORIGIN_MOMENT_X= -0.125 -REF_ORIGIN_MOMENT_Y= 0.00 -REF_ORIGIN_MOMENT_Z= 0.00 -REF_LENGTH= 0.5 -REF_AREA= 0.5 -MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) -MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) -MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) -% -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 15.0 -% -% Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-3 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= BCGSTAB -DISCADJ_LIN_PREC= ILU -% Multigrid -MGLEVEL= 2 -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) -MG_DAMP_RESTRICTION= 0.75 -MG_DAMP_PROLONGATION= 0.75 -% -DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT -DEFORM_LINEAR_SOLVER_PREC= ILU -DEFORM_LINEAR_SOLVER_ERROR= 1e-8 -DEFORM_LINEAR_SOLVER_ITER= 1000 -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME -DEFORM_POISSONS_RATIO= 1e6 -% -% Convergence criteria ------------------------------------------------- % -% interaction -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -% fluid -INNER_ITER= 51 -CONV_STARTITER= 0 -CONV_RESIDUAL_MINVAL= -9 -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_fluid.dat -SOLUTION_ADJ_FILENAME= adjoint_fluid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_fluid.dat -RESTART_ADJ_FILENAME= adjoint_fluid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= fluid -VOLUME_ADJ_FILENAME= adjoint_fluid -SURFACE_FILENAME= surface_fluid -SURFACE_ADJ_FILENAME= adjoint_surface_fluid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF -OUTPUT_FILES= NONE diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt deleted file mode 100644 index 4cff5b6d58b..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/dv_young.opt +++ /dev/null @@ -1,9 +0,0 @@ -INDEX VAL SCALE LOWER_BOUND UPPER_BOUND -0 1.001 1 0.01 100.0 -1 1 1 0.01 100.0 -2 1 1 0.01 100.0 -3 1 1 0.01 100.0 -4 1 1 0.01 100.0 -5 1 1 0.01 100.0 -6 1 1 0.01 100.0 -7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat deleted file mode 100644 index 90421c13042..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/FD_DV_0/element_properties_1.dat +++ /dev/null @@ -1,369 +0,0 @@ -INDEX MMOD MPROP ELPROP DV DENSITY -0 0 0 0 0 1.0 -1 0 0 0 0 1.0 -2 0 0 0 0 1.0 -3 0 0 0 0 1.0 -4 0 0 0 0 1.0 -5 0 0 0 0 1.0 -6 0 0 0 0 1.0 -7 0 0 0 0 1.0 -8 0 0 0 0 1.0 -9 0 0 0 0 1.0 -10 0 0 0 0 1.0 -11 0 0 0 0 1.0 -12 0 0 0 0 1.0 -13 0 0 0 0 1.0 -14 0 0 0 0 1.0 -15 0 0 0 0 1.0 -16 0 0 0 0 1.0 -17 0 0 0 0 1.0 -18 0 0 0 0 1.0 -19 0 0 0 0 1.0 -20 0 0 0 0 1.0 -21 0 0 0 0 1.0 -22 0 0 0 0 1.0 -23 0 0 0 0 1.0 -24 0 0 0 0 1.0 -25 0 0 0 0 1.0 -26 0 0 0 0 1.0 -27 0 0 0 0 1.0 -28 0 0 0 0 1.0 -29 0 0 0 0 1.0 -30 0 0 0 0 1.0 -31 0 0 0 0 1.0 -32 0 0 0 0 1.0 -33 0 0 0 0 1.0 -34 0 0 0 0 1.0 -35 0 0 0 0 1.0 -36 0 0 0 0 1.0 -37 0 0 0 0 1.0 -38 0 0 0 0 1.0 -39 0 0 0 0 1.0 -40 0 0 0 0 1.0 -41 0 0 0 0 1.0 -42 0 0 0 0 1.0 -43 0 0 0 0 1.0 -44 0 0 0 0 1.0 -45 0 0 0 0 1.0 -46 0 0 0 1 1.0 -47 0 0 0 1 1.0 -48 0 0 0 1 1.0 -49 0 0 0 1 1.0 -50 0 0 0 1 1.0 -51 0 0 0 1 1.0 -52 0 0 0 1 1.0 -53 0 0 0 1 1.0 -54 0 0 0 1 1.0 -55 0 0 0 1 1.0 -56 0 0 0 1 1.0 -57 0 0 0 1 1.0 -58 0 0 0 1 1.0 -59 0 0 0 1 1.0 -60 0 0 0 1 1.0 -61 0 0 0 1 1.0 -62 0 0 0 1 1.0 -63 0 0 0 1 1.0 -64 0 0 0 1 1.0 -65 0 0 0 1 1.0 -66 0 0 0 1 1.0 -67 0 0 0 1 1.0 -68 0 0 0 1 1.0 -69 0 0 0 1 1.0 -70 0 0 0 1 1.0 -71 0 0 0 1 1.0 -72 0 0 0 1 1.0 -73 0 0 0 1 1.0 -74 0 0 0 1 1.0 -75 0 0 0 1 1.0 -76 0 0 0 1 1.0 -77 0 0 0 1 1.0 -78 0 0 0 1 1.0 -79 0 0 0 1 1.0 -80 0 0 0 1 1.0 -81 0 0 0 1 1.0 -82 0 0 0 1 1.0 -83 0 0 0 1 1.0 -84 0 0 0 1 1.0 -85 0 0 0 1 1.0 -86 0 0 0 1 1.0 -87 0 0 0 1 1.0 -88 0 0 0 1 1.0 -89 0 0 0 1 1.0 -90 0 0 0 1 1.0 -91 0 0 0 1 1.0 -92 0 0 0 2 1.0 -93 0 0 0 2 1.0 -94 0 0 0 2 1.0 -95 0 0 0 2 1.0 -96 0 0 0 2 1.0 -97 0 0 0 2 1.0 -98 0 0 0 2 1.0 -99 0 0 0 2 1.0 -100 0 0 0 2 1.0 -101 0 0 0 2 1.0 -102 0 0 0 2 1.0 -103 0 0 0 2 1.0 -104 0 0 0 2 1.0 -105 0 0 0 2 1.0 -106 0 0 0 2 1.0 -107 0 0 0 2 1.0 -108 0 0 0 2 1.0 -109 0 0 0 2 1.0 -110 0 0 0 2 1.0 -111 0 0 0 2 1.0 -112 0 0 0 2 1.0 -113 0 0 0 2 1.0 -114 0 0 0 2 1.0 -115 0 0 0 2 1.0 -116 0 0 0 2 1.0 -117 0 0 0 2 1.0 -118 0 0 0 2 1.0 -119 0 0 0 2 1.0 -120 0 0 0 2 1.0 -121 0 0 0 2 1.0 -122 0 0 0 2 1.0 -123 0 0 0 2 1.0 -124 0 0 0 2 1.0 -125 0 0 0 2 1.0 -126 0 0 0 2 1.0 -127 0 0 0 2 1.0 -128 0 0 0 2 1.0 -129 0 0 0 2 1.0 -130 0 0 0 2 1.0 -131 0 0 0 2 1.0 -132 0 0 0 2 1.0 -133 0 0 0 2 1.0 -134 0 0 0 2 1.0 -135 0 0 0 2 1.0 -136 0 0 0 2 1.0 -137 0 0 0 2 1.0 -138 0 0 0 3 1.0 -139 0 0 0 3 1.0 -140 0 0 0 3 1.0 -141 0 0 0 3 1.0 -142 0 0 0 3 1.0 -143 0 0 0 3 1.0 -144 0 0 0 3 1.0 -145 0 0 0 3 1.0 -146 0 0 0 3 1.0 -147 0 0 0 3 1.0 -148 0 0 0 3 1.0 -149 0 0 0 3 1.0 -150 0 0 0 3 1.0 -151 0 0 0 3 1.0 -152 0 0 0 3 1.0 -153 0 0 0 3 1.0 -154 0 0 0 3 1.0 -155 0 0 0 3 1.0 -156 0 0 0 3 1.0 -157 0 0 0 3 1.0 -158 0 0 0 3 1.0 -159 0 0 0 3 1.0 -160 0 0 0 3 1.0 -161 0 0 0 3 1.0 -162 0 0 0 3 1.0 -163 0 0 0 3 1.0 -164 0 0 0 3 1.0 -165 0 0 0 3 1.0 -166 0 0 0 3 1.0 -167 0 0 0 3 1.0 -168 0 0 0 3 1.0 -169 0 0 0 3 1.0 -170 0 0 0 3 1.0 -171 0 0 0 3 1.0 -172 0 0 0 3 1.0 -173 0 0 0 3 1.0 -174 0 0 0 3 1.0 -175 0 0 0 3 1.0 -176 0 0 0 3 1.0 -177 0 0 0 3 1.0 -178 0 0 0 3 1.0 -179 0 0 0 3 1.0 -180 0 0 0 3 1.0 -181 0 0 0 3 1.0 -182 0 0 0 3 1.0 -183 0 0 0 3 1.0 -184 0 0 0 4 1.0 -185 0 0 0 4 1.0 -186 0 0 0 4 1.0 -187 0 0 0 4 1.0 -188 0 0 0 4 1.0 -189 0 0 0 4 1.0 -190 0 0 0 4 1.0 -191 0 0 0 4 1.0 -192 0 0 0 4 1.0 -193 0 0 0 4 1.0 -194 0 0 0 4 1.0 -195 0 0 0 4 1.0 -196 0 0 0 4 1.0 -197 0 0 0 4 1.0 -198 0 0 0 4 1.0 -199 0 0 0 4 1.0 -200 0 0 0 4 1.0 -201 0 0 0 4 1.0 -202 0 0 0 4 1.0 -203 0 0 0 4 1.0 -204 0 0 0 4 1.0 -205 0 0 0 4 1.0 -206 0 0 0 4 1.0 -207 0 0 0 4 1.0 -208 0 0 0 4 1.0 -209 0 0 0 4 1.0 -210 0 0 0 4 1.0 -211 0 0 0 4 1.0 -212 0 0 0 4 1.0 -213 0 0 0 4 1.0 -214 0 0 0 4 1.0 -215 0 0 0 4 1.0 -216 0 0 0 4 1.0 -217 0 0 0 4 1.0 -218 0 0 0 4 1.0 -219 0 0 0 4 1.0 -220 0 0 0 4 1.0 -221 0 0 0 4 1.0 -222 0 0 0 4 1.0 -223 0 0 0 4 1.0 -224 0 0 0 4 1.0 -225 0 0 0 4 1.0 -226 0 0 0 4 1.0 -227 0 0 0 4 1.0 -228 0 0 0 4 1.0 -229 0 0 0 4 1.0 -230 0 0 0 5 1.0 -231 0 0 0 5 1.0 -232 0 0 0 5 1.0 -233 0 0 0 5 1.0 -234 0 0 0 5 1.0 -235 0 0 0 5 1.0 -236 0 0 0 5 1.0 -237 0 0 0 5 1.0 -238 0 0 0 5 1.0 -239 0 0 0 5 1.0 -240 0 0 0 5 1.0 -241 0 0 0 5 1.0 -242 0 0 0 5 1.0 -243 0 0 0 5 1.0 -244 0 0 0 5 1.0 -245 0 0 0 5 1.0 -246 0 0 0 5 1.0 -247 0 0 0 5 1.0 -248 0 0 0 5 1.0 -249 0 0 0 5 1.0 -250 0 0 0 5 1.0 -251 0 0 0 5 1.0 -252 0 0 0 5 1.0 -253 0 0 0 5 1.0 -254 0 0 0 5 1.0 -255 0 0 0 5 1.0 -256 0 0 0 5 1.0 -257 0 0 0 5 1.0 -258 0 0 0 5 1.0 -259 0 0 0 5 1.0 -260 0 0 0 5 1.0 -261 0 0 0 5 1.0 -262 0 0 0 5 1.0 -263 0 0 0 5 1.0 -264 0 0 0 5 1.0 -265 0 0 0 5 1.0 -266 0 0 0 5 1.0 -267 0 0 0 5 1.0 -268 0 0 0 5 1.0 -269 0 0 0 5 1.0 -270 0 0 0 5 1.0 -271 0 0 0 5 1.0 -272 0 0 0 5 1.0 -273 0 0 0 5 1.0 -274 0 0 0 5 1.0 -275 0 0 0 5 1.0 -276 0 0 0 6 1.0 -277 0 0 0 6 1.0 -278 0 0 0 6 1.0 -279 0 0 0 6 1.0 -280 0 0 0 6 1.0 -281 0 0 0 6 1.0 -282 0 0 0 6 1.0 -283 0 0 0 6 1.0 -284 0 0 0 6 1.0 -285 0 0 0 6 1.0 -286 0 0 0 6 1.0 -287 0 0 0 6 1.0 -288 0 0 0 6 1.0 -289 0 0 0 6 1.0 -290 0 0 0 6 1.0 -291 0 0 0 6 1.0 -292 0 0 0 6 1.0 -293 0 0 0 6 1.0 -294 0 0 0 6 1.0 -295 0 0 0 6 1.0 -296 0 0 0 6 1.0 -297 0 0 0 6 1.0 -298 0 0 0 6 1.0 -299 0 0 0 6 1.0 -300 0 0 0 6 1.0 -301 0 0 0 6 1.0 -302 0 0 0 6 1.0 -303 0 0 0 6 1.0 -304 0 0 0 6 1.0 -305 0 0 0 6 1.0 -306 0 0 0 6 1.0 -307 0 0 0 6 1.0 -308 0 0 0 6 1.0 -309 0 0 0 6 1.0 -310 0 0 0 6 1.0 -311 0 0 0 6 1.0 -312 0 0 0 6 1.0 -313 0 0 0 6 1.0 -314 0 0 0 6 1.0 -315 0 0 0 6 1.0 -316 0 0 0 6 1.0 -317 0 0 0 6 1.0 -318 0 0 0 6 1.0 -319 0 0 0 6 1.0 -320 0 0 0 6 1.0 -321 0 0 0 6 1.0 -322 0 0 0 7 1.0 -323 0 0 0 7 1.0 -324 0 0 0 7 1.0 -325 0 0 0 7 1.0 -326 0 0 0 7 1.0 -327 0 0 0 7 1.0 -328 0 0 0 7 1.0 -329 0 0 0 7 1.0 -330 0 0 0 7 1.0 -331 0 0 0 7 1.0 -332 0 0 0 7 1.0 -333 0 0 0 7 1.0 -334 0 0 0 7 1.0 -335 0 0 0 7 1.0 -336 0 0 0 7 1.0 -337 0 0 0 7 1.0 -338 0 0 0 7 1.0 -339 0 0 0 7 1.0 -340 0 0 0 7 1.0 -341 0 0 0 7 1.0 -342 0 0 0 7 1.0 -343 0 0 0 7 1.0 -344 0 0 0 7 1.0 -345 0 0 0 7 1.0 -346 0 0 0 7 1.0 -347 0 0 0 7 1.0 -348 0 0 0 7 1.0 -349 0 0 0 7 1.0 -350 0 0 0 7 1.0 -351 0 0 0 7 1.0 -352 0 0 0 7 1.0 -353 0 0 0 7 1.0 -354 0 0 0 7 1.0 -355 0 0 0 7 1.0 -356 0 0 0 7 1.0 -357 0 0 0 7 1.0 -358 0 0 0 7 1.0 -359 0 0 0 7 1.0 -360 0 0 0 7 1.0 -361 0 0 0 7 1.0 -362 0 0 0 7 1.0 -363 0 0 0 7 1.0 -364 0 0 0 7 1.0 -365 0 0 0 7 1.0 -366 0 0 0 7 1.0 -367 0 0 0 7 1.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg deleted file mode 100755 index 1a5d2889b95..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Primal/config.cfg +++ /dev/null @@ -1,28 +0,0 @@ -SOLVER= MULTIPHYSICS -MATH_PROBLEM= DIRECT -CONFIG_LIST=(configFlow.cfg, configFEA.cfg) - -MARKER_ZONE_INTERFACE= (pressure_side,pressure_side_s, suction_side,suction_side_s) - -CONSERVATIVE_INTERPOLATION= NO - -READ_BINARY_RESTART= NO - -OUTER_ITER= 40 -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 - -TIME_DOMAIN = YES -TIME_ITER = 10 -TIME_STEP = 0.01 -UNST_ADJOINT_ITER= 10 -ITER_AVERAGE_OBJ= 10 - -OBJECTIVE_FUNCTION= REFERENCE_NODE - -SCREEN_OUTPUT= OUTER_ITER, AVG_BGS_RES[0], SENS_E[1] - -WRT_ZONE_HIST=YES -%WRT_ZONE_CONV=YES - -% Debug: Force Zero Grid Velocity = NO -WRT_PERFORMANCE= NO diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg deleted file mode 100755 index 3f9b2f174c9..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFEA.cfg +++ /dev/null @@ -1,65 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= ELASTICITY -% -% Time settings --------------------------------------------------------- % -TIME_DISCRE_FEA= NEWMARK_IMPLICIT -NEWMARK_BETA=0.2601 -NEWMARK_GAMMA=0.52 -% -% Optimization --------------------------------------------------------- % -FEA_ADVANCED_MODE= YES -FEA_FILENAME= element_properties.dat -GRAD_OBJFUNC_FILENAME= of_grad.dat -REFERENCE_NODE= 234 -REFERENCE_NODE_DISPLACEMENT= (0.0, 0.0) -REFERENCE_NODE_PENALTY= 1.0 -DESIGN_VARIABLE_FEA= YOUNG_MODULUS -% -% Solid properties ----------------------------------------------------- % -MATERIAL_MODEL= NEO_HOOKEAN -ELASTICITY_MODULUS= 7E8 -POISSON_RATIO= 0.35 -MATERIAL_DENSITY= 2700.0 -% -% Boundary conditions -------------------------------------------------- % -MARKER_CLAMPED= ( clamped ) -MARKER_FLUID_LOAD= ( pressure_side_s, suction_side_s ) -% -% Solid numerics ------------------------------------------------------- % -GEOMETRIC_CONDITIONS= LARGE_DEFORMATIONS -FORMULATION_ELASTICITY_2D= PLANE_STRESS -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= CONJUGATE_GRADIENT -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-8 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= CONJUGATE_GRADIENT -DISCADJ_LIN_PREC= ILU -% -% Convergence criteria ------------------------------------------------- % -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -INNER_ITER= 11 -% Incremental load on to test that it does not break the discadj, it should only affect the direct solution. -INCREMENTAL_LOAD= NO -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_solid.dat -SOLUTION_ADJ_FILENAME= adjoint_solid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_solid.dat -RESTART_ADJ_FILENAME= adjoint_solid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= solid -VOLUME_ADJ_FILENAME= adjoint_solid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, STRUCT_COEFF, TAVG_STRUCT_COEFF -OUTPUT_FILES= RESTART_ASCII diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg deleted file mode 100755 index 9f0eddf9c23..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Primal/configFlow.cfg +++ /dev/null @@ -1,105 +0,0 @@ -% Physics -------------------------------------------------------------- % -SOLVER= EULER -KIND_TURB_MODEL= NONE -% -% Time settings --------------------------------------------------------- % -TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER -% -% Optimization --------------------------------------------------------- % -GRAD_OBJFUNC_FILENAME= of_grad.dat -% -% Compressible free-stream conditions ---------------------------------- % -MACH_NUMBER= 0.8 -AOA= 5.0 -INIT_OPTION= TD_CONDITIONS -FREESTREAM_OPTION= TEMPERATURE_FS -FREESTREAM_PRESSURE= 101325.0 -FREESTREAM_TEMPERATURE= 273.15 -REYNOLDS_LENGTH= 0.5 -% -% Fluid properties ----------------------------------------------------- % -FLUID_MODEL= IDEAL_GAS -GAMMA_VALUE= 1.4 -GAS_CONSTANT= 287.87 -VISCOSITY_MODEL= CONSTANT_VISCOSITY -MU_CONSTANT= 1.716E-5 -% -% Boundary conditions -------------------------------------------------- % -MARKER_FAR= ( farfield ) -MARKER_EULER= ( leading_edge, pressure_side, suction_side) -MARKER_DEFORM_MESH= ( leading_edge, pressure_side, suction_side ) -DEFORM_MESH= YES -% -% Post processing and monitoring --------------------------------------- % -REF_ORIGIN_MOMENT_X= -0.125 -REF_ORIGIN_MOMENT_Y= 0.00 -REF_ORIGIN_MOMENT_Z= 0.00 -REF_LENGTH= 0.5 -REF_AREA= 0.5 -MARKER_PLOTTING= ( leading_edge, pressure_side, suction_side ) -MARKER_MONITORING= ( leading_edge, pressure_side, suction_side ) -MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) -% -% Common numerics settings --------------------------------------------- % -REF_DIMENSIONALIZATION= DIMENSIONAL -NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 15.0 -% -% Flow numerics -------------------------------------------------------- % -CONV_NUM_METHOD_FLOW= JST -JST_SENSOR_COEFF= ( 0.5, 0.02 ) -TIME_DISCRE_FLOW= EULER_IMPLICIT -% -% Linear solvers ------------------------------------------------------- % -LINEAR_SOLVER= BCGSTAB -LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-3 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= BCGSTAB -DISCADJ_LIN_PREC= ILU -% Multigrid -MGLEVEL= 2 -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) -MG_DAMP_RESTRICTION= 0.75 -MG_DAMP_PROLONGATION= 0.75 -% -DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT -DEFORM_LINEAR_SOLVER_PREC= ILU -DEFORM_LINEAR_SOLVER_ERROR= 1e-8 -DEFORM_LINEAR_SOLVER_ITER= 1000 -DEFORM_STIFFNESS_TYPE= INVERSE_VOLUME -DEFORM_POISSONS_RATIO= 1e6 -% -% Convergence criteria ------------------------------------------------- % -% interaction -BGS_RELAXATION= FIXED_PARAMETER -STAT_RELAX_PARAMETER= 1.0 -% fluid -INNER_ITER= 51 -CONV_STARTITER= 0 -CONV_RESIDUAL_MINVAL= -9 -% -% In\Out --------------------------------------------------------------- % -MESH_FILENAME= ../../Airfoil_2d/mesh.su2 -MESH_FORMAT= SU2 -% -RESTART_SOL= NO -SOLUTION_FILENAME= solution_fluid.dat -SOLUTION_ADJ_FILENAME= adjoint_fluid.dat -OUTPUT_WRT_FREQ= 1 -RESTART_FILENAME= solution_fluid.dat -RESTART_ADJ_FILENAME= adjoint_fluid.dat -% -TABULAR_FORMAT= CSV -VOLUME_FILENAME= fluid -VOLUME_ADJ_FILENAME= adjoint_fluid -SURFACE_FILENAME= surface_fluid -SURFACE_ADJ_FILENAME= adjoint_surface_fluid -% -SCREEN_WRT_FREQ_INNER= 10 -CONV_FILENAME= history -HISTORY_OUTPUT= ITER, RMS_RES, AERO_COEFF, TAVG_AERO_COEFF -OUTPUT_FILES= RESTART_ASCII diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt b/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt deleted file mode 100644 index 3c691471847..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Primal/dv_young.opt +++ /dev/null @@ -1,9 +0,0 @@ -INDEX VAL SCALE LOWER_BOUND UPPER_BOUND -0 1 1 0.01 100.0 -1 1 1 0.01 100.0 -2 1 1 0.01 100.0 -3 1 1 0.01 100.0 -4 1 1 0.01 100.0 -5 1 1 0.01 100.0 -6 1 1 0.01 100.0 -7 1 1 0.01 100.0 diff --git a/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat b/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat deleted file mode 100644 index 90421c13042..00000000000 --- a/TestCases/disc_adj_fsi/dyn_fsi/Primal/element_properties_1.dat +++ /dev/null @@ -1,369 +0,0 @@ -INDEX MMOD MPROP ELPROP DV DENSITY -0 0 0 0 0 1.0 -1 0 0 0 0 1.0 -2 0 0 0 0 1.0 -3 0 0 0 0 1.0 -4 0 0 0 0 1.0 -5 0 0 0 0 1.0 -6 0 0 0 0 1.0 -7 0 0 0 0 1.0 -8 0 0 0 0 1.0 -9 0 0 0 0 1.0 -10 0 0 0 0 1.0 -11 0 0 0 0 1.0 -12 0 0 0 0 1.0 -13 0 0 0 0 1.0 -14 0 0 0 0 1.0 -15 0 0 0 0 1.0 -16 0 0 0 0 1.0 -17 0 0 0 0 1.0 -18 0 0 0 0 1.0 -19 0 0 0 0 1.0 -20 0 0 0 0 1.0 -21 0 0 0 0 1.0 -22 0 0 0 0 1.0 -23 0 0 0 0 1.0 -24 0 0 0 0 1.0 -25 0 0 0 0 1.0 -26 0 0 0 0 1.0 -27 0 0 0 0 1.0 -28 0 0 0 0 1.0 -29 0 0 0 0 1.0 -30 0 0 0 0 1.0 -31 0 0 0 0 1.0 -32 0 0 0 0 1.0 -33 0 0 0 0 1.0 -34 0 0 0 0 1.0 -35 0 0 0 0 1.0 -36 0 0 0 0 1.0 -37 0 0 0 0 1.0 -38 0 0 0 0 1.0 -39 0 0 0 0 1.0 -40 0 0 0 0 1.0 -41 0 0 0 0 1.0 -42 0 0 0 0 1.0 -43 0 0 0 0 1.0 -44 0 0 0 0 1.0 -45 0 0 0 0 1.0 -46 0 0 0 1 1.0 -47 0 0 0 1 1.0 -48 0 0 0 1 1.0 -49 0 0 0 1 1.0 -50 0 0 0 1 1.0 -51 0 0 0 1 1.0 -52 0 0 0 1 1.0 -53 0 0 0 1 1.0 -54 0 0 0 1 1.0 -55 0 0 0 1 1.0 -56 0 0 0 1 1.0 -57 0 0 0 1 1.0 -58 0 0 0 1 1.0 -59 0 0 0 1 1.0 -60 0 0 0 1 1.0 -61 0 0 0 1 1.0 -62 0 0 0 1 1.0 -63 0 0 0 1 1.0 -64 0 0 0 1 1.0 -65 0 0 0 1 1.0 -66 0 0 0 1 1.0 -67 0 0 0 1 1.0 -68 0 0 0 1 1.0 -69 0 0 0 1 1.0 -70 0 0 0 1 1.0 -71 0 0 0 1 1.0 -72 0 0 0 1 1.0 -73 0 0 0 1 1.0 -74 0 0 0 1 1.0 -75 0 0 0 1 1.0 -76 0 0 0 1 1.0 -77 0 0 0 1 1.0 -78 0 0 0 1 1.0 -79 0 0 0 1 1.0 -80 0 0 0 1 1.0 -81 0 0 0 1 1.0 -82 0 0 0 1 1.0 -83 0 0 0 1 1.0 -84 0 0 0 1 1.0 -85 0 0 0 1 1.0 -86 0 0 0 1 1.0 -87 0 0 0 1 1.0 -88 0 0 0 1 1.0 -89 0 0 0 1 1.0 -90 0 0 0 1 1.0 -91 0 0 0 1 1.0 -92 0 0 0 2 1.0 -93 0 0 0 2 1.0 -94 0 0 0 2 1.0 -95 0 0 0 2 1.0 -96 0 0 0 2 1.0 -97 0 0 0 2 1.0 -98 0 0 0 2 1.0 -99 0 0 0 2 1.0 -100 0 0 0 2 1.0 -101 0 0 0 2 1.0 -102 0 0 0 2 1.0 -103 0 0 0 2 1.0 -104 0 0 0 2 1.0 -105 0 0 0 2 1.0 -106 0 0 0 2 1.0 -107 0 0 0 2 1.0 -108 0 0 0 2 1.0 -109 0 0 0 2 1.0 -110 0 0 0 2 1.0 -111 0 0 0 2 1.0 -112 0 0 0 2 1.0 -113 0 0 0 2 1.0 -114 0 0 0 2 1.0 -115 0 0 0 2 1.0 -116 0 0 0 2 1.0 -117 0 0 0 2 1.0 -118 0 0 0 2 1.0 -119 0 0 0 2 1.0 -120 0 0 0 2 1.0 -121 0 0 0 2 1.0 -122 0 0 0 2 1.0 -123 0 0 0 2 1.0 -124 0 0 0 2 1.0 -125 0 0 0 2 1.0 -126 0 0 0 2 1.0 -127 0 0 0 2 1.0 -128 0 0 0 2 1.0 -129 0 0 0 2 1.0 -130 0 0 0 2 1.0 -131 0 0 0 2 1.0 -132 0 0 0 2 1.0 -133 0 0 0 2 1.0 -134 0 0 0 2 1.0 -135 0 0 0 2 1.0 -136 0 0 0 2 1.0 -137 0 0 0 2 1.0 -138 0 0 0 3 1.0 -139 0 0 0 3 1.0 -140 0 0 0 3 1.0 -141 0 0 0 3 1.0 -142 0 0 0 3 1.0 -143 0 0 0 3 1.0 -144 0 0 0 3 1.0 -145 0 0 0 3 1.0 -146 0 0 0 3 1.0 -147 0 0 0 3 1.0 -148 0 0 0 3 1.0 -149 0 0 0 3 1.0 -150 0 0 0 3 1.0 -151 0 0 0 3 1.0 -152 0 0 0 3 1.0 -153 0 0 0 3 1.0 -154 0 0 0 3 1.0 -155 0 0 0 3 1.0 -156 0 0 0 3 1.0 -157 0 0 0 3 1.0 -158 0 0 0 3 1.0 -159 0 0 0 3 1.0 -160 0 0 0 3 1.0 -161 0 0 0 3 1.0 -162 0 0 0 3 1.0 -163 0 0 0 3 1.0 -164 0 0 0 3 1.0 -165 0 0 0 3 1.0 -166 0 0 0 3 1.0 -167 0 0 0 3 1.0 -168 0 0 0 3 1.0 -169 0 0 0 3 1.0 -170 0 0 0 3 1.0 -171 0 0 0 3 1.0 -172 0 0 0 3 1.0 -173 0 0 0 3 1.0 -174 0 0 0 3 1.0 -175 0 0 0 3 1.0 -176 0 0 0 3 1.0 -177 0 0 0 3 1.0 -178 0 0 0 3 1.0 -179 0 0 0 3 1.0 -180 0 0 0 3 1.0 -181 0 0 0 3 1.0 -182 0 0 0 3 1.0 -183 0 0 0 3 1.0 -184 0 0 0 4 1.0 -185 0 0 0 4 1.0 -186 0 0 0 4 1.0 -187 0 0 0 4 1.0 -188 0 0 0 4 1.0 -189 0 0 0 4 1.0 -190 0 0 0 4 1.0 -191 0 0 0 4 1.0 -192 0 0 0 4 1.0 -193 0 0 0 4 1.0 -194 0 0 0 4 1.0 -195 0 0 0 4 1.0 -196 0 0 0 4 1.0 -197 0 0 0 4 1.0 -198 0 0 0 4 1.0 -199 0 0 0 4 1.0 -200 0 0 0 4 1.0 -201 0 0 0 4 1.0 -202 0 0 0 4 1.0 -203 0 0 0 4 1.0 -204 0 0 0 4 1.0 -205 0 0 0 4 1.0 -206 0 0 0 4 1.0 -207 0 0 0 4 1.0 -208 0 0 0 4 1.0 -209 0 0 0 4 1.0 -210 0 0 0 4 1.0 -211 0 0 0 4 1.0 -212 0 0 0 4 1.0 -213 0 0 0 4 1.0 -214 0 0 0 4 1.0 -215 0 0 0 4 1.0 -216 0 0 0 4 1.0 -217 0 0 0 4 1.0 -218 0 0 0 4 1.0 -219 0 0 0 4 1.0 -220 0 0 0 4 1.0 -221 0 0 0 4 1.0 -222 0 0 0 4 1.0 -223 0 0 0 4 1.0 -224 0 0 0 4 1.0 -225 0 0 0 4 1.0 -226 0 0 0 4 1.0 -227 0 0 0 4 1.0 -228 0 0 0 4 1.0 -229 0 0 0 4 1.0 -230 0 0 0 5 1.0 -231 0 0 0 5 1.0 -232 0 0 0 5 1.0 -233 0 0 0 5 1.0 -234 0 0 0 5 1.0 -235 0 0 0 5 1.0 -236 0 0 0 5 1.0 -237 0 0 0 5 1.0 -238 0 0 0 5 1.0 -239 0 0 0 5 1.0 -240 0 0 0 5 1.0 -241 0 0 0 5 1.0 -242 0 0 0 5 1.0 -243 0 0 0 5 1.0 -244 0 0 0 5 1.0 -245 0 0 0 5 1.0 -246 0 0 0 5 1.0 -247 0 0 0 5 1.0 -248 0 0 0 5 1.0 -249 0 0 0 5 1.0 -250 0 0 0 5 1.0 -251 0 0 0 5 1.0 -252 0 0 0 5 1.0 -253 0 0 0 5 1.0 -254 0 0 0 5 1.0 -255 0 0 0 5 1.0 -256 0 0 0 5 1.0 -257 0 0 0 5 1.0 -258 0 0 0 5 1.0 -259 0 0 0 5 1.0 -260 0 0 0 5 1.0 -261 0 0 0 5 1.0 -262 0 0 0 5 1.0 -263 0 0 0 5 1.0 -264 0 0 0 5 1.0 -265 0 0 0 5 1.0 -266 0 0 0 5 1.0 -267 0 0 0 5 1.0 -268 0 0 0 5 1.0 -269 0 0 0 5 1.0 -270 0 0 0 5 1.0 -271 0 0 0 5 1.0 -272 0 0 0 5 1.0 -273 0 0 0 5 1.0 -274 0 0 0 5 1.0 -275 0 0 0 5 1.0 -276 0 0 0 6 1.0 -277 0 0 0 6 1.0 -278 0 0 0 6 1.0 -279 0 0 0 6 1.0 -280 0 0 0 6 1.0 -281 0 0 0 6 1.0 -282 0 0 0 6 1.0 -283 0 0 0 6 1.0 -284 0 0 0 6 1.0 -285 0 0 0 6 1.0 -286 0 0 0 6 1.0 -287 0 0 0 6 1.0 -288 0 0 0 6 1.0 -289 0 0 0 6 1.0 -290 0 0 0 6 1.0 -291 0 0 0 6 1.0 -292 0 0 0 6 1.0 -293 0 0 0 6 1.0 -294 0 0 0 6 1.0 -295 0 0 0 6 1.0 -296 0 0 0 6 1.0 -297 0 0 0 6 1.0 -298 0 0 0 6 1.0 -299 0 0 0 6 1.0 -300 0 0 0 6 1.0 -301 0 0 0 6 1.0 -302 0 0 0 6 1.0 -303 0 0 0 6 1.0 -304 0 0 0 6 1.0 -305 0 0 0 6 1.0 -306 0 0 0 6 1.0 -307 0 0 0 6 1.0 -308 0 0 0 6 1.0 -309 0 0 0 6 1.0 -310 0 0 0 6 1.0 -311 0 0 0 6 1.0 -312 0 0 0 6 1.0 -313 0 0 0 6 1.0 -314 0 0 0 6 1.0 -315 0 0 0 6 1.0 -316 0 0 0 6 1.0 -317 0 0 0 6 1.0 -318 0 0 0 6 1.0 -319 0 0 0 6 1.0 -320 0 0 0 6 1.0 -321 0 0 0 6 1.0 -322 0 0 0 7 1.0 -323 0 0 0 7 1.0 -324 0 0 0 7 1.0 -325 0 0 0 7 1.0 -326 0 0 0 7 1.0 -327 0 0 0 7 1.0 -328 0 0 0 7 1.0 -329 0 0 0 7 1.0 -330 0 0 0 7 1.0 -331 0 0 0 7 1.0 -332 0 0 0 7 1.0 -333 0 0 0 7 1.0 -334 0 0 0 7 1.0 -335 0 0 0 7 1.0 -336 0 0 0 7 1.0 -337 0 0 0 7 1.0 -338 0 0 0 7 1.0 -339 0 0 0 7 1.0 -340 0 0 0 7 1.0 -341 0 0 0 7 1.0 -342 0 0 0 7 1.0 -343 0 0 0 7 1.0 -344 0 0 0 7 1.0 -345 0 0 0 7 1.0 -346 0 0 0 7 1.0 -347 0 0 0 7 1.0 -348 0 0 0 7 1.0 -349 0 0 0 7 1.0 -350 0 0 0 7 1.0 -351 0 0 0 7 1.0 -352 0 0 0 7 1.0 -353 0 0 0 7 1.0 -354 0 0 0 7 1.0 -355 0 0 0 7 1.0 -356 0 0 0 7 1.0 -357 0 0 0 7 1.0 -358 0 0 0 7 1.0 -359 0 0 0 7 1.0 -360 0 0 0 7 1.0 -361 0 0 0 7 1.0 -362 0 0 0 7 1.0 -363 0 0 0 7 1.0 -364 0 0 0 7 1.0 -365 0 0 0 7 1.0 -366 0 0 0 7 1.0 -367 0 0 0 7 1.0 From 38afb5ed4b68d22670763866c36a62461472bd39 Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 12 May 2021 20:22:21 +0100 Subject: [PATCH 081/192] add gradient reference --- TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref diff --git a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref new file mode 100644 index 00000000000..9f9eb61496d --- /dev/null +++ b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref @@ -0,0 +1,9 @@ +INDEX GRAD +0 -3.465631559336758e-03 +1 -1.844003066470726e-03 +2 -7.925069065625049e-04 +3 -2.742895537614673e-04 +4 -2.738092746211827e-04 +5 -7.890546914650276e-04 +6 -1.831172635608937e-03 +7 -3.431364694518416e-03 From 3548413ed7ab7b312b32f3def9894e88095ad43b Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 13 May 2021 01:45:11 +0200 Subject: [PATCH 082/192] Add files for unsteady CHT adjoint and primal regression test. --- .../O_mesh_cylinder.geo | 147 +++++++++++++++++ .../disc_adj_unsteadyCHT_cylinder/README.md | 28 ++++ .../chtMaster.cfg | 151 ++++++++++++++++++ .../disc_adj_unsteadyCHT_cylinder/findiff.py | 78 +++++++++ .../disc_adj_unsteadyCHT_cylinder/fluid.cfg | 80 ++++++++++ .../postprocess.py | 28 ++++ .../disc_adj_unsteadyCHT_cylinder/solid.cfg | 59 +++++++ TestCases/parallel_regression_AD.py | 13 ++ 8 files changed, 584 insertions(+) create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/O_mesh_cylinder.geo create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/fluid.cfg create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/solid.cfg diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/O_mesh_cylinder.geo b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/O_mesh_cylinder.geo new file mode 100644 index 00000000000..b048536e342 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/O_mesh_cylinder.geo @@ -0,0 +1,147 @@ +// ----------------------------------------------------------------------------------- // +// Kattmann 20.08.2018, O mesh for CHT vortex shedding behind cylinder +// The O mesh around the cylinder consists out of two half cylinders. +// The inner pin is hollow. +// ----------------------------------------------------------------------------------- // + +// Create fluid and solid mesh seperately and merge together e.g. by hand. + +// Which domain part should be handled +Which_Mesh_Part= 1;// 0=all, 1=Fluid, 2=Solid +// Evoke Meshing Algorithm? +Do_Meshing= 1; // 0=false, 1=true +// Write Mesh files in .su2 format +Write_mesh= 1; // 0=false, 1=true + +//Geometric inputs +cylinder_diameter = 1; +cylinder_radius = cylinder_diameter/2; +mesh_radius = 20 * cylinder_diameter; +inner_pin_d = 0.5; +inner_pin_r = inner_pin_d/2; + +// ----------------------------------------------------------------------------------- // +//Mesh inputs +gridsize = 0.1; +Ncylinder = 40; +Nradial = 50; +Rradial = 1.15; + +NPinRadial = 10; +RPinRadial = 0.91; + +// Each zone is self-sufficient (i.e. has all of its own Points/Lines etc.) +// ----------------------------------------------------------------------------------- // +// Fluid zone +If (Which_Mesh_Part == 0 || Which_Mesh_Part == 1) + + // Geometry definition + // Points + Point(1) = {-mesh_radius, 0, 0, gridsize}; + Point(2) = {-cylinder_radius, 0, 0, gridsize}; + Point(3) = {cylinder_radius, 0, 0, gridsize}; + Point(4) = {mesh_radius, 0, 0, gridsize}; + Point(5) = {0, 0, 0, gridsize}; + + //helping point to know height of first layer + //Point(6) = {-cylinder_radius - 0.002, 0, 0, gridsize}; + + // Lines + Line(1) = {1, 2}; // to the left + Line(2) = {3, 4}; // to the right + + Circle(3) = {2, 5, 3}; // lower inner + Circle(4) = {1, 5, 4}; // lower outer + Circle(5) = {3, 5, 2}; // upper inner + Circle(6) = {4, 5, 1}; // upper outer + + // Lineloops and surfaces + Line Loop(1) = {1, 3, 2, -4}; Plane Surface(1) = {1}; // lower half cylinder + Line Loop(2) = {1, -5, 2, 6}; Plane Surface(2) = {2}; // upper half cylinder + + // ----------------------------------------------------------------------------------- // + // Mesh definition + // make structured mesh with transfinite Lines + + // lower + Transfinite Line{3, 4} = Ncylinder; + Transfinite Line{-1, 2} = Nradial Using Progression Rradial; + + // upper + Transfinite Line{-5, -6} = Ncylinder; + Transfinite Line{-1, 2} = Nradial Using Progression Rradial; + + // Physical Groups + Physical Line("cylinder_fluid") = {3, 5}; + Physical Line("farfield") = {4, 6}; + Physical Surface("surface_mesh") = {1, 2}; + +EndIf + +// ----------------------------------------------------------------------------------- // +// Pin zone +If (Which_Mesh_Part == 0 || Which_Mesh_Part == 2) + + // Geometry definition + // Points + Point(11) = {-cylinder_radius, 0, 0, gridsize}; + Point(12) = {-inner_pin_r, 0, 0, gridsize}; + Point(13) = {inner_pin_r, 0, 0, gridsize}; + Point(14) = {cylinder_radius, 0, 0, gridsize}; + Point(15) = {0, 0, 0, gridsize}; + + // Lines + Line(11) = {11, 12}; // to the left + Line(12) = {13, 14}; // to the right + + Circle(13) = {12, 15, 13}; // lower inner + Circle(14) = {11, 15, 14}; // lower outer + Circle(15) = {13, 15, 12}; // upper inner + Circle(16) = {14, 15, 11}; // upper outer + + // Lineloops and surfaces + Line Loop(11) = {11, 13, 12, -14}; Plane Surface(11) = {11}; // lower half cylinder + Line Loop(12) = {11, -15, 12, 16}; Plane Surface(12) = {12}; // upper half cylinder + + // ----------------------------------------------------------------------------------- // + // Mesh definition + // make structured mesh with transfinite Lines + + // lower + Transfinite Line{13, 14} = Ncylinder; + Transfinite Line{-11, 12} = NPinRadial Using Progression RPinRadial; + + // upper + Transfinite Line{-15, -16} = Ncylinder; + Transfinite Line{-11, 12} = NPinRadial Using Progression RPinRadial; + + // Physical Groups + Physical Line("inner_pin") = {13, 15}; + Physical Line("cylinder_solid") = {14, 16}; + Physical Surface("surface_mesh") = {11, 12}; + +EndIf + +// ----------------------------------------------------------------------------------- // +Transfinite Surface "*"; +Recombine Surface "*"; + +If (Do_Meshing == 1) + Mesh 1; Mesh 2; +EndIf + +// ----------------------------------------------------------------------------------- // +// Write .su2 meshfile +If (Write_mesh == 1) + + Mesh.Format = 42; // .su2 mesh format, + If (Which_Mesh_Part == 1) + Save "fluid.su2"; + ElseIf (Which_Mesh_Part == 2) + Save "solid.su2"; + Else + Printf("Invalid Which_Mesh_Part variable."); + Abort; + EndIf + +EndIf diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md new file mode 100644 index 00000000000..35403c1e17c --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md @@ -0,0 +1,28 @@ +# Unsteady CHT Adjoint Testcase + +## Short Description +This is a 2D cylinder in freestream testcase. The flow is incompressible and laminar at Re=200. +A uniform vortex shedding forms behind the cylinder and each shedding cycle is resolved by 54 timesteps. +The pin is heated on the inner surface. + +## Mesh +The mesh is for testing purposes only and contains ~4000 elements for the flow and ~1000 for the heat domain. +A gmsh .geo file is added such that the mesh can be recreated and modified. + +## Recreating full primal +The primal for a full cycle can be restarted with the `solution_*_00000.dat` and `solution_*_00001.dat`. +The primal solution is necessary for the Discrete Adjoint sweep and for the gradient of the full +shedding cycle the full primal is necessary. The necessary changes to `chtMaster.cfg` are documented +in the config itself + +## Discrete Adjoint +In the regression testcase of SU2 only 2 reverse steps are taken. +For that, the solution files 52-55 for the adjoint are added. +The objective Function is the average temperature on the inner pin surface, averaged over the full time. + +## Finite Differences using FADO +In order to validate the Discrete Adjoint gradient a Finite Differences python script `findiff.py` +using [FADO](www.github.com/su2code/FADO) is added. +The script starts a baseline simulation and an additional for each of the 18 Design Variables. +Using the `postprocess.py` to print the absolute difference and relative difference in percent to screen. +Make sure to adapt the `chtMaster.cfg` as for the primal. diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg new file mode 100644 index 00000000000..d4be542e290 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg @@ -0,0 +1,151 @@ +% 2021-03-11 TobiKattmann +% +SOLVER= MULTIPHYSICS +% +% Set RESTART_SOL=YES for primal runs including the FD sweep +RESTART_SOL= NO +RESTART_ITER= 2 +READ_BINARY_RESTART= YES +SOLUTION_FILENAME= solution +RESTART_FILENAME= solution +% +CONFIG_LIST = ( fluid.cfg, solid.cfg ) +% +MARKER_ZONE_INTERFACE= ( cylinder_fluid, cylinder_solid ) +MARKER_CHT_INTERFACE= ( cylinder_fluid, cylinder_solid ) +% +% ------------------------- UNSTEADY SIMULATION -------------------------------% +% +TIME_DOMAIN= YES +TIME_MARCHING= DUAL_TIME_STEPPING-2ND_ORDER +% +TIME_STEP= 500 +% +MAX_TIME= 1e9 +% For a primal restart change TIME_ITER=56 for the correct number of steps. 54 is for the adjoint run. +TIME_ITER= 54 +% For the primal (and therefore FD sweep) OUTER_ITER=200 is suitable. +% For an accurate adjont run set OUTER_ITER=500. 100 is for the regression test. +OUTER_ITER= 100 +%INNER_ITER= 1 +% +UNST_ADJOINT_ITER= 56 +% +ITER_AVERAGE_OBJ= 54 +% +% ------------------------- INPUT/OUTPUT FILE INFORMATION --------------------------% +% +MESH_FILENAME= MeshCHT.su2 +% +SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, BGS_ADJ_PRESSURE[0], BGS_ADJ_VELOCITY-X[0], BGS_ADJ_VELOCITY-Y[0], BGS_ADJ_TEMPERATURE[0], BGS_ADJ_TEMPERATURE[1] ) +% Suitable output for primal simulations +%SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, WALL_TIME, BGS_PRESSURE[0], BGS_TEMPERATURE[0], BGS_TEMPERATURE[1], DRAG[0], AVG_TEMPERATURE[1] ) +SCREEN_WRT_FREQ_OUTER= 50 +% +HISTORY_OUTPUT= ( ITER, BGS_RES[0], RMS_RES[0], BGS_RES[1], RMS_RES[1],\ + FLOW_COEFF[0], HEAT[0], AERO_COEFF[0], HEAT[1],\ + LINSOL[0], LINSOL[1]) +% +OUTPUT_FILES= (RESTART, PARAVIEW) +OUTPUT_WRT_FREQ= 1 +VOLUME_FILENAME= flow +WRT_PERFORMANCE= YES +% +SOLUTION_ADJ_FILENAME= solution_adj +RESTART_ADJ_FILENAME= solution_adj +VOLUME_ADJ_FILENAME= flow_adj +% +TABULAR_FORMAT= CSV +GRAD_OBJFUNC_FILENAME= of_grad.csv +OUTPUT_PRECISION=16 +% +% -------------------- FREE-FORM DEFORMATION PARAMETERS -----------------------% +% +FFD_TOLERANCE= 1E-10 +FFD_ITERATIONS= 500 +% +% FFD box definition: 2D case (FFD_BoxTag, X1, Y1, 0.0, X2, Y2, 0.0, X3, Y3, 0.0, X4, Y4, 0.0, +% 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) +% Counterclockwise definition of FFD cornerpoints +FFD_DEFINITION= (BOX,\ + -0.6,-0.6,0.0,\ + 0.6,-0.6,0.0,\ + 0.6, 0.6,0.0,\ + -0.6, 0.6,0.0,\ + 0.0,0.0,0.0, 0.0,0.0,0.0 0.0,0.0,0.0, 0.0,0.0,0.0 ) +% +% FFD box degree: 2D case (x_degree, y_degree, 0) +FFD_DEGREE= (8, 1, 0) +% +% Surface grid continuity at the intersection with the faces of the FFD boxes. +% To keep a particular level of surface continuity, SU2 automatically freezes the right +% number of control point planes (NO_DERIVATIVE, 1ST_DERIVATIVE, 2ND_DERIVATIVE, USER_INPUT) +FFD_CONTINUITY= NO_DERIVATIVE +% +% ----------------------- DESIGN VARIABLE PARAMETERS --------------------------% +% +%DV_KIND= FFD_SETTING +% First 9 are upper, second 9 are lower DV's +DV_KIND= FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D, FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D,FFD_CONTROL_POINT_2D +% +% Marker of the surface in which we are going apply the shape deformation +DV_MARKER= ( cylinder_fluid, cylinder_solid ) +% +% Parameters of the shape deformation +% - FFD_SETTING ( 1.0 ) +% - FFD_CONTROL_POINT_2D ( FFD_BoxTag, i_Ind, j_Ind, x_Disp, y_Disp ) +%DV_PARAM= ( 1.0 ) +DV_PARAM= \ +( BOX, 0, 1, 0.0, 1.0);\ +( BOX, 1, 1, 0.0, 1.0);\ +( BOX, 2, 1, 0.0, 1.0);\ +( BOX, 3, 1, 0.0, 1.0);\ +( BOX, 4, 1, 0.0, 1.0);\ +( BOX, 5, 1, 0.0, 1.0);\ +( BOX, 6, 1, 0.0, 1.0);\ +( BOX, 7, 1, 0.0, 1.0);\ +( BOX, 8, 1, 0.0, 1.0);\ +( BOX, 0, 0, 0.0, 1.0);\ +( BOX, 1, 0, 0.0, 1.0);\ +( BOX, 2, 0, 0.0, 1.0);\ +( BOX, 3, 0, 0.0, 1.0);\ +( BOX, 4, 0, 0.0, 1.0);\ +( BOX, 5, 0, 0.0, 1.0);\ +( BOX, 6, 0, 0.0, 1.0);\ +( BOX, 7, 0, 0.0, 1.0);\ +( BOX, 8, 0, 0.0, 1.0) +% +% Value of the shape deformation +DV_VALUE= 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0, 1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0 +% +% ------------------------ GRID DEFORMATION PARAMETERS ------------------------% +% +DEFORM_LINEAR_SOLVER= FGMRES +DEFORM_LINEAR_SOLVER_PREC= ILU +DEFORM_LINEAR_SOLVER_ERROR= 1E-14 +DEFORM_NONLINEAR_ITER= 1 +DEFORM_LINEAR_SOLVER_ITER= 1000 +% +DEFORM_CONSOLE_OUTPUT= YES +DEFORM_STIFFNESS_TYPE= WALL_DISTANCE +% +DEFINITION_DV= \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 0, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 1, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 2, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 3, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 4, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 5, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 6, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 7, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 8, 1, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 0, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 1, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 2, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 3, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 4, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 5, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 6, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 7, 0, 0.0, 1.0 ); \ +( 19, 1.0 | cylinder_fluid, cylinder_solid | BOX, 8, 0, 0.0, 1.0 ) + diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py new file mode 100644 index 00000000000..5fc71139304 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py @@ -0,0 +1,78 @@ +# FADO script: Finite Differences of unsteady CHT + +from FADO import * +import subprocess + +# Design variables ----------------------------------------------------- # + +nDV = 18 +ffd = InputVariable(0.0,PreStringHandler("DV_VALUE="),nDV) + +# Parameters ----------------------------------------------------------- # + +# switch input mesh to perform deformation +mesh_in = Parameter(["MESH_FILENAME= mesh_out.su2"],\ + LabelReplacer("MESH_FILENAME= MeshCHT.su2")) + +# Evaluations ---------------------------------------------------------- # + +def_command = "SU2_DEF chtMaster.cfg" # Note that correct SU2 version needs to be in PATH +cfd_command = "mpirun -n 12 SU2_CFD chtMaster.cfg" + +max_tries = 1 + +# mesh deformation +deform = ExternalRun("DEFORM",def_command,True) # True means sym links are used for addData +deform.setMaxTries(max_tries) +deform.addConfig("chtMaster.cfg") +deform.addData("fluid.cfg") # zonal cfg's can be symlinked as they are unchanged +deform.addData("solid.cfg") +deform.addData("MeshCHT.su2") +deform.addExpected("mesh_out.su2") + +# direct run +direct = ExternalRun("DIRECT",cfd_command,True) +direct.setMaxTries(max_tries) +direct.addConfig("chtMaster.cfg") +direct.addData("fluid.cfg") +direct.addData("solid.cfg") +direct.addData("DEFORM/mesh_out.su2") +direct.addData("solution_0_00000.dat") +direct.addData("solution_0_00001.dat") +direct.addData("solution_1_00000.dat") +direct.addData("solution_1_00001.dat") +direct.addExpected("solution_0_00055.dat") +direct.addExpected("solution_1_00055.dat") +direct.addParameter(mesh_in) + +# Functions ------------------------------------------------------------ # + +tavgT = Function("tavgT", "DIRECT/chtMaster.csv",LabeledTableReader("\"tavg[AvgTemp[1]]\"")) +tavgT.addInputVariable(ffd,"",None) +tavgT.addValueEvalStep(deform) +tavgT.addValueEvalStep(direct) + +# Driver --------------------------------------------------------------- # + +driver = ExteriorPenaltyDriver(0.005) +driver.addObjective("min", tavgT) + +driver.setWorkingDirectory("DOE") +driver.preprocessVariables() +driver.setStorageMode(True,"DESIGN_") + +his = open("doe.his","w",1) +driver.setHistorian(his) + +# Finite Differences +x = driver.getInitial() +driver.fun(x) # baseline evaluation + +for iLoop in range(0, nDV, 1): + x = driver.getInitial() + x[iLoop] = 1e-4 # DV_VALUE + driver.fun(x) +#end + +his.close() + diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/fluid.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/fluid.cfg new file mode 100644 index 00000000000..b4fe5b28efb --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/fluid.cfg @@ -0,0 +1,80 @@ +% TobiKattmann 2021-03-11 +% +SOLVER= INC_NAVIER_STOKES +% +OBJECTIVE_FUNCTION= AVG_TEMPERATURE +%OBJECTIVE_FUNCTION= DRAG +OBJECTIVE_WEIGHT= 0.0 +% +% ---------------- INCOMPRESSIBLE FLOW CONDITION DEFINITION -------------------% +% +INC_NONDIM= DIMENSIONAL +% ~Water at room temperature +INC_DENSITY_MODEL= CONSTANT +INC_DENSITY_INIT= 1.0e3 +% +% Re = rho*v*d/mu_dyn = 1e3*v*1/1e-3 = 200 => v = 2.0e-4 +INC_VELOCITY_INIT= ( 2.0e-4, 0.0, 0.0 ) +% +INC_ENERGY_EQUATION= YES +INC_TEMPERATURE_INIT= 288.15 +SPECIFIC_HEAT_CP= 4180 +% +VISCOSITY_MODEL= CONSTANT_VISCOSITY +MU_CONSTANT= 1.0e-3 +% +% Pr = c_p * mu_dyn / lambda +% lambda_water = 0.6 => Pr = 4180 * 1e-3 / 0.6 = 6.96 +CONDUCTIVITY_MODEL= CONSTANT_PRANDTL +PRANDTL_LAM = 6.96 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_FAR= ( farfield ) +%MARKER_HEATFLUX= ( cylinder_fluid, 1e2 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +% +CFL_NUMBER= 1e3 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 0.8, 1.4, 10.0, 1e10, 0.001 ) +% +RK_ALPHA_COEFF= ( 0.66667, 0.66667, 1.000000 ) +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +%LINEAR_SOLVER_ERROR= 1E-4 +LINEAR_SOLVER_ERROR= 1E-8 +LINEAR_SOLVER_ITER= 20 +% +CONV_NUM_METHOD_FLOW= FDS +MUSCL_FLOW= YES +SLOPE_LIMITER_FLOW= NONE +TIME_DISCRE_FLOW= EULER_IMPLICIT +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_RESIDUAL_MINVAL= -20 +CONV_STARTITER= 2000 +CONV_CAUCHY_ELEMS= 100 +CONV_CAUCHY_EPS= 1E-6 +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +%MESH_FILENAME= fluid.su2 +% +%SCREEN_OUTPUT= (TIME_ITER, WALL_TIME, INNER_ITER, RMS_PRESSURE, RMS_VELOCITY-X, DRAG, LIFT, AVG_TEMPERATURE, TOTAL_HEATFLUX ) +%SCREEN_WRT_FREQ_INNER= 100 +% +%HISTORY_OUTPUT= (ITER, RMS_RES, AERO_COEFF, HEAT, FLOW_COEFF, LINSOL) +%HISTORY_WRT_FREQ_INNER= 100 +MARKER_MONITORING= ( cylinder_fluid ) +MARKER_ANALYZE= ( cylinder_fluid ) +MARKER_ANALYZE_AVERAGE= AREA +% +%OUTPUT_FILES= ( RESTART, PARAVIEW ) + diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py new file mode 100644 index 00000000000..d03bea21c98 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py @@ -0,0 +1,28 @@ +# Compute and print absolute difference between Discrete Adjoint +# and Finite Difference gradient. Prints also percentage difference. + +import pandas as pd + +# load files +DAgrad = pd.read_csv("of_grad.csv") +FDvals = pd.read_csv("doe.his") + +# additional values +FDstep = 1e-4 +FDstring = ' tavgT' +DAstring = 'AVG_TEMPERATURE gradient ' + +# create FD gradient +FDgrad = (FDvals[FDstring].iloc[1:] - FDvals[FDstring].iloc[0]) / FDstep +# The above operation creates a pd.series that starts at 1 because the first FDval is the baseline. +# This is reset to match the DAgrad +FDgrad = FDgrad.reset_index(inplace=False) + +# absolute difference +absoluteDiff = DAgrad[DAstring] - FDgrad[FDstring] +print("DAgrad - FDgrad\n", absoluteDiff) + +# relative difference in percent +relDiffPercent = abs(DAgrad[DAstring] - FDgrad[FDstring])/DAgrad[DAstring] * 100 +print("(DAgrad - FDgrad) / DAgrad * 100\n", relDiffPercent) + diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/solid.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/solid.cfg new file mode 100644 index 00000000000..8af4dae4a7d --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/solid.cfg @@ -0,0 +1,59 @@ +% 2021-03-11 TobiKattmann +% +SOLVER= HEAT_EQUATION +% +OBJECTIVE_FUNCTION= AVG_TEMPERATURE +%OBJECTIVE_FUNCTION= DRAG +OBJECTIVE_WEIGHT= 1.0 +% +% ---------------- (SOLIDS) CONDUCTION CONDITION DEFINITION -------------------% +% +% ~Aluminium at room temperature +INC_NONDIM= DIMENSIONAL +% +SOLID_TEMPERATURE_INIT= 340.0 +SOLID_DENSITY= 2719 +SPECIFIC_HEAT_CP = 0.8710 +SOLID_THERMAL_CONDUCTIVITY= 200 +% +% -------------------- BOUNDARY CONDITION DEFINITION --------------------------% +% +MARKER_HEATFLUX= ( inner_pin, 1e3 ) +% +% ------------- COMMON PARAMETERS DEFINING THE NUMERICAL METHOD ---------------% +% +NUM_METHOD_GRAD= GREEN_GAUSS +% +CFL_NUMBER= 1e4 +CFL_ADAPT= NO +CFL_ADAPT_PARAM= ( 0.1, 2.0, 10.0, 1e10, 0.001 ) +% +BETA_FACTOR= 50 +MAX_DELTA_TIME= 1.0 +% +% ------------------------ LINEAR SOLVER DEFINITION ---------------------------% +% +LINEAR_SOLVER= FGMRES +LINEAR_SOLVER_PREC= ILU +LINEAR_SOLVER_ERROR= 1E-15 +LINEAR_SOLVER_ITER= 20 +% +% --------------------------- CONVERGENCE PARAMETERS --------------------------% +% +CONV_RESIDUAL_MINVAL= -20 +CONV_STARTITER= 10000 +% +% -------------------- HEAT NUMERICAL METHOD DEFINITION -----------------------% +% +CONV_NUM_METHOD_HEAT = SPACE_CENTERED +TIME_DISCRE_HEAT= EULER_IMPLICIT +% +% ------------------------- INPUT/OUTPUT INFORMATION --------------------------% +% +%MESH_FILENAME= solid.su2 +% +%HISTORY_OUTPUT= (ITER, RMS_RES, HEAT, LINSOL) +HISTORY_OUTPUT= (HEAT) +MARKER_MONITORING= ( inner_pin ) +%MARKER_ANALYZE= ( inner_pin ) + diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 8688cc2d455..000b16f0fb9 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -348,6 +348,19 @@ def main(): da_sp_pinArray_cht_2d_dp_hf.multizone = True test_list.append(da_sp_pinArray_cht_2d_dp_hf) + # 2D unsteady CHT vortex shedding at RE=200. TAVG_Temperature OF + da_unsteadyCHT_cylinder = TestCase('da_unsteadyCHT_cylinder') + da_unsteadyCHT_cylinder.cfg_dir = "coupled_cht/disc_adj_unsteadyCHT_cylinder" + da_unsteadyCHT_cylinder.cfg_file = "chtMaster.cfg" + da_unsteadyCHT_cylinder.test_iter = 2 + da_unsteadyCHT_cylinder.test_vals = [-3.521358, -4.312658, -4.271025, -9.846075, -7.967741] + da_unsteadyCHT_cylinder.su2_exec = "mpirun -n 2 SU2_CFD_AD" + da_unsteadyCHT_cylinder.timeout = 1600 + da_unsteadyCHT_cylinder.tol = 0.00001 + da_unsteadyCHT_cylinder.unsteady = True + da_unsteadyCHT_cylinder.multizone = True + test_list.append(da_unsteadyCHT_cylinder) + ###################################### ### RUN TESTS ### ###################################### From 9ae02f0b0c4434b2a2c05464bb53e236c86c14cb Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Thu, 13 May 2021 11:25:50 +0200 Subject: [PATCH 083/192] remove unnecessary python import. LGTM warning --- TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py index 5fc71139304..c1672bfc9de 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py @@ -1,7 +1,6 @@ # FADO script: Finite Differences of unsteady CHT from FADO import * -import subprocess # Design variables ----------------------------------------------------- # @@ -75,4 +74,3 @@ #end his.close() - From 5d5f2b8c539191f209a8c5513a7236ff6c33e2be Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Thu, 13 May 2021 18:55:11 +0100 Subject: [PATCH 084/192] Enable regression --- TestCases/parallel_regression_AD.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 8688cc2d455..fa467125918 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -308,18 +308,18 @@ def main(): discadj_fsi2.tol = 1e-16 test_list.append(discadj_fsi2) - ## Unsteady multi physics framework - #dyn_discadj_fsi = TestCase('dyn_discadj_fsi') - #dyn_discadj_fsi.cfg_dir = "disc_adj_fsi/dyn_fsi" - #dyn_discadj_fsi.cfg_file = "config.cfg" - #dyn_discadj_fsi.test_iter = 2 - #dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" - #dyn_discadj_fsi.timeout = 1600 - #dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" - #dyn_discadj_fsi.test_file = "grad_dv.opt" - #dyn_discadj_fsi.unsteady = True - #pass_list.append(dyn_discadj_fsi.run_filediff()) - #test_list.append(dyn_discadj_fsi) + # Unsteady multi physics framework + dyn_discadj_fsi = TestCase('dyn_discadj_fsi') + dyn_discadj_fsi.cfg_dir = "disc_adj_fsi/dyn_fsi" + dyn_discadj_fsi.cfg_file = "config.cfg" + dyn_discadj_fsi.test_iter = 2 + dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" + dyn_discadj_fsi.timeout = 1600 + dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" + dyn_discadj_fsi.test_file = "grad_dv.opt" + dyn_discadj_fsi.unsteady = True + pass_list.append(dyn_discadj_fsi.run_filediff()) + test_list.append(dyn_discadj_fsi) ################################### ### Coupled CHT Adjoint ### From 7fe3d484c3f9f952d110cc3627adbc1e3647a17d Mon Sep 17 00:00:00 2001 From: cvencro Date: Thu, 13 May 2021 21:25:07 +0100 Subject: [PATCH 085/192] move new test --- TestCases/parallel_regression_AD.py | 30 ++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 8688cc2d455..2865f11f1e1 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -308,19 +308,6 @@ def main(): discadj_fsi2.tol = 1e-16 test_list.append(discadj_fsi2) - ## Unsteady multi physics framework - #dyn_discadj_fsi = TestCase('dyn_discadj_fsi') - #dyn_discadj_fsi.cfg_dir = "disc_adj_fsi/dyn_fsi" - #dyn_discadj_fsi.cfg_file = "config.cfg" - #dyn_discadj_fsi.test_iter = 2 - #dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" - #dyn_discadj_fsi.timeout = 1600 - #dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" - #dyn_discadj_fsi.test_file = "grad_dv.opt" - #dyn_discadj_fsi.unsteady = True - #pass_list.append(dyn_discadj_fsi.run_filediff()) - #test_list.append(dyn_discadj_fsi) - ################################### ### Coupled CHT Adjoint ### ################################### @@ -420,6 +407,23 @@ def main(): pass_list.append(naca_restart_shape_opt.run_opt()) test_list.append(naca_restart_shape_opt) + #################################################################### + ### Unsteady Disc. Adj. Coupled FSI ### + #################################################################### + + # Unsteady multi physics framework + dyn_discadj_fsi = TestCase('dyn_discadj_fsi') + dyn_discadj_fsi.cfg_dir = "disc_adj_fsi/dyn_fsi" + dyn_discadj_fsi.cfg_file = "config.cfg" + dyn_discadj_fsi.test_iter = 2 + dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" + dyn_discadj_fsi.timeout = 1600 + dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" + dyn_discadj_fsi.test_file = "grad_dv.opt" + dyn_discadj_fsi.unsteady = True + pass_list.append(dyn_discadj_fsi.run_filediff()) + test_list.append(dyn_discadj_fsi) + # Tests summary print('==================================================================') print('Summary of the parallel tests') From 2144acde713241f87a70c5f4e4d3264517ea97b4 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Thu, 13 May 2021 22:19:45 +0100 Subject: [PATCH 086/192] try to fix restarts --- Common/include/CConfig.hpp | 2 +- Common/src/CConfig.cpp | 4 +- .../include/solvers/CFVMFlowSolverBase.inl | 5 +- SU2_CFD/src/drivers/CDriver.cpp | 185 +++--------------- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 12 +- SU2_CFD/src/solvers/CMeshSolver.cpp | 12 +- 7 files changed, 50 insertions(+), 172 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index c8a9819435f..f403284c37c 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5235,7 +5235,7 @@ class CConfig { * \param[in] ext - the extension to be added. * \return The new filename */ - string GetFilename(string filename, string ext, unsigned long Iter) const; + string GetFilename(string filename, string ext, int Iter) const; /*! * \brief Append the zone index to the restart or the solution files. diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index abe3f235992..8a51da7a728 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -7820,7 +7820,7 @@ CConfig::~CConfig(void) { } -string CConfig::GetFilename(string filename, string ext, unsigned long Iter) const { +string CConfig::GetFilename(string filename, string ext, int Iter) const { /*--- Remove any extension --- */ @@ -7840,7 +7840,7 @@ string CConfig::GetFilename(string filename, string ext, unsigned long Iter) con filename = GetMultiInstance_FileName(filename, GetiInst(), ext); if (GetTime_Domain()){ - filename = GetUnsteady_FileName(filename, (int)Iter, ext); + filename = GetUnsteady_FileName(filename, Iter, ext); } return filename; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index fa533937244..64d3934c539 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -999,10 +999,13 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo } if (restart && (TimeIter == config->GetRestart_Iter()) && (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) { + + const bool update_geo = !config->GetFSI_Simulation(); + /*--- Load an additional restart file for a 2nd-order restart ---*/ solver_container[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver_container, config, config->GetRestart_Iter() - 1, - true); + update_geo); /*--- Load an additional restart file for the turbulence model ---*/ if (rans) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index e78890f1fd6..d88af7dbc3b 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -250,17 +250,6 @@ CDriver::CDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunica interface_types, interface_container, interpolator_container); } - if(fsi && (config_container[ZONE_0]->GetRestart() || config_container[ZONE_0]->GetDiscrete_Adjoint())){ - if (rank == MASTER_NODE)cout << endl <<"Restarting Fluid and Structural Solvers." << endl; - - for (iZone = 0; iZone < nZone; iZone++) { - for (iInst = 0; iInst < nInst[iZone]; iInst++){ - Solver_Restart(solver_container[iZone][iInst], geometry_container[iZone][iInst], - config_container[iZone], true); - } - } - } - if (config_container[ZONE_0]->GetBoolTurbomachinery()){ if (rank == MASTER_NODE)cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; Turbomachinery_Preprocessing(config_container, geometry_container, solver_container, interface_container); @@ -1137,170 +1126,56 @@ void CDriver::Inlet_Preprocessing(CSolver ***solver, CGeometry **geometry, void CDriver::Solver_Restart(CSolver ***solver, CGeometry **geometry, CConfig *config, bool update_geo) { - bool euler, ns, turbulent, - NEMO_euler, NEMO_ns, - adj_euler, adj_ns, adj_turb, - heat, fem, fem_euler, fem_ns, fem_dg_flow, - template_solver, disc_adj, disc_adj_fem, disc_adj_turb, disc_adj_heat; - int val_iter = 0; - - /*--- Initialize some useful booleans ---*/ - - euler = false; ns = false; turbulent = false; - NEMO_euler = false; NEMO_ns = false; - adj_euler = false; adj_ns = false; adj_turb = false; - fem_euler = false; fem_ns = false; fem_dg_flow = false; - disc_adj = false; - fem = false; disc_adj_fem = false; - disc_adj_turb = false; - heat = false; disc_adj_heat = false; - template_solver = false; - /*--- Check for restarts and use the LoadRestart() routines. ---*/ - bool restart = config->GetRestart(); - bool restart_flow = config->GetRestart_Flow(); - bool no_restart = false; + const bool restart = config->GetRestart(); + const bool restart_flow = config->GetRestart_Flow(); /*--- Adjust iteration number for unsteady restarts. ---*/ - bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || - (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)); - bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING; - bool adjoint = (config->GetDiscrete_Adjoint() || config->GetContinuous_Adjoint()); - bool time_domain = (config->GetTime_Domain()); // Dynamic simulation (FSI). + int val_iter = 0; - if (dual_time) { - if (adjoint) val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; - else if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) - val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-2; - } + const bool adjoint = (config->GetDiscrete_Adjoint() || config->GetContinuous_Adjoint()); + const bool time_domain = config->GetTime_Domain(); + const bool dt_step_2nd = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) && + !config->GetStructuralProblem() && !config->GetFEMSolver() && + !adjoint && time_domain; - if (time_stepping) { - if (adjoint) val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; - else val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; + if (time_domain) { + if (adjoint) val_iter = config->GetUnst_AdjointIter() - 1; + else val_iter = config->GetRestart_Iter() - 1 - dt_step_2nd; } - /*--- Assign booleans ---*/ - - switch (config->GetKind_Solver()) { - case TEMPLATE_SOLVER: template_solver = true; break; - case EULER : case INC_EULER: euler = true; break; - case NEMO_EULER : NEMO_euler = true; break; - case NAVIER_STOKES: case INC_NAVIER_STOKES: ns = true; heat = config->GetWeakly_Coupled_Heat(); break; - case NEMO_NAVIER_STOKES: NEMO_ns = true; break; - case RANS : case INC_RANS: ns = true; turbulent = true; heat = config->GetWeakly_Coupled_Heat(); break; - case FEM_EULER : fem_euler = true; break; - case FEM_NAVIER_STOKES: fem_ns = true; break; - case FEM_RANS : fem_ns = true; break; - case FEM_LES : fem_ns = true; break; - case HEAT_EQUATION: heat = true; break; - case FEM_ELASTICITY: fem = true; break; - case ADJ_EULER : euler = true; adj_euler = true; break; - case ADJ_NAVIER_STOKES : ns = true; turbulent = (config->GetKind_Turb_Model() != NONE); adj_ns = true; break; - case ADJ_RANS : ns = true; turbulent = true; adj_ns = true; adj_turb = (!config->GetFrozen_Visc_Cont()); break; - case DISC_ADJ_EULER: case DISC_ADJ_INC_EULER: euler = true; disc_adj = true; break; - case DISC_ADJ_NAVIER_STOKES: case DISC_ADJ_INC_NAVIER_STOKES: ns = true; disc_adj = true; heat = config->GetWeakly_Coupled_Heat(); break; - case DISC_ADJ_RANS: case DISC_ADJ_INC_RANS: ns = true; turbulent = true; disc_adj = true; disc_adj_turb = (!config->GetFrozen_Visc_Disc()); heat = config->GetWeakly_Coupled_Heat(); break; - case DISC_ADJ_FEM_EULER: fem_euler = true; disc_adj = true; break; - case DISC_ADJ_FEM_NS: fem_ns = true; disc_adj = true; break; - case DISC_ADJ_FEM_RANS: fem_ns = true; turbulent = true; disc_adj = true; disc_adj_turb = (!config->GetFrozen_Visc_Disc()); break; - case DISC_ADJ_FEM: fem = true; disc_adj_fem = true; break; - case DISC_ADJ_HEAT: heat = true; disc_adj_heat = true; break; - - } - - /*--- Determine the kind of FEM solver used for the flow. ---*/ - - switch( config->GetKind_FEM_Flow() ) { - case DG: fem_dg_flow = true; break; - } - - /*--- Load restarts for any of the active solver containers. Note that - these restart routines fill the fine grid and interpolate to all MG levels. ---*/ + /*--- Restart direct solvers. ---*/ if (restart || restart_flow) { - if (euler || ns) { - SU2_OMP_PARALLEL_(if(solver[MESH_0][FLOW_SOL]->GetHasHybridParallel())) - solver[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - END_SU2_OMP_PARALLEL - } - if (NEMO_euler || NEMO_ns) { - solver[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (turbulent) { - SU2_OMP_PARALLEL_(if(solver[MESH_0][TURB_SOL]->GetHasHybridParallel())) - solver[MESH_0][TURB_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - END_SU2_OMP_PARALLEL - } - if (config->AddRadiation()) { - solver[MESH_0][RAD_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (fem) { - if (time_domain) { - if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; + for (auto iSol = 0u; iSol < MAX_SOLS; ++iSol) { + auto sol = solver[MESH_0][iSol]; + if (sol && !sol->GetAdjoint()) { + /*--- Note that the mesh solver always loads the most recent file (and not -2). ---*/ + SU2_OMP_PARALLEL_(if(sol->GetHasHybridParallel())) + sol->LoadRestart(geometry, solver, config, val_iter + (iSol==MESH_SOL && dt_step_2nd), update_geo); + END_SU2_OMP_PARALLEL } - solver[MESH_0][FEA_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (fem_euler || fem_ns) { - if (fem_dg_flow) - solver[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (heat) { - solver[MESH_0][HEAT_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); } } + /*--- Restart adjoint solvers. ---*/ + if (restart) { - if (template_solver) { - no_restart = true; - } - if (heat) { - solver[MESH_0][HEAT_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (adj_euler || adj_ns) { - solver[MESH_0][ADJFLOW_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (adj_turb) { - no_restart = true; - } - if (disc_adj) { - solver[MESH_0][ADJFLOW_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - if (disc_adj_turb) - solver[MESH_0][ADJTURB_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - if (disc_adj_heat) - solver[MESH_0][ADJHEAT_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - if (config->AddRadiation()) - solver[MESH_0][ADJRAD_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - if (disc_adj_fem) { - if (time_domain) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - solver[MESH_0][ADJFEA_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); + if ((config->GetKind_Solver() == TEMPLATE_SOLVER) || + (config->GetKind_Solver() == ADJ_RANS && !config->GetFrozen_Visc_Cont())) { + SU2_MPI::Error("A restart capability has not been implemented yet for this solver.\n" + "Please set RESTART_SOL= NO and try again.", CURRENT_FUNCTION); } - if (disc_adj_heat) { - solver[MESH_0][ADJHEAT_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - } - - if ((restart || restart_flow) && config->GetDeform_Mesh() && update_geo){ - /*--- Always restart with the last state ---*/ - if (config->GetRestart()) val_iter = SU2_TYPE::Int(config->GetRestart_Iter())-1; - else val_iter = SU2_TYPE::Int(config->GetUnst_AdjointIter())-1; - solver[MESH_0][MESH_SOL]->LoadRestart(geometry, solver, config, val_iter, update_geo); - } - /*--- Exit if a restart was requested for a solver that is not available. ---*/ - - if (no_restart) { - SU2_MPI::Error(string("A restart capability has not been implemented yet for this solver.\n") + - string("Please set RESTART_SOL= NO and try again."), CURRENT_FUNCTION); + for (auto iSol = 0u; iSol < MAX_SOLS; ++iSol) { + auto sol = solver[MESH_0][iSol]; + if (sol && sol->GetAdjoint()) + sol->LoadRestart(geometry, solver, config, val_iter, update_geo); + } } - /*--- Think about calls to pre / post-processing here, plus realizability checks. ---*/ - - } void CDriver::Solver_Postprocessing(CSolver ****solver, CGeometry **geometry, diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 41e5d901f98..db7b9599c33 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -239,7 +239,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { /*--- Set the initial condition for EULER/N-S/RANS ---------------------------------------------*/ /*--- For FSI, the initial conditions are set, after the mesh has been moved. --------------------------------------*/ - if (!fsi && !config_container[iZone]->GetDiscrete_Adjoint() && config_container[iZone]->GetFluidProblem()) { + if (!fsi && config_container[iZone]->GetFluidProblem()) { solver_container[iZone][INST_0][MESH_0][FLOW_SOL]->SetInitialCondition(geometry_container[iZone][INST_0], solver_container[iZone][INST_0], config_container[iZone], TimeIter); diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index f3d3e4b46f3..965665148d9 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -158,14 +158,14 @@ void CSinglezoneDriver::Run() { void CSinglezoneDriver::Postprocess() { - iteration_container[ZONE_0][INST_0]->Postprocess(output_container[ZONE_0], integration_container, geometry_container, solver_container, - numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); + iteration_container[ZONE_0][INST_0]->Postprocess(output_container[ZONE_0], integration_container, geometry_container, solver_container, + numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); - /*--- A corrector step can help preventing numerical instabilities ---*/ + /*--- A corrector step can help preventing numerical instabilities ---*/ - if (config_container[ZONE_0]->GetRelaxation()) - iteration_container[ZONE_0][INST_0]->Relaxation(output_container[ZONE_0], integration_container, geometry_container, solver_container, - numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); + if (config_container[ZONE_0]->GetRelaxation()) + iteration_container[ZONE_0][INST_0]->Relaxation(output_container[ZONE_0], integration_container, geometry_container, solver_container, + numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0); } diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 06af9b8408c..62d3b2c7cf8 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -830,8 +830,6 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * minus the coordinates of the reference mesh file ---*/ su2double displ = curr_coord - nodes->GetMesh_Coord(iPoint_Local, iDim); nodes->SetSolution(iPoint_Local, iDim, displ); - su2double vel = Restart_Data[index+iDim+6]; - if (time_domain && config->GetFSI_Simulation()) geometry[MESH_0]->nodes->SetGridVel(iPoint_Local, iDim, vel); } /*--- Increment the overall counter for how many points have been loaded. ---*/ @@ -866,8 +864,8 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * domain and on the boundaries. ---*/ UpdateDualGrid(geometry[MESH_0], config); - /*--- For time-domain problems, we need to compute the grid velocities ---*/ - if (time_domain){ + /*--- For time-domain problems, we need to compute the grid velocities. ---*/ + if (time_domain && !config->GetFSI_Simulation()) { /*--- Update the old geometry (coordinates n and n-1) ---*/ Restart_OldGeometry(geometry[MESH_0], config); /*--- Once Displacement_n and Displacement_n1 are filled, @@ -928,8 +926,10 @@ void CMeshSolver::Restart_OldGeometry(CGeometry *geometry, CConfig *config) { /*--- Modify file name for an unsteady restart ---*/ int Unst_RestartIter; - if (config->GetRestart()) Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter()) - iStep; - else Unst_RestartIter = SU2_TYPE::Int(config->GetUnst_AdjointIter()) - SU2_TYPE::Int(config->GetTimeIter())-iStep-1; + if (!config->GetDiscrete_Adjoint()) + Unst_RestartIter = static_cast(config->GetRestart_Iter()) - iStep; + else + Unst_RestartIter = static_cast(config->GetUnst_AdjointIter()) - config->GetTimeIter() - iStep - 1; if (Unst_RestartIter < 0) { From f6f62f5de4dc9f5327d67253e5460459ed2d0683 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Wed, 12 May 2021 16:33:04 +0200 Subject: [PATCH 087/192] communicate wall roughness with NdFlattener --- Common/include/fem/fem_geometry_structure.hpp | 6 +- Common/include/geometry/CGeometry.hpp | 11 +- Common/include/geometry/CPhysicalGeometry.hpp | 15 +- Common/include/geometry/dual_grid/CPoint.hpp | 31 +- Common/include/ndflattener.hpp | 556 ++++++++++++++++++ Common/src/fem/fem_wall_distance.cpp | 2 +- Common/src/geometry/CGeometry.cpp | 42 +- Common/src/geometry/CPhysicalGeometry.cpp | 45 +- Common/src/geometry/dual_grid/CPoint.cpp | 17 + 9 files changed, 648 insertions(+), 77 deletions(-) create mode 100644 Common/include/ndflattener.hpp diff --git a/Common/include/fem/fem_geometry_structure.hpp b/Common/include/fem/fem_geometry_structure.hpp index 210f3e2a7a2..d9e92fb4b65 100644 --- a/Common/include/fem/fem_geometry_structure.hpp +++ b/Common/include/fem/fem_geometry_structure.hpp @@ -1231,10 +1231,10 @@ class CMeshFEM_DG: public CMeshFEM { * \details The ADT might belong to another zone, giving rise to lower wall distances * than those already stored. * \param[in] WallADT - The ADT to reduce the wall distance - * \param[in] geometry - ignored - * \param[in] config - ignored + * \param[in] config - Config of this geometry (not the ADT zone's geometry) + * \param[in] iZone - ignored */ - void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry = nullptr) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone=numeric_limits::max()) override; }; /*! diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index a9f938bd108..61dd15714a1 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1687,10 +1687,10 @@ class CGeometry { * \details The ADT might belong to another zone, giving rise to lower wall distances * than those already stored. * \param[in] WallADT - The ADT to reduce the wall distance - * \param[in] geometry - Geometry associated to the ADT - * \param[in] config - Config associated to the ADT + * \param[in] config - Config of this geometry (not the ADT zone's geometry) + * \param[in] iZone - Zone whose markers made the ADT */ - virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) {} + virtual void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone = numeric_limits::max()) {} /*! * \brief Set wall distances a specific value @@ -1705,11 +1705,6 @@ class CGeometry { */ static void ComputeWallDistance(const CConfig * const *config_container, CGeometry ****geometry_container); - /*! - * \brief Virtual function to set roughness values. - */ - virtual void SetGlobalMarkerRoughness(const CConfig* config) {} - /*! * \brief Set the amount of nonconvex elements in the mesh. * \param[in] nonconvex_elems - amount of nonconvex elements in the mesh diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 98d8b8bc604..976d7902de3 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -106,10 +106,6 @@ class CPhysicalGeometry final : public CGeometry { su2double Streamwise_Periodic_RefNode[MAXNDIM] = {0}; /*!< \brief Coordinates of the reference node [m] on the receiving periodic marker, for recovered pressure/temperature computation only.*/ -public: - vector GlobalMarkerStorageDispl; - vector GlobalRoughness_Height; - public: /*--- This is to suppress Woverloaded-virtual, omitting it has no negative impact. ---*/ using CGeometry::SetVertex; @@ -772,10 +768,10 @@ class CPhysicalGeometry final : public CGeometry { * \details The ADT might belong to another zone, giving rise to lower wall distances * than those already stored. * \param[in] WallADT - The ADT to reduce the wall distance - * \param[in] geometry - Physical geometry associated to the ADT - * \param[in] config - Config associated to the ADT + * \param[in] config - ignored + * \param[in] iZone - zone whose markers made the ADT */ - void SetWallDistance(CADTElemClass* WallADT, const CConfig *config = nullptr, const CGeometry* geometry=nullptr) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone=numeric_limits::max()) override; /*! * \brief Set wall distances a specific value @@ -786,11 +782,6 @@ class CPhysicalGeometry final : public CGeometry { } } - /*! - * \brief Set roughness values for markers in a global array. - */ - void SetGlobalMarkerRoughness(const CConfig* config) override; - /*! * \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet. * \param[in] config - Definition of the particular problem. diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 9db963524ad..d6cc87c3dbc 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -32,6 +32,7 @@ #include "../../containers/container_decorators.hpp" #include "../../toolboxes/graph_toolbox.hpp" #include +#include "../../ndflattener.hpp" using namespace std; @@ -85,7 +86,14 @@ class CPoint { su2vector Agglomerate; /*!< \brief This flag indicates if the element has been agglomerated. */ su2vector nNeighbor; /*!< \brief Number of neighbors, needed by some numerical methods. */ + + /*--- Closest element on a viscous wall, and distance to it. ---*/ su2activevector Wall_Distance; /*!< \brief Distance to the nearest wall. */ + su2vector ClosestWall_Rank; /*!< \brief Rank of process holding the closest wall element. */ + su2vector ClosestWall_Zone; /*!< \brief Zone index of closest wall element. */ + su2vector ClosestWall_Marker; /*!< \brief Marker index of closest wall element, for given rank and zone index. */ + su2vector ClosestWall_Elem; /*!< \brief Element index of closest wall element, for givenrank, zone and marker index. */ + su2activevector SharpEdge_Distance; /*!< \brief Distance to a sharp edge. */ su2activevector Curvature; /*!< \brief Value of the surface curvature (SU2_GEO). */ su2activevector MaxLength; /*!< \brief The maximum cell-center to cell-center length. */ @@ -415,8 +423,22 @@ class CPoint { * \brief Set the value of the distance to the nearest wall. * \param[in] iPoint - Index of the point. * \param[in] distance - Value of the distance. - */ - inline void SetWall_Distance(unsigned long iPoint, su2double distance) { Wall_Distance(iPoint) = distance; } + * \param[in] rankID - Rank of process holding the closest wall element. + * \param[in] zoneID - Zone index of closest wall element. + * \param[in] markerID - Marker index of closest wall element. + * \param[in] elemID - Element index of closest wall element. + */ + inline void SetWall_Distance(unsigned long iPoint, su2double distance, + int rankID = -1, + unsigned short zoneID = numeric_limits::max(), + unsigned short markerID = numeric_limits::max(), + unsigned long elemID = numeric_limits::max() ) { + Wall_Distance(iPoint) = distance; + ClosestWall_Rank(iPoint) = rankID; + ClosestWall_Zone(iPoint) = zoneID; + ClosestWall_Marker(iPoint) = markerID; + ClosestWall_Elem(iPoint) = elemID; + } /*! * \brief Get the value of the distance to the nearest wall. @@ -829,4 +851,9 @@ class CPoint { */ void SetIndex(unsigned long iPoint, bool input); + /*! + * \brief Set wall roughnesses according to stored closest wall information. + * \param[in] roughness - Mapping [rank][zone][marker] -> roughness + */ + void SetWallRoughness(NdFlattener const& roughness); }; diff --git a/Common/include/ndflattener.hpp b/Common/include/ndflattener.hpp new file mode 100644 index 00000000000..616598632a0 --- /dev/null +++ b/Common/include/ndflattener.hpp @@ -0,0 +1,556 @@ +/*! + * \file ndflattener.hpp + * \brief Flatten pointer-to-pointer-... arrays for MPI communication + * \author M. Aehle + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include +#include +#include +#include + + + +template +struct MPI_Environment { + MPI_Allgatherv_type MPI_Allgatherv; + MPI_Datatype_type mpi_data; + MPI_Datatype_type mpi_index; + MPI_Communicator_type comm; + int rank; int size; +}; + +/*! + * \class NdFlattener + * \brief Serialize pointer-to-pointer-... array into one 1D array, keeping track + * of the offsets in few additional 1D arrays. + * + * The pointer-to-pointer-... array can be provided by a nested lambda function + * ('recursive function') or by gathering such arrays from MPI processes ('collective + * communication'). After initializing an NdFlattener with either of these data, + * it can be refreshed in the same way after the the pointer-to-pointer-... array's + * values (but not its structure) have changed. + * + * \tparam Data - Type of stored array data + * \tparam K - (number of layers) = (number of indices) - 1 + * \tparam Index - Type of index + */ + +/* --- Implementation details--- + * If you array has (K+1) indices, instantiate this class with template parameter K, + * which is derived recursively from this class with template parameter (K-1). + * In each layer, there is an array: Of type Data for K=0, and of type Index for K>0. + * + * The data array of K=0 contains the values of the array A in lexicographic ordering: + * [0]...[0][0][0], [0]...[0][0][1], ..., [0]...[0][0][something], + * [0]...[0][1][0], [0]...[0][1][1], ..., [0]...[0][1][something], + * ..., + * [0]...[1][0][0], [0]...[1][0][1], ..., [0]...[1][0][something], + * ... ..., + * [1]...[0][0][0], [1]...[0][0][1], ..., [1]...[0][0][something], + * ... ... ... + * Let us call each row in this representation a "last-index list". + * Note that they might have different lengths, so "something" might stand for different + * values here. Last-index lists can also be empty. + * + * The indices array of K=1 contains the indices of the (K=0)-data array at which a new + * last-index list starts. If a last-index list is empty, the are repetitive entries in the + * indices array. + * + * The indices array of K=2 contains the indices of the (K=1)-indices array at which the + * last-but-two index increases by one or drops to zero. If the last-but-two index is increased + * by more than one, there are repetitive entries. + * + * Etc. etc, up to the indices array at layer K. + * + * To form such a structure, we typically iterate twice through the pointer-to-pointer-... + * array: The first time we get to know how much space to reserve in each layer, then we + * allocate it and fill it with data during the second iteration. + */ + +template +class NdFlattener: public NdFlattener{ +public: + typedef NdFlattener Base; // could also be named LowerLayer + typedef NdFlattener CurrentLayer; + typedef typename Base::LowestLayer LowestLayer; // the K=0 class + +private: + /*! \brief Number of nodes in this layer. + * + * For the layer K=0, nNodes will be the number of data points. + */ + Index nNodes=0; + + /*! \brief Iterator used at construction, runs from 0 to nNodes. */ + Index iNode=0; + + /*! \brief Indices in the lower layer's indices or data array */ + Index* indices=nullptr; + + /*! \brief Return a const pointer to the base class (one layer down). + */ + Base const* cast_to_Base() const { + return (Base const*)this; + } + + /*=== Outputting ===*/ + +public: + /*! \brief Return a python-style list string. + * + * Like this: [[1, 2], [10, 20, 30]] + */ + std::string toPythonString() const { + return toPythonString_fromto(0, getNChildren()); + } +protected: + /*! \brief Return a python-style list string, using the data of the + * indices array between 'from' (inclusive) and 'to' (exclusive). + * + * Like this: [[1, 2], [10, 20, 30]] + * \param[in] from - Beginning of the representation in the indices array. + * \param[in] to - Ending of the representation in the indices array. + */ + std::string toPythonString_fromto(Index from, Index to) const { + std::string result = "["; + for(Index i=from; i + void initialize_or_refresh(ARGS... args){ + if( initialized() ){ + refresh(args...); + } else { + initialize(args...); + } + } + + /*! \brief Initialization status of the NdFlattener. + * \returns true if the NdFlattener has been initialized + */ + bool initialized(){ + return (indices!=nullptr); + } + + + virtual ~NdFlattener(void) { + if(indices!=nullptr) + delete[] indices; + } + + +protected: + /*! \brief Allocate the indices array after \a nNodes has been determined. + */ + void allocate() { + indices = new Index[nNodes+1]; + indices[0] = 0; + Base::allocate(); + } + + /*! \brief Set \a iNode to 0 in all layers. + */ + void reset_iNode(){ + iNode = 0; + Base::reset_iNode(); + } + + /*=== Construct from 'recursive function' ===*/ +public: + /*! \brief Initialize from a 'recursive function'. + * + * The function should return a pair. Its first entry is the number of children. + * Its second entry is a function with the same meaning, recursively + * one layer down. + * \param f - the 'recursive function' + */ + template + void initialize(f_type f) { + count_f(f); + allocate(); + set_f(f, false); + } + + /*! \brief Refresh the data according to the 'recursive function' + * + * The NdFlattener must have been constructed with a 'recursive function'. + * Now refresh the values with another 'recursive function'. The subarray lengths + * resulting from both 'recursive functions' must coincide, as the indices arrays + * are not changed. + * + * \param f - the 'recursive function' + * \tparam f_type - to allow for any type of the 'recursive function' + */ + template + void refresh(f_type f){ + reset_iNode(); + set_f(f, true); + } + +protected: + /*! \brief Determine the space required for reading the 'recursive function'. + * + * \param f - the 'recursive function' + */ + template + void count_f(f_type f) { + Index nChild = f.first; + for(Index iChild=0; iChild + void set_f(f_type f, bool refresh) { + Index nChild = f.first; + for(Index iChild=0; iChild + void initialize( + MPI_Environment const& mpi_env, + Base const* local_version + ) { + Index** Nodes_all = new Index*[K+1]; // [k][r] is number of all nodes in layer k, rank r in the new structure + for(int k=0; k + void refresh( + MPI_Environment const& mpi_env, + Base const* local_version + ) { + Index* Nodes_all_0 = nullptr; + int* displs = new int[mpi_env.size]; // {0, 1, ..., size-1} + int* ones = new int[mpi_env.size]; // {1,1, ...} + for(int r=0; r + void count_g(MPI_Environment const& mpi_env, + Index** Nodes_all, + CurrentLayer const* local_version, + int const* displs, int const* ones ) + { + assert( Nodes_all[K]==nullptr); + Nodes_all[K] = new Index[mpi_env.size]; + nNodes = 0; + // gather numbers of nodes in the current layer from all processes + mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + for(int r=0; rcast_to_Base(), displs, ones); + } + + /*! \brief Gather the distributed flatteners' arrays into the allocated arrays. + * + * \param[in] mpi_env - MPI environment for communication + * \param[in] Nodes_all - [k][r] is the number of nodes in layer k, rank r. + * \param[in] local_version - local instance to be send to the other processes + */ + template + void set_g(MPI_Environment const& mpi_env, + Index** Nodes_all, + CurrentLayer const* local_version ) + { + + int* Nodes_all_K_as_int = new int[mpi_env.size]; + int* Nodes_all_k_cumulated = new int[mpi_env.size+1]; // [r] is number of nodes in the current layer, summed over all processes with rank below r + // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the last element of indices, + // which is the local nNodes of the layer below. Note that MPI needs indices in type 'int'. + Nodes_all_k_cumulated[0] = 1; + for(int r=0; rindices+1, Nodes_all[K][mpi_env.rank], mpi_env.mpi_index, indices, Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + // shift indices + for(int r=1; rcast_to_Base()); + } + + + + + /*=== Access to data and numbers of children ===*/ +protected: + template + Data get_withoffset(Index offset, Index i1, ARGS... i2) const { + return Base::get_withoffset(indices[offset+i1], i2...); + } + template + Index getNChildren_withoffset(Index offset, Index i1, ARGS... i2) const { + return Base::getNChildren_withoffset(indices[offset+i1], i2...); + } + Index getNChildren_withoffset(Index offset, Index i) const { + return indices[offset+i+1] - indices[offset+i]; + } +public: + /*! \brief Index look-up. + * + * The number of parameters must be (K+1). + */ + template + Data get(ARGS... i) const { + return get_withoffset(0, i...); + } + /*! \brief Look-up of length of the next-layer sublist. + * + * Specify less than (K+1) indices. When the function returns N, + * the next index must lie inside {0, 1, ..., N-1}. + */ + template + Index getNChildren(ARGS... i) const { + return getNChildren_withoffset(0, i...); + } + Index getNChildren() const { // should not be called be recursion + return nNodes; + } + + +}; + +template +class NdFlattener { +public: + typedef NdFlattener CurrentLayer; + typedef CurrentLayer LowestLayer; + +private: + Index nNodes=0; + Index iNode=0; + Data* data=nullptr; + + /*=== Outputting ===*/ +protected: + std::string toPythonString_fromto(Index from, Index to) const { + std::stringstream result; + result << "["; + for(Index i=from; i + void count_f(f_type f){ + nNodes += f.first; + } + + template + void set_f(f_type f, bool refresh){ + Index nChild = f.first; + for(Index iChild=0; iChild + void count_g(MPI_Environment const& mpi_env, + Index** Nodes_all, + CurrentLayer const* local_version, + int const* displs, int const* ones) + { + assert( Nodes_all[0]==nullptr); + Nodes_all[0] = new Index[mpi_env.size]; + nNodes = 0; + // gather numbers of nodes in the current layer from all processes + mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + for(int r=0; r + void set_g(MPI_Environment mpi_env, + Index** Nodes_all, + CurrentLayer const* local_version ) + { + + + int* Nodes_all_0_as_int = new int[mpi_env.size]; + int* Nodes_all_0_cumulated = new int[mpi_env.size+1]; + Nodes_all_0_cumulated[0] = 0; + for(int r=0; rdata, Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data, Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); + delete[] Nodes_all_0_as_int; + delete[] Nodes_all_0_cumulated; + } + + + /*== Access to data and numbers of children ==*/ +protected: + Data get_withoffset(Index offset, Index i) const{ + return data[offset+i]; + } +public: + Data get(Index i) const{ + return get_withoffset(0, i); + } + + +}; + + diff --git a/Common/src/fem/fem_wall_distance.cpp b/Common/src/fem/fem_wall_distance.cpp index 5273732594c..d8830797e5f 100644 --- a/Common/src/fem/fem_wall_distance.cpp +++ b/Common/src/fem/fem_wall_distance.cpp @@ -172,7 +172,7 @@ void CMeshFEM_DG::SetWallDistance(su2double val){ } } -void CMeshFEM_DG::SetWallDistance(CADTElemClass *WallADT, const CConfig *config, const CGeometry* geometry){ +void CMeshFEM_DG::SetWallDistance(CADTElemClass *WallADT, const CConfig* config, unsigned short iZone){ /*--------------------------------------------------------------------------*/ /*--- Step 3: Determine the wall distance of the integration points of ---*/ diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index ffa96bce168..545d9b5490a 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -29,6 +29,7 @@ #include "../../include/geometry/elements/CElement.hpp" #include "../../include/parallelization/omp_structure.hpp" #include "../../include/toolboxes/geometry_toolbox.hpp" +#include "../../include/ndflattener.hpp" CGeometry::CGeometry(void) : size(SU2_MPI::GetSize()), @@ -3922,20 +3923,14 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo /*--- Loop over all zones and compute the ADT based on the viscous walls in that zone ---*/ for (int iZone = 0; iZone < nZone; iZone++){ - CGeometry *geometry = geometry_container[iZone][iInst][MESH_0]; - const CConfig *config = config_container[iZone]; - unique_ptr WallADT = geometry->ComputeViscousWallADT(config); + unique_ptr WallADT = geometry_container[iZone][iInst][MESH_0]->ComputeViscousWallADT(config_container[iZone]); if (WallADT && !WallADT->IsEmpty()){ allEmpty = false; - /*--- Along with finding the closest walls, we collect their roughnesses. ---*/ - if (config_container[iZone]->GetnRoughWall() > 0) - geometry->SetGlobalMarkerRoughness(config); - /*--- Inner loop over all zones to update the wall distances. * It might happen that there is a closer viscous wall in zone iZone for points in zone jZone. ---*/ for (int jZone = 0; jZone < nZone; jZone++){ if (wallDistanceNeeded[jZone]) - geometry_container[jZone][iInst][MESH_0]->SetWallDistance(WallADT.get(), config, geometry); + geometry_container[jZone][iInst][MESH_0]->SetWallDistance(WallADT.get(), config_container[jZone], iZone); } } } @@ -3947,5 +3942,36 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo geometry->SetWallDistance(0.0); } } + /*--- Otherwise, set wall roughnesses. ---*/ + if(!allEmpty){ + /*--- Store all wall roughnesses in a common data structure. ---*/ + // prepare parameters for collective communication + MPI_Environment mpi_env; + mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); + mpi_env.mpi_index = MPI_UNSIGNED_LONG; + mpi_env.mpi_data = MPI_DOUBLE; + mpi_env.comm=SU2_MPI::GetComm(); + SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); + SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); + // [iZone][iMarker] -> roughness, for this rank + auto roughness_f = + make_pair( nZone, [=](unsigned long iZone){ + const CConfig* config = config_container[iZone]; + return make_pair( geometry_container[iZone][iInst][MESH_0]->GetnMarker() , [=](unsigned long iMarker){ + return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; + }); + }); + NdFlattener roughness_local; + roughness_local.initialize_or_refresh(roughness_f); + // [rank][iZone][iMarker] -> roughness + NdFlattener roughness_global; + roughness_global.initialize_or_refresh(mpi_env, &(roughness_local)); + // use it to update roughnesses + for(int jZone=0; jZoneGetnRoughWall()>0){ + geometry_container[jZone][iInst][MESH_0]->nodes->SetWallRoughness(roughness_global); + } + } + } } } diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index c2cc183420b..5bebaded5f0 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -11017,7 +11017,7 @@ std::unique_ptr CPhysicalGeometry::ComputeViscousWallADT(const CC } -void CPhysicalGeometry::SetWallDistance(CADTElemClass* WallADT, const CConfig *config, const CGeometry* geometry) { +void CPhysicalGeometry::SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) { /*--------------------------------------------------------------------------*/ /*--- Step 3: Loop over all interior mesh nodes and compute minimum ---*/ @@ -11039,51 +11039,10 @@ void CPhysicalGeometry::SetWallDistance(CADTElemClass* WallADT, const CConfig *c WallADT->DetermineNearestElement(nodes->GetCoord(iPoint), dist, markerID, elemID, rankID); if(dist < nodes->GetWall_Distance(iPoint)){ - nodes->SetWall_Distance(iPoint, dist); - - if (config->GetnRoughWall() > 0) { - const CPhysicalGeometry* ph_geometry = dynamic_cast(geometry); - auto index = ph_geometry->GlobalMarkerStorageDispl[rankID] + markerID; - su2double localRoughness = ph_geometry->GlobalRoughness_Height[index]; - nodes->SetRoughnessHeight(iPoint, localRoughness); - } + nodes->SetWall_Distance(iPoint, dist, rankID, iZone, markerID, elemID); } } END_SU2_OMP_FOR - } END_SU2_OMP_PARALLEL } - -void CPhysicalGeometry::SetGlobalMarkerRoughness(const CConfig* config) { - - const auto nMarker_All = config->GetnMarker_All(); - - vector recvCounts(size); - auto sizeLocal = static_cast(nMarker_All); // number of local markers - - /*--- Communicate size of local marker array and make an array large enough to hold all data. ---*/ - SU2_MPI::Allgather(&sizeLocal, 1, MPI_INT, recvCounts.data(), 1, MPI_INT, SU2_MPI::GetComm()); - - /*--- Set the global array of displacements, needed to access the correct roughness element. ---*/ - GlobalMarkerStorageDispl.resize(size); - GlobalMarkerStorageDispl[0] = 0; - for (int iRank = 1; iRank < size; iRank++) - GlobalMarkerStorageDispl[iRank] = GlobalMarkerStorageDispl[iRank-1] + recvCounts[iRank-1]; - - /*--- Total size ---*/ - const auto sizeGlobal = GlobalMarkerStorageDispl[size-1] + recvCounts[size-1]; - - /*--- Allocate local and global arrays to hold roughness. ---*/ - vector localRough(nMarker_All); // local number of markers - GlobalRoughness_Height.resize(sizeGlobal); // all markers including send recieve - - for (auto iMarker = 0u; iMarker < nMarker_All; iMarker++) { - auto wallprop = config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)); - localRough[iMarker] = wallprop.second; - } - - /*--- Finally, gather the roughness of all markers. ---*/ - SU2_MPI::Allgatherv(localRough.data(), sizeLocal, MPI_DOUBLE, GlobalRoughness_Height.data(), - recvCounts.data(), GlobalMarkerStorageDispl.data(), MPI_DOUBLE, SU2_MPI::GetComm()); -} diff --git a/Common/src/geometry/dual_grid/CPoint.cpp b/Common/src/geometry/dual_grid/CPoint.cpp index 810f60321b6..ed474a6ad71 100644 --- a/Common/src/geometry/dual_grid/CPoint.cpp +++ b/Common/src/geometry/dual_grid/CPoint.cpp @@ -125,7 +125,13 @@ void CPoint::FullAllocation(unsigned short imesh, const CConfig *config) { nNeighbor.resize(npoint) = 0; MaxLength.resize(npoint) = su2double(0.0); Curvature.resize(npoint) = su2double(0.0); + Wall_Distance.resize(npoint) = su2double(0.0); + ClosestWall_Rank.resize(npoint) = -1; + ClosestWall_Zone.resize(npoint) = numeric_limits::max(); + ClosestWall_Marker.resize(npoint) = numeric_limits::max(); + ClosestWall_Elem.resize(npoint) = numeric_limits::max(); + RoughnessHeight.resize(npoint) = su2double(0.0); SharpEdge_Distance.resize(npoint) = su2double(0.0); @@ -179,3 +185,14 @@ void CPoint::SetCoord_Old() { } void CPoint::SetCoord_SumZero() { parallelSet(Coord_Sum.size(), 0.0, Coord_Sum.data()); } + +void CPoint::SetWallRoughness(NdFlattener const& roughness){ + for (unsigned long iPoint=0; iPoint Date: Fri, 14 May 2021 10:55:59 +0200 Subject: [PATCH 088/192] Index shift for K in NdFlattener is number of indices now, not (number of indices)-1. --- Common/include/geometry/dual_grid/CPoint.hpp | 2 +- Common/include/ndflattener.hpp | 76 ++++++++++---------- Common/src/geometry/CGeometry.cpp | 4 +- Common/src/geometry/dual_grid/CPoint.cpp | 2 +- 4 files changed, 43 insertions(+), 41 deletions(-) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index d6cc87c3dbc..2350907ab16 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -855,5 +855,5 @@ class CPoint { * \brief Set wall roughnesses according to stored closest wall information. * \param[in] roughness - Mapping [rank][zone][marker] -> roughness */ - void SetWallRoughness(NdFlattener const& roughness); + void SetWallRoughness(NdFlattener const& roughness); }; diff --git a/Common/include/ndflattener.hpp b/Common/include/ndflattener.hpp index 616598632a0..5d2e3479dcf 100644 --- a/Common/include/ndflattener.hpp +++ b/Common/include/ndflattener.hpp @@ -55,16 +55,16 @@ struct MPI_Environment { * values (but not its structure) have changed. * * \tparam Data - Type of stored array data - * \tparam K - (number of layers) = (number of indices) - 1 + * \tparam K - number of indices * \tparam Index - Type of index */ /* --- Implementation details--- - * If you array has (K+1) indices, instantiate this class with template parameter K, + * If your array has K indices, instantiate this class with template parameter K, * which is derived recursively from this class with template parameter (K-1). - * In each layer, there is an array: Of type Data for K=0, and of type Index for K>0. + * In each layer, there is an array: Of type Data for K=1, and of type Index for K>1. * - * The data array of K=0 contains the values of the array A in lexicographic ordering: + * The data array of K=1 contains the values of the array A in lexicographic ordering: * [0]...[0][0][0], [0]...[0][0][1], ..., [0]...[0][0][something], * [0]...[0][1][0], [0]...[0][1][1], ..., [0]...[0][1][something], * ..., @@ -76,11 +76,11 @@ struct MPI_Environment { * Note that they might have different lengths, so "something" might stand for different * values here. Last-index lists can also be empty. * - * The indices array of K=1 contains the indices of the (K=0)-data array at which a new + * The indices array of K=2 contains the indices of the (K=1)-data array at which a new * last-index list starts. If a last-index list is empty, the are repetitive entries in the * indices array. * - * The indices array of K=2 contains the indices of the (K=1)-indices array at which the + * The indices array of K=3 contains the indices of the (K=2)-indices array at which the * last-but-two index increases by one or drops to zero. If the last-but-two index is increased * by more than one, there are repetitive entries. * @@ -96,16 +96,17 @@ class NdFlattener: public NdFlattener{ public: typedef NdFlattener Base; // could also be named LowerLayer typedef NdFlattener CurrentLayer; - typedef typename Base::LowestLayer LowestLayer; // the K=0 class + typedef typename Base::LowestLayer LowestLayer; // the K=1 class private: /*! \brief Number of nodes in this layer. * - * For the layer K=0, nNodes will be the number of data points. + * For the layer K=1, nNodes will be the number of data points. + * For a layer K>1, nNodes will be the number of sublists. */ Index nNodes=0; - /*! \brief Iterator used at construction, runs from 0 to nNodes. */ + /*! \brief Iterator used at construction, runs from 0 to (nNodes-1). */ Index iNode=0; /*! \brief Indices in the lower layer's indices or data array */ @@ -150,6 +151,7 @@ class NdFlattener: public NdFlattener{ /*! \brief Basic constructor. * * Called recursively when a derived class (higher K) is constructed. + * Allocation is done later with initialize_or_refresh. */ NdFlattener() {}; @@ -157,7 +159,7 @@ class NdFlattener: public NdFlattener{ * \details Either a 'recursive function' or 'collective communication' * may be used. When the NdFlattener does not hold data yet, it is * initialized, meaning that the data are collected and the indices arrays - * are formed. Otherwise it is refreshed, meaning that the data are + * are allocated and filled. Otherwise it is refreshed, meaning that the data are * recollected under the assumption that the indices arrays did not change. */ template @@ -249,7 +251,7 @@ class NdFlattener: public NdFlattener{ * * \param f - the 'recursive function' * \param refresh - if true, the object is already initialized and only the data - * in layer 0 have to be overwritten + * in layer 1 have to be overwritten * \tparam f_type - to allow for any type of the 'recursive function' */ template @@ -270,40 +272,40 @@ class NdFlattener: public NdFlattener{ /*=== Construct with Allgatherv ===*/ public: - /*! \brief Initialize a flattener with (K+1) indices by combining distributed flatteners with K indices each. + /*! \brief Initialize a flattener with K indices by combining distributed flatteners with (K-1) indices each. * * The new first index will encode the rank of the process. Data is exchanged in MPI::Allgatherv-style * collective communication. * \param[in] mpi_env - The MPI environment used for communication. - * \param[in] local_version - The local NdFlattener structure. + * \param[in] local_version - The local NdFlattener structure with (K-1) indices. */ template void initialize( MPI_Environment const& mpi_env, Base const* local_version ) { - Index** Nodes_all = new Index*[K+1]; // [k][r] is number of all nodes in layer k, rank r in the new structure - for(int k=0; k{ } protected: - /*! \brief Gather the distributed flatteners' arrays into the allocated arrays. + /*! \brief Count the distributed flatteners' numbers of nodes, and set nNodes. * * \param[in] mpi_env - MPI environment for communication - * \param[out] Nodes_all - [k][r] is set to number of nodes in layer k, rank r. + * \param[out] Nodes_all - [k][r] is set to number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be send to the other processes * \param[in] displs - {0,1,...,size-1} * \param[in] ones - {1,1,...,1} @@ -355,21 +357,21 @@ class NdFlattener: public NdFlattener{ CurrentLayer const* local_version, int const* displs, int const* ones ) { - assert( Nodes_all[K]==nullptr); - Nodes_all[K] = new Index[mpi_env.size]; + assert( Nodes_all[K-1]==nullptr); + Nodes_all[K-1] = new Index[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; rcast_to_Base(), displs, ones); } - /*! \brief Gather the distributed flatteners' arrays into the allocated arrays. + /*! \brief Gather the distributed flatteners' data and index arrays into the allocated arrays. * * \param[in] mpi_env - MPI environment for communication - * \param[in] Nodes_all - [k][r] is the number of nodes in layer k, rank r. + * \param[in] Nodes_all - [k][r] is the number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be send to the other processes */ template @@ -381,13 +383,13 @@ class NdFlattener: public NdFlattener{ int* Nodes_all_K_as_int = new int[mpi_env.size]; int* Nodes_all_k_cumulated = new int[mpi_env.size+1]; // [r] is number of nodes in the current layer, summed over all processes with rank below r // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the last element of indices, - // which is the local nNodes of the layer below. Note that MPI needs indices in type 'int'. + // which is the local nNodes of the layer below. Note that MPI needs indices of type 'int'. Nodes_all_k_cumulated[0] = 1; for(int r=0; rindices+1, Nodes_all[K][mpi_env.rank], mpi_env.mpi_index, indices, Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv( local_version->indices+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices, Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); // shift indices for(int r=1; r{ public: /*! \brief Index look-up. * - * The number of parameters must be (K+1). + * The number of parameters must be K. */ template Data get(ARGS... i) const { @@ -430,14 +432,14 @@ class NdFlattener: public NdFlattener{ } /*! \brief Look-up of length of the next-layer sublist. * - * Specify less than (K+1) indices. When the function returns N, + * Specify less than K indices. When the function returns N, * the next index must lie inside {0, 1, ..., N-1}. */ template Index getNChildren(ARGS... i) const { return getNChildren_withoffset(0, i...); } - Index getNChildren() const { // should not be called be recursion + Index getNChildren() const { // should not be called by recursion return nNodes; } @@ -445,9 +447,9 @@ class NdFlattener: public NdFlattener{ }; template -class NdFlattener { +class NdFlattener { public: - typedef NdFlattener CurrentLayer; + typedef NdFlattener CurrentLayer; typedef CurrentLayer LowestLayer; private: diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 545d9b5490a..e804afc5c0d 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3961,10 +3961,10 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); }); - NdFlattener roughness_local; + NdFlattener roughness_local; roughness_local.initialize_or_refresh(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener roughness_global; + NdFlattener roughness_global; roughness_global.initialize_or_refresh(mpi_env, &(roughness_local)); // use it to update roughnesses for(int jZone=0; jZone const& roughness){ +void CPoint::SetWallRoughness(NdFlattener const& roughness){ for (unsigned long iPoint=0; iPoint Date: Fri, 14 May 2021 11:25:09 +0200 Subject: [PATCH 089/192] corrections resolves the warning: comparison between signed and unsigned integer expression --- Common/include/ndflattener.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/ndflattener.hpp b/Common/include/ndflattener.hpp index 5d2e3479dcf..b1ffdeeeaaa 100644 --- a/Common/include/ndflattener.hpp +++ b/Common/include/ndflattener.hpp @@ -285,7 +285,7 @@ class NdFlattener: public NdFlattener{ Base const* local_version ) { Index** Nodes_all = new Index*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure - for(int k=0; k{ } Base::set_g(mpi_env, Nodes_all, local_version); - for(int k=0; k Date: Fri, 14 May 2021 14:57:04 +0200 Subject: [PATCH 090/192] improvements proposed by @pcarruscag --- Common/include/ndflattener.hpp | 140 +++++++++++++++--------------- Common/src/geometry/CGeometry.cpp | 20 ++--- 2 files changed, 77 insertions(+), 83 deletions(-) diff --git a/Common/include/ndflattener.hpp b/Common/include/ndflattener.hpp index b1ffdeeeaaa..29dc4165706 100644 --- a/Common/include/ndflattener.hpp +++ b/Common/include/ndflattener.hpp @@ -31,17 +31,32 @@ #include #include #include +#include +#include "parallelization/mpi_structure.hpp" - +namespace helpers { template -struct MPI_Environment { - MPI_Allgatherv_type MPI_Allgatherv; - MPI_Datatype_type mpi_data; - MPI_Datatype_type mpi_index; - MPI_Communicator_type comm; - int rank; int size; -}; + struct NdFlattener_MPI_Environment { + MPI_Allgatherv_type MPI_Allgatherv; + MPI_Datatype_type mpi_data; + MPI_Datatype_type mpi_index; + MPI_Communicator_type comm; + int rank; int size; + }; +} // namespace helpers + +static helpers::NdFlattener_MPI_Environment +Get_Nd_MPI_Env() { + helpers::NdFlattener_MPI_Environment mpi_env; + mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); + mpi_env.mpi_index = MPI_UNSIGNED_LONG; + mpi_env.mpi_data = MPI_DOUBLE; + mpi_env.comm=SU2_MPI::GetComm(); + SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); + SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); + return mpi_env; +} /*! * \class NdFlattener @@ -110,51 +125,54 @@ class NdFlattener: public NdFlattener{ Index iNode=0; /*! \brief Indices in the lower layer's indices or data array */ - Index* indices=nullptr; - - /*! \brief Return a const pointer to the base class (one layer down). - */ - Base const* cast_to_Base() const { - return (Base const*)this; - } + std::vector indices; /*=== Outputting ===*/ public: - /*! \brief Return a python-style list string. + /*! \brief Write in Python-list style. * * Like this: [[1, 2], [10, 20, 30]] */ - std::string toPythonString() const { - return toPythonString_fromto(0, getNChildren()); + friend std::ostream& operator<<(std::ostream& output, NdFlattener const& nd) { + nd.toPythonString_fromto(output, 0, nd.getNChildren()); + return output; } + protected: - /*! \brief Return a python-style list string, using the data of the + /*! \brief Write to stream in Python-list style, using the data of the * indices array between 'from' (inclusive) and 'to' (exclusive). * * Like this: [[1, 2], [10, 20, 30]] + * \param[in] output - Stream * \param[in] from - Beginning of the representation in the indices array. * \param[in] to - Ending of the representation in the indices array. */ - std::string toPythonString_fromto(Index from, Index to) const { - std::string result = "["; + void toPythonString_fromto(std::ostream& output, Index from, Index to) const { + output << "["; for(Index i=from; i + NdFlattener(ARGS... args) { + initialize_or_refresh(args...); + }; + /*! \brief Initialize or refresh the NdFlattener. * \details Either a 'recursive function' or 'collective communication' * may be used. When the NdFlattener does not hold data yet, it is @@ -175,21 +193,14 @@ class NdFlattener: public NdFlattener{ * \returns true if the NdFlattener has been initialized */ bool initialized(){ - return (indices!=nullptr); - } - - - virtual ~NdFlattener(void) { - if(indices!=nullptr) - delete[] indices; + return indices.size()>0; } - protected: /*! \brief Allocate the indices array after \a nNodes has been determined. */ void allocate() { - indices = new Index[nNodes+1]; + indices.reserve(nNodes+1); indices[0] = 0; Base::allocate(); } @@ -279,9 +290,9 @@ class NdFlattener: public NdFlattener{ * \param[in] mpi_env - The MPI environment used for communication. * \param[in] local_version - The local NdFlattener structure with (K-1) indices. */ - template + template void initialize( - MPI_Environment const& mpi_env, + MPI_Environment_type const& mpi_env, Base const* local_version ) { Index** Nodes_all = new Index*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure @@ -322,9 +333,9 @@ class NdFlattener: public NdFlattener{ * \param[in] mpi_env - The MPI environment used for communication. * \param[in] local_version - The local NdFlattener structure. */ - template + template void refresh( - MPI_Environment const& mpi_env, + MPI_Environment_type const& mpi_env, Base const* local_version ) { Index* Nodes_all_0 = nullptr; @@ -334,8 +345,8 @@ class NdFlattener: public NdFlattener{ displs[r] = r; ones[r] = 1; } - LowestLayer::count_g(mpi_env, &Nodes_all_0, (LowestLayer const*)local_version, displs, ones); - LowestLayer::set_g(mpi_env, &Nodes_all_0, (LowestLayer const*)local_version); + LowestLayer::count_g(mpi_env, &Nodes_all_0, static_cast(local_version), displs, ones); + LowestLayer::set_g(mpi_env, &Nodes_all_0, static_cast(local_version)); delete[] Nodes_all_0; // allocated by count_g delete[] displs; @@ -351,8 +362,8 @@ class NdFlattener: public NdFlattener{ * \param[in] displs - {0,1,...,size-1} * \param[in] ones - {1,1,...,1} */ - template - void count_g(MPI_Environment const& mpi_env, + template + void count_g(MPI_Environment_type const& mpi_env, Index** Nodes_all, CurrentLayer const* local_version, int const* displs, int const* ones ) @@ -365,7 +376,7 @@ class NdFlattener: public NdFlattener{ for(int r=0; rcast_to_Base(), displs, ones); + Base::count_g(mpi_env, Nodes_all, static_cast(local_version), displs, ones); } /*! \brief Gather the distributed flatteners' data and index arrays into the allocated arrays. @@ -374,8 +385,8 @@ class NdFlattener: public NdFlattener{ * \param[in] Nodes_all - [k][r] is the number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be send to the other processes */ - template - void set_g(MPI_Environment const& mpi_env, + template + void set_g(MPI_Environment_type const& mpi_env, Index** Nodes_all, CurrentLayer const* local_version ) { @@ -389,7 +400,7 @@ class NdFlattener: public NdFlattener{ Nodes_all_k_cumulated[r+1] = Nodes_all_k_cumulated[r] + Nodes_all[K-1][r]; Nodes_all_K_as_int[r] = Nodes_all[K-1][r]; } - mpi_env.MPI_Allgatherv( local_version->indices+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices, Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv( local_version->indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); // shift indices for(int r=1; r{ delete[] Nodes_all_K_as_int; delete[] Nodes_all_k_cumulated; - Base::set_g(mpi_env, Nodes_all, local_version->cast_to_Base()); + Base::set_g(mpi_env, Nodes_all, static_cast(local_version)); } @@ -455,32 +466,25 @@ class NdFlattener { private: Index nNodes=0; Index iNode=0; - Data* data=nullptr; + std::vector data; /*=== Outputting ===*/ protected: - std::string toPythonString_fromto(Index from, Index to) const { - std::stringstream result; - result << "["; + void toPythonString_fromto(std::ostream& output, Index from, Index to) const { + output << "["; for(Index i=from; i { /*=== Construct with Allgatherv ===*/ protected: - template - void count_g(MPI_Environment const& mpi_env, + template + void count_g(MPI_Environment_type const& mpi_env, Index** Nodes_all, CurrentLayer const* local_version, int const* displs, int const* ones) @@ -521,8 +525,8 @@ class NdFlattener { } } - template - void set_g(MPI_Environment mpi_env, + template + void set_g(MPI_Environment_type const& mpi_env, Index** Nodes_all, CurrentLayer const* local_version ) { @@ -536,7 +540,7 @@ class NdFlattener { Nodes_all_0_as_int[r] = Nodes_all[0][r]; } - mpi_env.MPI_Allgatherv( local_version->data, Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data, Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); + mpi_env.MPI_Allgatherv( local_version->data.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); delete[] Nodes_all_0_as_int; delete[] Nodes_all_0_cumulated; } diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index e804afc5c0d..3e1d62baf82 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3944,28 +3944,18 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo } /*--- Otherwise, set wall roughnesses. ---*/ if(!allEmpty){ - /*--- Store all wall roughnesses in a common data structure. ---*/ - // prepare parameters for collective communication - MPI_Environment mpi_env; - mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); - mpi_env.mpi_index = MPI_UNSIGNED_LONG; - mpi_env.mpi_data = MPI_DOUBLE; - mpi_env.comm=SU2_MPI::GetComm(); - SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); - SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); + /*--- Store all wall roughnesses in a common data structure. ---*/ // [iZone][iMarker] -> roughness, for this rank auto roughness_f = - make_pair( nZone, [=](unsigned long iZone){ + make_pair( nZone, [config_container,geometry_container,iInst](unsigned long iZone){ const CConfig* config = config_container[iZone]; - return make_pair( geometry_container[iZone][iInst][MESH_0]->GetnMarker() , [=](unsigned long iMarker){ + return make_pair( geometry_container[iZone][iInst][MESH_0]->GetnMarker() , [config](unsigned long iMarker){ return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); }); - NdFlattener roughness_local; - roughness_local.initialize_or_refresh(roughness_f); + NdFlattener roughness_local(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener roughness_global; - roughness_global.initialize_or_refresh(mpi_env, &(roughness_local)); + NdFlattener roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); // use it to update roughnesses for(int jZone=0; jZoneGetnRoughWall()>0){ From 49f2d50c6390c8141100ed5eee1990f9112ebb11 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Fri, 14 May 2021 16:10:59 +0200 Subject: [PATCH 091/192] Addtional reg test screen output. Adapt unst cht adjoint FADO script to run adjoint as well. --- .../disc_adj_unsteadyCHT_cylinder/README.md | 14 +- .../chtMaster.cfg | 2 +- .../disc_adj_unsteadyCHT_cylinder/findiff.py | 76 ---------- .../gradient_validation.py | 139 ++++++++++++++++++ .../postprocess.py | 14 +- TestCases/parallel_regression_AD.py | 2 +- 6 files changed, 155 insertions(+), 92 deletions(-) delete mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py create mode 100644 TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md index 35403c1e17c..7440d8d4896 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md @@ -13,16 +13,18 @@ A gmsh .geo file is added such that the mesh can be recreated and modified. The primal for a full cycle can be restarted with the `solution_*_00000.dat` and `solution_*_00001.dat`. The primal solution is necessary for the Discrete Adjoint sweep and for the gradient of the full shedding cycle the full primal is necessary. The necessary changes to `chtMaster.cfg` are documented -in the config itself +in the config itself. ## Discrete Adjoint In the regression testcase of SU2 only 2 reverse steps are taken. For that, the solution files 52-55 for the adjoint are added. The objective Function is the average temperature on the inner pin surface, averaged over the full time. -## Finite Differences using FADO -In order to validate the Discrete Adjoint gradient a Finite Differences python script `findiff.py` +## Gradient validation via Finite Differences using FADO +In order to validate the Discrete Adjoint gradient a Finite Differences python script `gradient_validation.py` using [FADO](www.github.com/su2code/FADO) is added. -The script starts a baseline simulation and an additional for each of the 18 Design Variables. -Using the `postprocess.py` to print the absolute difference and relative difference in percent to screen. -Make sure to adapt the `chtMaster.cfg` as for the primal. +Note that the script can be used with the files as they are. Necessary adaptions are made by FADO itself. +The script deforms the mesh and runs the primal for each of the 18 Design Variables. +Afterwards the baseline mesh is evaluated and then the Discrete Adjoint. +Use `postprocess.py` to print the absolute difference and relative difference in percent to screen. + diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg index d4be542e290..6821416134a 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg @@ -37,7 +37,7 @@ ITER_AVERAGE_OBJ= 54 % MESH_FILENAME= MeshCHT.su2 % -SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, BGS_ADJ_PRESSURE[0], BGS_ADJ_VELOCITY-X[0], BGS_ADJ_VELOCITY-Y[0], BGS_ADJ_TEMPERATURE[0], BGS_ADJ_TEMPERATURE[1] ) +SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, BGS_ADJ_PRESSURE[0], BGS_ADJ_VELOCITY-X[0], BGS_ADJ_VELOCITY-Y[0], BGS_ADJ_TEMPERATURE[0], BGS_ADJ_TEMPERATURE[1], SENS_TEMP[0], SENS_GEO[0], SENS_GEO[1] ) % Suitable output for primal simulations %SCREEN_OUTPUT= (TIME_ITER, OUTER_ITER, WALL_TIME, BGS_PRESSURE[0], BGS_TEMPERATURE[0], BGS_TEMPERATURE[1], DRAG[0], AVG_TEMPERATURE[1] ) SCREEN_WRT_FREQ_OUTER= 50 diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py deleted file mode 100644 index c1672bfc9de..00000000000 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/findiff.py +++ /dev/null @@ -1,76 +0,0 @@ -# FADO script: Finite Differences of unsteady CHT - -from FADO import * - -# Design variables ----------------------------------------------------- # - -nDV = 18 -ffd = InputVariable(0.0,PreStringHandler("DV_VALUE="),nDV) - -# Parameters ----------------------------------------------------------- # - -# switch input mesh to perform deformation -mesh_in = Parameter(["MESH_FILENAME= mesh_out.su2"],\ - LabelReplacer("MESH_FILENAME= MeshCHT.su2")) - -# Evaluations ---------------------------------------------------------- # - -def_command = "SU2_DEF chtMaster.cfg" # Note that correct SU2 version needs to be in PATH -cfd_command = "mpirun -n 12 SU2_CFD chtMaster.cfg" - -max_tries = 1 - -# mesh deformation -deform = ExternalRun("DEFORM",def_command,True) # True means sym links are used for addData -deform.setMaxTries(max_tries) -deform.addConfig("chtMaster.cfg") -deform.addData("fluid.cfg") # zonal cfg's can be symlinked as they are unchanged -deform.addData("solid.cfg") -deform.addData("MeshCHT.su2") -deform.addExpected("mesh_out.su2") - -# direct run -direct = ExternalRun("DIRECT",cfd_command,True) -direct.setMaxTries(max_tries) -direct.addConfig("chtMaster.cfg") -direct.addData("fluid.cfg") -direct.addData("solid.cfg") -direct.addData("DEFORM/mesh_out.su2") -direct.addData("solution_0_00000.dat") -direct.addData("solution_0_00001.dat") -direct.addData("solution_1_00000.dat") -direct.addData("solution_1_00001.dat") -direct.addExpected("solution_0_00055.dat") -direct.addExpected("solution_1_00055.dat") -direct.addParameter(mesh_in) - -# Functions ------------------------------------------------------------ # - -tavgT = Function("tavgT", "DIRECT/chtMaster.csv",LabeledTableReader("\"tavg[AvgTemp[1]]\"")) -tavgT.addInputVariable(ffd,"",None) -tavgT.addValueEvalStep(deform) -tavgT.addValueEvalStep(direct) - -# Driver --------------------------------------------------------------- # - -driver = ExteriorPenaltyDriver(0.005) -driver.addObjective("min", tavgT) - -driver.setWorkingDirectory("DOE") -driver.preprocessVariables() -driver.setStorageMode(True,"DESIGN_") - -his = open("doe.his","w",1) -driver.setHistorian(his) - -# Finite Differences -x = driver.getInitial() -driver.fun(x) # baseline evaluation - -for iLoop in range(0, nDV, 1): - x = driver.getInitial() - x[iLoop] = 1e-4 # DV_VALUE - driver.fun(x) -#end - -his.close() diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py new file mode 100644 index 00000000000..003f742ce09 --- /dev/null +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py @@ -0,0 +1,139 @@ +# FADO script: Finite Differences of unsteady CHT and adjoint run + +from FADO import * + +# Design variables ----------------------------------------------------- # + +nDV = 18 +ffd = InputVariable(0.0,PreStringHandler("DV_VALUE="),nDV) + +# Parameters ----------------------------------------------------------- # + +# The master config `chtMaster.cfg` serves as an SU2 adjoint regression test. +# For a correct gradient validation we need to exchange some options + +time_iter_primal = Parameter(["TIME_ITER= 56"],\ + LabelReplacer("TIME_ITER= 54")) +outer_iter_primal = Parameter(["OUTER_ITER= 200"],\ + LabelReplacer("OUTER_ITER= 100")) +restart_sol_primal = Parameter(["RESTART_SOL= YES"],\ + LabelReplacer("RESTART_SOL= NO")) + +outer_iter_adjoint = Parameter(["OUTER_ITER= 500"],\ + LabelReplacer("OUTER_ITER= 100")) + +# Evaluations ---------------------------------------------------------- # + +# Note that correct SU2 version needs to be in PATH + +def_command = "SU2_DEF chtMaster.cfg" +cfd_command = "mpirun -n 12 SU2_CFD chtMaster.cfg" + +cfd_ad_command = "mpirun -n 12 SU2_CFD_AD chtMaster.cfg" +dot_ad_command = "mpirun -n 12 SU2_DOT_AD chtMaster.cfg" + +max_tries = 1 + +# mesh deformation +deform = ExternalRun("DEFORM",def_command,True) # True means sym links are used for addData +deform.setMaxTries(max_tries) +deform.addConfig("chtMaster.cfg") +deform.addData("fluid.cfg") # zonal cfg's can be symlinked as they are unchanged +deform.addData("solid.cfg") +deform.addData("MeshCHT.su2") +deform.addExpected("mesh_out.su2") + +# direct run +direct = ExternalRun("DIRECT",cfd_command,True) +direct.setMaxTries(max_tries) +direct.addConfig("chtMaster.cfg") +direct.addData("fluid.cfg") +direct.addData("solid.cfg") +direct.addData("DEFORM/mesh_out.su2",destination="MeshCHT.su2") +direct.addData("solution_0_00000.dat") +direct.addData("solution_0_00001.dat") +direct.addData("solution_1_00000.dat") +direct.addData("solution_1_00001.dat") +direct.addExpected("solution_0_00055.dat") +direct.addExpected("solution_1_00055.dat") +direct.addParameter(time_iter_primal) +direct.addParameter(outer_iter_primal) +direct.addParameter(restart_sol_primal) + +# adjoint run +adjoint = ExternalRun("ADJOINT",cfd_ad_command,True) +adjoint.setMaxTries(max_tries) +adjoint.addConfig("chtMaster.cfg") +adjoint.addData("fluid.cfg") # zonal cfg's can be symlinked +adjoint.addData("solid.cfg") +adjoint.addData("DEFORM/mesh_out.su2", destination="MeshCHT.su2") +# add all primal solution files +for timeIter in range(56): # + if timeIter < 10: + timeIter = "0" + str(timeIter) + adjoint.addData("DIRECT/solution_0_000" + str(timeIter) + ".dat") + adjoint.addData("DIRECT/solution_1_000" + str(timeIter) + ".dat") +#end +# replace OUTER_ITER= by 500 and TIME_ITER= 56 +adjoint.addParameter(outer_iter_adjoint) +adjoint.addExpected("solution_adj_avtp_0_00053.dat") +adjoint.addExpected("solution_adj_avtp_1_00053.dat") + +# gradient projection +dot = adjont = ExternalRun("DOT",dot_ad_command,True) +dot.setMaxTries(max_tries) +dot.addConfig("chtMaster.cfg") +dot.addData("fluid.cfg") # zonal cfg's can be symlinked +dot.addData("solid.cfg") +dot.addData("DEFORM/mesh_out.su2", destination="MeshCHT.su2") +# add all adjoint solution files +for timeIter in range(54): + if timeIter < 10: + timeIter = "0" + str(timeIter) + dot.addData("ADJOINT/solution_adj_avtp_0_000" + str(timeIter) + ".dat") + dot.addData("ADJOINT/solution_adj_avtp_1_000" + str(timeIter) + ".dat") +#end +dot.addExpected("of_grad.csv") + +# Functions ------------------------------------------------------------ # + +tavgT = Function("tavgT", "DIRECT/chtMaster.csv",LabeledTableReader("\"tavg[AvgTemp[1]]\"")) +tavgT.addInputVariable(ffd,"DOT/of_grad.csv",TableReader(None,0,(1,0))) # all rows, col 0, don't read the header +tavgT.addValueEvalStep(deform) +tavgT.addValueEvalStep(direct) +tavgT.addGradientEvalStep(adjoint) +tavgT.addGradientEvalStep(dot) + +# Driver --------------------------------------------------------------- # + +driver = ExteriorPenaltyDriver(0.005) +driver.addObjective("min", tavgT) + +driver.setWorkingDirectory("DOE") +driver.preprocessVariables() +driver.setStorageMode(True,"DESIGN_") + +his = open("doe.his","w",1) +driver.setHistorian(his) + +# Simulation Runs ------------------------------------------------------ # + +# Primal simulation for each deformed DV +for iLoop in range(0, nDV, 1): + x = driver.getInitial() + x[iLoop] = 1e-4 # DV_VALUE + driver.fun(x) +#end + +# Undeformed/initial primal last in order to have the correct solution in +# the WorkindDirectory for the following adjoint +x = driver.getInitial() +driver.fun(x) # baseline evaluation + +# Compute discrete adjoint gradient +driver.grad(x) + +his.close() + +# For results run `python postprocess.py` to get screen output +# of the differences between primal and adjoint simulation. diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py index d03bea21c98..8e59310c1a9 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py @@ -1,10 +1,12 @@ # Compute and print absolute difference between Discrete Adjoint # and Finite Difference gradient. Prints also percentage difference. +# +# Run this script after `python gradient_validation.py` successfully finished import pandas as pd # load files -DAgrad = pd.read_csv("of_grad.csv") +DAgrad = pd.read_csv("DOE/DOT/of_grad.csv") FDvals = pd.read_csv("doe.his") # additional values @@ -13,16 +15,12 @@ DAstring = 'AVG_TEMPERATURE gradient ' # create FD gradient -FDgrad = (FDvals[FDstring].iloc[1:] - FDvals[FDstring].iloc[0]) / FDstep -# The above operation creates a pd.series that starts at 1 because the first FDval is the baseline. -# This is reset to match the DAgrad -FDgrad = FDgrad.reset_index(inplace=False) +FDgrad = (FDvals[FDstring].iloc[:18] - FDvals[FDstring].iloc[18]) / FDstep # absolute difference -absoluteDiff = DAgrad[DAstring] - FDgrad[FDstring] +absoluteDiff = DAgrad[DAstring] - FDgrad print("DAgrad - FDgrad\n", absoluteDiff) # relative difference in percent -relDiffPercent = abs(DAgrad[DAstring] - FDgrad[FDstring])/DAgrad[DAstring] * 100 +relDiffPercent = abs(DAgrad[DAstring] - FDgrad)/DAgrad[DAstring] * 100 print("(DAgrad - FDgrad) / DAgrad * 100\n", relDiffPercent) - diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index d69d01f9b9d..95c5e6ae204 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -340,7 +340,7 @@ def main(): da_unsteadyCHT_cylinder.cfg_dir = "coupled_cht/disc_adj_unsteadyCHT_cylinder" da_unsteadyCHT_cylinder.cfg_file = "chtMaster.cfg" da_unsteadyCHT_cylinder.test_iter = 2 - da_unsteadyCHT_cylinder.test_vals = [-3.521358, -4.312658, -4.271025, -9.846075, -7.967741] + da_unsteadyCHT_cylinder.test_vals = [-3.521358, -4.312658, -4.271025, -9.846075, -7.967741, 0.0000e+00, 3.6840e+00, 2.9483e-01] da_unsteadyCHT_cylinder.su2_exec = "mpirun -n 2 SU2_CFD_AD" da_unsteadyCHT_cylinder.timeout = 1600 da_unsteadyCHT_cylinder.tol = 0.00001 From f20947b20cf00c410d06ccdc25fa3558c1ee5f6a Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Fri, 14 May 2021 16:18:19 +0200 Subject: [PATCH 092/192] Add comment on accuracy --- TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md index 7440d8d4896..7023e981943 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/README.md @@ -27,4 +27,4 @@ Note that the script can be used with the files as they are. Necessary adaptions The script deforms the mesh and runs the primal for each of the 18 Design Variables. Afterwards the baseline mesh is evaluated and then the Discrete Adjoint. Use `postprocess.py` to print the absolute difference and relative difference in percent to screen. - +The relative differences in percent are <0.15% for all Design Variables (2021-05-14). From 1b827e5e03d94af76e8c57477353e0a6bf27f252 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Fri, 14 May 2021 18:05:49 +0200 Subject: [PATCH 093/192] NdFlattener IndexAccumulator to provide []...[] interface and order of NdFlattener template arguments changed --- Common/include/geometry/dual_grid/CPoint.hpp | 2 +- Common/include/ndflattener.hpp | 114 +++++++++++++++++-- Common/src/geometry/CGeometry.cpp | 4 +- Common/src/geometry/dual_grid/CPoint.cpp | 4 +- 4 files changed, 109 insertions(+), 15 deletions(-) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 2350907ab16..2fcdcebb6cf 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -855,5 +855,5 @@ class CPoint { * \brief Set wall roughnesses according to stored closest wall information. * \param[in] roughness - Mapping [rank][zone][marker] -> roughness */ - void SetWallRoughness(NdFlattener const& roughness); + void SetWallRoughness(NdFlattener<3> const& roughness); }; diff --git a/Common/include/ndflattener.hpp b/Common/include/ndflattener.hpp index 29dc4165706..7acb33b51cf 100644 --- a/Common/include/ndflattener.hpp +++ b/Common/include/ndflattener.hpp @@ -34,9 +34,11 @@ #include #include "parallelization/mpi_structure.hpp" +template +class NdFlattener; namespace helpers { -template + template struct NdFlattener_MPI_Environment { MPI_Allgatherv_type MPI_Allgatherv; MPI_Datatype_type mpi_data; @@ -44,6 +46,67 @@ template2, more indices have to be read, return an IndexAccumulator. + * \tparam N - Number of missing parameters + * \tparam K - number of indices of accessed NdFlattener + * \tparam Data - Data type of accessed NdFlattener + * \tparam Index - Index type of accessed NdFlattener + */ + /*! \class IndexAccumulator_Base + * \brief Parent class of IndexAccumulator. + * \details IndexAccumulator provides the operator[] method. + */ + template + class IndexAccumulator_Base { + protected: + typedef NdFlattener Nd_type; /*!< \brief Access this level of the NdFlattener next. */ + const Nd_type* nd; /*!< \brief The accessed NdFlattener. */ + const Index offset; /*!< \brief Index in the currently accessed layer. */ + IndexAccumulator_Base(const Nd_type* nd, Index offset): nd(nd), offset(offset) {} + }; + template + class IndexAccumulator : public IndexAccumulator_Base{ + public: + typedef IndexAccumulator_Base Base; + template IndexAccumulator(ARGS... args): Base(args...) {}; + typedef IndexAccumulator LookupType; /*!< Return type of operator[] */ + typedef const LookupType LookupType_const; /*!< Return type of operator[], const version */ + /*! \brief Read one more index. */ + LookupType operator[] (Index i){ + return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + } + /*! \brief Read one more index, const version. */ + LookupType_const operator[] (Index i) const { + return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + } + }; + template + class IndexAccumulator<2,K,Data,Index> : public IndexAccumulator_Base<2,K,Data,Index>{ + public: + typedef IndexAccumulator_Base<2,K,Data,Index> Base; + template IndexAccumulator(ARGS... args): Base(args...) {}; + typedef Data* LookupType; /*!< Return type of operator[] */ + typedef const Data* LookupType_const; /*!< Return type of operator[], const version */ + /*! \brief Read the last-but-one index. + * \return Pointer to the corresponding section in the data array in layer K=1. + */ + LookupType operator[] (Index i){ + return static_cast(this->nd)->GetData() + this->nd->GetIndices()[this->offset+i]; + } + /*! \brief Read the last-but-one index, const version. + * \return Const pointer to the corresponding section in the data array in layer K=1. + */ + LookupType_const operator[] (Index i) const { + return static_cast(this->nd)->GetData() + this->nd->GetIndices()[this->offset+i]; + } + }; + } // namespace helpers static helpers::NdFlattener_MPI_Environment @@ -69,8 +132,8 @@ Get_Nd_MPI_Env() { * it can be refreshed in the same way after the the pointer-to-pointer-... array's * values (but not its structure) have changed. * - * \tparam Data - Type of stored array data * \tparam K - number of indices + * \tparam Data - Type of stored array data * \tparam Index - Type of index */ @@ -106,11 +169,12 @@ Get_Nd_MPI_Env() { * allocate it and fill it with data during the second iteration. */ -template -class NdFlattener: public NdFlattener{ +template +class NdFlattener: public NdFlattener{ + public: - typedef NdFlattener Base; // could also be named LowerLayer - typedef NdFlattener CurrentLayer; + typedef NdFlattener Base; // could also be named LowerLayer + typedef NdFlattener CurrentLayer; typedef typename Base::LowestLayer LowestLayer; // the K=1 class private: @@ -127,6 +191,11 @@ class NdFlattener: public NdFlattener{ /*! \brief Indices in the lower layer's indices or data array */ std::vector indices; + /*=== Getters ===*/ +public: + Index* GetIndices() {return indices.data();} + const Index* GetIndices() const {return indices.data();} + /*=== Outputting ===*/ public: @@ -420,6 +489,12 @@ class NdFlattener: public NdFlattener{ /*=== Access to data and numbers of children ===*/ + // There are two ways to access data: + // - nd.get(i_1, ..., i_K) for reading + // - nd[i_1]...[i_{K-1}] returns a pointer to the data array, so you can + // read and write nd[i_1]...[i_K]. + // If you have indices i_1, ..., i_k and are interested in the bound for i_{k+1}, + // use getNChildren(i_1,...,i_k). protected: template Data get_withoffset(Index offset, Index i1, ARGS... i2) const { @@ -432,10 +507,12 @@ class NdFlattener: public NdFlattener{ Index getNChildren_withoffset(Index offset, Index i) const { return indices[offset+i+1] - indices[offset+i]; } + public: - /*! \brief Index look-up. + /*! \brief Reading access. * * The number of parameters must be K. + * If you also need write access, use the nd[i1]...[iK] interface. */ template Data get(ARGS... i) const { @@ -454,13 +531,22 @@ class NdFlattener: public NdFlattener{ return nNodes; } - + /*! \brief Look-up with IndexAccumulator. + */ + typename helpers::IndexAccumulator::LookupType operator[](Index i0){ + return helpers::IndexAccumulator(this,0)[i0]; + } + /*! \brief Look-up with IndexAccumulator, const version. + */ + typename helpers::IndexAccumulator::LookupType_const operator[](Index i0) const { + return helpers::IndexAccumulator(this,0)[i0]; + } }; template -class NdFlattener { +class NdFlattener<1, Data, Index> { public: - typedef NdFlattener CurrentLayer; + typedef NdFlattener<1, Data, Index> CurrentLayer; typedef CurrentLayer LowestLayer; private: @@ -468,6 +554,12 @@ class NdFlattener { Index iNode=0; std::vector data; + + /*=== Getters ===*/ +public: + Data* GetData() {return data.data();} + const Data* GetData() const {return data.data();} + /*=== Outputting ===*/ protected: void toPythonString_fromto(std::ostream& output, Index from, Index to) const { @@ -560,3 +652,5 @@ class NdFlattener { }; + + diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 3e1d62baf82..4a5cf6f4879 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3953,9 +3953,9 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); }); - NdFlattener roughness_local(roughness_f); + NdFlattener<2,su2double,unsigned long> roughness_local(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); + NdFlattener<3,su2double,unsigned long> roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); // use it to update roughnesses for(int jZone=0; jZoneGetnRoughWall()>0){ diff --git a/Common/src/geometry/dual_grid/CPoint.cpp b/Common/src/geometry/dual_grid/CPoint.cpp index e0e32d715cb..b08d76d4cae 100644 --- a/Common/src/geometry/dual_grid/CPoint.cpp +++ b/Common/src/geometry/dual_grid/CPoint.cpp @@ -186,13 +186,13 @@ void CPoint::SetCoord_Old() { void CPoint::SetCoord_SumZero() { parallelSet(Coord_Sum.size(), 0.0, Coord_Sum.data()); } -void CPoint::SetWallRoughness(NdFlattener const& roughness){ +void CPoint::SetWallRoughness(NdFlattener<3> const& roughness){ for (unsigned long iPoint=0; iPoint Date: Fri, 14 May 2021 18:27:08 +0200 Subject: [PATCH 094/192] SetWallRoughness as template with the [][][] interface --- Common/include/geometry/dual_grid/CPoint.hpp | 12 +++++++++++- Common/src/geometry/dual_grid/CPoint.cpp | 10 ---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 2fcdcebb6cf..e19baeff245 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -855,5 +855,15 @@ class CPoint { * \brief Set wall roughnesses according to stored closest wall information. * \param[in] roughness - Mapping [rank][zone][marker] -> roughness */ - void SetWallRoughness(NdFlattener<3> const& roughness); + template + void SetWallRoughness(Roughness_type const& roughness){ + for (unsigned long iPoint=0; iPoint const& roughness){ - for (unsigned long iPoint=0; iPoint Date: Fri, 14 May 2021 18:49:03 +0200 Subject: [PATCH 095/192] moved ndflattener.hpp to Common/include/toolboxes --- Common/include/geometry/dual_grid/CPoint.hpp | 2 +- Common/include/{ => toolboxes}/ndflattener.hpp | 2 +- Common/src/geometry/CGeometry.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename Common/include/{ => toolboxes}/ndflattener.hpp (99%) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index e19baeff245..c2adbdd545f 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -32,7 +32,7 @@ #include "../../containers/container_decorators.hpp" #include "../../toolboxes/graph_toolbox.hpp" #include -#include "../../ndflattener.hpp" +#include "../../toolboxes/ndflattener.hpp" using namespace std; diff --git a/Common/include/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp similarity index 99% rename from Common/include/ndflattener.hpp rename to Common/include/toolboxes/ndflattener.hpp index 7acb33b51cf..1503862532a 100644 --- a/Common/include/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -32,7 +32,7 @@ #include #include #include -#include "parallelization/mpi_structure.hpp" +#include "../parallelization/mpi_structure.hpp" template class NdFlattener; diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 4a5cf6f4879..a43843c5a0a 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -29,7 +29,7 @@ #include "../../include/geometry/elements/CElement.hpp" #include "../../include/parallelization/omp_structure.hpp" #include "../../include/toolboxes/geometry_toolbox.hpp" -#include "../../include/ndflattener.hpp" +#include "../../include/toolboxes/ndflattener.hpp" CGeometry::CGeometry(void) : size(SU2_MPI::GetSize()), From af1bb01a18127ffeacefbb8ef7aa90c7ab4c8e7f Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Fri, 14 May 2021 20:20:51 +0200 Subject: [PATCH 096/192] Unit tests added --- Common/include/toolboxes/ndflattener.hpp | 20 ++-- .../Common/toolboxes/ndflattener_tests.cpp | 94 +++++++++++++++++++ UnitTests/meson.build | 1 + 3 files changed, 105 insertions(+), 10 deletions(-) create mode 100644 UnitTests/Common/toolboxes/ndflattener_tests.cpp diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 1503862532a..3a25ebae742 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -77,10 +77,10 @@ namespace helpers { template IndexAccumulator(ARGS... args): Base(args...) {}; typedef IndexAccumulator LookupType; /*!< Return type of operator[] */ typedef const LookupType LookupType_const; /*!< Return type of operator[], const version */ - /*! \brief Read one more index. */ - LookupType operator[] (Index i){ - return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); - } + /* \brief Read one more index. */ + /*LookupType operator[] (Index i){ + return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + }*/ /*! \brief Read one more index, const version. */ LookupType_const operator[] (Index i) const { return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); @@ -93,12 +93,12 @@ namespace helpers { template IndexAccumulator(ARGS... args): Base(args...) {}; typedef Data* LookupType; /*!< Return type of operator[] */ typedef const Data* LookupType_const; /*!< Return type of operator[], const version */ - /*! \brief Read the last-but-one index. + /* \brief Read the last-but-one index. * \return Pointer to the corresponding section in the data array in layer K=1. */ - LookupType operator[] (Index i){ + /*LookupType operator[] (Index i){ return static_cast(this->nd)->GetData() + this->nd->GetIndices()[this->offset+i]; - } + }*/ /*! \brief Read the last-but-one index, const version. * \return Const pointer to the corresponding section in the data array in layer K=1. */ @@ -531,11 +531,11 @@ class NdFlattener: public NdFlattener{ return nNodes; } - /*! \brief Look-up with IndexAccumulator. + /* \brief Look-up with IndexAccumulator. */ - typename helpers::IndexAccumulator::LookupType operator[](Index i0){ + /*typename helpers::IndexAccumulator::LookupType operator[](Index i0){ return helpers::IndexAccumulator(this,0)[i0]; - } + }*/ /*! \brief Look-up with IndexAccumulator, const version. */ typename helpers::IndexAccumulator::LookupType_const operator[](Index i0) const { diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp new file mode 100644 index 00000000000..979aa5cabd3 --- /dev/null +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -0,0 +1,94 @@ +/*! + * \file ndflattener_tests.cpp + * \brief Unit tests for NdFlattener template classes. + * \author M. Aehle + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "catch.hpp" +#include "../../Common/include/toolboxes/ndflattener.hpp" + +TEST_CASE("NdFlattener Test", "[NdFlattener]"){ + + int rank; SU2_MPI::Comm_rank(SU2_MPI::GetComm(), &rank); + int size; SU2_MPI::Comm_size(SU2_MPI::GetComm(), &size); + + /*-- Provide non-flat array --*/ + su2double** A = new su2double*[2]; + A[0] = new su2double[2]; A[0][0] = 0.0; A[0][1] = 1.0; + A[1] = new su2double[3+rank]; + for(int i=0; i<3+rank; i++) + A[1][i] = 2.0 + rank + i; + + /*-- Accessor --*/ + auto f = std::make_pair( (size_t)2, [A](int i) { + return std::make_pair( (size_t)(i==0?2:(3+rank)), [A,i](int j){ + return A[i][j]; + }); + }); + + /*-- Read into flattening structure --*/ + NdFlattener<2> nd2(f); + + /*-- Modify A -> this should not alter n at this point --*/ + A[0][0] = 0.5; + + /*-- Check structure --*/ + REQUIRE( nd2.getNChildren() == 2 ); + REQUIRE( nd2.get( 0, 0) == 0.0 ); + REQUIRE( nd2[0][1] == 1.0 ); + REQUIRE( nd2.getNChildren(1) == 3 + rank ); + for(int i=0; i<3+rank; i++){ + REQUIRE( nd2[1][i] == 2.0 + rank + i ); + } + + /*-- gather flattening structures of all processes --*/ + NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); + + /*-- Check gathered structure --*/ + for(int r=0; r Date: Sat, 15 May 2021 08:52:28 +0200 Subject: [PATCH 097/192] documentation of NdFlattener --- Common/include/toolboxes/ndflattener.hpp | 74 ++++++++++++++++++++++-- 1 file changed, 69 insertions(+), 5 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 3a25ebae742..da5150239e4 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -50,9 +50,10 @@ namespace helpers { /*! \class IndexAccumulator * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. * \details Derived from IndexAccumulator_Base, specifying the operator[] method: - * - For N==2, the structure has already read all indices but two. So after this method has read the last-but-one - * index, return a pointer to the corresponding section of the data array in layer K=1. - * - For N>2, more indices have to be read, return an IndexAccumulator. + * - For N==1, the structure has already read all indices but one. So after this method has read the last + * index, return a reference to the data. + * - The case N==2 is much like the case N>3 but an additional function data() should be provided. + * - For N>3, more indices have to be read, return an IndexAccumulator. * \tparam N - Number of missing parameters * \tparam K - number of indices of accessed NdFlattener * \tparam Data - Data type of accessed NdFlattener @@ -83,7 +84,7 @@ namespace helpers { }*/ /*! \brief Read one more index, const version. */ LookupType_const operator[] (Index i) const { - return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + return LookupType_const(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); } }; template @@ -137,7 +138,70 @@ Get_Nd_MPI_Env() { * \tparam Index - Type of index */ -/* --- Implementation details--- +// --- Usage +/*! \page ndflattener_usage Usage of NdFlattener + * To demonstrate the usage of NdFlattener, let us collect information that depends on + * the rank, zone index, and marker index. + * + * # Form the local NdFlattener + * by a "recursive function" like this: + * + * auto f_local = + * make_pair( nZone, [=](unsigned long iZone){ + * return make_pair( (Geometry of iZone)->GetnMarker() , [=](unsigned long iMarker){ + * return YOUR_PROPERTY(iZone, iMarker); + * }); + * }); + * NdFlattener<2> nd_local(f_local); + * + * It might be safer to explicitly capture what you need in the lambda expressions. + * + * f_local is + * - a pair of an (exclusive) upper bound for the first index and a function that maps the first index to + * - a pair of an (exclusive) upper bound for the second index and a function that maps the second index to + * - (iterate this if there are more layers) + * - the value corresponding to these indices. + * The template parameter "2" is the number of indices. The data type (default: su2double) and the index type + * (default: unsigned long) are further optional template parameters. + * + * # Form the global NdFlattener + * by "collective communication" like this: + * + * NdFlattener<3> nd_global(Get_Nd_MPI_Env(), &nd_local); + * + * nd_global's first index is the rank, then the indices of nd_local follow. + * + * # Look-up + * We usually provide two interfaces to access an NdFlattener: + * - A "[]...[]" interface that resembles multidimensional arrays or pointer-to-pointer-... arrays. + * - A function get which additionally checks whether all indices are within the bounds dictated by + * the data and the previous indices. + * + * You can get a reference to a single data element like this: + * + * nd_global[rank][zone][marker] += 0.1; + * nd_global.get(rank, zone, marker) += 0.2; + * + * When all indices except the last one are fixed, the corresponding data is stored contiguously and a pointer + * to this 1D array can be retrieved by + * + * nd_global[rank][zone].data() + * nd_global.get(rank, zone).data() + * + * You can get the (exclusive) upper bound for the next index of an incomplete index tuple like this: + * + * // no index given + * nd_global.size() + * // one index given + * nd_global[rank].size(); + * nd_global.get(rank).size(); + * // two indices given + * nd_global[rank][zone].size(); + * nd_global.get(rank, zone).size(); + */ + +// --- Implementation details--- +/*! \page ndflattener_implementationdetails Implementation details of NdFlattener * If your array has K indices, instantiate this class with template parameter K, * which is derived recursively from this class with template parameter (K-1). * In each layer, there is an array: Of type Data for K=1, and of type Index for K>1. From 16c75e5cf913e58fcaece882a50a20e870afeb97 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 10:34:58 +0200 Subject: [PATCH 098/192] correct handling of non-const and const access --- Common/include/toolboxes/ndflattener.hpp | 274 ++++++++++-------- .../Common/toolboxes/ndflattener_tests.cpp | 6 +- 2 files changed, 160 insertions(+), 120 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index da5150239e4..d026b5dff46 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -34,110 +34,6 @@ #include #include "../parallelization/mpi_structure.hpp" -template -class NdFlattener; - -namespace helpers { - template - struct NdFlattener_MPI_Environment { - MPI_Allgatherv_type MPI_Allgatherv; - MPI_Datatype_type mpi_data; - MPI_Datatype_type mpi_index; - MPI_Communicator_type comm; - int rank; int size; - }; - - /*! \class IndexAccumulator - * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. - * \details Derived from IndexAccumulator_Base, specifying the operator[] method: - * - For N==1, the structure has already read all indices but one. So after this method has read the last - * index, return a reference to the data. - * - The case N==2 is much like the case N>3 but an additional function data() should be provided. - * - For N>3, more indices have to be read, return an IndexAccumulator. - * \tparam N - Number of missing parameters - * \tparam K - number of indices of accessed NdFlattener - * \tparam Data - Data type of accessed NdFlattener - * \tparam Index - Index type of accessed NdFlattener - */ - /*! \class IndexAccumulator_Base - * \brief Parent class of IndexAccumulator. - * \details IndexAccumulator provides the operator[] method. - */ - template - class IndexAccumulator_Base { - protected: - typedef NdFlattener Nd_type; /*!< \brief Access this level of the NdFlattener next. */ - const Nd_type* nd; /*!< \brief The accessed NdFlattener. */ - const Index offset; /*!< \brief Index in the currently accessed layer. */ - IndexAccumulator_Base(const Nd_type* nd, Index offset): nd(nd), offset(offset) {} - }; - template - class IndexAccumulator : public IndexAccumulator_Base{ - public: - typedef IndexAccumulator_Base Base; - template IndexAccumulator(ARGS... args): Base(args...) {}; - typedef IndexAccumulator LookupType; /*!< Return type of operator[] */ - typedef const LookupType LookupType_const; /*!< Return type of operator[], const version */ - /* \brief Read one more index. */ - /*LookupType operator[] (Index i){ - return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); - }*/ - /*! \brief Read one more index, const version. */ - LookupType_const operator[] (Index i) const { - return LookupType_const(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); - } - }; - template - class IndexAccumulator<2,K,Data,Index> : public IndexAccumulator_Base<2,K,Data,Index>{ - public: - typedef IndexAccumulator_Base<2,K,Data,Index> Base; - template IndexAccumulator(ARGS... args): Base(args...) {}; - typedef Data* LookupType; /*!< Return type of operator[] */ - typedef const Data* LookupType_const; /*!< Return type of operator[], const version */ - /* \brief Read the last-but-one index. - * \return Pointer to the corresponding section in the data array in layer K=1. - */ - /*LookupType operator[] (Index i){ - return static_cast(this->nd)->GetData() + this->nd->GetIndices()[this->offset+i]; - }*/ - /*! \brief Read the last-but-one index, const version. - * \return Const pointer to the corresponding section in the data array in layer K=1. - */ - LookupType_const operator[] (Index i) const { - return static_cast(this->nd)->GetData() + this->nd->GetIndices()[this->offset+i]; - } - }; - -} // namespace helpers - -static helpers::NdFlattener_MPI_Environment -Get_Nd_MPI_Env() { - helpers::NdFlattener_MPI_Environment mpi_env; - mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); - mpi_env.mpi_index = MPI_UNSIGNED_LONG; - mpi_env.mpi_data = MPI_DOUBLE; - mpi_env.comm=SU2_MPI::GetComm(); - SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); - SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); - return mpi_env; -} - -/*! - * \class NdFlattener - * \brief Serialize pointer-to-pointer-... array into one 1D array, keeping track - * of the offsets in few additional 1D arrays. - * - * The pointer-to-pointer-... array can be provided by a nested lambda function - * ('recursive function') or by gathering such arrays from MPI processes ('collective - * communication'). After initializing an NdFlattener with either of these data, - * it can be refreshed in the same way after the the pointer-to-pointer-... array's - * values (but not its structure) have changed. - * - * \tparam K - number of indices - * \tparam Data - Type of stored array data - * \tparam Index - Type of index - */ - // --- Usage /*! \page ndflattener_usage Usage of NdFlattener * To demonstrate the usage of NdFlattener, let us collect information that depends on @@ -198,16 +94,19 @@ Get_Nd_MPI_Env() { * // two indices given * nd_global[rank][zone].size(); * nd_global.get(rank, zone).size(); + * + * # Another example + * You can find another example in UnitTests/Common/toolboxes/ndflattener_tests.cpp. */ // --- Implementation details--- /*! \page ndflattener_implementationdetails Implementation details of NdFlattener * If your array has K indices, instantiate this class with template parameter K, - * which is derived recursively from this class with template parameter (K-1). + * which is derived recursively from this class with template parameter (K-1). * In each layer, there is an array: Of type Data for K=1, and of type Index for K>1. * * The data array of K=1 contains the values of the array A in lexicographic ordering: - * [0]...[0][0][0], [0]...[0][0][1], ..., [0]...[0][0][something], + * [0]...[0][0][0], [0]...[0][0][1], ..., [0]...[0][0][something], * [0]...[0][1][0], [0]...[0][1][1], ..., [0]...[0][1][something], * ..., * [0]...[1][0][0], [0]...[1][0][1], ..., [0]...[1][0][something], @@ -219,7 +118,7 @@ Get_Nd_MPI_Env() { * values here. Last-index lists can also be empty. * * The indices array of K=2 contains the indices of the (K=1)-data array at which a new - * last-index list starts. If a last-index list is empty, the are repetitive entries in the + * last-index list starts. If a last-index list is empty, the are repetitive entries in the * indices array. * * The indices array of K=3 contains the indices of the (K=2)-indices array at which the @@ -228,15 +127,147 @@ Get_Nd_MPI_Env() { * * Etc. etc, up to the indices array at layer K. * - * To form such a structure, we typically iterate twice through the pointer-to-pointer-... - * array: The first time we get to know how much space to reserve in each layer, then we + * To form such a structure, we typically iterate twice through the pointer-to-pointer-... + * array: The first time we get to know how much space to reserve in each layer, then we * allocate it and fill it with data during the second iteration. */ -template -class NdFlattener: public NdFlattener{ + +template +class NdFlattener; + +namespace helpers { + template + struct NdFlattener_MPI_Environment { + MPI_Allgatherv_type MPI_Allgatherv; + MPI_Datatype_type mpi_data; + MPI_Datatype_type mpi_index; + MPI_Communicator_type comm; + int rank; int size; + }; + + /*! \class IndexAccumulator + * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. + * \details Derived from IndexAccumulator_Base, specifying the operator[] method: + * - For N==1, the structure has already read all indices but one. So after this method has read the last + * index, return a reference to the data. + * - The case N==2 is much like the case N>3 but an additional function data() should be provided. + * - For N>3, more indices have to be read, return an IndexAccumulator. + * \tparam N - Number of missing parameters + * \tparam Nd_type - Type of the accessed NdFlattener, should be NdFlattener + */ + /*! \class IndexAccumulator_Base + * \brief Parent class of IndexAccumulator. + * \details IndexAccumulator provides the operator[] method. + */ + template + class IndexAccumulator_Base { + public: + static constexpr size_t N = _N; + using Nd_type = _Nd_type; + + /*== Conditional is part of the standard library since C++14, keep it here for C++11 compatibility. ==*/ + template struct conditional { typedef T type; }; + template struct conditional { typedef F type; }; + + protected: + Nd_type* nd; /*!< \brief The accessed NdFlattener. */ + const typename Nd_type::Index offset; /*!< \brief Index in the currently accessed layer. */ + IndexAccumulator_Base(Nd_type* nd, typename Nd_type::Index offset): nd(nd), offset(offset) {} + + }; + + template + class IndexAccumulator : public IndexAccumulator_Base<_N,_Nd_type>{ + public: + static constexpr size_t N = _N; + using Nd_type = _Nd_type; + typedef IndexAccumulator_Base<_N,_Nd_type> Base; + + template IndexAccumulator(ARGS... args): Base(args...) {}; + + /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. + */ + using Nd_Base_type = typename Base::template conditional< + std::is_const::value, + const typename Nd_type::Base, + typename Nd_type::Base + >::type; + /*! Return type of operator[]. */ + using LookupType = IndexAccumulator; + + /*! \brief Read one more index. + * \param[in] i - Index. + */ + LookupType operator[] (typename Nd_type::Index i) { + return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + } + }; + template + class IndexAccumulator<1,_Nd_type> : public IndexAccumulator_Base<1,_Nd_type>{ + public: + static constexpr size_t N = 1; + using Nd_type = _Nd_type; + typedef IndexAccumulator_Base<1,_Nd_type> Base; + + template IndexAccumulator(ARGS... args): Base(args...) {}; + + /*! Return type of operator[]. + * \details Data type of NdFlattener, but do also preserve constness. + */ + using LookupType = typename Base::template conditional< + std::is_const::value, + typename Nd_type::Data, + const typename Nd_type::Data + >::type; + + /*! \brief Return (possibly const) reference to the corresponding data element. + * \param[in] i - Last index. + */ + LookupType operator[] (typename Nd_type::Index i) { + return this->nd->GetData() [ this->offset+i ]; + } + }; + +} // namespace helpers + +static helpers::NdFlattener_MPI_Environment +Get_Nd_MPI_Env() { + helpers::NdFlattener_MPI_Environment mpi_env; + mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); + mpi_env.mpi_index = MPI_UNSIGNED_LONG; + mpi_env.mpi_data = MPI_DOUBLE; + mpi_env.comm=SU2_MPI::GetComm(); + SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); + SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); + return mpi_env; +} + +/*! + * \class NdFlattener + * \brief Serialize pointer-to-pointer-... array into one 1D array, keeping track + * of the offsets in few additional 1D arrays. + * + * The pointer-to-pointer-... array can be provided by a nested lambda function + * ('recursive function') or by gathering such arrays from MPI processes ('collective + * communication'). After initializing an NdFlattener with either of these data, + * it can be refreshed in the same way after the the pointer-to-pointer-... array's + * values (but not its structure) have changed. + * + * \tparam K - number of indices + * \tparam Data - Type of stored array data + * \tparam Index - Type of index + */ + + +template +class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ public: + static constexpr size_t K = _K; + using Data = _Data; + using Index = _Index; + typedef NdFlattener Base; // could also be named LowerLayer typedef NdFlattener CurrentLayer; typedef typename Base::LowestLayer LowestLayer; // the K=1 class @@ -268,7 +299,7 @@ class NdFlattener: public NdFlattener{ * Like this: [[1, 2], [10, 20, 30]] */ friend std::ostream& operator<<(std::ostream& output, NdFlattener const& nd) { - nd.toPythonString_fromto(output, 0, nd.getNChildren()); + nd.toPythonString_fromto(output, 0, nd.size()); return output; } @@ -591,7 +622,7 @@ class NdFlattener: public NdFlattener{ Index getNChildren(ARGS... i) const { return getNChildren_withoffset(0, i...); } - Index getNChildren() const { // should not be called by recursion + Index size() const { // should not be called by recursion return nNodes; } @@ -600,16 +631,25 @@ class NdFlattener: public NdFlattener{ /*typename helpers::IndexAccumulator::LookupType operator[](Index i0){ return helpers::IndexAccumulator(this,0)[i0]; }*/ + /*! \brief Look-up with IndexAccumulator, non-const version. + */ + helpers::IndexAccumulator > operator[](Index i0) { + return helpers::IndexAccumulator >(this,0)[i0]; + } /*! \brief Look-up with IndexAccumulator, const version. */ - typename helpers::IndexAccumulator::LookupType_const operator[](Index i0) const { - return helpers::IndexAccumulator(this,0)[i0]; + helpers::IndexAccumulator > operator[](Index i0) const { + return helpers::IndexAccumulator >(this,0)[i0]; } }; -template -class NdFlattener<1, Data, Index> { +template +class NdFlattener<1, _Data, _Index> { public: + static constexpr size_t K = 1; + using Data = _Data; + using Index = _Index; + typedef NdFlattener<1, Data, Index> CurrentLayer; typedef CurrentLayer LowestLayer; diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 979aa5cabd3..0df13206203 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -41,8 +41,8 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ A[1][i] = 2.0 + rank + i; /*-- Accessor --*/ - auto f = std::make_pair( (size_t)2, [A](int i) { - return std::make_pair( (size_t)(i==0?2:(3+rank)), [A,i](int j){ + auto f = std::make_pair( (size_t)2, [rank,A](int i) { + return std::make_pair( (size_t)(i==0?2:(3+rank)), [rank,A,i](int j){ return A[i][j]; }); }); @@ -50,7 +50,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- Read into flattening structure --*/ NdFlattener<2> nd2(f); - /*-- Modify A -> this should not alter n at this point --*/ + /*-- Modify A -> this should not alter nd2 at this point --*/ A[0][0] = 0.5; /*-- Check structure --*/ From 4a1b3d46d1a2a1d8ebf6b2c21a697f9a6a4c3386 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 10:47:34 +0200 Subject: [PATCH 099/192] operator[] returns reference to Data, and provide .data() --- Common/include/toolboxes/ndflattener.hpp | 16 +++++++++++++--- UnitTests/Common/toolboxes/ndflattener_tests.cpp | 12 ++++++++---- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index d026b5dff46..647e20a0c66 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -217,16 +217,26 @@ namespace helpers { */ using LookupType = typename Base::template conditional< std::is_const::value, - typename Nd_type::Data, - const typename Nd_type::Data + const typename Nd_type::Data, + typename Nd_type::Data >::type; /*! \brief Return (possibly const) reference to the corresponding data element. * \param[in] i - Last index. */ - LookupType operator[] (typename Nd_type::Index i) { + LookupType& operator[] (typename Nd_type::Index i) { return this->nd->GetData() [ this->offset+i ]; } + + /*! \brief Return (possibly const) pointer to data. + * \details If all indices except the last one are fixed, the corresponding data + * is stored contiguously. Return a pointer to the beginning of the + * block. If this IndexAccumulator was generated from a non-const NdFlattener, the + * pointer is non-const, otherwise it is const. + */ + LookupType* data() { + return &(this->operator[](0)); + } }; } // namespace helpers diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 0df13206203..9f1975f1ec0 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -54,7 +54,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ A[0][0] = 0.5; /*-- Check structure --*/ - REQUIRE( nd2.getNChildren() == 2 ); + REQUIRE( nd2.size() == 2 ); REQUIRE( nd2.get( 0, 0) == 0.0 ); REQUIRE( nd2[0][1] == 1.0 ); REQUIRE( nd2.getNChildren(1) == 3 + rank ); @@ -62,21 +62,25 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ REQUIRE( nd2[1][i] == 2.0 + rank + i ); } + /*-- Modify structure. --*/ + nd2[0][0] = 0.7; + nd2[0].data()[1] = 1.7; + /*-- gather flattening structures of all processes --*/ NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); /*-- Check gathered structure --*/ for(int r=0; r Date: Sat, 15 May 2021 11:56:29 +0200 Subject: [PATCH 100/192] IndexAccumulator_Checked added, which also carries size --- Common/include/toolboxes/ndflattener.hpp | 85 ++++++++++++++++++- .../Common/toolboxes/ndflattener_tests.cpp | 20 +++-- 2 files changed, 99 insertions(+), 6 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 647e20a0c66..d5bcf252286 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -173,7 +173,9 @@ namespace helpers { protected: Nd_type* nd; /*!< \brief The accessed NdFlattener. */ const typename Nd_type::Index offset; /*!< \brief Index in the currently accessed layer. */ - IndexAccumulator_Base(Nd_type* nd, typename Nd_type::Index offset): nd(nd), offset(offset) {} + //const typename Nd_type::Index size; /*!< \brief Exclusive upper bound for the next index. */ + IndexAccumulator_Base(Nd_type* nd, typename Nd_type::Index offset): + nd(nd), offset(offset) {} }; @@ -200,9 +202,50 @@ namespace helpers { * \param[in] i - Index. */ LookupType operator[] (typename Nd_type::Index i) { + //const typename Nd_type::Index new_offset = this->nd->GetIndices()[this->offset+i]; + //const typename Nd_type::Index new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); } }; + + template + class IndexAccumulator_Checked : public IndexAccumulator<_N,_Nd_type>{ + public: + static constexpr size_t N = _N; + using Nd_type = _Nd_type; + typedef IndexAccumulator<_N,_Nd_type> Base; + + protected: + /*! Exclusive upper bound for the next index. */ + const typename Nd_type::Index _size; + + public: + template + IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {}; + + /*! Return type of operator[]. */ + using LookupType = IndexAccumulator_Checked; + + /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and + * previous indices. + * \param[in] i - Index. + */ + LookupType operator[] (typename Nd_type::Index i) { + if(i>=_size){ + SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } + const typename Nd_type::Index new_offset = this->nd->GetIndices()[this->offset+i]; + const typename Nd_type::Index new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; + return LookupType(new_size, static_cast(this->nd),new_offset); + } + + /*! \brief Return exclusive upper bound for next index. + */ + typename Nd_type::Index size() const { + return _size; + } + }; + template class IndexAccumulator<1,_Nd_type> : public IndexAccumulator_Base<1,_Nd_type>{ public: @@ -239,6 +282,36 @@ namespace helpers { } }; + template + class IndexAccumulator_Checked<1,_Nd_type> : public IndexAccumulator<1,_Nd_type>{ + public: + static constexpr size_t N = 1; + using Nd_type = _Nd_type; + typedef IndexAccumulator<1,_Nd_type> Base; + + protected: + /*! Exclusive upper bound for the next index. */ + const typename Nd_type::Index _size; + + public: + template + IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {}; + + /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. + * \param[in] i - Last index. + */ + typename Base::LookupType& operator[] (typename Nd_type::Index i) { + if(i>=_size){ + SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } + return Base::operator[](i); + } + + typename Nd_type::Index size() const { + return _size; + } + }; + } // namespace helpers static helpers::NdFlattener_MPI_Environment @@ -651,6 +724,16 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ helpers::IndexAccumulator > operator[](Index i0) const { return helpers::IndexAccumulator >(this,0)[i0]; } + /*! \brief Look-up with IndexAccumulator_Checked, non-const version. + */ + helpers::IndexAccumulator_Checked > checked() { + return helpers::IndexAccumulator_Checked >(size(),this,0); + } + /*! \brief Look-up with IndexAccumulator_Checked, const version. + */ + helpers::IndexAccumulator_Checked > checked() const { + return helpers::IndexAccumulator_Checked >(size(),this,0); + } }; template diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 9f1975f1ec0..821b4c2285f 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -62,6 +62,15 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ REQUIRE( nd2[1][i] == 2.0 + rank + i ); } + /*-- Check structure again, with checked look-up. --*/ + REQUIRE( nd2.checked()[0].size() == 2 ); + REQUIRE( nd2.checked()[0][0] == 0.0 ); + REQUIRE( nd2.checked()[0][1] == 1.0 ); + REQUIRE( nd2.checked()[1].size() == 3 + rank ); + for(int i=0; i<3+rank; i++){ + REQUIRE( nd2.checked()[1][i] == 2.0 + rank + i ); + } + /*-- Modify structure. --*/ nd2[0][0] = 0.7; nd2[0].data()[1] = 1.7; @@ -69,14 +78,15 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- gather flattening structures of all processes --*/ NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); - /*-- Check gathered structure --*/ + /*-- Check gathered structure, partly with checked look-up. --*/ for(int r=0; r Date: Sat, 15 May 2021 12:21:47 +0200 Subject: [PATCH 101/192] Removed get, getNChildren in favor of []...[] interface --- Common/include/toolboxes/ndflattener.hpp | 123 +++++++----------- .../Common/toolboxes/ndflattener_tests.cpp | 19 +-- 2 files changed, 57 insertions(+), 85 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index d5bcf252286..07c043a9ab9 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -68,35 +68,34 @@ * nd_global's first index is the rank, then the indices of nd_local follow. * * # Look-up - * We usually provide two interfaces to access an NdFlattener: - * - A "[]...[]" interface that resembles multidimensional arrays or pointer-to-pointer-... arrays. - * - A function get which additionally checks whether all indices are within the bounds dictated by - * the data and the previous indices. + * You can access the NdFlattener via a "[]...[]" interface that resembles multidimensional arrays + * or pointer-to-pointer-... arrays. If you provide all of the K indices, this returns a reference + * to the data element. If the NdFlattener is declared const, the reference is also const. If you + * provide less than K indices, you obtain an IndexAccumulator object to which you can later pass more + * indices. With respect to the above example: * - * You can get a reference to a single data element like this: + * std::cout << nd_global[rank][zone][marker]; + * auto nd_g_rank = nd_global[rank]; + * nd_g_rank[zone][marker] += 1.0; * - * nd_global[rank][zone][marker] += 0.1; - * nd_global.get(rank, zone, marker) += 0.2; + * If you want to check that every index is in the correct range dictated by the NdFlattener and the + * previous indices, call NdFlattener::checked() before interacting with the "[]...[]" interface. + * Now you can obtain IndexAccumulator_Checked objects which you can also query for the (exclusive) + * upper bound for the next index: + * + * auto nd_g_rank = nd_global.checked()[rank]; + * nd_g_rank[zone][marker] += 1.0; + * std::cout << nd_g_rank[zone].size(); * * When all indices except the last one are fixed, the corresponding data is stored contiguously and a pointer * to this 1D array can be retrieved by * * nd_global[rank][zone].data() - * nd_global.get(rank, zone).data() - * - * You can get the (exclusive) upper bound for the next index of an incomplete index tuple like this: - * - * // no index given - * nd_global.size() - * // one index given - * nd_global[rank].size(); - * nd_global.get(rank).size(); - * // two indices given - * nd_global[rank][zone].size(); - * nd_global.get(rank, zone).size(); + * nd_global.checked()[rank][zone].data() * - * # Another example - * You can find another example in UnitTests/Common/toolboxes/ndflattener_tests.cpp. + * # Unit tests + * The interface described here is tested in UnitTests/Common/toolboxes/ndflattener_tests.cpp, which may also + * serve as an addition example of how to use the NdFlattener. */ // --- Implementation details--- @@ -663,57 +662,12 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ Base::set_g(mpi_env, Nodes_all, static_cast(local_version)); } - - - - /*=== Access to data and numbers of children ===*/ - // There are two ways to access data: - // - nd.get(i_1, ..., i_K) for reading - // - nd[i_1]...[i_{K-1}] returns a pointer to the data array, so you can - // read and write nd[i_1]...[i_K]. - // If you have indices i_1, ..., i_k and are interested in the bound for i_{k+1}, - // use getNChildren(i_1,...,i_k). -protected: - template - Data get_withoffset(Index offset, Index i1, ARGS... i2) const { - return Base::get_withoffset(indices[offset+i1], i2...); - } - template - Index getNChildren_withoffset(Index offset, Index i1, ARGS... i2) const { - return Base::getNChildren_withoffset(indices[offset+i1], i2...); - } - Index getNChildren_withoffset(Index offset, Index i) const { - return indices[offset+i+1] - indices[offset+i]; - } - + /*== Data access ==*/ public: - /*! \brief Reading access. - * - * The number of parameters must be K. - * If you also need write access, use the nd[i1]...[iK] interface. - */ - template - Data get(ARGS... i) const { - return get_withoffset(0, i...); - } - /*! \brief Look-up of length of the next-layer sublist. - * - * Specify less than K indices. When the function returns N, - * the next index must lie inside {0, 1, ..., N-1}. - */ - template - Index getNChildren(ARGS... i) const { - return getNChildren_withoffset(0, i...); - } - Index size() const { // should not be called by recursion + Index size() const { // should not be called by recursion, is incorrect in lower layers! return nNodes; } - /* \brief Look-up with IndexAccumulator. - */ - /*typename helpers::IndexAccumulator::LookupType operator[](Index i0){ - return helpers::IndexAccumulator(this,0)[i0]; - }*/ /*! \brief Look-up with IndexAccumulator, non-const version. */ helpers::IndexAccumulator > operator[](Index i0) { @@ -835,16 +789,33 @@ class NdFlattener<1, _Data, _Index> { } - /*== Access to data and numbers of children ==*/ -protected: - Data get_withoffset(Index offset, Index i) const{ - return data[offset+i]; - } + /*== Access to data ==*/ + // Calling the following functions is a bit strange, because if you have only one level, + // you do not really benefit from NdFlattener's functionality. public: - Data get(Index i) const{ - return get_withoffset(0, i); + Index size() const { // should not be called by recursion, is incorrect in lower layers! + return nNodes; + } + /*! \brief Data look-up, non-const version. + */ + Data& operator[](Index i0) { + return data[i0]; + } + /*! \brief Data look-up, const version. + */ + const Data& operator[](Index i0) const { + return data[0]; + } + /*! \brief Look-up with IndexAccumulator_Checked, non-const version. + */ + helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data,Index> > checked() { + return helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data,Index> >(size(),this,0); + } + /*! \brief Look-up with IndexAccumulator_Checked, const version. + */ + helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data,Index> > checked() const { + return helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data,Index> >(size(),this,0); } - }; diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 821b4c2285f..abcb7d61aaa 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -55,9 +55,9 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- Check structure --*/ REQUIRE( nd2.size() == 2 ); - REQUIRE( nd2.get( 0, 0) == 0.0 ); + REQUIRE( nd2[0][0] == 0.0 ); REQUIRE( nd2[0][1] == 1.0 ); - REQUIRE( nd2.getNChildren(1) == 3 + rank ); + REQUIRE( nd2.checked()[1].size() == 3 + rank ); for(int i=0; i<3+rank; i++){ REQUIRE( nd2[1][i] == 2.0 + rank + i ); } @@ -79,23 +79,24 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); /*-- Check gathered structure, partly with checked look-up. --*/ + REQUIRE( nd3.size() == size ); for(int r=0; r Date: Sat, 15 May 2021 13:15:53 +0200 Subject: [PATCH 102/192] correction, now unit tests are passed --- Common/include/toolboxes/ndflattener.hpp | 6 ++++-- UnitTests/Common/toolboxes/ndflattener_tests.cpp | 15 ++++++++------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 07c043a9ab9..82b7877dc8b 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -439,7 +439,7 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ * \returns true if the NdFlattener has been initialized */ bool initialized(){ - return indices.size()>0; + return nNodes>0; } protected: @@ -519,7 +519,9 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ if(!refresh){ indices[iNode+1] = indices[iNode] + f.second(iChild).first; } else { - assert( indices[iNode+1] == indices[iNode] + f.second(iChild).first ); + if( indices[iNode+1] != indices[iNode] + f.second(iChild).first ){ + SU2_MPI::Error("NdFlattener: Structure has changed, cannot refresh.", CURRENT_FUNCTION); + } } iNode++; } diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index abcb7d61aaa..ce0dcbb4a19 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -48,7 +48,8 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ }); /*-- Read into flattening structure --*/ - NdFlattener<2> nd2(f); + NdFlattener<2> nd2; + nd2.initialize_or_refresh(f); /*-- Modify A -> this should not alter nd2 at this point --*/ A[0][0] = 0.5; @@ -84,9 +85,9 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ REQUIRE( nd3.checked()[r].size() == 2 ); REQUIRE( nd3[r][0][0] == 0.7 ); REQUIRE( nd3[r][0][1] == 1.7 ); - REQUIRE( nd3.checked()[r][1].size() == 3 + rank ); - for(int i=0; i<3+rank; i++){ - REQUIRE( nd3.checked()[r][1][i] == 2.0 + rank + i ); + REQUIRE( nd3.checked()[r][1].size() == 3 + r ); + for(int i=0; i<3+r; i++){ + REQUIRE( nd3.checked()[r][1][i] == 2.0 + r + i ); } } @@ -98,9 +99,9 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ REQUIRE( nd3.checked()[r].size() == 2 ); REQUIRE( nd3[r][0][0] == 0.5 ); REQUIRE( nd3[r][0][1] == 1.0 ); - REQUIRE( nd3.checked()[r][1].size() == 3 + rank ); - for(int i=0; i<3+rank; i++){ - REQUIRE( nd3.checked()[r][1][i] == 2.0 + rank + i ); + REQUIRE( nd3.checked()[r][1].size() == 3 + r ); + for(int i=0; i<3+r; i++){ + REQUIRE( nd3.checked()[r][1][i] == 2.0 + r + i ); } } From 9020677a00ca1714f99e82fbd2bfb163fd2dbf6d Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 13:46:53 +0200 Subject: [PATCH 103/192] NdFlattener documentation improved: refreshing --- Common/include/toolboxes/ndflattener.hpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 82b7877dc8b..7bcfb9053e8 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -52,6 +52,8 @@ * * It might be safer to explicitly capture what you need in the lambda expressions. * + * You can also construct an NdFlattener without any arguments, and use NdFlattener::initialize(f_local). + * * f_local is * - a pair of an (exclusive) upper bound for the first index and a function that maps the first index to * - a pair of an (exclusive) upper bound for the second index and a function that maps the second index to @@ -66,6 +68,24 @@ * NdFlattener<3> nd_global(Get_Nd_MPI_Env(), &nd_local); * * nd_global's first index is the rank, then the indices of nd_local follow. + * Get_Nd_MPI_Env returns a helpers:NdFlattener_MPI_Environment struct suitable to gather su2double data over + * unsigned long indices. If you deviate from these default datatypes, you need to define the MPI environment + * structure yourself. + * + * You can also construct an NdFlattener without any arguments, and use NdFlattener::initialize(mpi_env, &nd_local). + * + * # Refreshing + * If only the data but not the indices (i.e. the structure of sublists' lengths) have changed, you can refresh + * them with the call + * + * nd_local.refresh(f_local); // , or + * nd_global(Get_Nd_MPI_Env(), &nd_local); // respectively. + * + * An NdFlattener constructed or initialized from a "recursive function" or "collective communication" must be + * refreshed in the same way. + * + * We also provide a function NdFlattener::initialize_or_refresh, that initializes if not initialized, and refreshes + * otherwise. * * # Look-up * You can access the NdFlattener via a "[]...[]" interface that resembles multidimensional arrays From 80ec291ee0ef20d310f3eb1a688e140b54b6acc6 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 15:19:45 +0200 Subject: [PATCH 104/192] ::Get_Nd_MPI_Env() is inline, not static --- Common/include/toolboxes/ndflattener.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 7bcfb9053e8..623fdb35219 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -333,7 +333,7 @@ namespace helpers { } // namespace helpers -static helpers::NdFlattener_MPI_Environment +inline helpers::NdFlattener_MPI_Environment Get_Nd_MPI_Env() { helpers::NdFlattener_MPI_Environment mpi_env; mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); From e2a44d143c37cd91e6048ace909d786eb2c4ad5e Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 15:24:40 +0200 Subject: [PATCH 105/192] removed unnecessary ";" --- Common/include/toolboxes/ndflattener.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 623fdb35219..c3ff2b1de6f 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -437,7 +437,7 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ template NdFlattener(ARGS... args) { initialize_or_refresh(args...); - }; + } /*! \brief Initialize or refresh the NdFlattener. * \details Either a 'recursive function' or 'collective communication' From 1bfa060badb2f165086f104b0b78397a21996b69 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Sat, 15 May 2021 15:32:23 +0200 Subject: [PATCH 106/192] removed more unused ";" --- Common/include/toolboxes/ndflattener.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index c3ff2b1de6f..1b20da931ea 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -205,7 +205,7 @@ namespace helpers { using Nd_type = _Nd_type; typedef IndexAccumulator_Base<_N,_Nd_type> Base; - template IndexAccumulator(ARGS... args): Base(args...) {}; + template IndexAccumulator(ARGS... args): Base(args...) {} /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. */ @@ -240,7 +240,7 @@ namespace helpers { public: template - IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {}; + IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {} /*! Return type of operator[]. */ using LookupType = IndexAccumulator_Checked; @@ -272,7 +272,7 @@ namespace helpers { using Nd_type = _Nd_type; typedef IndexAccumulator_Base<1,_Nd_type> Base; - template IndexAccumulator(ARGS... args): Base(args...) {}; + template IndexAccumulator(ARGS... args): Base(args...) {} /*! Return type of operator[]. * \details Data type of NdFlattener, but do also preserve constness. @@ -314,7 +314,7 @@ namespace helpers { public: template - IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {}; + IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {} /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. From 0d55909d8eaf29855b284aa067ac114c31be5cc7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 18 May 2021 00:09:36 +0100 Subject: [PATCH 107/192] update regressions --- TestCases/hybrid_regression.py | 6 +++--- TestCases/parallel_regression.py | 6 +++--- TestCases/serial_regression.py | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index fb06b8d5a6a..48b223f8024 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -646,7 +646,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4.000000, 0.000000, -3.768521, -4.159940] + fsi2d.test_vals = [4, 0, -3.771897, -4.163473] fsi2d.multizone= True fsi2d.unsteady = True test_list.append(fsi2d) @@ -656,7 +656,7 @@ def main(): stat_fsi.cfg_dir = "fea_fsi/stat_fsi" stat_fsi.cfg_file = "config.cfg" stat_fsi.test_iter = 7 - stat_fsi.test_vals = [-3.242851, -4.866383, 0.000000, 11.000000] + stat_fsi.test_vals = [-3.242851, -4.866383, 0.000000, 11] stat_fsi.multizone = True test_list.append(stat_fsi) @@ -665,7 +665,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.398527, -4.086735, 0.000000, 121.000000] + dyn_fsi.test_vals = [-4.400852, -4.085149, 5.3839e-08, 121] dyn_fsi.multizone = True dyn_fsi.unsteady = True test_list.append(dyn_fsi) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index b0c92bcb386..abee592c8eb 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1175,7 +1175,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4, 0, -3.768496, -4.159961] #last 4 columns + fsi2d.test_vals = [4, 0, -3.771873, -4.163491] #last 4 columns fsi2d.su2_exec = "parallel_computation_fsi.py -f" fsi2d.timeout = 1600 fsi2d.multizone= True @@ -1200,7 +1200,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.398550, -4.086739, 0.000000, 117.000000] + dyn_fsi.test_vals = [-4.400874, -4.085152, 0.000000, 117] dyn_fsi.multizone = True dyn_fsi.unsteady = True dyn_fsi.su2_exec = "mpirun -n 2 SU2_CFD" @@ -1356,7 +1356,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4, 0, -3.768496, -4.159961] #last 4 columns + pywrapper_fsi2d.test_vals = [4, 0, -3.771873, -4.163491] #last 4 columns pywrapper_fsi2d.su2_exec = "mpirun -np 2 SU2_CFD.py --nZone 2 --fsi True --parallel -f" pywrapper_fsi2d.timeout = 1600 pywrapper_fsi2d.unsteady = True diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 98fd0feb499..feb426f565e 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1319,7 +1319,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4, 0, -3.768501, -4.159959] #last 4 columns + fsi2d.test_vals = [4, 0, -3.771878, -4.163489] #last 4 columns fsi2d.su2_exec = "SU2_CFD" fsi2d.timeout = 1600 fsi2d.multizone = True @@ -1356,7 +1356,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.398530, -4.086741, 0.000000, 101.000000] #last 4 columns + dyn_fsi.test_vals = [-4.400854, -4.085153, 0.000000, 101] #last 4 columns dyn_fsi.multizone = True dyn_fsi.unsteady = True dyn_fsi.su2_exec = "SU2_CFD" @@ -1874,7 +1874,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4, 0, -3.768501, -4.159959] #last 4 columns + pywrapper_fsi2d.test_vals = [4, 0, -3.771878, -4.163489] #last 4 columns pywrapper_fsi2d.su2_exec = "SU2_CFD.py --nZone 2 --fsi True -f" pywrapper_fsi2d.new_output = True pywrapper_fsi2d.unsteady = True From 590fdddc5f36381a594b35b15dd300cf3c86bf36 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 18 May 2021 01:16:24 +0100 Subject: [PATCH 108/192] fix file output issues --- .../drivers/CDiscAdjMultizoneDriver.hpp | 4 +- .../src/drivers/CDiscAdjMultizoneDriver.cpp | 18 ++-- .../src/iteration/CDiscAdjFEAIteration.cpp | 87 +++++++++---------- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 26 ------ TestCases/parallel_regression_AD.py | 2 +- 5 files changed, 58 insertions(+), 79 deletions(-) diff --git a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp index 2a754973798..7d195d45e59 100644 --- a/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp +++ b/SU2_CFD/include/drivers/CDiscAdjMultizoneDriver.hpp @@ -169,9 +169,9 @@ class CDiscAdjMultizoneDriver : public CMultizoneDriver { /*! * \brief Evaluate sensitivites for the current adjoint solution and output files. * \param[in] Iter - Current outer or time iteration. - * \param[in] StopCalc - Final iteration flag (converged or reached max number of iters). + * \param[in] force_writing - Force file output. */ - void EvaluateSensitivities(unsigned long Iter, bool StopCalc); + void EvaluateSensitivities(unsigned long Iter, bool force_writing); /*! * \brief Setup the matrix of cross-terms. Allocate necessary memory and initialize to zero. diff --git a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp index d18a33b2333..fc2b099129d 100644 --- a/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjMultizoneDriver.cpp @@ -446,16 +446,16 @@ void CDiscAdjMultizoneDriver::Run() { AD::ClearAdjoints(); - /*--- Compute the geometrical sensitivities and write them to file. ---*/ + /*--- Compute the geometrical sensitivities and write them to file, except for time_domain. ---*/ - bool checkSensitivity = StopCalc || ((iOuterIter % wrt_sol_freq == 0) && (iOuterIter != 0)); + if (time_domain) continue; - if (checkSensitivity && !time_domain) + if (StopCalc || ((iOuterIter % wrt_sol_freq == 0) && (iOuterIter != 0))) EvaluateSensitivities(iOuterIter, StopCalc); } if (time_domain) { - EvaluateSensitivities(TimeIter, false); + EvaluateSensitivities(TimeIter, (TimeIter+1) == driver_config->GetnTime_Iter()); } } @@ -493,7 +493,7 @@ bool CDiscAdjMultizoneDriver::EvaluateObjectiveFunctionGradient() { return rhs_norm < EPS; } -void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool StopCalc) { +void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool force_writing) { /*--- SetRecording stores the computational graph on one iteration of the direct problem. Calling it with NONE * as argument ensures that all information from a previous recording is removed. ---*/ @@ -547,15 +547,21 @@ void CDiscAdjMultizoneDriver::EvaluateSensitivities(unsigned long Iter, bool Sto solvers[ADJMESH_SOL]->SetSensitivity(geometry, config, solvers[IDX_SOL]); else solvers[IDX_SOL]->SetSensitivity(geometry, config); + + iteration_container[iZone][INST_0]->Postprocess(output_container[iZone], integration_container, geometry_container, + solver_container, numerics_container, config_container, + surface_movement, grid_movement, FFDBox, iZone, INST_0); } /*--- Clear the stored adjoint information to be ready for a new evaluation. ---*/ AD::ClearAdjoints(); - /*--- Output files. ---*/ + /*--- Output files (CMultizoneDriver::Output uses StopCalc to force file output). ---*/ + swap(StopCalc, force_writing); Output(Iter); + swap(StopCalc, force_writing); } diff --git a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp index de4b30d7ee7..6fe780efba4 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFEAIteration.cpp @@ -67,24 +67,24 @@ CDiscAdjFEAIteration::~CDiscAdjFEAIteration(void) {} void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst) { unsigned long iPoint; - auto solvers0 = solver[val_iZone][val_iInst][MESH_0]; - auto geometry0 = geometry[val_iZone][val_iInst][MESH_0]; + auto solvers0 = solver[iZone][iInst][MESH_0]; + auto geometry0 = geometry[iZone][iInst][MESH_0]; auto dirNodes = solvers0[FEA_SOL]->GetNodes(); auto adjNodes = solvers0[ADJFEA_SOL]->GetNodes(); /*--- For the dynamic adjoint, load direct solutions from restart files. ---*/ - if (config[val_iZone]->GetTime_Domain()) { - const int TimeIter = config[val_iZone]->GetTimeIter(); - const int Direct_Iter = SU2_TYPE::Int(config[val_iZone]->GetUnst_AdjointIter()) - TimeIter - 1; + if (config[iZone]->GetTime_Domain()) { + const int TimeIter = config[iZone]->GetTimeIter(); + const int Direct_Iter = SU2_TYPE::Int(config[iZone]->GetUnst_AdjointIter()) - TimeIter - 1; /*--- We want to load the already converged solution at timesteps n and n-1 ---*/ /*--- Load solution at timestep n-1 ---*/ - LoadDynamic_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter - 1); + LoadDynamic_Solution(geometry, solver, config, iZone, iInst, Direct_Iter - 1); /*--- Push solution back to correct array ---*/ @@ -92,7 +92,7 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat /*--- Load solution timestep n ---*/ - LoadDynamic_Solution(geometry, solver, config, val_iZone, val_iInst, Direct_Iter); + LoadDynamic_Solution(geometry, solver, config, iZone, iInst, Direct_Iter); /*--- Store FEA solution also in the adjoint solver in order to be able to reset it later ---*/ @@ -108,56 +108,54 @@ void CDiscAdjFEAIteration::Preprocess(COutput* output, CIntegration**** integrat } } - solvers0[ADJFEA_SOL]->Preprocessing(geometry0, solvers0, config[val_iZone], MESH_0, 0, RUNTIME_ADJFEA_SYS, false); + solvers0[ADJFEA_SOL]->Preprocessing(geometry0, solvers0, config[iZone], MESH_0, 0, RUNTIME_ADJFEA_SYS, false); } void CDiscAdjFEAIteration::LoadDynamic_Solution(CGeometry**** geometry, CSolver***** solver, CConfig** config, - unsigned short val_iZone, unsigned short val_iInst, + unsigned short iZone, unsigned short iInst, int val_DirectIter) { unsigned short iVar; unsigned long iPoint; bool update_geo = false; // TODO: check if (val_DirectIter >= 0) { - if (rank == MASTER_NODE && val_iZone == ZONE_0) + if (rank == MASTER_NODE && iZone == ZONE_0) cout << " Loading FEA solution from direct iteration " << val_DirectIter << "." << endl; - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->LoadRestart( - geometry[val_iZone][val_iInst], solver[val_iZone][val_iInst], config[val_iZone], val_DirectIter, update_geo); + solver[iZone][iInst][MESH_0][FEA_SOL]->LoadRestart( + geometry[iZone][iInst], solver[iZone][iInst], config[iZone], val_DirectIter, update_geo); } else { /*--- If there is no solution file we set the freestream condition ---*/ - if (rank == MASTER_NODE && val_iZone == ZONE_0) + if (rank == MASTER_NODE && iZone == ZONE_0) cout << " Setting static conditions at direct iteration " << val_DirectIter << "." << endl; /*--- Push solution back to correct array ---*/ - for (iPoint = 0; iPoint < geometry[val_iZone][val_iInst][MESH_0]->GetnPoint(); iPoint++) { - for (iVar = 0; iVar < solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetnVar(); iVar++) { - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel(iPoint, iVar, 0.0); - solver[val_iZone][val_iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel(iPoint, iVar, 0.0); + for (iPoint = 0; iPoint < geometry[iZone][iInst][MESH_0]->GetnPoint(); iPoint++) { + for (iVar = 0; iVar < solver[iZone][iInst][MESH_0][FEA_SOL]->GetnVar(); iVar++) { + solver[iZone][iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution(iPoint, iVar, 0.0); + solver[iZone][iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Accel(iPoint, iVar, 0.0); + solver[iZone][iInst][MESH_0][FEA_SOL]->GetNodes()->SetSolution_Vel(iPoint, iVar, 0.0); } } } } void CDiscAdjFEAIteration::IterateDiscAdj(CGeometry**** geometry, CSolver***** solver, CConfig** config, - unsigned short val_iZone, unsigned short val_iInst, bool CrossTerm) { + unsigned short iZone, unsigned short iInst, bool CrossTerm) { /*--- Extract the adjoints of the conservative input variables and store them for the next iteration ---*/ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Solution(geometry[val_iZone][val_iInst][MESH_0], - config[val_iZone], CrossTerm); + solver[iZone][iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Solution(geometry[iZone][iInst][MESH_0], config[iZone], + CrossTerm); - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Variables(geometry[val_iZone][val_iInst][MESH_0], - config[val_iZone]); + solver[iZone][iInst][MESH_0][ADJFEA_SOL]->ExtractAdjoint_Variables(geometry[iZone][iInst][MESH_0], config[iZone]); } void CDiscAdjFEAIteration::SetRecording(CSolver***** solver, CGeometry**** geometry, CConfig** config, - unsigned short val_iZone, unsigned short val_iInst, + unsigned short iZone, unsigned short iInst, RECORDING kind_recording) { /*--- Prepare for recording by resetting the solution to the initial converged solution ---*/ - solver[val_iZone][val_iInst][MESH_0][ADJFEA_SOL]->SetRecording(geometry[val_iZone][val_iInst][MESH_0], - config[val_iZone]); + solver[iZone][iInst][MESH_0][ADJFEA_SOL]->SetRecording(geometry[iZone][iInst][MESH_0], config[iZone]); } void CDiscAdjFEAIteration::RegisterInput(CSolver***** solver, CGeometry**** geometry, CConfig** config, @@ -316,27 +314,28 @@ void CDiscAdjFEAIteration::InitializeAdjoint(CSolver***** solver, CGeometry**** bool CDiscAdjFEAIteration::Monitor(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { + CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst) { /*--- Write the convergence history (only screen output) ---*/ - output->SetHistory_Output(geometry[val_iZone][INST_0][MESH_0], solver[val_iZone][INST_0][MESH_0], config[val_iZone], - config[val_iZone]->GetTimeIter(), config[val_iZone]->GetOuterIter(), - config[val_iZone]->GetInnerIter()); + output->SetHistory_Output(geometry[iZone][INST_0][MESH_0], solver[iZone][INST_0][MESH_0], config[iZone], + config[iZone]->GetTimeIter(), config[iZone]->GetOuterIter(), + config[iZone]->GetInnerIter()); return output->GetConvergence(); } + void CDiscAdjFEAIteration::Postprocess(COutput* output, CIntegration**** integration, CGeometry**** geometry, CSolver***** solver, CNumerics****** numerics, CConfig** config, CSurfaceMovement** surface_movement, CVolumetricMovement*** grid_movement, - CFreeFormDefBox*** FFDBox, unsigned short val_iZone, unsigned short val_iInst) { - const bool dynamic = (config[val_iZone]->GetTime_Domain()); - auto solvers0 = solver[val_iZone][val_iInst][MESH_0]; + CFreeFormDefBox*** FFDBox, unsigned short iZone, unsigned short iInst) { + const bool dynamic = (config[iZone]->GetTime_Domain()); + auto solvers0 = solver[iZone][iInst][MESH_0]; // TEMPORARY output only for standalone structural problems - if ((!config[val_iZone]->GetFSI_Simulation()) && (rank == MASTER_NODE)) { + if (config[iZone]->GetAdvanced_FEAElementBased() && (rank == MASTER_NODE)) { unsigned short iVar; - const bool de_effects = config[val_iZone]->GetDE_Effects(); + const bool de_effects = config[iZone]->GetDE_Effects(); /*--- Header of the temporary output file ---*/ ofstream myfile_res; @@ -344,21 +343,21 @@ void CDiscAdjFEAIteration::Postprocess(COutput* output, CIntegration**** integra myfile_res.precision(15); - myfile_res << config[val_iZone]->GetTimeIter() << "\t"; + myfile_res << config[iZone]->GetTimeIter() << "\t"; - solvers0[FEA_SOL]->Evaluate_ObjFunc(config[val_iZone]); + solvers0[FEA_SOL]->Evaluate_ObjFunc(config[iZone]); myfile_res << scientific << solvers0[FEA_SOL]->GetTotal_ComboObj() << "\t"; - for (iVar = 0; iVar < config[val_iZone]->GetnElasticityMod(); iVar++) + for (iVar = 0; iVar < config[iZone]->GetnElasticityMod(); iVar++) myfile_res << scientific << solvers0[ADJFEA_SOL]->GetTotal_Sens_E(iVar) << "\t"; - for (iVar = 0; iVar < config[val_iZone]->GetnPoissonRatio(); iVar++) + for (iVar = 0; iVar < config[iZone]->GetnPoissonRatio(); iVar++) myfile_res << scientific << solvers0[ADJFEA_SOL]->GetTotal_Sens_Nu(iVar) << "\t"; if (dynamic) { - for (iVar = 0; iVar < config[val_iZone]->GetnMaterialDensity(); iVar++) + for (iVar = 0; iVar < config[iZone]->GetnMaterialDensity(); iVar++) myfile_res << scientific << solvers0[ADJFEA_SOL]->GetTotal_Sens_Rho(iVar) << "\t"; } if (de_effects) { - for (iVar = 0; iVar < config[val_iZone]->GetnElectric_Field(); iVar++) + for (iVar = 0; iVar < config[iZone]->GetnElectric_Field(); iVar++) myfile_res << scientific << solvers0[ADJFEA_SOL]->GetTotal_Sens_EField(iVar) << "\t"; } for (iVar = 0; iVar < solvers0[ADJFEA_SOL]->GetnDVFEA(); iVar++) { @@ -371,12 +370,12 @@ void CDiscAdjFEAIteration::Postprocess(COutput* output, CIntegration**** integra } // TEST: for implementation of python framework in standalone structural problems - if ((!config[val_iZone]->GetFSI_Simulation()) && (rank == MASTER_NODE)) { + if (config[iZone]->GetAdvanced_FEAElementBased() && (rank == MASTER_NODE)) { /*--- Header of the temporary output file ---*/ ofstream myfile_res; bool outputDVFEA = false; - switch (config[val_iZone]->GetDV_FEA()) { + switch (config[iZone]->GetDV_FEA()) { case YOUNG_MODULUS: myfile_res.open("grad_young.opt"); outputDVFEA = true; diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 11148489c3b..48554939332 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -443,32 +443,6 @@ void CDiscAdjFEASolver::SetSensitivity(CGeometry *geometry, CConfig *config, CSo } } - // Temporary Output - if (config->GetAdvanced_FEAElementBased()) { - if (rank == MASTER_NODE) { - - /*--- Header of the temporary dv sensitivity output file ---*/ - ofstream myfile2_res; - - switch (config->GetDV_FEA()) { - case YOUNG_MODULUS: case DENSITY_VAL: - myfile2_res.open("grad_dv.opt"); - myfile2_res << "INDEX" - << "\t" - << "GRAD" << endl; - myfile2_res.precision(15); - - for (unsigned short iDV = 0; iDV < nDV; iDV++) { - myfile2_res << iDV; - myfile2_res << "\t"; - myfile2_res << scientific << GetTotal_Sens_DVFEA(iDV);//Total_Sens_DV[iDV]; - myfile2_res << endl; - } - myfile2_res.close(); - break; - } - } - } } void CDiscAdjFEASolver::ReadDV(const CConfig *config) { diff --git a/TestCases/parallel_regression_AD.py b/TestCases/parallel_regression_AD.py index 2865f11f1e1..0759ab1913d 100644 --- a/TestCases/parallel_regression_AD.py +++ b/TestCases/parallel_regression_AD.py @@ -419,7 +419,7 @@ def main(): dyn_discadj_fsi.su2_exec = "mpirun -n 2 SU2_CFD_AD" dyn_discadj_fsi.timeout = 1600 dyn_discadj_fsi.reference_file = "grad_dv.opt.ref" - dyn_discadj_fsi.test_file = "grad_dv.opt" + dyn_discadj_fsi.test_file = "grad_young.opt" dyn_discadj_fsi.unsteady = True pass_list.append(dyn_discadj_fsi.run_filediff()) test_list.append(dyn_discadj_fsi) From 8c6233a3a8d180d093eb32f4295e2a184b9cd610 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Tue, 18 May 2021 12:37:07 +0200 Subject: [PATCH 109/192] Move \!Crossterm bool in front of loop for unsteady adjoint extraction. --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 4 ++-- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index 8115e187d0e..59d2a277e9b 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -271,7 +271,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Solution for acceleration (u'') and velocity (u') at time n ---*/ - if (dynamic){ + if (dynamic && !CrossTerm){ /*--- NOW: The solution at time n ---*/ for (iPoint = 0; iPoint < nPoint; iPoint++){ @@ -282,7 +282,7 @@ void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *co /*--- Store the adjoint solution at time n ---*/ - if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } } diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 31259d78856..680e61670af 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -362,25 +362,25 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi END_SU2_OMP_MASTER /*--- Extract and store the adjoint of the primal solution at time n ---*/ - if (time_n_needed) { + if (time_n_needed && !CrossTerm) { SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); - if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } END_SU2_OMP_FOR } /*--- Extract and store the adjoint of the primal solution at time n-1 ---*/ - if (time_n1_needed) { + if (time_n1_needed && !CrossTerm) { SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); - if (!CrossTerm) nodes->Set_Solution_time_n1(iPoint,Solution); + nodes->Set_Solution_time_n1(iPoint,Solution); } END_SU2_OMP_FOR } From 7422c0003398393c419d335308686f2cf5224fac Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 18 May 2021 12:07:09 +0100 Subject: [PATCH 110/192] dont extract some terms during cross term evaluation --- SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp | 55 +++++++---------------- SU2_CFD/src/solvers/CDiscAdjSolver.cpp | 26 +++++------ 2 files changed, 29 insertions(+), 52 deletions(-) diff --git a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp index e044ae9659c..3f0e634230e 100644 --- a/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjFEASolver.cpp @@ -236,64 +236,41 @@ void CDiscAdjFEASolver::RegisterOutput(CGeometry *geometry, CConfig *config){ } -void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ - - const bool dynamic = config->GetTime_Domain(); - const bool multizone = config->GetMultizone_Problem(); - - unsigned short iVar; - unsigned long iPoint; - su2double residual; - - su2double Solution[MAXNVAR] = {0.0}; - - /*--- Set Residuals to zero ---*/ - - SetResToZero(); +void CDiscAdjFEASolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) { /*--- Set the old solution, for multi-zone problems this is done after computing the * residuals, otherwise the per-zone-residuals do not make sense, as on entry Solution * contains contributions from other zones but on extraction it does not. ---*/ - if(!multizone) nodes->Set_OldSolution(); - - for (iPoint = 0; iPoint < nPoint; iPoint++){ + if (!config->GetMultizone_Problem()) nodes->Set_OldSolution(); - /*--- Extract the adjoint solution ---*/ + /*--- Extract and store the adjoint solution ---*/ + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { + su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); - - /*--- Store the adjoint solution ---*/ - nodes->SetSolution(iPoint,Solution); - } - /*--- Solution for acceleration (u'') and velocity (u') at time n ---*/ + if (CrossTerm) return; - if (dynamic){ - - /*--- NOW: The solution at time n ---*/ - for (iPoint = 0; iPoint < nPoint; iPoint++){ - - /*--- Extract the adjoint solution at time n ---*/ + /*--- Extract and store the adjoint solution at time n (including accel. and velocity) ---*/ + if (config->GetTime_Domain()) { + for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { + su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); - - /*--- Store the adjoint solution at time n ---*/ - - if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } - } - /*--- TODO: Need to set the MPI solution in the previous TS ---*/ - /*--- Set the residuals ---*/ - for (iPoint = 0; iPoint < nPointDomain; iPoint++){ - for (iVar = 0; iVar < nVar; iVar++){ - residual = nodes->GetSolution(iPoint, iVar) - nodes->GetSolution_Old(iPoint, iVar); + SetResToZero(); + + for (auto iPoint = 0ul; iPoint < nPointDomain; iPoint++) { + for (auto iVar = 0u; iVar < nVar; iVar++){ + su2double residual = nodes->GetSolution(iPoint, iVar) - nodes->GetSolution_Old(iPoint, iVar); Residual_RMS[iVar] += residual*residual; AddRes_Max(iVar,fabs(residual),geometry->nodes->GetGlobalIndex(iPoint),geometry->nodes->GetCoord(iPoint)); diff --git a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp index 31259d78856..84ce1b3906c 100644 --- a/SU2_CFD/src/solvers/CDiscAdjSolver.cpp +++ b/SU2_CFD/src/solvers/CDiscAdjSolver.cpp @@ -297,18 +297,14 @@ void CDiscAdjSolver::RegisterOutput(CGeometry *geometry, CConfig *config) { direct_solver->GetNodes()->RegisterSolution(false); } -void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm){ +void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *config, bool CrossTerm) { const bool time_n1_needed = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; const bool time_n_needed = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) || time_n1_needed; const su2double relax = (config->GetInnerIter()==0) ? 1.0 : config->GetRelaxation_Factor_Adjoint(); - su2double Solution[MAXNVAR] = {0.0}; - - /*--- Set Residuals to zero ---*/ - - SetResToZero(); + /*--- Thread-local residual variables. ---*/ su2double resMax[MAXNVAR] = {0.0}, resRMS[MAXNVAR] = {0.0}; const su2double* coordMax[MAXNVAR] = {nullptr}; @@ -316,13 +312,14 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi /*--- Set the old solution and compute residuals. ---*/ - if(!config->GetMultizone_Problem()) nodes->Set_OldSolution(); + if (!config->GetMultizone_Problem()) nodes->Set_OldSolution(); SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { /*--- Extract the adjoint solution ---*/ + su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjointSolution(iPoint,Solution); /*--- Relax and store the adjoint solution, compute the residuals. ---*/ @@ -344,6 +341,11 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi } END_SU2_OMP_FOR + /*--- Residuals and time_n terms are not needed when evaluating multizone cross terms. ---*/ + if (CrossTerm) return; + + SetResToZero(); + /*--- Reduce residual information over all threads in this rank. ---*/ SU2_OMP_CRITICAL for (auto iVar = 0u; iVar < nVar; iVar++) { @@ -365,10 +367,9 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi if (time_n_needed) { SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - + su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjointSolution_time_n(iPoint,Solution); - - if (!CrossTerm) nodes->Set_Solution_time_n(iPoint,Solution); + nodes->Set_Solution_time_n(iPoint,Solution); } END_SU2_OMP_FOR } @@ -377,10 +378,9 @@ void CDiscAdjSolver::ExtractAdjoint_Solution(CGeometry *geometry, CConfig *confi if (time_n1_needed) { SU2_OMP_FOR_STAT(omp_chunk_size) for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) { - + su2double Solution[MAXNVAR] = {0.0}; direct_solver->GetNodes()->GetAdjointSolution_time_n1(iPoint,Solution); - - if (!CrossTerm) nodes->Set_Solution_time_n1(iPoint,Solution); + nodes->Set_Solution_time_n1(iPoint,Solution); } END_SU2_OMP_FOR } From d949cbed776ab1088b5ac6d22e708b0f5a891d19 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 18 May 2021 19:31:19 +0100 Subject: [PATCH 111/192] apply BGS relaxation also to velocities --- SU2_CFD/include/variables/CFEAVariable.hpp | 4 ++-- SU2_CFD/include/variables/CVariable.hpp | 2 +- SU2_CFD/src/solvers/CFEASolver.cpp | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/include/variables/CFEAVariable.hpp b/SU2_CFD/include/variables/CFEAVariable.hpp index 5dc26957717..975f4b24f56 100644 --- a/SU2_CFD/include/variables/CFEAVariable.hpp +++ b/SU2_CFD/include/variables/CFEAVariable.hpp @@ -266,8 +266,8 @@ class CFEAVariable : public CVariable { /*! * \brief Set the value of the solution velocity predictor. */ - inline void SetSolution_Vel_Pred(unsigned long iPoint) final { - for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = Solution_Vel(iPoint,iVar); + inline void SetSolution_Vel_Pred(unsigned long iPoint, const su2double *val_solution_pred) final { + for (unsigned long iVar = 0; iVar < nVar; iVar++) Solution_Vel_Pred(iPoint,iVar) = val_solution_pred[iVar]; } /*! diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 567e453021f..8f049516587 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -1941,7 +1941,7 @@ class CVariable { /*! * \brief A virtual member. Set the value of the velocity solution predictor. */ - inline virtual void SetSolution_Vel_Pred(unsigned long iPoint) {} + inline virtual void SetSolution_Vel_Pred(unsigned long iPoint, const su2double *val_solution_pred) { } /*! * \brief A virtual member. Set the value of the old solution. diff --git a/SU2_CFD/src/solvers/CFEASolver.cpp b/SU2_CFD/src/solvers/CFEASolver.cpp index 30307741607..7763d01f1b1 100644 --- a/SU2_CFD/src/solvers/CFEASolver.cpp +++ b/SU2_CFD/src/solvers/CFEASolver.cpp @@ -2628,7 +2628,7 @@ void CFEASolver::PredictStruct_Displacement(CGeometry *geometry, const CConfig * } break; } - if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); + if (dynamic) nodes->SetSolution_Vel_Pred(iPoint, nodes->GetSolution_Vel(iPoint)); } END_SU2_OMP_PARALLEL @@ -2744,15 +2744,22 @@ void CFEASolver::SetAitken_Relaxation(CGeometry *geometry, const CConfig *config /*--- Set calculated solution as the old solution (needed for dynamic Aitken relaxation) ---*/ nodes->SetSolution_Old(iPoint, dispCalc); - /*--- Set predicted velocity to update in multizone iterations ---*/ - if (dynamic) nodes->SetSolution_Vel_Pred(iPoint); - /*--- Apply the Aitken relaxation ---*/ su2double newDispPred[MAXNVAR] = {0.0}; for (unsigned short iDim=0; iDim < nDim; iDim++) newDispPred[iDim] = (1.0 - WAitken)*dispPred[iDim] + WAitken*dispCalc[iDim]; nodes->SetSolution_Pred(iPoint, newDispPred); + + /*--- Set predicted velocity to update in multizone iterations ---*/ + if (dynamic) { + su2double newVelPred[MAXNVAR] = {0.0}; + const su2double* velPred = nodes->GetSolution_Vel_Pred(iPoint); + const su2double* velCalc = nodes->GetSolution_Vel(iPoint); + for (unsigned short iDim=0; iDim < nDim; iDim++) + newVelPred[iDim] = (1.0 - WAitken)*velPred[iDim] + WAitken*velCalc[iDim]; + nodes->SetSolution_Vel_Pred(iPoint, newVelPred); + } } END_SU2_OMP_PARALLEL @@ -3199,7 +3206,7 @@ void CFEASolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *c if (dynamic) { for (auto iPoint = 0ul; iPoint < nPoint; ++iPoint) - nodes->SetSolution_Vel_Pred(iPoint); + nodes->SetSolution_Vel_Pred(iPoint, nodes->GetSolution_Vel(iPoint)); } if (discrete_adjoint) { From b5d0ed11786ca12a7671fd94836996b9fcef5d5f Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Wed, 19 May 2021 13:53:16 +0200 Subject: [PATCH 112/192] Debugging streamwise x spanwise periodicty. --- Common/src/CConfig.cpp | 4 +++- Common/src/geometry/CPhysicalGeometry.cpp | 4 ++-- SU2_CFD/src/SU2_CFD.cpp | 4 ++-- SU2_CFD/src/numerics/flow/flow_sources.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 17 +++++++++++++---- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 1 + 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 8a51da7a728..08ed394ad35 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4662,7 +4662,9 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow currently only implemented for incompressible flow.", CURRENT_FUNCTION); if (Kind_Solver == INC_EULER) SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); - if (nMarker_PerBound != 2) + if (nMarker_PerBound == 0) + SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); + if (nMarker_PerBound != 2 && false) SU2_MPI::Error("Streamwise Periodic Flow currently only implemented for one Periodic Marker pair. Combining Streamwise and Spanwise periodicity not possible in the moment.", CURRENT_FUNCTION); if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 0) SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 75db70bc909..1f8d300002f 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -8399,11 +8399,11 @@ void CPhysicalGeometry::ComputeMeshQualityStatistics(const CConfig *config) { are close to 90 degress, poor values are typically below 20 degress. ---*/ if (nodes->GetDomain(iPoint)) { - Orthogonality[iPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); + //Orthogonality[iPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); SurfaceArea[iPoint] += area; } if (nodes->GetDomain(jPoint)) { - Orthogonality[jPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); + //Orthogonality[jPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); SurfaceArea[jPoint] += area; } diff --git a/SU2_CFD/src/SU2_CFD.cpp b/SU2_CFD/src/SU2_CFD.cpp index 99f7003d048..49050f4b346 100644 --- a/SU2_CFD/src/SU2_CFD.cpp +++ b/SU2_CFD/src/SU2_CFD.cpp @@ -33,7 +33,7 @@ #endif /* Include file, needed for the runtime NaN catching. You also have to include feenableexcept(...) below. */ -//#include +#include using namespace std; @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { #endif /*--- Uncomment the following line if runtime NaN catching is desired. ---*/ - // feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO ); + feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO ); /*--- Initialize libxsmm, if supported. ---*/ #ifdef HAVE_LIBXSMM diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index b7e583757d4..da7512418d2 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -713,7 +713,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C residual[nDim+1] = Volume * scalar_factor * dot_product; - /*--- If a RANS turbulence model ias used an additional source term, based on the eddy viscosity gradient is added. ---*/ + /*--- If a RANS turbulence model is used, an additional source term, based on the eddy viscosity gradient is added. ---*/ if(turbulent) { /*--- Compute a scalar factor ---*/ diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index f1d6d54963e..be92ed0ab35 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -130,10 +130,19 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Temperature_Local = 0.0; for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - - /*--- Only "outlet"/donor periodic marker ---*/ + if (false) { + cout << "iMarker: " << iMarker << endl; + cout << "Marker Name: " << config->GetMarker_All_TagBound(iMarker) << endl; + cout << "Is Periodic: " << (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY) << endl; + cout << "Global index for periodic bc: " << config->GetMarker_All_PerBound(iMarker) << endl; + if (iMarker < 4) cout << "GetMarker_PerBound: " << config->GetMarker_PerBound(iMarker) << endl; + cout << endl; + } + /*--- Only "outlet"/donor periodic marker. GetnMarker_Periodic counts from 1: First all the inlet marker from + the periodic marker pairs and then the all the outlets. I.e. in order to get the outlet of the first pair + we need to divide the number of periodic markers by 2 and add 1 (because count starts at 1). ---*/ if (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY && - config->GetMarker_All_PerBound(iMarker) == 2) { + config->GetMarker_All_PerBound(iMarker) == (config->GetnMarker_Periodic()/2 + 1)) { for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -154,7 +163,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Average_Density_Local += FaceArea * nodes->GetDensity(iPoint); - /*--- Due to periodicty, temperatures are equal one the inlet(1) and outlet(2) ---*/ + /*--- Due to periodicity, temperatures are equal one the inlet(1) and outlet(2) ---*/ Temperature_Local += FaceArea * nodes->GetTemperature(iPoint); } // if domain diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 6c06747d7fa..5a5c7128485 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -267,6 +267,7 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai su2double kine = nodes->GetSolution(iPoint,0); su2double omega = nodes->GetSolution(iPoint,1); + if ((VorticityMag*F2==0)) {VorticityMag=1;F2=1;} su2double zeta = min(1.0/omega, a1/(VorticityMag*F2)); su2double muT = max(rho*kine*zeta,0.0); From b7f5b05dc28a49d389abffd1b41c5a2173581d67 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 19 May 2021 14:16:46 +0100 Subject: [PATCH 113/192] cleanup overzealous SU2_OMP_MASTER --- SU2_CFD/src/drivers/CDriver.cpp | 158 +++++++--------------------- SU2_CFD/src/solvers/CMeshSolver.cpp | 32 +++--- 2 files changed, 60 insertions(+), 130 deletions(-) diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index b383c006778..25f56322426 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -140,28 +140,22 @@ CDriver::CDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunica nInst[iZone] = config_container[iZone]->GetnTimeInstances(); - geometry_container[iZone] = new CGeometry** [nInst[iZone]]; - iteration_container[iZone] = new CIteration* [nInst[iZone]]; - solver_container[iZone] = new CSolver*** [nInst[iZone]]; - integration_container[iZone] = new CIntegration** [nInst[iZone]]; - numerics_container[iZone] = new CNumerics**** [nInst[iZone]]; - grid_movement[iZone] = new CVolumetricMovement* [nInst[iZone]]; + geometry_container[iZone] = new CGeometry** [nInst[iZone]] (); + iteration_container[iZone] = new CIteration* [nInst[iZone]] (); + solver_container[iZone] = new CSolver*** [nInst[iZone]] (); + integration_container[iZone] = new CIntegration** [nInst[iZone]] (); + numerics_container[iZone] = new CNumerics**** [nInst[iZone]] (); + grid_movement[iZone] = new CVolumetricMovement* [nInst[iZone]] (); /*--- Allocate transfer and interpolation container --- */ interface_container[iZone] = new CInterface*[nZone] (); interpolator_container[iZone].resize(nZone); - for (iInst = 0; iInst < nInst[iZone]; iInst++){ + for (iInst = 0; iInst < nInst[iZone]; iInst++) { config_container[iZone]->SetiInst(iInst); - geometry_container[iZone][iInst] = nullptr; - iteration_container[iZone][iInst] = nullptr; - solver_container[iZone][iInst] = nullptr; - integration_container[iZone][iInst] = nullptr; - grid_movement[iZone][iInst] = nullptr; - /*--- Preprocessing of the geometry for all zones. In this routine, the edge- based data structure is constructed, i.e. node and cell neighbors are identified and linked, face areas and volumes of the dual mesh cells are @@ -319,40 +313,28 @@ void CDriver::SetContainers_Null(){ interface_types = nullptr; nInst = nullptr; - /*--- Definition and of the containers for all possible zones. ---*/ - iteration_container = new CIteration**[nZone]; - solver_container = new CSolver****[nZone]; - integration_container = new CIntegration***[nZone]; - numerics_container = new CNumerics*****[nZone]; - config_container = new CConfig*[nZone]; - geometry_container = new CGeometry***[nZone]; - surface_movement = new CSurfaceMovement*[nZone]; - grid_movement = new CVolumetricMovement**[nZone]; - FFDBox = new CFreeFormDefBox**[nZone]; + iteration_container = new CIteration**[nZone] (); + solver_container = new CSolver****[nZone] (); + integration_container = new CIntegration***[nZone] (); + numerics_container = new CNumerics*****[nZone] (); + config_container = new CConfig*[nZone] (); + geometry_container = new CGeometry***[nZone] (); + surface_movement = new CSurfaceMovement*[nZone] (); + grid_movement = new CVolumetricMovement**[nZone] (); + FFDBox = new CFreeFormDefBox**[nZone] (); interpolator_container.resize(nZone); - interface_container = new CInterface**[nZone]; - interface_types = new unsigned short*[nZone]; - output_container = new COutput*[nZone]; - nInst = new unsigned short[nZone]; + interface_container = new CInterface**[nZone] (); + interface_types = new unsigned short*[nZone] (); + output_container = new COutput*[nZone] (); + nInst = new unsigned short[nZone] (); driver_config = nullptr; driver_output = nullptr; - for (iZone = 0; iZone < nZone; iZone++) { - solver_container[iZone] = nullptr; - integration_container[iZone] = nullptr; - numerics_container[iZone] = nullptr; - config_container[iZone] = nullptr; - geometry_container[iZone] = nullptr; - surface_movement[iZone] = nullptr; - grid_movement[iZone] = nullptr; - FFDBox[iZone] = nullptr; - interface_container[iZone] = nullptr; - interface_types[iZone] = new unsigned short[nZone]; - output_container[iZone] = nullptr; - nInst[iZone] = 1; + interface_types[iZone] = new unsigned short[nZone]; + nInst[iZone] = 1; } strcpy(runtime_file_name, "runtime.dat"); @@ -425,8 +407,7 @@ void CDriver::Postprocessing() { for (iZone = 0; iZone < nZone; iZone++) { if (interface_container[iZone] != nullptr) { for (unsigned short jZone = 0; jZone < nZone; jZone++) - if (interface_container[iZone][jZone] != nullptr) - delete interface_container[iZone][jZone]; + delete interface_container[iZone][jZone]; delete [] interface_container[iZone]; } } @@ -435,20 +416,17 @@ void CDriver::Postprocessing() { } if (interface_types != nullptr) { - for (iZone = 0; iZone < nZone; iZone++) { - if (interface_types[iZone] != nullptr) + for (iZone = 0; iZone < nZone; iZone++) delete [] interface_types[iZone]; - } delete [] interface_types; } for (iZone = 0; iZone < nZone; iZone++) { if (geometry_container[iZone] != nullptr) { for (iInst = 0; iInst < nInst[iZone]; iInst++){ - for (unsigned short iMGlevel = 0; iMGlevel < config_container[iZone]->GetnMGLevels()+1; iMGlevel++) { - if (geometry_container[iZone][iInst][iMGlevel] != nullptr) delete geometry_container[iZone][iInst][iMGlevel]; - } - if (geometry_container[iZone][iInst] != nullptr) delete [] geometry_container[iZone][iInst]; + for (unsigned short iMGlevel = 0; iMGlevel < config_container[iZone]->GetnMGLevels()+1; iMGlevel++) + delete geometry_container[iZone][iInst][iMGlevel]; + delete [] geometry_container[iZone][iInst]; } delete [] geometry_container[iZone]; } @@ -469,10 +447,9 @@ void CDriver::Postprocessing() { if (rank == MASTER_NODE) cout << "Deleted CSurfaceMovement class." << endl; for (iZone = 0; iZone < nZone; iZone++) { - for (iInst = 0; iInst < nInst[iZone]; iInst++){ - if (grid_movement[iZone][iInst] != nullptr) delete grid_movement[iZone][iInst]; - } - if (grid_movement[iZone] != nullptr) delete [] grid_movement[iZone]; + for (iInst = 0; iInst < nInst[iZone]; iInst++) + delete grid_movement[iZone][iInst]; + delete [] grid_movement[iZone]; } delete [] grid_movement; if (rank == MASTER_NODE) cout << "Deleted CVolumetricMovement class." << endl; @@ -486,11 +463,8 @@ void CDriver::Postprocessing() { /*--- Deallocate config container ---*/ if (config_container!= nullptr) { - for (iZone = 0; iZone < nZone; iZone++) { - if (config_container[iZone] != nullptr) { - delete config_container[iZone]; - } - } + for (iZone = 0; iZone < nZone; iZone++) + delete config_container[iZone]; delete [] config_container; } delete driver_config; @@ -502,18 +476,13 @@ void CDriver::Postprocessing() { /*--- Deallocate output container ---*/ if (output_container!= nullptr) { - for (iZone = 0; iZone < nZone; iZone++) { - if (output_container[iZone] != nullptr) { - delete output_container[iZone]; - } - } + for (iZone = 0; iZone < nZone; iZone++) + delete output_container[iZone]; delete [] output_container; } - delete driver_output; - if (rank == MASTER_NODE) cout << "Deleted COutput class." << endl; if (rank == MASTER_NODE) cout << "-------------------------------------------------------------------------" << endl; @@ -647,7 +616,7 @@ void CDriver::Geometrical_Preprocessing(CConfig* config, CGeometry **&geometry, unsigned short iMGlevel; - geometry = new CGeometry*[config->GetnMGLevels()+1]; + geometry = new CGeometry*[config->GetnMGLevels()+1] (); if (!fem_solver){ for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { @@ -745,7 +714,7 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet /*--- Allocate the memory of the current domain, and divide the grid between the ranks. ---*/ - geometry = new CGeometry *[config->GetnMGLevels()+1]; + geometry = new CGeometry *[config->GetnMGLevels()+1] (); /*--- Build the grid data structures using the ParMETIS coloring. ---*/ @@ -881,6 +850,7 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet if (config->GetnMGLevels() != requestedMGlevels) { delete geometry[iMGlevel]; + geometry[iMGlevel] = nullptr; break; } @@ -953,7 +923,7 @@ void CDriver::Geometrical_Preprocessing_DGFEM(CConfig* config, CGeometry **&geom /*--- Allocate the memory of the current domain, and divide the grid between the ranks. ---*/ - geometry = new CGeometry *[config->GetnMGLevels()+1]; + geometry = new CGeometry *[config->GetnMGLevels()+1] (); geometry[MESH_0] = new CMeshFEM_DG(geometry_aux, config); @@ -1029,7 +999,7 @@ void CDriver::Solver_Preprocessing(CConfig* config, CGeometry** geometry, CSolve if (rank == MASTER_NODE) cout << endl <<"-------------------- Solver Preprocessing ( Zone " << config->GetiZone() <<" ) --------------------" << endl; - solver = new CSolver**[config->GetnMGLevels()+1]; + solver = new CSolver**[config->GetnMGLevels()+1] (); for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++){ solver[iMesh] = CSolverFactory::CreateSolverContainer(kindSolver, config, geometry[iMesh], iMesh); @@ -1234,7 +1204,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol nVar_Rad = 0, nVar_Heat = 0; - numerics = new CNumerics***[config->GetnMGLevels()+1]; + numerics = new CNumerics***[config->GetnMGLevels()+1] (); const su2double *constants = nullptr; su2double kine_Inf = 0.0, omega_Inf = 0.0; @@ -1421,9 +1391,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol numerics[iMGlevel][TEMPLATE_SOL][conv_term] = new CConvective_Template(nDim, nVar_Template, config); break; default: - SU2_OMP_MASTER SU2_MPI::Error("Convective scheme not implemented (template_solver).", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1448,9 +1416,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Flow()) { case NO_CONVECTIVE : - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_FLOW option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_CENTERED : @@ -1468,9 +1434,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLaxInc_Flow(nDim, nVar_Flow, config); break; case JST : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentJSTInc_Flow(nDim, nVar_Flow, config); break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid centered scheme or not implemented.\n Currently, only JST and LAX-FRIEDRICH are available for incompressible flows.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } for (iMGlevel = 1; iMGlevel <= config->GetnMGLevels(); iMGlevel++) @@ -1587,9 +1551,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid upwind scheme or not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1604,18 +1566,14 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid upwind scheme or not implemented.\n Currently, only FDS is available for incompressible flows.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the Euler / Navier-Stokes equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1714,9 +1672,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Flow()) { case NO_CONVECTIVE : - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_FLOW option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_CENTERED : @@ -1725,9 +1681,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol switch (config->GetKind_Centered_Flow()) { case LAX : numerics[MESH_0][FLOW_SOL][conv_term] = new CCentLax_NEMO(nDim, nVar_NEMO, nPrimVar_NEMO, nPrimVarGrad_NEMO, config); break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid centered scheme or not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1779,9 +1733,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid upwind scheme or not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1789,9 +1741,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the NEMO Euler / Navier-Stokes equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1861,9 +1811,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol break; default: - SU2_OMP_MASTER SU2_MPI::Error("Riemann solver not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1877,9 +1825,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol switch (config->GetKind_ConvNumScheme_Turb()) { case NO_UPWIND: - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_UPWIND : for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { @@ -1890,9 +1836,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the turbulence equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1942,9 +1886,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_Turb()) { case NO_UPWIND: - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_TURB option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_UPWIND: for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { @@ -1952,9 +1894,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the transition equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -1997,9 +1937,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the heat transfer equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } } @@ -2023,17 +1961,13 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (adj_euler || adj_ns) { if (incompressible) - SU2_OMP_MASTER SU2_MPI::Error("Convective schemes not implemented for incompressible continuous adjoint.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_AdjFlow()) { case NO_CONVECTIVE: - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_ADJFLOW option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_CENTERED : @@ -2046,9 +1980,7 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol case LAX : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentLax_AdjFlow(nDim, nVar_Adj_Flow, config); break; case JST : numerics[MESH_0][ADJFLOW_SOL][conv_term] = new CCentJST_AdjFlow(nDim, nVar_Adj_Flow, config); break; default: - SU2_OMP_MASTER SU2_MPI::Error("Centered scheme not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -2075,18 +2007,14 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Upwind scheme not implemented.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } } break; default: - SU2_OMP_MASTER SU2_MPI::Error("Invalid convective scheme for the continuous adjoint Euler / Navier-Stokes equations.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } @@ -2148,25 +2076,19 @@ void CDriver::Numerics_Preprocessing(CConfig *config, CGeometry **geometry, CSol if (adj_turb) { if (!spalart_allmaras) - SU2_OMP_MASTER SU2_MPI::Error("Only the SA turbulence model can be used with the continuous adjoint solver.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER /*--- Definition of the convective scheme for each equation and mesh level ---*/ switch (config->GetKind_ConvNumScheme_AdjTurb()) { case NO_CONVECTIVE: - SU2_OMP_MASTER SU2_MPI::Error("Config file is missing the CONV_NUM_METHOD_ADJTURB option.", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; case SPACE_UPWIND : for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) numerics[iMGlevel][ADJTURB_SOL][conv_term] = new CUpwSca_AdjTurb(nDim, nVar_Adj_Turb, config); break; default: - SU2_OMP_MASTER SU2_MPI::Error("Convective scheme not implemented (adjoint turbulence).", CURRENT_FUNCTION); - END_SU2_OMP_MASTER break; } diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 62d3b2c7cf8..8a8d5ad1461 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -502,7 +502,14 @@ void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig /*--- Clear residual (loses AD info), we do not want an incremental solution. ---*/ SU2_OMP_PARALLEL { LinSysRes.SetValZero(); - if (time_domain && config->GetFSI_Simulation()) LinSysSol.SetValZero(); + + if (time_domain && config->GetFSI_Simulation()) { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) + for (unsigned short iDim = 0; iDim < nDim; ++iDim) + LinSysSol(iPoint, iDim) = nodes->GetSolution(iPoint, iDim); + END_SU2_OMP_FOR + } } END_SU2_OMP_PARALLEL @@ -593,10 +600,18 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri AD::EndPassive(wasActive); + const su2double velRef = config->GetVelocity_Ref(); + const su2double invVelRef = 1.0 / velRef; + /*--- Clear residual (loses AD info), we do not want an incremental solution. ---*/ SU2_OMP_PARALLEL { LinSysRes.SetValZero(); - LinSysSol.SetValZero(); + + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned short iDim = 0; iDim < nDim; iDim++) + LinSysSol(iPoint, iDim) = geometry[MESH_0]->nodes->GetGridVel(iPoint)[iDim] * velRef; + END_SU2_OMP_FOR } END_SU2_OMP_PARALLEL @@ -607,16 +622,9 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri Solve_System(geometry[MESH_0], config); SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { - for (unsigned short iDim = 0; iDim < nDim; iDim++) { - su2double val_vel = LinSysSol(iPoint, iDim); - - /*--- Non-dimensionalize velocity ---*/ - val_vel /= config->GetVelocity_Ref(); - - geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, val_vel); - } - } + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned short iDim = 0; iDim < nDim; iDim++) + geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, LinSysSol(iPoint,iDim)*invVelRef); END_SU2_OMP_PARALLEL } From 706e878cea991e4482eba51398b9c3f1e67073a6 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Wed, 19 May 2021 16:24:19 +0200 Subject: [PATCH 114/192] correct spelling in comment to trigger recompilation ;) --- Common/include/code_config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/code_config.hpp b/Common/include/code_config.hpp index 377432ee945..4c14ad876b7 100644 --- a/Common/include/code_config.hpp +++ b/Common/include/code_config.hpp @@ -103,7 +103,7 @@ using su2double = codi::RealForward; using su2double = double; #endif -/*--- This type can be used for (rare) compatiblity cases or for +/*--- This type can be used for (rare) compatibility cases or for * computations that are intended to be (always) passive. ---*/ using passivedouble = double; From c08535ec1e049b026058927397f87fb4c32d07c6 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 20:57:20 +0200 Subject: [PATCH 115/192] small cleanup CHeatSolver --- SU2_CFD/src/solvers/CHeatSolver.cpp | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index c845fa0e8f1..27a6941cdf6 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -1264,9 +1264,6 @@ void CHeatSolver::ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) { - unsigned long total_index; - su2double Delta, Vol, *local_Res_TruncError; - /*--- Set maximum residual to zero ---*/ SetResToZero(); @@ -1277,29 +1274,20 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Read the residual ---*/ - local_Res_TruncError = nodes->GetResTruncError(iPoint); - - /*--- Read the volume ---*/ - - Vol = geometry->nodes->GetVolume(iPoint); + su2double* local_Res_TruncError = nodes->GetResTruncError(iPoint); /*--- Modify matrix diagonal to assure diagonal dominance ---*/ if (nodes->GetDelta_Time(iPoint) != 0.0) { - if(flow) { - Delta = Vol / nodes->GetDelta_Time(iPoint); - Jacobian.AddVal2Diag(iPoint, Delta); - } - else if (heat_equation) { - Delta = Vol / nodes->GetDelta_Time(iPoint); - Jacobian.AddVal2Diag(iPoint, Delta); - } + // Identical for flow and heat + const auto Delta = geometry->nodes->GetVolume(iPoint) / nodes->GetDelta_Time(iPoint); + Jacobian.AddVal2Diag(iPoint, Delta); } else { Jacobian.SetVal2Diag(iPoint, 1.0); for (auto iVar = 0u; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; + const auto total_index = iPoint*nVar + iVar; LinSysRes[total_index] = 0.0; local_Res_TruncError[iVar] = 0.0; } @@ -1308,7 +1296,7 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ /*--- Right hand side of the system (-Residual) and initial guess (x = 0) ---*/ for (auto iVar = 0; iVar < nVar; iVar++) { - total_index = iPoint*nVar+iVar; + const auto total_index = iPoint*nVar+iVar; LinSysRes[total_index] = - (LinSysRes[total_index] + local_Res_TruncError[iVar]); LinSysSol[total_index] = 0.0; Residual_RMS[iVar] += LinSysRes[total_index]*LinSysRes[total_index]; @@ -1320,7 +1308,7 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ for (auto iPoint = nPointDomain; iPoint < nPoint; iPoint++) { for (auto iVar = 0u; iVar < nVar; iVar++) { - total_index = iPoint*nVar + iVar; + const auto total_index = iPoint*nVar + iVar; LinSysRes[total_index] = 0.0; LinSysSol[total_index] = 0.0; } From 41d1f9c65230fa6372ee06eab3ffdb53392dd407 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 21:16:23 +0200 Subject: [PATCH 116/192] remove fenv debugging stuff --- Common/src/geometry/CPhysicalGeometry.cpp | 4 ++-- SU2_CFD/src/SU2_CFD.cpp | 4 ++-- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Common/src/geometry/CPhysicalGeometry.cpp b/Common/src/geometry/CPhysicalGeometry.cpp index 1f8d300002f..75db70bc909 100644 --- a/Common/src/geometry/CPhysicalGeometry.cpp +++ b/Common/src/geometry/CPhysicalGeometry.cpp @@ -8399,11 +8399,11 @@ void CPhysicalGeometry::ComputeMeshQualityStatistics(const CConfig *config) { are close to 90 degress, poor values are typically below 20 degress. ---*/ if (nodes->GetDomain(iPoint)) { - //Orthogonality[iPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); + Orthogonality[iPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); SurfaceArea[iPoint] += area; } if (nodes->GetDomain(jPoint)) { - //Orthogonality[jPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); + Orthogonality[jPoint] += area*(90.0 - acos(dotProduct)*180.0/PI_NUMBER); SurfaceArea[jPoint] += area; } diff --git a/SU2_CFD/src/SU2_CFD.cpp b/SU2_CFD/src/SU2_CFD.cpp index 49050f4b346..0eac518b5c2 100644 --- a/SU2_CFD/src/SU2_CFD.cpp +++ b/SU2_CFD/src/SU2_CFD.cpp @@ -33,7 +33,7 @@ #endif /* Include file, needed for the runtime NaN catching. You also have to include feenableexcept(...) below. */ -#include +// #include using namespace std; @@ -79,7 +79,7 @@ int main(int argc, char *argv[]) { #endif /*--- Uncomment the following line if runtime NaN catching is desired. ---*/ - feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO ); + // feenableexcept(FE_INVALID | FE_OVERFLOW | FE_DIVBYZERO ); /*--- Initialize libxsmm, if supported. ---*/ #ifdef HAVE_LIBXSMM diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 5a5c7128485..6c06747d7fa 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -267,7 +267,6 @@ void CTurbSSTSolver::Postprocessing(CGeometry *geometry, CSolver **solver_contai su2double kine = nodes->GetSolution(iPoint,0); su2double omega = nodes->GetSolution(iPoint,1); - if ((VorticityMag*F2==0)) {VorticityMag=1;F2=1;} su2double zeta = min(1.0/omega, a1/(VorticityMag*F2)); su2double muT = max(rho*kine*zeta,0.0); From ee3400834dd432a7dcb10f14e0ea1a4af04717b2 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 21:57:25 +0200 Subject: [PATCH 117/192] lil'cleanup CConjugateHeatInterface --- SU2_CFD/include/interfaces/CInterface.hpp | 1 + SU2_CFD/include/variables/CVariable.hpp | 2 +- .../src/drivers/CDiscAdjSinglezoneDriver.cpp | 12 --- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- .../cht/CConjugateHeatInterface.cpp | 89 +++++++------------ 5 files changed, 35 insertions(+), 71 deletions(-) diff --git a/SU2_CFD/include/interfaces/CInterface.hpp b/SU2_CFD/include/interfaces/CInterface.hpp index 0bd9e4f70fe..ea4b487cbfb 100644 --- a/SU2_CFD/include/interfaces/CInterface.hpp +++ b/SU2_CFD/include/interfaces/CInterface.hpp @@ -70,6 +70,7 @@ class CInterface { unsigned short nSpanMaxAllZones = 0; unsigned short nVar = 0; + static constexpr size_t MAXNDIM = 3; /*!< \brief Max number of space dimensions, used in some static arrays. */ public: /*! diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 8f049516587..4a3b6131511 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -78,7 +78,7 @@ class CVariable { MatrixType Solution_Min; /*!< \brief Min solution for limiter computation. */ MatrixType AuxVar; /*!< \brief Auxiliary variable for gradient computation. */ - CVectorOfMatrix Grad_AuxVar; /*!< \brief Gradient of the auxiliary variables of the problem. */ + CVectorOfMatrix Grad_AuxVar; /*!< \brief Gradient of the auxiliary variables of the problem. */ VectorType Max_Lambda_Inv; /*!< \brief Maximun inviscid eingenvalue. */ VectorType Max_Lambda_Visc; /*!< \brief Maximun viscous eingenvalue. */ diff --git a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp index 885d155fb2b..657785783e8 100644 --- a/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp @@ -345,18 +345,6 @@ void CDiscAdjSinglezoneDriver::SetObjFunction(){ solver[FLOW_SOL]->SetTotal_ComboObj(0.0); -// if (config->GetnMarker_Analyze() != 0) -// output->SpecialOutput_AnalyzeSurface(solver[FLOW_SOL], geometry, config, false); - -// if ((config->GetnMarker_Analyze() != 0) && compressible) -// output->SpecialOutput_Distortion(solver[FLOW_SOL], geometry, config, false); - -// if (config->GetnMarker_NearFieldBound() != 0) -// output->SpecialOutput_SonicBoom(solver[FLOW_SOL], geometry, config, false); - -// if (config->GetPlot_Section_Forces()) -// output->SpecialOutput_SpanLoad(solver[FLOW_SOL], geometry, config, false); - /*--- Surface based obj. function ---*/ solver[FLOW_SOL]->Evaluate_ObjFunc(config); diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 707f5bf264d..c103a577272 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -145,7 +145,7 @@ void CMultizoneDriver::StartSolver() { for (iZone = 1; iZone < nZone; iZone++) { if (config_container[iZone]->GetTime_Ref() < Time_Ref) - Time_Ref = config_container[iZone]->GetTime_Ref(); + Time_Ref = config_container[iZone]->GetTime_Ref(); // TK:: last TimeRef is used } for (iZone = 0; iZone < nZone; iZone++) { diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 50baa8b386d..52a10dfca43 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -42,88 +42,62 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet const auto nDim = donor_geometry->GetnDim(); - su2double Twall, Tnormal, dTdn, rho_cp_solid, Prandtl_Lam, laminar_viscosity, - thermal_diffusivity, thermal_conductivity=0.0, thermal_conductivityND, - heat_flux_density=0.0, conductivity_over_dist=0.0; - /*--- Check whether the current zone is a solid zone or a fluid zone ---*/ - const bool compressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE); const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) && donor_config->GetEnergy_Equation(); - const bool heat_equation = (donor_config->GetKind_Solver() == HEAT_EQUATION) || - (donor_config->GetKind_Solver() == DISC_ADJ_HEAT); + su2double thermal_conductivity; + su2double heat_flux_density; + su2double conductivity_over_dist; + + /*--- Compute distance of donor point to PointNormal for T-gradient/heatflux computation ---*/ const auto Coord = donor_geometry->nodes->GetCoord(Point_Donor); const auto PointNormal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal_Neighbor(); const auto Coord_Normal = donor_geometry->nodes->GetCoord(PointNormal); - Twall = 0.0; Tnormal = 0.0; dTdn = 0.0; - - su2double Edge_Vector[3] = {0.0}; + su2double Edge_Vector[MAXNDIM] = {0.0}; GeometryToolbox::Distance(nDim, Coord_Normal, Coord, Edge_Vector); - su2double dist = GeometryToolbox::Norm(nDim, Edge_Vector); + const auto dist = GeometryToolbox::Norm(nDim, Edge_Vector); /*--- Retrieve temperature solution and its gradient ---*/ - if (compressible_flow) { - - Twall = donor_solution->GetNodes()->GetPrimitive(Point_Donor,0); - Tnormal = donor_solution->GetNodes()->GetPrimitive(PointNormal,0); - - dTdn = (Twall - Tnormal)/dist; - } - else if (incompressible_flow) { - - Twall = donor_solution->GetNodes()->GetTemperature(Point_Donor); - Tnormal = donor_solution->GetNodes()->GetTemperature(PointNormal); - - dTdn = (Twall - Tnormal)/dist; - } - else if (heat_equation) { - Twall = donor_solution->GetNodes()->GetSolution(Point_Donor,0); - Tnormal = donor_solution->GetNodes()->GetSolution(PointNormal,0); - - // TODO: Check if these improve accuracy, if needed at all - // const auto Normal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal(); - // su2double Area = GeometryToolbox::Norm(nDim, Normal); - // for (iDim = 0; iDim < nDim; iDim++) { - // dTdn += (Twall - Tnormal)/dist * (Edge_Vector[iDim]/dist) * (Normal[iDim]/Area); - // } - - dTdn = (Twall - Tnormal)/dist; - } - else { + const auto Twall = donor_solution->GetNodes()->GetTemperature(Point_Donor); + const auto Tnormal = donor_solution->GetNodes()->GetTemperature(PointNormal); - SU2_MPI::Error("Transfer of conjugate heat variables failed (non-supported donor solver).", CURRENT_FUNCTION); - } + const auto dTdn = (Twall - Tnormal)/dist; + // TODO: Check if these improve accuracy, if needed at all + // const auto Normal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal(); + // su2double Area = GeometryToolbox::Norm(nDim, Normal); + // for (iDim = 0; iDim < nDim; iDim++) { + // dTdn += (Twall - Tnormal)/dist * (Edge_Vector[iDim]/dist) * (Normal[iDim]/Area); + // } /*--- Calculate the heat flux density (temperature gradient times thermal conductivity) ---*/ if (compressible_flow) { - su2double Gamma = donor_config->GetGamma(); - su2double Gas_Constant = donor_config->GetGas_ConstantND(); - su2double Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; + const auto Gamma = donor_config->GetGamma(); + const auto Gas_Constant = donor_config->GetGas_ConstantND(); + const auto Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; - Prandtl_Lam = donor_config->GetPrandtl_Lam(); - laminar_viscosity = donor_solution->GetNodes()->GetLaminarViscosity(Point_Donor); // TDE check for consistency - Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; + const auto Prandtl_Lam = donor_config->GetPrandtl_Lam(); + const auto laminar_viscosity = donor_solution->GetNodes()->GetLaminarViscosity(Point_Donor); // TDE check for consistency - thermal_conductivityND = Cp*(laminar_viscosity/Prandtl_Lam); - heat_flux_density = thermal_conductivityND*dTdn; + const auto thermal_conductivityND = Cp*(laminar_viscosity/Prandtl_Lam); + heat_flux_density = thermal_conductivityND*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || (donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::AVERAGED_TEMPERATURE_ROBIN_HEATFLUX)) { - thermal_conductivity = thermal_conductivityND*donor_config->GetViscosity_Ref(); - conductivity_over_dist = thermal_conductivity/dist; + thermal_conductivity = thermal_conductivityND*donor_config->GetViscosity_Ref(); + conductivity_over_dist = thermal_conductivity/dist; } } else if (incompressible_flow) { const auto iPoint = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNode(); - thermal_conductivityND = donor_solution->GetNodes()->GetThermalConductivity(iPoint); + const auto thermal_conductivityND = donor_solution->GetNodes()->GetThermalConductivity(iPoint); heat_flux_density = thermal_conductivityND*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || @@ -140,24 +114,25 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet *donor_config->GetViscosity_Ref(); break; - default: + case CONDUCTIVITYMODEL::POLYNOMIAL: + SU2_MPI::Error("Polynomial Conductivity model not implemented for CHT interface.", CURRENT_FUNCTION); break; } conductivity_over_dist = thermal_conductivity/dist; } } - else if (heat_equation) { + else if (donor_config->GetHeatProblem()) { /*--- Heat solver stand-alone case ---*/ - thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); - heat_flux_density = thermal_diffusivity*dTdn; + const auto thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); + heat_flux_density = thermal_diffusivity*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || (donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::AVERAGED_TEMPERATURE_ROBIN_HEATFLUX)) { - rho_cp_solid = donor_config->GetSpecific_Heat_Cp()*donor_config->GetDensity_Solid(); + const auto rho_cp_solid = donor_config->GetSpecific_Heat_Cp()*donor_config->GetDensity_Solid(); conductivity_over_dist = thermal_diffusivity*rho_cp_solid/dist; } } From 97455a1e100db776ebe9b111b1f1d2951ecb17a7 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 21:59:54 +0200 Subject: [PATCH 118/192] remove debug output --- SU2_CFD/src/solvers/CIncNSSolver.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index be92ed0ab35..c085b8b629d 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -130,17 +130,10 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, Temperature_Local = 0.0; for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) { - if (false) { - cout << "iMarker: " << iMarker << endl; - cout << "Marker Name: " << config->GetMarker_All_TagBound(iMarker) << endl; - cout << "Is Periodic: " << (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY) << endl; - cout << "Global index for periodic bc: " << config->GetMarker_All_PerBound(iMarker) << endl; - if (iMarker < 4) cout << "GetMarker_PerBound: " << config->GetMarker_PerBound(iMarker) << endl; - cout << endl; - } + /*--- Only "outlet"/donor periodic marker. GetnMarker_Periodic counts from 1: First all the inlet marker from - the periodic marker pairs and then the all the outlets. I.e. in order to get the outlet of the first pair - we need to divide the number of periodic markers by 2 and add 1 (because count starts at 1). ---*/ + the periodic marker pairs and then the all the outlets. I.e. in order to get the outlet of the first pair + we need to divide the number of periodic markers by 2 and add 1 (because count starts at 1). ---*/ if (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY && config->GetMarker_All_PerBound(iMarker) == (config->GetnMarker_Periodic()/2 + 1)) { From 465a75a8a244eab77d3f8f7e65242579d166a453 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 22:10:00 +0200 Subject: [PATCH 119/192] Maybe uninitialized fix --- SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 52a10dfca43..22309bab59f 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -47,8 +47,8 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) && donor_config->GetEnergy_Equation(); su2double thermal_conductivity; - su2double heat_flux_density; - su2double conductivity_over_dist; + su2double heat_flux_density = 0.0; + su2double conductivity_over_dist 0.0; /*--- Compute distance of donor point to PointNormal for T-gradient/heatflux computation ---*/ const auto Coord = donor_geometry->nodes->GetCoord(Point_Donor); From 953508f66b9b1b224572188f6f99939a071f5eaa Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 20 May 2021 22:21:30 +0200 Subject: [PATCH 120/192] I should build locally before I push... --- SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 22309bab59f..b5cb6eee3a8 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -48,7 +48,7 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet su2double thermal_conductivity; su2double heat_flux_density = 0.0; - su2double conductivity_over_dist 0.0; + su2double conductivity_over_dist = 0.0; /*--- Compute distance of donor point to PointNormal for T-gradient/heatflux computation ---*/ const auto Coord = donor_geometry->nodes->GetCoord(Point_Donor); From 8968a1bceda672c7e7c32da91a4a136bbbda849e Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Fri, 21 May 2021 00:10:33 +0200 Subject: [PATCH 121/192] fml --- SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index b5cb6eee3a8..2ce47ae1933 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -46,7 +46,7 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet const bool compressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE); const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) && donor_config->GetEnergy_Equation(); - su2double thermal_conductivity; + su2double thermal_conductivity = 0.0; su2double heat_flux_density = 0.0; su2double conductivity_over_dist = 0.0; From c6d73468f4da77fb8f59c22628b1e2717823e1a4 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:32:51 +0200 Subject: [PATCH 122/192] inherit default values for SetWallDistance --- Common/include/fem/fem_geometry_structure.hpp | 2 +- Common/include/geometry/CPhysicalGeometry.hpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/include/fem/fem_geometry_structure.hpp b/Common/include/fem/fem_geometry_structure.hpp index d9e92fb4b65..eec7e3bac29 100644 --- a/Common/include/fem/fem_geometry_structure.hpp +++ b/Common/include/fem/fem_geometry_structure.hpp @@ -1234,7 +1234,7 @@ class CMeshFEM_DG: public CMeshFEM { * \param[in] config - Config of this geometry (not the ADT zone's geometry) * \param[in] iZone - ignored */ - void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone=numeric_limits::max()) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override; }; /*! diff --git a/Common/include/geometry/CPhysicalGeometry.hpp b/Common/include/geometry/CPhysicalGeometry.hpp index 976d7902de3..21e1ec02b7f 100644 --- a/Common/include/geometry/CPhysicalGeometry.hpp +++ b/Common/include/geometry/CPhysicalGeometry.hpp @@ -771,7 +771,7 @@ class CPhysicalGeometry final : public CGeometry { * \param[in] config - ignored * \param[in] iZone - zone whose markers made the ADT */ - void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone=numeric_limits::max()) override; + void SetWallDistance(CADTElemClass* WallADT, const CConfig* config, unsigned short iZone) override; /*! * \brief Set wall distances a specific value From 13cb05df2d6477df831ff784f0e9a43b0b0df32e Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:34:04 +0200 Subject: [PATCH 123/192] use default NdFlattener arguments --- Common/src/geometry/CGeometry.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a43843c5a0a..bc4d67931e5 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3953,9 +3953,9 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); }); - NdFlattener<2,su2double,unsigned long> roughness_local(roughness_f); + NdFlattener<2> roughness_local(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener<3,su2double,unsigned long> roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); + NdFlattener<3> roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); // use it to update roughnesses for(int jZone=0; jZoneGetnRoughWall()>0){ From f60ca15d83f8fd869aa08a5db22a186bb269c7d5 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:34:36 +0200 Subject: [PATCH 124/192] Refactoring in ndflattener.hpp Data -> Data_t Index -> Index_t _TemplateArgument -> TemplateArgument_ typename Nd_type::Index -> using Index_t = typename Nd_t::Index_t, then use Index_t etc. --- Common/include/toolboxes/ndflattener.hpp | 243 ++++++++++++----------- 1 file changed, 124 insertions(+), 119 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 1b20da931ea..0e1caa4ff00 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -152,16 +152,16 @@ */ -template +template class NdFlattener; namespace helpers { - template + template struct NdFlattener_MPI_Environment { - MPI_Allgatherv_type MPI_Allgatherv; - MPI_Datatype_type mpi_data; - MPI_Datatype_type mpi_index; - MPI_Communicator_type comm; + MPI_Allgatherv_t MPI_Allgatherv_fun; + MPI_Datatype_t mpi_data; + MPI_Datatype_t mpi_index; + MPI_Communicator_t comm; int rank; int size; }; @@ -173,74 +173,77 @@ namespace helpers { * - The case N==2 is much like the case N>3 but an additional function data() should be provided. * - For N>3, more indices have to be read, return an IndexAccumulator. * \tparam N - Number of missing parameters - * \tparam Nd_type - Type of the accessed NdFlattener, should be NdFlattener + * \tparam Nd_t - Type of the accessed NdFlattener, should be NdFlattener */ /*! \class IndexAccumulator_Base * \brief Parent class of IndexAccumulator. * \details IndexAccumulator provides the operator[] method. */ - template + template class IndexAccumulator_Base { public: static constexpr size_t N = _N; - using Nd_type = _Nd_type; + using Nd_t = Nd_t_; + using Index_t = typename Nd_t::Index_t; /*== Conditional is part of the standard library since C++14, keep it here for C++11 compatibility. ==*/ template struct conditional { typedef T type; }; template struct conditional { typedef F type; }; protected: - Nd_type* nd; /*!< \brief The accessed NdFlattener. */ - const typename Nd_type::Index offset; /*!< \brief Index in the currently accessed layer. */ + Nd_t* nd; /*!< \brief The accessed NdFlattener. */ + const Index_t offset; /*!< \brief Index in the currently accessed layer. */ //const typename Nd_type::Index size; /*!< \brief Exclusive upper bound for the next index. */ - IndexAccumulator_Base(Nd_type* nd, typename Nd_type::Index offset): + IndexAccumulator_Base(Nd_t* nd, Index_t offset): nd(nd), offset(offset) {} }; - template - class IndexAccumulator : public IndexAccumulator_Base<_N,_Nd_type>{ + template + class IndexAccumulator : public IndexAccumulator_Base<_N,Nd_t_>{ public: static constexpr size_t N = _N; - using Nd_type = _Nd_type; - typedef IndexAccumulator_Base<_N,_Nd_type> Base; + using Nd_t = Nd_t_; + typedef IndexAccumulator_Base<_N,Nd_t_> Base; + using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. */ - using Nd_Base_type = typename Base::template conditional< - std::is_const::value, - const typename Nd_type::Base, - typename Nd_type::Base + using Nd_Base_t = typename Base::template conditional< + std::is_const::value, + const typename Nd_t::Base, + typename Nd_t::Base >::type; /*! Return type of operator[]. */ - using LookupType = IndexAccumulator; + using LookupType = IndexAccumulator; /*! \brief Read one more index. * \param[in] i - Index. */ - LookupType operator[] (typename Nd_type::Index i) { + LookupType operator[] (Index_t i) { //const typename Nd_type::Index new_offset = this->nd->GetIndices()[this->offset+i]; //const typename Nd_type::Index new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; - return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); + return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); } }; - template - class IndexAccumulator_Checked : public IndexAccumulator<_N,_Nd_type>{ + template + class IndexAccumulator_Checked : public IndexAccumulator<_N,Nd_t_>{ public: static constexpr size_t N = _N; - using Nd_type = _Nd_type; - typedef IndexAccumulator<_N,_Nd_type> Base; + using Nd_t = Nd_t_; + typedef IndexAccumulator<_N,Nd_t_> Base; + using Index_t = typename Nd_t::Index_t; protected: /*! Exclusive upper bound for the next index. */ - const typename Nd_type::Index _size; + const Index_t size_; public: template - IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {} + IndexAccumulator_Checked(Index_t size, ARGS... args): Base(args...), size_(size) {} /*! Return type of operator[]. */ using LookupType = IndexAccumulator_Checked; @@ -249,28 +252,29 @@ namespace helpers { * previous indices. * \param[in] i - Index. */ - LookupType operator[] (typename Nd_type::Index i) { - if(i>=_size){ + LookupType operator[] (Index_t i) { + if(i>=size_){ SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } - const typename Nd_type::Index new_offset = this->nd->GetIndices()[this->offset+i]; - const typename Nd_type::Index new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; + const Index_t new_offset = this->nd->GetIndices()[this->offset+i]; + const Index_t new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; return LookupType(new_size, static_cast(this->nd),new_offset); } /*! \brief Return exclusive upper bound for next index. */ - typename Nd_type::Index size() const { - return _size; + Index_t size() const { + return size_; } }; - template - class IndexAccumulator<1,_Nd_type> : public IndexAccumulator_Base<1,_Nd_type>{ + template + class IndexAccumulator<1,Nd_t_> : public IndexAccumulator_Base<1,Nd_t_>{ public: static constexpr size_t N = 1; - using Nd_type = _Nd_type; - typedef IndexAccumulator_Base<1,_Nd_type> Base; + using Nd_t = Nd_t_; + typedef IndexAccumulator_Base<1,Nd_t_> Base; + using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} @@ -278,15 +282,15 @@ namespace helpers { * \details Data type of NdFlattener, but do also preserve constness. */ using LookupType = typename Base::template conditional< - std::is_const::value, - const typename Nd_type::Data, - typename Nd_type::Data + std::is_const::value, + const typename Nd_t::Data_t, + typename Nd_t::Data_t >::type; /*! \brief Return (possibly const) reference to the corresponding data element. * \param[in] i - Last index. */ - LookupType& operator[] (typename Nd_type::Index i) { + LookupType& operator[] (Index_t i) { return this->nd->GetData() [ this->offset+i ]; } @@ -301,33 +305,34 @@ namespace helpers { } }; - template - class IndexAccumulator_Checked<1,_Nd_type> : public IndexAccumulator<1,_Nd_type>{ + template + class IndexAccumulator_Checked<1,Nd_t_> : public IndexAccumulator<1,Nd_t_>{ public: static constexpr size_t N = 1; - using Nd_type = _Nd_type; - typedef IndexAccumulator<1,_Nd_type> Base; + using Nd_t = Nd_t_; + typedef IndexAccumulator<1,Nd_t_> Base; + using Index_t = typename Nd_t::Index_t; protected: /*! Exclusive upper bound for the next index. */ - const typename Nd_type::Index _size; + const Index_t size_; public: template - IndexAccumulator_Checked(typename Nd_type::Index size, ARGS... args): Base(args...), _size(size) {} + IndexAccumulator_Checked(Index_t size, ARGS... args): Base(args...), size_(size) {} /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. */ - typename Base::LookupType& operator[] (typename Nd_type::Index i) { - if(i>=_size){ + typename Base::LookupType& operator[] (Index_t i) { + if(i>=size_){ SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } return Base::operator[](i); } - typename Nd_type::Index size() const { - return _size; + Index_t size() const { + return size_; } }; @@ -336,7 +341,7 @@ namespace helpers { inline helpers::NdFlattener_MPI_Environment Get_Nd_MPI_Env() { helpers::NdFlattener_MPI_Environment mpi_env; - mpi_env.MPI_Allgatherv = &(SU2_MPI::Allgatherv); + mpi_env.MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv); mpi_env.mpi_index = MPI_UNSIGNED_LONG; mpi_env.mpi_data = MPI_DOUBLE; mpi_env.comm=SU2_MPI::GetComm(); @@ -357,21 +362,21 @@ Get_Nd_MPI_Env() { * values (but not its structure) have changed. * * \tparam K - number of indices - * \tparam Data - Type of stored array data + * \tparam Data_t - Type of stored array data * \tparam Index - Type of index */ -template -class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ +template +class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ public: static constexpr size_t K = _K; - using Data = _Data; - using Index = _Index; + using Data_t = Data_t_; + using Index_t = Index_; - typedef NdFlattener Base; // could also be named LowerLayer - typedef NdFlattener CurrentLayer; + typedef NdFlattener Base; // could also be named LowerLayer + typedef NdFlattener CurrentLayer; typedef typename Base::LowestLayer LowestLayer; // the K=1 class private: @@ -380,18 +385,18 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ * For the layer K=1, nNodes will be the number of data points. * For a layer K>1, nNodes will be the number of sublists. */ - Index nNodes=0; + Index_t nNodes=0; /*! \brief Iterator used at construction, runs from 0 to (nNodes-1). */ - Index iNode=0; + Index_t iNode=0; /*! \brief Indices in the lower layer's indices or data array */ - std::vector indices; + std::vector indices; /*=== Getters ===*/ public: - Index* GetIndices() {return indices.data();} - const Index* GetIndices() const {return indices.data();} + Index_t* GetIndices() {return indices.data();} + const Index_t* GetIndices() const {return indices.data();} /*=== Outputting ===*/ @@ -414,9 +419,9 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ * \param[in] from - Beginning of the representation in the indices array. * \param[in] to - Ending of the representation in the indices array. */ - void toPythonString_fromto(std::ostream& output, Index from, Index to) const { + void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { output << "["; - for(Index i=from; i{ */ template void count_f(f_type f) { - Index nChild = f.first; - for(Index iChild=0; iChild{ */ template void set_f(f_type f, bool refresh) { - Index nChild = f.first; - for(Index iChild=0; iChild{ MPI_Environment_type const& mpi_env, Base const* local_version ) { - Index** Nodes_all = new Index*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure + Index_t** Nodes_all = new Index_t*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure for(size_t k=0; k{ MPI_Environment_type const& mpi_env, Base const* local_version ) { - Index* Nodes_all_0 = nullptr; + Index_t* Nodes_all_0 = nullptr; int* displs = new int[mpi_env.size]; // {0, 1, ..., size-1} int* ones = new int[mpi_env.size]; // {1,1, ...} for(int r=0; r{ */ template void count_g(MPI_Environment_type const& mpi_env, - Index** Nodes_all, + Index_t** Nodes_all, CurrentLayer const* local_version, int const* displs, int const* ones ) { assert( Nodes_all[K-1]==nullptr); - Nodes_all[K-1] = new Index[mpi_env.size]; + Nodes_all[K-1] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r{ */ template void set_g(MPI_Environment_type const& mpi_env, - Index** Nodes_all, + Index_t** Nodes_all, CurrentLayer const* local_version ) { @@ -668,13 +673,13 @@ class NdFlattener: public NdFlattener<_K-1,_Data,_Index>{ Nodes_all_k_cumulated[r+1] = Nodes_all_k_cumulated[r] + Nodes_all[K-1][r]; Nodes_all_K_as_int[r] = Nodes_all[K-1][r]; } - mpi_env.MPI_Allgatherv( local_version->indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version->indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); // shift indices for(int r=1; r{ /*== Data access ==*/ public: - Index size() const { // should not be called by recursion, is incorrect in lower layers! + Index_t size() const { // should not be called by recursion, is incorrect in lower layers! return nNodes; } /*! \brief Look-up with IndexAccumulator, non-const version. */ - helpers::IndexAccumulator > operator[](Index i0) { - return helpers::IndexAccumulator >(this,0)[i0]; + helpers::IndexAccumulator > operator[](Index_t i0) { + return helpers::IndexAccumulator >(this,0)[i0]; } /*! \brief Look-up with IndexAccumulator, const version. */ - helpers::IndexAccumulator > operator[](Index i0) const { - return helpers::IndexAccumulator >(this,0)[i0]; + helpers::IndexAccumulator > operator[](Index_t i0) const { + return helpers::IndexAccumulator >(this,0)[i0]; } /*! \brief Look-up with IndexAccumulator_Checked, non-const version. */ - helpers::IndexAccumulator_Checked > checked() { - return helpers::IndexAccumulator_Checked >(size(),this,0); + helpers::IndexAccumulator_Checked > checked() { + return helpers::IndexAccumulator_Checked >(size(),this,0); } /*! \brief Look-up with IndexAccumulator_Checked, const version. */ - helpers::IndexAccumulator_Checked > checked() const { - return helpers::IndexAccumulator_Checked >(size(),this,0); + helpers::IndexAccumulator_Checked > checked() const { + return helpers::IndexAccumulator_Checked >(size(),this,0); } }; -template -class NdFlattener<1, _Data, _Index> { +template +class NdFlattener<1, Data_t_, _Index> { public: static constexpr size_t K = 1; - using Data = _Data; - using Index = _Index; + using Data_t = Data_t_; + using Index_t = _Index; - typedef NdFlattener<1, Data, Index> CurrentLayer; + typedef NdFlattener<1, Data_t, Index_t> CurrentLayer; typedef CurrentLayer LowestLayer; private: - Index nNodes=0; - Index iNode=0; - std::vector data; + Index_t nNodes=0; + Index_t iNode=0; + std::vector data; /*=== Getters ===*/ public: - Data* GetData() {return data.data();} - const Data* GetData() const {return data.data();} + Data_t* GetData() {return data.data();} + const Data_t* GetData() const {return data.data();} /*=== Outputting ===*/ protected: - void toPythonString_fromto(std::ostream& output, Index from, Index to) const { + void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { output << "["; - for(Index i=from; i { template void set_f(f_type f, bool refresh){ - Index nChild = f.first; - for(Index iChild=0; iChild { protected: template void count_g(MPI_Environment_type const& mpi_env, - Index** Nodes_all, + Index_t** Nodes_all, CurrentLayer const* local_version, int const* displs, int const* ones) { assert( Nodes_all[0]==nullptr); - Nodes_all[0] = new Index[mpi_env.size]; + Nodes_all[0] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r { template void set_g(MPI_Environment_type const& mpi_env, - Index** Nodes_all, + Index_t** Nodes_all, CurrentLayer const* local_version ) { @@ -805,7 +810,7 @@ class NdFlattener<1, _Data, _Index> { Nodes_all_0_as_int[r] = Nodes_all[0][r]; } - mpi_env.MPI_Allgatherv( local_version->data.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version->data.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); delete[] Nodes_all_0_as_int; delete[] Nodes_all_0_cumulated; } @@ -815,28 +820,28 @@ class NdFlattener<1, _Data, _Index> { // Calling the following functions is a bit strange, because if you have only one level, // you do not really benefit from NdFlattener's functionality. public: - Index size() const { // should not be called by recursion, is incorrect in lower layers! + Index_t size() const { // should not be called by recursion, is incorrect in lower layers! return nNodes; } /*! \brief Data look-up, non-const version. */ - Data& operator[](Index i0) { + Data_t& operator[](Index_t i0) { return data[i0]; } /*! \brief Data look-up, const version. */ - const Data& operator[](Index i0) const { + const Data_t& operator[](Index_t i0) const { return data[0]; } /*! \brief Look-up with IndexAccumulator_Checked, non-const version. */ - helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data,Index> > checked() { - return helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data,Index> >(size(),this,0); + helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data_t,Index_t> > checked() { + return helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data_t,Index_t> >(size(),this,0); } /*! \brief Look-up with IndexAccumulator_Checked, const version. */ - helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data,Index> > checked() const { - return helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data,Index> >(size(),this,0); + helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data_t,Index_t> > checked() const { + return helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data_t,Index_t> >(size(),this,0); } }; From c70706b7b26906835c144e509ba29ae0226f5a68 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:41:19 +0200 Subject: [PATCH 125/192] typedef -> using --- Common/include/toolboxes/ndflattener.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 0e1caa4ff00..f501ff8c6e0 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -204,7 +204,7 @@ namespace helpers { public: static constexpr size_t N = _N; using Nd_t = Nd_t_; - typedef IndexAccumulator_Base<_N,Nd_t_> Base; + using Base = IndexAccumulator_Base<_N,Nd_t_>; using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} @@ -234,7 +234,7 @@ namespace helpers { public: static constexpr size_t N = _N; using Nd_t = Nd_t_; - typedef IndexAccumulator<_N,Nd_t_> Base; + using Base = IndexAccumulator<_N,Nd_t_>; using Index_t = typename Nd_t::Index_t; protected: @@ -273,7 +273,7 @@ namespace helpers { public: static constexpr size_t N = 1; using Nd_t = Nd_t_; - typedef IndexAccumulator_Base<1,Nd_t_> Base; + using Base = IndexAccumulator_Base<1,Nd_t_>; using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} @@ -310,7 +310,7 @@ namespace helpers { public: static constexpr size_t N = 1; using Nd_t = Nd_t_; - typedef IndexAccumulator<1,Nd_t_> Base; + using Base = IndexAccumulator<1,Nd_t_>; using Index_t = typename Nd_t::Index_t; protected: @@ -375,9 +375,9 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ using Data_t = Data_t_; using Index_t = Index_; - typedef NdFlattener Base; // could also be named LowerLayer - typedef NdFlattener CurrentLayer; - typedef typename Base::LowestLayer LowestLayer; // the K=1 class + using Base = NdFlattener; + using CurrentLayer = NdFlattener; + using LowestLayer = typename Base::LowestLayer; // the K=1 class private: /*! \brief Number of nodes in this layer. @@ -724,8 +724,8 @@ class NdFlattener<1, Data_t_, _Index> { using Data_t = Data_t_; using Index_t = _Index; - typedef NdFlattener<1, Data_t, Index_t> CurrentLayer; - typedef CurrentLayer LowestLayer; + using CurrentLayer = NdFlattener<1, Data_t, Index_t>; + using LowestLayer = CurrentLayer; private: Index_t nNodes=0; From efe1c63498e2d6b362a91747612eac1637fecffc Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:44:04 +0200 Subject: [PATCH 126/192] continue f60ca15d with _N -> N_ --- Common/include/toolboxes/ndflattener.hpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index f501ff8c6e0..905e969b510 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -179,10 +179,10 @@ namespace helpers { * \brief Parent class of IndexAccumulator. * \details IndexAccumulator provides the operator[] method. */ - template + template class IndexAccumulator_Base { public: - static constexpr size_t N = _N; + static constexpr size_t N = N_; using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; @@ -199,12 +199,12 @@ namespace helpers { }; - template - class IndexAccumulator : public IndexAccumulator_Base<_N,Nd_t_>{ + template + class IndexAccumulator : public IndexAccumulator_Base{ public: - static constexpr size_t N = _N; + using Base = IndexAccumulator_Base; + static constexpr size_t N = N_; using Nd_t = Nd_t_; - using Base = IndexAccumulator_Base<_N,Nd_t_>; using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} @@ -229,12 +229,12 @@ namespace helpers { } }; - template - class IndexAccumulator_Checked : public IndexAccumulator<_N,Nd_t_>{ + template + class IndexAccumulator_Checked : public IndexAccumulator{ public: - static constexpr size_t N = _N; + using Base = IndexAccumulator; + static constexpr size_t N = N_; using Nd_t = Nd_t_; - using Base = IndexAccumulator<_N,Nd_t_>; using Index_t = typename Nd_t::Index_t; protected: @@ -271,9 +271,9 @@ namespace helpers { template class IndexAccumulator<1,Nd_t_> : public IndexAccumulator_Base<1,Nd_t_>{ public: + using Base = IndexAccumulator_Base<1,Nd_t_>; static constexpr size_t N = 1; using Nd_t = Nd_t_; - using Base = IndexAccumulator_Base<1,Nd_t_>; using Index_t = typename Nd_t::Index_t; template IndexAccumulator(ARGS... args): Base(args...) {} @@ -308,9 +308,9 @@ namespace helpers { template class IndexAccumulator_Checked<1,Nd_t_> : public IndexAccumulator<1,Nd_t_>{ public: + using Base = IndexAccumulator<1,Nd_t_>; static constexpr size_t N = 1; using Nd_t = Nd_t_; - using Base = IndexAccumulator<1,Nd_t_>; using Index_t = typename Nd_t::Index_t; protected: From 0b19e6d278ebd7bfd85ca291d5ae62a1ca65faa8 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 12:52:58 +0200 Subject: [PATCH 127/192] IndexAccumulator_Base::conditional -> ::su2conditional --- Common/include/code_config.hpp | 7 +++++++ Common/include/toolboxes/ndflattener.hpp | 12 ++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Common/include/code_config.hpp b/Common/include/code_config.hpp index 4c14ad876b7..0e085acbc76 100644 --- a/Common/include/code_config.hpp +++ b/Common/include/code_config.hpp @@ -60,6 +60,13 @@ template using su2enable_if = typename std::enable_if::type; +/*--- Compile-time type selection. ---*/ +template struct su2conditional { typedef T type; }; +template struct su2conditional { typedef F type; }; + +template +using su2conditional_t = typename su2conditional::type; + /*--- Detect compilation with OpenMP. ---*/ #if defined(_OPENMP) #define HAVE_OMP diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 905e969b510..0c9aa905813 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -186,10 +186,6 @@ namespace helpers { using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; - /*== Conditional is part of the standard library since C++14, keep it here for C++11 compatibility. ==*/ - template struct conditional { typedef T type; }; - template struct conditional { typedef F type; }; - protected: Nd_t* nd; /*!< \brief The accessed NdFlattener. */ const Index_t offset; /*!< \brief Index in the currently accessed layer. */ @@ -211,11 +207,11 @@ namespace helpers { /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. */ - using Nd_Base_t = typename Base::template conditional< + using Nd_Base_t = su2conditional_t< std::is_const::value, const typename Nd_t::Base, typename Nd_t::Base - >::type; + >; /*! Return type of operator[]. */ using LookupType = IndexAccumulator; @@ -281,11 +277,11 @@ namespace helpers { /*! Return type of operator[]. * \details Data type of NdFlattener, but do also preserve constness. */ - using LookupType = typename Base::template conditional< + using LookupType = su2conditional_t< std::is_const::value, const typename Nd_t::Data_t, typename Nd_t::Data_t - >::type; + >; /*! \brief Return (possibly const) reference to the corresponding data element. * \param[in] i - Last index. From dfd3686de9d020f71a0c71e9b06c71ae735572cb Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 13:12:41 +0200 Subject: [PATCH 128/192] 'Merge' IndexAccumulator_Checked into IndexAccumulator checking functionality is standard now Added const lookup tests to ndflattener_tests.cpp Fixed bug in NdFlattener<1>::operator[](Index_t) const. --- Common/include/toolboxes/ndflattener.hpp | 135 ++++-------------- .../Common/toolboxes/ndflattener_tests.cpp | 43 +++--- 2 files changed, 55 insertions(+), 123 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 0c9aa905813..56dd2fd0496 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -98,20 +98,16 @@ * auto nd_g_rank = nd_global[rank]; * nd_g_rank[zone][marker] += 1.0; * - * If you want to check that every index is in the correct range dictated by the NdFlattener and the - * previous indices, call NdFlattener::checked() before interacting with the "[]...[]" interface. - * Now you can obtain IndexAccumulator_Checked objects which you can also query for the (exclusive) - * upper bound for the next index: + * Each index is checked to lie in the correct range dictated by the NdFlattener and the + * previous indices. You can obtain the minimal overflowing index with `size`: * - * auto nd_g_rank = nd_global.checked()[rank]; - * nd_g_rank[zone][marker] += 1.0; + * auto nd_g_rank = nd_global[rank]; * std::cout << nd_g_rank[zone].size(); * * When all indices except the last one are fixed, the corresponding data is stored contiguously and a pointer * to this 1D array can be retrieved by * * nd_global[rank][zone].data() - * nd_global.checked()[rank][zone].data() * * # Unit tests * The interface described here is tested in UnitTests/Common/toolboxes/ndflattener_tests.cpp, which may also @@ -174,6 +170,7 @@ namespace helpers { * - For N>3, more indices have to be read, return an IndexAccumulator. * \tparam N - Number of missing parameters * \tparam Nd_t - Type of the accessed NdFlattener, should be NdFlattener + * \tparam Check - if true, raise error if index to operator[] is not in range */ /*! \class IndexAccumulator_Base * \brief Parent class of IndexAccumulator. @@ -189,13 +186,21 @@ namespace helpers { protected: Nd_t* nd; /*!< \brief The accessed NdFlattener. */ const Index_t offset; /*!< \brief Index in the currently accessed layer. */ + const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ + //const typename Nd_type::Index size; /*!< \brief Exclusive upper bound for the next index. */ - IndexAccumulator_Base(Nd_t* nd, Index_t offset): - nd(nd), offset(offset) {} + IndexAccumulator_Base(Nd_t* nd, Index_t offset, Index_t size): + nd(nd), offset(offset), size_(size) {} + + /*! \brief Return exclusive upper bound for next index. + */ + Index_t size() const { + return size_; + } }; - template + template class IndexAccumulator : public IndexAccumulator_Base{ public: using Base = IndexAccumulator_Base; @@ -214,58 +219,26 @@ namespace helpers { >; /*! Return type of operator[]. */ using LookupType = IndexAccumulator; - - /*! \brief Read one more index. - * \param[in] i - Index. - */ - LookupType operator[] (Index_t i) { - //const typename Nd_type::Index new_offset = this->nd->GetIndices()[this->offset+i]; - //const typename Nd_type::Index new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; - return LookupType(static_cast(this->nd),this->nd->GetIndices()[this->offset+i]); - } - }; - - template - class IndexAccumulator_Checked : public IndexAccumulator{ - public: - using Base = IndexAccumulator; - static constexpr size_t N = N_; - using Nd_t = Nd_t_; - using Index_t = typename Nd_t::Index_t; - - protected: - /*! Exclusive upper bound for the next index. */ - const Index_t size_; - - public: - template - IndexAccumulator_Checked(Index_t size, ARGS... args): Base(args...), size_(size) {} - - /*! Return type of operator[]. */ - using LookupType = IndexAccumulator_Checked; + using Base::size; /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and * previous indices. * \param[in] i - Index. */ LookupType operator[] (Index_t i) { - if(i>=size_){ - SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } const Index_t new_offset = this->nd->GetIndices()[this->offset+i]; const Index_t new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; - return LookupType(new_size, static_cast(this->nd),new_offset); + return LookupType(static_cast(this->nd),new_offset,new_size); } - /*! \brief Return exclusive upper bound for next index. - */ - Index_t size() const { - return size_; - } }; - template - class IndexAccumulator<1,Nd_t_> : public IndexAccumulator_Base<1,Nd_t_>{ + template + class IndexAccumulator<1,Nd_t_,Check> : public IndexAccumulator_Base<1,Nd_t_>{ public: using Base = IndexAccumulator_Base<1,Nd_t_>; static constexpr size_t N = 1; @@ -282,11 +255,16 @@ namespace helpers { const typename Nd_t::Data_t, typename Nd_t::Data_t >; + using Base::size; - /*! \brief Return (possibly const) reference to the corresponding data element. + /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. */ LookupType& operator[] (Index_t i) { + assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } return this->nd->GetData() [ this->offset+i ]; } @@ -301,37 +279,6 @@ namespace helpers { } }; - template - class IndexAccumulator_Checked<1,Nd_t_> : public IndexAccumulator<1,Nd_t_>{ - public: - using Base = IndexAccumulator<1,Nd_t_>; - static constexpr size_t N = 1; - using Nd_t = Nd_t_; - using Index_t = typename Nd_t::Index_t; - - protected: - /*! Exclusive upper bound for the next index. */ - const Index_t size_; - - public: - template - IndexAccumulator_Checked(Index_t size, ARGS... args): Base(args...), size_(size) {} - - /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. - * \param[in] i - Last index. - */ - typename Base::LookupType& operator[] (Index_t i) { - if(i>=size_){ - SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } - return Base::operator[](i); - } - - Index_t size() const { - return size_; - } - }; - } // namespace helpers inline helpers::NdFlattener_MPI_Environment @@ -694,22 +641,12 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ /*! \brief Look-up with IndexAccumulator, non-const version. */ helpers::IndexAccumulator > operator[](Index_t i0) { - return helpers::IndexAccumulator >(this,0)[i0]; + return helpers::IndexAccumulator >(this,0,size())[i0]; } /*! \brief Look-up with IndexAccumulator, const version. */ helpers::IndexAccumulator > operator[](Index_t i0) const { - return helpers::IndexAccumulator >(this,0)[i0]; - } - /*! \brief Look-up with IndexAccumulator_Checked, non-const version. - */ - helpers::IndexAccumulator_Checked > checked() { - return helpers::IndexAccumulator_Checked >(size(),this,0); - } - /*! \brief Look-up with IndexAccumulator_Checked, const version. - */ - helpers::IndexAccumulator_Checked > checked() const { - return helpers::IndexAccumulator_Checked >(size(),this,0); + return helpers::IndexAccumulator >(this,0,size())[i0]; } }; @@ -827,17 +764,7 @@ class NdFlattener<1, Data_t_, _Index> { /*! \brief Data look-up, const version. */ const Data_t& operator[](Index_t i0) const { - return data[0]; - } - /*! \brief Look-up with IndexAccumulator_Checked, non-const version. - */ - helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data_t,Index_t> > checked() { - return helpers::IndexAccumulator_Checked<1, NdFlattener<1,Data_t,Index_t> >(size(),this,0); - } - /*! \brief Look-up with IndexAccumulator_Checked, const version. - */ - helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data_t,Index_t> > checked() const { - return helpers::IndexAccumulator_Checked<1, const NdFlattener<1,Data_t,Index_t> >(size(),this,0); + return data[i0]; } }; diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index ce0dcbb4a19..b120ac123b8 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -58,20 +58,11 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ REQUIRE( nd2.size() == 2 ); REQUIRE( nd2[0][0] == 0.0 ); REQUIRE( nd2[0][1] == 1.0 ); - REQUIRE( nd2.checked()[1].size() == 3 + rank ); + REQUIRE( nd2[1].size() == 3 + rank ); for(int i=0; i<3+rank; i++){ REQUIRE( nd2[1][i] == 2.0 + rank + i ); } - /*-- Check structure again, with checked look-up. --*/ - REQUIRE( nd2.checked()[0].size() == 2 ); - REQUIRE( nd2.checked()[0][0] == 0.0 ); - REQUIRE( nd2.checked()[0][1] == 1.0 ); - REQUIRE( nd2.checked()[1].size() == 3 + rank ); - for(int i=0; i<3+rank; i++){ - REQUIRE( nd2.checked()[1][i] == 2.0 + rank + i ); - } - /*-- Modify structure. --*/ nd2[0][0] = 0.7; nd2[0].data()[1] = 1.7; @@ -79,29 +70,43 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- gather flattening structures of all processes --*/ NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); - /*-- Check gathered structure, partly with checked look-up. --*/ + /*-- Check gathered structure, non-const look-up. --*/ REQUIRE( nd3.size() == size ); for(int r=0; r& nd3_const = nd3; + REQUIRE( nd3_const.size() == size ); + for(int r=0; r Date: Mon, 24 May 2021 13:57:56 +0200 Subject: [PATCH 129/192] added functionality to NdFlattener<1> and corresponding tests --- Common/include/toolboxes/ndflattener.hpp | 64 ++++++++++++++++--- .../Common/toolboxes/ndflattener_tests.cpp | 25 ++++++++ 2 files changed, 79 insertions(+), 10 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 56dd2fd0496..56cc93cbbe2 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -377,7 +377,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ * * Called recursively when a derived class (higher K) is constructed. */ - NdFlattener() {}; + NdFlattener() {} /*! \brief Constructor which calls initialize_or_refresh. * @@ -663,20 +663,20 @@ class NdFlattener<1, Data_t_, _Index> { private: Index_t nNodes=0; Index_t iNode=0; - std::vector data; + std::vector data_; /*=== Getters ===*/ public: - Data_t* GetData() {return data.data();} - const Data_t* GetData() const {return data.data();} + Data_t* GetData() {return data_.data();} + const Data_t* GetData() const {return data_.data();} /*=== Outputting ===*/ protected: void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { output << "["; for(Index_t i=from; i { public: NdFlattener(void) {} + template + NdFlattener(ARGS... args) { + initialize_or_refresh(args...); + } + + template + void initialize_or_refresh(ARGS... args){ + if( initialized() ){ + refresh(args...); + } else { + initialize(args...); + } + } + + bool initialized(){ + return nNodes>0; + } + + // Functionality to initialize/refresh from a recursive function + // could be desirable also for N=1, in order to gather from such + // NdFlatteners an NdFlattener with N=2. + // Gathering an NdFlattener with N=1 is not meaningful however. + + template + void initialize(f_type f) { + count_f(f); + allocate(); + set_f(f, false); + } + + template + void refresh(f_type f){ + reset_iNode(); + set_f(f, true); + } + protected: void allocate(){ - data.reserve(nNodes); + data_.reserve(nNodes); } void reset_iNode(){ @@ -705,7 +741,7 @@ class NdFlattener<1, Data_t_, _Index> { void set_f(f_type f, bool refresh){ Index_t nChild = f.first; for(Index_t iChild=0; iChild { Nodes_all_0_as_int[r] = Nodes_all[0][r]; } - mpi_env.MPI_Allgatherv_fun( local_version->data.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version->data_.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data_.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); delete[] Nodes_all_0_as_int; delete[] Nodes_all_0_cumulated; } @@ -759,12 +795,20 @@ class NdFlattener<1, Data_t_, _Index> { /*! \brief Data look-up, non-const version. */ Data_t& operator[](Index_t i0) { - return data[i0]; + return data_[i0]; } /*! \brief Data look-up, const version. */ const Data_t& operator[](Index_t i0) const { - return data[i0]; + return data_[i0]; + } + + Data_t* data() { + return data_.data(); + } + + const Data_t* data() const { + return data_.data(); } }; diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index b120ac123b8..8015c50a257 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -110,6 +110,31 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ } } + /*-- Check 1D functionality. --*/ + NdFlattener<1> a1( + std::make_pair( (size_t)(3+rank), [rank,A](int i) { + return A[1][i]; + }) + ); + const NdFlattener<1>& a1_const = a1; + REQUIRE( a1.size() == 3 + rank ); + for(int i=0; i<3+rank; i++){ + REQUIRE( a1[i] == 2.0 + rank + i ); + REQUIRE( a1_const[i] == 2.0 + rank + i ); + } + a1[0] = -1.0; + REQUIRE( a1_const.data()[0] == -1.0 ); + a1.data()[0] = 2.0 + rank; + REQUIRE( a1_const[0] == 2.0 + rank ); + const NdFlattener<2> a2_const(Get_Nd_MPI_Env(), &a1); + REQUIRE( a2_const.size() == size ); + for(int r=0; r Date: Mon, 24 May 2021 14:03:19 +0200 Subject: [PATCH 130/192] Reference instead of pointer for gathering initialization/refreshing --- Common/include/toolboxes/ndflattener.hpp | 30 +++++++++---------- Common/src/geometry/CGeometry.cpp | 2 +- .../Common/toolboxes/ndflattener_tests.cpp | 6 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 56cc93cbbe2..b67c2f3adb8 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -509,7 +509,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ template void initialize( MPI_Environment_type const& mpi_env, - Base const* local_version + Base const& local_version ) { Index_t** Nodes_all = new Index_t*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure for(size_t k=0; k{ template void refresh( MPI_Environment_type const& mpi_env, - Base const* local_version + Base const& local_version ) { Index_t* Nodes_all_0 = nullptr; int* displs = new int[mpi_env.size]; // {0, 1, ..., size-1} @@ -561,8 +561,8 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ displs[r] = r; ones[r] = 1; } - LowestLayer::count_g(mpi_env, &Nodes_all_0, static_cast(local_version), displs, ones); - LowestLayer::set_g(mpi_env, &Nodes_all_0, static_cast(local_version)); + LowestLayer::count_g(mpi_env, &Nodes_all_0, static_cast(local_version), displs, ones); + LowestLayer::set_g(mpi_env, &Nodes_all_0, static_cast(local_version)); delete[] Nodes_all_0; // allocated by count_g delete[] displs; @@ -581,30 +581,30 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ template void count_g(MPI_Environment_type const& mpi_env, Index_t** Nodes_all, - CurrentLayer const* local_version, + CurrentLayer const& local_version, int const* displs, int const* ones ) { assert( Nodes_all[K-1]==nullptr); Nodes_all[K-1] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv_fun( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r(local_version), displs, ones); + Base::count_g(mpi_env, Nodes_all, static_cast(local_version), displs, ones); } /*! \brief Gather the distributed flatteners' data and index arrays into the allocated arrays. * * \param[in] mpi_env - MPI environment for communication * \param[in] Nodes_all - [k][r] is the number of nodes in layer (k+1), rank r. - * \param[in] local_version - local instance to be send to the other processes + * \param[in] local_version - local instance to be sent to the other processes */ template void set_g(MPI_Environment_type const& mpi_env, Index_t** Nodes_all, - CurrentLayer const* local_version ) + CurrentLayer const& local_version ) { int* Nodes_all_K_as_int = new int[mpi_env.size]; @@ -616,7 +616,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ Nodes_all_k_cumulated[r+1] = Nodes_all_k_cumulated[r] + Nodes_all[K-1][r]; Nodes_all_K_as_int[r] = Nodes_all[K-1][r]; } - mpi_env.MPI_Allgatherv_fun( local_version->indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version.indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); // shift indices for(int r=1; r{ delete[] Nodes_all_K_as_int; delete[] Nodes_all_k_cumulated; - Base::set_g(mpi_env, Nodes_all, static_cast(local_version)); + Base::set_g(mpi_env, Nodes_all, static_cast(local_version)); } /*== Data access ==*/ @@ -751,14 +751,14 @@ class NdFlattener<1, Data_t_, _Index> { template void count_g(MPI_Environment_type const& mpi_env, Index_t** Nodes_all, - CurrentLayer const* local_version, + CurrentLayer const& local_version, int const* displs, int const* ones) { assert( Nodes_all[0]==nullptr); Nodes_all[0] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv_fun( &(local_version->nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r { template void set_g(MPI_Environment_type const& mpi_env, Index_t** Nodes_all, - CurrentLayer const* local_version ) + CurrentLayer const& local_version ) { @@ -779,7 +779,7 @@ class NdFlattener<1, Data_t_, _Index> { Nodes_all_0_as_int[r] = Nodes_all[0][r]; } - mpi_env.MPI_Allgatherv_fun( local_version->data_.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data_.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version.data_.data(), Nodes_all[0][mpi_env.rank], mpi_env.mpi_data, data_.data(), Nodes_all_0_as_int, Nodes_all_0_cumulated, mpi_env.mpi_data, mpi_env.comm ); delete[] Nodes_all_0_as_int; delete[] Nodes_all_0_cumulated; } diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index bc4d67931e5..883f385f889 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3955,7 +3955,7 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo }); NdFlattener<2> roughness_local(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener<3> roughness_global(Get_Nd_MPI_Env(), &(roughness_local)); + NdFlattener<3> roughness_global(Get_Nd_MPI_Env(), roughness_local); // use it to update roughnesses for(int jZone=0; jZoneGetnRoughWall()>0){ diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 8015c50a257..af60fa26d23 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -68,7 +68,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ nd2[0].data()[1] = 1.7; /*-- gather flattening structures of all processes --*/ - NdFlattener<3> nd3(Get_Nd_MPI_Env(), &nd2); + NdFlattener<3> nd3(Get_Nd_MPI_Env(), nd2); /*-- Check gathered structure, non-const look-up. --*/ REQUIRE( nd3.size() == size ); @@ -98,7 +98,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- Reread modified A and check again. --*/ nd2.initialize_or_refresh(f); - nd3.refresh(Get_Nd_MPI_Env(), &nd2); + nd3.refresh(Get_Nd_MPI_Env(), nd2); REQUIRE( nd3.size() == size ); for(int r=0; r a2_const(Get_Nd_MPI_Env(), &a1); + const NdFlattener<2> a2_const(Get_Nd_MPI_Env(), a1); REQUIRE( a2_const.size() == size ); for(int r=0; r Date: Mon, 24 May 2021 14:44:24 +0200 Subject: [PATCH 131/192] nd pointer->ref --- Common/include/toolboxes/ndflattener.hpp | 27 ++++++++++++------------ 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index b67c2f3adb8..f5528e8a8c3 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -184,12 +184,11 @@ namespace helpers { using Index_t = typename Nd_t::Index_t; protected: - Nd_t* nd; /*!< \brief The accessed NdFlattener. */ + Nd_t& nd; /*!< \brief The accessed NdFlattener. */ const Index_t offset; /*!< \brief Index in the currently accessed layer. */ const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ - //const typename Nd_type::Index size; /*!< \brief Exclusive upper bound for the next index. */ - IndexAccumulator_Base(Nd_t* nd, Index_t offset, Index_t size): + IndexAccumulator_Base(Nd_t& nd, Index_t offset, Index_t size): nd(nd), offset(offset), size_(size) {} /*! \brief Return exclusive upper bound for next index. @@ -220,6 +219,7 @@ namespace helpers { /*! Return type of operator[]. */ using LookupType = IndexAccumulator; using Base::size; + using Base::nd; using Base::offset; /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and * previous indices. @@ -230,9 +230,9 @@ namespace helpers { if(Check){ if(i>=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } - const Index_t new_offset = this->nd->GetIndices()[this->offset+i]; - const Index_t new_size = this->nd->GetIndices()[this->offset+i+1] - new_offset; - return LookupType(static_cast(this->nd),new_offset,new_size); + const Index_t new_offset = nd.GetIndices()[offset+i]; + const Index_t new_size = nd.GetIndices()[offset+i+1] - new_offset; + return LookupType(nd,new_offset,new_size); } }; @@ -256,6 +256,7 @@ namespace helpers { typename Nd_t::Data_t >; using Base::size; + using Base::nd; using Base::offset; /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. @@ -265,7 +266,7 @@ namespace helpers { if(Check){ if(i>=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } - return this->nd->GetData() [ this->offset+i ]; + return nd.GetData() [ offset+i ]; } /*! \brief Return (possibly const) pointer to data. @@ -561,8 +562,8 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ displs[r] = r; ones[r] = 1; } - LowestLayer::count_g(mpi_env, &Nodes_all_0, static_cast(local_version), displs, ones); - LowestLayer::set_g(mpi_env, &Nodes_all_0, static_cast(local_version)); + LowestLayer::count_g(mpi_env, &Nodes_all_0, local_version, displs, ones); + LowestLayer::set_g(mpi_env, &Nodes_all_0, local_version); delete[] Nodes_all_0; // allocated by count_g delete[] displs; @@ -592,7 +593,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ for(int r=0; r(local_version), displs, ones); + Base::count_g(mpi_env, Nodes_all, local_version, displs, ones); } /*! \brief Gather the distributed flatteners' data and index arrays into the allocated arrays. @@ -629,7 +630,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ delete[] Nodes_all_K_as_int; delete[] Nodes_all_k_cumulated; - Base::set_g(mpi_env, Nodes_all, static_cast(local_version)); + Base::set_g(mpi_env, Nodes_all, local_version); } /*== Data access ==*/ @@ -641,12 +642,12 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ /*! \brief Look-up with IndexAccumulator, non-const version. */ helpers::IndexAccumulator > operator[](Index_t i0) { - return helpers::IndexAccumulator >(this,0,size())[i0]; + return helpers::IndexAccumulator >(*this,0,size())[i0]; } /*! \brief Look-up with IndexAccumulator, const version. */ helpers::IndexAccumulator > operator[](Index_t i0) const { - return helpers::IndexAccumulator >(this,0,size())[i0]; + return helpers::IndexAccumulator >(*this,0,size())[i0]; } }; From 6364cbf235c950023b558b5bef942457c4ffb420 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 24 May 2021 14:31:04 +0100 Subject: [PATCH 132/192] less duplication, better unsteady FSI restarts --- Common/include/geometry/CGeometry.hpp | 2 +- Common/include/geometry/dual_grid/CPoint.hpp | 2 +- .../include/solvers/CFVMFlowSolverBase.inl | 69 +++++------ SU2_CFD/include/solvers/CMeshSolver.hpp | 30 ++--- SU2_CFD/include/solvers/CSolver.hpp | 2 +- SU2_CFD/src/drivers/CDriver.cpp | 47 ++++---- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- SU2_CFD/src/drivers/CSinglezoneDriver.cpp | 2 +- .../src/iteration/CDiscAdjFluidIteration.cpp | 2 +- .../src/iteration/CDiscAdjHeatIteration.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 9 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 11 +- SU2_CFD/src/output/CNEMOCompOutput.cpp | 14 ++- SU2_CFD/src/solvers/CMeshSolver.cpp | 114 ++++++------------ 14 files changed, 134 insertions(+), 174 deletions(-) diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index ad4f6d80e67..c0d1ac313ba 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1258,7 +1258,7 @@ class CGeometry { * \param geometry_container - Geometrical definition. * \param config - Config */ - void UpdateGeometry(CGeometry **geometry_container, CConfig *config); + static void UpdateGeometry(CGeometry **geometry_container, CConfig *config); /*! * \brief Update the multi-grid structure for the customized boundary conditions diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 83f1b89b7ad..56a21fc1ad9 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -543,7 +543,7 @@ class CPoint { void SetVolume_n(); /*! - * \brief Set the volume of the control volume at time n+1. + * \brief Set the volume of the control volume at time n-1. */ void SetVolume_nM1(); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 64d3934c539..374a6ec3917 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -707,7 +707,7 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** /*--- Restart the solution from file information ---*/ - unsigned short iDim, iVar, iMesh, iMeshFine; + unsigned short iDim, iVar, iMesh; unsigned long iPoint, index, iChildren, Point_Fine; unsigned short turb_model = config->GetKind_Turb_Model(); su2double Area_Children, Area_Parent; @@ -746,6 +746,15 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** Read_SU2_Restart_ASCII(geometry[MESH_0], config, restart_filename); } + if (update_geo && dynamic_grid) { + auto notFound = fields.end(); + if (find(fields.begin(), notFound, string("\"Grid_Velocity_x\"")) == notFound) { + if (rank == MASTER_NODE) + cout << "\nWARNING: The restart file does not contain grid velocities, these will be set to zero.\n" << endl; + steady_restart = true; + } + } + /*--- Load data from the restart into correct containers. ---*/ unsigned long counter = 0, iPoint_Global = 0; @@ -829,39 +838,26 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** END_SU2_OMP_MASTER SU2_OMP_BARRIER - /*--- Update the geometry for flows on deforming meshes ---*/ + /*--- Update the geometry for flows on deforming meshes. ---*/ if ((dynamic_grid || static_fsi) && update_geo) { - /*--- Communicate the new coordinates and grid velocities at the halos ---*/ - - geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, COORDINATES); - geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, COORDINATES); + CGeometry::UpdateGeometry(geometry, config); if (dynamic_grid) { - geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, GRID_VELOCITY); - geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, GRID_VELOCITY); - } - - /*--- Recompute the edges and dual mesh control volumes in the - domain and on the boundaries. ---*/ + for (iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { - geometry[MESH_0]->SetControlVolume(config, UPDATE); - geometry[MESH_0]->SetBoundControlVolume(config, UPDATE); - geometry[MESH_0]->SetMaxLength(config); + /*--- Compute the grid velocities on the coarser levels. ---*/ + if (iMesh) geometry[iMesh]->SetRestricted_GridVelocity(geometry[iMesh-1], config); - /*--- Update the multigrid structure after setting up the finest grid, - including computing the grid velocities on the coarser levels. ---*/ + geometry[iMesh]->nodes->SetVolume_n(); + geometry[iMesh]->nodes->SetVolume_nM1(); - for (iMesh = 1; iMesh <= config->GetnMGLevels(); iMesh++) { - iMeshFine = iMesh-1; - geometry[iMesh]->SetControlVolume(config, geometry[iMeshFine], UPDATE); - geometry[iMesh]->SetBoundControlVolume(config, geometry[iMeshFine],UPDATE); - geometry[iMesh]->SetCoord(geometry[iMeshFine]); - if (dynamic_grid) { - geometry[iMesh]->SetRestricted_GridVelocity(geometry[iMeshFine], config); + if (config->GetGrid_Movement()) { + geometry[iMesh]->nodes->SetCoord_n(); + geometry[iMesh]->nodes->SetCoord_n1(); + } } - geometry[iMesh]->SetMaxLength(config); } } @@ -973,7 +969,7 @@ void CFVMFlowSolverBase::SetInitialCondition(CGeometry **geometry, CSolver /*--- The value of the solution for the first iteration of the dual time ---*/ - if (dual_time && (TimeIter == 0 || (restart && TimeIter == config->GetRestart_Iter()))) { + if (dual_time && TimeIter == config->GetRestart_Iter()) { PushSolutionBackInTime(TimeIter, restart, rans, solver_container, geometry, config); } @@ -998,27 +994,24 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo } } - if (restart && (TimeIter == config->GetRestart_Iter()) && (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) { - - const bool update_geo = !config->GetFSI_Simulation(); + if (restart && (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) { - /*--- Load an additional restart file for a 2nd-order restart ---*/ + /*--- Load an additional restart file for a 2nd-order restart. ---*/ - solver_container[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver_container, config, config->GetRestart_Iter() - 1, - update_geo); + solver_container[MESH_0][FLOW_SOL]->LoadRestart(geometry, solver_container, config, TimeIter-1, true); - /*--- Load an additional restart file for the turbulence model ---*/ + /*--- Load an additional restart file for the turbulence model. ---*/ if (rans) - solver_container[MESH_0][TURB_SOL]->LoadRestart(geometry, solver_container, config, config->GetRestart_Iter() - 1, - false); + solver_container[MESH_0][TURB_SOL]->LoadRestart(geometry, solver_container, config, TimeIter-1, false); /*--- Push back this new solution to time level N. ---*/ for (unsigned short iMesh = 0; iMesh <= config->GetnMGLevels(); iMesh++) { solver_container[iMesh][FLOW_SOL]->GetNodes()->Set_Solution_time_n(); - if (rans) { - solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); - } + if (rans) solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); + + geometry[iMesh]->nodes->SetVolume_n(); + if (config->GetGrid_Movement()) geometry[iMesh]->nodes->SetCoord_n(); } } } diff --git a/SU2_CFD/include/solvers/CMeshSolver.hpp b/SU2_CFD/include/solvers/CMeshSolver.hpp index 5a4a6d927f0..27fd06dd39c 100644 --- a/SU2_CFD/include/solvers/CMeshSolver.hpp +++ b/SU2_CFD/include/solvers/CMeshSolver.hpp @@ -72,21 +72,14 @@ class CMeshSolver final : public CFEASolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void UpdateGridCoord(CGeometry *geometry, CConfig *config); - - /*! - * \brief Update the dual grid after the grid movement (edges and control volumes). - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void UpdateDualGrid(CGeometry *geometry, CConfig *config); + void UpdateGridCoord(CGeometry *geometry, const CConfig *config); /*! * \brief Compute the grid velocity form the displacements of the mesh. * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - void ComputeGridVelocity(CGeometry *geometry, CConfig *config); + void ComputeGridVelocity(CGeometry **geometry, const CConfig *config) const; /*! * \brief Compute the grid velocity form the velocity at deformable boundary. @@ -96,13 +89,6 @@ class CMeshSolver final : public CFEASolver { */ void ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumerics **numerics, CConfig *config); - /*! - * \brief Update the coarse multigrid levels after the grid movement. - * \param[in] geometry - Geometrical definition of the problem. - * \param[in] config - Definition of the particular problem. - */ - void UpdateMultiGrid(CGeometry **geometry, CConfig *config) const; - /*! * \brief Check the boundary vertex that are going to be moved. * \param[in] geometry - Geometrical definition of the problem. @@ -120,6 +106,12 @@ class CMeshSolver final : public CFEASolver { */ void BC_Deforming(CGeometry *geometry, const CConfig *config, unsigned short val_marker, bool velocity); + /*! + * \brief Load the geometries at the previous time states n and nM1. + * \param[in] geometry - Geometrical definition of the problem. + */ + void RestartOldGeometry(CGeometry *geometry, const CConfig *config); + public: /*! * \brief Constructor of the class. @@ -174,12 +166,6 @@ class CMeshSolver final : public CFEASolver { int val_iter, bool val_update_geo) override; - /*! - * \brief Load the geometries at the previous time states n and nM1. - * \param[in] geometry - Geometrical definition of the problem. - */ - void Restart_OldGeometry(CGeometry *geometry, CConfig *config) override; - /*! * \brief Get minimun volume in the mesh * \return diff --git a/SU2_CFD/include/solvers/CSolver.hpp b/SU2_CFD/include/solvers/CSolver.hpp index 946c4e36502..ccf0bbf7408 100644 --- a/SU2_CFD/include/solvers/CSolver.hpp +++ b/SU2_CFD/include/solvers/CSolver.hpp @@ -630,7 +630,7 @@ class CSolver { * \param[in] geometry - Geometrical definition of the problem. * \param[in] config - Definition of the particular problem. */ - virtual void Restart_OldGeometry(CGeometry *geometry, CConfig *config); + void Restart_OldGeometry(CGeometry *geometry, CConfig *config); /*! * \brief A virtual member. diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index 25f56322426..ee98c0b25a3 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -229,14 +229,9 @@ CDriver::CDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunica CGeometry::ComputeWallDistance(config_container, geometry_container); } + /*--- Definition of the interface and transfer conditions between different zones. ---*/ - /*--- Definition of the interface and transfer conditions between different zones. - *--- The transfer container is defined for zones paired one to one. - *--- This only works for a multizone FSI problem (nZone > 1). - *--- Also, at the moment this capability is limited to two zones (nZone < 3). - *--- This will change in the future. ---*/ - - if ( nZone > 1 ) { + if (nZone > 1) { if (rank == MASTER_NODE) cout << endl <<"------------------- Multizone Interface Preprocessing -------------------" << endl; @@ -244,8 +239,19 @@ CDriver::CDriver(char* confFile, unsigned short val_nZone, SU2_Comm MPICommunica interface_types, interface_container, interpolator_container); } + if (fsi) { + for (iZone = 0; iZone < nZone; iZone++) { + for (iInst = 0; iInst < nInst[iZone]; iInst++){ + Solver_Restart(solver_container[iZone][iInst], geometry_container[iZone][iInst], + config_container[iZone], true); + } + } + } + if (config_container[ZONE_0]->GetBoolTurbomachinery()){ - if (rank == MASTER_NODE)cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; + if (rank == MASTER_NODE) + cout << endl <<"---------------------- Turbomachinery Preprocessing ---------------------" << endl; + Turbomachinery_Preprocessing(config_container, geometry_container, solver_container, interface_container); } @@ -861,16 +867,18 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet /*--- For unsteady simulations, initialize the grid volumes and coordinates for previous solutions. Loop over all zones/grids ---*/ - if ((config->GetTime_Marching() != TIME_MARCHING::STEADY) && config->GetGrid_Movement()) { + if ((config->GetTime_Marching() != TIME_MARCHING::STEADY) && config->GetDynamic_Grid()) { for (iMGlevel = 0; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { /*--- Update cell volume ---*/ geometry[iMGlevel]->nodes->SetVolume_n(); geometry[iMGlevel]->nodes->SetVolume_nM1(); - /*--- Update point coordinates ---*/ - geometry[iMGlevel]->nodes->SetCoord_n(); - geometry[iMGlevel]->nodes->SetCoord_n1(); + if (config->GetGrid_Movement()) { + /*--- Update point coordinates ---*/ + geometry[iMGlevel]->nodes->SetCoord_n(); + geometry[iMGlevel]->nodes->SetCoord_n1(); + } } } @@ -1009,16 +1017,13 @@ void CDriver::Solver_Preprocessing(CConfig* config, CGeometry** geometry, CSolve DOFsPerPoint = 0; - for (unsigned int iSol = 0; iSol < MAX_SOLS; iSol++){ - if (solver[MESH_0][iSol] != nullptr){ - DOFsPerPoint += solver[MESH_0][iSol]->GetnVar(); - } - } + for (unsigned int iSol = 0; iSol < MAX_SOLS; iSol++) + if (solver[MESH_0][iSol]) DOFsPerPoint += solver[MESH_0][iSol]->GetnVar(); - bool update_geo = true; - if (config->GetFSI_Simulation()) update_geo = false; + /*--- Restart solvers, for FSI the geometry cannot be updated because the interpolation classes + * should always use the undeformed mesh (otherwise the results would not be repeatable). ---*/ - Solver_Restart(solver, geometry, config, update_geo); + if (!fsi) Solver_Restart(solver, geometry, config, true); /*--- Set up any necessary inlet profiles ---*/ @@ -2251,7 +2256,7 @@ void CDriver::DynamicMesh_Preprocessing(CConfig *config, CGeometry **geometry, C /*--- Update the multi-grid structure to propagate the derivative information to the coarser levels ---*/ - geometry[MESH_0]->UpdateGeometry(geometry,config); + CGeometry::UpdateGeometry(geometry,config); } diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 707f5bf264d..314f21daace 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -244,7 +244,7 @@ void CMultizoneDriver::Preprocess(unsigned long TimeIter) { solver_container[iZone][INST_0], config_container[iZone], TimeIter); } - else if (!fsi && !config_container[iZone]->GetDiscrete_Adjoint() && config_container[iZone]->GetHeatProblem()) { + else if (!fsi && config_container[iZone]->GetHeatProblem()) { /*--- Set the initial condition for HEAT equation ---------------------------------------------*/ solver_container[iZone][INST_0][MESH_0][HEAT_SOL]->SetInitialCondition(geometry_container[iZone][INST_0], solver_container[iZone][INST_0], diff --git a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp index 05090c168c3..2b9f488d493 100644 --- a/SU2_CFD/src/drivers/CSinglezoneDriver.cpp +++ b/SU2_CFD/src/drivers/CSinglezoneDriver.cpp @@ -129,7 +129,7 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) { solver_container[ZONE_0][INST_0], config_container[ZONE_0], TimeIter); } - else if ( config_container[ZONE_0]->GetHeatProblem()) { + else if (config_container[ZONE_0]->GetHeatProblem()) { /*--- Set the initial condition for HEAT equation ---------------------------------------------*/ solver_container[ZONE_0][INST_0][MESH_0][HEAT_SOL]->SetInitialCondition(geometry_container[ZONE_0][INST_0], solver_container[ZONE_0][INST_0], diff --git a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp index 8cfd548399c..87449a46cc4 100644 --- a/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjFluidIteration.cpp @@ -503,7 +503,7 @@ void CDiscAdjFluidIteration::SetDependencies(CSolver***** solver, CGeometry**** (kind_recording == RECORDING::SOLUTION_AND_MESH)) { /*--- Update geometry to get the influence on other geometry variables (normals, volume etc) ---*/ - geometry[iZone][iInst][MESH_0]->UpdateGeometry(geometry[iZone][iInst], config[iZone]); + CGeometry::UpdateGeometry(geometry[iZone][iInst], config[iZone]); CGeometry::ComputeWallDistance(config, geometry); } diff --git a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp index aa6f9471a01..be710ab4b2e 100644 --- a/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp +++ b/SU2_CFD/src/iteration/CDiscAdjHeatIteration.cpp @@ -212,7 +212,7 @@ void CDiscAdjHeatIteration::SetDependencies(CSolver***** solver, CGeometry**** g (kind_recording == RECORDING::SOLUTION_AND_MESH)) { /*--- Update geometry to get the influence on other geometry variables (normals, volume etc) ---*/ - geometries[MESH_0]->UpdateGeometry(geometries, config[iZone]); + CGeometry::UpdateGeometry(geometries, config[iZone]); CGeometry::ComputeWallDistance(config, geometry); } diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 077aa5b988f..5f053a80275 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -58,10 +58,17 @@ CFlowCompOutput::CFlowCompOutput(CConfig *config, unsigned short nDim) : CFlowOu requestedVolumeFields.emplace_back("COORDINATES"); requestedVolumeFields.emplace_back("SOLUTION"); requestedVolumeFields.emplace_back("PRIMITIVE"); - if (gridMovement) requestedVolumeFields.emplace_back("GRID_VELOCITY"); nRequestedVolumeFields = requestedVolumeFields.size(); } + if (gridMovement) { + auto notFound = requestedVolumeFields.end(); + if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) { + requestedVolumeFields.emplace_back("GRID_VELOCITY"); + nRequestedVolumeFields ++; + } + } + stringstream ss; ss << "Zone " << config->GetiZone() << " (Comp. Fluid)"; multiZoneHeaderString = ss.str(); diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index b1b23e74c42..229d61f866c 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -64,10 +64,17 @@ CFlowIncOutput::CFlowIncOutput(CConfig *config, unsigned short nDim) : CFlowOutp requestedVolumeFields.emplace_back("COORDINATES"); requestedVolumeFields.emplace_back("SOLUTION"); requestedVolumeFields.emplace_back("PRIMITIVE"); - if (gridMovement) requestedVolumeFields.emplace_back("GRID_VELOCITY"); nRequestedVolumeFields = requestedVolumeFields.size(); } + if (gridMovement) { + auto notFound = requestedVolumeFields.end(); + if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) { + requestedVolumeFields.emplace_back("GRID_VELOCITY"); + nRequestedVolumeFields ++; + } + } + stringstream ss; ss << "Zone " << config->GetiZone() << " (Incomp. Fluid)"; multiZoneHeaderString = ss.str(); @@ -436,7 +443,7 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("RES_VELOCITY-Y", "Residual_Velocity_y", "RESIDUAL", "Residual of the y-velocity component"); if (nDim == 3) AddVolumeOutput("RES_VELOCITY-Z", "Residual_Velocity_z", "RESIDUAL", "Residual of the z-velocity component"); - if (config->GetEnergy_Equation()) + if (config->GetEnergy_Equation()) AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); switch(config->GetKind_Turb_Model()){ diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index c3de5fbf3a5..291127f4e08 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -44,7 +44,7 @@ CNEMOCompOutput::CNEMOCompOutput(CConfig *config, unsigned short nDim) : CFlowOu turb_model = config->GetKind_Turb_Model(); lastInnerIter = curInnerIter; - gridMovement = config->GetGrid_Movement(); + gridMovement = config->GetDynamic_Grid(); nSpecies = config->GetnSpecies(); /*--- Set the default history fields if nothing is set in the config file ---*/ @@ -74,6 +74,14 @@ CNEMOCompOutput::CNEMOCompOutput(CConfig *config, unsigned short nDim) : CFlowOu nRequestedVolumeFields = requestedVolumeFields.size(); } + if (gridMovement) { + auto notFound = requestedVolumeFields.end(); + if (find(requestedVolumeFields.begin(), notFound, string("GRID_VELOCITY")) == notFound) { + requestedVolumeFields.emplace_back("GRID_VELOCITY"); + nRequestedVolumeFields ++; + } + } + stringstream ss; ss << "Zone " << config->GetiZone() << " (Comp. Fluid)"; multiZoneHeaderString = ss.str(); @@ -327,7 +335,7 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("MASSFRAC_" + std::to_string(iSpecies), "MassFrac_" + std::to_string(iSpecies), "AUXILIARY", "MassFrac_" + std::to_string(iSpecies)); // Grid velocity - if (config->GetDynamic_Grid()){ + if (gridMovement){ AddVolumeOutput("GRID_VELOCITY-X", "Grid_Velocity_x", "GRID_VELOCITY", "x-component of the grid velocity vector"); AddVolumeOutput("GRID_VELOCITY-Y", "Grid_Velocity_y", "GRID_VELOCITY", "y-component of the grid velocity vector"); if (nDim == 3 ) @@ -474,7 +482,7 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv break; } - if (config->GetDynamic_Grid()){ + if (gridMovement){ SetVolumeOutputValue("GRID_VELOCITY-X", iPoint, Node_Geo->GetGridVel(iPoint)[0]); SetVolumeOutputValue("GRID_VELOCITY-Y", iPoint, Node_Geo->GetGridVel(iPoint)[1]); if (nDim == 3) diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index 8a8d5ad1461..e8f68c9a3af 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -526,14 +526,14 @@ void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig UpdateGridCoord(geometry[MESH_0], config); /*--- Update the dual grid. ---*/ - UpdateDualGrid(geometry[MESH_0], config); + CGeometry::UpdateGeometry(geometry, config); /*--- Check for failed deformation (negative volumes). ---*/ SetMinMaxVolume(geometry[MESH_0], config, true); /*--- The Grid Velocity is only computed if the problem is time domain ---*/ if (time_domain && !config->GetFSI_Simulation()) - ComputeGridVelocity(geometry[MESH_0], config); + ComputeGridVelocity(geometry, config); } END_SU2_OMP_PARALLEL @@ -542,14 +542,9 @@ void CMeshSolver::DeformMesh(CGeometry **geometry, CNumerics **numerics, CConfig ComputeGridVelocity_FromBoundary(geometry, numerics, config); } - /*--- Update the multigrid structure. ---*/ - SU2_OMP_PARALLEL - UpdateMultiGrid(geometry, config); - END_SU2_OMP_PARALLEL - } -void CMeshSolver::UpdateGridCoord(CGeometry *geometry, CConfig *config){ +void CMeshSolver::UpdateGridCoord(CGeometry *geometry, const CConfig *config){ /*--- Update the grid coordinates using the solution of the linear system ---*/ @@ -575,17 +570,6 @@ void CMeshSolver::UpdateGridCoord(CGeometry *geometry, CConfig *config){ } -void CMeshSolver::UpdateDualGrid(CGeometry *geometry, CConfig *config){ - - /*--- After moving all nodes, update the dual mesh. Recompute the edges and - dual mesh control volumes in the domain and on the boundaries. ---*/ - - geometry->SetControlVolume(config, UPDATE); - geometry->SetBoundControlVolume(config, UPDATE); - geometry->SetMaxLength(config); - -} - void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumerics **numerics, CConfig *config){ if (config->GetnZone() == 1) @@ -621,20 +605,30 @@ void CMeshSolver::ComputeGridVelocity_FromBoundary(CGeometry **geometry, CNumeri /*--- Solve the linear system. ---*/ Solve_System(geometry[MESH_0], config); - SU2_OMP_PARALLEL_(for schedule(static,omp_chunk_size)) - for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) - for (unsigned short iDim = 0; iDim < nDim; iDim++) - geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, LinSysSol(iPoint,iDim)*invVelRef); + SU2_OMP_PARALLEL { + SU2_OMP_FOR_STAT(omp_chunk_size) + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) + for (unsigned short iDim = 0; iDim < nDim; iDim++) + geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, LinSysSol(iPoint,iDim)*invVelRef); + END_SU2_OMP_FOR + + for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGlevel-1], config); + } END_SU2_OMP_PARALLEL + } -void CMeshSolver::ComputeGridVelocity(CGeometry *geometry, CConfig *config){ +void CMeshSolver::ComputeGridVelocity(CGeometry **geometry, const CConfig *config) const { + + /*--- Compute the velocity of each node. ---*/ - /*--- Compute the velocity of each node in the domain of the current rank - (halo nodes are not computed as the grid velocity is later communicated). ---*/ + const bool firstOrder = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST; + const bool secondOrder = config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND; + const su2double invTimeStep = 1.0 / config->GetDelta_UnstTimeND(); SU2_OMP_FOR_STAT(omp_chunk_size) - for (unsigned long iPoint = 0; iPoint < nPointDomain; iPoint++) { + for (unsigned long iPoint = 0; iPoint < nPoint; iPoint++) { /*--- Coordinates of the current point at n+1, n, & n-1 time levels. ---*/ @@ -642,50 +636,23 @@ void CMeshSolver::ComputeGridVelocity(CGeometry *geometry, CConfig *config){ const su2double* Disp_n = nodes->GetSolution_time_n(iPoint); const su2double* Disp_nP1 = nodes->GetSolution(iPoint); - /*--- Unsteady time step ---*/ - - su2double TimeStep = config->GetDelta_UnstTimeND(); - - /*--- Compute mesh velocity with 1st or 2nd-order approximation. ---*/ + /*--- Compute mesh velocity for this point with 1st or 2nd-order approximation. ---*/ for (unsigned short iDim = 0; iDim < nDim; iDim++) { su2double GridVel = 0.0; + if (firstOrder) + GridVel = (Disp_nP1[iDim] - Disp_n[iDim]) * invTimeStep; + else if (secondOrder) + GridVel = (1.5*Disp_nP1[iDim] - 2.0*Disp_n[iDim] + 0.5*Disp_nM1[iDim]) * invTimeStep; - if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) - GridVel = ( Disp_nP1[iDim] - Disp_n[iDim] ) / TimeStep; - if (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND) - GridVel = ( 3.0*Disp_nP1[iDim] - 4.0*Disp_n[iDim] + - 1.0*Disp_nM1[iDim] ) / (2.0*TimeStep); - - /*--- Store grid velocity for this point ---*/ - - geometry->nodes->SetGridVel(iPoint, iDim, GridVel); - + geometry[MESH_0]->nodes->SetGridVel(iPoint, iDim, GridVel); } } END_SU2_OMP_FOR - /*--- The velocity was computed for nPointDomain, now we communicate it. ---*/ - geometry->InitiateComms(geometry, config, GRID_VELOCITY); - geometry->CompleteComms(geometry, config, GRID_VELOCITY); - -} - -void CMeshSolver::UpdateMultiGrid(CGeometry **geometry, CConfig *config) const{ - - /*--- Update the multigrid structure after moving the finest grid, - including computing the grid velocities on the coarser levels - when the problem is solved in unsteady conditions. ---*/ - - for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) { - const auto iMGfine = iMGlevel-1; - geometry[iMGlevel]->SetControlVolume(config, geometry[iMGfine], UPDATE); - geometry[iMGlevel]->SetBoundControlVolume(config, geometry[iMGfine],UPDATE); - geometry[iMGlevel]->SetCoord(geometry[iMGfine]); - if (time_domain) - geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGfine], config); - } + for (auto iMGlevel = 1u; iMGlevel <= config->GetnMGLevels(); iMGlevel++) + geometry[iMGlevel]->SetRestricted_GridVelocity(geometry[iMGlevel-1], config); } @@ -857,10 +824,6 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * solver[MESH_0][MESH_SOL]->InitiateComms(geometry[MESH_0], config, SOLUTION); solver[MESH_0][MESH_SOL]->CompleteComms(geometry[MESH_0], config, SOLUTION); - /*--- Communicate the new coordinates at the halos ---*/ - geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, COORDINATES); - geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, COORDINATES); - /*--- Init the linear system solution. ---*/ for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for (unsigned short iDim = 0; iDim < nDim; ++iDim) { @@ -868,23 +831,14 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * } } - /*--- Recompute the edges and dual mesh control volumes in the - domain and on the boundaries. ---*/ - UpdateDualGrid(geometry[MESH_0], config); - /*--- For time-domain problems, we need to compute the grid velocities. ---*/ if (time_domain && !config->GetFSI_Simulation()) { /*--- Update the old geometry (coordinates n and n-1) ---*/ - Restart_OldGeometry(geometry[MESH_0], config); - /*--- Once Displacement_n and Displacement_n1 are filled, - we can compute the Grid Velocity ---*/ - ComputeGridVelocity(geometry[MESH_0], config); - } + RestartOldGeometry(geometry[MESH_0], config); - /*--- Update the multigrid structure after setting up the finest grid, - including computing the grid velocities on the coarser levels - when the problem is unsteady. ---*/ - UpdateMultiGrid(geometry, config); + /*--- Once Displacement_n and Displacement_n1 are filled we can compute the Grid Velocity ---*/ + ComputeGridVelocity(geometry, config); + } /*--- Store the boundary displacements at the Bound_Disp variable. ---*/ @@ -911,7 +865,7 @@ void CMeshSolver::LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig * } -void CMeshSolver::Restart_OldGeometry(CGeometry *geometry, CConfig *config) { +void CMeshSolver::RestartOldGeometry(CGeometry *geometry, const CConfig *config) { /*--- This function is intended for dual time simulations ---*/ From d2fbc1357df49cc8c5c38303365d7afa4b021c6e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 24 May 2021 15:38:14 +0100 Subject: [PATCH 133/192] fix for turbo --- Common/src/geometry/CGeometry.cpp | 4 ---- SU2_CFD/include/solvers/CFVMFlowSolverBase.inl | 16 +++++++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index d4aab89d4c0..a7b1fe7b9fa 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -2489,10 +2489,6 @@ void CGeometry::UpdateGeometry(CGeometry **geometry_container, CConfig *config) geometry_container[MESH_0]->InitiateComms(geometry_container[MESH_0], config, COORDINATES); geometry_container[MESH_0]->CompleteComms(geometry_container[MESH_0], config, COORDINATES); - if (config->GetDynamic_Grid()){ - geometry_container[MESH_0]->InitiateComms(geometry_container[MESH_0], config, GRID_VELOCITY); - geometry_container[MESH_0]->CompleteComms(geometry_container[MESH_0], config, GRID_VELOCITY); - } geometry_container[MESH_0]->SetControlVolume(config, UPDATE); geometry_container[MESH_0]->SetBoundControlVolume(config, UPDATE); diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 374a6ec3917..67c1366fb7d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -849,13 +849,19 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** /*--- Compute the grid velocities on the coarser levels. ---*/ if (iMesh) geometry[iMesh]->SetRestricted_GridVelocity(geometry[iMesh-1], config); + else { + geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, GRID_VELOCITY); + geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, GRID_VELOCITY); + } - geometry[iMesh]->nodes->SetVolume_n(); - geometry[iMesh]->nodes->SetVolume_nM1(); + if (config->GetTime_Marching() != TIME_MARCHING::STEADY) { + geometry[iMesh]->nodes->SetVolume_n(); + geometry[iMesh]->nodes->SetVolume_nM1(); - if (config->GetGrid_Movement()) { - geometry[iMesh]->nodes->SetCoord_n(); - geometry[iMesh]->nodes->SetCoord_n1(); + if (config->GetGrid_Movement()) { + geometry[iMesh]->nodes->SetCoord_n(); + geometry[iMesh]->nodes->SetCoord_n1(); + } } } } From a0fb3d54cf9a43e75983a3aa951a2c7a1f8e4ac8 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 17:27:07 +0200 Subject: [PATCH 134/192] const reference in parameter packs ARGS... args -> ARGS const&... args --- Common/include/toolboxes/ndflattener.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index b67c2f3adb8..a29b31efab6 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -383,7 +383,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ * */ template - NdFlattener(ARGS... args) { + NdFlattener(ARGS const&... args) { initialize_or_refresh(args...); } @@ -395,7 +395,7 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ * recollected under the assumption that the indices arrays did not change. */ template - void initialize_or_refresh(ARGS... args){ + void initialize_or_refresh(ARGS const&... args){ if( initialized() ){ refresh(args...); } else { @@ -686,12 +686,12 @@ class NdFlattener<1, Data_t_, _Index> { NdFlattener(void) {} template - NdFlattener(ARGS... args) { + NdFlattener(ARGS const&... args) { initialize_or_refresh(args...); } template - void initialize_or_refresh(ARGS... args){ + void initialize_or_refresh(ARGS const&... args){ if( initialized() ){ refresh(args...); } else { From 12890b9df19adb2304e59e1fedac2a4f61533522 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 17:41:52 +0200 Subject: [PATCH 135/192] replace parameter pack in IndexAccumulator constructor nd should be given as a reference (not value), but not generally a const reference. offset and size should be const references however. --- Common/include/toolboxes/ndflattener.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 2329cf46fbc..51ebc1e7c62 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -207,7 +207,8 @@ namespace helpers { using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; - template IndexAccumulator(ARGS... args): Base(args...) {} + IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size): + Base(nd, offset, size) {} /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. */ @@ -245,7 +246,8 @@ namespace helpers { using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; - template IndexAccumulator(ARGS... args): Base(args...) {} + IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size): + Base(nd, offset,size) {} /*! Return type of operator[]. * \details Data type of NdFlattener, but do also preserve constness. From 25e58e60691b60e6e0a70aa6843044db6ae4ecb7 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 17:46:58 +0200 Subject: [PATCH 136/192] continue f60ca15d --- Common/include/toolboxes/ndflattener.hpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 51ebc1e7c62..f4c42b7c4c1 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -148,7 +148,7 @@ */ -template +template class NdFlattener; namespace helpers { @@ -313,13 +313,13 @@ Get_Nd_MPI_Env() { */ -template -class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ +template +class NdFlattener: public NdFlattener{ public: - static constexpr size_t K = _K; + static constexpr size_t K = K_; using Data_t = Data_t_; - using Index_t = Index_; + using Index_t = Index_t_; using Base = NdFlattener; using CurrentLayer = NdFlattener; @@ -653,12 +653,12 @@ class NdFlattener: public NdFlattener<_K-1,Data_t_,Index_>{ } }; -template -class NdFlattener<1, Data_t_, _Index> { +template +class NdFlattener<1, Data_t_, Index_t_> { public: static constexpr size_t K = 1; using Data_t = Data_t_; - using Index_t = _Index; + using Index_t = Index_t_; using CurrentLayer = NdFlattener<1, Data_t, Index_t>; using LowestLayer = CurrentLayer; From 319e51e67a11aa3dbecdc0b19b1e396e98cc79df Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 24 May 2021 17:22:09 +0100 Subject: [PATCH 137/192] fix for moving grid disc adj --- .../include/solvers/CFVMFlowSolverBase.inl | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 67c1366fb7d..5102b521a13 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -853,16 +853,6 @@ void CFVMFlowSolverBase::LoadRestart_impl(CGeometry **geometry, CSolver ** geometry[MESH_0]->InitiateComms(geometry[MESH_0], config, GRID_VELOCITY); geometry[MESH_0]->CompleteComms(geometry[MESH_0], config, GRID_VELOCITY); } - - if (config->GetTime_Marching() != TIME_MARCHING::STEADY) { - geometry[iMesh]->nodes->SetVolume_n(); - geometry[iMesh]->nodes->SetVolume_nM1(); - - if (config->GetGrid_Movement()) { - geometry[iMesh]->nodes->SetCoord_n(); - geometry[iMesh]->nodes->SetCoord_n1(); - } - } } } } @@ -998,6 +988,16 @@ void CFVMFlowSolverBase::PushSolutionBackInTime(unsigned long TimeIter, bo solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n(); solver_container[iMesh][TURB_SOL]->GetNodes()->Set_Solution_time_n1(); } + + if (dynamic_grid) { + geometry[iMesh]->nodes->SetVolume_n(); + geometry[iMesh]->nodes->SetVolume_nM1(); + } + + if (config->GetGrid_Movement()) { + geometry[iMesh]->nodes->SetCoord_n(); + geometry[iMesh]->nodes->SetCoord_n1(); + } } if (restart && (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND)) { From 0cfcf1bbbc668c31aca523888547ce9bb761f343 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 18:23:15 +0200 Subject: [PATCH 138/192] Nd_MPI_Environment in main scope, with constructor instead of Get_Nd_MPI_Env 1D test modified to check communication of data type unsigned long --- Common/include/toolboxes/ndflattener.hpp | 62 ++++++++++--------- Common/src/geometry/CGeometry.cpp | 2 +- .../Common/toolboxes/ndflattener_tests.cpp | 28 ++++----- 3 files changed, 48 insertions(+), 44 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index f4c42b7c4c1..e85b0221a26 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -151,16 +151,36 @@ template class NdFlattener; -namespace helpers { - template - struct NdFlattener_MPI_Environment { - MPI_Allgatherv_t MPI_Allgatherv_fun; - MPI_Datatype_t mpi_data; - MPI_Datatype_t mpi_index; - MPI_Communicator_t comm; - int rank; int size; - }; +/*! \struct Nd_MPI_Environment + * \brief Contains information for the collective communication of NdFlatteners. + * + * The default arguments in the constructor are chosen in a sensible way: + * - To communicate su2double data, just call ND_MPI_Environment(). + * - To communicate unsigned long data, call Nd_MPI_Environment(MPI_UNSIGNED_LONG). + */ +struct Nd_MPI_Environment { + using MPI_Allgather_t = decltype(&(SU2_MPI::Allgather)); + using MPI_Allgatherv_t = decltype(&(SU2_MPI::Allgatherv)); + using MPI_Datatype_t = decltype(MPI_INT); + using MPI_Communicator_t = typename SU2_MPI::Comm; + MPI_Datatype_t mpi_data; + MPI_Datatype_t mpi_index; + MPI_Communicator_t comm; + MPI_Allgather_t MPI_Allgather_fun; + MPI_Allgatherv_t MPI_Allgatherv_fun; + int rank; int size; + Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, + MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, + MPI_Communicator_t comm = SU2_MPI::GetComm(), + MPI_Allgather_t MPI_Allgather_fun = &(SU2_MPI::Allgather), + MPI_Allgatherv_t MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv)): + mpi_data(mpi_data), mpi_index(mpi_index), comm(comm), + MPI_Allgather_fun(MPI_Allgather_fun), MPI_Allgatherv_fun(MPI_Allgatherv_fun), + rank(SU2_MPI::GetRank()), size(SU2_MPI::GetSize()) + {} +}; +namespace helpers { /*! \class IndexAccumulator * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. * \details Derived from IndexAccumulator_Base, specifying the operator[] method: @@ -284,18 +304,6 @@ namespace helpers { } // namespace helpers -inline helpers::NdFlattener_MPI_Environment -Get_Nd_MPI_Env() { - helpers::NdFlattener_MPI_Environment mpi_env; - mpi_env.MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv); - mpi_env.mpi_index = MPI_UNSIGNED_LONG; - mpi_env.mpi_data = MPI_DOUBLE; - mpi_env.comm=SU2_MPI::GetComm(); - SU2_MPI::Comm_rank(mpi_env.comm, &(mpi_env.rank)); - SU2_MPI::Comm_size(mpi_env.comm, &(mpi_env.size)); - return mpi_env; -} - /*! * \class NdFlattener * \brief Serialize pointer-to-pointer-... array into one 1D array, keeping track @@ -581,8 +589,7 @@ class NdFlattener: public NdFlattener{ * \param[in] displs - {0,1,...,size-1} * \param[in] ones - {1,1,...,1} */ - template - void count_g(MPI_Environment_type const& mpi_env, + void count_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, CurrentLayer const& local_version, int const* displs, int const* ones ) @@ -604,8 +611,7 @@ class NdFlattener: public NdFlattener{ * \param[in] Nodes_all - [k][r] is the number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be sent to the other processes */ - template - void set_g(MPI_Environment_type const& mpi_env, + void set_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, CurrentLayer const& local_version ) { @@ -751,8 +757,7 @@ class NdFlattener<1, Data_t_, Index_t_> { /*=== Construct with Allgatherv ===*/ protected: - template - void count_g(MPI_Environment_type const& mpi_env, + void count_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, CurrentLayer const& local_version, int const* displs, int const* ones) @@ -767,8 +772,7 @@ class NdFlattener<1, Data_t_, Index_t_> { } } - template - void set_g(MPI_Environment_type const& mpi_env, + void set_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, CurrentLayer const& local_version ) { diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 883f385f889..8d8792bb369 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3955,7 +3955,7 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo }); NdFlattener<2> roughness_local(roughness_f); // [rank][iZone][iMarker] -> roughness - NdFlattener<3> roughness_global(Get_Nd_MPI_Env(), roughness_local); + NdFlattener<3> roughness_global(Nd_MPI_Environment(), roughness_local); // use it to update roughnesses for(int jZone=0; jZoneGetnRoughWall()>0){ diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index af60fa26d23..9ec4440e8e6 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -68,7 +68,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ nd2[0].data()[1] = 1.7; /*-- gather flattening structures of all processes --*/ - NdFlattener<3> nd3(Get_Nd_MPI_Env(), nd2); + NdFlattener<3> nd3(Nd_MPI_Environment(), nd2); /*-- Check gathered structure, non-const look-up. --*/ REQUIRE( nd3.size() == size ); @@ -98,7 +98,7 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ /*-- Reread modified A and check again. --*/ nd2.initialize_or_refresh(f); - nd3.refresh(Get_Nd_MPI_Env(), nd2); + nd3.refresh(Nd_MPI_Environment(), nd2); REQUIRE( nd3.size() == size ); for(int r=0; r a1( + /*-- Check 1D functionality, communicating unsigned long data. --*/ + NdFlattener<1,unsigned long> a1( std::make_pair( (size_t)(3+rank), [rank,A](int i) { - return A[1][i]; + return (unsigned long)(2+rank+i); }) ); - const NdFlattener<1>& a1_const = a1; + const NdFlattener<1, unsigned long>& a1_const = a1; REQUIRE( a1.size() == 3 + rank ); for(int i=0; i<3+rank; i++){ - REQUIRE( a1[i] == 2.0 + rank + i ); - REQUIRE( a1_const[i] == 2.0 + rank + i ); + REQUIRE( a1[i] == 2 + rank + i ); + REQUIRE( a1_const[i] == 2 + rank + i ); } - a1[0] = -1.0; - REQUIRE( a1_const.data()[0] == -1.0 ); - a1.data()[0] = 2.0 + rank; - REQUIRE( a1_const[0] == 2.0 + rank ); - const NdFlattener<2> a2_const(Get_Nd_MPI_Env(), a1); + a1[0] = 1; + REQUIRE( a1_const.data()[0] == 1 ); + a1.data()[0] = 2 + rank; + REQUIRE( a1_const[0] == 2 + rank ); + const NdFlattener<2, unsigned long> a2_const(Nd_MPI_Environment(MPI_UNSIGNED_LONG), a1); REQUIRE( a2_const.size() == size ); for(int r=0; r Date: Mon, 24 May 2021 18:29:48 +0200 Subject: [PATCH 139/192] Look-up for IndexAccumulator is always a const method Whether the returned reference or pointer is const is determined by the NdFlattener type template argument. --- Common/include/toolboxes/ndflattener.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index e85b0221a26..b962a147a18 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -246,7 +246,7 @@ namespace helpers { * previous indices. * \param[in] i - Index. */ - LookupType operator[] (Index_t i) { + LookupType operator[] (Index_t i) const { assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); @@ -283,7 +283,7 @@ namespace helpers { /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. */ - LookupType& operator[] (Index_t i) { + LookupType& operator[] (Index_t i) const { assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); @@ -297,7 +297,7 @@ namespace helpers { * block. If this IndexAccumulator was generated from a non-const NdFlattener, the * pointer is non-const, otherwise it is const. */ - LookupType* data() { + LookupType* data() const { return &(this->operator[](0)); } }; From 9d13918ce9c3de049ec92392877995e5ff17c503 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 18:39:36 +0200 Subject: [PATCH 140/192] get rid of ones and displs by using MPI_Allgather instead of MPI_Allgatherv --- Common/include/toolboxes/ndflattener.hpp | 32 ++++++------------------ 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index b962a147a18..023890dc5e4 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -526,14 +526,10 @@ class NdFlattener: public NdFlattener{ for(size_t k=0; k{ delete[] Nodes_all[k]; } delete[] Nodes_all; - delete[] displs; - delete[] ones; } /*! \brief Refresh the data by MPI collective communication. @@ -566,18 +560,10 @@ class NdFlattener: public NdFlattener{ Base const& local_version ) { Index_t* Nodes_all_0 = nullptr; - int* displs = new int[mpi_env.size]; // {0, 1, ..., size-1} - int* ones = new int[mpi_env.size]; // {1,1, ...} - for(int r=0; r{ * \param[in] mpi_env - MPI environment for communication * \param[out] Nodes_all - [k][r] is set to number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be send to the other processes - * \param[in] displs - {0,1,...,size-1} - * \param[in] ones - {1,1,...,1} */ void count_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, - CurrentLayer const& local_version, - int const* displs, int const* ones ) + CurrentLayer const& local_version ) { assert( Nodes_all[K-1]==nullptr); Nodes_all[K-1] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], 1, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r { protected: void count_g(Nd_MPI_Environment const& mpi_env, Index_t** Nodes_all, - CurrentLayer const& local_version, - int const* displs, int const* ones) + CurrentLayer const& local_version ) { assert( Nodes_all[0]==nullptr); Nodes_all[0] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgatherv_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[0], ones, displs, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[0], 1, mpi_env.mpi_index, mpi_env.comm ); for(int r=0; r Date: Mon, 24 May 2021 18:50:48 +0200 Subject: [PATCH 141/192] use std::vector for Nodes_all_K_as_int, Nodes_all_k_cumulated --- Common/include/toolboxes/ndflattener.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 023890dc5e4..75124a8d28c 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -599,8 +599,8 @@ class NdFlattener: public NdFlattener{ CurrentLayer const& local_version ) { - int* Nodes_all_K_as_int = new int[mpi_env.size]; - int* Nodes_all_k_cumulated = new int[mpi_env.size+1]; // [r] is number of nodes in the current layer, summed over all processes with rank below r + std::vector Nodes_all_K_as_int(mpi_env.size); + std::vector Nodes_all_k_cumulated(mpi_env.size+1); // [r] is number of nodes in the current layer, summed over all processes with rank below r // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the last element of indices, // which is the local nNodes of the layer below. Note that MPI needs indices of type 'int'. Nodes_all_k_cumulated[0] = 1; @@ -608,7 +608,9 @@ class NdFlattener: public NdFlattener{ Nodes_all_k_cumulated[r+1] = Nodes_all_k_cumulated[r] + Nodes_all[K-1][r]; Nodes_all_K_as_int[r] = Nodes_all[K-1][r]; } - mpi_env.MPI_Allgatherv_fun( local_version.indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, indices.data(), Nodes_all_K_as_int, Nodes_all_k_cumulated, mpi_env.mpi_index, mpi_env.comm ); + mpi_env.MPI_Allgatherv_fun( local_version.indices.data()+1, Nodes_all[K-1][mpi_env.rank], mpi_env.mpi_index, + indices.data(), Nodes_all_K_as_int.data(), Nodes_all_k_cumulated.data(), mpi_env.mpi_index, + mpi_env.comm ); // shift indices for(int r=1; r{ indices[ i ] += shift; } } - delete[] Nodes_all_K_as_int; - delete[] Nodes_all_k_cumulated; Base::set_g(mpi_env, Nodes_all, local_version); } @@ -760,17 +760,17 @@ class NdFlattener<1, Data_t_, Index_t_> { { - int* Nodes_all_0_as_int = new int[mpi_env.size]; - int* Nodes_all_0_cumulated = new int[mpi_env.size+1]; + std::vector Nodes_all_0_as_int(mpi_env.size); + std::vector Nodes_all_0_cumulated(mpi_env.size+1); Nodes_all_0_cumulated[0] = 0; for(int r=0; r Date: Mon, 24 May 2021 19:10:37 +0200 Subject: [PATCH 142/192] use su2matrix for Nodes_all --- Common/include/toolboxes/ndflattener.hpp | 32 ++++++++---------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 75124a8d28c..14a13da06f4 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -33,6 +33,7 @@ #include #include #include "../parallelization/mpi_structure.hpp" +#include "../containers/C2DContainer.hpp" // --- Usage /*! \page ndflattener_usage Usage of NdFlattener @@ -522,11 +523,8 @@ class NdFlattener: public NdFlattener{ MPI_Environment_type const& mpi_env, Base const& local_version ) { - Index_t** Nodes_all = new Index_t*[K]; // [k][r] is number of all nodes in layer (k+1), rank r in the new structure - for(size_t k=0; k Nodes_all(K,mpi_env.size); // [k][r] is number of all nodes in layer (k+1), rank r in the new structure + for(int r=0; r{ } Base::set_g(mpi_env, Nodes_all, local_version); - for(size_t k=0; k{ MPI_Environment_type const& mpi_env, Base const& local_version ) { - Index_t* Nodes_all_0 = nullptr; - LowestLayer::count_g(mpi_env, &Nodes_all_0, local_version); - LowestLayer::set_g(mpi_env, &Nodes_all_0, local_version); - - delete[] Nodes_all_0; // allocated by count_g + su2matrix Nodes_all_0(1,mpi_env.size); + LowestLayer::count_g(mpi_env, Nodes_all_0, local_version); + LowestLayer::set_g(mpi_env, Nodes_all_0, local_version); } protected: @@ -574,11 +566,9 @@ class NdFlattener: public NdFlattener{ * \param[in] local_version - local instance to be send to the other processes */ void count_g(Nd_MPI_Environment const& mpi_env, - Index_t** Nodes_all, + su2matrix& Nodes_all, CurrentLayer const& local_version ) { - assert( Nodes_all[K-1]==nullptr); - Nodes_all[K-1] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], 1, mpi_env.mpi_index, mpi_env.comm ); @@ -595,7 +585,7 @@ class NdFlattener: public NdFlattener{ * \param[in] local_version - local instance to be sent to the other processes */ void set_g(Nd_MPI_Environment const& mpi_env, - Index_t** Nodes_all, + su2matrix const& Nodes_all, CurrentLayer const& local_version ) { @@ -741,11 +731,9 @@ class NdFlattener<1, Data_t_, Index_t_> { /*=== Construct with Allgatherv ===*/ protected: void count_g(Nd_MPI_Environment const& mpi_env, - Index_t** Nodes_all, + su2matrix& Nodes_all, CurrentLayer const& local_version ) { - assert( Nodes_all[0]==nullptr); - Nodes_all[0] = new Index_t[mpi_env.size]; nNodes = 0; // gather numbers of nodes in the current layer from all processes mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[0], 1, mpi_env.mpi_index, mpi_env.comm ); @@ -755,7 +743,7 @@ class NdFlattener<1, Data_t_, Index_t_> { } void set_g(Nd_MPI_Environment const& mpi_env, - Index_t** Nodes_all, + su2matrix const& Nodes_all, CurrentLayer const& local_version ) { From fd29fe9832072a041c0d7ceaf951bf6f9bb5c410 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 19:18:08 +0200 Subject: [PATCH 143/192] update comments to reflect 0cfcf1bb --- Common/include/toolboxes/ndflattener.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 14a13da06f4..69c747c0349 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -66,12 +66,13 @@ * # Form the global NdFlattener * by "collective communication" like this: * - * NdFlattener<3> nd_global(Get_Nd_MPI_Env(), &nd_local); + * NdFlattener<3> nd_global(Nd_MPI_Environment(), &nd_local); * * nd_global's first index is the rank, then the indices of nd_local follow. - * Get_Nd_MPI_Env returns a helpers:NdFlattener_MPI_Environment struct suitable to gather su2double data over - * unsigned long indices. If you deviate from these default datatypes, you need to define the MPI environment - * structure yourself. + * + * The struct Nd_MPI_Environment contains the relevant information about the parallel environment. The default + * values are suitable to communicate su2double data. In order to communicate data of another MPI datatype, + * use e.g. Nd_MPI_Environment(MPI_UNSIGNED_LONG). * * You can also construct an NdFlattener without any arguments, and use NdFlattener::initialize(mpi_env, &nd_local). * @@ -80,7 +81,7 @@ * them with the call * * nd_local.refresh(f_local); // , or - * nd_global(Get_Nd_MPI_Env(), &nd_local); // respectively. + * nd_global(Nd_MPI_Environment(), &nd_local); // respectively. * * An NdFlattener constructed or initialized from a "recursive function" or "collective communication" must be * refreshed in the same way. From f376c805875332545f63d2d058e7c5e85d390a7c Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Mon, 24 May 2021 19:35:57 +0200 Subject: [PATCH 144/192] clang-format -i Common/include/toolboxes/ndflattener.hpp --- Common/include/toolboxes/ndflattener.hpp | 567 ++++++++++------------- 1 file changed, 256 insertions(+), 311 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 69c747c0349..bc25247f3e3 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -27,13 +27,14 @@ #pragma once -#include -#include #include +#include #include +#include #include -#include "../parallelization/mpi_structure.hpp" + #include "../containers/C2DContainer.hpp" +#include "../parallelization/mpi_structure.hpp" // --- Usage /*! \page ndflattener_usage Usage of NdFlattener @@ -149,8 +150,7 @@ * allocate it and fill it with data during the second iteration. */ - -template +template class NdFlattener; /*! \struct Nd_MPI_Environment @@ -170,141 +170,129 @@ struct Nd_MPI_Environment { MPI_Communicator_t comm; MPI_Allgather_t MPI_Allgather_fun; MPI_Allgatherv_t MPI_Allgatherv_fun; - int rank; int size; - Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, - MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, + int rank; + int size; + Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, MPI_Communicator_t comm = SU2_MPI::GetComm(), MPI_Allgather_t MPI_Allgather_fun = &(SU2_MPI::Allgather), - MPI_Allgatherv_t MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv)): - mpi_data(mpi_data), mpi_index(mpi_index), comm(comm), - MPI_Allgather_fun(MPI_Allgather_fun), MPI_Allgatherv_fun(MPI_Allgatherv_fun), - rank(SU2_MPI::GetRank()), size(SU2_MPI::GetSize()) - {} + MPI_Allgatherv_t MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv)) + : mpi_data(mpi_data), + mpi_index(mpi_index), + comm(comm), + MPI_Allgather_fun(MPI_Allgather_fun), + MPI_Allgatherv_fun(MPI_Allgatherv_fun), + rank(SU2_MPI::GetRank()), + size(SU2_MPI::GetSize()) {} }; namespace helpers { - /*! \class IndexAccumulator - * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. - * \details Derived from IndexAccumulator_Base, specifying the operator[] method: - * - For N==1, the structure has already read all indices but one. So after this method has read the last - * index, return a reference to the data. - * - The case N==2 is much like the case N>3 but an additional function data() should be provided. - * - For N>3, more indices have to be read, return an IndexAccumulator. - * \tparam N - Number of missing parameters - * \tparam Nd_t - Type of the accessed NdFlattener, should be NdFlattener - * \tparam Check - if true, raise error if index to operator[] is not in range +/*! \class IndexAccumulator + * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. + * \details Derived from IndexAccumulator_Base, specifying the operator[] method: + * - For N==1, the structure has already read all indices but one. So after this method has read the last + * index, return a reference to the data. + * - The case N==2 is much like the case N>3 but an additional function data() should be provided. + * - For N>3, more indices have to be read, return an IndexAccumulator. + * \tparam N - Number of missing parameters + * \tparam Nd_t - Type of the accessed NdFlattener, should be NdFlattener + * \tparam Check - if true, raise error if index to operator[] is not in range + */ +/*! \class IndexAccumulator_Base + * \brief Parent class of IndexAccumulator. + * \details IndexAccumulator provides the operator[] method. + */ +template +class IndexAccumulator_Base { + public: + static constexpr size_t N = N_; + using Nd_t = Nd_t_; + using Index_t = typename Nd_t::Index_t; + + protected: + Nd_t& nd; /*!< \brief The accessed NdFlattener. */ + const Index_t offset; /*!< \brief Index in the currently accessed layer. */ + const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ + + IndexAccumulator_Base(Nd_t& nd, Index_t offset, Index_t size) : nd(nd), offset(offset), size_(size) {} + + /*! \brief Return exclusive upper bound for next index. */ - /*! \class IndexAccumulator_Base - * \brief Parent class of IndexAccumulator. - * \details IndexAccumulator provides the operator[] method. + Index_t size() const { return size_; } +}; + +template +class IndexAccumulator : public IndexAccumulator_Base { + public: + using Base = IndexAccumulator_Base; + static constexpr size_t N = N_; + using Nd_t = Nd_t_; + using Index_t = typename Nd_t::Index_t; + + IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size) : Base(nd, offset, size) {} + + /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. + */ + using Nd_Base_t = su2conditional_t::value, const typename Nd_t::Base, typename Nd_t::Base>; + /*! Return type of operator[]. */ + using LookupType = IndexAccumulator; + using Base::nd; + using Base::offset; + using Base::size; + + /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and + * previous indices. + * \param[in] i - Index. */ - template - class IndexAccumulator_Base { - public: - static constexpr size_t N = N_; - using Nd_t = Nd_t_; - using Index_t = typename Nd_t::Index_t; - - protected: - Nd_t& nd; /*!< \brief The accessed NdFlattener. */ - const Index_t offset; /*!< \brief Index in the currently accessed layer. */ - const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ - - IndexAccumulator_Base(Nd_t& nd, Index_t offset, Index_t size): - nd(nd), offset(offset), size_(size) {} - - /*! \brief Return exclusive upper bound for next index. - */ - Index_t size() const { - return size_; + LookupType operator[](Index_t i) const { + assert(i < size()); + if (Check) { + if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } + const Index_t new_offset = nd.GetIndices()[offset + i]; + const Index_t new_size = nd.GetIndices()[offset + i + 1] - new_offset; + return LookupType(nd, new_offset, new_size); + } +}; - }; - - template - class IndexAccumulator : public IndexAccumulator_Base{ - public: - using Base = IndexAccumulator_Base; - static constexpr size_t N = N_; - using Nd_t = Nd_t_; - using Index_t = typename Nd_t::Index_t; - - IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size): - Base(nd, offset, size) {} - - /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. - */ - using Nd_Base_t = su2conditional_t< - std::is_const::value, - const typename Nd_t::Base, - typename Nd_t::Base - >; - /*! Return type of operator[]. */ - using LookupType = IndexAccumulator; - using Base::size; - using Base::nd; using Base::offset; - - /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and - * previous indices. - * \param[in] i - Index. - */ - LookupType operator[] (Index_t i) const { - assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } - const Index_t new_offset = nd.GetIndices()[offset+i]; - const Index_t new_size = nd.GetIndices()[offset+i+1] - new_offset; - return LookupType(nd,new_offset,new_size); - } +template +class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> { + public: + using Base = IndexAccumulator_Base<1, Nd_t_>; + static constexpr size_t N = 1; + using Nd_t = Nd_t_; + using Index_t = typename Nd_t::Index_t; - }; - - template - class IndexAccumulator<1,Nd_t_,Check> : public IndexAccumulator_Base<1,Nd_t_>{ - public: - using Base = IndexAccumulator_Base<1,Nd_t_>; - static constexpr size_t N = 1; - using Nd_t = Nd_t_; - using Index_t = typename Nd_t::Index_t; - - IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size): - Base(nd, offset,size) {} - - /*! Return type of operator[]. - * \details Data type of NdFlattener, but do also preserve constness. - */ - using LookupType = su2conditional_t< - std::is_const::value, - const typename Nd_t::Data_t, - typename Nd_t::Data_t - >; - using Base::size; - using Base::nd; using Base::offset; - - /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. - * \param[in] i - Last index. - */ - LookupType& operator[] (Index_t i) const { - assert(i=size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } - return nd.GetData() [ offset+i ]; - } + IndexAccumulator(Nd_t& nd, Index_t offset, Index_t size) : Base(nd, offset, size) {} - /*! \brief Return (possibly const) pointer to data. - * \details If all indices except the last one are fixed, the corresponding data - * is stored contiguously. Return a pointer to the beginning of the - * block. If this IndexAccumulator was generated from a non-const NdFlattener, the - * pointer is non-const, otherwise it is const. - */ - LookupType* data() const { - return &(this->operator[](0)); + /*! Return type of operator[]. + * \details Data type of NdFlattener, but do also preserve constness. + */ + using LookupType = su2conditional_t::value, const typename Nd_t::Data_t, typename Nd_t::Data_t>; + using Base::nd; + using Base::offset; + using Base::size; + + /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. + * \param[in] i - Last index. + */ + LookupType& operator[](Index_t i) const { + assert(i < size()); + if (Check) { + if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } - }; + return nd.GetData()[offset + i]; + } + + /*! \brief Return (possibly const) pointer to data. + * \details If all indices except the last one are fixed, the corresponding data + * is stored contiguously. Return a pointer to the beginning of the + * block. If this IndexAccumulator was generated from a non-const NdFlattener, the + * pointer is non-const, otherwise it is const. + */ + LookupType* data() const { return &(this->operator[](0)); } +}; -} // namespace helpers +} // namespace helpers /*! * \class NdFlattener @@ -313,7 +301,7 @@ namespace helpers { * * The pointer-to-pointer-... array can be provided by a nested lambda function * ('recursive function') or by gathering such arrays from MPI processes ('collective - * communication'). After initializing an NdFlattener with either of these data, + * communication'). After initializing an NdFlattener with either of these data, * it can be refreshed in the same way after the the pointer-to-pointer-... array's * values (but not its structure) have changed. * @@ -322,41 +310,39 @@ namespace helpers { * \tparam Index - Type of index */ - -template -class NdFlattener: public NdFlattener{ - -public: +template +class NdFlattener : public NdFlattener { + public: static constexpr size_t K = K_; using Data_t = Data_t_; using Index_t = Index_t_; - using Base = NdFlattener; - using CurrentLayer = NdFlattener; - using LowestLayer = typename Base::LowestLayer; // the K=1 class + using Base = NdFlattener; + using CurrentLayer = NdFlattener; + using LowestLayer = typename Base::LowestLayer; // the K=1 class -private: + private: /*! \brief Number of nodes in this layer. - * + * * For the layer K=1, nNodes will be the number of data points. * For a layer K>1, nNodes will be the number of sublists. */ - Index_t nNodes=0; + Index_t nNodes = 0; /*! \brief Iterator used at construction, runs from 0 to (nNodes-1). */ - Index_t iNode=0; + Index_t iNode = 0; /*! \brief Indices in the lower layer's indices or data array */ std::vector indices; /*=== Getters ===*/ -public: - Index_t* GetIndices() {return indices.data();} - const Index_t* GetIndices() const {return indices.data();} + public: + Index_t* GetIndices() { return indices.data(); } + const Index_t* GetIndices() const { return indices.data(); } /*=== Outputting ===*/ -public: + public: /*! \brief Write in Python-list style. * * Like this: [[1, 2], [10, 20, 30]] @@ -366,7 +352,7 @@ class NdFlattener: public NdFlattener{ return output; } -protected: + protected: /*! \brief Write to stream in Python-list style, using the data of the * indices array between 'from' (inclusive) and 'to' (exclusive). * @@ -377,17 +363,16 @@ class NdFlattener: public NdFlattener{ */ void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { output << "["; - for(Index_t i=from; i{ /*! \brief Constructor which calls initialize_or_refresh. * */ - template + template NdFlattener(ARGS const&... args) { initialize_or_refresh(args...); } /*! \brief Initialize or refresh the NdFlattener. * \details Either a 'recursive function' or 'collective communication' - * may be used. When the NdFlattener does not hold data yet, it is + * may be used. When the NdFlattener does not hold data yet, it is * initialized, meaning that the data are collected and the indices arrays * are allocated and filled. Otherwise it is refreshed, meaning that the data are * recollected under the assumption that the indices arrays did not change. */ - template - void initialize_or_refresh(ARGS const&... args){ - if( initialized() ){ + template + void initialize_or_refresh(ARGS const&... args) { + if (initialized()) { refresh(args...); } else { initialize(args...); @@ -419,36 +404,34 @@ class NdFlattener: public NdFlattener{ /*! \brief Initialization status of the NdFlattener. * \returns true if the NdFlattener has been initialized */ - bool initialized(){ - return nNodes>0; - } + bool initialized() { return nNodes > 0; } -protected: + protected: /*! \brief Allocate the indices array after \a nNodes has been determined. */ void allocate() { - indices.reserve(nNodes+1); + indices.reserve(nNodes + 1); indices[0] = 0; Base::allocate(); } /*! \brief Set \a iNode to 0 in all layers. */ - void reset_iNode(){ + void reset_iNode() { iNode = 0; Base::reset_iNode(); } /*=== Construct from 'recursive function' ===*/ -public: + public: /*! \brief Initialize from a 'recursive function'. * - * The function should return a pair. Its first entry is the number of children. - * Its second entry is a function with the same meaning, recursively + * The function should return a pair. Its first entry is the number of children. + * Its second entry is a function with the same meaning, recursively * one layer down. * \param f - the 'recursive function' */ - template + template void initialize(f_type f) { count_f(f); allocate(); @@ -458,32 +441,32 @@ class NdFlattener: public NdFlattener{ /*! \brief Refresh the data according to the 'recursive function' * * The NdFlattener must have been constructed with a 'recursive function'. - * Now refresh the values with another 'recursive function'. The subarray lengths + * Now refresh the values with another 'recursive function'. The subarray lengths * resulting from both 'recursive functions' must coincide, as the indices arrays * are not changed. - * + * * \param f - the 'recursive function' * \tparam f_type - to allow for any type of the 'recursive function' */ - template - void refresh(f_type f){ + template + void refresh(f_type f) { reset_iNode(); set_f(f, true); } -protected: + protected: /*! \brief Determine the space required for reading the 'recursive function'. * * \param f - the 'recursive function' */ - template + template void count_f(f_type f) { Index_t nChild = f.first; - for(Index_t iChild=0; iChild{ * in layer 1 have to be overwritten * \tparam f_type - to allow for any type of the 'recursive function' */ - template + template void set_f(f_type f, bool refresh) { Index_t nChild = f.first; - for(Index_t iChild=0; iChild{ } } - /*=== Construct with Allgatherv ===*/ -public: + public: /*! \brief Initialize a flattener with K indices by combining distributed flatteners with (K-1) indices each. * * The new first index will encode the rank of the process. Data is exchanged in MPI::Allgatherv-style @@ -519,62 +501,55 @@ class NdFlattener: public NdFlattener{ * \param[in] mpi_env - The MPI environment used for communication. * \param[in] local_version - The local NdFlattener structure with (K-1) indices. */ - template - void initialize( - MPI_Environment_type const& mpi_env, - Base const& local_version - ) { - su2matrix Nodes_all(K,mpi_env.size); // [k][r] is number of all nodes in layer (k+1), rank r in the new structure - for(int r=0; r + void initialize(MPI_Environment_type const& mpi_env, Base const& local_version) { + su2matrix Nodes_all( + K, mpi_env.size); // [k][r] is number of all nodes in layer (k+1), rank r in the new structure + for (int r = 0; r < mpi_env.size; + r++) { // the first index decides on the rank, so there is exactly one node per rank + nNodes += Nodes_all[K - 1][r] = 1; } - Base::count_g(mpi_env, Nodes_all, local_version); // set the lower layers' nNodes and Nodes_all[k] + Base::count_g(mpi_env, Nodes_all, local_version); // set the lower layers' nNodes and Nodes_all[k] allocate(); indices[0] = 0; - for(int r=0; r - void refresh( - MPI_Environment_type const& mpi_env, - Base const& local_version - ) { - su2matrix Nodes_all_0(1,mpi_env.size); + template + void refresh(MPI_Environment_type const& mpi_env, Base const& local_version) { + su2matrix Nodes_all_0(1, mpi_env.size); LowestLayer::count_g(mpi_env, Nodes_all_0, local_version); LowestLayer::set_g(mpi_env, Nodes_all_0, local_version); } -protected: + protected: /*! \brief Count the distributed flatteners' numbers of nodes, and set nNodes. * * \param[in] mpi_env - MPI environment for communication * \param[out] Nodes_all - [k][r] is set to number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be send to the other processes */ - void count_g(Nd_MPI_Environment const& mpi_env, - su2matrix& Nodes_all, - CurrentLayer const& local_version ) - { + void count_g(Nd_MPI_Environment const& mpi_env, su2matrix& Nodes_all, CurrentLayer const& local_version) { nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[K-1], 1, mpi_env.mpi_index, mpi_env.comm ); - for(int r=0; r{ * \param[in] Nodes_all - [k][r] is the number of nodes in layer (k+1), rank r. * \param[in] local_version - local instance to be sent to the other processes */ - void set_g(Nd_MPI_Environment const& mpi_env, - su2matrix const& Nodes_all, - CurrentLayer const& local_version ) - { - + void set_g(Nd_MPI_Environment const& mpi_env, su2matrix const& Nodes_all, + CurrentLayer const& local_version) { std::vector Nodes_all_K_as_int(mpi_env.size); - std::vector Nodes_all_k_cumulated(mpi_env.size+1); // [r] is number of nodes in the current layer, summed over all processes with rank below r - // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the last element of indices, - // which is the local nNodes of the layer below. Note that MPI needs indices of type 'int'. + std::vector Nodes_all_k_cumulated( + mpi_env.size + 1); // [r] is number of nodes in the current layer, summed over all processes with rank below r + // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the + // last element of indices, which is the local nNodes of the layer below. Note that MPI needs indices of type 'int'. Nodes_all_k_cumulated[0] = 1; - for(int r=0; r{ } /*== Data access ==*/ -public: - Index_t size() const { // should not be called by recursion, is incorrect in lower layers! + public: + Index_t size() const { // should not be called by recursion, is incorrect in lower layers! return nNodes; } /*! \brief Look-up with IndexAccumulator, non-const version. */ - helpers::IndexAccumulator > operator[](Index_t i0) { - return helpers::IndexAccumulator >(*this,0,size())[i0]; + helpers::IndexAccumulator > operator[](Index_t i0) { + return helpers::IndexAccumulator >(*this, 0, size())[i0]; } /*! \brief Look-up with IndexAccumulator, const version. */ - helpers::IndexAccumulator > operator[](Index_t i0) const { - return helpers::IndexAccumulator >(*this,0,size())[i0]; + helpers::IndexAccumulator > operator[](Index_t i0) const { + return helpers::IndexAccumulator >(*this, 0, size())[i0]; } }; -template +template class NdFlattener<1, Data_t_, Index_t_> { -public: + public: static constexpr size_t K = 1; using Data_t = Data_t_; using Index_t = Index_t_; @@ -643,154 +616,126 @@ class NdFlattener<1, Data_t_, Index_t_> { using CurrentLayer = NdFlattener<1, Data_t, Index_t>; using LowestLayer = CurrentLayer; -private: - Index_t nNodes=0; - Index_t iNode=0; + private: + Index_t nNodes = 0; + Index_t iNode = 0; std::vector data_; - /*=== Getters ===*/ -public: - Data_t* GetData() {return data_.data();} - const Data_t* GetData() const {return data_.data();} + public: + Data_t* GetData() { return data_.data(); } + const Data_t* GetData() const { return data_.data(); } /*=== Outputting ===*/ -protected: + protected: void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { - output << "["; - for(Index_t i=from; i + template NdFlattener(ARGS const&... args) { initialize_or_refresh(args...); } - template - void initialize_or_refresh(ARGS const&... args){ - if( initialized() ){ + template + void initialize_or_refresh(ARGS const&... args) { + if (initialized()) { refresh(args...); } else { initialize(args...); } } - bool initialized(){ - return nNodes>0; - } + bool initialized() { return nNodes > 0; } // Functionality to initialize/refresh from a recursive function // could be desirable also for N=1, in order to gather from such // NdFlatteners an NdFlattener with N=2. // Gathering an NdFlattener with N=1 is not meaningful however. - template + template void initialize(f_type f) { count_f(f); allocate(); set_f(f, false); } - template - void refresh(f_type f){ + template + void refresh(f_type f) { reset_iNode(); set_f(f, true); } -protected: - void allocate(){ - data_.reserve(nNodes); - } + protected: + void allocate() { data_.reserve(nNodes); } - void reset_iNode(){ - iNode = 0; - } + void reset_iNode() { iNode = 0; } /*=== Construct from 'recursive function' ===*/ -protected: - template - void count_f(f_type f){ + protected: + template + void count_f(f_type f) { nNodes += f.first; } - template - void set_f(f_type f, bool refresh){ + template + void set_f(f_type f, bool refresh) { Index_t nChild = f.first; - for(Index_t iChild=0; iChild& Nodes_all, - CurrentLayer const& local_version ) - { + protected: + void count_g(Nd_MPI_Environment const& mpi_env, su2matrix& Nodes_all, CurrentLayer const& local_version) { nNodes = 0; // gather numbers of nodes in the current layer from all processes - mpi_env.MPI_Allgather_fun( &(local_version.nNodes), 1, mpi_env.mpi_index, Nodes_all[0], 1, mpi_env.mpi_index, mpi_env.comm ); - for(int r=0; r const& Nodes_all, - CurrentLayer const& local_version ) - { - - + void set_g(Nd_MPI_Environment const& mpi_env, su2matrix const& Nodes_all, + CurrentLayer const& local_version) { std::vector Nodes_all_0_as_int(mpi_env.size); - std::vector Nodes_all_0_cumulated(mpi_env.size+1); + std::vector Nodes_all_0_cumulated(mpi_env.size + 1); Nodes_all_0_cumulated[0] = 0; - for(int r=0; r Date: Mon, 24 May 2021 19:42:45 +0200 Subject: [PATCH 145/192] manual improvements of code formatting --- Common/include/toolboxes/ndflattener.hpp | 32 ++++++++++++++++-------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index bc25247f3e3..28be6fa1027 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -172,7 +172,8 @@ struct Nd_MPI_Environment { MPI_Allgatherv_t MPI_Allgatherv_fun; int rank; int size; - Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, + Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, + MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, MPI_Communicator_t comm = SU2_MPI::GetComm(), MPI_Allgather_t MPI_Allgather_fun = &(SU2_MPI::Allgather), MPI_Allgatherv_t MPI_Allgatherv_fun = &(SU2_MPI::Allgatherv)) @@ -232,7 +233,11 @@ class IndexAccumulator : public IndexAccumulator_Base { /*! The Base of NdFlattener is NdFlattener, but do also preserve constness. */ - using Nd_Base_t = su2conditional_t::value, const typename Nd_t::Base, typename Nd_t::Base>; + using Nd_Base_t = su2conditional_t< + std::is_const::value, + const typename Nd_t::Base, + typename Nd_t::Base + >; /*! Return type of operator[]. */ using LookupType = IndexAccumulator; using Base::nd; @@ -267,7 +272,11 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> /*! Return type of operator[]. * \details Data type of NdFlattener, but do also preserve constness. */ - using LookupType = su2conditional_t::value, const typename Nd_t::Data_t, typename Nd_t::Data_t>; + using LookupType = su2conditional_t< + std::is_const::value, + const typename Nd_t::Data_t, + typename Nd_t::Data_t + >; using Base::nd; using Base::offset; using Base::size; @@ -503,13 +512,14 @@ class NdFlattener : public NdFlattener { */ template void initialize(MPI_Environment_type const& mpi_env, Base const& local_version) { - su2matrix Nodes_all( - K, mpi_env.size); // [k][r] is number of all nodes in layer (k+1), rank r in the new structure - for (int r = 0; r < mpi_env.size; - r++) { // the first index decides on the rank, so there is exactly one node per rank + // [k][r] is number of all nodes in layer (k+1), rank r in the new structure + su2matrix Nodes_all(K, mpi_env.size); + // the first index decides on the rank, so there is exactly one node per rank + for (int r = 0; r < mpi_env.size; r++) { nNodes += Nodes_all[K - 1][r] = 1; } - Base::count_g(mpi_env, Nodes_all, local_version); // set the lower layers' nNodes and Nodes_all[k] + // set the lower layers' nNodes and Nodes_all[k] + Base::count_g(mpi_env, Nodes_all, local_version); allocate(); @@ -563,9 +573,9 @@ class NdFlattener : public NdFlattener { void set_g(Nd_MPI_Environment const& mpi_env, su2matrix const& Nodes_all, CurrentLayer const& local_version) { std::vector Nodes_all_K_as_int(mpi_env.size); - std::vector Nodes_all_k_cumulated( - mpi_env.size + 1); // [r] is number of nodes in the current layer, summed over all processes with rank below r - // plus one. Used as displacements in Allgatherv, but we do not want to transfer the initial zeros and rather the + std::vector Nodes_all_k_cumulated( mpi_env.size + 1); + //< [r] is the number of nodes in the current layer, summed over all processes with rank below r, **plus one**. + // Used as displacements in Allgatherv, as we do not want to transfer the initial zeros, but we want to transfer the // last element of indices, which is the local nNodes of the layer below. Note that MPI needs indices of type 'int'. Nodes_all_k_cumulated[0] = 1; for (int r = 0; r < mpi_env.size; r++) { From 6094cb6d753e0c9b6a83f9a0b5293d011e5cc1eb Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Mon, 24 May 2021 23:28:21 +0100 Subject: [PATCH 146/192] update tests --- TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref | 16 ++++++++-------- TestCases/hybrid_regression.py | 4 ++-- TestCases/parallel_regression.py | 8 ++++---- TestCases/serial_regression.py | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref index 9f9eb61496d..72cc7d70416 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref +++ b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref @@ -1,9 +1,9 @@ INDEX GRAD -0 -3.465631559336758e-03 -1 -1.844003066470726e-03 -2 -7.925069065625049e-04 -3 -2.742895537614673e-04 -4 -2.738092746211827e-04 -5 -7.890546914650276e-04 -6 -1.831172635608937e-03 -7 -3.431364694518416e-03 +0 -3.465632121754074e-03 +1 -1.844003360219930e-03 +2 -7.925070240684198e-04 +3 -2.742895873196515e-04 +4 -2.738093165742900e-04 +5 -7.890548338696854e-04 +6 -1.831172969426724e-03 +7 -3.431365309796604e-03 diff --git a/TestCases/hybrid_regression.py b/TestCases/hybrid_regression.py index 48b223f8024..af6011b0eaf 100644 --- a/TestCases/hybrid_regression.py +++ b/TestCases/hybrid_regression.py @@ -646,7 +646,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4, 0, -3.771897, -4.163473] + fsi2d.test_vals = [4, 0, -3.743230, -4.133462] fsi2d.multizone= True fsi2d.unsteady = True test_list.append(fsi2d) @@ -665,7 +665,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.400852, -4.085149, 5.3839e-08, 121] + dyn_fsi.test_vals = [-4.355806, -4.060581, 5.3837e-08, 100] dyn_fsi.multizone = True dyn_fsi.unsteady = True test_list.append(dyn_fsi) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index abee592c8eb..54728bb237a 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1175,7 +1175,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4, 0, -3.771873, -4.163491] #last 4 columns + fsi2d.test_vals = [4, 0, -3.743210, -4.133483] #last 4 columns fsi2d.su2_exec = "parallel_computation_fsi.py -f" fsi2d.timeout = 1600 fsi2d.multizone= True @@ -1200,7 +1200,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.400874, -4.085152, 0.000000, 117] + dyn_fsi.test_vals = [-4.355829, -4.060587, 5.3837e-08, 98] dyn_fsi.multizone = True dyn_fsi.unsteady = True dyn_fsi.su2_exec = "mpirun -n 2 SU2_CFD" @@ -1356,7 +1356,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4, 0, -3.771873, -4.163491] #last 4 columns + pywrapper_fsi2d.test_vals = [4, 0, -3.743210, -4.133483] #last 4 columns pywrapper_fsi2d.su2_exec = "mpirun -np 2 SU2_CFD.py --nZone 2 --fsi True --parallel -f" pywrapper_fsi2d.timeout = 1600 pywrapper_fsi2d.unsteady = True @@ -1382,7 +1382,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.551335, 2.295594, 0.350036, 0.093081] + pywrapper_rigidMotion.test_vals = [-1.614170, 2.242953, 0.350036, 0.093137] pywrapper_rigidMotion.su2_exec = "mpirun -np 2 python launch_flatPlate_rigidMotion.py --parallel -f" pywrapper_rigidMotion.timeout = 1600 pywrapper_rigidMotion.tol = 0.00001 diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index feb426f565e..6a715ac5478 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1319,7 +1319,7 @@ def main(): fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" fsi2d.cfg_file = "configFSI.cfg" fsi2d.test_iter = 4 - fsi2d.test_vals = [4, 0, -3.771878, -4.163489] #last 4 columns + fsi2d.test_vals = [4, 0, -3.743214, -4.133482] #last 4 columns fsi2d.su2_exec = "SU2_CFD" fsi2d.timeout = 1600 fsi2d.multizone = True @@ -1356,7 +1356,7 @@ def main(): dyn_fsi.cfg_dir = "fea_fsi/dyn_fsi" dyn_fsi.cfg_file = "config.cfg" dyn_fsi.test_iter = 4 - dyn_fsi.test_vals = [-4.400854, -4.085153, 0.000000, 101] #last 4 columns + dyn_fsi.test_vals = [-4.355809, -4.060588, 5.3837e-08, 86] #last 4 columns dyn_fsi.multizone = True dyn_fsi.unsteady = True dyn_fsi.su2_exec = "SU2_CFD" @@ -1874,7 +1874,7 @@ def main(): pywrapper_fsi2d.cfg_dir = "fea_fsi/WallChannel_2d" pywrapper_fsi2d.cfg_file = "configFSI.cfg" pywrapper_fsi2d.test_iter = 4 - pywrapper_fsi2d.test_vals = [4, 0, -3.771878, -4.163489] #last 4 columns + pywrapper_fsi2d.test_vals = [4, 0, -3.743214, -4.133482] #last 4 columns pywrapper_fsi2d.su2_exec = "SU2_CFD.py --nZone 2 --fsi True -f" pywrapper_fsi2d.new_output = True pywrapper_fsi2d.unsteady = True @@ -1903,7 +1903,7 @@ def main(): pywrapper_rigidMotion.cfg_dir = "py_wrapper/flatPlate_rigidMotion" pywrapper_rigidMotion.cfg_file = "flatPlate_rigidMotion_Conf.cfg" pywrapper_rigidMotion.test_iter = 5 - pywrapper_rigidMotion.test_vals = [-1.551335, 2.295594, 0.350050, 0.093081] + pywrapper_rigidMotion.test_vals = [-1.614170, 2.242953, 0.350050, 0.093137] pywrapper_rigidMotion.su2_exec = "python launch_flatPlate_rigidMotion.py -f" pywrapper_rigidMotion.new_output = True pywrapper_rigidMotion.timeout = 1600 From 13c63fa2256eef1c520d041ef0d22eb6197394fa Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 25 May 2021 01:10:15 +0100 Subject: [PATCH 147/192] avoid duplication of default values --- Common/include/code_config.hpp | 4 +-- Common/include/geometry/dual_grid/CPoint.hpp | 16 +++++------ Common/include/toolboxes/ndflattener.hpp | 30 +++++++++----------- Common/src/geometry/CGeometry.cpp | 6 ++-- Common/src/geometry/dual_grid/CPoint.cpp | 2 +- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/Common/include/code_config.hpp b/Common/include/code_config.hpp index 0e085acbc76..1524b720aff 100644 --- a/Common/include/code_config.hpp +++ b/Common/include/code_config.hpp @@ -61,8 +61,8 @@ template using su2enable_if = typename std::enable_if::type; /*--- Compile-time type selection. ---*/ -template struct su2conditional { typedef T type; }; -template struct su2conditional { typedef F type; }; +template struct su2conditional { using type = T; }; +template struct su2conditional { using type = F; }; template using su2conditional_t = typename su2conditional::type; diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 099b7668dd1..417b88974ff 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -431,17 +431,15 @@ class CPoint { * \param[in] markerID - Marker index of closest wall element. * \param[in] elemID - Element index of closest wall element. */ - inline void SetWall_Distance(unsigned long iPoint, su2double distance, - int rankID = -1, - unsigned short zoneID = numeric_limits::max(), - unsigned short markerID = numeric_limits::max(), - unsigned long elemID = numeric_limits::max() ) { + inline void SetWall_Distance(unsigned long iPoint, su2double distance, int rankID, unsigned short zoneID, + unsigned short markerID, unsigned long elemID) { Wall_Distance(iPoint) = distance; ClosestWall_Rank(iPoint) = rankID; ClosestWall_Zone(iPoint) = zoneID; ClosestWall_Marker(iPoint) = markerID; ClosestWall_Elem(iPoint) = elemID; } + inline void SetWall_Distance(unsigned long iPoint, su2double distance) { Wall_Distance(iPoint) = distance; } /*! * \brief Get the value of the distance to the nearest wall. @@ -886,10 +884,10 @@ class CPoint { template void SetWallRoughness(Roughness_type const& roughness){ for (unsigned long iPoint=0; iPoint= 0){ SetRoughnessHeight(iPoint, roughness[rankID][zoneID][markerID]); } } diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 28be6fa1027..bc1a4ad466b 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -163,15 +163,17 @@ class NdFlattener; struct Nd_MPI_Environment { using MPI_Allgather_t = decltype(&(SU2_MPI::Allgather)); using MPI_Allgatherv_t = decltype(&(SU2_MPI::Allgatherv)); - using MPI_Datatype_t = decltype(MPI_INT); + using MPI_Datatype_t = typename SU2_MPI::Datatype; using MPI_Communicator_t = typename SU2_MPI::Comm; - MPI_Datatype_t mpi_data; - MPI_Datatype_t mpi_index; + + const MPI_Datatype_t mpi_data; + const MPI_Datatype_t mpi_index; MPI_Communicator_t comm; MPI_Allgather_t MPI_Allgather_fun; MPI_Allgatherv_t MPI_Allgatherv_fun; - int rank; - int size; + const int rank; + const int size; + Nd_MPI_Environment(MPI_Datatype_t mpi_data = MPI_DOUBLE, MPI_Datatype_t mpi_index = MPI_UNSIGNED_LONG, MPI_Communicator_t comm = SU2_MPI::GetComm(), @@ -209,19 +211,19 @@ class IndexAccumulator_Base { using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; + /*! \brief Return exclusive upper bound for next index. + */ + Index_t size() const { return size_; } + protected: Nd_t& nd; /*!< \brief The accessed NdFlattener. */ const Index_t offset; /*!< \brief Index in the currently accessed layer. */ const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ IndexAccumulator_Base(Nd_t& nd, Index_t offset, Index_t size) : nd(nd), offset(offset), size_(size) {} - - /*! \brief Return exclusive upper bound for next index. - */ - Index_t size() const { return size_; } }; -template +template class IndexAccumulator : public IndexAccumulator_Base { public: using Base = IndexAccumulator_Base; @@ -289,7 +291,7 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> if (Check) { if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); } - return nd.GetData()[offset + i]; + return nd.data()[offset + i]; } /*! \brief Return (possibly const) pointer to data. @@ -351,7 +353,6 @@ class NdFlattener : public NdFlattener { /*=== Outputting ===*/ - public: /*! \brief Write in Python-list style. * * Like this: [[1, 2], [10, 20, 30]] @@ -631,11 +632,6 @@ class NdFlattener<1, Data_t_, Index_t_> { Index_t iNode = 0; std::vector data_; - /*=== Getters ===*/ - public: - Data_t* GetData() { return data_.data(); } - const Data_t* GetData() const { return data_.data(); } - /*=== Outputting ===*/ protected: void toPythonString_fromto(std::ostream& output, Index_t from, Index_t to) const { diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index 8d8792bb369..3f1c9066792 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -3944,12 +3944,14 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo } /*--- Otherwise, set wall roughnesses. ---*/ if(!allEmpty){ - /*--- Store all wall roughnesses in a common data structure. ---*/ + /*--- Store all wall roughnesses in a common data structure. ---*/ // [iZone][iMarker] -> roughness, for this rank auto roughness_f = make_pair( nZone, [config_container,geometry_container,iInst](unsigned long iZone){ const CConfig* config = config_container[iZone]; - return make_pair( geometry_container[iZone][iInst][MESH_0]->GetnMarker() , [config](unsigned long iMarker){ + const auto nMarker = geometry_container[iZone][iInst][MESH_0]->GetnMarker(); + + return make_pair( nMarker, [config](unsigned long iMarker){ return config->GetWallRoughnessProperties(config->GetMarker_All_TagBound(iMarker)).second; }); }); diff --git a/Common/src/geometry/dual_grid/CPoint.cpp b/Common/src/geometry/dual_grid/CPoint.cpp index 532636133f5..6fd84b1afde 100644 --- a/Common/src/geometry/dual_grid/CPoint.cpp +++ b/Common/src/geometry/dual_grid/CPoint.cpp @@ -134,7 +134,7 @@ void CPoint::FullAllocation(unsigned short imesh, const CConfig *config) { Wall_Distance.resize(npoint) = su2double(0.0); ClosestWall_Rank.resize(npoint) = -1; ClosestWall_Zone.resize(npoint) = numeric_limits::max(); - ClosestWall_Marker.resize(npoint) = numeric_limits::max(); + ClosestWall_Marker = ClosestWall_Zone; ClosestWall_Elem.resize(npoint) = numeric_limits::max(); RoughnessHeight.resize(npoint) = su2double(0.0); From 018b1a8b0b431e1a56aa909a8311889591d8abb9 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 25 May 2021 10:50:06 +0100 Subject: [PATCH 148/192] example of what should not be possible --- UnitTests/Common/toolboxes/ndflattener_tests.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 9ec4440e8e6..1fe733a0e07 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -28,6 +28,11 @@ #include "catch.hpp" #include "../../Common/include/toolboxes/ndflattener.hpp" +template +void setIntoConstObject(const T& obj) { + obj[0] = 1; +} + TEST_CASE("NdFlattener Test", "[NdFlattener]"){ int rank; SU2_MPI::Comm_rank(SU2_MPI::GetComm(), &rank); @@ -51,6 +56,8 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ NdFlattener<2> nd2; nd2.initialize_or_refresh(f); + setIntoConstObject(nd2[0]); + /*-- Modify A -> this should not alter nd2 at this point --*/ A[0][0] = 0.5; From f0e16b0e2d6441e7bf0609ef798648981e7b861e Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Tue, 25 May 2021 14:12:39 +0200 Subject: [PATCH 149/192] IndexAccumulator::operator[],data is non-const, added const variants which turn the NdFlattener type to const (for N>1) or return a const reference/pointer (for N==1). Now the ndflattener_tests.cpp should NOT compile. --- Common/include/toolboxes/ndflattener.hpp | 67 ++++++++++++++++++++---- 1 file changed, 58 insertions(+), 9 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index bc1a4ad466b..b852e23529f 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -112,6 +112,22 @@ * * nd_global[rank][zone].data() * + * # Constness + * The IndexAccumulator stores how to access an NdFlattener (and which one), and this information does not change along + * with read or write access. Therefore the members `IndexAccumulator::operator[]` and `IndexAccumulator<1,Nd_t>::data` + * could be always const, and any const-qualification of `Nd_t` could just be passed by `operator[]` to the + * `IndexAccumulator` class of lower `N` and finally decide whether a reference/pointer to `const Data_t` or `Data_t` is returned. + * + * However, in order to comply with the intended semantic meaning of const, those `operator[]` and `data` are not marked as + * const functions. We provide const variants of them, which however make the `Nd_t` const or return references/pointers to + * `const Data_t`. + * + * This ensures that the following is not possible: + * + * template set(T const& t) { t[0] = 1.0; } + * NdFlattener<2> nd2(...); + * set( nd2[0] ); + * * # Unit tests * The interface described here is tested in UnitTests/Common/toolboxes/ndflattener_tests.cpp, which may also * serve as an addition example of how to use the NdFlattener. @@ -157,7 +173,7 @@ class NdFlattener; * \brief Contains information for the collective communication of NdFlatteners. * * The default arguments in the constructor are chosen in a sensible way: - * - To communicate su2double data, just call ND_MPI_Environment(). + * - To communicate su2double data, just call Nd_MPI_Environment(). * - To communicate unsigned long data, call Nd_MPI_Environment(MPI_UNSIGNED_LONG). */ struct Nd_MPI_Environment { @@ -193,9 +209,10 @@ namespace helpers { * \brief Data structure holding an offset for the NdFlattener, to provide a []...[]-interface. * \details Derived from IndexAccumulator_Base, specifying the operator[] method: * - For N==1, the structure has already read all indices but one. So after this method has read the last - * index, return a reference to the data. - * - The case N==2 is much like the case N>3 but an additional function data() should be provided. - * - For N>3, more indices have to be read, return an IndexAccumulator. + * index, return a (possibly const) reference to the data. An additional function data() should be provided. + * - For N>1, more indices have to be read, return an IndexAccumulator. Nd_t_lower is the + * NdFlattener type with one index less. Nd_t_lower is const-qualified if Nd_t is const-qualified, or if the + * index look-up is performed in a const IndexAccumulator. * \tparam N - Number of missing parameters * \tparam Nd_t - Type of the accessed NdFlattener, should be NdFlattener * \tparam Check - if true, raise error if index to operator[] is not in range @@ -242,15 +259,17 @@ class IndexAccumulator : public IndexAccumulator_Base { >; /*! Return type of operator[]. */ using LookupType = IndexAccumulator; + /*! Return type of operator[] const. */ + using LookupType_const = IndexAccumulator; using Base::nd; using Base::offset; using Base::size; /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and - * previous indices. + * previous indices. Non-const version. * \param[in] i - Index. */ - LookupType operator[](Index_t i) const { + LookupType operator[](Index_t i) { assert(i < size()); if (Check) { if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); @@ -259,6 +278,18 @@ class IndexAccumulator : public IndexAccumulator_Base { const Index_t new_size = nd.GetIndices()[offset + i + 1] - new_offset; return LookupType(nd, new_offset, new_size); } + /*! \brief Read one more index, const version. + * \param[in] i - Index. + */ + LookupType_const operator[](Index_t i) const { + assert(i < size()); + if (Check) { + if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } + const Index_t new_offset = nd.GetIndices()[offset + i]; + const Index_t new_size = nd.GetIndices()[offset + i + 1] - new_offset; + return LookupType_const(nd, new_offset, new_size); + } }; template @@ -279,14 +310,29 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> const typename Nd_t::Data_t, typename Nd_t::Data_t >; + using LookupType_const = const typename Nd_t::Data_t; using Base::nd; using Base::offset; using Base::size; /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. + * Non-const version. + * \details The returned reference is const if and only if the type of the accessed NdFlattener is const-qualified. + * Even though the original NdFlattener might be non-const, marking any IndexAccumulator as const during index look-up + * will invoke the const version of operator[], which turns the NdFlattener type to const. * \param[in] i - Last index. */ - LookupType& operator[](Index_t i) const { + LookupType& operator[](Index_t i) { + assert(i < size()); + if (Check) { + if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } + return nd.data()[offset + i]; + } + /*! \brief Return const reference to the corresponding data element, checking if the index is in its range. + * \param[in] i - Last index. + */ + LookupType_const& operator[](Index_t i) const { assert(i < size()); if (Check) { if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); @@ -294,13 +340,16 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> return nd.data()[offset + i]; } - /*! \brief Return (possibly const) pointer to data. + /*! \brief Return (possibly const) pointer to data, non-const version. * \details If all indices except the last one are fixed, the corresponding data * is stored contiguously. Return a pointer to the beginning of the * block. If this IndexAccumulator was generated from a non-const NdFlattener, the * pointer is non-const, otherwise it is const. */ - LookupType* data() const { return &(this->operator[](0)); } + LookupType* data() { return &(this->operator[](0)); } + /*! \brief Return const pointer to data. + */ + LookupType_const* data() const { return &(this->operator[](0)); } }; } // namespace helpers From 722a4dcc43589901efb0df63ea86946a70215b21 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Tue, 25 May 2021 14:22:18 +0200 Subject: [PATCH 150/192] Removed forbidden write access in ndflattener_tests.cpp --- UnitTests/Common/toolboxes/ndflattener_tests.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/UnitTests/Common/toolboxes/ndflattener_tests.cpp b/UnitTests/Common/toolboxes/ndflattener_tests.cpp index 1fe733a0e07..9ec4440e8e6 100644 --- a/UnitTests/Common/toolboxes/ndflattener_tests.cpp +++ b/UnitTests/Common/toolboxes/ndflattener_tests.cpp @@ -28,11 +28,6 @@ #include "catch.hpp" #include "../../Common/include/toolboxes/ndflattener.hpp" -template -void setIntoConstObject(const T& obj) { - obj[0] = 1; -} - TEST_CASE("NdFlattener Test", "[NdFlattener]"){ int rank; SU2_MPI::Comm_rank(SU2_MPI::GetComm(), &rank); @@ -56,8 +51,6 @@ TEST_CASE("NdFlattener Test", "[NdFlattener]"){ NdFlattener<2> nd2; nd2.initialize_or_refresh(f); - setIntoConstObject(nd2[0]); - /*-- Modify A -> this should not alter nd2 at this point --*/ A[0][0] = 0.5; From d5715c40a324fa63aa2dc1e08cab840cfdca659e Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 25 May 2021 16:16:18 +0100 Subject: [PATCH 151/192] local indices only, no more hidden global "adjointPosition" --- Common/include/basic_types/ad_structure.hpp | 30 ++----------------- .../basic_types/datatype_structure.hpp | 10 ------- Common/include/geometry/CGeometry.hpp | 6 ++-- Common/include/geometry/dual_grid/CPoint.hpp | 2 +- Common/src/basic_types/ad_structure.cpp | 6 ---- SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp | 10 ++----- SU2_CFD/include/variables/CMeshVariable.hpp | 2 +- SU2_CFD/include/variables/CVariable.hpp | 20 +++++++------ SU2_CFD/src/variables/CMeshVariable.cpp | 5 +--- SU2_CFD/src/variables/CVariable.cpp | 10 ++----- TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg | 23 +++++++------- 11 files changed, 33 insertions(+), 91 deletions(-) diff --git a/Common/include/basic_types/ad_structure.hpp b/Common/include/basic_types/ad_structure.hpp index 620da3246f5..6ecbaaac531 100644 --- a/Common/include/basic_types/ad_structure.hpp +++ b/Common/include/basic_types/ad_structure.hpp @@ -271,14 +271,6 @@ namespace AD{ extern ExtFuncHelper* FuncHelper; - /*--- Stores the indices of the input variables (they might be overwritten) ---*/ - - extern std::vector inputValues; - - /*--- Current position inside the adjoint vector ---*/ - - extern int adjointVectorPosition; - extern bool Status; extern bool PreaccActive; @@ -297,24 +289,13 @@ namespace AD{ extern std::vector TapePositions; - extern std::vector localInputValues; - - extern std::vector localOutputValues; - extern codi::PreaccumulationHelper PreaccHelper; /*--- Reference to the tape. ---*/ - FORCEINLINE su2double::TapeType& getGlobalTape() { - return su2double::getGlobalTape(); - } + FORCEINLINE su2double::TapeType& getGlobalTape() {return su2double::getGlobalTape();} - FORCEINLINE void RegisterInput(su2double &data, bool push_index = true) { - AD::getGlobalTape().registerInput(data); - if (push_index) { - inputValues.push_back(data.getGradientData()); - } - } + FORCEINLINE void RegisterInput(su2double &data) {AD::getGlobalTape().registerInput(data);} FORCEINLINE void RegisterOutput(su2double& data) {AD::getGlobalTape().registerOutput(data);} @@ -335,7 +316,6 @@ namespace AD{ opdi::logic->prepareEvaluate(); #endif AD::getGlobalTape().evaluate(); - adjointVectorPosition = 0; } FORCEINLINE void ComputeAdjoint(unsigned short enter, unsigned short leave) { @@ -346,8 +326,6 @@ namespace AD{ #else AD::getGlobalTape().evaluate(TapePositions[enter], TapePositions[leave]); #endif - if (leave == 0) - adjointVectorPosition = 0; } FORCEINLINE void Reset() { @@ -355,10 +333,6 @@ namespace AD{ #if defined(HAVE_OPDI) opdi::logic->reset(); #endif - if (inputValues.size() != 0) { - adjointVectorPosition = 0; - inputValues.clear(); - } if (TapePositions.size() != 0) { #if defined(HAVE_OPDI) for (TapePosition& pos : TapePositions) { diff --git a/Common/include/basic_types/datatype_structure.hpp b/Common/include/basic_types/datatype_structure.hpp index 039df331200..b30d81555f1 100644 --- a/Common/include/basic_types/datatype_structure.hpp +++ b/Common/include/basic_types/datatype_structure.hpp @@ -95,19 +95,9 @@ namespace SU2_TYPE { FORCEINLINE void SetDerivative(su2double& data, const passivedouble &val) {data.setGradient(val);} -#ifdef CODI_REVERSE_TYPE - FORCEINLINE passivedouble GetSecondary(const su2double& data) { - return AD::getGlobalTape().getGradient(AD::inputValues[AD::adjointVectorPosition++]); - } - - FORCEINLINE passivedouble GetDerivative(const su2double& data) { - return AD::getGlobalTape().getGradient(AD::inputValues[AD::adjointVectorPosition++]); - } -#else // forward FORCEINLINE passivedouble GetSecondary(const su2double& data) {return data.getGradient();} FORCEINLINE passivedouble GetDerivative(const su2double& data) {return data.getGradient();} -#endif #else // passive type, no AD diff --git a/Common/include/geometry/CGeometry.hpp b/Common/include/geometry/CGeometry.hpp index c0d1ac313ba..91f033b5164 100644 --- a/Common/include/geometry/CGeometry.hpp +++ b/Common/include/geometry/CGeometry.hpp @@ -1234,14 +1234,14 @@ class CGeometry { * \brief Ray Intersects Triangle (Moller and Trumbore algorithm) */ bool RayIntersectsTriangle(const su2double orig[3], const su2double dir[3], - const su2double vert0[3], const su2double vert1[3], const su2double vert2[3], - su2double *intersect); + const su2double vert0[3], const su2double vert1[3], const su2double vert2[3], + su2double *intersect); /*! * \brief Segment Intersects Triangle */ bool SegmentIntersectsTriangle(su2double point0[3], const su2double point1[3], - su2double vert0[3], su2double vert1[3], su2double vert2[3]); + su2double vert0[3], su2double vert1[3], su2double vert2[3]); /*! * \brief Segment Intersects Line (for 2D FFD Intersection) diff --git a/Common/include/geometry/dual_grid/CPoint.hpp b/Common/include/geometry/dual_grid/CPoint.hpp index 56a21fc1ad9..91ff7135eb4 100644 --- a/Common/include/geometry/dual_grid/CPoint.hpp +++ b/Common/include/geometry/dual_grid/CPoint.hpp @@ -818,7 +818,7 @@ class CPoint { inline void RegisterCoordinates(unsigned long iPoint, bool input) { for (unsigned long iDim = 0; iDim < nDim; iDim++) { if(input) { - AD::RegisterInput(Coord(iPoint,iDim),false); + AD::RegisterInput(Coord(iPoint,iDim)); AD::SetIndex(AD_InputIndex(iPoint,iDim), Coord(iPoint,iDim)); } else { diff --git a/Common/src/basic_types/ad_structure.cpp b/Common/src/basic_types/ad_structure.cpp index 18342e13a90..f6defb62435 100644 --- a/Common/src/basic_types/ad_structure.cpp +++ b/Common/src/basic_types/ad_structure.cpp @@ -31,12 +31,6 @@ namespace AD { #ifdef CODI_REVERSE_TYPE /*--- Initialization of the global variables ---*/ - int adjointVectorPosition = 0; - - std::vector inputValues; - std::vector localInputValues; - std::vector localOutputValues; - TapePosition StartPosition, EndPosition; std::vector TapePositions; diff --git a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp index e81ac660eb2..750bf1dda8f 100644 --- a/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp +++ b/SU2_CFD/include/solvers/CDiscAdjFEASolver.hpp @@ -48,7 +48,6 @@ class CDiscAdjFEASolver final : public CSolver { struct SensData { unsigned short size = 0; su2double* val = nullptr; /*!< \brief Value of the variable. */ - int* AD_Idx = nullptr; /*!< \brief Derivative index in the AD tape. */ su2double* LocalSens = nullptr; /*!< \brief Local sensitivity (domain). */ su2double* GlobalSens = nullptr; /*!< \brief Global sensitivity (mpi). */ su2double* TotalSens = nullptr; /*!< \brief Total sensitivity (time domain). */ @@ -60,7 +59,6 @@ class CDiscAdjFEASolver final : public CSolver { clear(); size = n; val = new su2double[n](); - AD_Idx = new int[n](); LocalSens = new su2double[n](); GlobalSens = new su2double[n](); TotalSens = new su2double[n](); @@ -69,21 +67,17 @@ class CDiscAdjFEASolver final : public CSolver { void clear() { size = 0; delete [] val; - delete [] AD_Idx; delete [] LocalSens; delete [] GlobalSens; delete [] TotalSens; } void Register() { - for (auto i = 0u; i < size; ++i) { - AD::RegisterInput(val[i], false); - AD::SetIndex(AD_Idx[i], val[i]); - } + for (auto i = 0u; i < size; ++i) AD::RegisterInput(val[i]); } void GetDerivative() { - for (auto i = 0u; i < size; ++i) LocalSens[i] = AD::GetDerivative(AD_Idx[i]); + for (auto i = 0u; i < size; ++i) LocalSens[i] = SU2_TYPE::GetDerivative(val[i]); SU2_MPI::Allreduce(LocalSens, GlobalSens, size, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); } diff --git a/SU2_CFD/include/variables/CMeshVariable.hpp b/SU2_CFD/include/variables/CMeshVariable.hpp index c420e523206..217c51ce5f3 100644 --- a/SU2_CFD/include/variables/CMeshVariable.hpp +++ b/SU2_CFD/include/variables/CMeshVariable.hpp @@ -95,7 +95,7 @@ class CMeshVariable : public CVariable { */ inline void GetAdjoint_MeshCoord(unsigned long iPoint, su2double *adj_mesh) final { for (unsigned long iDim = 0; iDim < nDim; iDim++) { - adj_mesh[iDim] = AD::GetDerivative(AD_InputIndex(iPoint,iDim)); + adj_mesh[iDim] = SU2_TYPE::GetDerivative(Mesh_Coord(iPoint,iDim)); AD::ResetInput(Mesh_Coord(iPoint,iDim)); } } diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 8f049516587..1898006dbac 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -95,8 +95,6 @@ class CVariable { su2matrix AD_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ su2matrix AD_OutputIndex; /*!< \brief Indices of Solution variables in the adjoint vector after having been updated. */ - su2matrix AD_Time_n_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ - su2matrix AD_Time_n1_InputIndex; /*!< \brief Indices of Solution variables in the adjoint vector. */ unsigned long nPoint = 0; /*!< \brief Number of points in the domain. */ unsigned long nDim = 0; /*!< \brief Number of dimension of the problem. */ @@ -114,21 +112,25 @@ class CVariable { assert(false && "A base method of CVariable was used, but it should have been overridden by the derived class."); } - void RegisterContainer(bool input, su2activematrix& variable, su2matrix& ad_index) { + void RegisterContainer(bool input, su2activematrix& variable, su2matrix* ad_index = nullptr) { const auto nPoint = variable.rows(); SU2_OMP_FOR_STAT(roundUpDiv(nPoint,omp_get_num_threads())) for (unsigned long iPoint = 0; iPoint < nPoint; ++iPoint) { for(unsigned long iVar=0; iVar& ad_index) { + RegisterContainer(input, variable, &ad_index); + } + public: /*--- Disable copy and assignment. ---*/ CVariable(const CVariable&) = delete; @@ -2159,13 +2161,13 @@ class CVariable { } inline void GetAdjointSolution_time_n(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < AD_Time_n_InputIndex.cols(); iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Time_n_InputIndex(iPoint,iVar)); + for (unsigned long iVar = 0; iVar < Solution_time_n.cols(); iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n(iPoint,iVar)); } inline void GetAdjointSolution_time_n1(unsigned long iPoint, su2double *adj_sol) const { - for (unsigned long iVar = 0; iVar < nVar; iVar++) - adj_sol[iVar] = AD::GetDerivative(AD_Time_n1_InputIndex(iPoint,iVar)); + for (unsigned long iVar = 0; iVar < Solution_time_n1.cols(); iVar++) + adj_sol[iVar] = SU2_TYPE::GetDerivative(Solution_time_n1(iPoint,iVar)); } /*! diff --git a/SU2_CFD/src/variables/CMeshVariable.cpp b/SU2_CFD/src/variables/CMeshVariable.cpp index aed8430db5e..143c0f1188f 100644 --- a/SU2_CFD/src/variables/CMeshVariable.cpp +++ b/SU2_CFD/src/variables/CMeshVariable.cpp @@ -38,9 +38,6 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig * Mesh_Coord.resize(nPoint,nDim) = su2double(0.0); WallDistance.resize(nPoint) = su2double(1e-9); - if (config->GetDiscrete_Adjoint()) - AD_InputIndex.resize(nPoint,nDim) = -1; - /*--- Initialize the variables necessary when the problem is time domain ---*/ if (config->GetTime_Domain()) { Solution_time_n.resize(nPoint,nDim) = su2double(0.0); @@ -49,5 +46,5 @@ CMeshVariable::CMeshVariable(unsigned long npoint, unsigned long ndim, CConfig * } void CMeshVariable::Register_MeshCoord() { - RegisterContainer(true, Mesh_Coord, AD_InputIndex); + RegisterContainer(true, Mesh_Coord); } diff --git a/SU2_CFD/src/variables/CVariable.cpp b/SU2_CFD/src/variables/CVariable.cpp index ce5f9a03c4c..78e6ae7b59d 100644 --- a/SU2_CFD/src/variables/CVariable.cpp +++ b/SU2_CFD/src/variables/CVariable.cpp @@ -72,12 +72,6 @@ CVariable::CVariable(unsigned long npoint, unsigned long ndim, unsigned long nva if (!adjoint) { AD_InputIndex.resize(nPoint,nVar) = -1; AD_OutputIndex.resize(nPoint,nVar) = -1; - - if (config->GetTime_Domain()) - AD_Time_n_InputIndex.resize(nPoint,nVar) = -1; - - if (config->GetTime_Marching() != TIME_MARCHING::STEADY) - AD_Time_n1_InputIndex.resize(nPoint,nVar) = -1; } } @@ -122,9 +116,9 @@ void CVariable::RegisterSolution(bool input) { } void CVariable::RegisterSolution_time_n() { - RegisterContainer(true, Solution_time_n, AD_Time_n_InputIndex); + RegisterContainer(true, Solution_time_n); } void CVariable::RegisterSolution_time_n1() { - RegisterContainer(true, Solution_time_n1, AD_Time_n1_InputIndex); + RegisterContainer(true, Solution_time_n1); } diff --git a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg index e5fb7fcd096..04cf4c83c6e 100755 --- a/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg +++ b/TestCases/disc_adj_fsi/dyn_fsi/configFlow.cfg @@ -43,7 +43,7 @@ MARKER_DESIGNING= ( leading_edge, pressure_side, suction_side ) % Common numerics settings --------------------------------------------- % REF_DIMENSIONALIZATION= DIMENSIONAL NUM_METHOD_GRAD= GREEN_GAUSS -CFL_NUMBER= 15.0 +CFL_NUMBER= 1000.0 % % Flow numerics -------------------------------------------------------- % CONV_NUM_METHOD_FLOW= JST @@ -53,18 +53,15 @@ TIME_DISCRE_FLOW= EULER_IMPLICIT % Linear solvers ------------------------------------------------------- % LINEAR_SOLVER= BCGSTAB LINEAR_SOLVER_PREC= ILU -LINEAR_SOLVER_ERROR= 1E-3 -LINEAR_SOLVER_ITER= 1000 -DISCADJ_LIN_SOLVER= BCGSTAB +LINEAR_SOLVER_ERROR= 1E-6 +LINEAR_SOLVER_ITER= 25 +DISCADJ_LIN_SOLVER= SMOOTHER DISCADJ_LIN_PREC= ILU +LINEAR_SOLVER_SMOOTHER_RELAXATION= 0.7 % Multigrid -MGLEVEL= 2 -MGCYCLE= V_CYCLE -MG_PRE_SMOOTH= ( 1, 2, 3, 3 ) -MG_POST_SMOOTH= ( 0, 0, 0, 0 ) -MG_CORRECTION_SMOOTH= ( 0, 0, 0, 0 ) -MG_DAMP_RESTRICTION= 0.75 -MG_DAMP_PROLONGATION= 0.75 +MGLEVEL= 0 +NEWTON_KRYLOV= YES +QUASI_NEWTON_NUM_SAMPLES= 999 % DEFORM_LINEAR_SOLVER= CONJUGATE_GRADIENT DEFORM_LINEAR_SOLVER_PREC= ILU @@ -78,9 +75,9 @@ DEFORM_POISSONS_RATIO= 1e6 BGS_RELAXATION= FIXED_PARAMETER STAT_RELAX_PARAMETER= 1.0 % fluid -INNER_ITER= 51 +INNER_ITER= 31 CONV_STARTITER= 0 -CONV_RESIDUAL_MINVAL= -9 +CONV_RESIDUAL_MINVAL= -7 % % In\Out --------------------------------------------------------------- % MESH_FILENAME= mesh.su2 From 567064a5e2364fa992edb9a5e92aa89b1d78566c Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 25 May 2021 18:43:09 +0100 Subject: [PATCH 152/192] fixes --- Common/include/CConfig.hpp | 3 +- SU2_DOT/src/SU2_DOT.cpp | 37 ++++++------------- .../disc_adj_fsi/dyn_fsi/grad_dv.opt.ref | 16 ++++---- UnitTests/Common/simple_ad_test.cpp | 2 +- 4 files changed, 22 insertions(+), 36 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index f403284c37c..f1952f35355 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -5444,7 +5444,8 @@ class CConfig { * \param[in] val_val - Value of the design variable that we want to read. * \return Design variable step. */ - su2double GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) const { return DV_Value[val_dv][val_val]; } + su2double& GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) { return DV_Value[val_dv][val_val]; } + const su2double& GetDV_Value(unsigned short val_dv, unsigned short val_val = 0) const { return DV_Value[val_dv][val_val]; } /*! * \brief Set the value of the design variable step, we use this value in design problems. diff --git a/SU2_DOT/src/SU2_DOT.cpp b/SU2_DOT/src/SU2_DOT.cpp index f544b6e63fe..35aab262fff 100644 --- a/SU2_DOT/src/SU2_DOT.cpp +++ b/SU2_DOT/src/SU2_DOT.cpp @@ -688,18 +688,16 @@ void SetProjection_FD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su void SetProjection_AD(CGeometry *geometry, CConfig *config, CSurfaceMovement *surface_movement, su2double** Gradient){ - su2double DV_Value, *VarCoord, Sensitivity, my_Gradient, localGradient, *Normal, Area = 0.0; - unsigned short iDV_Value = 0, iMarker, nMarker, iDim, nDim, iDV, nDV, nDV_Value; + su2double *VarCoord = nullptr, Sensitivity, my_Gradient, localGradient, *Normal, Area = 0.0; + unsigned short iDV_Value = 0, iMarker, nMarker, iDim, nDim, iDV, nDV; unsigned long iVertex, nVertex, iPoint; - int rank = SU2_MPI::GetRank(); + const int rank = SU2_MPI::GetRank(); nMarker = config->GetnMarker_All(); nDim = geometry->GetnDim(); nDV = config->GetnDV(); - VarCoord = nullptr; - /*--- Discrete adjoint gradient computation ---*/ if (rank == MASTER_NODE) @@ -712,21 +710,13 @@ void SetProjection_AD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su /*--- Register design variables as input and set them to zero * (since we want to have the derivative at alpha = 0, i.e. for the current design) ---*/ - - for (iDV = 0; iDV < nDV; iDV++){ - nDV_Value = config->GetnDV_Value(iDV); - - for (iDV_Value = 0; iDV_Value < nDV_Value; iDV_Value++){ + for (iDV_Value = 0; iDV_Value < config->GetnDV_Value(iDV); iDV_Value++){ - /*--- Initilization with su2double resets the index ---*/ + config->SetDV_Value(iDV, iDV_Value, 0.0); - DV_Value = 0.0; - - AD::RegisterInput(DV_Value); - - config->SetDV_Value(iDV, iDV_Value, DV_Value); + AD::RegisterInput(config->GetDV_Value(iDV, iDV_Value)); } } @@ -742,10 +732,7 @@ void SetProjection_AD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su * We need that to make sure to set the sensitivity of surface points only once * (Markers share points, so we would visit them more than once in the loop over the markers below) ---*/ - bool* visited = new bool[geometry->GetnPoint()]; - for (iPoint = 0; iPoint < geometry->GetnPoint(); iPoint++){ - visited[iPoint] = false; - } + vector visited(geometry->GetnPoint(), false); /*--- Initialize the derivatives of the output of the surface deformation routine * with the discrete adjoints from the CFD solution ---*/ @@ -779,18 +766,16 @@ void SetProjection_AD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su } } - delete [] visited; - /*--- Compute derivatives and extract gradient ---*/ AD::ComputeAdjoint(); for (iDV = 0; iDV < nDV; iDV++){ - nDV_Value = config->GetnDV_Value(iDV); - for (iDV_Value = 0; iDV_Value < nDV_Value; iDV_Value++){ - DV_Value = config->GetDV_Value(iDV, iDV_Value); - my_Gradient = SU2_TYPE::GetDerivative(DV_Value); + for (iDV_Value = 0; iDV_Value < config->GetnDV_Value(iDV); iDV_Value++){ + + my_Gradient = SU2_TYPE::GetDerivative(config->GetDV_Value(iDV, iDV_Value)); + SU2_MPI::Allreduce(&my_Gradient, &localGradient, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm()); /*--- Angle of Attack design variable (this is different, diff --git a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref index 72cc7d70416..3bcc2d6eedf 100644 --- a/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref +++ b/TestCases/disc_adj_fsi/dyn_fsi/grad_dv.opt.ref @@ -1,9 +1,9 @@ INDEX GRAD -0 -3.465632121754074e-03 -1 -1.844003360219930e-03 -2 -7.925070240684198e-04 -3 -2.742895873196515e-04 -4 -2.738093165742900e-04 -5 -7.890548338696854e-04 -6 -1.831172969426724e-03 -7 -3.431365309796604e-03 +0 -3.461460672772851e-03 +1 -1.841786315630031e-03 +2 -7.915536278471477e-04 +3 -2.739622075935052e-04 +4 -2.734869089862929e-04 +5 -7.881162336341228e-04 +6 -1.828978274796512e-03 +7 -3.427219375030697e-03 diff --git a/UnitTests/Common/simple_ad_test.cpp b/UnitTests/Common/simple_ad_test.cpp index 6e95b218bb4..49d18467f43 100644 --- a/UnitTests/Common/simple_ad_test.cpp +++ b/UnitTests/Common/simple_ad_test.cpp @@ -56,5 +56,5 @@ TEST_CASE("Simple AD Test", "[AD tests]") { AD::ComputeAdjoint(); CHECK(SU2_TYPE::GetValue(y) == Approx(64)); - CHECK(SU2_TYPE::GetDerivative(y) == Approx(48)); + CHECK(SU2_TYPE::GetDerivative(x) == Approx(48)); } From e97b0bf930fd2da8001ed811997b4cfd7f29e8a6 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 26 May 2021 15:56:09 +0100 Subject: [PATCH 153/192] little less duplication in [] --- Common/include/toolboxes/ndflattener.hpp | 39 +++++++++++------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index b852e23529f..81fb1c74462 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -221,7 +221,7 @@ namespace helpers { * \brief Parent class of IndexAccumulator. * \details IndexAccumulator provides the operator[] method. */ -template +template class IndexAccumulator_Base { public: static constexpr size_t N = N_; @@ -238,12 +238,19 @@ class IndexAccumulator_Base { const Index_t size_; /*!< \brief Exclusive upper bound for the next index. */ IndexAccumulator_Base(Nd_t& nd, Index_t offset, Index_t size) : nd(nd), offset(offset), size_(size) {} + + FORCEINLINE void CheckBound(Index_t i) const { + assert(i < size()); + if (Check) { + if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); + } + } }; template -class IndexAccumulator : public IndexAccumulator_Base { +class IndexAccumulator : public IndexAccumulator_Base { public: - using Base = IndexAccumulator_Base; + using Base = IndexAccumulator_Base; static constexpr size_t N = N_; using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; @@ -264,16 +271,14 @@ class IndexAccumulator : public IndexAccumulator_Base { using Base::nd; using Base::offset; using Base::size; + using Base::CheckBound; /*! \brief Read one more index, checking whether it is in the range dictated by the NdFlattener and * previous indices. Non-const version. * \param[in] i - Index. */ LookupType operator[](Index_t i) { - assert(i < size()); - if (Check) { - if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } + CheckBound(i); const Index_t new_offset = nd.GetIndices()[offset + i]; const Index_t new_size = nd.GetIndices()[offset + i + 1] - new_offset; return LookupType(nd, new_offset, new_size); @@ -282,10 +287,7 @@ class IndexAccumulator : public IndexAccumulator_Base { * \param[in] i - Index. */ LookupType_const operator[](Index_t i) const { - assert(i < size()); - if (Check) { - if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } + CheckBound(i); const Index_t new_offset = nd.GetIndices()[offset + i]; const Index_t new_size = nd.GetIndices()[offset + i + 1] - new_offset; return LookupType_const(nd, new_offset, new_size); @@ -293,9 +295,9 @@ class IndexAccumulator : public IndexAccumulator_Base { }; template -class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> { +class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_, Check> { public: - using Base = IndexAccumulator_Base<1, Nd_t_>; + using Base = IndexAccumulator_Base<1, Nd_t_, Check>; static constexpr size_t N = 1; using Nd_t = Nd_t_; using Index_t = typename Nd_t::Index_t; @@ -314,6 +316,7 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> using Base::nd; using Base::offset; using Base::size; + using Base::CheckBound; /*! \brief Return (possibly const) reference to the corresponding data element, checking if the index is in its range. * Non-const version. @@ -323,20 +326,14 @@ class IndexAccumulator<1, Nd_t_, Check> : public IndexAccumulator_Base<1, Nd_t_> * \param[in] i - Last index. */ LookupType& operator[](Index_t i) { - assert(i < size()); - if (Check) { - if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } + CheckBound(i); return nd.data()[offset + i]; } /*! \brief Return const reference to the corresponding data element, checking if the index is in its range. * \param[in] i - Last index. */ LookupType_const& operator[](Index_t i) const { - assert(i < size()); - if (Check) { - if (i >= size()) SU2_MPI::Error("NdFlattener: Index out of range.", CURRENT_FUNCTION); - } + CheckBound(i); return nd.data()[offset + i]; } From ef4f23329ed9b07a91920055afe37a7d9819d094 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 26 May 2021 16:09:42 +0100 Subject: [PATCH 154/192] proper-er way to reset input --- Common/include/basic_types/ad_structure.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/basic_types/ad_structure.hpp b/Common/include/basic_types/ad_structure.hpp index 6ecbaaac531..18c430c7b2f 100644 --- a/Common/include/basic_types/ad_structure.hpp +++ b/Common/include/basic_types/ad_structure.hpp @@ -299,7 +299,7 @@ namespace AD{ FORCEINLINE void RegisterOutput(su2double& data) {AD::getGlobalTape().registerOutput(data);} - FORCEINLINE void ResetInput(su2double &data) {data.getGradientData() = su2double::GradientData();} + FORCEINLINE void ResetInput(su2double &data) {data = data.getValue();} FORCEINLINE void StartRecording() {AD::getGlobalTape().setActive();} From 9df5d023626eb7c6e8089c22e2bc0ae6f8904333 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Wed, 26 May 2021 17:29:10 +0100 Subject: [PATCH 155/192] small things --- Common/src/geometry/CGeometry.cpp | 4 +--- SU2_CFD/src/drivers/CDriver.cpp | 18 ++++++++++++------ SU2_CFD/src/solvers/CSolver.cpp | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Common/src/geometry/CGeometry.cpp b/Common/src/geometry/CGeometry.cpp index a7b1fe7b9fa..62e0c2b3551 100644 --- a/Common/src/geometry/CGeometry.cpp +++ b/Common/src/geometry/CGeometry.cpp @@ -2721,8 +2721,6 @@ void CGeometry::ComputeSurf_Curvature(CConfig *config) { su2double U[3] = {0.0}, V[3] = {0.0}, W[3] = {0.0}, Length_U, Length_V, Length_W, CosValue, Angle_Value, *K, *Angle_Defect, *Area_Vertex, *Angle_Alpha, *Angle_Beta, **NormalMeanK, MeanK, GaussK, MaxPrinK, cot_alpha, cot_beta, delta, X1, X2, X3, Y1, Y2, Y3, radius, *Buffer_Send_Coord, *Buffer_Receive_Coord, *Coord, Dist, MinDist, MaxK, MinK, SigmaK; bool *Check_Edge; - const bool fea = config->GetStructuralProblem(); - /*--- Allocate surface curvature ---*/ K = new su2double [nPoint]; for (iPoint = 0; iPoint < nPoint; iPoint++) K[iPoint] = 0.0; @@ -2986,7 +2984,7 @@ void CGeometry::ComputeSurf_Curvature(CConfig *config) { SigmaK = sqrt(SigmaK/su2double(TotalnPointDomain)); - if ((rank == MASTER_NODE) && (!fea)) + if (rank == MASTER_NODE) cout << "Max K: " << MaxK << ". Mean K: " << MeanK << ". Standard deviation K: " << SigmaK << "." << endl; Point_Critical.clear(); diff --git a/SU2_CFD/src/drivers/CDriver.cpp b/SU2_CFD/src/drivers/CDriver.cpp index ee98c0b25a3..677f19a7bb8 100644 --- a/SU2_CFD/src/drivers/CDriver.cpp +++ b/SU2_CFD/src/drivers/CDriver.cpp @@ -773,7 +773,7 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet /*--- Create the control volume structures ---*/ - if ((rank == MASTER_NODE) && (!fea)) cout << "Setting the control volume structure." << endl; + if (rank == MASTER_NODE) cout << "Setting the control volume structure." << endl; SU2_OMP_PARALLEL { geometry[MESH_0]->SetControlVolume(config, ALLOCATE); geometry[MESH_0]->SetBoundControlVolume(config, ALLOCATE); @@ -798,8 +798,10 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet /*--- Compute the surface curvature ---*/ - if ((rank == MASTER_NODE) && (!fea)) cout << "Compute the surface curvature." << endl; - geometry[MESH_0]->ComputeSurf_Curvature(config); + if (!fea) { + if (rank == MASTER_NODE) cout << "Compute the surface curvature." << endl; + geometry[MESH_0]->ComputeSurf_Curvature(config); + } /*--- Check for periodicity and disable MG if necessary. ---*/ @@ -895,13 +897,17 @@ void CDriver::Geometrical_Preprocessing_FVM(CConfig *config, CGeometry **&geomet /*--- Compute the max length. ---*/ - if ((rank == MASTER_NODE) && (!fea) && (iMGlevel == MESH_0)) cout << "Finding max control volume width." << endl; - geometry[iMGlevel]->SetMaxLength(config); + if (!fea) { + if ((rank == MASTER_NODE) && (iMGlevel == MESH_0)) + cout << "Finding max control volume width." << endl; + geometry[iMGlevel]->SetMaxLength(config); + } /*--- Communicate the number of neighbors. This is needed for some centered schemes and for multigrid in parallel. ---*/ - if ((rank == MASTER_NODE) && (size > SINGLE_NODE) && (!fea) && (iMGlevel == MESH_0)) cout << "Communicating number of neighbors." << endl; + if ((rank == MASTER_NODE) && (size > SINGLE_NODE) && (iMGlevel == MESH_0)) + cout << "Communicating number of neighbors." << endl; geometry[iMGlevel]->InitiateComms(geometry[iMGlevel], config, NEIGHBORS); geometry[iMGlevel]->CompleteComms(geometry[iMGlevel], config, NEIGHBORS); } diff --git a/SU2_CFD/src/solvers/CSolver.cpp b/SU2_CFD/src/solvers/CSolver.cpp index c36e6404f54..9f8da0fbd13 100644 --- a/SU2_CFD/src/solvers/CSolver.cpp +++ b/SU2_CFD/src/solvers/CSolver.cpp @@ -3129,7 +3129,7 @@ void CSolver::InterpolateRestartData(const CGeometry *geometry, const CConfig *c if (size != SINGLE_NODE && size % 2) SU2_MPI::Error("Number of ranks must be multiple of 2.", CURRENT_FUNCTION); - if (config->GetStructuralProblem() || config->GetFEMSolver()) + if (config->GetFEMSolver()) SU2_MPI::Error("Cannot interpolate the restart file for FEM problems.", CURRENT_FUNCTION); /* Challenges: From 1244638d5ab7942d839bdc8a737471b75c7cb3b3 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Thu, 27 May 2021 09:59:35 +0200 Subject: [PATCH 156/192] error if roughness is set to non-0 value let's see what happens in the CI pipeline --- SU2_CFD/include/numerics/CNumerics.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 2181487e7ac..95c61369c0d 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -802,6 +802,8 @@ class CNumerics { * \param[in] val_dist_j - Value of of the roughness of the nearest wall from point j */ void SetRoughness(su2double val_roughness_i, su2double val_roughness_j) { + if(val_roughness_i!=0.0) SU2_MPI::Error("val_roughness_i!=0.0",CURRENT_FUNCTION); + if(val_roughness_j!=0.0) SU2_MPI::Error("val_roughness_j!=0.0",CURRENT_FUNCTION); roughness_i = val_roughness_i; roughness_j = val_roughness_j; } From 19d3329da5b596c19a463e0ef8fbeae72e1f02e0 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 27 May 2021 12:05:32 +0200 Subject: [PATCH 157/192] Remove errors from #1281. No auto for su2double with rhs math operation and MAXNVAR fix for flow. --- SU2_CFD/src/solvers/CHeatSolver.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index c845fa0e8f1..f8a8b862033 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -363,8 +363,8 @@ void CHeatSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe nVarFlow = solver_container[FLOW_SOL]->GetnVar(); /*--- Define some auxiliary vectors related to the primitive flow solution ---*/ - su2double Primitive_Flow_i[MAXNVAR] = {0}; - su2double Primitive_Flow_j[MAXNVAR] = {0}; + vector Primitive_Flow_i(nVarFlow, 0.0); + vector Primitive_Flow_j(nVarFlow, 0.0); for (auto iEdge = 0ul; iEdge < geometry->GetnEdge(); iEdge++) { @@ -421,7 +421,7 @@ void CHeatSolver::Upwind_Residual(CGeometry *geometry, CSolver **solver_containe Temp_i_Corrected = Temp_i + Project_Temp_i_Grad; Temp_j_Corrected = Temp_j + Project_Temp_j_Grad; - numerics->SetPrimitive(Primitive_Flow_i, Primitive_Flow_j); + numerics->SetPrimitive(Primitive_Flow_i.data(), Primitive_Flow_j.data()); numerics->SetTemperature(Temp_i_Corrected, Temp_j_Corrected); } @@ -571,9 +571,9 @@ void CHeatSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_conta su2double *Normal, *Coord_i, *Coord_j, Area, dist_ij, Twall, dTdn; const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - const auto laminar_viscosity = config->GetMu_ConstantND(); - const auto Prandtl_Lam = config->GetPrandtl_Lam(); - const auto thermal_diffusivity = flow ? laminar_viscosity/Prandtl_Lam : config->GetThermalDiffusivity_Solid(); + const su2double laminar_viscosity = config->GetMu_ConstantND(); + const su2double Prandtl_Lam = config->GetPrandtl_Lam(); + const su2double thermal_diffusivity = flow ? laminar_viscosity/Prandtl_Lam : config->GetThermalDiffusivity_Solid(); //su2double Prandtl_Turb = config->GetPrandtl_Turb(); //laminar_viscosity = config->GetViscosity_FreeStreamND(); // TDE check for consistency for CHT @@ -832,8 +832,8 @@ void CHeatSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solv const bool implicit = (config->GetKind_TimeIntScheme_Flow() == EULER_IMPLICIT); - const auto Temperature_Ref = config->GetTemperature_Ref(); - const auto rho_cp_solid = config->GetDensity_Solid()*config->GetSpecific_Heat_Cp(); + const su2double Temperature_Ref = config->GetTemperature_Ref(); + const su2double rho_cp_solid = config->GetDensity_Solid()*config->GetSpecific_Heat_Cp(); if (flow) { From e8cee0bd684dd45d25996bde7edd3fb0d38188b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 27 May 2021 14:20:48 +0200 Subject: [PATCH 158/192] CoDiPack update. --- externals/codi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/externals/codi b/externals/codi index 6a67202a388..c78918f5eab 160000 --- a/externals/codi +++ b/externals/codi @@ -1 +1 @@ -Subproject commit 6a67202a3887c8da490fdfde82bc46507de68692 +Subproject commit c78918f5eabfc3ef06c8f00a82fb9880ff2c4c75 From be27e1d5ab45ec240fd0cba610d503e2a8a2929a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Bl=C3=BChdorn?= Date: Thu, 27 May 2021 14:21:11 +0200 Subject: [PATCH 159/192] Testing RealReverseIndex. --- Common/include/code_config.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Common/include/code_config.hpp b/Common/include/code_config.hpp index 17315154c34..a341541c920 100644 --- a/Common/include/code_config.hpp +++ b/Common/include/code_config.hpp @@ -92,7 +92,7 @@ using su2double = codi::RealReversePrimal; #elif CODI_PRIMAL_INDEX_TAPE using su2double = codi::RealReversePrimalIndex; #else -using su2double = codi::RealReverse; +using su2double = codi::RealReverseIndex; #endif #endif #elif defined(CODI_FORWARD_TYPE) // forward mode AD From b5bd2b17c29906de8380eeaac6dc10e7b50e2fb7 Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Thu, 27 May 2021 15:50:06 +0200 Subject: [PATCH 160/192] documentation improved Comments on when/why to use NdFlattener, and some other changes. --- Common/include/toolboxes/ndflattener.hpp | 73 ++++++++++++++++++------ 1 file changed, 54 insertions(+), 19 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 81fb1c74462..7252f1bd0c2 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -37,8 +37,40 @@ #include "../parallelization/mpi_structure.hpp" // --- Usage -/*! \page ndflattener_usage Usage of NdFlattener - * To demonstrate the usage of NdFlattener, let us collect information that depends on +/*! \page ndflattener_usage NdFlattener usage + * + * # What is an NdFlattener? + * + * NdFlattener is a container to store a deep copy of multidimensional data in a single object that provides a + * generic []...[] interface. The data and their structure are stored in few contiguous arrays, allowing for an + * efficient MPI gathering operation. + * + * # Which problem does it solve? + * In SU2, there is a lot of multidimensional data: data depending on K>1 indices, like a wall property + * depending on the rank, zone index, and marker index. + * + * The data is often stored non-contiguously as a "tree": + * - an array of pointers, each one of which points to + * - (repeat the previous line another (K-2) times) + * - an array of data. + * + * The individual arrays' sizes are usually unrelated to each other. Therefore in addition to this tree of + * pointers-to-...-to-data, usually there is a tree of pointers-to-...-to-size for each lower level. + * Instead of arrays, there might be getter functions for the data and the sizes. + * + * In order to use multidimensional data behind such a non-generic interface as an argument in a function call, + * we usually make the callee aware of the interface and expose all the trees: Either as separate pointers to arrays + * (or functions), which is tedious, or by handing an object in which they naturally live, which exposes much more + * information. + * + * If the callee is an MPI communication operation, this is not possible. Here, a frequent pattern is to copy the data + * into a single contiguous array, which is then communicated alongside with the structure (lengths of the arrays). + * + * The NdFlattener container is a systematic way to store multidimensional data in a single contiguous array, and + * the structure in few additional contiguous arrays. It exposes them through a generic []...[] interface and allows + * for an efficient MPI_Allgatherv-like operation. + * + * To demonstrate the usage of NdFlattener, let us store a property of type su2double that depends on * the rank, zone index, and marker index. * * # Form the local NdFlattener @@ -93,13 +125,17 @@ * # Look-up * You can access the NdFlattener via a "[]...[]" interface that resembles multidimensional arrays * or pointer-to-pointer-... arrays. If you provide all of the K indices, this returns a reference - * to the data element. If the NdFlattener is declared const, the reference is also const. If you - * provide less than K indices, you obtain an IndexAccumulator object to which you can later pass more - * indices. With respect to the above example: + * to the data element. If you provide less than K indices, you obtain an IndexAccumulator object + * to which you can later pass more indices. With respect to the above example: * - * std::cout << nd_global[rank][zone][marker]; + * std::cout << nd_global[rank][zone][marker]; // e.g. 4.0 * auto nd_g_rank = nd_global[rank]; - * nd_g_rank[zone][marker] += 1.0; + * nd_g_rank[zone][marker] *= 2.0; + * std::cout << nd_g_rank[zone][marker]; // e.g. 8.0 + * + * You may use the IndexAccumulator repeatedly as long as the accessed NdFlattener exists. + * As NdFlatteners are always deep copies, the above block would not change nd_local or the non-contiguous + * data from which it was copied. * * Each index is checked to lie in the correct range dictated by the NdFlattener and the * previous indices. You can obtain the minimal overflowing index with `size`: @@ -113,20 +149,19 @@ * nd_global[rank][zone].data() * * # Constness - * The IndexAccumulator stores how to access an NdFlattener (and which one), and this information does not change along - * with read or write access. Therefore the members `IndexAccumulator::operator[]` and `IndexAccumulator<1,Nd_t>::data` - * could be always const, and any const-qualification of `Nd_t` could just be passed by `operator[]` to the - * `IndexAccumulator` class of lower `N` and finally decide whether a reference/pointer to `const Data_t` or `Data_t` is returned. + * The reference returned by the last `operator[]`, and the pointer returned by `data()`, are const if + * - the accessed NdFlattener object was const, or + * - one of the intermediate IndexAccumulator objects was qualified as const. * - * However, in order to comply with the intended semantic meaning of const, those `operator[]` and `data` are not marked as - * const functions. We provide const variants of them, which however make the `Nd_t` const or return references/pointers to - * `const Data_t`. + * This reflects the semantic meaning of const: * - * This ensures that the following is not possible: - * - * template set(T const& t) { t[0] = 1.0; } * NdFlattener<2> nd2(...); - * set( nd2[0] ); + * + * template set(T& t) { t[0] = 1.0; } + * set( nd2[0] ); // OK + * + * template set_const(T const& t) { t[0] = 1.0; } + * set_const( nd2[0] ); // does not compile * * # Unit tests * The interface described here is tested in UnitTests/Common/toolboxes/ndflattener_tests.cpp, which may also @@ -163,7 +198,7 @@ * * To form such a structure, we typically iterate twice through the pointer-to-pointer-... * array: The first time we get to know how much space to reserve in each layer, then we - * allocate it and fill it with data during the second iteration. + * allocate it and during the second iteration we copy the data. */ template From 340cf8c9affb55984ee2f105cd7307ec8f81f10e Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Thu, 27 May 2021 17:12:35 +0200 Subject: [PATCH 161/192] further testing of the CI pipeline resize instead of reserve? --- Common/include/toolboxes/ndflattener.hpp | 4 ++-- SU2_CFD/include/numerics/CNumerics.hpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 7252f1bd0c2..2162f2503a1 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -501,7 +501,7 @@ class NdFlattener : public NdFlattener { /*! \brief Allocate the indices array after \a nNodes has been determined. */ void allocate() { - indices.reserve(nNodes + 1); + indices.resize(nNodes + 1, 2000000000ul); indices[0] = 0; Base::allocate(); } @@ -762,7 +762,7 @@ class NdFlattener<1, Data_t_, Index_t_> { } protected: - void allocate() { data_.reserve(nNodes); } + void allocate() { data_.resize(nNodes,1); } void reset_iNode() { iNode = 0; } diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 95c61369c0d..996ade92992 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -802,8 +802,10 @@ class CNumerics { * \param[in] val_dist_j - Value of of the roughness of the nearest wall from point j */ void SetRoughness(su2double val_roughness_i, su2double val_roughness_j) { - if(val_roughness_i!=0.0) SU2_MPI::Error("val_roughness_i!=0.0",CURRENT_FUNCTION); - if(val_roughness_j!=0.0) SU2_MPI::Error("val_roughness_j!=0.0",CURRENT_FUNCTION); + if(val_roughness_i!=0.0||val_roughness_j!=0.0) { + std::cout << "val_roughness_i=" << val_roughness_i << " val_roughness_j=" << val_roughness_j << "\n"; + SU2_MPI::Error("val_roughness !=0.0",CURRENT_FUNCTION); + } roughness_i = val_roughness_i; roughness_j = val_roughness_j; } From a5d8a625e651adf88979922677cdb19f299846ab Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Fri, 28 May 2021 13:19:03 +0200 Subject: [PATCH 162/192] remove debug stuff --- Common/include/toolboxes/ndflattener.hpp | 4 ++-- SU2_CFD/include/numerics/CNumerics.hpp | 4 ---- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/Common/include/toolboxes/ndflattener.hpp b/Common/include/toolboxes/ndflattener.hpp index 2162f2503a1..8898c65e64a 100644 --- a/Common/include/toolboxes/ndflattener.hpp +++ b/Common/include/toolboxes/ndflattener.hpp @@ -501,7 +501,7 @@ class NdFlattener : public NdFlattener { /*! \brief Allocate the indices array after \a nNodes has been determined. */ void allocate() { - indices.resize(nNodes + 1, 2000000000ul); + indices.resize(nNodes + 1); indices[0] = 0; Base::allocate(); } @@ -762,7 +762,7 @@ class NdFlattener<1, Data_t_, Index_t_> { } protected: - void allocate() { data_.resize(nNodes,1); } + void allocate() { data_.resize(nNodes); } void reset_iNode() { iNode = 0; } diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 996ade92992..2181487e7ac 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -802,10 +802,6 @@ class CNumerics { * \param[in] val_dist_j - Value of of the roughness of the nearest wall from point j */ void SetRoughness(su2double val_roughness_i, su2double val_roughness_j) { - if(val_roughness_i!=0.0||val_roughness_j!=0.0) { - std::cout << "val_roughness_i=" << val_roughness_i << " val_roughness_j=" << val_roughness_j << "\n"; - SU2_MPI::Error("val_roughness !=0.0",CURRENT_FUNCTION); - } roughness_i = val_roughness_i; roughness_j = val_roughness_j; } From 83723092eeb1c7cdd232952c3ddbafa0dedd16be Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Fri, 28 May 2021 13:24:34 +0200 Subject: [PATCH 163/192] correct non-MPI Allgatherv, Alltoallv before, possibly non-zero displacements were ignored --- Common/include/parallelization/mpi_structure.cpp | 16 ++++++++-------- Common/include/parallelization/mpi_structure.hpp | 6 +++--- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/Common/include/parallelization/mpi_structure.cpp b/Common/include/parallelization/mpi_structure.cpp index 3f4b540211e..451d03178c5 100644 --- a/Common/include/parallelization/mpi_structure.cpp +++ b/Common/include/parallelization/mpi_structure.cpp @@ -123,41 +123,41 @@ void CBaseMPIWrapper::Error(std::string ErrorMsg, std::string FunctionName){ Abort(currentComm, 0); } -void CBaseMPIWrapper::CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype) { +void CBaseMPIWrapper::CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype, int recvshift, int sendshift) { switch (datatype) { case MPI_DOUBLE: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_UNSIGNED_LONG: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_LONG: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_UNSIGNED_SHORT: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_CHAR: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_SHORT: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; case MPI_INT: for (int i = 0; i < size; i++) { - static_cast(recvbuf)[i] = static_cast(sendbuf)[i]; + static_cast(recvbuf)[i+recvshift] = static_cast(sendbuf)[i+sendshift]; } break; default: diff --git a/Common/include/parallelization/mpi_structure.hpp b/Common/include/parallelization/mpi_structure.hpp index 3ae5de48abd..a6d2524bb7f 100644 --- a/Common/include/parallelization/mpi_structure.hpp +++ b/Common/include/parallelization/mpi_structure.hpp @@ -503,7 +503,7 @@ class CBaseMPIWrapper { static int Rank, Size; static Comm currentComm; - static void CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype); + static void CopyData(const void* sendbuf, void* recvbuf, int size, Datatype datatype, int recvshift=0, int sendshift=0); public: static void Error(std::string ErrorMsg, std::string FunctionName); @@ -570,7 +570,7 @@ class CBaseMPIWrapper { static inline void Allgatherv(const void* sendbuf, int sendcnt, Datatype sendtype, void* recvbuf, const int* recvcnt, const int* displs, Datatype recvtype, Comm comm) { - CopyData(sendbuf, recvbuf, sendcnt, sendtype); + CopyData(sendbuf, recvbuf, sendcnt, sendtype, displs[0]); } static inline void Allgather(const void* sendbuf, int sendcnt, Datatype sendtype, void* recvbuf, int recvcnt, @@ -596,7 +596,7 @@ class CBaseMPIWrapper { static inline void Alltoallv(const void* sendbuf, const int* sendcounts, const int* sdispls, Datatype sendtype, void* recvbuf, const int* recvcounts, const int* recvdispls, Datatype recvtype, Comm comm) { - CopyData(sendbuf, recvbuf, recvcounts[0], recvtype); + CopyData(sendbuf, recvbuf, recvcounts[0], recvtype, recvdispls[0], sdispls[0]); } static inline void Probe(int source, int tag, Comm comm, Status* status) {} From aaf5b8ab39ec70b824d9bdf52f05eb4a8fd6e44d Mon Sep 17 00:00:00 2001 From: Max Aehle Date: Fri, 28 May 2021 20:42:33 +0200 Subject: [PATCH 164/192] include in CPrimalGrid.hpp fixes bug #1293: compilation with GCC 11 fails --- Common/include/geometry/primal_grid/CPrimalGrid.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Common/include/geometry/primal_grid/CPrimalGrid.hpp b/Common/include/geometry/primal_grid/CPrimalGrid.hpp index 5697b6fbf07..1a1d4fa1482 100644 --- a/Common/include/geometry/primal_grid/CPrimalGrid.hpp +++ b/Common/include/geometry/primal_grid/CPrimalGrid.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "../../CConfig.hpp" From 5e516936a930ad4aedd3cac316488b061b2496b2 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Sun, 30 May 2021 16:32:15 +0200 Subject: [PATCH 165/192] Fix indices for restart --- SU2_PY/FSI_tools/FSIInterface.py | 4 ++-- SU2_PY/SU2_Nastran/pysu2_nastran.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/SU2_PY/FSI_tools/FSIInterface.py b/SU2_PY/FSI_tools/FSIInterface.py index 2b1e167d79b..8d6a542027c 100644 --- a/SU2_PY/FSI_tools/FSIInterface.py +++ b/SU2_PY/FSI_tools/FSIInterface.py @@ -1900,8 +1900,8 @@ def UnsteadyFSI(self,FSI_config, FluidSolver, SolidSolver): if FSI_config['RESTART_SOL'] == 'YES': NbTimeIter = ((totTime)/deltaT)-1 - time = (FSI_config['RESTART_ITER']+1)*deltaT - TimeIter = FSI_config['RESTART_ITER']+1 + time = (FSI_config['RESTART_ITER'])*deltaT + TimeIter = FSI_config['RESTART_ITER'] else: NbTimeIter = (totTime/deltaT)-1 # number of time iterations time = 0.0 # initial time diff --git a/SU2_PY/SU2_Nastran/pysu2_nastran.py b/SU2_PY/SU2_Nastran/pysu2_nastran.py index d8f37de6f6d..1994ec7b512 100644 --- a/SU2_PY/SU2_Nastran/pysu2_nastran.py +++ b/SU2_PY/SU2_Nastran/pysu2_nastran.py @@ -870,7 +870,7 @@ def __setRestart(self, timeIter): print("The restart iteration was not found in the structural history") break line = line.strip('\r\n').split() - if int(line[1])==(self.Config["RESTART_ITER"]-1): + if int(line[1])==(self.Config["RESTART_ITER"]-2): break index = 0 for index_mode in range(self.nDof): @@ -896,7 +896,7 @@ def __setRestart(self, timeIter): print("The restart iteration was not found in the structural history") break line = line.strip('\r\n').split() - if int(line[1])==self.Config["RESTART_ITER"]: + if int(line[1])==(self.Config["RESTART_ITER"]-1): break index = 0 for index_mode in range(self.nDof): From 18a7a27dc64d7e419d0f05a83cfba6684c783390 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Mon, 31 May 2021 15:09:26 +0200 Subject: [PATCH 166/192] Fix of restart in interface --- SU2_PY/FSI_tools/FSIInterface.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/SU2_PY/FSI_tools/FSIInterface.py b/SU2_PY/FSI_tools/FSIInterface.py index 8d6a542027c..70f0f164b15 100644 --- a/SU2_PY/FSI_tools/FSIInterface.py +++ b/SU2_PY/FSI_tools/FSIInterface.py @@ -1922,13 +1922,6 @@ def UnsteadyFSI(self,FSI_config, FluidSolver, SolidSolver): TimeIterTreshold = -1 self.getSolidInterfaceDisplacement(SolidSolver) self.displacementPredictor(FSI_config, SolidSolver, deltaT) - # We need now to update the solution because both restarter functions (solid and fluid) - # load the files in the solution containers, pushing back the previous solutions. We need - # then to push it back once more to compute the solution at the next time level - # Also this is required because in the fluid iteration preprocessor, if we do not update - # and step to the next time level, there is a flag "fsi" that will initialise the flow - if myid in self.fluidSolverProcessors: - FluidSolver.Update() if myid in self.solidSolverProcessors: SolidSolver.updateSolution() #If no restart From 02442b6d2e0d59edf9b87dd30a69dafec76a1ffa Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Mon, 31 May 2021 16:11:36 +0200 Subject: [PATCH 167/192] Replace auto-type with su2double for introduced changes --- Common/src/CConfig.cpp | 2 -- SU2_CFD/src/SU2_CFD.cpp | 2 +- .../cht/CConjugateHeatInterface.cpp | 26 +++++++++---------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 08ed394ad35..3ad89a51503 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -4664,8 +4664,6 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i SU2_MPI::Error("Streamwise Periodic Flow + Incompressible Euler: Not tested yet.", CURRENT_FUNCTION); if (nMarker_PerBound == 0) SU2_MPI::Error("A MARKER_PERIODIC pair has to be set with KIND_STREAMWISE_PERIODIC != NONE.", CURRENT_FUNCTION); - if (nMarker_PerBound != 2 && false) - SU2_MPI::Error("Streamwise Periodic Flow currently only implemented for one Periodic Marker pair. Combining Streamwise and Spanwise periodicity not possible in the moment.", CURRENT_FUNCTION); if (Energy_Equation && Streamwise_Periodic_Temperature && nMarker_Isothermal != 0) SU2_MPI::Error("No MARKER_ISOTHERMAL marker allowed with STREAMWISE_PERIODIC_TEMPERATURE= YES, only MARKER_HEATFLUX & MARKER_SYM.", CURRENT_FUNCTION); if (DiscreteAdjoint && Kind_Streamwise_Periodic == ENUM_STREAMWISE_PERIODIC::MASSFLOW) diff --git a/SU2_CFD/src/SU2_CFD.cpp b/SU2_CFD/src/SU2_CFD.cpp index 0eac518b5c2..99f7003d048 100644 --- a/SU2_CFD/src/SU2_CFD.cpp +++ b/SU2_CFD/src/SU2_CFD.cpp @@ -33,7 +33,7 @@ #endif /* Include file, needed for the runtime NaN catching. You also have to include feenableexcept(...) below. */ -// #include +//#include using namespace std; diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index 2ce47ae1933..bcd03bfa17b 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -57,14 +57,14 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet su2double Edge_Vector[MAXNDIM] = {0.0}; GeometryToolbox::Distance(nDim, Coord_Normal, Coord, Edge_Vector); - const auto dist = GeometryToolbox::Norm(nDim, Edge_Vector); + const su2double dist = GeometryToolbox::Norm(nDim, Edge_Vector); /*--- Retrieve temperature solution and its gradient ---*/ - const auto Twall = donor_solution->GetNodes()->GetTemperature(Point_Donor); - const auto Tnormal = donor_solution->GetNodes()->GetTemperature(PointNormal); + const su2double Twall = donor_solution->GetNodes()->GetTemperature(Point_Donor); + const su2double Tnormal = donor_solution->GetNodes()->GetTemperature(PointNormal); - const auto dTdn = (Twall - Tnormal)/dist; + const su2double dTdn = (Twall - Tnormal)/dist; // TODO: Check if these improve accuracy, if needed at all // const auto Normal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal(); // su2double Area = GeometryToolbox::Norm(nDim, Normal); @@ -76,14 +76,14 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet if (compressible_flow) { - const auto Gamma = donor_config->GetGamma(); - const auto Gas_Constant = donor_config->GetGas_ConstantND(); - const auto Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; + const su2double Gamma = donor_config->GetGamma(); + const su2double Gas_Constant = donor_config->GetGas_ConstantND(); + const su2double Cp = (Gamma / (Gamma - 1.0)) * Gas_Constant; - const auto Prandtl_Lam = donor_config->GetPrandtl_Lam(); - const auto laminar_viscosity = donor_solution->GetNodes()->GetLaminarViscosity(Point_Donor); // TDE check for consistency + const su2double Prandtl_Lam = donor_config->GetPrandtl_Lam(); + const su2double laminar_viscosity = donor_solution->GetNodes()->GetLaminarViscosity(Point_Donor); // TDE check for consistency - const auto thermal_conductivityND = Cp*(laminar_viscosity/Prandtl_Lam); + const su2double thermal_conductivityND = Cp*(laminar_viscosity/Prandtl_Lam); heat_flux_density = thermal_conductivityND*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || @@ -97,7 +97,7 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet const auto iPoint = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNode(); - const auto thermal_conductivityND = donor_solution->GetNodes()->GetThermalConductivity(iPoint); + const su2double thermal_conductivityND = donor_solution->GetNodes()->GetThermalConductivity(iPoint); heat_flux_density = thermal_conductivityND*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || @@ -126,13 +126,13 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet /*--- Heat solver stand-alone case ---*/ - const auto thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); + const su2double thermal_diffusivity = donor_config->GetThermalDiffusivity_Solid(); heat_flux_density = thermal_diffusivity*dTdn; if ((donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::DIRECT_TEMPERATURE_ROBIN_HEATFLUX) || (donor_config->GetKind_CHT_Coupling() == CHT_COUPLING::AVERAGED_TEMPERATURE_ROBIN_HEATFLUX)) { - const auto rho_cp_solid = donor_config->GetSpecific_Heat_Cp()*donor_config->GetDensity_Solid(); + const su2double rho_cp_solid = donor_config->GetSpecific_Heat_Cp()*donor_config->GetDensity_Solid(); conductivity_over_dist = thermal_diffusivity*rho_cp_solid/dist; } } From b38b99009cd40aa1c41349e1b7749bd938e0dd46 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Wed, 2 Jun 2021 12:48:00 +0200 Subject: [PATCH 168/192] Removed debug --- SU2_CFD/src/solvers/CMeshSolver.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CMeshSolver.cpp b/SU2_CFD/src/solvers/CMeshSolver.cpp index b5dc1da6722..c9db520150e 100644 --- a/SU2_CFD/src/solvers/CMeshSolver.cpp +++ b/SU2_CFD/src/solvers/CMeshSolver.cpp @@ -285,7 +285,6 @@ void CMeshSolver::SetMinMaxVolume(CGeometry *geometry, CConfig *config, bool upd AD::EndPassive(wasActive); - geometry->ComputeMeshQualityStatistics(config); // Only used for debug purpose } void CMeshSolver::SetWallDistance(CGeometry *geometry, CConfig *config) { From 0e1e58ff16caae92916e2d850f3186df998a6bc1 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Wed, 2 Jun 2021 14:12:57 +0200 Subject: [PATCH 169/192] Change Multizone TimeRef. Tiny changes in CHTinterface. --- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- .../cht/CConjugateHeatInterface.cpp | 20 +++++++++---------- .../chtMaster.cfg | 2 +- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index b591a75fbd0..421a75dc344 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -145,7 +145,7 @@ void CMultizoneDriver::StartSolver() { for (iZone = 1; iZone < nZone; iZone++) { if (config_container[iZone]->GetTime_Ref() < Time_Ref) - Time_Ref = config_container[iZone]->GetTime_Ref(); // TK:: last TimeRef is used + Time_Ref = min(Time_Ref, config_container[iZone]->GetTime_Ref()); } for (iZone = 0; iZone < nZone; iZone++) { diff --git a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp index bcd03bfa17b..9996f85c410 100644 --- a/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp +++ b/SU2_CFD/src/interfaces/cht/CConjugateHeatInterface.cpp @@ -40,17 +40,8 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet const CConfig *donor_config, unsigned long Marker_Donor, unsigned long Vertex_Donor, unsigned long Point_Donor) { - const auto nDim = donor_geometry->GetnDim(); - - /*--- Check whether the current zone is a solid zone or a fluid zone ---*/ - const bool compressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE); - const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) && donor_config->GetEnergy_Equation(); - - su2double thermal_conductivity = 0.0; - su2double heat_flux_density = 0.0; - su2double conductivity_over_dist = 0.0; - /*--- Compute distance of donor point to PointNormal for T-gradient/heatflux computation ---*/ + const auto nDim = donor_geometry->GetnDim(); const auto Coord = donor_geometry->nodes->GetCoord(Point_Donor); const auto PointNormal = donor_geometry->vertex[Marker_Donor][Vertex_Donor]->GetNormal_Neighbor(); const auto Coord_Normal = donor_geometry->nodes->GetCoord(PointNormal); @@ -72,7 +63,14 @@ void CConjugateHeatInterface::GetDonor_Variable(CSolver *donor_solution, CGeomet // dTdn += (Twall - Tnormal)/dist * (Edge_Vector[iDim]/dist) * (Normal[iDim]/Area); // } - /*--- Calculate the heat flux density (temperature gradient times thermal conductivity) ---*/ + /*--- Calculate the heat flux density (temperature gradient times thermal conductivity) and + thermal conductivity divided by distance. ---*/ + su2double thermal_conductivity = 0.0; + su2double heat_flux_density = 0.0; + su2double conductivity_over_dist = 0.0; + + const bool compressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::COMPRESSIBLE); + const bool incompressible_flow = (donor_config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE) && donor_config->GetEnergy_Equation(); if (compressible_flow) { diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg index 6821416134a..a32ece5723b 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/chtMaster.cfg @@ -44,7 +44,7 @@ SCREEN_WRT_FREQ_OUTER= 50 % HISTORY_OUTPUT= ( ITER, BGS_RES[0], RMS_RES[0], BGS_RES[1], RMS_RES[1],\ FLOW_COEFF[0], HEAT[0], AERO_COEFF[0], HEAT[1],\ - LINSOL[0], LINSOL[1]) + LINSOL[0], LINSOL[1], TAVG_HEAT[1]) % OUTPUT_FILES= (RESTART, PARAVIEW) OUTPUT_WRT_FREQ= 1 From cae07a649ee9d66368cba4d37b7ceaf762f05166 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Wed, 2 Jun 2021 15:54:03 +0200 Subject: [PATCH 170/192] Add CFVMOutput and move CommonOutput there. --- SU2_CFD/include/output/CFVMOutput.hpp | 55 ++++++++++++++++++ SU2_CFD/include/output/CFlowOutput.hpp | 14 +---- SU2_CFD/include/output/CHeatOutput.hpp | 4 +- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- SU2_CFD/src/meson.build | 1 + SU2_CFD/src/output/CFVMOutput.cpp | 71 ++++++++++++++++++++++++ SU2_CFD/src/output/CFlowOutput.cpp | 38 +------------ SU2_CFD/src/output/CHeatOutput.cpp | 20 +------ 8 files changed, 136 insertions(+), 69 deletions(-) create mode 100644 SU2_CFD/include/output/CFVMOutput.hpp create mode 100644 SU2_CFD/src/output/CFVMOutput.cpp diff --git a/SU2_CFD/include/output/CFVMOutput.hpp b/SU2_CFD/include/output/CFVMOutput.hpp new file mode 100644 index 00000000000..6b9c4c39380 --- /dev/null +++ b/SU2_CFD/include/output/CFVMOutput.hpp @@ -0,0 +1,55 @@ +/*! + * \file CFlowOutput.hpp + * \brief Headers of the Finite Volume Method output. + * \author T. Kattmann + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#pragma once + +#include "COutput.hpp" + +class CFVMOutput : public COutput{ +public: + /*! + * \brief Constructor of the class + */ + CFVMOutput(CConfig *config, unsigned short nDim, bool femOutput); + + /*! + * \brief Destructor of the class. + */ + ~CFVMOutput(void) override; + +protected: + + /*! + * \brief Add common FVM outputs. + */ + void AddCommonFVMOutputs(const CConfig* config); + + /*! + * \brief Load common FVM outputs. + */ + void LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint); +}; diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index 8e15d607ae1..b5665420442 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -27,10 +27,10 @@ #pragma once -#include "COutput.hpp" +#include "CFVMOutput.hpp" #include "../variables/CVariable.hpp" -class CFlowOutput : public COutput{ +class CFlowOutput : public CFVMOutput{ public: /*! * \brief Constructor of the class @@ -142,14 +142,4 @@ class CFlowOutput : public COutput{ */ void LoadTimeAveragedData(unsigned long iPoint, CVariable *node_flow); - /*! - * \brief Add common FVM outputs. - */ - void AddCommonFVMOutputs(const CConfig* config); - - /*! - * \brief Load common FVM outputs. - */ - void LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint); - }; diff --git a/SU2_CFD/include/output/CHeatOutput.hpp b/SU2_CFD/include/output/CHeatOutput.hpp index cb9b2b1b0f4..279d5658ad8 100644 --- a/SU2_CFD/include/output/CHeatOutput.hpp +++ b/SU2_CFD/include/output/CHeatOutput.hpp @@ -27,7 +27,7 @@ #pragma once -#include "COutput.hpp" +#include "CFVMOutput.hpp" /*! \class CHeatOutput @@ -35,7 +35,7 @@ * \author R. Sanchez, T. Albring. * \date June 5, 2018. */ -class CHeatOutput final: public COutput { +class CHeatOutput final: public CFVMOutput { public: /*! diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 421a75dc344..cb904f1a143 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -139,7 +139,7 @@ CMultizoneDriver::~CMultizoneDriver(void) { void CMultizoneDriver::StartSolver() { /*--- Find out the minimum of all references times and then set each zone to this (same) value. - * (To ensure that all zones run synchronously in time, be it a dimensional or non-dimensionalized one.) ---*/ + To ensure that all zones run synchronously in time, be it a dimensional or non-dimensionalized one. ---*/ su2double Time_Ref = config_container[ZONE_0]->GetTime_Ref(); diff --git a/SU2_CFD/src/meson.build b/SU2_CFD/src/meson.build index ee288818ef4..736100a1b81 100644 --- a/SU2_CFD/src/meson.build +++ b/SU2_CFD/src/meson.build @@ -21,6 +21,7 @@ su2_cfd_src += files(['output/COutputFactory.cpp', 'output/CElasticityOutput.cpp', 'output/CFlowCompOutput.cpp', 'output/CFlowCompFEMOutput.cpp', + 'output/CFVMOutput.cpp', 'output/CFlowOutput.cpp', 'output/CFlowIncOutput.cpp', 'output/CHeatOutput.cpp', diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp new file mode 100644 index 00000000000..91ce6cb1afa --- /dev/null +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -0,0 +1,71 @@ +/*! + * \file output_flow.cpp + * \brief Main subroutines for Finite Volume Method output + * \author T. Kattmann + * \version 7.1.1 "Blackbird" + * + * SU2 Project Website: https://su2code.github.io + * + * The SU2 Project is maintained by the SU2 Foundation + * (http://su2foundation.org) + * + * Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md) + * + * SU2 is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * SU2 is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with SU2. If not, see . + */ + +#include "../../include/output/CFVMOutput.hpp" +#include "../../../Common/include/geometry/CGeometry.hpp" + + +CFVMOutput::CFVMOutput(CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ } + +CFVMOutput::~CFVMOutput(void){ } + +void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { + + // Mesh quality metrics + AddVolumeOutput("ORTHOGONALITY", "Orthogonality", "MESH_QUALITY", "Orthogonality Angle (deg.)"); + AddVolumeOutput("ASPECT_RATIO", "Aspect_Ratio", "MESH_QUALITY", "CV Face Area Aspect Ratio"); + AddVolumeOutput("VOLUME_RATIO", "Volume_Ratio", "MESH_QUALITY", "CV Sub-Volume Ratio"); + + AddVolumeOutput("RANK", "rank", "MPI", "Rank of the MPI-partition"); + + for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); ++iMesh) { + stringstream key, name; + key << "MG_" << iMesh; + name << "Coarse_Grid_" << iMesh; + AddVolumeOutput(key.str(), name.str(), "MULTIGRID", "Coarse mesh"); + } +} + +void CFVMOutput::LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint) { + + // Mesh quality metrics, computed in CPhysicalGeometry::ComputeMeshQualityStatistics. + if (config->GetWrt_MeshQuality()) { + SetVolumeOutputValue("ORTHOGONALITY", iPoint, geometry->Orthogonality[iPoint]); + SetVolumeOutputValue("ASPECT_RATIO", iPoint, geometry->Aspect_Ratio[iPoint]); + SetVolumeOutputValue("VOLUME_RATIO", iPoint, geometry->Volume_Ratio[iPoint]); + } + + SetVolumeOutputValue("RANK", iPoint, rank); + + if (config->GetWrt_MultiGrid()) { + for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); ++iMesh) { + stringstream key; + key << "MG_" << iMesh; + SetVolumeOutputValue(key.str(), iPoint, geometry->CoarseGridColor(iPoint,iMesh-1)); + } + } +} diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 815b400b13a..57967e29df0 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -30,11 +30,10 @@ #include "../../../Common/include/toolboxes/geometry_toolbox.hpp" #include "../../include/solvers/CSolver.hpp" -CFlowOutput::CFlowOutput(CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ +CFlowOutput::CFlowOutput(CConfig *config, unsigned short nDim, bool fem_output) : CFVMOutput (config, nDim, fem_output){ } - CFlowOutput::~CFlowOutput(void){} void CFlowOutput::AddAnalyzeSurfaceOutput(CConfig *config){ @@ -2735,41 +2734,6 @@ bool CFlowOutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool f return false || force_writing; } -void CFlowOutput::AddCommonFVMOutputs(const CConfig *config) { - - AddVolumeOutput("ORTHOGONALITY", "Orthogonality", "MESH_QUALITY", "Orthogonality Angle (deg.)"); - AddVolumeOutput("ASPECT_RATIO", "Aspect_Ratio", "MESH_QUALITY", "CV Face Area Aspect Ratio"); - AddVolumeOutput("VOLUME_RATIO", "Volume_Ratio", "MESH_QUALITY", "CV Sub-Volume Ratio"); - - AddVolumeOutput("RANK", "rank", "MPI", "Rank of the MPI-partition"); - - for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); ++iMesh) { - stringstream key, name; - key << "MG_" << iMesh; - name << "Coarse_Grid_" << iMesh; - AddVolumeOutput(key.str(), name.str(), "MULTIGRID", "Coarse mesh"); - } -} - -void CFlowOutput::LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint) { - - if (config->GetWrt_MeshQuality()) { - SetVolumeOutputValue("ORTHOGONALITY", iPoint, geometry->Orthogonality[iPoint]); - SetVolumeOutputValue("ASPECT_RATIO", iPoint, geometry->Aspect_Ratio[iPoint]); - SetVolumeOutputValue("VOLUME_RATIO", iPoint, geometry->Volume_Ratio[iPoint]); - } - - SetVolumeOutputValue("RANK", iPoint, rank); - - if (config->GetWrt_MultiGrid()) { - for (auto iMesh = 1u; iMesh <= config->GetnMGLevels(); ++iMesh) { - stringstream key; - key << "MG_" << iMesh; - SetVolumeOutputValue(key.str(), iPoint, geometry->CoarseGridColor(iPoint,iMesh-1)); - } - } -} - void CFlowOutput::SetTimeAveragedFields(){ AddVolumeOutput("MEAN_DENSITY", "MeanDensity", "TIME_AVERAGE", "Mean density"); AddVolumeOutput("MEAN_VELOCITY-X", "MeanVelocity_x", "TIME_AVERAGE", "Mean velocity x-component"); diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index 831c2afa98b..41b782b06f0 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -30,7 +30,7 @@ #include "../../../Common/include/geometry/CGeometry.hpp" #include "../../include/solvers/CSolver.hpp" -CHeatOutput::CHeatOutput(CConfig *config, unsigned short nDim) : COutput(config, nDim, false) { +CHeatOutput::CHeatOutput(CConfig *config, unsigned short nDim) : CFVMOutput(config, nDim, false) { multiZone = config->GetMultizone_Problem(); @@ -131,13 +131,7 @@ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ // Residuals AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); - // Mesh quality metrics, computed in CPhysicalGeometry::ComputeMeshQualityStatistics. - AddVolumeOutput("ORTHOGONALITY", "Orthogonality", "MESH_QUALITY", "Orthogonality Angle (deg.)"); - AddVolumeOutput("ASPECT_RATIO", "Aspect_Ratio", "MESH_QUALITY", "CV Face Area Aspect Ratio"); - AddVolumeOutput("VOLUME_RATIO", "Volume_Ratio", "MESH_QUALITY", "CV Sub-Volume Ratio"); - - // MPI-Rank - AddVolumeOutput("RANK", "rank", "MPI", "Rank of the MPI-partition"); + AddCommonFVMOutputs(config); } @@ -158,15 +152,7 @@ void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver * // Residuals SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes(iPoint, 0)); - // Mesh quality metrics - if (config->GetWrt_MeshQuality()) { - SetVolumeOutputValue("ORTHOGONALITY", iPoint, geometry->Orthogonality[iPoint]); - SetVolumeOutputValue("ASPECT_RATIO", iPoint, geometry->Aspect_Ratio[iPoint]); - SetVolumeOutputValue("VOLUME_RATIO", iPoint, geometry->Volume_Ratio[iPoint]); - } - - // MPI-Rank - SetVolumeOutputValue("RANK", iPoint, rank); + LoadCommonFVMOutputs(config, geometry, iPoint); } void CHeatOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ From 43e369083ef778805b7533ea82158f59b6a8fe7f Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Wed, 2 Jun 2021 18:06:12 +0200 Subject: [PATCH 171/192] Add Coord-XYZ to fresh CFVMOutput and therefore remove that from individual FVM outputs. --- SU2_CFD/src/output/CFVMOutput.cpp | 14 ++++++++++++++ SU2_CFD/src/output/CFlowCompOutput.cpp | 20 +++++--------------- SU2_CFD/src/output/CFlowIncOutput.cpp | 19 +++++-------------- SU2_CFD/src/output/CHeatOutput.cpp | 23 ++++++----------------- SU2_CFD/src/output/CNEMOCompOutput.cpp | 20 +++++--------------- 5 files changed, 35 insertions(+), 61 deletions(-) diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index 91ce6cb1afa..05062753bf8 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -35,6 +35,12 @@ CFVMOutput::~CFVMOutput(void){ } void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES","z-component of the coordinate vector"); + // Mesh quality metrics AddVolumeOutput("ORTHOGONALITY", "Orthogonality", "MESH_QUALITY", "Orthogonality Angle (deg.)"); AddVolumeOutput("ASPECT_RATIO", "Aspect_Ratio", "MESH_QUALITY", "CV Face Area Aspect Ratio"); @@ -52,6 +58,14 @@ void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { void CFVMOutput::LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint) { + CPoint* Node_Geo = geometry->nodes; + + // Grid coordinates + SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); + SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + // Mesh quality metrics, computed in CPhysicalGeometry::ComputeMeshQualityStatistics. if (config->GetWrt_MeshQuality()) { SetVolumeOutputValue("ORTHOGONALITY", iPoint, geometry->Orthogonality[iPoint]); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 5f053a80275..ea1774488fb 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -290,11 +290,8 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ - // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + // Coordinates, Mesh quality metrics + AddCommonFVMOutputs(config); // Solution variables AddVolumeOutput("DENSITY", "Density", "SOLUTION", "Density"); @@ -422,8 +419,6 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("Q_CRITERION", "Q_Criterion", "VORTEX_IDENTIFICATION", "Value of the Q-Criterion"); } - AddCommonFVMOutputs(config); - if (config->GetTime_Domain()){ SetTimeAveragedFields(); } @@ -433,17 +428,14 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = nullptr; + CPoint* Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - CPoint* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + // Coordinates, Mesh quality metrics + LoadCommonFVMOutputs(config, geometry, iPoint); SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("MOMENTUM-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); @@ -568,8 +560,6 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(&(Node_Flow->GetGradient_Primitive(iPoint)[1]))); } - LoadCommonFVMOutputs(config, geometry, iPoint); - if (config->GetTime_Domain()){ LoadTimeAveragedData(iPoint, Node_Flow); } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 229d61f866c..27ed587dfbb 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -372,11 +372,8 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ - // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + // Coordinates, Mesh quality metrics + AddCommonFVMOutputs(config); // SOLUTION variables AddVolumeOutput("PRESSURE", "Pressure", "SOLUTION", "Pressure"); @@ -512,7 +509,6 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("RECOVERED_TEMPERATURE", "Recovered_Temperature", "SOLUTION", "Recovered physical temperature"); } - AddCommonFVMOutputs(config); } void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ @@ -521,6 +517,7 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve CVariable* Node_Heat = nullptr; CVariable* Node_Turb = nullptr; CVariable* Node_Rad = nullptr; + CPoint* Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); @@ -529,12 +526,8 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve Node_Heat = solver[HEAT_SOL]->GetNodes(); } - CPoint* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + // Coordinates, Mesh quality metrics + LoadCommonFVMOutputs(config, geometry, iPoint); SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); @@ -665,8 +658,6 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (heat && streamwisePeriodic_temperature) SetVolumeOutputValue("RECOVERED_TEMPERATURE", iPoint, Node_Flow->GetStreamwise_Periodic_RecoveredTemperature(iPoint)); } - - LoadCommonFVMOutputs(config, geometry, iPoint); } void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index 41b782b06f0..beb4a2b9cde 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -116,13 +116,10 @@ void CHeatOutput::SetHistoryOutputFields(CConfig *config){ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ - // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES","z-component of the coordinate vector"); + // Coordinates, Mesh quality metrics + AddCommonFVMOutputs(config); - // SOLUTION + // Solution AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature"); // Primitives @@ -130,29 +127,21 @@ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ // Residuals AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); - - AddCommonFVMOutputs(config); } void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ CVariable* Node_Heat = solver[HEAT_SOL]->GetNodes(); - CPoint* Node_Geo = geometry->nodes; - // Grid coordinates - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + // Coordinates, Mesh quality metrics + LoadCommonFVMOutputs(config, geometry, iPoint); - // SOLUTION + // Solution SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); // Residuals SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes(iPoint, 0)); - - LoadCommonFVMOutputs(config, geometry, iPoint); } void CHeatOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 291127f4e08..45b5d183e10 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -295,11 +295,8 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ unsigned short nSpecies = config->GetnSpecies(); - // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + // Coordinates, Mesh quality metrics + AddCommonFVMOutputs(config); // Solution variables for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) @@ -427,8 +424,6 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("VORTICITY_Z", "Vorticity_z", "VORTEX_IDENTIFICATION", "z-component of the vorticity vector"); } - AddCommonFVMOutputs(config); - if (config->GetTime_Domain()){ SetTimeAveragedFields(); } @@ -438,18 +433,15 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = NULL; + auto* Node_Geo = geometry->nodes; unsigned short nSpecies = config->GetnSpecies(); if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - auto* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + // Coordinates, Mesh quality metrics + LoadCommonFVMOutputs(config, geometry, iPoint); for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) SetVolumeOutputValue("DENSITY_" + std::to_string(iSpecies), iPoint, Node_Flow->GetSolution(iPoint, iSpecies)); @@ -565,8 +557,6 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation(iPoint)); } - LoadCommonFVMOutputs(config, geometry, iPoint); - if (config->GetTime_Domain()){ LoadTimeAveragedData(iPoint, Node_Flow); } From 2ee6fed32ccc7f0033d1d9b210e786e1e64cd128 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi Date: Wed, 2 Jun 2021 18:17:00 +0200 Subject: [PATCH 172/192] Be sure that coupling starts immediately when restarting --- SU2_PY/FSI_tools/FSI_config.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SU2_PY/FSI_tools/FSI_config.py b/SU2_PY/FSI_tools/FSI_config.py index aad28ff0ee1..6a1dc3f88d0 100644 --- a/SU2_PY/FSI_tools/FSI_config.py +++ b/SU2_PY/FSI_tools/FSI_config.py @@ -122,3 +122,6 @@ def applyDefaults(self): if self._ConfigContent["CSD_SOLVER"] == "IMPOSED": self._ConfigContent["AITKEN_RELAX"] = "STATIC" self._ConfigContent["AITKEN_PARAM"] = 1.0 + + if self._ConfigContent["RESTART_SOL"] == "YES": + self._ConfigContent["TIME_TRESHOLD"] = -1 From bd952cf26349abc6001ae5fb43a3420e2ea7cb47 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Wed, 2 Jun 2021 18:40:56 +0200 Subject: [PATCH 173/192] Fix doxygen filenames for output folder. --- .../output/{CAdjFlowOutput.hpp => CAdjFlowCompOutput.hpp} | 0 SU2_CFD/include/output/CAdjHeatOutput.hpp | 2 +- SU2_CFD/include/output/CFVMOutput.hpp | 2 +- SU2_CFD/include/output/CFlowIncOutput.hpp | 4 ++-- SU2_CFD/include/output/CMeshOutput.hpp | 2 +- SU2_CFD/include/output/CMultizoneOutput.hpp | 6 +++--- SU2_CFD/include/output/COutputFactory.hpp | 2 +- SU2_CFD/include/output/COutputLegacy.hpp | 4 ++-- SU2_CFD/src/output/CAdjFlowCompOutput.cpp | 4 ++-- SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 2 +- SU2_CFD/src/output/CAdjHeatOutput.cpp | 2 +- SU2_CFD/src/output/CBaselineOutput.cpp | 2 +- SU2_CFD/src/output/CElasticityOutput.cpp | 2 +- SU2_CFD/src/output/CFVMOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompFEMOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 2 +- SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- SU2_CFD/src/output/CFlowOutput.cpp | 2 +- SU2_CFD/src/output/CHeatOutput.cpp | 2 +- SU2_CFD/src/output/CMeshOutput.cpp | 2 +- SU2_CFD/src/output/COutput.cpp | 2 +- SU2_CFD/src/output/COutputFactory.cpp | 2 +- SU2_CFD/src/output/output_structure_legacy.cpp | 2 +- 23 files changed, 27 insertions(+), 27 deletions(-) rename SU2_CFD/include/output/{CAdjFlowOutput.hpp => CAdjFlowCompOutput.hpp} (100%) diff --git a/SU2_CFD/include/output/CAdjFlowOutput.hpp b/SU2_CFD/include/output/CAdjFlowCompOutput.hpp similarity index 100% rename from SU2_CFD/include/output/CAdjFlowOutput.hpp rename to SU2_CFD/include/output/CAdjFlowCompOutput.hpp diff --git a/SU2_CFD/include/output/CAdjHeatOutput.hpp b/SU2_CFD/include/output/CAdjHeatOutput.hpp index 5b5586591de..2102be9ad84 100644 --- a/SU2_CFD/include/output/CAdjHeatOutput.hpp +++ b/SU2_CFD/include/output/CAdjHeatOutput.hpp @@ -1,5 +1,5 @@ /*! - * \file output_fea_discadj.hpp + * \file CAdjHeatOutput.hpp * \brief Headers of the adjoint heat output. * \author T. Albring * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/include/output/CFVMOutput.hpp b/SU2_CFD/include/output/CFVMOutput.hpp index 6b9c4c39380..324e089d3cc 100644 --- a/SU2_CFD/include/output/CFVMOutput.hpp +++ b/SU2_CFD/include/output/CFVMOutput.hpp @@ -1,5 +1,5 @@ /*! - * \file CFlowOutput.hpp + * \file CFVMOutput.hpp * \brief Headers of the Finite Volume Method output. * \author T. Kattmann * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index af106a33093..9e1618c697e 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -1,5 +1,5 @@ -/*! - * \file CFlowIncCompOutput.hpp +/*! + * \file CFlowIncOutput.hpp * \brief Headers of the incompressible flow output. * \author T. Albring, R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/include/output/CMeshOutput.hpp b/SU2_CFD/include/output/CMeshOutput.hpp index 5c736090c4c..34c01ebc435 100644 --- a/SU2_CFD/include/output/CMeshOutput.hpp +++ b/SU2_CFD/include/output/CMeshOutput.hpp @@ -1,6 +1,6 @@ /*! * \file CMeshOutput.hpp - * \brief Headers of the mesh output. + * \brief Headers of the mesh output. * \author R. Sanchez, T. Albring. * \version 7.1.1 "Blackbird" * diff --git a/SU2_CFD/include/output/CMultizoneOutput.hpp b/SU2_CFD/include/output/CMultizoneOutput.hpp index 1be5ea3e753..28ff8d1b555 100644 --- a/SU2_CFD/include/output/CMultizoneOutput.hpp +++ b/SU2_CFD/include/output/CMultizoneOutput.hpp @@ -1,5 +1,5 @@ /*! - * \file CDriverOutput.hpp + * \file CMultizoneOutput.hpp * \brief Headers of the main subroutines for screen and history output in multizone problems. * \author R. Sanchez, T. Albring * \version 7.1.1 "Blackbird" @@ -44,7 +44,7 @@ using namespace std; /*! - * \class CDriverOutput + * \class CMultizoneOutput * \brief Class for writing the multizone output. * \author R. Sanchez, T. Albring. */ @@ -53,7 +53,7 @@ class CMultizoneOutput final: public COutput { protected: unsigned short nZone; //!< Number of zones - string bgs_res_name; //!< Block-Gauss seidel residual name + string bgs_res_name; //!< Block-Gauss Seidel residual name bool write_zone; //!< Boolean indicating whether the individual zones write to screen public: diff --git a/SU2_CFD/include/output/COutputFactory.hpp b/SU2_CFD/include/output/COutputFactory.hpp index 3e659e97954..0aa2dd25e45 100644 --- a/SU2_CFD/include/output/COutputFactory.hpp +++ b/SU2_CFD/include/output/COutputFactory.hpp @@ -1,5 +1,5 @@ /*! - * \file COutput.hpp + * \file COutputFactory.hpp * \brief Headers of the output class. * \author T.Albring * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/include/output/COutputLegacy.hpp b/SU2_CFD/include/output/COutputLegacy.hpp index fbf334a66ca..9f34d8e4529 100644 --- a/SU2_CFD/include/output/COutputLegacy.hpp +++ b/SU2_CFD/include/output/COutputLegacy.hpp @@ -1,7 +1,7 @@ /*! - * \file output.hpp + * \file COutputLegacy.hpp * \brief Headers of the main subroutines for generating the file outputs. - * The subroutines and functions are in the output_structure.cpp file. + * The subroutines and functions are in the output_structure_legacy.cpp file. * \author F. Palacios, T. Economon, M. Colonno * \version 7.1.1 "Blackbird" * diff --git a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp index 6d5db2133b2..2cf99b95e39 100644 --- a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_adj_flow_comp.cpp + * \file CAdjFlowCompOutput.cpp * \brief Main subroutines for flow discrete adjoint output * \author R. Sanchez * \version 7.1.1 "Blackbird" @@ -26,7 +26,7 @@ */ -#include "../../include/output/CAdjFlowOutput.hpp" +#include "../../include/output/CAdjFlowCompOutput.hpp" #include "../../../Common/include/geometry/CGeometry.hpp" #include "../../include/solvers/CSolver.hpp" diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index f51f0e6c795..8bcec5adeb9 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_adj_flow_inc.cpp + * \file CAdjFlowIncOutput.cpp * \brief Main subroutines for flow discrete adjoint output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CAdjHeatOutput.cpp b/SU2_CFD/src/output/CAdjHeatOutput.cpp index 3c3cbd0cabd..0570f97ad68 100644 --- a/SU2_CFD/src/output/CAdjHeatOutput.cpp +++ b/SU2_CFD/src/output/CAdjHeatOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_adj_heat.cpp + * \file CAdjHeatOutput.cpp * \brief Main subroutines for flow discrete adjoint output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CBaselineOutput.cpp b/SU2_CFD/src/output/CBaselineOutput.cpp index a37004c092f..253ac5d432b 100644 --- a/SU2_CFD/src/output/CBaselineOutput.cpp +++ b/SU2_CFD/src/output/CBaselineOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_baseline.cpp + * \file CBaselineOutput.cpp * \brief Main subroutines for flow discrete adjoint output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index 55d2f9f84a0..c48dab833db 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_elasticity.cpp + * \file CElasticityOutput.cpp * \brief Main subroutines for FEA output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index 05062753bf8..4b4b2a4c123 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_flow.cpp + * \file CFVMOutput.cpp * \brief Main subroutines for Finite Volume Method output * \author T. Kattmann * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp index 91cade8a86c..5eb60cbe660 100644 --- a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_flow_comp_fem.cpp + * \file CFlowCompFEMOutput.cpp * \brief Main subroutines for compressible flow output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index ea1774488fb..25eb63ff145 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_flow_comp.cpp + * \file CFlowCompOutput.cpp * \brief Main subroutines for compressible flow output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 27ed587dfbb..b5c56efea40 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_flow_inc.cpp + * \file CFlowIncOutput.cpp * \brief Main subroutines for incompressible flow output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 57967e29df0..27d5d78fec4 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_flow.cpp + * \file CFlowOutput.cpp * \brief Main subroutines for compressible flow output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index beb4a2b9cde..fd71b45a775 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_heat.cpp + * \file CHeatOutput.cpp * \brief Main subroutines for the heat solver output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/CMeshOutput.cpp b/SU2_CFD/src/output/CMeshOutput.cpp index ea2969ecbd2..5b27d3e7bbe 100644 --- a/SU2_CFD/src/output/CMeshOutput.cpp +++ b/SU2_CFD/src/output/CMeshOutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_mesh.cpp + * \file CMeshOutput.cpp * \brief Main subroutines for the heat solver output * \author R. Sanchez * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index efc29fe036e..fe736fbccb9 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -1,5 +1,5 @@ /*! - * \file output_structure.cpp + * \file COutput.cpp * \brief Main subroutines for output solver information * \author F. Palacios, T. Economon * \version 7.1.1 "Blackbird" diff --git a/SU2_CFD/src/output/COutputFactory.cpp b/SU2_CFD/src/output/COutputFactory.cpp index 2feb4cd3ac3..5814c85767b 100644 --- a/SU2_CFD/src/output/COutputFactory.cpp +++ b/SU2_CFD/src/output/COutputFactory.cpp @@ -33,7 +33,7 @@ #include "../../include/output/CAdjElasticityOutput.hpp" #include "../../include/output/CFlowCompOutput.hpp" #include "../../include/output/CNEMOCompOutput.hpp" -#include "../../include/output/CAdjFlowOutput.hpp" +#include "../../include/output/CAdjFlowCompOutput.hpp" #include "../../include/output/CFlowCompFEMOutput.hpp" #include "../../include/output/CFlowIncOutput.hpp" #include "../../include/output/CAdjFlowIncOutput.hpp" diff --git a/SU2_CFD/src/output/output_structure_legacy.cpp b/SU2_CFD/src/output/output_structure_legacy.cpp index acfa5d7f1b5..fc65caa3aeb 100644 --- a/SU2_CFD/src/output/output_structure_legacy.cpp +++ b/SU2_CFD/src/output/output_structure_legacy.cpp @@ -1,5 +1,5 @@ /*! - * \file output_structure.cpp + * \file output_structure_legacy.cpp * \brief Main subroutines for output solver information * \author F. Palacios, T. Economon * \version 7.1.1 "Blackbird" From 4ce75faa977cbfc9f200be322602c56c7130bfdc Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sat, 5 Jun 2021 18:28:38 +0200 Subject: [PATCH 174/192] Revert some autos into su2double, for safety you know --- SU2_CFD/src/solvers/CHeatSolver.cpp | 2 +- SU2_CFD/src/solvers/CIncNSSolver.cpp | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/SU2_CFD/src/solvers/CHeatSolver.cpp b/SU2_CFD/src/solvers/CHeatSolver.cpp index 7c2015de1f4..e31233ae6e4 100644 --- a/SU2_CFD/src/solvers/CHeatSolver.cpp +++ b/SU2_CFD/src/solvers/CHeatSolver.cpp @@ -1281,7 +1281,7 @@ void CHeatSolver::ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_ if (nodes->GetDelta_Time(iPoint) != 0.0) { // Identical for flow and heat - const auto Delta = geometry->nodes->GetVolume(iPoint) / nodes->GetDelta_Time(iPoint); + const su2double Delta = geometry->nodes->GetVolume(iPoint) / nodes->GetDelta_Time(iPoint); Jacobian.AddVal2Diag(iPoint, Delta); } else { diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index c085b8b629d..de5cc3090d7 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -145,9 +145,9 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- A = dot_prod(n_A*n_A), with n_A beeing the area-normal. ---*/ - const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + const su2double* AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); + const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); /*--- m_dot = dot_prod(n*v) * A * rho, with n beeing unit normal. ---*/ MassFlow_Local += nodes->GetProjVel(iPoint, AreaNormal) * nodes->GetDensity(iPoint); @@ -232,7 +232,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- Identify the boundary by string name and retrive heatflux from config ---*/ const auto Marker_StringTag = config->GetMarker_All_TagBound(iMarker); - const auto Wall_HeatFlux = config->GetWall_HeatFlux(Marker_StringTag); + const su2double Wall_HeatFlux = config->GetWall_HeatFlux(Marker_StringTag); for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -240,9 +240,9 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (!geometry->nodes->GetDomain(iPoint)) continue; - const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + const su2double* AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); - auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); + const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();; } // loop Vertices @@ -393,7 +393,7 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con /*--- Compute dual-grid area and boundary normal ---*/ - const auto Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); + const su2double* Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); const su2double Area = GeometryToolbox::Norm(nDim, Normal); @@ -447,12 +447,12 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con } else { // ISOTHERMAL - auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); /*--- Get coordinates of i & nearest normal and compute distance ---*/ - auto Coord_i = geometry->nodes->GetCoord(iPoint); - auto Coord_j = geometry->nodes->GetCoord(Point_Normal); + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + const su2double* Coord_j = geometry->nodes->GetCoord(Point_Normal); su2double Edge_Vector[MAXNDIM]; GeometryToolbox::Distance(nDim, Coord_j, Coord_i, Edge_Vector); su2double dist_ij_2 = GeometryToolbox::SquaredNorm(nDim, Edge_Vector); @@ -557,12 +557,12 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol /*--- Compute closest normal neighbor ---*/ - auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); /*--- Get coordinates of i & nearest normal and compute distance ---*/ - auto Coord_i = geometry->nodes->GetCoord(iPoint); - auto Coord_j = geometry->nodes->GetCoord(Point_Normal); + const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); + const su2double* Coord_j = geometry->nodes->GetCoord(Point_Normal); su2double dist_ij = GeometryToolbox::Distance(nDim, Coord_j, Coord_i); /*--- Compute wall temperature from both temperatures ---*/ From 07a1b34d131c9c5f7280ed5426858e9fe679492b Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sat, 5 Jun 2021 18:31:58 +0200 Subject: [PATCH 175/192] Little changes to unst CHT grad validation files --- .../gradient_validation.py | 6 +++++- .../postprocess.py | 21 +++++++++++++++---- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py index 003f742ce09..9751520d2be 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/gradient_validation.py @@ -80,7 +80,7 @@ adjoint.addExpected("solution_adj_avtp_1_00053.dat") # gradient projection -dot = adjont = ExternalRun("DOT",dot_ad_command,True) +dot = ExternalRun("DOT",dot_ad_command,True) dot.setMaxTries(max_tries) dot.addConfig("chtMaster.cfg") dot.addData("fluid.cfg") # zonal cfg's can be symlinked @@ -106,6 +106,7 @@ # Driver --------------------------------------------------------------- # +# The input variable is the constraint tolerance which is not used for our purpose of finite differences driver = ExteriorPenaltyDriver(0.005) driver.addObjective("min", tavgT) @@ -120,6 +121,7 @@ # Primal simulation for each deformed DV for iLoop in range(0, nDV, 1): + print("Computing deformed primal ", iLoop, "/", nDV-1) x = driver.getInitial() x[iLoop] = 1e-4 # DV_VALUE driver.fun(x) @@ -127,10 +129,12 @@ # Undeformed/initial primal last in order to have the correct solution in # the WorkindDirectory for the following adjoint +print("Computing baseline primal") x = driver.getInitial() driver.fun(x) # baseline evaluation # Compute discrete adjoint gradient +print("Computing discrete adjoint gradient") driver.grad(x) his.close() diff --git a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py index 8e59310c1a9..bcbe8a7ba2d 100644 --- a/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py +++ b/TestCases/coupled_cht/disc_adj_unsteadyCHT_cylinder/postprocess.py @@ -10,17 +10,30 @@ FDvals = pd.read_csv("doe.his") # additional values +nDV = 18 FDstep = 1e-4 FDstring = ' tavgT' DAstring = 'AVG_TEMPERATURE gradient ' # create FD gradient -FDgrad = (FDvals[FDstring].iloc[:18] - FDvals[FDstring].iloc[18]) / FDstep +FDgrad = (FDvals[FDstring].iloc[:nDV] - FDvals[FDstring].iloc[nDV]) / FDstep # absolute difference absoluteDiff = DAgrad[DAstring] - FDgrad -print("DAgrad - FDgrad\n", absoluteDiff) +print("absolute diff = DAgrad - FDgrad") # relative difference in percent -relDiffPercent = abs(DAgrad[DAstring] - FDgrad)/DAgrad[DAstring] * 100 -print("(DAgrad - FDgrad) / DAgrad * 100\n", relDiffPercent) +relDiffPercent = (DAgrad[DAstring] - FDgrad)/abs(DAgrad[DAstring]) * 100 +print("relative diff = (DAgrad - FDgrad) / abs(DAgrad) * 100") + + +print('') +print('+-----------+-------------------+-------------------+-------------------+-------------------+') +print('| DV number | DA gradient | FD gradient | absolute diff | relative diff [%] |') +print('+-----------+-------------------+-------------------+-------------------+-------------------+') + +for i_dv in range(0, nDV,1): + print('|{0:10d} |{1:18.10f} |{2:18.10f} |{3:18.10f} |{4:18.10f} |'.format(i_dv, DAgrad[DAstring].iloc[i_dv], FDgrad[i_dv], absoluteDiff[i_dv], relDiffPercent[i_dv])) + +print('+-----------+-------------------+-------------------+-------------------+-------------------+') +print('') From 41109fe6956e392a31133fc399edc4bbbe569fc0 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sat, 5 Jun 2021 20:05:00 +0200 Subject: [PATCH 176/192] Adress PR review comments: readding autos and stuff in CFVMOutput. --- SU2_CFD/include/output/CFVMOutput.hpp | 6 ++---- SU2_CFD/obj/Makefile.am | 1 + SU2_CFD/src/output/CFVMOutput.cpp | 2 -- SU2_CFD/src/solvers/CIncNSSolver.cpp | 16 ++++++++-------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/SU2_CFD/include/output/CFVMOutput.hpp b/SU2_CFD/include/output/CFVMOutput.hpp index 324e089d3cc..7eed4f54b75 100644 --- a/SU2_CFD/include/output/CFVMOutput.hpp +++ b/SU2_CFD/include/output/CFVMOutput.hpp @@ -30,7 +30,7 @@ #include "COutput.hpp" class CFVMOutput : public COutput{ -public: +protected: /*! * \brief Constructor of the class */ @@ -39,9 +39,7 @@ class CFVMOutput : public COutput{ /*! * \brief Destructor of the class. */ - ~CFVMOutput(void) override; - -protected: + ~CFVMOutput(void) = default; /*! * \brief Add common FVM outputs. diff --git a/SU2_CFD/obj/Makefile.am b/SU2_CFD/obj/Makefile.am index 5f7975302eb..6b7f7854ac9 100644 --- a/SU2_CFD/obj/Makefile.am +++ b/SU2_CFD/obj/Makefile.am @@ -136,6 +136,7 @@ libSU2Core_sources = ../src/definition_structure.cpp \ ../src/output/output_physics.cpp \ ../src/output/CMeshOutput.cpp \ ../src/output/CElasticityOutput.cpp \ + ../src/output/CFVMOutput.cpp \ ../src/output/CFlowOutput.cpp \ ../src/output/CFlowCompOutput.cpp \ ../src/output/CFlowCompFEMOutput.cpp \ diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index 4b4b2a4c123..c1d3101d356 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -31,8 +31,6 @@ CFVMOutput::CFVMOutput(CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ } -CFVMOutput::~CFVMOutput(void){ } - void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { // Grid coordinates diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index de5cc3090d7..6a564e5f111 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -145,7 +145,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, /*--- A = dot_prod(n_A*n_A), with n_A beeing the area-normal. ---*/ - const su2double* AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); @@ -240,7 +240,7 @@ void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry, if (!geometry->nodes->GetDomain(iPoint)) continue; - const su2double* AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); + const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal(); const su2double FaceArea = GeometryToolbox::Norm(nDim, AreaNormal); @@ -265,7 +265,7 @@ void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const auto InnerIter = config->GetInnerIter(); /*--- Reference node on inlet periodic marker to compute relative distance along periodic translation vector. ---*/ - const su2double* ReferenceNode = geometry->GetStreamwise_Periodic_RefNode(); + const auto ReferenceNode = geometry->GetStreamwise_Periodic_RefNode(); /*--- Compute square of the distance between the 2 periodic surfaces. ---*/ const su2double norm2_translation = GeometryToolbox::SquaredNorm(nDim, config->GetPeriodic_Translation(0)); @@ -393,7 +393,7 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con /*--- Compute dual-grid area and boundary normal ---*/ - const su2double* Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); + const auto Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); const su2double Area = GeometryToolbox::Norm(nDim, Normal); @@ -451,8 +451,8 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con /*--- Get coordinates of i & nearest normal and compute distance ---*/ - const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); - const su2double* Coord_j = geometry->nodes->GetCoord(Point_Normal); + const auto Coord_i = geometry->nodes->GetCoord(iPoint); + const auto Coord_j = geometry->nodes->GetCoord(Point_Normal); su2double Edge_Vector[MAXNDIM]; GeometryToolbox::Distance(nDim, Coord_j, Coord_i, Edge_Vector); su2double dist_ij_2 = GeometryToolbox::SquaredNorm(nDim, Edge_Vector); @@ -561,8 +561,8 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol /*--- Get coordinates of i & nearest normal and compute distance ---*/ - const su2double* Coord_i = geometry->nodes->GetCoord(iPoint); - const su2double* Coord_j = geometry->nodes->GetCoord(Point_Normal); + const auto Coord_i = geometry->nodes->GetCoord(iPoint); + const auto Coord_j = geometry->nodes->GetCoord(Point_Normal); su2double dist_ij = GeometryToolbox::Distance(nDim, Coord_j, Coord_i); /*--- Compute wall temperature from both temperatures ---*/ From 9b6ae985471cc0f4e39e2bf1411bca4967255e6f Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sat, 5 Jun 2021 20:06:19 +0200 Subject: [PATCH 177/192] Revert "Add Coord-XYZ to fresh CFVMOutput and therefore remove that from individual FVM outputs." This reverts commit 43e369083ef778805b7533ea82158f59b6a8fe7f. --- SU2_CFD/src/output/CFVMOutput.cpp | 14 -------------- SU2_CFD/src/output/CFlowCompOutput.cpp | 20 +++++++++++++++----- SU2_CFD/src/output/CFlowIncOutput.cpp | 19 ++++++++++++++----- SU2_CFD/src/output/CHeatOutput.cpp | 23 +++++++++++++++++------ SU2_CFD/src/output/CNEMOCompOutput.cpp | 20 +++++++++++++++----- 5 files changed, 61 insertions(+), 35 deletions(-) diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index c1d3101d356..831a26d5d97 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -33,12 +33,6 @@ CFVMOutput::CFVMOutput(CConfig *config, unsigned short nDim, bool fem_output) : void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { - // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES","z-component of the coordinate vector"); - // Mesh quality metrics AddVolumeOutput("ORTHOGONALITY", "Orthogonality", "MESH_QUALITY", "Orthogonality Angle (deg.)"); AddVolumeOutput("ASPECT_RATIO", "Aspect_Ratio", "MESH_QUALITY", "CV Face Area Aspect Ratio"); @@ -56,14 +50,6 @@ void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { void CFVMOutput::LoadCommonFVMOutputs(const CConfig* config, const CGeometry* geometry, unsigned long iPoint) { - CPoint* Node_Geo = geometry->nodes; - - // Grid coordinates - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); - // Mesh quality metrics, computed in CPhysicalGeometry::ComputeMeshQualityStatistics. if (config->GetWrt_MeshQuality()) { SetVolumeOutputValue("ORTHOGONALITY", iPoint, geometry->Orthogonality[iPoint]); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 25eb63ff145..e5774e0de41 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -290,8 +290,11 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ - // Coordinates, Mesh quality metrics - AddCommonFVMOutputs(config); + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); // Solution variables AddVolumeOutput("DENSITY", "Density", "SOLUTION", "Density"); @@ -419,6 +422,8 @@ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("Q_CRITERION", "Q_Criterion", "VORTEX_IDENTIFICATION", "Value of the Q-Criterion"); } + AddCommonFVMOutputs(config); + if (config->GetTime_Domain()){ SetTimeAveragedFields(); } @@ -428,14 +433,17 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = nullptr; - CPoint* Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - // Coordinates, Mesh quality metrics - LoadCommonFVMOutputs(config, geometry, iPoint); + CPoint* Node_Geo = geometry->nodes; + + SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); + SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("MOMENTUM-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); @@ -560,6 +568,8 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("Q_CRITERION", iPoint, GetQ_Criterion(&(Node_Flow->GetGradient_Primitive(iPoint)[1]))); } + LoadCommonFVMOutputs(config, geometry, iPoint); + if (config->GetTime_Domain()){ LoadTimeAveragedData(iPoint, Node_Flow); } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index b5c56efea40..a688a9b865c 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -372,8 +372,11 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ - // Coordinates, Mesh quality metrics - AddCommonFVMOutputs(config); + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); // SOLUTION variables AddVolumeOutput("PRESSURE", "Pressure", "SOLUTION", "Pressure"); @@ -509,6 +512,7 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("RECOVERED_TEMPERATURE", "Recovered_Temperature", "SOLUTION", "Recovered physical temperature"); } + AddCommonFVMOutputs(config); } void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ @@ -517,7 +521,6 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve CVariable* Node_Heat = nullptr; CVariable* Node_Turb = nullptr; CVariable* Node_Rad = nullptr; - CPoint* Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); @@ -526,8 +529,12 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve Node_Heat = solver[HEAT_SOL]->GetNodes(); } - // Coordinates, Mesh quality metrics - LoadCommonFVMOutputs(config, geometry, iPoint); + CPoint* Node_Geo = geometry->nodes; + + SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); + SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); @@ -658,6 +665,8 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve if (heat && streamwisePeriodic_temperature) SetVolumeOutputValue("RECOVERED_TEMPERATURE", iPoint, Node_Flow->GetStreamwise_Periodic_RecoveredTemperature(iPoint)); } + + LoadCommonFVMOutputs(config, geometry, iPoint); } void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index fd71b45a775..32cc43bdd41 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -116,10 +116,13 @@ void CHeatOutput::SetHistoryOutputFields(CConfig *config){ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ - // Coordinates, Mesh quality metrics - AddCommonFVMOutputs(config); + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES","z-component of the coordinate vector"); - // Solution + // SOLUTION AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature"); // Primitives @@ -127,21 +130,29 @@ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ // Residuals AddVolumeOutput("RES_TEMPERATURE", "Residual_Temperature", "RESIDUAL", "Residual of the temperature"); + + AddCommonFVMOutputs(config); } void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ CVariable* Node_Heat = solver[HEAT_SOL]->GetNodes(); + CPoint* Node_Geo = geometry->nodes; - // Coordinates, Mesh quality metrics - LoadCommonFVMOutputs(config, geometry, iPoint); + // Grid coordinates + SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); + SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); - // Solution + // SOLUTION SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); // Residuals SetVolumeOutputValue("RES_TEMPERATURE", iPoint, solver[HEAT_SOL]->LinSysRes(iPoint, 0)); + + LoadCommonFVMOutputs(config, geometry, iPoint); } void CHeatOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint, unsigned short iMarker, unsigned long iVertex){ diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 45b5d183e10..291127f4e08 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -295,8 +295,11 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ unsigned short nSpecies = config->GetnSpecies(); - // Coordinates, Mesh quality metrics - AddCommonFVMOutputs(config); + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); // Solution variables for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) @@ -424,6 +427,8 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("VORTICITY_Z", "Vorticity_z", "VORTEX_IDENTIFICATION", "z-component of the vorticity vector"); } + AddCommonFVMOutputs(config); + if (config->GetTime_Domain()){ SetTimeAveragedFields(); } @@ -433,15 +438,18 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = NULL; - auto* Node_Geo = geometry->nodes; unsigned short nSpecies = config->GetnSpecies(); if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - // Coordinates, Mesh quality metrics - LoadCommonFVMOutputs(config, geometry, iPoint); + auto* Node_Geo = geometry->nodes; + + SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); + SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) SetVolumeOutputValue("DENSITY_" + std::to_string(iSpecies), iPoint, Node_Flow->GetSolution(iPoint, iSpecies)); @@ -557,6 +565,8 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("ROE_DISSIPATION", iPoint, Node_Flow->GetRoe_Dissipation(iPoint)); } + LoadCommonFVMOutputs(config, geometry, iPoint); + if (config->GetTime_Domain()){ LoadTimeAveragedData(iPoint, Node_Flow); } From 1ebee477e09f2e3c43b3c51a920a9d4961ffc96f Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sun, 6 Jun 2021 00:28:58 +0200 Subject: [PATCH 178/192] AddCoordinates routine for CFVMOutput --- SU2_CFD/include/output/CFVMOutput.hpp | 10 ++++++++++ SU2_CFD/include/output/CHeatOutput.hpp | 2 +- SU2_CFD/src/output/CFVMOutput.cpp | 17 +++++++++++++++++ SU2_CFD/src/output/CFlowCompOutput.cpp | 13 +++---------- SU2_CFD/src/output/CFlowIncOutput.cpp | 13 +++---------- SU2_CFD/src/output/CHeatOutput.cpp | 12 +++--------- SU2_CFD/src/output/CNEMOCompOutput.cpp | 13 +++---------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/SU2_CFD/include/output/CFVMOutput.hpp b/SU2_CFD/include/output/CFVMOutput.hpp index 7eed4f54b75..15769487cb4 100644 --- a/SU2_CFD/include/output/CFVMOutput.hpp +++ b/SU2_CFD/include/output/CFVMOutput.hpp @@ -41,6 +41,16 @@ class CFVMOutput : public COutput{ */ ~CFVMOutput(void) = default; + /*! + * \brief Add Coordinates to output. + */ + void AddCoordinates(); + + /*! + * \brief Load the coordinates. + */ + void LoadCoordinates(const su2double* Coord, const unsigned long iPoint); + /*! * \brief Add common FVM outputs. */ diff --git a/SU2_CFD/include/output/CHeatOutput.hpp b/SU2_CFD/include/output/CHeatOutput.hpp index 279d5658ad8..06f37d1a334 100644 --- a/SU2_CFD/include/output/CHeatOutput.hpp +++ b/SU2_CFD/include/output/CHeatOutput.hpp @@ -1,6 +1,6 @@ /*! * \file CHeatOutput.hpp - * \brief Headers of the heat output. + * \brief Headers of the heat output. * \author R. Sanchez, T. Albring. * \version 7.1.1 "Blackbird" * diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index 831a26d5d97..d530cd2f13e 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -31,6 +31,23 @@ CFVMOutput::CFVMOutput(CConfig *config, unsigned short nDim, bool fem_output) : COutput (config, nDim, fem_output){ } +void CFVMOutput::AddCoordinates() { + + // Grid coordinates + AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); + AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); + if (nDim == 3) + AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); +} + +void CFVMOutput::LoadCoordinates(const su2double* Coord, const unsigned long iPoint) { + + SetVolumeOutputValue("COORD-X", iPoint, Coord[0]); + SetVolumeOutputValue("COORD-Y", iPoint, Coord[1]); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Coord[2]); +} + void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { // Mesh quality metrics diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index e5774e0de41..0126222cf4e 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -291,10 +291,7 @@ void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ void CFlowCompOutput::SetVolumeOutputFields(CConfig *config){ // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + AddCoordinates(); // Solution variables AddVolumeOutput("DENSITY", "Density", "SOLUTION", "Density"); @@ -433,17 +430,13 @@ void CFlowCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = nullptr; + const auto Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - CPoint* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + LoadCoordinates(Node_Geo->GetCoord(iPoint), iPoint); SetVolumeOutputValue("DENSITY", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("MOMENTUM-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index a688a9b865c..57398f448e8 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -373,10 +373,7 @@ void CFlowIncOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSolv void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + AddCoordinates(); // SOLUTION variables AddVolumeOutput("PRESSURE", "Pressure", "SOLUTION", "Pressure"); @@ -521,6 +518,7 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve CVariable* Node_Heat = nullptr; CVariable* Node_Turb = nullptr; CVariable* Node_Rad = nullptr; + const auto Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); @@ -529,12 +527,7 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve Node_Heat = solver[HEAT_SOL]->GetNodes(); } - CPoint* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + LoadCoordinates(Node_Geo->GetCoord(iPoint), iPoint); SetVolumeOutputValue("PRESSURE", iPoint, Node_Flow->GetSolution(iPoint, 0)); SetVolumeOutputValue("VELOCITY-X", iPoint, Node_Flow->GetSolution(iPoint, 1)); diff --git a/SU2_CFD/src/output/CHeatOutput.cpp b/SU2_CFD/src/output/CHeatOutput.cpp index 32cc43bdd41..0e277da5787 100644 --- a/SU2_CFD/src/output/CHeatOutput.cpp +++ b/SU2_CFD/src/output/CHeatOutput.cpp @@ -117,10 +117,7 @@ void CHeatOutput::SetHistoryOutputFields(CConfig *config){ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES","z-component of the coordinate vector"); + AddCoordinates(); // SOLUTION AddVolumeOutput("TEMPERATURE", "Temperature", "SOLUTION", "Temperature"); @@ -138,13 +135,10 @@ void CHeatOutput::SetVolumeOutputFields(CConfig *config){ void CHeatOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolver **solver, unsigned long iPoint){ CVariable* Node_Heat = solver[HEAT_SOL]->GetNodes(); - CPoint* Node_Geo = geometry->nodes; + const auto Node_Geo = geometry->nodes; // Grid coordinates - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + LoadCoordinates(Node_Geo->GetCoord(iPoint), iPoint); // SOLUTION SetVolumeOutputValue("TEMPERATURE", iPoint, Node_Heat->GetSolution(iPoint, 0)); diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 291127f4e08..779b72aa86a 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -296,10 +296,7 @@ void CNEMOCompOutput::SetVolumeOutputFields(CConfig *config){ unsigned short nSpecies = config->GetnSpecies(); // Grid coordinates - AddVolumeOutput("COORD-X", "x", "COORDINATES", "x-component of the coordinate vector"); - AddVolumeOutput("COORD-Y", "y", "COORDINATES", "y-component of the coordinate vector"); - if (nDim == 3) - AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); + AddCoordinates(); // Solution variables for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) @@ -439,17 +436,13 @@ void CNEMOCompOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolv CVariable* Node_Flow = solver[FLOW_SOL]->GetNodes(); CVariable* Node_Turb = NULL; unsigned short nSpecies = config->GetnSpecies(); + const auto Node_Geo = geometry->nodes; if (config->GetKind_Turb_Model() != NONE){ Node_Turb = solver[TURB_SOL]->GetNodes(); } - auto* Node_Geo = geometry->nodes; - - SetVolumeOutputValue("COORD-X", iPoint, Node_Geo->GetCoord(iPoint, 0)); - SetVolumeOutputValue("COORD-Y", iPoint, Node_Geo->GetCoord(iPoint, 1)); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Node_Geo->GetCoord(iPoint, 2)); + LoadCoordinates(Node_Geo->GetCoord(iPoint), iPoint); for(iSpecies = 0; iSpecies < nSpecies; iSpecies++) SetVolumeOutputValue("DENSITY_" + std::to_string(iSpecies), iPoint, Node_Flow->GetSolution(iPoint, iSpecies)); From 034eb5af3f8e041366f8f80a7b07c02f3c62ac19 Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Sun, 6 Jun 2021 00:29:35 +0200 Subject: [PATCH 179/192] TimeRef multizoneDriver --- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index cb904f1a143..635abc330f5 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -142,11 +142,8 @@ void CMultizoneDriver::StartSolver() { To ensure that all zones run synchronously in time, be it a dimensional or non-dimensionalized one. ---*/ su2double Time_Ref = config_container[ZONE_0]->GetTime_Ref(); - - for (iZone = 1; iZone < nZone; iZone++) { - if (config_container[iZone]->GetTime_Ref() < Time_Ref) - Time_Ref = min(Time_Ref, config_container[iZone]->GetTime_Ref()); - } + for (iZone = 1; iZone < nZone; iZone++) + Time_Ref = min(Time_Ref, config_container[iZone]->GetTime_Ref()); for (iZone = 0; iZone < nZone; iZone++) { From cd175e6ce032377511a8cb131f4fb430cc83b175 Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:17:37 +0200 Subject: [PATCH 180/192] Multizone TimeRef update 1/2 Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 635abc330f5..8704da027e5 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -141,7 +141,7 @@ void CMultizoneDriver::StartSolver() { /*--- Find out the minimum of all references times and then set each zone to this (same) value. To ensure that all zones run synchronously in time, be it a dimensional or non-dimensionalized one. ---*/ - su2double Time_Ref = config_container[ZONE_0]->GetTime_Ref(); + su2double Time_Ref = std::numeric_limits::max(); for (iZone = 1; iZone < nZone; iZone++) Time_Ref = min(Time_Ref, config_container[iZone]->GetTime_Ref()); From f52092def27941c42ddc9ef17fc9dd4f4dee5995 Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:17:50 +0200 Subject: [PATCH 181/192] Multizone TimeRef update 2/2 Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/drivers/CMultizoneDriver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/drivers/CMultizoneDriver.cpp b/SU2_CFD/src/drivers/CMultizoneDriver.cpp index 8704da027e5..ea5af8b5945 100644 --- a/SU2_CFD/src/drivers/CMultizoneDriver.cpp +++ b/SU2_CFD/src/drivers/CMultizoneDriver.cpp @@ -142,7 +142,7 @@ void CMultizoneDriver::StartSolver() { To ensure that all zones run synchronously in time, be it a dimensional or non-dimensionalized one. ---*/ su2double Time_Ref = std::numeric_limits::max(); - for (iZone = 1; iZone < nZone; iZone++) + for (iZone = 0; iZone < nZone; iZone++) Time_Ref = min(Time_Ref, config_container[iZone]->GetTime_Ref()); for (iZone = 0; iZone < nZone; iZone++) { From e5f6d4fbab764be32c4ae2b816bc3da04f224fc3 Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:20:01 +0200 Subject: [PATCH 182/192] Templated input Coord to CFVMOutput::LoadCoordinates 1/2 Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/src/output/CFVMOutput.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/SU2_CFD/src/output/CFVMOutput.cpp b/SU2_CFD/src/output/CFVMOutput.cpp index d530cd2f13e..364f1f357eb 100644 --- a/SU2_CFD/src/output/CFVMOutput.cpp +++ b/SU2_CFD/src/output/CFVMOutput.cpp @@ -40,13 +40,6 @@ void CFVMOutput::AddCoordinates() { AddVolumeOutput("COORD-Z", "z", "COORDINATES", "z-component of the coordinate vector"); } -void CFVMOutput::LoadCoordinates(const su2double* Coord, const unsigned long iPoint) { - - SetVolumeOutputValue("COORD-X", iPoint, Coord[0]); - SetVolumeOutputValue("COORD-Y", iPoint, Coord[1]); - if (nDim == 3) - SetVolumeOutputValue("COORD-Z", iPoint, Coord[2]); -} void CFVMOutput::AddCommonFVMOutputs(const CConfig *config) { From 80f8a3e62ac3819672b75aa3a29ef75694f23a22 Mon Sep 17 00:00:00 2001 From: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Date: Sun, 6 Jun 2021 17:20:14 +0200 Subject: [PATCH 183/192] Templated input Coord to CFVMOutput::LoadCoordinates 2/2 Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/output/CFVMOutput.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/output/CFVMOutput.hpp b/SU2_CFD/include/output/CFVMOutput.hpp index 15769487cb4..7e7da9e7a38 100644 --- a/SU2_CFD/include/output/CFVMOutput.hpp +++ b/SU2_CFD/include/output/CFVMOutput.hpp @@ -49,7 +49,13 @@ class CFVMOutput : public COutput{ /*! * \brief Load the coordinates. */ - void LoadCoordinates(const su2double* Coord, const unsigned long iPoint); + template + inline void LoadCoordinates(const T& Coord, const unsigned long iPoint) { + SetVolumeOutputValue("COORD-X", iPoint, Coord[0]); + SetVolumeOutputValue("COORD-Y", iPoint, Coord[1]); + if (nDim == 3) + SetVolumeOutputValue("COORD-Z", iPoint, Coord[2]); + } /*! * \brief Add common FVM outputs. From 1771391e4f771f7ce684977cb05d7675fd75844b Mon Sep 17 00:00:00 2001 From: TobiKattmann Date: Thu, 18 Mar 2021 22:42:57 +0100 Subject: [PATCH 184/192] Move unsteady CHT regression test to tutorials.py. --- TestCases/parallel_regression.py | 13 ------------- TestCases/serial_regression.py | 13 ------------- TestCases/tutorials.py | 14 ++++++++++++++ 3 files changed, 14 insertions(+), 26 deletions(-) diff --git a/TestCases/parallel_regression.py b/TestCases/parallel_regression.py index 54728bb237a..77faa7d3ecf 100644 --- a/TestCases/parallel_regression.py +++ b/TestCases/parallel_regression.py @@ -1252,19 +1252,6 @@ def main(): cht_incompressible.tol = 0.00001 test_list.append(cht_incompressible) - # CHT incompressible unsteady - cht_incompressible_unsteady = TestCase('cht_incompressible_unsteady') - cht_incompressible_unsteady.cfg_dir = "coupled_cht/incomp_2d_unsteady" - cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg" - cht_incompressible_unsteady.test_iter = 2 - cht_incompressible_unsteady.test_vals = [-1.305471, -0.080372, -0.080376, -0.080372] #last 4 columns - cht_incompressible_unsteady.su2_exec = "mpirun -n 2 SU2_CFD" - cht_incompressible_unsteady.timeout = 1600 - cht_incompressible_unsteady.multizone = True - cht_incompressible_unsteady.unsteady = True - cht_incompressible_unsteady.tol = 0.00001 - test_list.append(cht_incompressible_unsteady) - # CHT compressible cht_compressible = TestCase('cht_compressible') cht_compressible.cfg_dir = "coupled_cht/comp_2d" diff --git a/TestCases/serial_regression.py b/TestCases/serial_regression.py index 6a715ac5478..040d9fba020 100644 --- a/TestCases/serial_regression.py +++ b/TestCases/serial_regression.py @@ -1416,19 +1416,6 @@ def main(): cht_incompressible.tol = 0.00001 test_list.append(cht_incompressible) - # CHT incompressible unsteady - cht_incompressible_unsteady = TestCase('cht_incompressible_unsteady') - cht_incompressible_unsteady.cfg_dir = "coupled_cht/incomp_2d_unsteady" - cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg" - cht_incompressible_unsteady.test_iter = 2 - cht_incompressible_unsteady.test_vals = [-1.303588, -0.080377, -0.080380, -0.080377] #last 4 columns - cht_incompressible_unsteady.su2_exec = "SU2_CFD" - cht_incompressible_unsteady.timeout = 1600 - cht_incompressible_unsteady.multizone = True - cht_incompressible_unsteady.unsteady = True - cht_incompressible_unsteady.tol = 0.00001 - test_list.append(cht_incompressible_unsteady) - # CHT compressible cht_incompressible = TestCase('cht_compressible') cht_incompressible.cfg_dir = "coupled_cht/comp_2d" diff --git a/TestCases/tutorials.py b/TestCases/tutorials.py index 8ae969d93c7..01bf850b4e2 100644 --- a/TestCases/tutorials.py +++ b/TestCases/tutorials.py @@ -42,6 +42,20 @@ def main(): ### RUN TUTORIAL CASES ### ###################################### + + # CHT incompressible unsteady + cht_incompressible_unsteady = TestCase('cht_incompressible_unsteady') + cht_incompressible_unsteady.cfg_dir = "../Tutorials/multiphysics/unsteady_cht/" + cht_incompressible_unsteady.cfg_file = "cht_2d_3cylinders.cfg" + cht_incompressible_unsteady.test_iter = 2 + cht_incompressible_unsteady.test_vals = [-2.659390, -2.533160, -0.080399, -0.080399, -0.080399, -12.421450, 0.0000e+00, 0.0000e+00, 2.3824e+02] #last 9 columns + cht_incompressible_unsteady.su2_exec = "mpirun -n 2 SU2_CFD" + cht_incompressible_unsteady.timeout = 1600 + cht_incompressible_unsteady.multizone = True + cht_incompressible_unsteady.unsteady = True + cht_incompressible_unsteady.tol = 0.00001 + test_list.append(cht_incompressible_unsteady) + ### Incompressible Flow # 2D pin case massflow periodic with heatflux BC and prescribed extracted outlet heat From 747b2b7ccd3ef889a4d3a0837590fcb3022b27f4 Mon Sep 17 00:00:00 2001 From: Nicola-Fonzi <60700515+Nicola-Fonzi@users.noreply.github.com> Date: Thu, 10 Jun 2021 16:51:19 +0200 Subject: [PATCH 185/192] Addressing comment from reviewer Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> --- SU2_CFD/include/drivers/CDriver.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SU2_CFD/include/drivers/CDriver.hpp b/SU2_CFD/include/drivers/CDriver.hpp index edc5e1b6d6a..f6890b53a09 100644 --- a/SU2_CFD/include/drivers/CDriver.hpp +++ b/SU2_CFD/include/drivers/CDriver.hpp @@ -525,7 +525,11 @@ class CDriver { * \param[in] iVertex - Vertex identifier. * \return Unit normal (vector) at the vertex. */ - vector GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal) const; + vector GetVertexNormal(unsigned short iMarker, unsigned long iVertex, bool unitNormal = false) const; + + inline vector GetVertexUnitNormal(unsigned short iMarker, unsigned long iVertex) const { + return GetVertexNormal(iMarker, iVertex, true); + } /*! * \brief Get all the boundary markers tags. From bc686349493f95bc3ef5fa5f4d3eb8c6075cb5d7 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 12 Jun 2021 10:53:14 +0100 Subject: [PATCH 186/192] conversion of AoS to radians and some cleanup --- SU2_CFD/include/output/CAdjFlowCompOutput.hpp | 2 +- SU2_CFD/include/output/CAdjFlowIncOutput.hpp | 2 +- SU2_CFD/include/output/CElasticityOutput.hpp | 2 +- SU2_CFD/include/output/CFlowCompFEMOutput.hpp | 2 +- SU2_CFD/include/output/CFlowCompOutput.hpp | 19 +---- SU2_CFD/include/output/CFlowIncOutput.hpp | 2 +- SU2_CFD/include/output/CFlowOutput.hpp | 18 +++-- SU2_CFD/include/output/CMultizoneOutput.hpp | 6 +- SU2_CFD/include/output/CNEMOCompOutput.hpp | 20 +---- SU2_CFD/include/output/COutput.hpp | 19 +++-- SU2_CFD/src/output/CAdjFlowCompOutput.cpp | 2 +- SU2_CFD/src/output/CAdjFlowIncOutput.cpp | 2 +- SU2_CFD/src/output/CElasticityOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompFEMOutput.cpp | 2 +- SU2_CFD/src/output/CFlowCompOutput.cpp | 51 +------------ SU2_CFD/src/output/CFlowIncOutput.cpp | 2 +- SU2_CFD/src/output/CFlowOutput.cpp | 46 +++++++++++- SU2_CFD/src/output/CMultizoneOutput.cpp | 6 +- SU2_CFD/src/output/CNEMOCompOutput.cpp | 49 +----------- SU2_CFD/src/output/COutput.cpp | 14 ++-- SU2_CFD/src/solvers/CEulerSolver.cpp | 74 +++++++++---------- 21 files changed, 130 insertions(+), 212 deletions(-) diff --git a/SU2_CFD/include/output/CAdjFlowCompOutput.hpp b/SU2_CFD/include/output/CAdjFlowCompOutput.hpp index d18e6aa462c..1c6f2db616d 100644 --- a/SU2_CFD/include/output/CAdjFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowCompOutput.hpp @@ -97,6 +97,6 @@ class CAdjFlowCompOutput final: public COutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp index e4c974b68c1..02f40204347 100644 --- a/SU2_CFD/include/output/CAdjFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CAdjFlowIncOutput.hpp @@ -100,6 +100,6 @@ class CAdjFlowIncOutput final: public COutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CElasticityOutput.hpp b/SU2_CFD/include/output/CElasticityOutput.hpp index b79ad3df54a..00792c68899 100644 --- a/SU2_CFD/include/output/CElasticityOutput.hpp +++ b/SU2_CFD/include/output/CElasticityOutput.hpp @@ -87,6 +87,6 @@ class CElasticityOutput final: public COutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp index 748be9c21a8..063cb3499f4 100644 --- a/SU2_CFD/include/output/CFlowCompFEMOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompFEMOutput.hpp @@ -101,6 +101,6 @@ class CFlowCompFEMOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowCompOutput.hpp b/SU2_CFD/include/output/CFlowCompOutput.hpp index 7af5d70a6a6..fde484afbfd 100644 --- a/SU2_CFD/include/output/CFlowCompOutput.hpp +++ b/SU2_CFD/include/output/CFlowCompOutput.hpp @@ -40,7 +40,6 @@ class CFlowCompOutput final: public CFlowOutput { private: unsigned short turb_model; //!< Kind of turbulence model - unsigned long lastInnerIter; public: @@ -50,12 +49,6 @@ class CFlowCompOutput final: public CFlowOutput { */ CFlowCompOutput(CConfig *config, unsigned short nDim); - /*! - * \brief Destructor of the class. - */ - ~CFlowCompOutput(void) override; - - /*! * \brief Load the history output field values * \param[in] config - Definition of the particular problem. @@ -100,23 +93,17 @@ class CFlowCompOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; /*! * \brief Write any additional output defined for the current solver. * \param[in] config - Definition of the particular problem per zone. */ - void SetAdditionalScreenOutput(CConfig *config) override; - - /*! - * \brief Write additional output for fixed CL mode. - * \param[in] config - Definition of the particular problem per zone. - */ - void SetFixedCLScreenOutput(CConfig *config); + void SetAdditionalScreenOutput(const CConfig *config) override; /*! * \brief Determines if the history file output. * \param[in] config - Definition of the particular problem. */ - bool WriteHistoryFile_Output(CConfig *config) override; + bool WriteHistoryFile_Output(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowIncOutput.hpp b/SU2_CFD/include/output/CFlowIncOutput.hpp index 9e1618c697e..338060bb4eb 100644 --- a/SU2_CFD/include/output/CFlowIncOutput.hpp +++ b/SU2_CFD/include/output/CFlowIncOutput.hpp @@ -102,6 +102,6 @@ class CFlowIncOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CFlowOutput.hpp b/SU2_CFD/include/output/CFlowOutput.hpp index b5665420442..81168fb872d 100644 --- a/SU2_CFD/include/output/CFlowOutput.hpp +++ b/SU2_CFD/include/output/CFlowOutput.hpp @@ -31,19 +31,15 @@ #include "../variables/CVariable.hpp" class CFlowOutput : public CFVMOutput{ -public: +protected: + unsigned long lastInnerIter; + /*! * \brief Constructor of the class * \param[in] config - Definition of the particular problem. */ CFlowOutput(CConfig *config, unsigned short nDim, bool femOutput); - /*! - * \brief Destructor of the class. - */ - ~CFlowOutput(void) override; - -protected: /*! * \brief Add flow surface output fields * \param[in] config - Definition of the particular problem. @@ -104,7 +100,7 @@ class CFlowOutput : public CFVMOutput{ * \brief Write information to meta data file * \param[in] config - Definition of the particular problem per zone. */ - void WriteMetaData(CConfig *config); + void WriteMetaData(const CConfig *config); /*! * \brief Write any additional files defined for the current solver. @@ -142,4 +138,10 @@ class CFlowOutput : public CFVMOutput{ */ void LoadTimeAveragedData(unsigned long iPoint, CVariable *node_flow); + /*! + * \brief Write additional output for fixed CL mode. + * \param[in] config - Definition of the particular problem per zone. + */ + void SetFixedCLScreenOutput(const CConfig *config); + }; diff --git a/SU2_CFD/include/output/CMultizoneOutput.hpp b/SU2_CFD/include/output/CMultizoneOutput.hpp index 28ff8d1b555..537fc7baf61 100644 --- a/SU2_CFD/include/output/CMultizoneOutput.hpp +++ b/SU2_CFD/include/output/CMultizoneOutput.hpp @@ -86,17 +86,17 @@ class CMultizoneOutput final: public COutput { * \brief Determines if the history file output. * \param[in] config - Definition of the particular problem. */ - bool WriteHistoryFile_Output(CConfig *config) override; + bool WriteHistoryFile_Output(const CConfig *config) override; /*! * \brief Determines if the screen header should be written. * \param[in] config - Definition of the particular problem. */ - bool WriteScreen_Header(CConfig *config) override; + bool WriteScreen_Header(const CConfig *config) override; /*! * \brief Determines if the screen header should be written. * \param[in] config - Definition of the particular problem. */ - bool WriteScreen_Output(CConfig *config) override; + bool WriteScreen_Output(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/CNEMOCompOutput.hpp b/SU2_CFD/include/output/CNEMOCompOutput.hpp index 434536cd1c0..517c0d7be6c 100644 --- a/SU2_CFD/include/output/CNEMOCompOutput.hpp +++ b/SU2_CFD/include/output/CNEMOCompOutput.hpp @@ -41,8 +41,6 @@ class CNEMOCompOutput final: public CFlowOutput { unsigned short turb_model, /*!< \brief Kind of turbulence model */ iSpecies, /*!< \brief Species index */ nSpecies; /*!< \brief Number of species */ - unsigned long lastInnerIter; - public: /*! @@ -51,12 +49,6 @@ class CNEMOCompOutput final: public CFlowOutput { */ CNEMOCompOutput(CConfig *config, unsigned short nDim); - /*! - * \brief Destructor of the class. - */ - ~CNEMOCompOutput(void) override; - - /*! * \brief Load the history output field values * \param[in] config - Definition of the particular problem. @@ -101,23 +93,17 @@ class CNEMOCompOutput final: public CFlowOutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - bool SetInit_Residuals(CConfig *config) override; + bool SetInit_Residuals(const CConfig *config) override; /*! * \brief Write any additional output defined for the current solver. * \param[in] config - Definition of the particular problem per zone. */ - void SetAdditionalScreenOutput(CConfig *config) override; - - /*! - * \brief Write additional output for fixed CL mode. - * \param[in] config - Definition of the particular problem per zone. - */ - void SetFixedCLScreenOutput(CConfig *config); + void SetAdditionalScreenOutput(const CConfig *config) override; /*! * \brief Determines if the history file output. * \param[in] config - Definition of the particular problem. */ - bool WriteHistoryFile_Output(CConfig *config) override; + bool WriteHistoryFile_Output(const CConfig *config) override; }; diff --git a/SU2_CFD/include/output/COutput.hpp b/SU2_CFD/include/output/COutput.hpp index 08c8213aa70..403b614fc3e 100644 --- a/SU2_CFD/include/output/COutput.hpp +++ b/SU2_CFD/include/output/COutput.hpp @@ -490,26 +490,25 @@ class COutput { * \brief Set the history file header * \param[in] config - Definition of the particular problem. */ - void SetHistoryFile_Header(CConfig *config); + void SetHistoryFile_Header(const CConfig *config); /*! * \brief Write the history file output * \param[in] config - Definition of the particular problem. */ - void SetHistoryFile_Output(CConfig *config); + void SetHistoryFile_Output(const CConfig *config); /*! * \brief Write the screen header. * \param[in] config - Definition of the particular problem. */ - void SetScreen_Header(CConfig *config); - + void SetScreen_Header(const CConfig *config); /*! * \brief Write the screen output. * \param[in] config - Definition of the particular problem. */ - void SetScreen_Output(CConfig *config); + void SetScreen_Output(const CConfig *config); /*! * \brief Add a new field to the history output. @@ -691,19 +690,19 @@ class COutput { * \brief Determines if the history file output. * \param[in] config - Definition of the particular problem. */ - virtual bool WriteHistoryFile_Output(CConfig *config); + virtual bool WriteHistoryFile_Output(const CConfig *config); /*! * \brief Determines if the screen header should be written. * \param[in] config - Definition of the particular problem. */ - virtual bool WriteScreen_Header(CConfig *config); + virtual bool WriteScreen_Header(const CConfig *config); /*! * \brief Determines if the screen header should be written. * \param[in] config - Definition of the particular problem. */ - virtual bool WriteScreen_Output(CConfig *config); + virtual bool WriteScreen_Output(const CConfig *config); /*! * \brief Determines if the the volume output should be written. @@ -739,7 +738,7 @@ class COutput { * \param[in] config - Definition of the particular problem. * \return if the residuals should be initialized. */ - inline virtual bool SetInit_Residuals(CConfig *config) {return false;} + inline virtual bool SetInit_Residuals(const CConfig *config) {return false;} /*! * \brief Set the values of the volume output fields for a surface point. @@ -798,6 +797,6 @@ class COutput { * \brief Write any additional output defined for the current solver. * \param[in] config - Definition of the particular problem per zone. */ - inline virtual void SetAdditionalScreenOutput(CConfig *config){} + inline virtual void SetAdditionalScreenOutput(const CConfig *config){} }; diff --git a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp index 2cf99b95e39..c5bb5d16ff5 100644 --- a/SU2_CFD/src/output/CAdjFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowCompOutput.cpp @@ -460,7 +460,7 @@ void CAdjFlowCompOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, C } -bool CAdjFlowCompOutput::SetInit_Residuals(CConfig *config){ +bool CAdjFlowCompOutput::SetInit_Residuals(const CConfig *config){ return ((config->GetTime_Marching() != TIME_MARCHING::STEADY) && (curInnerIter == 0)) || ((config->GetTime_Marching() == TIME_MARCHING::STEADY) && (curInnerIter < 2)); diff --git a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp index 8bcec5adeb9..c96e0a54b4a 100644 --- a/SU2_CFD/src/output/CAdjFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CAdjFlowIncOutput.cpp @@ -524,7 +524,7 @@ void CAdjFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CS } -bool CAdjFlowIncOutput::SetInit_Residuals(CConfig *config){ +bool CAdjFlowIncOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curTimeIter < 2)); diff --git a/SU2_CFD/src/output/CElasticityOutput.cpp b/SU2_CFD/src/output/CElasticityOutput.cpp index c48dab833db..1ecc83330b2 100644 --- a/SU2_CFD/src/output/CElasticityOutput.cpp +++ b/SU2_CFD/src/output/CElasticityOutput.cpp @@ -265,7 +265,7 @@ void CElasticityOutput::SetVolumeOutputFields(CConfig *config){ } } -bool CElasticityOutput::SetInit_Residuals(CConfig *config){ +bool CElasticityOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Domain() == NO && (curInnerIter == 0)); diff --git a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp index 5eb60cbe660..3fba86dfbd1 100644 --- a/SU2_CFD/src/output/CFlowCompFEMOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompFEMOutput.cpp @@ -272,7 +272,7 @@ void CFlowCompFEMOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, C } -bool CFlowCompFEMOutput::SetInit_Residuals(CConfig *config){ +bool CFlowCompFEMOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curTimeIter < 2)); diff --git a/SU2_CFD/src/output/CFlowCompOutput.cpp b/SU2_CFD/src/output/CFlowCompOutput.cpp index 0126222cf4e..f4bf29ed537 100644 --- a/SU2_CFD/src/output/CFlowCompOutput.cpp +++ b/SU2_CFD/src/output/CFlowCompOutput.cpp @@ -34,7 +34,6 @@ CFlowCompOutput::CFlowCompOutput(CConfig *config, unsigned short nDim) : CFlowOutput(config, nDim, false) { turb_model = config->GetKind_Turb_Model(); - lastInnerIter = curInnerIter; gridMovement = config->GetDynamic_Grid(); /*--- Set the default history fields if nothing is set in the config file ---*/ @@ -105,10 +104,6 @@ CFlowCompOutput::CFlowCompOutput(CConfig *config, unsigned short nDim) : CFlowOu } } -CFlowCompOutput::~CFlowCompOutput(void) {} - - - void CFlowCompOutput::SetHistoryOutputFields(CConfig *config){ @@ -703,60 +698,20 @@ void CFlowCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol } -bool CFlowCompOutput::SetInit_Residuals(CConfig *config){ +bool CFlowCompOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curInnerIter < 2)); } -void CFlowCompOutput::SetAdditionalScreenOutput(CConfig *config){ +void CFlowCompOutput::SetAdditionalScreenOutput(const CConfig *config){ if (config->GetFixed_CL_Mode()){ SetFixedCLScreenOutput(config); } } -void CFlowCompOutput::SetFixedCLScreenOutput(CConfig *config){ - PrintingToolbox::CTablePrinter FixedCLSummary(&cout); - - if (fabs(historyOutput_Map["CL_DRIVER_COMMAND"].value) > 1e-16){ - FixedCLSummary.AddColumn("Fixed CL Mode", 40); - FixedCLSummary.AddColumn("Value", 30); - FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); - FixedCLSummary.PrintHeader(); - FixedCLSummary << "Current CL" << historyOutput_Map["LIFT"].value; - FixedCLSummary << "Target CL" << config->GetTarget_CL(); - FixedCLSummary << "Previous AOA" << historyOutput_Map["PREV_AOA"].value; - if (config->GetFinite_Difference_Mode()){ - FixedCLSummary << "Changed AoA by (Finite Difference step)" << historyOutput_Map["CL_DRIVER_COMMAND"].value; - lastInnerIter = curInnerIter - 1; - } - else - FixedCLSummary << "Changed AoA by" << historyOutput_Map["CL_DRIVER_COMMAND"].value; - FixedCLSummary.PrintFooter(); - SetScreen_Header(config); - } - - else if (config->GetFinite_Difference_Mode() && historyOutput_Map["AOA"].value == historyOutput_Map["PREV_AOA"].value){ - FixedCLSummary.AddColumn("Fixed CL Mode (Finite Difference)", 40); - FixedCLSummary.AddColumn("Value", 30); - FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); - FixedCLSummary.PrintHeader(); - FixedCLSummary << "Delta CL / Delta AoA" << config->GetdCL_dAlpha(); - FixedCLSummary << "Delta CD / Delta CL" << config->GetdCD_dCL(); - if (nDim == 3){ - FixedCLSummary << "Delta CMx / Delta CL" << config->GetdCMx_dCL(); - FixedCLSummary << "Delta CMy / Delta CL" << config->GetdCMy_dCL(); - } - FixedCLSummary << "Delta CMz / Delta CL" << config->GetdCMz_dCL(); - FixedCLSummary.PrintFooter(); - curInnerIter = lastInnerIter; - WriteMetaData(config); - curInnerIter = config->GetInnerIter(); - } -} - -bool CFlowCompOutput::WriteHistoryFile_Output(CConfig *config) { +bool CFlowCompOutput::WriteHistoryFile_Output(const CConfig *config) { return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFile_Output(config); } diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 57398f448e8..377eeb2e6f7 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -681,7 +681,7 @@ void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolv } -bool CFlowIncOutput::SetInit_Residuals(CConfig *config){ +bool CFlowIncOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curInnerIter < 2)); diff --git a/SU2_CFD/src/output/CFlowOutput.cpp b/SU2_CFD/src/output/CFlowOutput.cpp index 27d5d78fec4..d25a861c8c4 100644 --- a/SU2_CFD/src/output/CFlowOutput.cpp +++ b/SU2_CFD/src/output/CFlowOutput.cpp @@ -32,10 +32,9 @@ CFlowOutput::CFlowOutput(CConfig *config, unsigned short nDim, bool fem_output) : CFVMOutput (config, nDim, fem_output){ + lastInnerIter = curInnerIter; } -CFlowOutput::~CFlowOutput(void){} - void CFlowOutput::AddAnalyzeSurfaceOutput(CConfig *config){ @@ -862,7 +861,7 @@ void CFlowOutput::WriteAdditionalFiles(CConfig *config, CGeometry *geometry, CSo } -void CFlowOutput::WriteMetaData(CConfig *config){ +void CFlowOutput::WriteMetaData(const CConfig *config){ ofstream meta_file; @@ -2710,7 +2709,6 @@ void CFlowOutput::WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSo } - bool CFlowOutput::WriteVolume_Output(CConfig *config, unsigned long Iter, bool force_writing){ if (config->GetTime_Domain()){ @@ -2801,3 +2799,43 @@ void CFlowOutput::LoadTimeAveragedData(unsigned long iPoint, CVariable *Node_Flo SetVolumeOutputValue("VWPRIME", iPoint, -(vmean*wmean - vwmean)); } } + +void CFlowOutput::SetFixedCLScreenOutput(const CConfig *config){ + PrintingToolbox::CTablePrinter FixedCLSummary(&cout); + + if (fabs(historyOutput_Map["CL_DRIVER_COMMAND"].value) > 1e-16){ + FixedCLSummary.AddColumn("Fixed CL Mode", 40); + FixedCLSummary.AddColumn("Value", 30); + FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); + FixedCLSummary.PrintHeader(); + FixedCLSummary << "Current CL" << historyOutput_Map["LIFT"].value; + FixedCLSummary << "Target CL" << config->GetTarget_CL(); + FixedCLSummary << "Previous AOA" << historyOutput_Map["PREV_AOA"].value; + if (config->GetFinite_Difference_Mode()){ + FixedCLSummary << "Changed AoA by (Finite Difference step)" << historyOutput_Map["CL_DRIVER_COMMAND"].value; + lastInnerIter = curInnerIter - 1; + } + else + FixedCLSummary << "Changed AoA by" << historyOutput_Map["CL_DRIVER_COMMAND"].value; + FixedCLSummary.PrintFooter(); + SetScreen_Header(config); + } + + else if (config->GetFinite_Difference_Mode() && historyOutput_Map["AOA"].value == historyOutput_Map["PREV_AOA"].value){ + FixedCLSummary.AddColumn("Fixed CL Mode (Finite Difference)", 40); + FixedCLSummary.AddColumn("Value", 30); + FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); + FixedCLSummary.PrintHeader(); + FixedCLSummary << "Delta CL / Delta AoA" << config->GetdCL_dAlpha(); + FixedCLSummary << "Delta CD / Delta CL" << config->GetdCD_dCL(); + if (nDim == 3){ + FixedCLSummary << "Delta CMx / Delta CL" << config->GetdCMx_dCL(); + FixedCLSummary << "Delta CMy / Delta CL" << config->GetdCMy_dCL(); + } + FixedCLSummary << "Delta CMz / Delta CL" << config->GetdCMz_dCL(); + FixedCLSummary.PrintFooter(); + curInnerIter = lastInnerIter; + WriteMetaData(config); + curInnerIter = config->GetInnerIter(); + } +} diff --git a/SU2_CFD/src/output/CMultizoneOutput.cpp b/SU2_CFD/src/output/CMultizoneOutput.cpp index c5b6037cb0f..7042ede5adb 100644 --- a/SU2_CFD/src/output/CMultizoneOutput.cpp +++ b/SU2_CFD/src/output/CMultizoneOutput.cpp @@ -141,7 +141,7 @@ void CMultizoneOutput::SetMultizoneHistoryOutputFields(COutput **output, CConfig } } -bool CMultizoneOutput::WriteScreen_Header(CConfig *config) { +bool CMultizoneOutput::WriteScreen_Header(const CConfig *config) { /*--- Print header if the outer iteration is zero or zonal convergence is printed ---*/ @@ -157,7 +157,7 @@ bool CMultizoneOutput::WriteScreen_Header(CConfig *config) { return false; } -bool CMultizoneOutput::WriteScreen_Output(CConfig *config) { +bool CMultizoneOutput::WriteScreen_Output(const CConfig *config) { unsigned long ScreenWrt_Freq_Outer = config->GetScreen_Wrt_Freq(1); unsigned long ScreenWrt_Freq_Time = config->GetScreen_Wrt_Freq(0); @@ -183,7 +183,7 @@ bool CMultizoneOutput::WriteScreen_Output(CConfig *config) { return true; } -bool CMultizoneOutput::WriteHistoryFile_Output(CConfig *config){ +bool CMultizoneOutput::WriteHistoryFile_Output(const CConfig *config){ unsigned long HistoryWrt_Freq_Outer = config->GetHistory_Wrt_Freq(1); unsigned long HistoryWrt_Freq_Time = config->GetHistory_Wrt_Freq(0); diff --git a/SU2_CFD/src/output/CNEMOCompOutput.cpp b/SU2_CFD/src/output/CNEMOCompOutput.cpp index 779b72aa86a..81061fc1192 100644 --- a/SU2_CFD/src/output/CNEMOCompOutput.cpp +++ b/SU2_CFD/src/output/CNEMOCompOutput.cpp @@ -43,7 +43,6 @@ CNEMOCompOutput::CNEMOCompOutput(CConfig *config, unsigned short nDim) : CFlowOutput(config, nDim, false) { turb_model = config->GetKind_Turb_Model(); - lastInnerIter = curInnerIter; gridMovement = config->GetDynamic_Grid(); nSpecies = config->GetnSpecies(); @@ -117,8 +116,6 @@ CNEMOCompOutput::CNEMOCompOutput(CConfig *config, unsigned short nDim) : CFlowOu } } -CNEMOCompOutput::~CNEMOCompOutput(void) {} - void CNEMOCompOutput::SetHistoryOutputFields(CConfig *config){ /// BEGIN_GROUP: RMS_RES, DESCRIPTION: The root-mean-square residuals of the SOLUTION variables. @@ -694,60 +691,20 @@ void CNEMOCompOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CSol } -bool CNEMOCompOutput::SetInit_Residuals(CConfig *config){ +bool CNEMOCompOutput::SetInit_Residuals(const CConfig *config){ return (config->GetTime_Marching() != TIME_MARCHING::STEADY && (curInnerIter == 0))|| (config->GetTime_Marching() == TIME_MARCHING::STEADY && (curInnerIter < 2)); } -void CNEMOCompOutput::SetAdditionalScreenOutput(CConfig *config){ +void CNEMOCompOutput::SetAdditionalScreenOutput(const CConfig *config){ if (config->GetFixed_CL_Mode()){ SetFixedCLScreenOutput(config); } } -void CNEMOCompOutput::SetFixedCLScreenOutput(CConfig *config){ - PrintingToolbox::CTablePrinter FixedCLSummary(&cout); - - if (fabs(historyOutput_Map["CL_DRIVER_COMMAND"].value) > 1e-16){ - FixedCLSummary.AddColumn("Fixed CL Mode", 40); - FixedCLSummary.AddColumn("Value", 30); - FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); - FixedCLSummary.PrintHeader(); - FixedCLSummary << "Current CL" << historyOutput_Map["LIFT"].value; - FixedCLSummary << "Target CL" << config->GetTarget_CL(); - FixedCLSummary << "Previous AOA" << historyOutput_Map["PREV_AOA"].value; - if (config->GetFinite_Difference_Mode()){ - FixedCLSummary << "Changed AoA by (Finite Difference step)" << historyOutput_Map["CL_DRIVER_COMMAND"].value; - lastInnerIter = curInnerIter - 1; - } - else - FixedCLSummary << "Changed AoA by" << historyOutput_Map["CL_DRIVER_COMMAND"].value; - FixedCLSummary.PrintFooter(); - SetScreen_Header(config); - } - - else if (config->GetFinite_Difference_Mode() && historyOutput_Map["AOA"].value == historyOutput_Map["PREV_AOA"].value){ - FixedCLSummary.AddColumn("Fixed CL Mode (Finite Difference)", 40); - FixedCLSummary.AddColumn("Value", 30); - FixedCLSummary.SetAlign(PrintingToolbox::CTablePrinter::LEFT); - FixedCLSummary.PrintHeader(); - FixedCLSummary << "Delta CL / Delta AoA" << config->GetdCL_dAlpha(); - FixedCLSummary << "Delta CD / Delta CL" << config->GetdCD_dCL(); - if (nDim == 3){ - FixedCLSummary << "Delta CMx / Delta CL" << config->GetdCMx_dCL(); - FixedCLSummary << "Delta CMy / Delta CL" << config->GetdCMy_dCL(); - } - FixedCLSummary << "Delta CMz / Delta CL" << config->GetdCMz_dCL(); - FixedCLSummary.PrintFooter(); - curInnerIter = lastInnerIter; - WriteMetaData(config); - curInnerIter = config->GetInnerIter(); - } -} - -bool CNEMOCompOutput::WriteHistoryFile_Output(CConfig *config) { +bool CNEMOCompOutput::WriteHistoryFile_Output(const CConfig *config) { return !config->GetFinite_Difference_Mode() && COutput::WriteHistoryFile_Output(config); } diff --git a/SU2_CFD/src/output/COutput.cpp b/SU2_CFD/src/output/COutput.cpp index fe736fbccb9..c37bcab5a65 100644 --- a/SU2_CFD/src/output/COutput.cpp +++ b/SU2_CFD/src/output/COutput.cpp @@ -980,7 +980,7 @@ bool COutput::MonitorTimeConvergence(CConfig *config, unsigned long TimeIteratio return TimeConvergence; } -void COutput::SetHistoryFile_Header(CConfig *config) { +void COutput::SetHistoryFile_Header(const CConfig *config) { unsigned short iField_Output = 0, iReqField = 0, @@ -1024,7 +1024,7 @@ void COutput::SetHistoryFile_Header(CConfig *config) { } -void COutput::SetHistoryFile_Output(CConfig *config) { +void COutput::SetHistoryFile_Output(const CConfig *config) { unsigned short iField_Output = 0, iReqField = 0, @@ -1060,14 +1060,14 @@ void COutput::SetHistoryFile_Output(CConfig *config) { histFile.flush(); } -void COutput::SetScreen_Header(CConfig *config) { +void COutput::SetScreen_Header(const CConfig *config) { if (config->GetMultizone_Problem()) multiZoneHeaderTable->PrintHeader(); convergenceTable->PrintHeader(); } -void COutput::SetScreen_Output(CConfig *config) { +void COutput::SetScreen_Output(const CConfig *config) { string RequestedField; @@ -1815,7 +1815,7 @@ void COutput::Postprocess_HistoryFields(CConfig *config){ } } -bool COutput::WriteScreen_Header(CConfig *config) { +bool COutput::WriteScreen_Header(const CConfig *config) { unsigned long RestartIter = 0; @@ -1867,7 +1867,7 @@ bool COutput::WriteScreen_Header(CConfig *config) { return false; } -bool COutput::WriteScreen_Output(CConfig *config) { +bool COutput::WriteScreen_Output(const CConfig *config) { unsigned long ScreenWrt_Freq_Inner = config->GetScreen_Wrt_Freq(2); unsigned long ScreenWrt_Freq_Outer = config->GetScreen_Wrt_Freq(1); @@ -1908,7 +1908,7 @@ bool COutput::WriteScreen_Output(CConfig *config) { } -bool COutput::WriteHistoryFile_Output(CConfig *config) { +bool COutput::WriteHistoryFile_Output(const CConfig *config) { unsigned long HistoryWrt_Freq_Inner = config->GetHistory_Wrt_Freq(2); unsigned long HistoryWrt_Freq_Outer = config->GetHistory_Wrt_Freq(1); diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 19ee3038c6f..bb1dcafbe6c 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4272,10 +4272,8 @@ void CEulerSolver::ReadActDisk_InputFile(CGeometry *geometry, CSolver **solver_c void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, bool Output) { - su2double AoA = 0.0, Vel_Infty[3], Vel_Infty_Mag; - unsigned short iDim; - unsigned long InnerIter = config->GetInnerIter(); - su2double Beta = config->GetAoS(); + const auto InnerIter = config->GetInnerIter(); + const su2double AoS = config->GetAoS()*PI_NUMBER/180.0; /* --- Initialize values at first iteration --- */ @@ -4292,7 +4290,7 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain /*--- Retrieve the AoA (degrees) ---*/ - AoA = config->GetAoA(); + su2double AoA = config->GetAoA(); /* --- Set new AoA if needed --- */ @@ -4311,49 +4309,46 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain /*--- Compute a new value for AoA on the fine mesh only (degrees)---*/ - if (iMesh == MESH_0) AoA = AoA + AoA_inc; - else { AoA = config->GetAoA(); } - - /*--- Only the fine mesh stores the updated values for AoA in config ---*/ - if (iMesh == MESH_0) { + AoA = AoA + AoA_inc; config->SetAoA(AoA); } + else { + AoA = config->GetAoA(); + } + + AoA *= PI_NUMBER/180.0; /*--- Update the freestream velocity vector at the farfield ---*/ - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty[iDim] = GetVelocity_Inf(iDim); + su2double Vel_Infty[MAXNDIM]={0.0}; - /*--- Compute the magnitude of the free stream velocity ---*/ + for (auto iDim = 0u; iDim < nDim; iDim++) + Vel_Infty[iDim] = GetVelocity_Inf(iDim); - Vel_Infty_Mag = 0; - for (iDim = 0; iDim < nDim; iDim++) - Vel_Infty_Mag += Vel_Infty[iDim]*Vel_Infty[iDim]; - Vel_Infty_Mag = sqrt(Vel_Infty_Mag); + const su2double Vel_Infty_Mag = GeometryToolbox::Norm(int(MAXNDIM), Vel_Infty); /*--- Compute the new freestream velocity with the updated AoA ---*/ if (nDim == 2) { - Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoA*PI_NUMBER/180.0)*Vel_Infty_Mag; + Vel_Infty[0] = cos(AoA)*Vel_Infty_Mag; + Vel_Infty[1] = sin(AoA)*Vel_Infty_Mag; } - if (nDim == 3) { - Vel_Infty[0] = cos(AoA*PI_NUMBER/180.0)*cos(Beta*PI_NUMBER/180.0)*Vel_Infty_Mag; - Vel_Infty[1] = sin(Beta)*Vel_Infty_Mag; - Vel_Infty[2] = sin(AoA*PI_NUMBER/180.0)*cos(Beta*PI_NUMBER/180.0)*Vel_Infty_Mag; + else { + Vel_Infty[0] = cos(AoA)*cos(AoS)*Vel_Infty_Mag; + Vel_Infty[1] = sin(AoS)*Vel_Infty_Mag; + Vel_Infty[2] = sin(AoA)*cos(AoS)*Vel_Infty_Mag; } /*--- Store the new freestream velocity vector for the next iteration ---*/ - for (iDim = 0; iDim < nDim; iDim++) { + for (auto iDim = 0u; iDim < nDim; iDim++) Velocity_Inf[iDim] = Vel_Infty[iDim]; - } /*--- Only the fine mesh stores the updated values for velocity in config ---*/ if (iMesh == MESH_0) { - for (iDim = 0; iDim < nDim; iDim++) + for (auto iDim = 0u; iDim < nDim; iDim++) config->SetVelocity_FreeStreamND(Vel_Infty[iDim], iDim); } @@ -4361,13 +4356,12 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain } bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { - su2double Target_CL = config->GetTarget_CL(); - unsigned long curr_iter = config->GetInnerIter(); - unsigned long Iter_dCL_dAlpha = config->GetIter_dCL_dAlpha(); + const su2double Target_CL = config->GetTarget_CL(); + const auto curr_iter = config->GetInnerIter(); + const auto Iter_dCL_dAlpha = config->GetIter_dCL_dAlpha(); bool fixed_cl_conv = false; AoA_inc = 0.0; - /*--- if in Fixed CL mode, before finite differencing --- */ if (!Start_AoA_FD){ @@ -4464,17 +4458,18 @@ bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { } void CEulerSolver::SetCoefficient_Gradients(CConfig *config) const{ - su2double dCL_dAlpha_, dCD_dCL_, dCMx_dCL_, dCMy_dCL_, dCMz_dCL_; - su2double AoA = config->GetAoA(); - if (AoA != AoA_Prev) { - /* --- Calculate gradients of coefficients w.r.t. CL --- */ + const su2double AoA = config->GetAoA(); + + if (AoA == AoA_Prev) return; - dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); - dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); - dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); - dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); - dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); + /*--- Calculate gradients of coefficients w.r.t. CL ---*/ + + su2double dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); + su2double dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); + su2double dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); + su2double dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); + su2double dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); /*--- Set the value of the dOF/dCL in the config file ---*/ @@ -4483,7 +4478,6 @@ void CEulerSolver::SetCoefficient_Gradients(CConfig *config) const{ config->SetdCMy_dCL(dCMy_dCL_); config->SetdCMz_dCL(dCMz_dCL_); config->SetdCL_dAlpha(dCL_dAlpha_); - } } void CEulerSolver::UpdateCustomBoundaryConditions(CGeometry **geometry_container, CConfig *config){ From 3a0412d8c6b5d012184f848f06153bd4927f7446 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sat, 12 Jun 2021 10:57:24 +0100 Subject: [PATCH 187/192] remove dead code from #1171 --- .../src/grid_movement/CVolumetricMovement.cpp | 64 +------------------ 1 file changed, 2 insertions(+), 62 deletions(-) diff --git a/Common/src/grid_movement/CVolumetricMovement.cpp b/Common/src/grid_movement/CVolumetricMovement.cpp index 7be3d23435d..ee019127107 100644 --- a/Common/src/grid_movement/CVolumetricMovement.cpp +++ b/Common/src/grid_movement/CVolumetricMovement.cpp @@ -356,68 +356,8 @@ void CVolumetricMovement::ComputenNonconvexElements(CGeometry *geometry, bool Sc nNonconvexElements++; } } - } else if (false) { - - /*--- 3D elements ---*/ - unsigned short iNode, iFace, nFaceNodes; - - for (iElem = 0; iElem < geometry->GetnElem(); iElem++){ - for (iFace = 0; iFace < geometry->elem[iElem]->GetnFaces(); iFace++){ - nFaceNodes = geometry->elem[iElem]->GetnNodesFace(iFace); - - su2double minCrossProductLength = 1.e6, maxCrossProductLength = -1.e6; - for (iNode = 0; iNode < nFaceNodes; iNode++) { - su2double crossProductLength = 0.0; - - /*--- Get coords of node face_point_i and its adjacent nodes in the face ---*/ - unsigned long face_point_i, face_point_j, face_point_k; - - face_point_i = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, iNode)); - - /// TODO: Faces may have up to 4 nodes, not all posibilities are covered - - if (iNode == 0) { - face_point_j = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, nFaceNodes-1)); - face_point_k = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, iNode+1)); - } else if (iNode == nFaceNodes-1) { - face_point_j = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, iNode-1)); - face_point_k = geometry->elem[iElem]->GetNode(geometry->elem[iElem]->GetFaces(iFace, 0)); - } - - const auto Coords_i = geometry->nodes->GetCoord(face_point_i); - const auto Coords_j = geometry->nodes->GetCoord(face_point_j); - const auto Coords_k = geometry->nodes->GetCoord(face_point_k); - - /*--- Get edge vectors from point k to i and point j to i ---*/ - su2double edgeVector_i[3], edgeVector_j[3]; - GeometryToolbox::Distance(nDim, Coords_k, Coords_i, edgeVector_i); - GeometryToolbox::Distance(nDim, Coords_j, Coords_i, edgeVector_j); - - /*--- Calculate cross product of edge vectors and its length---*/ - su2double crossProduct[3]; - GeometryToolbox::CrossProduct(edgeVector_i, edgeVector_j, crossProduct); - - /// TODO: This logic is incorrect, the norm will never be less than 0 - - crossProductLength = GeometryToolbox::Norm(nDim, crossProduct); - - /*--- Check if length is minimum or maximum ---*/ - if (crossProductLength < minCrossProductLength) { - minCrossProductLength = crossProductLength; - } else if (crossProductLength > maxCrossProductLength) { - maxCrossProductLength = crossProductLength; - } - } - - /*--- If minimum cross product length is smaller than 0, - face (and therefore element) is not convex ---*/ - if (minCrossProductLength < 0) { - nNonconvexElements++; - break; - } - - } - } + } else if (rank == MASTER_NODE) { + cout << "\nWARNING: Convexity is not checked for 3D elements (issue #1171).\n" << endl; } unsigned long nNonconvexElements_Local = nNonconvexElements; nNonconvexElements = 0; From 16ba56932f52989eda29ac4face7c70713de9e7b Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sun, 13 Jun 2021 16:10:45 +0100 Subject: [PATCH 188/192] Update SU2_CFD/src/solvers/CEulerSolver.cpp Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/solvers/CEulerSolver.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index bb1dcafbe6c..93a42ec2cad 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4465,11 +4465,11 @@ void CEulerSolver::SetCoefficient_Gradients(CConfig *config) const{ /*--- Calculate gradients of coefficients w.r.t. CL ---*/ - su2double dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); - su2double dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); - su2double dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); - su2double dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); - su2double dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); + const su2double dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); + const su2double dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); + const su2double dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); + const su2double dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); + const su2double dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); /*--- Set the value of the dOF/dCL in the config file ---*/ From 371d91236b396e19e27a1d7b91e058acd4210d68 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Sun, 13 Jun 2021 16:19:25 +0100 Subject: [PATCH 189/192] Simplify --- SU2_CFD/src/solvers/CEulerSolver.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 93a42ec2cad..f5363f7c6fd 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4313,9 +4313,6 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain AoA = AoA + AoA_inc; config->SetAoA(AoA); } - else { - AoA = config->GetAoA(); - } AoA *= PI_NUMBER/180.0; @@ -4465,11 +4462,12 @@ void CEulerSolver::SetCoefficient_Gradients(CConfig *config) const{ /*--- Calculate gradients of coefficients w.r.t. CL ---*/ - const su2double dCL_dAlpha_ = (TotalCoeff.CL-Total_CL_Prev)/(AoA - AoA_Prev); - const su2double dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev)/(TotalCoeff.CL-Total_CL_Prev); - const su2double dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev)/(TotalCoeff.CL-Total_CL_Prev); - const su2double dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev)/(TotalCoeff.CL-Total_CL_Prev); - const su2double dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev)/(TotalCoeff.CL-Total_CL_Prev); + const su2double dCL = TotalCoeff.CL - Total_CL_Prev; + const su2double dCL_dAlpha_ = dCL / (AoA - AoA_Prev); + const su2double dCD_dCL_ = (TotalCoeff.CD-Total_CD_Prev) / dCL; + const su2double dCMx_dCL_ = (TotalCoeff.CMx-Total_CMx_Prev) / dCL; + const su2double dCMy_dCL_ = (TotalCoeff.CMy-Total_CMy_Prev) / dCL; + const su2double dCMz_dCL_ = (TotalCoeff.CMz-Total_CMz_Prev) / dCL; /*--- Set the value of the dOF/dCL in the config file ---*/ From 449222976362e4dace0b2873e80ea4acb8eafb4c Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Sun, 13 Jun 2021 17:50:21 +0100 Subject: [PATCH 190/192] redundant operations --- SU2_CFD/src/solvers/CEulerSolver.cpp | 37 +++++++--------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index f5363f7c6fd..a9b8127b080 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4316,39 +4316,21 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain AoA *= PI_NUMBER/180.0; - /*--- Update the freestream velocity vector at the farfield ---*/ + /*--- Update the freestream velocity vector at the farfield + * Compute the new freestream velocity with the updated AoA, + * "Velocity_Inf" is shared with config... ---*/ - su2double Vel_Infty[MAXNDIM]={0.0}; - - for (auto iDim = 0u; iDim < nDim; iDim++) - Vel_Infty[iDim] = GetVelocity_Inf(iDim); - - const su2double Vel_Infty_Mag = GeometryToolbox::Norm(int(MAXNDIM), Vel_Infty); - - /*--- Compute the new freestream velocity with the updated AoA ---*/ + const su2double Vel_Infty_Mag = GeometryToolbox::Norm(nDim, Velocity_Inf); if (nDim == 2) { - Vel_Infty[0] = cos(AoA)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoA)*Vel_Infty_Mag; + Velocity_Inf[0] = cos(AoA)*Vel_Infty_Mag; + Velocity_Inf[1] = sin(AoA)*Vel_Infty_Mag; } else { - Vel_Infty[0] = cos(AoA)*cos(AoS)*Vel_Infty_Mag; - Vel_Infty[1] = sin(AoS)*Vel_Infty_Mag; - Vel_Infty[2] = sin(AoA)*cos(AoS)*Vel_Infty_Mag; + Velocity_Inf[0] = cos(AoA)*cos(AoS)*Vel_Infty_Mag; + Velocity_Inf[1] = sin(AoS)*Vel_Infty_Mag; + Velocity_Inf[2] = sin(AoA)*cos(AoS)*Vel_Infty_Mag; } - - /*--- Store the new freestream velocity vector for the next iteration ---*/ - - for (auto iDim = 0u; iDim < nDim; iDim++) - Velocity_Inf[iDim] = Vel_Infty[iDim]; - - /*--- Only the fine mesh stores the updated values for velocity in config ---*/ - - if (iMesh == MESH_0) { - for (auto iDim = 0u; iDim < nDim; iDim++) - config->SetVelocity_FreeStreamND(Vel_Infty[iDim], iDim); - } - } } @@ -4441,7 +4423,6 @@ bool CEulerSolver::FixedCL_Convergence(CConfig* config, bool convergence) { if (convergence && (curr_iter - Iter_Update_AoA) > config->GetStartConv_Iter()) End_AoA_FD = true; - /* --- If Finite Difference mode is ending, reset AoA and calculate Coefficient Gradients --- */ if (End_AoA_FD){ From fce7de19b3d44f617145a65feedcd8196e11ade9 Mon Sep 17 00:00:00 2001 From: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Date: Tue, 15 Jun 2021 11:18:22 +0100 Subject: [PATCH 191/192] Update SU2_CFD/src/solvers/CEulerSolver.cpp Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> --- SU2_CFD/src/solvers/CEulerSolver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index a9b8127b080..3b68949a6bd 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -4318,7 +4318,7 @@ void CEulerSolver::SetFarfield_AoA(CGeometry *geometry, CSolver **solver_contain /*--- Update the freestream velocity vector at the farfield * Compute the new freestream velocity with the updated AoA, - * "Velocity_Inf" is shared with config... ---*/ + * "Velocity_Inf" is shared with config. ---*/ const su2double Vel_Infty_Mag = GeometryToolbox::Norm(nDim, Velocity_Inf); From 350fee94a837495ba2a0d821a2025020e444acb5 Mon Sep 17 00:00:00 2001 From: Nijso Date: Tue, 22 Jun 2021 09:03:20 +0200 Subject: [PATCH 192/192] Fix SA and SST wall functions (#1204) * fixed wall functions for SA and SST * fix unused variables update * fix wall model constant config option * computing skinfriction when y+ < 5 * fix OMP command * update to enum class * Apply suggestions from code review * a little more refactoring * apply fix from #1120 (do not consider tau wall for edges along wall), vectorized implementation * some fixes and better warnings Co-authored-by: TobiKattmann <31306376+TobiKattmann@users.noreply.github.com> Co-authored-by: Pedro Gomes <38071223+pcarruscag@users.noreply.github.com> Co-authored-by: Pedro Gomes --- Common/include/CConfig.hpp | 50 +-- Common/include/linear_algebra/CSysMatrix.hpp | 2 - Common/include/option_structure.hpp | 34 +-- Common/include/option_structure.inl | 30 +- Common/include/toolboxes/geometry_toolbox.hpp | 13 + Common/src/CConfig.cpp | 18 +- Common/src/fem/fem_geometry_structure.cpp | 8 +- .../src/fem/geometry_structure_fem_part.cpp | 8 +- Common/src/wall_model.cpp | 2 +- SU2_CFD/include/numerics/CNumerics.hpp | 5 - .../include/numerics/NEMO/CNEMONumerics.hpp | 3 + .../include/numerics/flow/flow_diffusion.hpp | 8 +- .../numerics/turbulent/turb_sources.hpp | 3 +- .../include/numerics_simd/CNumericsSIMD.hpp | 1 - .../numerics_simd/flow/diffusion/common.hpp | 29 ++ .../flow/diffusion/viscous_fluxes.hpp | 3 + SU2_CFD/include/numerics_simd/util.hpp | 18 ++ SU2_CFD/include/solvers/CEulerSolver.hpp | 5 + .../include/solvers/CFVMFlowSolverBase.hpp | 32 +- .../include/solvers/CFVMFlowSolverBase.inl | 80 ++--- SU2_CFD/include/solvers/CIncEulerSolver.hpp | 5 + SU2_CFD/include/solvers/CIncNSSolver.hpp | 10 + SU2_CFD/include/solvers/CNEMOEulerSolver.hpp | 5 + SU2_CFD/include/solvers/CNSSolver.hpp | 1 - SU2_CFD/include/solvers/CSolver.hpp | 16 + SU2_CFD/include/solvers/CTurbSASolver.hpp | 4 +- SU2_CFD/include/solvers/CTurbSSTSolver.hpp | 18 ++ SU2_CFD/include/variables/CNSVariable.hpp | 1 + SU2_CFD/include/variables/CVariable.hpp | 2 - SU2_CFD/src/numerics/flow/flow_diffusion.cpp | 89 +++--- SU2_CFD/src/numerics/flow/flow_sources.cpp | 23 ++ SU2_CFD/src/output/CFlowIncOutput.cpp | 17 +- SU2_CFD/src/solvers/CEulerSolver.cpp | 68 ++--- SU2_CFD/src/solvers/CIncEulerSolver.cpp | 25 ++ SU2_CFD/src/solvers/CIncNSSolver.cpp | 284 +++++++++++++++++- SU2_CFD/src/solvers/CNEMOEulerSolver.cpp | 9 + SU2_CFD/src/solvers/CNEMONSSolver.cpp | 11 +- SU2_CFD/src/solvers/CNSSolver.cpp | 170 ++++++++--- SU2_CFD/src/solvers/CTurbSASolver.cpp | 158 +++------- SU2_CFD/src/solvers/CTurbSSTSolver.cpp | 76 ++++- 40 files changed, 929 insertions(+), 415 deletions(-) diff --git a/Common/include/CConfig.hpp b/Common/include/CConfig.hpp index f1952f35355..87291feba80 100644 --- a/Common/include/CConfig.hpp +++ b/Common/include/CConfig.hpp @@ -676,7 +676,7 @@ class CConfig { unsigned short nConfig_Files; /*!< \brief Number of config files for multiphysics problems. */ string *Config_Filenames; /*!< \brief List of names for configuration files. */ - unsigned short *Kind_WallFunctions; /*!< \brief The kind of wall function to use for the corresponding markers. */ + WALL_FUNCTIONS *Kind_WallFunctions; /*!< \brief The kind of wall function to use for the corresponding markers. */ unsigned short **IntInfo_WallFunctions; /*!< \brief Additional integer information for the wall function markers. */ su2double **DoubleInfo_WallFunctions; /*!< \brief Additional double information for the wall function markers. */ unsigned short *Marker_All_Monitoring, /*!< \brief Global index for monitoring using the grid information. */ @@ -816,21 +816,23 @@ class CConfig { Turb2LamViscRatio_FreeStream, /*!< \brief Ratio of turbulent to laminar viscosity. */ NuFactor_FreeStream, /*!< \brief Ratio of turbulent to laminar viscosity. */ NuFactor_Engine, /*!< \brief Ratio of turbulent to laminar viscosity at the engine. */ - SecondaryFlow_ActDisk, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */ - Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */ - Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */ - Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */ - Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */ - Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */ - su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */ - Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */ - Length_Ref, /*!< \brief Reference length for non-dimensionalization. */ - Pressure_Ref, /*!< \brief Reference pressure for non-dimensionalization. */ - Temperature_Ref, /*!< \brief Reference temperature for non-dimensionalization.*/ - Temperature_ve_Ref, /*!< \brief Reference vibrational-electronic temperature for non-dimensionalization.*/ - Density_Ref, /*!< \brief Reference density for non-dimensionalization.*/ - Velocity_Ref, /*!< \brief Reference velocity for non-dimensionalization.*/ - Time_Ref, /*!< \brief Reference time for non-dimensionalization. */ + SecondaryFlow_ActDisk, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */ + Initial_BCThrust, /*!< \brief Ratio of turbulent to laminar viscosity at the actuator disk. */ + Pressure_FreeStream, /*!< \brief Total pressure of the fluid. */ + Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */ + Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */ + Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */ + su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */ + Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */ + wallModelKappa, /*!< \brief von Karman constant kappa for turbulence wall modeling */ + wallModelB, /*!< \brief constant B for turbulence wall modeling */ + Length_Ref, /*!< \brief Reference length for non-dimensionalization. */ + Pressure_Ref, /*!< \brief Reference pressure for non-dimensionalization. */ + Temperature_Ref, /*!< \brief Reference temperature for non-dimensionalization.*/ + Temperature_ve_Ref, /*!< \brief Reference vibrational-electronic temperature for non-dimensionalization.*/ + Density_Ref, /*!< \brief Reference density for non-dimensionalization.*/ + Velocity_Ref, /*!< \brief Reference velocity for non-dimensionalization.*/ + Time_Ref, /*!< \brief Reference time for non-dimensionalization. */ Viscosity_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */ Conductivity_Ref, /*!< \brief Reference conductivity for non-dimensionalization. */ Energy_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */ @@ -1255,7 +1257,7 @@ class CConfig { su2double** & ActDisk_PressJump, su2double** & ActDisk_TempJump, su2double** & ActDisk_Omega); void addWallFunctionOption(const string &name, unsigned short &list_size, - string* &string_field, unsigned short* &val_Kind_WF, + string* &string_field, WALL_FUNCTIONS* &val_Kind_WF, unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF); void addPythonOption(const string name); @@ -1664,6 +1666,18 @@ class CConfig { */ su2double GetPrandtl_Turb(void) const { return Prandtl_Turb; } + /*! + * \brief Get the value of the von Karman constant kappa for turbulence wall modeling. + * \return von Karman constant. + */ + su2double GetwallModelKappa(void) const { return wallModelKappa; } + + /*! + * \brief Get the value of the von Karman constant kappa for turbulence wall modeling. + * \return von Karman constant. + */ + su2double GetwallModelB(void) const { return wallModelB; } + /*! * \brief Get the value of the thermal conductivity for solids. * \return Thermal conductivity (solid). @@ -6618,7 +6632,7 @@ class CConfig { * \param[in] val_marker - String of the viscous wall marker. * \return The type of wall function treatment. */ - unsigned short GetWallFunction_Treatment(string val_marker) const; + WALL_FUNCTIONS GetWallFunction_Treatment(string val_marker) const; /*! * \brief Get the additional integer info for the wall function treatment diff --git a/Common/include/linear_algebra/CSysMatrix.hpp b/Common/include/linear_algebra/CSysMatrix.hpp index 75ab1a052c3..8d32302ee84 100644 --- a/Common/include/linear_algebra/CSysMatrix.hpp +++ b/Common/include/linear_algebra/CSysMatrix.hpp @@ -36,8 +36,6 @@ #include #include -using namespace std; - /*--- In forward mode the matrix is not of a built-in type. ---*/ #if defined(HAVE_MKL) && !defined(CODI_FORWARD_TYPE) #include "mkl.h" diff --git a/Common/include/option_structure.hpp b/Common/include/option_structure.hpp index 0a548762a37..f5d6a61a972 100644 --- a/Common/include/option_structure.hpp +++ b/Common/include/option_structure.hpp @@ -935,23 +935,23 @@ static const MapType RoeLowDiss_Map = { /*! * \brief Types of wall functions. */ -enum ENUM_WALL_FUNCTIONS { - NO_WALL_FUNCTION = 0, /*!< \brief No wall function treatment, integration to the wall. Default behavior. */ - STANDARD_WALL_FUNCTION = 1, /*!< \brief Standard wall function. */ - ADAPTIVE_WALL_FUNCTION = 2, /*!< \brief Adaptive wall function. Formulation depends on y+. */ - SCALABLE_WALL_FUNCTION = 3, /*!< \brief Scalable wall function. */ - EQUILIBRIUM_WALL_MODEL = 4, /*!< \brief Equilibrium wall model for LES. */ - NONEQUILIBRIUM_WALL_MODEL = 5, /*!< \brief Non-equilibrium wall model for LES. */ - LOGARITHMIC_WALL_MODEL = 6 /*!< \brief Logarithmic law-of-the-wall model for LES. */ -}; -static const MapType Wall_Functions_Map = { - MakePair("NO_WALL_FUNCTION", NO_WALL_FUNCTION) - MakePair("STANDARD_WALL_FUNCTION", STANDARD_WALL_FUNCTION) - MakePair("ADAPTIVE_WALL_FUNCTION", ADAPTIVE_WALL_FUNCTION) - MakePair("SCALABLE_WALL_FUNCTION", SCALABLE_WALL_FUNCTION) - MakePair("EQUILIBRIUM_WALL_MODEL", EQUILIBRIUM_WALL_MODEL) - MakePair("NONEQUILIBRIUM_WALL_MODEL", NONEQUILIBRIUM_WALL_MODEL) - MakePair("LOGARITHMIC_WALL_MODEL", LOGARITHMIC_WALL_MODEL) +enum class WALL_FUNCTIONS { + NONE , /*!< \brief No wall function treatment, integration to the wall. Default behavior. */ + STANDARD_FUNCTION , /*!< \brief Standard wall function. */ + ADAPTIVE_FUNCTION , /*!< \brief Adaptive wall function. Formulation depends on y+. */ + SCALABLE_FUNCTION , /*!< \brief Scalable wall function. */ + EQUILIBRIUM_MODEL , /*!< \brief Equilibrium wall model for LES. */ + NONEQUILIBRIUM_MODEL , /*!< \brief Non-equilibrium wall model for LES. */ + LOGARITHMIC_MODEL /*!< \brief Logarithmic law-of-the-wall model for LES. */ +}; +static const MapType Wall_Functions_Map = { + MakePair("NO_WALL_FUNCTION", WALL_FUNCTIONS::NONE) + MakePair("STANDARD_WALL_FUNCTION", WALL_FUNCTIONS::STANDARD_FUNCTION) + MakePair("ADAPTIVE_WALL_FUNCTION", WALL_FUNCTIONS::ADAPTIVE_FUNCTION) + MakePair("SCALABLE_WALL_FUNCTION", WALL_FUNCTIONS::SCALABLE_FUNCTION) + MakePair("EQUILIBRIUM_WALL_MODEL", WALL_FUNCTIONS::EQUILIBRIUM_MODEL) + MakePair("NONEQUILIBRIUM_WALL_MODEL", WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL) + MakePair("LOGARITHMIC_WALL_MODEL", WALL_FUNCTIONS::LOGARITHMIC_MODEL) }; /*! diff --git a/Common/include/option_structure.inl b/Common/include/option_structure.inl index 94a59c664b0..cbcd4671bbf 100644 --- a/Common/include/option_structure.inl +++ b/Common/include/option_structure.inl @@ -1736,13 +1736,13 @@ class COptionWallFunction : public COptionBase { string name; // identifier for the option unsigned short &nMarkers; string* &markers; - unsigned short* &walltype; + WALL_FUNCTIONS* &walltype; unsigned short** &intInfo; su2double** &doubleInfo; public: COptionWallFunction(const string name, unsigned short &nMarker_WF, - string* &Marker_WF, unsigned short* &type_WF, + string* &Marker_WF, WALL_FUNCTIONS* &type_WF, unsigned short** &intInfo_WF, su2double** &doubleInfo_WF) : nMarkers(nMarker_WF), markers(Marker_WF), walltype(type_WF), intInfo(intInfo_WF), doubleInfo(doubleInfo_WF) { @@ -1774,14 +1774,16 @@ public: If not, create an error message and return. */ ++counter; const unsigned short indWallType = counter; - unsigned short typeWF = NO_WALL_FUNCTION; + auto typeWF = WALL_FUNCTIONS::NONE; bool validWF = true; if (counter == totalSize) validWF = false; else { - map::const_iterator it; + map::const_iterator it; it = Wall_Functions_Map.find(option_value[counter]); - if(it == Wall_Functions_Map.end()) validWF = false; - else typeWF = it->second; + if(it == Wall_Functions_Map.end()) + validWF = false; + else + typeWF = it->second; } if (!validWF ) { @@ -1801,9 +1803,9 @@ public: must be specified. Hence the counter must be updated accordingly. ---*/ switch( typeWF ) { - case EQUILIBRIUM_WALL_MODEL: counter += 3; break; - case NONEQUILIBRIUM_WALL_MODEL: counter += 2; break; - case LOGARITHMIC_WALL_MODEL: counter += 3; break; + case WALL_FUNCTIONS::EQUILIBRIUM_MODEL: counter += 3; break; + case WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL: counter += 2; break; + case WALL_FUNCTIONS::LOGARITHMIC_MODEL: counter += 3; break; default: break; } @@ -1824,7 +1826,7 @@ public: /* Allocate the memory to store the data for the wall function markers. */ this->nMarkers = nVals; this->markers = new string[nVals]; - this->walltype = new unsigned short[nVals]; + this->walltype = new WALL_FUNCTIONS[nVals]; this->intInfo = new unsigned short*[nVals]; this->doubleInfo = new su2double*[nVals]; @@ -1843,7 +1845,7 @@ public: /* Determine the wall function type. As their validaties have already been tested, there is no need to do so again. */ - map::const_iterator it; + map::const_iterator it; it = Wall_Functions_Map.find(option_value[counter++]); this->walltype[i] = it->second; @@ -1852,7 +1854,7 @@ public: is needed, which is extracted from option_value. ---*/ switch( this->walltype[i] ) { - case EQUILIBRIUM_WALL_MODEL: { + case WALL_FUNCTIONS::EQUILIBRIUM_MODEL: { /* LES equilibrium wall model. The exchange distance, stretching factor and number of points in the wall model must be specified. */ @@ -1877,7 +1879,7 @@ public: break; } - case NONEQUILIBRIUM_WALL_MODEL: { + case WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL: { /* LES non-equilibrium model. The RANS turbulence model and the exchange distance need to be specified. */ @@ -1910,7 +1912,7 @@ public: break; } - case LOGARITHMIC_WALL_MODEL: { + case WALL_FUNCTIONS::LOGARITHMIC_MODEL: { /* LES Logarithmic law-of-the-wall model. The exchange distance, stretching factor and number of points in the wall model must be specified. */ diff --git a/Common/include/toolboxes/geometry_toolbox.hpp b/Common/include/toolboxes/geometry_toolbox.hpp index 458365fa3ee..8bd967f9b46 100644 --- a/Common/include/toolboxes/geometry_toolbox.hpp +++ b/Common/include/toolboxes/geometry_toolbox.hpp @@ -192,4 +192,17 @@ inline void Rotate(const Scalar R[][nDim], const Scalar* O, const Scalar* d, Sca } } +/*! \brief Tangent projection */ +template +inline void TangentProjection(Int nDim, const Mat& tensor, const Scalar* vector, Scalar* proj) { + + for (Int iDim = 0; iDim < nDim; iDim++) + proj[iDim] = DotProduct(nDim, tensor[iDim], vector); + + auto normalProj = DotProduct(nDim, proj, vector); + + for (Int iDim = 0; iDim < nDim; iDim++) + proj[iDim] -= normalProj * vector[iDim]; +} + } diff --git a/Common/src/CConfig.cpp b/Common/src/CConfig.cpp index 3ad89a51503..3eaed4c333f 100644 --- a/Common/src/CConfig.cpp +++ b/Common/src/CConfig.cpp @@ -531,7 +531,7 @@ void CConfig::addActDiskOption(const string & name, unsigned short & nMarker_Act } void CConfig::addWallFunctionOption(const string &name, unsigned short &list_size, string* &string_field, - unsigned short* &val_Kind_WF, unsigned short** &val_IntInfo_WF, + WALL_FUNCTIONS* &val_Kind_WF, unsigned short** &val_IntInfo_WF, su2double** &val_DoubleInfo_WF) { assert(option_map.find(name) == option_map.end()); all_options.insert(pair(name, true)); @@ -1223,6 +1223,10 @@ void CConfig::SetConfig_Options() { addDoubleOption("PRANDTL_LAM", Prandtl_Lam, 0.72); /*!\brief PRANDTL_TURB \n DESCRIPTION: Turbulent Prandtl number (0.9 (air), only for compressible flows) \n DEFAULT 0.90 \ingroup Config*/ addDoubleOption("PRANDTL_TURB", Prandtl_Turb, 0.90); + /*!\brief WALLMODELKAPPA \n DESCRIPTION: von Karman constant used for the wall model \n DEFAULT 0.41 \ingroup Config*/ + addDoubleOption("WALLMODELKAPPA", wallModelKappa, 0.41); + /*!\brief WALLMODELB \n DESCRIPTION: constant B used for the wall model \n DEFAULT 5.0 \ingroup Config*/ + addDoubleOption("WALLMODELB", wallModelB, 5.5); /*!\brief BULK_MODULUS \n DESCRIPTION: Value of the Bulk Modulus \n DEFAULT 1.42E5 \ingroup Config*/ addDoubleOption("BULK_MODULUS", Bulk_Modulus, 1.42E5); /* DESCRIPTION: Epsilon^2 multipier in Beta calculation for incompressible preconditioner. */ @@ -3258,13 +3262,13 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i Wall_Functions = false; if (nMarker_WallFunctions > 0) { for (iMarker = 0; iMarker < nMarker_WallFunctions; iMarker++) { - if (Kind_WallFunctions[iMarker] != NO_WALL_FUNCTION) + if (Kind_WallFunctions[iMarker] != WALL_FUNCTIONS::NONE) Wall_Functions = true; - if ((Kind_WallFunctions[iMarker] == ADAPTIVE_WALL_FUNCTION) || (Kind_WallFunctions[iMarker] == SCALABLE_WALL_FUNCTION) - || (Kind_WallFunctions[iMarker] == NONEQUILIBRIUM_WALL_MODEL)) + if ((Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::ADAPTIVE_FUNCTION) || (Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::SCALABLE_FUNCTION) + || (Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL)) - SU2_MPI::Error(string("For RANS problems, use NO_WALL_FUNCTION, STANDARD_WALL_FUNCTION or EQUILIBRIUM_WALL_MODEL.\n"), CURRENT_FUNCTION); + SU2_MPI::Error(string("For RANS problems, use NONE, STANDARD_WALL_FUNCTION or EQUILIBRIUM_WALL_MODEL.\n"), CURRENT_FUNCTION); } } @@ -8871,9 +8875,9 @@ pair CConfig::GetWallRoughnessProperties(string val_marker return WallProp; } -unsigned short CConfig::GetWallFunction_Treatment(string val_marker) const { +WALL_FUNCTIONS CConfig::GetWallFunction_Treatment(string val_marker) const { - unsigned short WallFunction = NO_WALL_FUNCTION; + WALL_FUNCTIONS WallFunction = WALL_FUNCTIONS::NONE; for(unsigned short iMarker=0; iMarkerGetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) wallFunctions = true; break; } @@ -6235,19 +6235,19 @@ void CMeshFEM_DG::WallFunctionPreprocessing(CConfig *config) { case ISOTHERMAL: case HEAT_FLUX: { const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) { + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) { /* An LES wall model is used for this boundary marker. Determine which wall model and allocate the memory for the member variable. */ switch (config->GetWallFunction_Treatment(Marker_Tag) ) { - case EQUILIBRIUM_WALL_MODEL: { + case WALL_FUNCTIONS::EQUILIBRIUM_MODEL: { if(rank == MASTER_NODE) cout << "Marker " << Marker_Tag << " uses an Equilibrium Wall Model." << endl; boundaries[iMarker].wallModel = new CWallModel1DEQ(config, Marker_Tag); break; } - case LOGARITHMIC_WALL_MODEL: { + case WALL_FUNCTIONS::LOGARITHMIC_MODEL: { if(rank == MASTER_NODE) cout << "Marker " << Marker_Tag << " uses the Reichardt and Kader analytical laws for the Wall Model." << endl; diff --git a/Common/src/fem/geometry_structure_fem_part.cpp b/Common/src/fem/geometry_structure_fem_part.cpp index 9f0384b6873..ad4085eb773 100644 --- a/Common/src/fem/geometry_structure_fem_part.cpp +++ b/Common/src/fem/geometry_structure_fem_part.cpp @@ -3355,7 +3355,7 @@ void CPhysicalGeometry::DetermineDonorElementsWallFunctions(CConfig *config) { case ISOTHERMAL: case HEAT_FLUX: { const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) wallFunctions = true; break; } @@ -3500,7 +3500,7 @@ void CPhysicalGeometry::DetermineDonorElementsWallFunctions(CConfig *config) { case ISOTHERMAL: case HEAT_FLUX: { const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) { + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) { /* Retrieve the floating point information for this boundary marker. The exchange location is the first element of this array. */ @@ -3952,7 +3952,7 @@ void CPhysicalGeometry::DetermineDonorElementsWallFunctions(CConfig *config) { case ISOTHERMAL: case HEAT_FLUX: { const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) { + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) { for(unsigned long l=0; lRemoveMultipleDonorsWallFunctions(); @@ -4825,7 +4825,7 @@ void CPhysicalGeometry::ComputeFEMGraphWeights( case ISOTHERMAL: case HEAT_FLUX: { const string Marker_Tag = config->GetMarker_All_TagBound(iMarker); - if(config->GetWallFunction_Treatment(Marker_Tag) != NO_WALL_FUNCTION) { + if(config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) { /* Retrieve the integer information for this boundary marker. The number of points in normal direction for the wall function diff --git a/Common/src/wall_model.cpp b/Common/src/wall_model.cpp index 37774dbab6b..0cc34ba4bd6 100644 --- a/Common/src/wall_model.cpp +++ b/Common/src/wall_model.cpp @@ -41,7 +41,7 @@ CWallModel::CWallModel(CConfig *config) { Pr_lam = config->GetPrandtl_Lam(); Pr_turb = config->GetPrandtl_Turb(); - karman = 0.41; // von Karman constant -> k = 0.41; or 0.38; + karman = config->GetwallModelKappa(); // von Karman constant -> k = 0.41; or 0.38; } void CWallModel::WallShearStressAndHeatFlux(const su2double rhoExchange, diff --git a/SU2_CFD/include/numerics/CNumerics.hpp b/SU2_CFD/include/numerics/CNumerics.hpp index 2181487e7ac..7e5fd557df6 100644 --- a/SU2_CFD/include/numerics/CNumerics.hpp +++ b/SU2_CFD/include/numerics/CNumerics.hpp @@ -34,13 +34,8 @@ #include #include "../../../Common/include/CConfig.hpp" -#include "../fluid/CNEMOGas.hpp" -#include "../../include/fluid/CMutationTCLib.hpp" -#include "../../include/fluid/CSU2TCLib.hpp" #include "../../../Common/include/linear_algebra/blas_structure.hpp" -using namespace std; - class CElement; class CFluidModel; diff --git a/SU2_CFD/include/numerics/NEMO/CNEMONumerics.hpp b/SU2_CFD/include/numerics/NEMO/CNEMONumerics.hpp index 408a13bdbd2..ff8482d425f 100644 --- a/SU2_CFD/include/numerics/NEMO/CNEMONumerics.hpp +++ b/SU2_CFD/include/numerics/NEMO/CNEMONumerics.hpp @@ -28,6 +28,9 @@ #pragma once #include "../CNumerics.hpp" +#include "../../fluid/CNEMOGas.hpp" +#include "../../fluid/CMutationTCLib.hpp" +#include "../../fluid/CSU2TCLib.hpp" /*! * \class CNEMONumerics diff --git a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp index 9e89955793d..70106000340 100644 --- a/SU2_CFD/include/numerics/flow/flow_diffusion.hpp +++ b/SU2_CFD/include/numerics/flow/flow_diffusion.hpp @@ -73,11 +73,11 @@ class CAvgGrad_Base : public CNumerics { * This function requires that the stress tensor already be * computed using \ref GetStressTensor * - * \param[in] val_normal - Normal vector, the norm of the vector is the area of the face. - * \param[in] val_tau_wall - The wall stress + * \param[in] UnitNormal - Unit normal vector. + * \param[in] TauWall - The wall stress. */ - void AddTauWall(const su2double *val_normal, - su2double val_tau_wall); + void AddTauWall(const su2double *UnitNormal, + su2double TauWall); /** * \brief Calculate the Jacobian of the viscous + turbulent stress tensor diff --git a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp index 52aba19213c..2e0e2b8cb62 100644 --- a/SU2_CFD/include/numerics/turbulent/turb_sources.hpp +++ b/SU2_CFD/include/numerics/turbulent/turb_sources.hpp @@ -134,7 +134,8 @@ class CSourcePieceWise_TurbSA final : public CSourceBase_TurbSA { su2double dr, dg, dfw; unsigned short iDim; bool transition; - + bool axisymmetric; + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/numerics_simd/CNumericsSIMD.hpp b/SU2_CFD/include/numerics_simd/CNumericsSIMD.hpp index c76d96bd373..701ee440bca 100644 --- a/SU2_CFD/include/numerics_simd/CNumericsSIMD.hpp +++ b/SU2_CFD/include/numerics_simd/CNumericsSIMD.hpp @@ -27,7 +27,6 @@ #pragma once -#include "../../../Common/include/CConfig.hpp" #include "../../../Common/include/parallelization/vectorization.hpp" /*! diff --git a/SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp b/SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp index 918388f4066..fa3df0f0b2f 100644 --- a/SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp +++ b/SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp @@ -149,6 +149,35 @@ FORCEINLINE void addQCR(const MatrixType& grad, MatrixDbl& tau) { tau(iDim,jDim) -= c_cr1 * qcr(iDim,jDim); } +/*! + * \brief Scale the stress tensor according to the target (from a + * wall function) magnitute in the tangential direction. + */ +template +FORCEINLINE void addTauWall(Int iPoint, Int jPoint, + const Container& tauWall, + const VectorDbl& unitNormal, + MatrixDbl& tau) { + + Double tauWall_i = max(gatherVariables(iPoint, tauWall), 0.0); + Double tauWall_j = max(gatherVariables(jPoint, tauWall), 0.0); + + Double isWall_i = tauWall_i > 0.0; + Double isWall_j = tauWall_j > 0.0; + /*--- Arithmetic xor. ---*/ + Double isNormalEdge = isWall_i+isWall_j - 2*isWall_i*isWall_j; + + /*--- Tau wall is 0 for edges that are not normal to walls. ---*/ + Double tauWall_ij = (tauWall_i+tauWall_j) * isNormalEdge; + + /*--- Scale is 1 for those edges, i.e. tau is not changed. ---*/ + Double scale = tauWall_ij / norm(tangentProjection(tau,unitNormal)) + (1.0-isNormalEdge); + + for (size_t iDim = 0; iDim < nDim; ++iDim) + for (size_t jDim = 0; jDim < nDim; ++jDim) + tau(iDim,jDim) *= scale; +} + /*! * \brief Jacobian of the stress tensor (compressible flow). */ diff --git a/SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp b/SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp index 6c2078bccd8..bbb9897bd7f 100644 --- a/SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp +++ b/SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp @@ -78,6 +78,7 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD { const su2double cp; const bool correct; const bool useSA_QCR; + const bool wallFun; const bool uq; const bool uq_permute; const size_t uq_eigval_comp; @@ -99,6 +100,7 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD { cp(gamma * gasConst / (gamma - 1)), correct(iMesh == MESH_0), useSA_QCR(config.GetQCR()), + wallFun(config.GetWall_Functions()), uq(config.GetUsing_UQ()), uq_permute(config.GetUQ_Permute()), uq_eigval_comp(config.GetEig_Val_Comp()), @@ -157,6 +159,7 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD { addPerturbedRSM(avgV, avgGrad, turb_ke, tau, uq_eigval_comp, uq_permute, uq_delta_b, uq_urlx); } + if(wallFun) addTauWall(iPoint, jPoint, solution.GetTauWall(), unitNormal, tau); Double cond = derived->thermalConductivity(avgV); VectorDbl heatFlux; diff --git a/SU2_CFD/include/numerics_simd/util.hpp b/SU2_CFD/include/numerics_simd/util.hpp index 21c99c7e529..ffd5620dd39 100644 --- a/SU2_CFD/include/numerics_simd/util.hpp +++ b/SU2_CFD/include/numerics_simd/util.hpp @@ -109,6 +109,24 @@ FORCEINLINE Double squaredNorm(const VectorDbl& vector) { return squaredNorm(vector.data()); } +/*! + * \brief Tangential projection. + */ +template +FORCEINLINE VectorDbl tangentProjection(const MatrixDbl& tensor, + const VectorDbl& unitVector) { + VectorDbl proj; + for (size_t iDim = 0; iDim < nDim; ++iDim) + proj(iDim) = dot(tensor[iDim], unitVector); + + Double normalProj = dot(proj, unitVector); + + for (size_t iDim = 0; iDim < nDim; ++iDim) + proj(iDim) -= normalProj * unitVector(iDim); + + return proj; +} + /*! * \brief Vector norm. */ diff --git a/SU2_CFD/include/solvers/CEulerSolver.hpp b/SU2_CFD/include/solvers/CEulerSolver.hpp index 3a181ec54de..d4a91b3d983 100644 --- a/SU2_CFD/include/solvers/CEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CEulerSolver.hpp @@ -273,6 +273,11 @@ class CEulerSolver : public CFVMFlowSolverBase > CPressure; /*!< \brief Pressure coefficient for each boundary and vertex. */ vector > CPressureTarget; /*!< \brief Target Pressure coefficient for each boundary and vertex. */ vector > YPlus; /*!< \brief Yplus for each boundary and vertex. */ + vector > UTau; /*!< \brief UTau for each boundary and vertex. */ + vector > EddyViscWall; /*!< \brief Eddy viscosuty at the wall for each boundary and vertex. */ bool space_centered; /*!< \brief True if space centered scheme used. */ bool euler_implicit; /*!< \brief True if euler implicit scheme used. */ @@ -226,6 +229,13 @@ class CFVMFlowSolverBase : public CSolver { */ CFVMFlowSolverBase() : CSolver() {} + /*! + * \brief Set reference values for pressure, forces, etc., e.g. "AeroCoeffForceRef". + * \note Implement this method in the derived class and call it in its constructor. + * Duplicating this type of information has caused bugs (I know because I fixed them). + */ + virtual void SetReferenceValues(const CConfig& config) = 0; + /*! * \brief Allocate member variables. */ @@ -2443,7 +2453,7 @@ class CFVMFlowSolverBase : public CSolver { } /*! - * \brief Get the skin friction coefficient. + * \brief Get the heat flux. * \param[in] val_marker - Surface marker where the coefficient is computed. * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. * \return Value of the heat transfer coefficient. @@ -2481,4 +2491,24 @@ class CFVMFlowSolverBase : public CSolver { inline su2double GetYPlus(unsigned short val_marker, unsigned long val_vertex) const final { return YPlus[val_marker][val_vertex]; } + + /*! + * \brief Get the u_tau . + * \param[in] val_marker - Surface marker where the coefficient is computed. + * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. + * \return Value of the u_tau. + */ + inline su2double GetUTau(unsigned short val_marker, unsigned long val_vertex) const final { + return UTau[val_marker][val_vertex]; + } + + /*! + * \brief Get the eddy viscosity at the wall (wall functions). + * \param[in] val_marker - Surface marker where the coefficient is computed. + * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. + * \return Value of the eddy viscosity. + */ + inline su2double GetEddyViscWall(unsigned short val_marker, unsigned long val_vertex) const final { + return EddyViscWall[val_marker][val_vertex]; + } }; diff --git a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl index 5102b521a13..b4dc537102d 100644 --- a/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl +++ b/SU2_CFD/include/solvers/CFVMFlowSolverBase.inl @@ -172,6 +172,14 @@ void CFVMFlowSolverBase::Allocate(const CConfig& config) { AllocVectorOfVectors(nVertex, YPlus); + /*--- U Tau in all the markers ---*/ + + AllocVectorOfVectors(nVertex, UTau); + + /*--- wall eddy viscosity in all the markers ---*/ + + AllocVectorOfVectors(nVertex, EddyViscWall); + /*--- Skin friction in all the markers ---*/ AllocVectorOfMatrices(nVertex, nDim, CSkinFriction); @@ -429,6 +437,11 @@ void CFVMFlowSolverBase::Viscous_Residual_impl(unsigned long iEdge, CGeome numerics->SetTurbKineticEnergy(turbNodes->GetSolution(iPoint,0), turbNodes->GetSolution(jPoint,0)); + /*--- Wall shear stress values (wall functions) ---*/ + + numerics->SetTauWall(nodes->GetTauWall(iPoint), + nodes->GetTauWall(jPoint)); + /*--- Compute and update residual ---*/ auto residual = numerics->ComputeResidual(config); @@ -1423,10 +1436,6 @@ void CFVMFlowSolverBase::BC_Fluid_Interface(CGeometry* geometry, visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint, 0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint, 0)); - /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ - - visc_numerics->SetTauWall(-1.0, -1.0); - /*--- Compute and update residual ---*/ auto residual = visc_numerics->ComputeResidual(config); @@ -1759,8 +1768,7 @@ template void CFVMFlowSolverBase::Pressure_Forces(const CGeometry* geometry, const CConfig* config) { unsigned long iVertex, iPoint; unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring; - su2double Pressure = 0.0, factor, NFPressOF, RefVel2 = 0.0, RefTemp, RefDensity = 0.0, RefPressure, Mach2Vel, - Mach_Motion; + su2double Pressure = 0.0, NFPressOF, RefPressure; const su2double *Normal = nullptr, *Coord = nullptr; string Marker_Tag, Monitoring_Tag; su2double AxiFactor; @@ -1769,49 +1777,12 @@ void CFVMFlowSolverBase::Pressure_Forces(const CGeometry* geometr su2double Beta = config->GetAoS() * PI_NUMBER / 180.0; su2double RefArea = config->GetRefArea(); su2double RefLength = config->GetRefLength(); - su2double Gas_Constant = config->GetGas_ConstantND(); auto Origin = config->GetRefOriginMoment(0); bool axisymmetric = config->GetAxisymmetric(); - /// TODO: Move these ifs to specialized functions. - - if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) { - /*--- Evaluate reference values for non-dimensionalization. - For dynamic meshes, use the motion Mach number as a reference value - for computing the force coefficients. Otherwise, use the freestream values, - which is the standard convention. ---*/ - - RefTemp = Temperature_Inf; - RefDensity = Density_Inf; - if (dynamic_grid && !config->GetFSI_Simulation()) { - Mach2Vel = sqrt(Gamma * Gas_Constant * RefTemp); - Mach_Motion = config->GetMach_Motion(); - RefVel2 = (Mach_Motion * Mach2Vel) * (Mach_Motion * Mach2Vel); - } else { - RefVel2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim]; - } - } - - if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE) { - /*--- Evaluate reference values for non-dimensionalization. - For dimensional or non-dim based on initial values, use - the far-field state (inf). For a custom non-dim based - on user-provided reference values, use the ref values - to compute the forces. ---*/ - - if ((config->GetRef_Inc_NonDim() == DIMENSIONAL) || (config->GetRef_Inc_NonDim() == INITIAL_VALUES)) { - RefDensity = Density_Inf; - RefVel2 = 0.0; - for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim]; - } else if (config->GetRef_Inc_NonDim() == REFERENCE_VALUES) { - RefDensity = config->GetInc_Density_Ref(); - RefVel2 = config->GetInc_Velocity_Ref() * config->GetInc_Velocity_Ref(); - } - } + SetReferenceValues(*config); - AeroCoeffForceRef = 0.5 * RefDensity * RefArea * RefVel2; - factor = 1.0 / AeroCoeffForceRef; + const su2double factor = 1.0 / AeroCoeffForceRef; /*--- Reference pressure is always the far-field value. ---*/ @@ -2453,6 +2424,7 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr for (iMarker = 0; iMarker < nMarker; iMarker++) { + Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (!config->GetViscous_Wall(iMarker)) continue; /*--- Obtain the origin for the moment computation for a particular marker ---*/ @@ -2461,7 +2433,6 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr if (Monitoring == YES) { for (iMarker_Monitoring = 0; iMarker_Monitoring < config->GetnMarker_Monitoring(); iMarker_Monitoring++) { Monitoring_Tag = config->GetMarker_Monitoring_TagBound(iMarker_Monitoring); - Marker_Tag = config->GetMarker_All_TagBound(iMarker); if (Marker_Tag == Monitoring_Tag) Origin = config->GetRefOriginMoment(iMarker_Monitoring); } } @@ -2476,6 +2447,10 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr su2double ForceViscous[MAXNDIM] = {0.0}, MomentViscous[MAXNDIM] = {0.0}; su2double MomentX_Force[MAXNDIM] = {0.0}, MomentY_Force[MAXNDIM] = {0.0}, MomentZ_Force[MAXNDIM] = {0.0}; + /* --- check if wall functions are used --- */ + + const bool wallfunctions = (config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE); + /*--- Loop over the vertices to compute the forces ---*/ for (iVertex = 0; iVertex < geometry->nVertex[iMarker]; iVertex++) { @@ -2539,7 +2514,12 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr WallShearStress[iMarker][iVertex] = 0.0; for (iDim = 0; iDim < nDim; iDim++) { TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric; + /* --- in case of wall functions, we have computed the skin friction in the turbulence solver --- */ + /* --- Note that in the wall model, we switch off the computation when the computed y+ < 5 --- */ + /* --- We put YPlus to 1.0 so we have to compute skinfriction and the actual y+ in that case as well --- */ + if (!wallfunctions || (wallfunctions && YPlus[iMarker][iVertex] < 5.0)) + CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric; + WallShearStress[iMarker][iVertex] += TauTangent[iDim] * TauTangent[iDim]; } WallShearStress[iMarker][iVertex] = sqrt(WallShearStress[iMarker][iVertex]); @@ -2552,7 +2532,11 @@ void CFVMFlowSolverBase::Friction_Forces(const CGeometry* geometr /*--- Compute y+ and non-dimensional velocity ---*/ FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density); - YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density); + + /* --- in case of wall functions, we have computed YPlus in the turbulence class --- */ + /* --- Note that we do not recompute y+ when y+<5 because y+ can become > 5 again --- */ + if (!wallfunctions) + YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density); /*--- Compute total and maximum heat flux on the wall ---*/ diff --git a/SU2_CFD/include/solvers/CIncEulerSolver.hpp b/SU2_CFD/include/solvers/CIncEulerSolver.hpp index aa925f387d1..710ab4dd742 100644 --- a/SU2_CFD/include/solvers/CIncEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CIncEulerSolver.hpp @@ -119,6 +119,11 @@ class CIncEulerSolver : public CFVMFlowSolverBase void Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep); + /*! + * \brief Set reference values for pressure, forces, etc. + */ + void SetReferenceValues(const CConfig& config) final; + public: /*! * \brief Constructor of the class. diff --git a/SU2_CFD/include/solvers/CIncNSSolver.hpp b/SU2_CFD/include/solvers/CIncNSSolver.hpp index a447a101e71..8702dada838 100644 --- a/SU2_CFD/include/solvers/CIncNSSolver.hpp +++ b/SU2_CFD/include/solvers/CIncNSSolver.hpp @@ -65,6 +65,16 @@ class CIncNSSolver final : public CIncEulerSolver { void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) override; +/*! + * \brief Computes the wall shear stress (Tau_Wall) on the surface using a wall function. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] config - Definition of the particular problem. + */ + void SetTauWall_WF(CGeometry *geometry, + CSolver** solver_container, + const CConfig* config); + /*! * \brief Compute necessary quantities (massflow, integrated heatflux, avg density) * for streamwise periodic cases. Also sets new delta P for prescribed massflow. diff --git a/SU2_CFD/include/solvers/CNEMOEulerSolver.hpp b/SU2_CFD/include/solvers/CNEMOEulerSolver.hpp index 9f977e61165..569d25464aa 100644 --- a/SU2_CFD/include/solvers/CNEMOEulerSolver.hpp +++ b/SU2_CFD/include/solvers/CNEMOEulerSolver.hpp @@ -85,6 +85,11 @@ class CNEMOEulerSolver : public CFVMFlowSolverBaseval_marker where the coefficient is evaluated. + * \return Value of the u tau. + */ + inline virtual su2double GetUTau(unsigned short val_marker, unsigned long val_vertex) const { return 0; } + + /*! + * \brief A virtual member. + * \param[in] val_marker - Surface marker where the coefficient is computed. + * \param[in] val_vertex - Vertex of the marker val_marker where the coefficient is evaluated. + * \return Value of the eddy viscosity. + */ + inline virtual su2double GetEddyViscWall(unsigned short val_marker, unsigned long val_vertex) const { return 0; } + /*! * \brief A virtual member. * \return Value of the StrainMag_Max diff --git a/SU2_CFD/include/solvers/CTurbSASolver.hpp b/SU2_CFD/include/solvers/CTurbSASolver.hpp index 9ebaae737c6..41b82b4486e 100644 --- a/SU2_CFD/include/solvers/CTurbSASolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSASolver.hpp @@ -60,10 +60,8 @@ class CTurbSASolver final : public CTurbSolver { * \param[in] config - Definition of the particular problem. * \param[in] val_marker - Surface marker where the boundary condition is applied. */ - void SetNuTilde_WF(CGeometry *geometry, + void SetTurbVars_WF(CGeometry *geometry, CSolver **solver_container, - CNumerics *conv_numerics, - CNumerics *visc_numerics, const CConfig *config, unsigned short val_marker); diff --git a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp index 323f0a2542c..d00ce5c6d00 100644 --- a/SU2_CFD/include/solvers/CTurbSSTSolver.hpp +++ b/SU2_CFD/include/solvers/CTurbSSTSolver.hpp @@ -40,6 +40,23 @@ class CTurbSSTSolver final : public CTurbSolver { su2double constants[10] = {0.0}; /*!< \brief Constants for the model. */ + + + /*! + * \brief Compute nu tilde from the wall functions. + * \param[in] geometry - Geometrical definition of the problem. + * \param[in] solver_container - Container vector with all the solutions. + * \param[in] conv_numerics - Description of the numerical method. + * \param[in] visc_numerics - Description of the numerical method. + * \param[in] config - Definition of the particular problem. + * \param[in] val_marker - Surface marker where the boundary condition is applied. + */ + void SetTurbVars_WF(CGeometry *geometry, + CSolver **solver_container, + const CConfig *config, + unsigned short val_marker); + + public: /*! * \brief Constructor of the class. @@ -281,4 +298,5 @@ class CTurbSSTSolver final : public CTurbSolver { */ inline su2double GetOmega_Inf(void) const override { return Solution_Inf[1]; } + }; diff --git a/SU2_CFD/include/variables/CNSVariable.hpp b/SU2_CFD/include/variables/CNSVariable.hpp index 3de4dfa849a..876605c3de3 100644 --- a/SU2_CFD/include/variables/CNSVariable.hpp +++ b/SU2_CFD/include/variables/CNSVariable.hpp @@ -170,6 +170,7 @@ class CNSVariable final : public CEulerVariable { * \return Value of the wall shear stress computed by a wall function. */ inline su2double GetTauWall(unsigned long iPoint) const override { return Tau_Wall(iPoint); } + inline const VectorType& GetTauWall() const { return Tau_Wall; } /*! * \brief Get the DES length scale diff --git a/SU2_CFD/include/variables/CVariable.hpp b/SU2_CFD/include/variables/CVariable.hpp index 49fac6b79b7..e83e6c1376a 100644 --- a/SU2_CFD/include/variables/CVariable.hpp +++ b/SU2_CFD/include/variables/CVariable.hpp @@ -41,8 +41,6 @@ class CFluidModel; class CNEMOGas; -using namespace std; - /*! * \class CVariable * \brief Main class for defining the variables. diff --git a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp index 6de0576e9b6..9062cf1f04d 100644 --- a/SU2_CFD/src/numerics/flow/flow_diffusion.cpp +++ b/SU2_CFD/src/numerics/flow/flow_diffusion.cpp @@ -143,44 +143,24 @@ void CAvgGrad_Base::SetStressTensor(const su2double *val_primvar, } } -void CAvgGrad_Base::AddTauWall(const su2double *val_normal, - const su2double val_tau_wall) { +void CAvgGrad_Base::AddTauWall(const su2double *UnitNormal, + const su2double TauWall) { - unsigned short iDim, jDim; - su2double TauNormal, TauElem[3], TauTangent[3], WallShearStress, Area, UnitNormal[3]; + /*--- Compute the wall shear stress as the magnitude of the + tangential projection of the shear stress tensor. ---*/ - Area = GeometryToolbox::Norm(nDim, Normal); - - for (iDim = 0; iDim < nDim; iDim++) - UnitNormal[iDim] = val_normal[iDim]/Area; + su2double TauTangent[MAXNDIM]; + GeometryToolbox::TangentProjection(nDim, tau, UnitNormal, TauTangent); - /*--- First, compute wall shear stress as the magnitude of the wall-tangential - component of the shear stress tensor---*/ - - for (iDim = 0; iDim < nDim; iDim++) { - TauElem[iDim] = 0.0; - for (jDim = 0; jDim < nDim; jDim++) - TauElem[iDim] += tau[iDim][jDim]*UnitNormal[jDim]; - } - - TauNormal = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - TauNormal += TauElem[iDim] * UnitNormal[iDim]; - - for (iDim = 0; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; - - WallShearStress = 0.0; - for (iDim = 0; iDim < nDim; iDim++) - WallShearStress += TauTangent[iDim]*TauTangent[iDim]; - WallShearStress = sqrt(WallShearStress); + su2double WallShearStress = GeometryToolbox::Norm(nDim, TauTangent); + su2double Scale = TauWall / WallShearStress; /*--- Scale the stress tensor by the ratio of the wall shear stress - to the computed representation of the shear stress ---*/ + (from wall functions) to the one computed above. ---*/ - for (iDim = 0 ; iDim < nDim; iDim++) - for (jDim = 0 ; jDim < nDim; jDim++) - tau[iDim][jDim] = tau[iDim][jDim]*(val_tau_wall/WallShearStress); + for (auto iDim = 0u; iDim < nDim; iDim++) + for (auto jDim = 0u; jDim < nDim; jDim++) + tau[iDim][jDim] *= Scale; } void CAvgGrad_Base::SetTauJacobian(const su2double *val_Mean_PrimVar, @@ -401,7 +381,6 @@ CNumerics::ResidualType<> CAvgGrad_Flow::ComputeResidual(const CConfig* config) Mean_PrimVar[iVar] = 0.5*(PrimVar_i[iVar]+PrimVar_j[iVar]); } - /*--- Compute vector going from iPoint to jPoint ---*/ dist_ij_2 = 0.0; @@ -436,14 +415,12 @@ CNumerics::ResidualType<> CAvgGrad_Flow::ComputeResidual(const CConfig* config) dist_ij_2, nDim+1); } - /*--- Wall shear stress values (wall functions) ---*/ + /*--- Wall shear stress values (wall functions) only used if present for one but not both points (xor) ---*/ - if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); - else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; - else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; - else Mean_TauWall = -1.0; + const int scale = (TauWall_i > 0.0) ^ (TauWall_j > 0.0); + Mean_TauWall = (max(TauWall_i,0.0) + max(TauWall_j,0.0)) * scale; - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + /*--- If using UQ methodology, set Reynolds Stress tensor and perform perturbation ---*/ if (using_uq){ ComputePerturbedRSM(nDim, Eig_Val_Comp, uq_permute, uq_delta_b, uq_urlx, @@ -454,9 +431,9 @@ CNumerics::ResidualType<> CAvgGrad_Flow::ComputeResidual(const CConfig* config) /*--- Get projected flux tensor (viscous residual) ---*/ SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, - Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); if (config->GetQCR()) AddQCR(nDim, &Mean_GradPrimVar[1], tau); - if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); + if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); @@ -622,8 +599,24 @@ CNumerics::ResidualType<> CAvgGradInc_Flow::ComputeResidual(const CConfig* confi dist_ij_2, nVar); } + /*--- Wall shear stress values (wall functions) only used if present for one but not both points (xor) ---*/ + + const int scale = (TauWall_i > 0.0) ^ (TauWall_j > 0.0); + Mean_TauWall = (max(TauWall_i,0.0) + max(TauWall_j,0.0)) * scale; + + /*--- If using UQ methodology, set Reynolds Stress tensor and perform perturbation ---*/ + + if (using_uq){ + ComputePerturbedRSM(nDim, Eig_Val_Comp, uq_permute, uq_delta_b, uq_urlx, + Mean_GradPrimVar+1, Mean_PrimVar[nDim+2], Mean_Eddy_Viscosity, + Mean_turb_ke, MeanPerturbedRSM); + } + /*--- Get projected flux tensor (viscous residual) ---*/ - SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, + Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); + if (config->GetQCR()) AddQCR(nDim, &Mean_GradPrimVar[1], tau); + if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); GetViscousIncProjFlux(Mean_GradPrimVar, Normal, Mean_Thermal_Conductivity); @@ -933,14 +926,12 @@ CNumerics::ResidualType<> CGeneralAvgGrad_Flow::ComputeResidual(const CConfig* c dist_ij_2, nDim+1); } - /*--- Wall shear stress values (wall functions) ---*/ + /*--- Wall shear stress values (wall functions) only used if present for one but not both points (xor) ---*/ - if (TauWall_i > 0.0 && TauWall_j > 0.0) Mean_TauWall = 0.5*(TauWall_i + TauWall_j); - else if (TauWall_i > 0.0) Mean_TauWall = TauWall_i; - else if (TauWall_j > 0.0) Mean_TauWall = TauWall_j; - else Mean_TauWall = -1.0; + const int scale = (TauWall_i > 0.0) ^ (TauWall_j > 0.0); + Mean_TauWall = (max(TauWall_i,0.0) + max(TauWall_j,0.0)) * scale; - /* --- If using UQ methodology, set Reynolds Stress tensor and perform perturbation--- */ + /*--- If using UQ methodology, set Reynolds Stress tensor and perform perturbation ---*/ if (using_uq){ ComputePerturbedRSM(nDim, Eig_Val_Comp, uq_permute, uq_delta_b, uq_urlx, @@ -953,7 +944,7 @@ CNumerics::ResidualType<> CGeneralAvgGrad_Flow::ComputeResidual(const CConfig* c SetStressTensor(Mean_PrimVar, Mean_GradPrimVar, Mean_turb_ke, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity); if (config->GetQCR()) AddQCR(nDim, &Mean_GradPrimVar[1], tau); - if (Mean_TauWall > 0) AddTauWall(Normal, Mean_TauWall); + if (Mean_TauWall > 0) AddTauWall(UnitNormal, Mean_TauWall); SetHeatFluxVector(Mean_GradPrimVar, Mean_Laminar_Viscosity, Mean_Eddy_Viscosity, Mean_Thermal_Conductivity, Mean_Cp); diff --git a/SU2_CFD/src/numerics/flow/flow_sources.cpp b/SU2_CFD/src/numerics/flow/flow_sources.cpp index da7512418d2..24f6356f824 100644 --- a/SU2_CFD/src/numerics/flow/flow_sources.cpp +++ b/SU2_CFD/src/numerics/flow/flow_sources.cpp @@ -627,39 +627,62 @@ CNumerics::ResidualType<> CSourceWindGust::ComputeResidual(const CConfig* config u_gust = WindGust_i[0]; v_gust = WindGust_i[1]; +// w_gust = WindGust_i[2]; if (GustDir == X_DIR) { du_gust_dx = WindGustDer_i[0]; du_gust_dy = WindGustDer_i[1]; + //du_gust_dz = WindGustDer_i[2]; du_gust_dt = WindGustDer_i[2]; + dv_gust_dx = 0.0; dv_gust_dy = 0.0; + //dv_gust_dz = 0.0; dv_gust_dt = 0.0; + + //dw_gust_dx = 0.0; + //dw_gust_dy = 0.0; + //dw_gust_dz = 0.0; + //dw_gust_dt = 0.0; } else { du_gust_dx = 0.0; du_gust_dy = 0.0; + //du_gust_dz = 0.0; du_gust_dt = 0.0; dv_gust_dx = WindGustDer_i[0]; dv_gust_dy = WindGustDer_i[1]; + //dv_gust_dz = WindGustDer_i[2] dv_gust_dt = WindGustDer_i[2]; + //dw_gust_dx = 0.0; + //dw_gust_dy = 0.0; + //dw_gust_dz = 0.0; + //dw_gust_dt = 0.0; + // + } /*--- Primitive variables at point i ---*/ u = V_i[1]; v = V_i[2]; + // w = V_i[3] + p = V_i[nDim+1]; rho = V_i[nDim+2]; /*--- Source terms ---*/ smx = rho*(du_gust_dt + (u+u_gust)*du_gust_dx + (v+v_gust)*du_gust_dy); smy = rho*(dv_gust_dt + (u+u_gust)*dv_gust_dx + (v+v_gust)*dv_gust_dy); + //smz = rho*(dw_gust_dt + (u+u_gust)*dw_gust_dx + (v+v_gust)*dw_gust_dy) + (w+w_gust)*dw_gust_dz; + se = u*smx + v*smy + p*(du_gust_dx + dv_gust_dy); + //se = u*smx + v*smy + w*smz + p*(du_gust_dx + dv_gust_dy + dw_gust_dz); if (nDim == 2) { residual[0] = 0.0; residual[1] = smx*Volume; residual[2] = smy*Volume; + //residual[3] = smz*Volume; residual[3] = se*Volume; } else { SU2_MPI::Error("You should only be in the gust source term in two dimensions", CURRENT_FUNCTION); diff --git a/SU2_CFD/src/output/CFlowIncOutput.cpp b/SU2_CFD/src/output/CFlowIncOutput.cpp index 377eeb2e6f7..d688b97f85b 100644 --- a/SU2_CFD/src/output/CFlowIncOutput.cpp +++ b/SU2_CFD/src/output/CFlowIncOutput.cpp @@ -207,7 +207,8 @@ void CFlowIncOutput::SetHistoryOutputFields(CConfig *config){ /// DESCRIPTION: Maximal heatflux AddHistoryOutput("MAXIMUM_HEATFLUX", "maxHF", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total maximum heatflux on all surfaces set with MARKER_MONITORING.", HistoryFieldType::COEFFICIENT); /// DESCRIPTION: Temperature - AddHistoryOutput("AVG_TEMPERATURE", "Temp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total avg. temperature on all surfaces set with MARKER_MONITORING.", HistoryFieldType::COEFFICIENT); + if (heat || weakly_coupled_heat) + AddHistoryOutput("AVG_TEMPERATURE", "Temp", ScreenOutputFormat::SCIENTIFIC, "HEAT", "Total avg. temperature on all surfaces set with MARKER_MONITORING.", HistoryFieldType::COEFFICIENT); /// END_GROUP /// DESCRIPTION: Angle of attack @@ -462,7 +463,8 @@ void CFlowIncOutput::SetVolumeOutputFields(CConfig *config){ AddVolumeOutput("LIMITER_VELOCITY-Y", "Limiter_Velocity_y", "LIMITER", "Limiter value of the y-velocity"); if (nDim == 3) AddVolumeOutput("LIMITER_VELOCITY-Z", "Limiter_Velocity_z", "LIMITER", "Limiter value of the z-velocity"); - AddVolumeOutput("LIMITER_TEMPERATURE", "Limiter_Temperature", "LIMITER", "Limiter value of the temperature"); + if (heat || weakly_coupled_heat) + AddVolumeOutput("LIMITER_TEMPERATURE", "Limiter_Temperature", "LIMITER", "Limiter value of the temperature"); } if (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) { @@ -609,12 +611,11 @@ void CFlowIncOutput::LoadVolumeData(CConfig *config, CGeometry *geometry, CSolve SetVolumeOutputValue("LIMITER_PRESSURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 0)); SetVolumeOutputValue("LIMITER_VELOCITY-X", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 1)); SetVolumeOutputValue("LIMITER_VELOCITY-Y", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 2)); - if (nDim == 3){ + if (nDim == 3) SetVolumeOutputValue("LIMITER_VELOCITY-Z", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); - SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 4)); - } else { - SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, 3)); - } + if (heat || weakly_coupled_heat) + SetVolumeOutputValue("LIMITER_TEMPERATURE", iPoint, Node_Flow->GetLimiter_Primitive(iPoint, nDim+1)); + } if (config->GetKind_SlopeLimit_Turb() != NO_LIMITER) { @@ -669,12 +670,10 @@ void CFlowIncOutput::LoadSurfaceData(CConfig *config, CGeometry *geometry, CSolv SetVolumeOutputValue("SKIN_FRICTION-Y", iPoint, solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 1)); if (nDim == 3) SetVolumeOutputValue("SKIN_FRICTION-Z", iPoint, solver[FLOW_SOL]->GetCSkinFriction(iMarker, iVertex, 2)); - if (weakly_coupled_heat) SetVolumeOutputValue("HEAT_FLUX", iPoint, solver[HEAT_SOL]->GetHeatFlux(iMarker, iVertex)); else { SetVolumeOutputValue("HEAT_FLUX", iPoint, solver[FLOW_SOL]->GetHeatFlux(iMarker, iVertex)); - } SetVolumeOutputValue("Y_PLUS", iPoint, solver[FLOW_SOL]->GetYPlus(iMarker, iVertex)); } diff --git a/SU2_CFD/src/solvers/CEulerSolver.cpp b/SU2_CFD/src/solvers/CEulerSolver.cpp index 3b68949a6bd..28a27463418 100644 --- a/SU2_CFD/src/solvers/CEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CEulerSolver.cpp @@ -256,6 +256,8 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config, break; } + SetReferenceValues(*config); + /*--- Initialize fan face pressure, fan face mach number, and mass flow rate ---*/ for (iMarker = 0; iMarker < nMarker; iMarker++) { @@ -1605,6 +1607,29 @@ void CEulerSolver::SetNondimensionalization(CConfig *config, unsigned short iMes } +void CEulerSolver::SetReferenceValues(const CConfig& config) { + + /*--- Evaluate reference values for non-dimensionalization. For dynamic meshes, + use the motion Mach number as a reference value for computing the force coefficients. + Otherwise, use the freestream values, which is the standard convention. ---*/ + + su2double RefVel2; + + if (dynamic_grid && !config.GetFSI_Simulation()) { + su2double Gas_Constant = config.GetGas_ConstantND(); + su2double Mach2Vel = sqrt(Gamma * Gas_Constant * Temperature_Inf); + su2double Mach_Motion = config.GetMach_Motion(); + RefVel2 = pow(Mach_Motion * Mach2Vel, 2); + } + else { + RefVel2 = GeometryToolbox::SquaredNorm(nDim, Velocity_Inf); + } + + DynamicPressureRef = 0.5 * Density_Inf * RefVel2; + AeroCoeffForceRef = DynamicPressureRef * config.GetRefArea(); + +} + void CEulerSolver::SetInitialCondition(CGeometry **geometry, CSolver ***solver_container, CConfig *config, unsigned long TimeIter) { const bool restart = (config->GetRestart() || config->GetRestart_Flow()); @@ -4766,10 +4791,6 @@ void CEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container, visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); - /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ - - visc_numerics->SetTauWall(-1.0, -1.0); - /*--- Compute and update viscous residual ---*/ auto residual = visc_numerics->ComputeResidual(config); @@ -5258,10 +5279,6 @@ void CEulerSolver::BC_Riemann(CGeometry *geometry, CSolver **solver_container, visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); - /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ - - visc_numerics->SetTauWall(-1.0, -1.0); - /*--- Compute and update residual ---*/ auto residual = visc_numerics->ComputeResidual(config); @@ -5776,10 +5793,6 @@ void CEulerSolver::BC_TurboRiemann(CGeometry *geometry, CSolver **solver_contain visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); - /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ - - visc_numerics->SetTauWall(-1.0, -1.0); - /*--- Compute and update residual ---*/ auto residual = visc_numerics->ComputeResidual(config); @@ -6677,10 +6690,6 @@ void CEulerSolver::BC_Giles(CGeometry *geometry, CSolver **solver_container, CNu visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); - /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ - - visc_numerics->SetTauWall(-1.0, -1.0); - /*--- Compute and update residual ---*/ auto residual = visc_numerics->ComputeResidual(config); @@ -7006,10 +7015,6 @@ void CEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); @@ -7184,9 +7189,6 @@ void CEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container, // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); @@ -7332,10 +7334,6 @@ void CEulerSolver::BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_con // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); @@ -7458,10 +7456,6 @@ void CEulerSolver::BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_co // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); @@ -7682,10 +7676,6 @@ void CEulerSolver::BC_Engine_Inflow(CGeometry *geometry, CSolver **solver_contai // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); @@ -7937,10 +7927,6 @@ void CEulerSolver::BC_Engine_Exhaust(CGeometry *geometry, CSolver **solver_conta // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config) @@ -8505,10 +8491,6 @@ void CEulerSolver::BC_ActDisk(CGeometry *geometry, CSolver **solver_container, C // visc_numerics->SetTurbKineticEnergy(solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0), // solver_container[TURB_SOL]->GetNodes()->GetSolution(iPoint,0)); // -// /*--- Set the wall shear stress values (wall functions) to -1 (no evaluation using wall functions) ---*/ -// -// visc_numerics->SetTauWall(-1.0, -1.0); -// // /*--- Compute and update residual ---*/ // // auto residual = visc_numerics->ComputeResidual(config); diff --git a/SU2_CFD/src/solvers/CIncEulerSolver.cpp b/SU2_CFD/src/solvers/CIncEulerSolver.cpp index 38f0e794d11..3bfad9f5285 100644 --- a/SU2_CFD/src/solvers/CIncEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CIncEulerSolver.cpp @@ -192,6 +192,8 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned break; } + SetReferenceValues(*config); + /*--- Initialize the solution to the far-field state everywhere. ---*/ if (navier_stokes) { @@ -815,6 +817,29 @@ void CIncEulerSolver::SetNondimensionalization(CConfig *config, unsigned short i } +void CIncEulerSolver::SetReferenceValues(const CConfig& config) { + + /*--- Evaluate reference values for non-dimensionalization. For dimensional or non-dim + based on initial values, use the far-field state (inf). For a custom non-dim based + on user-provided reference values, use the ref values to compute the forces. ---*/ + + su2double RefDensity, RefVel2; + + if ((config.GetRef_Inc_NonDim() == DIMENSIONAL) || + (config.GetRef_Inc_NonDim() == INITIAL_VALUES)) { + RefDensity = Density_Inf; + RefVel2 = GeometryToolbox::SquaredNorm(nDim, Velocity_Inf); + } + else { + RefDensity = config.GetInc_Density_Ref(); + RefVel2 = pow(config.GetInc_Velocity_Ref(), 2); + } + + DynamicPressureRef = 0.5 * RefDensity * RefVel2; + AeroCoeffForceRef = DynamicPressureRef * config.GetRefArea(); + +} + void CIncEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned short iRKStep, unsigned short RunTime_EqSystem, bool Output) { diff --git a/SU2_CFD/src/solvers/CIncNSSolver.cpp b/SU2_CFD/src/solvers/CIncNSSolver.cpp index 6a564e5f111..5a749ddfea8 100644 --- a/SU2_CFD/src/solvers/CIncNSSolver.cpp +++ b/SU2_CFD/src/solvers/CIncNSSolver.cpp @@ -62,6 +62,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container const bool center = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED); const bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter()); const bool van_albada = (config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE); + const bool wall_functions = config->GetWall_Functions(); /*--- Common preprocessing steps (implemented by CEulerSolver) ---*/ @@ -97,6 +98,17 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container ComputeVorticityAndStrainMag<1>(*config, iMesh); + /*--- Compute the TauWall from the wall functions ---*/ + + if (wall_functions) { + SU2_OMP_MASTER + SetTauWall_WF(geometry, solver_container, config); + END_SU2_OMP_MASTER + // nijso: we have to set this as well?? + // seteddyviscfirstpoint + SU2_OMP_BARRIER + } + /*--- Compute recovered pressure and temperature for streamwise periodic flow ---*/ if (config->GetKind_Streamwise_Periodic() != ENUM_STREAMWISE_PERIODIC::NONE) Compute_Streamwise_Periodic_Recovered_Values(config, geometry, iMesh); @@ -377,9 +389,11 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con /*--- Get wall function treatment from config. ---*/ - const auto Wall_Function = config->GetWallFunction_Treatment(Marker_Tag); - if (Wall_Function != NO_WALL_FUNCTION) - SU2_MPI::Error("Wall function treatment not implemented yet", CURRENT_FUNCTION); + //const auto Wall_Function = config->GetWallFunction_Treatment(Marker_Tag); + // nijso: we do not have a special treatment yet for heated walls + // the wall function model is written for heat flux, we have to implement isothermal wall conditions + //if (Wall_Function != WALL_FUNCTIONS::NONE) + // SU2_MPI::Error("Wall function treament not implemented yet", CURRENT_FUNCTION); /*--- Loop over all of the vertices on this boundary marker ---*/ @@ -509,8 +523,7 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol /*--- Retrieve the specified wall function treatment.---*/ - const auto Wall_Function = config->GetWallFunction_Treatment(Marker_Tag); - if (Wall_Function != NO_WALL_FUNCTION) { + if (config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::NONE) { SU2_MPI::Error("Wall function treament not implemented yet", CURRENT_FUNCTION); } @@ -593,3 +606,264 @@ void CIncNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **sol } END_SU2_OMP_FOR } + +void CIncNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, const CConfig *config) { + /*--- + The wall function implemented herein is based on Nichols and Nelson AIAAJ v32 n6 2004. + At this moment, the wall function is only available for adiabatic flows. + ---*/ + + unsigned long notConvergedCounter = 0; /*--- counts the number of wall cells that are not converged ---*/ + unsigned long smallYPlusCounter = 0; /*--- counts the number of wall cells where y+ < 5 ---*/ + + const su2double Gas_Constant = config->GetGas_ConstantND(); + const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; + constexpr unsigned short max_iter =200; /*--- maximum number of iterations for the Newton Solver---*/ + const su2double tol = 1e-12; /*--- convergence criterium for the Newton solver, note that 1e-10 is too large ---*/ + const su2double relax = 0.5; /*--- relaxation factor for the Newton solver ---*/ + + /*--- Compute the recovery factor ---*/ + + // Molecular (Laminar) Prandtl number (see Nichols & Nelson, nomenclature ) + const su2double Recovery = pow(config->GetPrandtl_Lam(), (1.0/3.0)); + + /*--- Typical constants from boundary layer theory ---*/ + + const su2double kappa = config->GetwallModelKappa(); + const su2double B = config->GetwallModelB(); + + for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { + + if (!config->GetViscous_Wall(iMarker)) continue; + + /*--- Identify the boundary by string name ---*/ + + const auto Marker_Tag = config->GetMarker_All_TagBound(iMarker); + + /*--- Jump to another BC if it is not wall function ---*/ + + if (config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::STANDARD_FUNCTION) continue; + + /*--- Get the specified wall heat flux from config ---*/ + // note that we can get the heat flux from the temperature gradient + su2double q_w = 0.0; + + if (config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) + q_w = config->GetWall_HeatFlux(Marker_Tag); + + // heat flux from temperature: q_w = h*(T_wall - T_fluid) + + /*--- Loop over all of the vertices on this boundary marker ---*/ + + SU2_OMP_FOR_DYN(OMP_MIN_SIZE) + for (auto iVertex = 0u; iVertex < geometry->nVertex[iMarker]; iVertex++) { + + const auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode(); + const auto Point_Normal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor(); + + /*--- Check if the node belongs to the domain (i.e, not a halo node) + and the neighbor is not part of the physical boundary ---*/ + + if (!geometry->nodes->GetDomain(iPoint)) continue; + + /*--- Get coordinates of the current vertex and nearest normal point ---*/ + + const auto Coord = geometry->nodes->GetCoord(iPoint); + const auto Coord_Normal = geometry->nodes->GetCoord(Point_Normal); + + /*--- Compute dual-grid area and boundary normal ---*/ + + const auto Normal = geometry->vertex[iMarker][iVertex]->GetNormal(); + + su2double Area = GeometryToolbox::Norm(nDim, Normal); + + su2double UnitNormal[MAXNDIM] = {0.0}; + for (auto iDim = 0u; iDim < nDim; iDim++) + UnitNormal[iDim] = -Normal[iDim]/Area; + + /*--- Get the velocity, pressure, and temperature at the nearest + (normal) interior point. ---*/ + + su2double Vel[MAXNDIM] = {0.0}; + for (auto iDim = 0u; iDim < nDim; iDim++) + Vel[iDim] = nodes->GetVelocity(Point_Normal,iDim); + + /*--- Compute the wall-parallel velocity at first point off the wall ---*/ + + su2double VelNormal = GeometryToolbox::DotProduct(int(MAXNDIM), Vel, UnitNormal); + + su2double VelTang[MAXNDIM] = {0.0}; + for (auto iDim = 0u; iDim < nDim; iDim++) + VelTang[iDim] = Vel[iDim] - VelNormal*UnitNormal[iDim]; + + su2double VelTangMod = GeometryToolbox::Norm(int(MAXNDIM), VelTang); + + /*--- Compute normal distance of the interior point from the wall ---*/ + + su2double WallDist[MAXNDIM] = {0.0}; + GeometryToolbox::Distance(nDim, Coord, Coord_Normal, WallDist); + + su2double WallDistMod = GeometryToolbox::Norm(int(MAXNDIM), WallDist); + + /*--- Compute the wall temperature using the Crocco-Buseman equation. + * In incompressible flows, we can assume that there is no velocity-related + * temperature change Prandtl: T+ = Pr*y+ ---*/ + su2double T_Wall = nodes->GetTemperature(iPoint); + + /*--- Extrapolate the pressure from the interior & compute the + wall density using the equation of state ---*/ + + /*--- incompressible formulation ---*/ + su2double Density_Wall = nodes->GetDensity(iPoint); + su2double Conductivity_Wall = nodes->GetThermalConductivity(iPoint); + su2double Lam_Visc_Normal = nodes->GetLaminarViscosity(Point_Normal); + + /*--- Compute the shear stress at the wall in the regular fashion + by using the stress tensor on the surface ---*/ + + su2double tau[MAXNDIM][MAXNDIM] = {{0.0}}; + su2double Lam_Visc_Wall = nodes->GetLaminarViscosity(iPoint); + su2double Eddy_Visc_Wall = nodes->GetEddyViscosity(iPoint); + // do we need the total viscosity for the stress tensor? + //su2double total_viscosity = (Lam_Visc_Wall + Eddy_Visc_Wall); + CNumerics::ComputeStressTensor(nDim, tau, nodes->GetGradient_Primitive(iPoint)+1, Lam_Visc_Wall); + + su2double TauTangent[MAXNDIM] = {0.0}; + GeometryToolbox::TangentProjection(nDim, tau, UnitNormal, TauTangent); + + su2double WallShearStress = GeometryToolbox::Norm(int(MAXNDIM), TauTangent); + + /*--- Calculate the quantities from boundary layer theory and + iteratively solve for a new wall shear stress. Use the current wall + shear stress as a starting guess for the wall function. ---*/ + + unsigned long counter = 0; + su2double diff = 1.0; + su2double U_Tau = max(1.0e-6,sqrt(WallShearStress/Density_Wall)); + su2double Y_Plus = 5.0; // clipping value + + su2double Y_Plus_Start = Density_Wall * U_Tau * WallDistMod / Lam_Visc_Wall; + + /*--- Automatic switch off when y+ < 5 according to Nichols & Nelson (2004) ---*/ + + if (Y_Plus_Start < Y_Plus) { + /*--- impose a minimum y+ for stability reasons---*/ + smallYPlusCounter++; + } + else { + while (fabs(diff) > tol) { + + /*--- Friction velocity and u+ ---*/ + + su2double U_Plus = VelTangMod/U_Tau; + + /*--- Gamma, Beta, Q, and Phi, defined by Nichols & Nelson (2004) page 1110 ---*/ + + su2double Gam = Recovery*U_Tau*U_Tau/(2.0*Cp*T_Wall); + /*--- nijso: heated wall needs validation testcase! ---*/ + su2double Beta = q_w*Lam_Visc_Wall/(Density_Wall*T_Wall*Conductivity_Wall*U_Tau); // TODO: nonzero heatflux needs validation case + su2double Q = sqrt(Beta*Beta + 4.0*Gam); + su2double Phi = asin(-1.0*Beta/Q); + + /*--- Y+ defined by White & Christoph (compressibility and heat transfer) negative value for (2.0*Gam*U_Plus - Beta)/Q ---*/ + + su2double Y_Plus_White = exp((kappa/sqrt(Gam))*(asin((2.0*Gam*U_Plus - Beta)/Q) - Phi))*exp(-1.0*kappa*B); + + /*--- Spalding's universal form for the BL velocity with the + outer velocity form of White & Christoph above. ---*/ + + su2double kUp = kappa*U_Plus; + Y_Plus = U_Plus + Y_Plus_White - (exp(-1.0*kappa*B)* (1.0 + kUp + 0.5*kUp*kUp + kUp*kUp*kUp/6.0)); + + su2double dypw_dyp = 2.0*Y_Plus_White*(kappa*sqrt(Gam)/Q)*sqrt(1.0 - pow(2.0*Gam*U_Plus - Beta,2.0)/(Q*Q)); + + Eddy_Visc_Wall = Lam_Visc_Wall*(1.0 + dypw_dyp - kappa*exp(-1.0*kappa*B)* + (1.0 + kappa*U_Plus + kappa*kappa*U_Plus*U_Plus/2.0) + - Lam_Visc_Normal/Lam_Visc_Wall); + Eddy_Visc_Wall = max(1.0e-6, Eddy_Visc_Wall); + + /* --- Define function for Newton method to zero --- */ + + diff = (Density_Wall * U_Tau * WallDistMod / Lam_Visc_Wall) - Y_Plus; + + /* --- Gradient of function defined above --- */ + + su2double grad_diff = Density_Wall * WallDistMod / Lam_Visc_Wall + VelTangMod / (U_Tau * U_Tau) + + kappa /(U_Tau * sqrt(Gam)) * asin(U_Plus * sqrt(Gam)) * Y_Plus_White - + exp(-1.0 * B * kappa) * (0.5 * pow(VelTangMod * kappa / U_Tau, 3) + + pow(VelTangMod * kappa / U_Tau, 2) + VelTangMod * kappa / U_Tau) / U_Tau; + + /* --- Newton Step --- */ + + U_Tau = U_Tau - relax*(diff / grad_diff); + + counter++; + if (counter > max_iter) { + notConvergedCounter++; + // use some safe values for convergence + Y_Plus = 30.0; + Eddy_Visc_Wall = 1.0; + U_Tau = 1.0; + break; + } + } + } + + /*--- Calculate an updated value for the wall shear stress + using the y+ value, the definition of y+, and the definition of + the friction velocity. ---*/ + + YPlus[iMarker][iVertex] = Y_Plus; + EddyViscWall[iMarker][iVertex] = Eddy_Visc_Wall; + UTau[iMarker][iVertex] = U_Tau; + + // wall model value + su2double Tau_Wall = (1.0/Density_Wall)*pow(Y_Plus*Lam_Visc_Wall/WallDistMod,2.0); + + // nijso: skinfriction for wall functions gives opposite sign? + + for (auto iDim = 0u; iDim < nDim; iDim++) + CSkinFriction[iMarker](iVertex,iDim) = (Tau_Wall/WallShearStress)*TauTangent[iDim] / DynamicPressureRef; + + nodes->SetTauWall(iPoint, Tau_Wall); + // for compressible flow: + //nodes->SetTemperature(iPoint,T_Wall); + //nodes->SetSolution(iPoint, 0, Density_Wall); + //nodes->SetPrimitive(iPoint, nDim + 1, P_Wall); + // for incompressible flow: + // ...? + + } + END_SU2_OMP_FOR + } + + if (config->GetComm_Level() == COMM_FULL) { + static unsigned long globalCounter1, globalCounter2; + + ompMasterAssignBarrier(globalCounter1,0, globalCounter2,0); + + SU2_OMP_ATOMIC + globalCounter1 += notConvergedCounter; + + SU2_OMP_ATOMIC + globalCounter2 += smallYPlusCounter; + + SU2_OMP_BARRIER + SU2_OMP_MASTER { + SU2_MPI::Allreduce(&globalCounter1, ¬ConvergedCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&globalCounter2, &smallYPlusCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm()); + + if (rank == MASTER_NODE) { + if (notConvergedCounter) + cout << "Warning: Computation of wall coefficients (y+) did not converge in " + << notConvergedCounter << " points." << endl; + + if (smallYPlusCounter) + cout << "Warning: y+ < 5.0 in " << smallYPlusCounter + << " points, for which the wall model is not active." << endl; + } + } + END_SU2_OMP_MASTER + } + +} diff --git a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp index 27a820d0cc0..e596e225ae0 100644 --- a/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMOEulerSolver.cpp @@ -175,6 +175,8 @@ CNEMOEulerSolver::CNEMOEulerSolver(CGeometry *geometry, CConfig *config, break; } + SetReferenceValues(*config); + /*--- Vectorize free stream Mach number based on AoA & AoS ---*/ Mvec_Inf = new su2double[nDim]; Alpha = config->GetAoA()*PI_NUMBER/180.0; @@ -1451,6 +1453,13 @@ void CNEMOEulerSolver::SetNondimensionalization(CConfig *config, unsigned short } } +void CNEMOEulerSolver::SetReferenceValues(const CConfig& config) { + + DynamicPressureRef = 0.5 * Density_Inf * GeometryToolbox::SquaredNorm(nDim, Velocity_Inf); + AeroCoeffForceRef = DynamicPressureRef * config.GetRefArea(); + +} + void CNEMOEulerSolver::BC_Sym_Plane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { diff --git a/SU2_CFD/src/solvers/CNEMONSSolver.cpp b/SU2_CFD/src/solvers/CNEMONSSolver.cpp index 8c51b809865..3a10d22f102 100644 --- a/SU2_CFD/src/solvers/CNEMONSSolver.cpp +++ b/SU2_CFD/src/solvers/CNEMONSSolver.cpp @@ -969,9 +969,8 @@ void CNEMONSSolver::BC_Smoluchowski_Maxwell(CGeometry *geometry, su2double dTn, dTven; su2double rhoCvtr, rhoCvve; - su2double TauElem[MAXNDIM] = {0.0}, TauTangent[MAXNDIM] = {0.0}; + su2double TauTangent[MAXNDIM] = {0.0}; su2double Tau[MAXNDIM][MAXNDIM] = {{0.0}}; - su2double TauNormal; bool ionization = config->GetIonization(); @@ -1095,14 +1094,8 @@ void CNEMONSSolver::BC_Smoluchowski_Maxwell(CGeometry *geometry, Res_Visc[iVar] = 0.0; CNumerics::ComputeStressTensor(nDim, Tau, Grad_PrimVar+VEL_INDEX, Viscosity); - for (iDim = 0; iDim < nDim; iDim++) - TauElem[iDim] = GeometryToolbox::DotProduct(nDim, Tau[iDim], UnitNormal); - - /*--- Compute wall shear stress (using the stress tensor) ---*/ - TauNormal = GeometryToolbox::DotProduct(nDim, TauElem, UnitNormal); - for (iDim = 0; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; + GeometryToolbox::TangentProjection(nDim, Tau, UnitNormal, TauTangent); /*--- Store the Slip Velocity at the wall */ for (iDim = 0; iDim < nDim; iDim++) diff --git a/SU2_CFD/src/solvers/CNSSolver.cpp b/SU2_CFD/src/solvers/CNSSolver.cpp index 6c602327ff1..f3b57266d66 100644 --- a/SU2_CFD/src/solvers/CNSSolver.cpp +++ b/SU2_CFD/src/solvers/CNSSolver.cpp @@ -417,7 +417,7 @@ void CNSSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_container su2double Wall_HeatFlux = config->GetWall_HeatFlux(Marker_Tag)/config->GetHeat_Flux_Ref(); // Wall_Function = config->GetWallFunction_Treatment(Marker_Tag); -// if (Wall_Function != NO_WALL_FUNCTION) { +// if (Wall_Function != WALL_FUNCTION::NONE) { // SU2_MPI::Error("Wall function treament not implemented yet", CURRENT_FUNCTION); // } @@ -578,7 +578,7 @@ void CNSSolver::BC_Isothermal_Wall_Generic(CGeometry *geometry, CSolver **solver } // Wall_Function = config->GetWallFunction_Treatment(Marker_Tag); -// if (Wall_Function != NO_WALL_FUNCTION) { +// if (Wall_Function != WALL_FUNCTION::NONE) { // SU2_MPI::Error("Wall function treament not implemented yet", CURRENT_FUNCTION); // } @@ -722,33 +722,36 @@ void CNSSolver::BC_Isothermal_Wall_Generic(CGeometry *geometry, CSolver **solver void CNSSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) { - BC_Isothermal_Wall_Generic(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); } void CNSSolver::BC_ConjugateHeat_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CConfig *config, unsigned short val_marker) { - BC_Isothermal_Wall_Generic(geometry, solver_container, conv_numerics, nullptr, config, val_marker, true); } void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, const CConfig *config) { + /*--- + The wall function implemented herein is based on Nichols and Nelson AIAAJ v32 n6 2004. + At this moment, the wall function is only available for adiabatic flows. + ---*/ + unsigned long notConvergedCounter = 0, skipCounter = 0; const su2double Gas_Constant = config->GetGas_ConstantND(); const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; - constexpr unsigned short max_iter = 10; - const su2double tol = 1e-6; - const su2double relax = 0.25; + constexpr unsigned short max_iter = 200; /*--- maximum number of iterations for the Newton Solver---*/ + const su2double tol = 1e-12; /*--- convergence criterium for the Newton solver, note that 1e-10 is too large ---*/ + const su2double relax = 0.5; /*--- relaxation factor for the Newton solver ---*/ /*--- Compute the recovery factor ---*/ - // Double-check: laminar or turbulent Pr for this? + // Molecular (Laminar) Prandtl number (see Nichols & Nelson, nomenclature ) const su2double Recovery = pow(config->GetPrandtl_Lam(), (1.0/3.0)); /*--- Typical constants from boundary layer theory ---*/ - const su2double kappa = 0.4; - const su2double B = 5.5; + const su2double kappa = config->GetwallModelKappa(); + const su2double B = config->GetwallModelB(); for (auto iMarker = 0u; iMarker < config->GetnMarker_All(); iMarker++) { @@ -758,9 +761,18 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, c const auto Marker_Tag = config->GetMarker_All_TagBound(iMarker); + /*--- Jump to another BC if it is not wall function ---*/ + + if (config->GetWallFunction_Treatment(Marker_Tag) != WALL_FUNCTIONS::STANDARD_FUNCTION) + continue; + /*--- Get the specified wall heat flux from config ---*/ + // note that we can get the heat flux from the temperature gradient + su2double q_w = 0.0; + if (config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) + q_w = config->GetWall_HeatFlux(Marker_Tag); - // Wall_HeatFlux = config->GetWall_HeatFlux(Marker_Tag); + // heat flux from temperature: q_w = h*(T_wall - T_fluid) /*--- Loop over all of the vertices on this boundary marker ---*/ @@ -796,12 +808,13 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, c su2double Vel[MAXNDIM] = {0.0}; for (auto iDim = 0u; iDim < nDim; iDim++) Vel[iDim] = nodes->GetVelocity(Point_Normal,iDim); + su2double P_Normal = nodes->GetPressure(Point_Normal); su2double T_Normal = nodes->GetTemperature(Point_Normal); /*--- Compute the wall-parallel velocity at first point off the wall ---*/ - su2double VelNormal = GeometryToolbox::DotProduct(nDim, Vel, UnitNormal); + su2double VelNormal = GeometryToolbox::DotProduct(int(MAXNDIM), Vel, UnitNormal); su2double VelTang[MAXNDIM] = {0.0}; for (auto iDim = 0u; iDim < nDim; iDim++) @@ -816,67 +829,65 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, c su2double WallDistMod = GeometryToolbox::Norm(int(MAXNDIM), WallDist); - /*--- Compute mach number ---*/ - - // M_Normal = VelTangMod / sqrt(Gamma * Gas_Constant * T_Normal); - /*--- Compute the wall temperature using the Crocco-Buseman equation ---*/ - //T_Wall = T_Normal * (1.0 + 0.5*Gamma_Minus_One*Recovery*M_Normal*M_Normal); + //Mach2_Normal = pow(VelTangMod,2) / (Gamma * Gas_Constant * T_Normal); + //T_Wall = T_Normal * (1.0 + 0.5*Gamma_Minus_One*Recovery*Mach2_Normal); su2double T_Wall = T_Normal + Recovery*pow(VelTangMod,2.0)/(2.0*Cp); /*--- Extrapolate the pressure from the interior & compute the wall density using the equation of state ---*/ + /*--- compressible formulation ---*/ su2double P_Wall = P_Normal; su2double Density_Wall = P_Wall/(Gas_Constant*T_Wall); + su2double Conductivity_Wall = nodes->GetThermalConductivity(iPoint); + su2double Lam_Visc_Normal = nodes->GetLaminarViscosity(Point_Normal); + /*--- Compute the shear stress at the wall in the regular fashion by using the stress tensor on the surface ---*/ - su2double tau[MAXNDIM][MAXNDIM] = {{0.0}}, TauElem[MAXNDIM] = {0.0}; + su2double tau[MAXNDIM][MAXNDIM] = {{0.0}}; su2double Lam_Visc_Wall = nodes->GetLaminarViscosity(iPoint); CNumerics::ComputeStressTensor(nDim, tau, nodes->GetGradient_Primitive(iPoint)+1, Lam_Visc_Wall); - for (auto iDim = 0u; iDim < nDim; iDim++) { - TauElem[iDim] = GeometryToolbox::DotProduct(nDim, tau[iDim], UnitNormal); - } - - /*--- Compute wall shear stress as the magnitude of the wall-tangential - component of the shear stress tensor---*/ - - su2double TauNormal = GeometryToolbox::DotProduct(nDim, TauElem, UnitNormal); - su2double TauTangent[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim]; + GeometryToolbox::TangentProjection(nDim, tau, UnitNormal, TauTangent); - su2double Tau_Wall = GeometryToolbox::Norm(int(MAXNDIM), TauTangent); + su2double WallShearStress = GeometryToolbox::Norm(int(MAXNDIM), TauTangent); /*--- Calculate the quantities from boundary layer theory and iteratively solve for a new wall shear stress. Use the current wall shear stress as a starting guess for the wall function. ---*/ - su2double Tau_Wall_Old = Tau_Wall; - unsigned short counter = 0; - su2double diff = 1.0; + unsigned long counter = 0; + su2double diff = 1.0, Eddy_Visc = 1.0; + su2double U_Tau = sqrt(WallShearStress/Density_Wall); + su2double Y_Plus = 5.0; - while (diff > tol) { + su2double Y_Plus_Start = Density_Wall * U_Tau * WallDistMod / Lam_Visc_Wall; + + /*--- Automatic switch off when y+ < 5 according to Nichols & Nelson (2004) ---*/ + + if (Y_Plus_Start < Y_Plus) { + skipCounter++; + } + else while (fabs(diff) > tol) { /*--- Friction velocity and u+ ---*/ - su2double U_Tau = sqrt(Tau_Wall_Old/Density_Wall); su2double U_Plus = VelTangMod/U_Tau; - /*--- Gamma, Beta, Q, and Phi, defined by Nichols & Nelson (2004) ---*/ + /*--- Gamma, Beta, Q, and Phi, defined by Nichols & Nelson (2004) page 1110 ---*/ - su2double Gam = Recovery*pow(U_Tau,2)/(2.0*Cp*T_Wall); - su2double Beta = 0.0; // For adiabatic flows only + su2double Gam = Recovery*U_Tau*U_Tau/(2.0*Cp*T_Wall); + /*--- nijso: heated wall needs validation testcase! ---*/ + su2double Beta = q_w*Lam_Visc_Wall/(Density_Wall*T_Wall*Conductivity_Wall*U_Tau); // TODO: nonzero heatflux needs validation case su2double Q = sqrt(Beta*Beta + 4.0*Gam); su2double Phi = asin(-1.0*Beta/Q); - /*--- Y+ defined by White & Christoph (compressibility and heat transfer) - negative value for (2.0*Gam*U_Plus - Beta)/Q ---*/ + /*--- Y+ defined by White & Christoph (compressibility and heat transfer) negative value for (2.0*Gam*U_Plus - Beta)/Q ---*/ su2double Y_Plus_White = exp((kappa/sqrt(Gam))*(asin((2.0*Gam*U_Plus - Beta)/Q) - Phi))*exp(-1.0*kappa*B); @@ -884,33 +895,92 @@ void CNSSolver::SetTauWall_WF(CGeometry *geometry, CSolver **solver_container, c outer velocity form of White & Christoph above. ---*/ su2double kUp = kappa*U_Plus; - su2double Y_Plus = U_Plus + Y_Plus_White - exp(-1.0*kappa*B) * (1.0 + kUp*(1.0 + 0.5*kUp + pow(kUp,2)/6.0)); + su2double Y_Plus = U_Plus + Y_Plus_White - (exp(-1.0*kappa*B)* (1.0 + kUp + 0.5*kUp*kUp + kUp*kUp*kUp/6.0)); + + su2double dypw_dyp = 2.0*Y_Plus_White*(kappa*sqrt(Gam)/Q)*sqrt(1.0 - pow(2.0*Gam*U_Plus - Beta,2.0)/(Q*Q)); + + Eddy_Visc = Lam_Visc_Wall*(1.0 + dypw_dyp - kappa*exp(-1.0*kappa*B)* + (1.0 + kappa*U_Plus + kappa*kappa*U_Plus*U_Plus/2.0) + - Lam_Visc_Normal/Lam_Visc_Wall); + Eddy_Visc = max(1.0e-6, Eddy_Visc); + + /* --- Define function for Newton method to zero --- */ - /*--- Calculate an updated value for the wall shear stress using the y+ value, - the definition of y+, and the definition of the friction velocity. ---*/ + diff = (Density_Wall * U_Tau * WallDistMod / Lam_Visc_Wall) - Y_Plus; - Tau_Wall = (1.0/Density_Wall)*pow(Y_Plus*Lam_Visc_Wall/WallDistMod,2.0); + /* --- Gradient of function defined above --- */ - /*--- Difference between the old and new Tau. Update old value. ---*/ + su2double grad_diff = Density_Wall * WallDistMod / Lam_Visc_Wall + VelTangMod / (U_Tau * U_Tau) + + kappa /(U_Tau * sqrt(Gam)) * asin(U_Plus * sqrt(Gam)) * Y_Plus_White - + exp(-1.0 * B * kappa) * (0.5 * pow(VelTangMod * kappa / U_Tau, 3) + + pow(VelTangMod * kappa / U_Tau, 2) + VelTangMod * kappa / U_Tau) / U_Tau; - diff = fabs(Tau_Wall-Tau_Wall_Old); - Tau_Wall_Old += relax * (Tau_Wall-Tau_Wall_Old); + /* --- Newton Step --- */ + + U_Tau = U_Tau - relax*(diff / grad_diff); counter++; + if (counter > max_iter) { - cout << "WARNING: Tau_Wall evaluation has not converged in CNSSolver.cpp" << endl; - cout << Tau_Wall_Old << " " << Tau_Wall << " " << diff << endl; + notConvergedCounter++; + // use some safe values for convergence + Y_Plus = 30.0; + Eddy_Visc = 1.0; + U_Tau = 1.0; break; } } + /*--- Calculate an updated value for the wall shear stress + using the y+ value, the definition of y+, and the definition of + the friction velocity. ---*/ + + YPlus[iMarker][iVertex] = Y_Plus; + EddyViscWall[iMarker][iVertex] = Eddy_Visc; + UTau[iMarker][iVertex] = U_Tau; + + // wall model value + su2double Tau_Wall = (1.0/Density_Wall)*pow(Y_Plus*Lam_Visc_Wall/WallDistMod,2.0); + + for (auto iDim = 0u; iDim < nDim; iDim++) + CSkinFriction[iMarker](iVertex,iDim) = (Tau_Wall/WallShearStress)*TauTangent[iDim] / DynamicPressureRef; + /*--- Store this value for the wall shear stress at the node. ---*/ nodes->SetTauWall(iPoint, Tau_Wall); } - END_SU2_OMP_FOR } + END_SU2_OMP_FOR + + if (config->GetComm_Level() == COMM_FULL) { + static unsigned long globalCounter1, globalCounter2; + + ompMasterAssignBarrier(globalCounter1,0, globalCounter2,0); + + SU2_OMP_ATOMIC + globalCounter1 += notConvergedCounter; + + SU2_OMP_ATOMIC + globalCounter2 += skipCounter; + + SU2_OMP_BARRIER + SU2_OMP_MASTER { + SU2_MPI::Allreduce(&globalCounter1, ¬ConvergedCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm()); + SU2_MPI::Allreduce(&globalCounter2, &skipCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm()); + + if (rank == MASTER_NODE) { + if (notConvergedCounter) + cout << "Warning: Computation of wall coefficients (y+) did not converge in " + << notConvergedCounter << " points." << endl; + + if (skipCounter) + cout << "Warning: y+ < 5.0 in " << skipCounter + << " points, for which the wall model is not active." << endl; + } + } + END_SU2_OMP_MASTER + } } diff --git a/SU2_CFD/src/solvers/CTurbSASolver.cpp b/SU2_CFD/src/solvers/CTurbSASolver.cpp index 67e875c2422..21d307bdac0 100644 --- a/SU2_CFD/src/solvers/CTurbSASolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSASolver.cpp @@ -413,7 +413,7 @@ void CTurbSASolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_conta if (config->GetWall_Functions()) { SU2_OMP_MASTER - SetNuTilde_WF(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker); + SetTurbVars_WF(geometry, solver_container, config, val_marker); END_SU2_OMP_MASTER SU2_OMP_BARRIER return; @@ -580,7 +580,6 @@ void CTurbSASolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container, CN conv_numerics->SetPrimitive(V_domain, V_inlet); - /*--- Set the turbulent variable states (prescribed for an inflow) ---*/ /*--- Load the inlet turbulence variable (uniform by default). ---*/ conv_numerics->SetTurbVar(nodes->GetSolution(iPoint), Inlet_TurbVars[val_marker][iVertex]); @@ -1574,24 +1573,20 @@ void CTurbSASolver::BC_NearField_Boundary(CGeometry *geometry, CSolver **solver_ // } -void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, - CNumerics *visc_numerics, const CConfig *config, unsigned short val_marker) { +void CTurbSASolver::SetTurbVars_WF(CGeometry *geometry, CSolver **solver_container, + const CConfig *config, unsigned short val_marker) { const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); - const su2double Gas_Constant = config->GetGas_ConstantND(); - const su2double Cp = (Gamma / Gamma_Minus_One) * Gas_Constant; - constexpr unsigned short max_iter = 100; - const su2double tol = 1e-10; + /*--- We use a very high max nr of iterations, but we only need this the first couple of iterations ---*/ + constexpr unsigned short max_iter = 200; - /*--- Compute the recovery factor ---*/ - // su2double-check: laminar or turbulent Pr for this? - const su2double Recovery = pow(config->GetPrandtl_Lam(),(1.0/3.0)); + /* --- tolerance has LARGE impact on convergence, do not increase this value! --- */ + const su2double tol = 1e-12; + su2double relax = 0.5; /*--- relaxation factor for the Newton solver ---*/ /*--- Typical constants from boundary layer theory ---*/ - const su2double kappa = 0.4; - const su2double B = 5.5; const su2double cv1_3 = 7.1*7.1*7.1; CVariable* flow_nodes = solver_container[FLOW_SOL]->GetNodes(); @@ -1600,126 +1595,63 @@ void CTurbSASolver::SetNuTilde_WF(CGeometry *geometry, CSolver **solver_containe for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { - const auto Point_Normal = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - - if (!geometry->nodes->GetDomain(Point_Normal)) continue; - const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); + const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); - /*--- Compute dual-grid area and boundary normal ---*/ - - const auto Normal = geometry->vertex[val_marker][iVertex]->GetNormal(); - - su2double Area = GeometryToolbox::Norm(nDim, Normal); - - su2double UnitNormal[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - UnitNormal[iDim] = -Normal[iDim]/Area; - - /*--- Get the velocity, pressure, and temperature at the nearest - (normal) interior point. ---*/ - - su2double Vel[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - Vel[iDim] = flow_nodes->GetVelocity(Point_Normal,iDim); - su2double P_Normal = flow_nodes->GetPressure(Point_Normal); - su2double T_Normal = flow_nodes->GetTemperature(Point_Normal); - - /*--- Compute the wall-parallel velocity at first point off the wall ---*/ - - su2double VelNormal = GeometryToolbox::DotProduct(int(MAXNDIM), Vel, UnitNormal); - - su2double VelTang[MAXNDIM] = {0.0}; - for (auto iDim = 0u; iDim < nDim; iDim++) - VelTang[iDim] = Vel[iDim] - VelNormal*UnitNormal[iDim]; - - su2double VelTangMod = GeometryToolbox::Norm(int(MAXNDIM), VelTang); - - /*--- Compute the wall temperature using the Crocco-Buseman equation ---*/ - - //T_Wall = T_Normal * (1.0 + 0.5*Gamma_Minus_One*Recovery*M_Normal*M_Normal); - su2double T_Wall = T_Normal + Recovery*pow(VelTangMod,2.0)/(2.0*Cp); - - /*--- Extrapolate the pressure from the interior & compute the - wall density using the equation of state ---*/ - - su2double P_Wall = P_Normal; - su2double Density_Wall = P_Wall/(Gas_Constant*T_Wall); - - /*--- Get wall shear stress computed by flow solver ---*/ - - su2double Lam_Visc_Wall = flow_nodes->GetLaminarViscosity(iPoint); - su2double Tau_Wall = flow_nodes->GetTauWall(iPoint); - - /*--- Friction velocity and u+ ---*/ - - su2double U_Tau = sqrt(Tau_Wall/Density_Wall); - su2double U_Plus = VelTangMod/U_Tau; - - /*--- Gamma, Beta, Q, and Phi, defined by Nichols & Nelson (2004) ---*/ - - su2double Gam = Recovery*U_Tau*U_Tau/(2.0*Cp*T_Wall); - su2double Beta = 0.0; // For adiabatic flows only - su2double Q = sqrt(Beta*Beta + 4.0*Gam); - su2double Phi = asin(-1.0*Beta/Q); - - /*--- Y+ defined by White & Christoph (compressibility and heat transfer) - negative value for (2.0*Gam*U_Plus - Beta)/Q ---*/ - - su2double Y_Plus_White = exp((kappa/sqrt(Gam))*(asin((2.0*Gam*U_Plus - Beta)/Q) - Phi))*exp(-1.0*kappa*B); - - /*--- Now compute the Eddy viscosity at the first point off of the wall ---*/ + /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ - su2double Lam_Visc_Normal = flow_nodes->GetLaminarViscosity(Point_Normal); - su2double Density_Normal = flow_nodes->GetDensity(Point_Normal); - su2double Kin_Visc_Normal = Lam_Visc_Normal/Density_Normal; + if (geometry->nodes->GetDomain(iPoint_Neighbor)) { - su2double dypw_dyp = 2.0*Y_Plus_White*(kappa*sqrt(Gam)/Q)*sqrt(1.0 - pow(2.0*Gam*U_Plus - Beta,2.0)/(Q*Q)); - su2double Eddy_Visc = Lam_Visc_Wall*(1.0 + dypw_dyp - kappa*exp(-1.0*kappa*B)* - (1.0 + kappa*U_Plus + kappa*kappa*U_Plus*U_Plus/2.0) - - Lam_Visc_Normal/Lam_Visc_Wall); + su2double Y_Plus = solver_container[FLOW_SOL]->GetYPlus(val_marker, iVertex); - /*--- Eddy viscosity should be always a positive number ---*/ + /*--- note that we do not do anything for y+ < 5, meaning that we have a zero flux (Neumann) boundary condition ---*/ - Eddy_Visc = max(0.0, Eddy_Visc); + if (Y_Plus < 5.0) continue; - /*--- Solve for the new value of nu_tilde given the eddy viscosity and using a Newton method ---*/ + su2double Lam_Visc_Normal = flow_nodes->GetLaminarViscosity(iPoint_Neighbor); + su2double Density_Normal = flow_nodes->GetDensity(iPoint_Neighbor); + su2double Kin_Visc_Normal = Lam_Visc_Normal/Density_Normal; - su2double nu_til_old = nodes->GetSolution(iPoint,0); + su2double Eddy_Visc = solver_container[FLOW_SOL]->GetEddyViscWall(val_marker, iVertex); - unsigned short counter = 0; - su2double diff = 1.0; + /*--- Solve for the new value of nu_tilde given the eddy viscosity and using a Newton method ---*/ - while (diff > tol) { + // start with positive value of nu_til_old + su2double nu_til = 0.0; + su2double nu_til_old = nodes->GetSolution(iPoint,0); - su2double const_term = (Eddy_Visc/Density_Normal) * pow(Kin_Visc_Normal,3)*cv1_3; + unsigned short counter = 0; + su2double diff = 1.0; + relax = 0.5; + while (diff > tol) { + // note the error in Nichols and Nelson + su2double func = pow(nu_til_old,4) - (Eddy_Visc/Density_Normal)*(pow(nu_til_old,3) + pow(Kin_Visc_Normal,3)*cv1_3); + su2double func_prim = 4.0 * pow(nu_til_old,3) - 3.0*(Eddy_Visc/Density_Normal)*pow(nu_til_old,2); - su2double nu_til_2 = pow(nu_til_old,2); - su2double nu_til_3 = nu_til_old * nu_til_2; + // damped Newton method + nu_til = nu_til_old - relax*(func/func_prim); - su2double func = nu_til_old * (nu_til_3 - (Eddy_Visc/Density_Normal)*nu_til_2) + const_term; - su2double func_prime = 4.0*nu_til_3 - 3.0*(Eddy_Visc/Density_Normal)*nu_til_2; - su2double nu_til = nu_til_old - func/func_prime; + diff = fabs(nu_til-nu_til_old); + nu_til_old = nu_til; - diff = fabs(nu_til-nu_til_old); - nu_til_old = nu_til; + // sometimes we get negative values when the solution has not converged yet, we just reset the nu_tilde in that case. + if (nu_til_oldGetSolution(iPoint,0)/relax; + } - counter++; - if (counter > max_iter) { - cout << "WARNING: Nu_tilde evaluation has not converged." << endl; - break; + counter++; + if (counter > max_iter) break; } - } - - nodes->SetSolution_Old(Point_Normal, 0, nu_til_old); - LinSysRes.SetBlock_Zero(Point_Normal); - /*--- includes 1 in the diagonal ---*/ + nodes->SetSolution_Old(iPoint_Neighbor, &nu_til); + LinSysRes.SetBlock_Zero(iPoint_Neighbor); - if (implicit) Jacobian.DeleteValsRowi(Point_Normal); + /*--- includes 1 in the diagonal ---*/ + if (implicit) Jacobian.DeleteValsRowi(iPoint_Neighbor); + } } - } void CTurbSASolver::SetDES_LengthScale(CSolver **solver, CGeometry *geometry, CConfig *config){ diff --git a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp index 6c06747d7fa..819a57c0a49 100644 --- a/SU2_CFD/src/solvers/CTurbSSTSolver.cpp +++ b/SU2_CFD/src/solvers/CTurbSSTSolver.cpp @@ -367,16 +367,24 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont tie(WallType, Roughness_Height) = config->GetWallRoughnessProperties(Marker_Tag); if (WallType == WALL_TYPE::ROUGH) rough_wall = true; + /*--- Evaluate nu tilde at the closest point to the surface using the wall functions. ---*/ + + if (config->GetWall_Functions()) { + SU2_OMP_MASTER + SetTurbVars_WF(geometry, solver_container, config, val_marker); + END_SU2_OMP_MASTER + SU2_OMP_BARRIER + return; + } + SU2_OMP_FOR_STAT(OMP_MIN_SIZE) for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { - const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); /*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/ if (geometry->nodes->GetDomain(iPoint)) { - if (rough_wall) { /*--- Set wall values ---*/ @@ -413,7 +421,9 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont nodes->SetSolution_Old(iPoint,solution); nodes->SetSolution(iPoint,solution); LinSysRes.SetBlock_Zero(iPoint); - } else { + + } else { // smooth wall + /*--- distance to closest neighbor ---*/ const auto jPoint = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); @@ -426,7 +436,7 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont su2double laminar_viscosity = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(jPoint); su2double beta_1 = constants[4]; - su2double solution[2]; + su2double solution[MAXNVAR]; solution[0] = 0.0; solution[1] = 60.0*laminar_viscosity/(density*beta_1*distance2); @@ -446,6 +456,64 @@ void CTurbSSTSolver::BC_HeatFlux_Wall(CGeometry *geometry, CSolver **solver_cont END_SU2_OMP_FOR } + +void CTurbSSTSolver::SetTurbVars_WF(CGeometry *geometry, CSolver **solver_container, + const CConfig *config, unsigned short val_marker) { + + const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT); + + /*--- von Karman constant from boundary layer theory ---*/ + const su2double kappa = config->GetwallModelKappa(); + + /*--- relaxation factor for k-omega values ---*/ + const su2double relax = 0.5; + + /*--- Loop over all of the vertices on this boundary marker ---*/ + + for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) { + + const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode(); + const auto iPoint_Neighbor = geometry->vertex[val_marker][iVertex]->GetNormal_Neighbor(); + + su2double Y_Plus = solver_container[FLOW_SOL]->GetYPlus(val_marker, iVertex); + su2double Lam_Visc_Wall = solver_container[FLOW_SOL]->GetNodes()->GetLaminarViscosity(iPoint); + + /*--- Do not use wall model at the ipoint when y+ < 5.0, use zero flux (Neumann) conditions. ---*/ + + if (Y_Plus < 5.0) continue; + + su2double Eddy_Visc = solver_container[FLOW_SOL]->GetEddyViscWall(val_marker, iVertex); + su2double k = nodes->GetSolution(iPoint_Neighbor,0); + su2double omega = nodes->GetSolution(iPoint_Neighbor,1); + su2double Density_Wall = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint); + su2double U_Tau = solver_container[FLOW_SOL]->GetUTau(val_marker, iVertex); + su2double y = Y_Plus*Lam_Visc_Wall/(Density_Wall*U_Tau); + + su2double omega1 = 6.0*Lam_Visc_Wall/(0.075*Density_Wall*y*y); // eq. 19 + su2double omega0 = U_Tau/(sqrt(0.09)*kappa*y); // eq. 20 + su2double omega_new = sqrt(omega0*omega0 + omega1*omega1); // eq. 21 Nichols & Nelson + su2double k_new = omega_new * Eddy_Visc/Density_Wall; // eq. 22 Nichols & Nelson + // (is this the correct density? paper says rho and not rho_w) + + /*--- put some relaxation factor on the k-omega values ---*/ + k += relax*(k_new - k); + omega += relax*(omega_new - omega); + + su2double solution[MAXNVAR] = {k, omega}; + + nodes->SetSolution_Old(iPoint_Neighbor,solution); + nodes->SetSolution(iPoint,solution); + + LinSysRes.SetBlock_Zero(iPoint_Neighbor); + + if (implicit) { + /*--- includes 1 in the diagonal ---*/ + Jacobian.DeleteValsRowi(iPoint_Neighbor*nVar); + Jacobian.DeleteValsRowi(iPoint_Neighbor*nVar+1); + } + } +} + void CTurbSSTSolver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {