From 8804def361f5b72acf56712dea45df8cc66edad0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Mon, 18 Jan 2021 17:43:48 +0000 Subject: [PATCH 01/73] 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 61516cce31c2..76341b53131d 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 02/73] 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 68c99d7d0dfc..0623e6437682 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 e2aac672de11..1708ffa905c2 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 4545b67b461b..25e8c9446417 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 207c9b7f2d9e..28be30a334c1 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 1194d8fc3e19..a053de8f9336 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 ae477336e56d..316b32f1d400 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 dc801b1e32ca..97bd35ef9dce 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 6860556e526d..fc5eb3e3dc6c 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 e20846277db9..47c23476f74e 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 52244aafd6cd..85366c2435f3 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 fd37e55262b5..22f88a0f3561 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 b1561b048f94..79df952578ac 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 841a0d6cb822..7b397e994c64 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 0484d9d7654d..e24e447fc71a 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 d889f036b4ce..09a89301934f 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 22c2b384c5de..eb8ace2f14f2 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 041ea3fcc06a..1631259b7bac 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 1fd3f093a60f..29d54e09da57 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 cabea1e48c82..4e2049fd4420 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 b53b35f7bc32..f22c76568032 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 50fcd31140b5..2396b0dbb4bd 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 de7eebe5d27e..0dc4a3cdd841 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 03/73] 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 289bd1dc7873..aecb3de4adb0 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 aa7185b6f753..7afa297c400f 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 b103e17f4709..5abbee32e618 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 ea6a9d708527..792c9919f22b 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 25eaf6433c66..bacaffa43257 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 04/73] 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 1621d22f12f0..4b074ee98e01 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 0dc4a3cdd841..23c805a713f7 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 05/73] 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 41b60c4dd0bd..bc8447b3ae09 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 06/73] 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 09a89301934f..d2e83ccfe3f9 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 07/73] 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 eb8ace2f14f2..73f6690174a3 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 08/73] 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 9c432add37f4..c97b9dc19038 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 09/73] 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 bc8447b3ae09..402f0c06131e 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 10/73] 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 92d7ffb3fa1b..c284a00c1e8e 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 11/73] 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 6e504444b190..c1bbac388869 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 d32c85c5cd00..2c4d47b885a4 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 73f6690174a3..2fafb8a4b370 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 12/73] 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 2d8d931776a8..29e01c54095f 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 ede224e14b6a..2cccc4d2d44c 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 5b040196f1e9..5d18a9aa77c0 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 4b074ee98e01..83f747422828 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 4e929d4a0fdc..a442d0fae687 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 13/73] 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 f22c76568032..9d83561de633 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 14/73] 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 d2e83ccfe3f9..944fdc568e1b 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 15/73] 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 43d99aef8dfb..518f80072b64 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 5d18a9aa77c0..74ab9219c3df 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 83f747422828..3b2229198161 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 23c805a713f7..27b9bc3f1c60 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 455ded50f088..b3f0971da340 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 16/73] 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 3b2229198161..7cb19e3d0c2f 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 17/73] 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 75680fd20373..5cb2b24e8748 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 18/73] 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 5cb2b24e8748..e243e1f89194 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 1bdc1edd0158080d3c7cea02767f406e028ae48b Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 24 Feb 2021 18:15:30 +0000 Subject: [PATCH 19/73] 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 e243e1f89194..2e6e63d718b9 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 b6958d9c55ff96a0f7add26e6e8061de27c63db0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 11 Apr 2021 13:51:16 +0100 Subject: [PATCH 20/73] 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 046c2334f6d7..47dadc33329d 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 21/73] 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 000000000000..8ed8339070c0 --- /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 000000000000..612823c75565 --- /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 000000000000..b83b3ecc1116 --- /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 000000000000..3c691471847f --- /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 000000000000..90421c130427 --- /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 000000000000..1a5d2889b957 --- /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 000000000000..612823c75565 --- /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 000000000000..b83b3ecc1116 --- /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 000000000000..4cff5b6d58be --- /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 000000000000..90421c130427 --- /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 000000000000..1a5d2889b957 --- /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 000000000000..3f9b2f174c94 --- /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 000000000000..9f0eddf9c234 --- /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 000000000000..3c691471847f --- /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 000000000000..90421c130427 --- /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 22/73] 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 54d9a9456a6c..c239f7063556 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 23/73] 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 89bb350771d6..e1e6613f629a 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 ae85afda06c7..7f5352ce0c7b 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 24/73] 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 e1e6613f629a..89bb350771d6 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 7f5352ce0c7b..ae85afda06c7 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 12345a6313fd77f8eae188228a28dfdc8a0a0aed Mon Sep 17 00:00:00 2001 From: cvencro Date: Sun, 18 Apr 2021 22:40:31 +0100 Subject: [PATCH 25/73] 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 455a0dbc8127..d60c2cff3295 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 69c97380968e..f0c557e7edec 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 26/73] 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 b5feeb7b695d..81ae8ae11fc6 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 c239f7063556..fa0c587440ae 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 27/73] 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 81ae8ae11fc6..90001a72d96b 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 28/73] 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 97237e680a77..f7f8499963a8 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 29/73] 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 fa0c587440ae..a6e74f4e0dfd 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 30/73] 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 48c29f76dc7f..c35e0f4951cc 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 d7ba9d80b75d..e120ed5cbf99 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 98c1f553fcae..31193cf40d31 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 a6e74f4e0dfd..d9e92d1a7c75 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 d60c2cff3295..c658955b8d5f 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 3f6159cbdc0d..5258293b1107 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 f0c557e7edec..1fb642bbe3a2 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 90dbc69d2d97..2995b97b3a54 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 31/73] 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 2595dc80540c..6b24acb58dae 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 32/73] 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 85e0e5654185..08bfe8d9400d 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 46f24ccbbcce..969d9b523c38 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 709b023bdd2a..d646208c5eee 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 a82763629ff1..31be9b7e8bd1 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 b0eea71aaf2c..9036a822ffd4 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 55d2f9f84a08..77e81a665e92 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 f7f8499963a8..65b1141ea377 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 1fb642bbe3a2..ce31eabc5e39 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 1e243f73550b..d20475a1dbd5 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 d1db55576560..c443ef351f77 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 4c95b416641b..5588ecb4b9a3 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 9ce54e9d9ab2..1d5b33460cf8 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 33/73] 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 969d9b523c38..d8750992c7db 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 ce31eabc5e39..779691cef1f0 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 34/73] 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 d20475a1dbd5..cd23ed15be30 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 35/73] 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 d8750992c7db..20eb82f36434 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 d646208c5eee..b367a5d62b90 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 56d5d8951521..f98eb9247c5e 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 cd23ed15be30..44e715e90a89 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 1d5b33460cf8..a9381f723c20 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 36/73] 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 44e715e90a89..c2c67c7f6485 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 37/73] 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 c2c67c7f6485..1955abf066f2 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 38/73] 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 08bfe8d9400d..c2396d5ecfef 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 20eb82f36434..e74d1a549dc6 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 b367a5d62b90..59b3b125715a 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 31be9b7e8bd1..a82763629ff1 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 9036a822ffd4..b0eea71aaf2c 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 77e81a665e92..55d2f9f84a08 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 65b1141ea377..f7f8499963a8 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 779691cef1f0..2d6b756a9222 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 1955abf066f2..1e243f73550b 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 c443ef351f77..d1db55576560 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 5588ecb4b9a3..f4fb5e3ec347 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 a9381f723c20..2c9667772456 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 39/73] 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 2d6b756a9222..2ec438dda629 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 40/73] 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 2ec438dda629..3134498010f7 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 41/73] 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 f98eb9247c5e..56d5d8951521 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 42/73] 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 c35e0f4951cc..2163e78e593d 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 c2396d5ecfef..6e5a0f35b98d 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 e74d1a549dc6..22c74615a1fe 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 59b3b125715a..8af45bcdb803 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 a82763629ff1..980255840a33 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 b0eea71aaf2c..ef081adbc6f7 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 3134498010f7..579f5f3e6f83 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 1e243f73550b..a9365826fad3 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 2c9667772456..718804f5edee 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 43/73] 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 6e5a0f35b98d..c2396d5ecfef 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 22c74615a1fe..9f9d4e91f46c 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 8af45bcdb803..6d4e32d5cb8c 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 980255840a33..a82763629ff1 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 ef081adbc6f7..b0eea71aaf2c 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 579f5f3e6f83..394ae74edbc8 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 a9365826fad3..1e243f73550b 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 f4fb5e3ec347..2a7b78c1d8b8 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 718804f5edee..baa25e957980 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 44/73] 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 2163e78e593d..613b5a7fb35e 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 e816483a18ac..cfe8dfe9e262 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 c2396d5ecfef..663ee094a3a9 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 cf0548abbbb8..6c4cfccef2ef 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 9f9d4e91f46c..a4f773b7b2ee 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 6d4e32d5cb8c..0f3ee5cb335c 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 a82763629ff1..31be9b7e8bd1 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 b0eea71aaf2c..8bfc68d684b8 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 394ae74edbc8..cd162329dd2f 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 1e243f73550b..30307741607f 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 0f8727a2876b..d55e9a9619cf 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 2a7b78c1d8b8..6cd75f74136b 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 e2ece345d8d6..bccb5d157db3 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 baa25e957980..405083afc095 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 45/73] 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 1de2974fa08c..f88c3417c5a1 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 6c4ec3a6fe7c..b8eacda6cbe9 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 07d1a19340e0..a9667c93c1c3 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 693240d33019..18bbb14ab0c0 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 a4f773b7b2ee..5dc269577178 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 0f3ee5cb335c..52bb1a2cbf9f 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 e917c122ce99..4c611bac2e38 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 db7d74099da1..e342d007e6f2 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 8bfc68d684b8..24de5f5b1b38 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 22bac262f934..6d627328f32f 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 7a8a6147fd38..8ecbf6411a59 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 cd162329dd2f..48b3202d7823 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 1478a4b559e0..06af9b8408c6 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 6cd75f74136b..28604822ab3d 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 bccb5d157db3..574500805bf3 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 405083afc095..27c9c405dee4 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 9e75f99d7f59..30f35a58bcf1 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 46/73] 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 cfe8dfe9e262..d7ac26f88f21 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 663ee094a3a9..000000000000 --- 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 6c4cfccef2ef..002199d3d91e 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 52bb1a2cbf9f..1201893ba154 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 054df6fa267f..5f7975302eb8 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 53de4efdb1df..ee288818ef4e 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 48b3202d7823..928e01c075f4 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 d55e9a9619cf..09234c1c67e9 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 28604822ab3d..000000000000 --- 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 574500805bf3..39f254f25852 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 30f35a58bcf1..37622e12441f 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 47/73] 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 5f1d08785013..90c135af1994 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 48/73] 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 002199d3d91e..83464efcfb86 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 49/73] 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 fa11c9ee7f4f..5a5e9bd5ebe2 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 83464efcfb86..306df11896f1 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 af6c101185d2..08a0977c4a87 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 8e07eb4fef7c..02eb4ec5e2b5 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 24de5f5b1b38..75b1080ac23a 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 928e01c075f4..e73635704e42 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 90c135af1994..fa6673e00ced 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 39f254f25852..315d6318e874 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 f545d1bfb531..e76d811427e8 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 30dbb2dc246f..b69b6d08132f 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 03ae5b6d85e5..2dbad80c7b7f 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 50/73] 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 ae0541745660..0ed2738d8a5e 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 1501d1bfc105..7b917f51ffc0 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 08a0977c4a87..576abe813153 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 2995b97b3a54..cc1a57b66845 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 9460543d3744..3330f7e885d0 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 d4786c3ed757..ea3a86a1513a 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 51/73] 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 e76d811427e8..012ad702857a 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 52/73] 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 75b1080ac23a..7e30516309d2 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 0d23ec5167d6..dbc6a0dff53f 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 53/73] 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 dbc6a0dff53f..0f20cf2d6c54 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 54/73] 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 5a5e9bd5ebe2..fdbeb839c5ac 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 306df11896f1..7d136ffa0b86 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 576abe813153..98b3f32d3051 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 02eb4ec5e2b5..6cf2cdd8cb07 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 e73635704e42..749fa322644c 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 fa6673e00ced..ce0dc2fff6f8 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 315d6318e874..bf048fea1870 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 27c9c405dee4..abe6e408ba99 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 55/73] 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 6cf2cdd8cb07..f6050f6da53d 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 749fa322644c..85f7199b5af0 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 ce0dc2fff6f8..1151adf7a7d6 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 56/73] 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 cc1a57b66845..0c81be0c3793 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 ea3a86a1513a..95aa08ab1aad 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 57/73] 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 fdbeb839c5ac..e919dd66ffa7 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 7d136ffa0b86..51a9a9a28129 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 98b3f32d3051..db37de808482 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 f6050f6da53d..53acd84f1b3b 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 85f7199b5af0..11148489c3bc 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 1151adf7a7d6..ce0dc2fff6f8 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 bf048fea1870..d6e697f3005f 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 58/73] 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 9690ab40b9e3..9513449abe05 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 f88c3417c5a1..0170ed57496a 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 b8eacda6cbe9..1e9c0666ac27 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 a9667c93c1c3..02268b19a4e6 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 5cc760c7db48..da1add90248c 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 327c8696b371..3a111035791d 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 bfd9f0be9d0a..72979a1804f9 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 320016b17f99..9908d439c8ea 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 18bbb14ab0c0..7ccdffc45d4f 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 53acd84f1b3b..d18a33b23334 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 a146e9d3dbf9..885d155fb2b7 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 cb460c844063..e78890f1fd6b 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 964f6884c0f0..37c2a8779c71 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 7e30516309d2..de4b30d7ee7e 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 0f20cf2d6c54..9016d1e03fe9 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 89147bd70ebf..987ca9a48a86 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 c57956f0cc60..b73fcafed6a6 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 7bcd1b5d5aaa..c3b21187646b 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 212dc1d133eb..dccc21497526 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 9a3cbeeac5ed..0d58a423e11b 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 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 59/73] 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 2a860f64f26a..946c4e36502b 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 60/73] 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 e919dd66ffa7..2a754973798b 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 61/73] 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 d7ac26f88f21..955b5a04d16a 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 62/73] 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 e78890f1fd6b..f9e5a25956da 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 63/73] 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 9016d1e03fe9..f464da1a2e5c 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 64/73] 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 f7f8499963a8..0617674ec787 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 65/73] 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 37622e12441f..5882fd2189b3 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 e7306269153c74aa5c82f673ce69f293c3354ec0 Mon Sep 17 00:00:00 2001 From: cvencro Date: Tue, 11 May 2021 23:13:20 +0100 Subject: [PATCH 66/73] 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 000000000000..02bad468d239 --- /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 000000000000..c657a8179329 --- /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 000000000000..e5fb7fcd096f --- /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 67/73] 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 481838842eb8..8688cc2d455f 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 1fab0e3b2968863a93ed7cfa8ba3b94b8dddc74a Mon Sep 17 00:00:00 2001 From: cvencro Date: Wed, 12 May 2021 19:59:42 +0100 Subject: [PATCH 68/73] 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 02bad468d239..2f8810526ad8 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 69/73] 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 8ed8339070c0..000000000000 --- 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 612823c75565..000000000000 --- 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 b83b3ecc1116..000000000000 --- 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 3c691471847f..000000000000 --- 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 90421c130427..000000000000 --- 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 1a5d2889b957..000000000000 --- 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 612823c75565..000000000000 --- 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 b83b3ecc1116..000000000000 --- 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 4cff5b6d58be..000000000000 --- 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 90421c130427..000000000000 --- 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 1a5d2889b957..000000000000 --- 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 3f9b2f174c94..000000000000 --- 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 9f0eddf9c234..000000000000 --- 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 3c691471847f..000000000000 --- 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 90421c130427..000000000000 --- 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 70/73] 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 000000000000..9f9eb61496da --- /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 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 71/73] 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 8688cc2d455f..fa4671259186 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 72/73] 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 8688cc2d455f..2865f11f1e17 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 590fdddc5f36381a594b35b15dd300cf3c86bf36 Mon Sep 17 00:00:00 2001 From: Pedro Gomes Date: Tue, 18 May 2021 01:16:24 +0100 Subject: [PATCH 73/73] 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 2a754973798b..7d195d45e593 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 d18a33b23334..fc2b099129d3 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 de4b30d7ee7e..6fe780efba46 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 11148489c3bc..485549393321 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 2865f11f1e17..0759ab1913db 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)