Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a097c10
Splitting test case files
talbring Oct 8, 2019
1d7f56f
Initial fixes - runs and results are very similar but BGS residual di…
rsanfer Oct 8, 2019
2d6d555
Remove tracking to IDE files.
rsanfer Oct 8, 2019
acea7e5
Change wrong output message.
rsanfer Oct 9, 2019
27ceac9
Fix disc adj fsi test case.
rsanfer Oct 10, 2019
085f412
Minimal sub-configs.
rsanfer Oct 10, 2019
2996990
Re-enable test cases of disc_adj_fsi.
rsanfer Oct 10, 2019
f84a1d9
Add Airfoil FSI ADJ case.
rsanfer Oct 10, 2019
485bf16
Edit description.
rsanfer Oct 10, 2019
0058fa3
Re-enable Airfoil 2d test case
rsanfer Oct 10, 2019
411e50d
Edit travis for testing.
rsanfer Oct 10, 2019
21a7057
Fix segfault.
rsanfer Oct 10, 2019
beb8cd8
Merge with develop.
rsanfer Oct 10, 2019
9f43647
Fix bug.
rsanfer Oct 11, 2019
9bba065
Edit travis to be able to run test cases.
rsanfer Oct 11, 2019
3ff333e
Fix output bug.
rsanfer Oct 11, 2019
7afb738
Enable FSI adjoint test cases.
rsanfer Oct 11, 2019
3a491de
Merge branch 'fix_discadjfsi' into fix_discadjfsi_merge
rsanfer Oct 11, 2019
f8bb7aa
Merge branch 'develop' of https://github.com/su2code/SU2 into fix_dis…
rsanfer Oct 11, 2019
654ba3d
A couple of minor fixes.
rsanfer Oct 15, 2019
6244725
Merge branch 'fix_discadjfsi' into fix_discadjfsi_merge
rsanfer Oct 15, 2019
711ab68
Merge branch 'develop' of https://github.com/su2code/SU2 into fix_dis…
rsanfer Oct 15, 2019
d06457b
Couple of fixes.
rsanfer Oct 15, 2019
5346ee2
fix segfault
pcarruscag Oct 15, 2019
5439e65
fix fluid adjoint solution not advancing in FSI cases
pcarruscag Oct 15, 2019
48c5a88
output cleanup, update Airfoil_2D testcase
pcarruscag Oct 16, 2019
bb055c4
fix fluid adj residuals for disc adj fsi
pcarruscag Oct 16, 2019
892b4dc
Re-set the vertical bars in output - needed for the Test scripts.
rsanfer Oct 17, 2019
7e55526
Update tests.
rsanfer Oct 17, 2019
aca42d1
Merge branch 'develop' into fix_discadjfsi_merge
rsanfer Oct 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Common/include/dual_grid_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,12 +810,24 @@ class CPoint : public CDualGrid {
*/
void SetAdjointCoord(su2double *adj_coor);

/*!
* \brief Set the adjoint values of the coordinates.
* \param[in] adj_sol - The adjoint values of the coordinates.
*/
void SetAdjointCoord_intIndexBased(su2double *adj_coor);

/*!
* \brief Get the adjoint values of the coordinates.
* \param[in] adj_sol - The adjoint values of the coordinates.
*/
void GetAdjointCoord(su2double *adj_coor);

/*!
* \brief Get the adjoint values of the coordinates.
* \param[in] adj_sol - The adjoint values of the coordinates.
*/
void GetAdjointCoord_intIndexBased(su2double *adj_coor);

};

/*!
Expand Down
19 changes: 14 additions & 5 deletions Common/include/dual_grid_structure.inl
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,23 @@ inline void CPoint::SetZeroValues(void) { }
inline void CPoint::AddNormal(su2double *val_face_normal) { }

inline void CPoint::SetAdjointCoord(su2double *adj_coor){
for (unsigned short iDim = 0; iDim < nDim; iDim++)
SU2_TYPE::SetDerivative(Coord[iDim], SU2_TYPE::GetValue(adj_coor[iDim]));
for (unsigned short iDim = 0; iDim < nDim; iDim++)
SU2_TYPE::SetDerivative(Coord[iDim], SU2_TYPE::GetValue(adj_coor[iDim]));
}

inline void CPoint::SetAdjointCoord_intIndexBased(su2double *adj_coor){
for (unsigned short iDim = 0; iDim < nDim; iDim++)
AD::SetDerivative(Output_AdjIndices[iDim], SU2_TYPE::GetValue(adj_coor[iDim]));
}

inline void CPoint::GetAdjointCoord(su2double *adj_coor){
for (unsigned short iDim = 0; iDim < nDim; iDim++){
adj_coor[iDim] = SU2_TYPE::GetDerivative(Coord[iDim]);
}
for (unsigned short iDim = 0; iDim < nDim; iDim++)
adj_coor[iDim] = SU2_TYPE::GetDerivative(Coord[iDim]);
}

inline void CPoint::GetAdjointCoord_intIndexBased(su2double *adj_coor){
for (unsigned short iDim = 0; iDim < nDim; iDim++)
adj_coor[iDim] = AD::GetDerivative(Input_AdjIndices[iDim]);
}

inline unsigned short CEdge::GetnNodes() { return 2; }
Expand Down
34 changes: 7 additions & 27 deletions Common/src/config_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,8 @@ void CConfig::SetConfig_Options() {
/*!\brief WEAKLY_COUPLED_HEAT_EQUATION \n DESCRIPTION: Enable heat equation for incompressible flows. \ingroup Config*/
addBoolOption("WEAKLY_COUPLED_HEAT_EQUATION", Weakly_Coupled_Heat, NO);

addBoolOption("ADJ_FSI", FSI_Problem, NO);

/*\brief AXISYMMETRIC \n DESCRIPTION: Axisymmetric simulation \n DEFAULT: false \ingroup Config */
addBoolOption("AXISYMMETRIC", Axisymmetric, false);
/* DESCRIPTION: Add the gravity force */
Expand Down Expand Up @@ -1692,7 +1694,7 @@ void CConfig::SetConfig_Options() {
/*!\par CONFIG_CATEGORY: Input/output files and formats \ingroup Config */
/*--- Options related to input/output files and formats ---*/

/*!\brief OUTPUT_FORMAT \n DESCRIPTION: I/O format for output plots. \n OPTIONS: see \link Output_Map \endlink \n DEFAULT: TECPLOT \ingroup Config */
/*!\brief OUTPUT_FORMAT \n DESCRIPTION: I/O format for output plots. \n OPTIONS: see \link TabOutput_Map \endlink \n DEFAULT: TECPLOT \ingroup Config */
addEnumOption("TABULAR_FORMAT", Tab_FileFormat, TabOutput_Map, TAB_CSV);
/*!\brief ACTDISK_JUMP \n DESCRIPTION: The jump is given by the difference in values or a ratio */
addEnumOption("ACTDISK_JUMP", ActDisk_Jump, Jump_Map, DIFFERENCE);
Expand Down Expand Up @@ -2875,8 +2877,7 @@ void CConfig::SetnZone(){

nZone = GetnZone(Mesh_FileName, Mesh_FileFormat);

}

}
}

void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_izone, unsigned short val_nDim) {
Expand Down Expand Up @@ -3136,27 +3137,6 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_

if ((ContinuousAdjoint && !MG_AdjointFlow) ||
(TimeMarching == TIME_STEPPING)) { nMGLevels = 0; }

/*--- If Fluid Structure Interaction, set the solver for each zone.
*--- ZONE_0 is the zone of the fluid.
*--- All the other zones are structure.
*--- This will allow us to define multiple physics structural problems */

if (Kind_Solver == FLUID_STRUCTURE_INTERACTION) {
if (val_izone == 0) {Kind_Solver = Kind_Solver_Fluid_FSI; FSI_Problem = true;}

else {Kind_Solver = Kind_Solver_Struc_FSI; FSI_Problem = true;
Kind_Linear_Solver = Kind_Linear_Solver_FSI_Struc;
Kind_Linear_Solver_Prec = Kind_Linear_Solver_Prec_FSI_Struc;
Linear_Solver_Error = Linear_Solver_Error_FSI_Struc;
Linear_Solver_Iter = Linear_Solver_Iter_FSI_Struc;
// Discrete adjoint linear solver
Kind_DiscAdj_Linear_Solver = Kind_DiscAdj_Linear_Solver_FSI_Struc;
Kind_DiscAdj_Linear_Prec = Kind_DiscAdj_Linear_Prec_FSI_Struc;}

Multizone_Residual = true;
}
else { FSI_Problem = false; }

if (Kind_Solver == EULER ||
Kind_Solver == NAVIER_STOKES ||
Expand Down Expand Up @@ -6035,10 +6015,10 @@ void CConfig::SetOutput(unsigned short val_software, unsigned short val_izone) {
}
else {
if (Time_Domain) {
cout << "Static structural analysis." << endl;
cout << "Dynamic structural analysis."<< endl;
cout << "Time step provided by the user for the dynamic analysis(s): "<< Delta_DynTime << "." << endl;
} else {
cout << "Dynamic structural analysis."<< endl;
cout << "Time step provided by the user for the dynamic analysis(s): "<< Delta_DynTime << "." << endl;
cout << "Static structural analysis." << endl;
}
}

Expand Down
1 change: 1 addition & 0 deletions QuickStart/inv_NACA0012.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SOLVER= EULER
% Mathematical problem (DIRECT, CONTINUOUS_ADJOINT)
MATH_PROBLEM= DIRECT
%

% Restart solution (NO, YES)
RESTART_SOL= NO
SCREEN_OUTPUT=(INNER_ITER, WALL_TIME, RMS_DENSITY, LIFT, DRAG, CAUCHY_SENS_PRESS, CAUCHY_DRAG)
Expand Down
17 changes: 12 additions & 5 deletions SU2_CFD/include/drivers/CDriver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,6 +1111,7 @@ class CHBDriver : public CFluidDriver {
class CDiscAdjFSIDriver : public CDriver {

COutputLegacy* output_legacy;

CIteration** direct_iteration;
unsigned short RecordingState;
unsigned short CurrentRecording; /*!< \brief Stores the current status of the recording. */
Expand Down Expand Up @@ -1153,6 +1154,17 @@ class CDiscAdjFSIDriver : public CDriver {
*/
~CDiscAdjFSIDriver(void);

/*!
* \brief Launch the computation for FSI adjoint (legacy) driver
*/
inline void StartSolver(){

/*--- Run the solver. ---*/
if (rank == MASTER_NODE)
cout << endl <<"------------------------------ Begin Solver -----------------------------" << endl;
Run();
}

/*!
* \brief Run a Discrete Adjoint iteration for the FSI problem.
* \param[in] iteration_container - Container vector with all the iteration methods.
Expand Down Expand Up @@ -1343,11 +1355,6 @@ class CDiscAdjFSIDriver : public CDriver {
void Postprocess(unsigned short ZONE_FLOW,
unsigned short ZONE_STRUCT);

/*!
* \brief Overload, does nothing but avoids updates in adjoint FSI problems before the iteration
*/
void Update(void);

/*!
* \brief Overload, does nothing but avoids dynamic mesh updates in adjoint FSI problems before the iteration
*/
Expand Down
26 changes: 25 additions & 1 deletion SU2_CFD/include/solver_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12644,7 +12644,19 @@ class CDiscAdjSolver : public CSolver {
*/
void LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo);

/*!
* \brief Compute the multizone residual.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] config - Definition of the particular problem.
*/
void ComputeResidual_Multizone(CGeometry *geometry, CConfig *config);

/*!
* \brief Store the BGS solution in the previous subiteration in the corresponding vector.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] config - Definition of the particular problem.
*/
void UpdateSolution_BGS(CGeometry *geometry, CConfig *config);

};

Expand Down Expand Up @@ -12790,7 +12802,7 @@ class CDiscAdjFEASolver : public CSolver {
* \param[in] geometry - The geometrical definition of the problem.
*/
void RegisterObj_Func(CConfig *config);

/*!
* \brief Set the surface sensitivity.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down Expand Up @@ -12991,7 +13003,19 @@ class CDiscAdjFEASolver : public CSolver {
*/
void LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo);

/*!
* \brief Compute the multizone residual.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] config - Definition of the particular problem.
*/
void ComputeResidual_Multizone(CGeometry *geometry, CConfig *config);

/*!
* \brief Store the BGS solution in the previous subiteration in the corresponding vector.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] config - Definition of the particular problem.
*/
void UpdateSolution_BGS(CGeometry *geometry, CConfig *config);

};

Expand Down
1 change: 0 additions & 1 deletion SU2_CFD/src/SU2_CFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ int main(int argc, char *argv[]) {
solver types from the config, instantiate the appropriate driver for the problem
and perform all the preprocessing. ---*/


if (!dry_run){

if ((!config->GetMultizone_Problem() && (config->GetTime_Marching() != HARMONIC_BALANCE) && !turbo)
Expand Down
89 changes: 40 additions & 49 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5067,23 +5067,23 @@ CDiscAdjFSIDriver::CDiscAdjFSIDriver(char* confFile,
direct_iteration = new CIteration*[nZone];

unsigned short iZone;
// for (iZone = 0; iZone < nZone; iZone++){
// switch (config_container[iZone]->GetKind_Solver()) {
// case DISC_ADJ_INC_RANS: case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES:
// case DISC_ADJ_RANS: case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES:
// direct_iteration[iZone] = new CFluidIteration(config_container[iZone]);
// nVar_Flow = solver_container[iZone][INST_0][MESH_0][ADJFLOW_SOL]->GetnVar();
// flow_criteria = config_container[iZone]->GetMinLogResidual_BGS_F();
// flow_criteria_rel = config_container[iZone]->GetOrderMagResidual_BGS_F();
// break;
// case DISC_ADJ_FEM:
// direct_iteration[iZone] = new CFEAIteration(config_container[iZone]);
// nVar_Struct = solver_container[iZone][INST_0][MESH_0][ADJFEA_SOL]->GetnVar();
// structure_criteria = config_container[iZone]->GetMinLogResidual_BGS_S();
// structure_criteria_rel = config_container[iZone]->GetOrderMagResidual_BGS_S();
// break;
// }
// }
for (iZone = 0; iZone < nZone; iZone++){
switch (config_container[iZone]->GetKind_Solver()) {
case DISC_ADJ_INC_RANS: case DISC_ADJ_INC_EULER: case DISC_ADJ_INC_NAVIER_STOKES:
case DISC_ADJ_RANS: case DISC_ADJ_EULER: case DISC_ADJ_NAVIER_STOKES:
direct_iteration[iZone] = new CFluidIteration(config_container[iZone]);
nVar_Flow = solver_container[iZone][INST_0][MESH_0][ADJFLOW_SOL]->GetnVar();
flow_criteria = -8.0; // Temporarily hard coded until adapted into new structure
flow_criteria_rel = 3.0;
break;
case DISC_ADJ_FEM:
direct_iteration[iZone] = new CFEAIteration(config_container[iZone]);
nVar_Struct = solver_container[iZone][INST_0][MESH_0][ADJFEA_SOL]->GetnVar();
structure_criteria = -8.0;
structure_criteria_rel = 3.0;
break;
}
}

init_res_flow = new su2double[nVar_Flow];
init_res_struct = new su2double[nVar_Struct];
Expand Down Expand Up @@ -5182,8 +5182,9 @@ CDiscAdjFSIDriver::CDiscAdjFSIDriver(char* confFile,

myfile_res.close();
}
output_legacy = new COutputLegacy(config_container[ZONE_0]);

// /*--- TODO: This is a workaround until the TestCases.py script incorporates new classes for nested loops. ---*/
/*--- TODO: This is a workaround until the TestCases.py script incorporates new classes for nested loops. ---*/
// config_container[ZONE_0]->SetnExtIter(1);
// config_container[ZONE_1]->SetnExtIter(1);
ConvHist_file = NULL;
Expand Down Expand Up @@ -5212,10 +5213,6 @@ CDiscAdjFSIDriver::~CDiscAdjFSIDriver(void) {

}

void CDiscAdjFSIDriver::Update(){

}

void CDiscAdjFSIDriver::DynamicMeshUpdate(unsigned long ExtIter){

}
Expand All @@ -5230,13 +5227,12 @@ void CDiscAdjFSIDriver::Run( ) {

unsigned long IntIter = 0; for (iZone = 0; iZone < nZone; iZone++) config_container[iZone]->SetInnerIter(IntIter);
unsigned long iOuterIter = 0; for (iZone = 0; iZone < nZone; iZone++) config_container[iZone]->SetOuterIter(iOuterIter);
unsigned long nOuterIter = config_container[ZONE_FLOW]->GetnIterFSI();
unsigned long nOuterIter = driver_config->GetnOuter_Iter();

ofstream myfile_struc, myfile_flow, myfile_geo;

Preprocess(ZONE_FLOW, ZONE_STRUCT, ALL_VARIABLES);


for (iOuterIter = 0; iOuterIter < nOuterIter && !BGS_Converged; iOuterIter++){

if (rank == MASTER_NODE){
Expand Down Expand Up @@ -5271,6 +5267,7 @@ void CDiscAdjFSIDriver::Run( ) {

/*--- Check convergence of the BGS method ---*/
BGS_Converged = BGSConvergence(iOuterIter, ZONE_FLOW, ZONE_STRUCT);

}


Expand Down Expand Up @@ -6057,10 +6054,10 @@ void CDiscAdjFSIDriver::Iterate_Block(unsigned short ZONE_FLOW,

switch (kind_recording){
case FLOW_CONS_VARS:
nIntIter = config_container[ZONE_FLOW]->GetUnst_nIntIter();
nIntIter = config_container[ZONE_FLOW]->GetnInner_Iter();
break;
case FEA_DISP_VARS:
nIntIter = config_container[ZONE_STRUCT]->GetDyn_nIntIter();
nIntIter = config_container[ZONE_STRUCT]->GetnInner_Iter();
break;
case MESH_COORDS:
case FEM_CROSS_TERM_GEOMETRY:
Expand Down Expand Up @@ -6321,9 +6318,8 @@ void CDiscAdjFSIDriver::ConvergenceHistory(unsigned long IntIter,
unsigned long BGS_Iter = config_container[ZONE_FLOW]->GetOuterIter();


// if (rank == MASTER_NODE)
// if ((!config_container[ZONE_0]->GetMultizone_Problem() && !config_container[ZONE_0]->GetSinglezone_Driver()))
// output_container[ZONE_0]->GetLegacyOutput()->SetConvHistory_Header(&ConvHist_file[ZONE_0][INST_0], config_container[ZONE_0], ZONE_0, INST_0);
if (rank == MASTER_NODE)
output_legacy->SetConvHistory_Header(&ConvHist_file[ZONE_0][INST_0], config_container[ZONE_0], ZONE_0, INST_0);

if (kind_recording == FLOW_CONS_VARS) {

Expand All @@ -6336,23 +6332,23 @@ void CDiscAdjFSIDriver::ConvergenceHistory(unsigned long IntIter,
if (IntIter % config_container[ZONE_FLOW]->GetWrt_Con_Freq() == 0){
/*--- Output the flow convergence ---*/
/*--- This is temporary as it requires several changes in the output structure ---*/
unsigned short nVar_Flow = solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->GetnVar();
cout.width(8); cout << IntIter;
cout.width(11); cout << BGS_Iter + 1;
cout.precision(6); cout.setf(ios::fixed, ios::floatfield);
cout.width(15); cout << log10(solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->GetRes_RMS(0));
cout.width(15); cout << log10(solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->GetRes_RMS(1));
cout.width(15); cout << log10(solver_container[ZONE_FLOW][INST_0][MESH_0][ADJFLOW_SOL]->GetRes_RMS(nVar_Flow-1));
cout << endl;
}

}
}

// if (kind_recording == FEA_DISP_VARS) {
// if ((!config_container[ZONE_0]->GetMultizone_Problem() && !config_container[ZONE_0]->GetSinglezone_Driver()))
// /*--- Set the convergence criteria (only residual possible) ---*/
// output_container[ZONE_0]->GetLegacyOutput()->SetConvHistory_Body(NULL, geometry_container, solver_container, config_container, integration_container, true, 0.0, ZONE_STRUCT, INST_0);
if (kind_recording == FEA_DISP_VARS) {
/*--- Set the convergence criteria (only residual possible) ---*/
output_legacy->SetConvHistory_Body(NULL, geometry_container, solver_container, config_container, integration_container, true, 0.0, ZONE_STRUCT, INST_0);

// }
}


}
Expand Down Expand Up @@ -6428,22 +6424,17 @@ bool CDiscAdjFSIDriver::BGSConvergence(unsigned long IntIter,

if (rank == MASTER_NODE){

cout << endl << "-------------------------------------------------------------------------" << endl;
cout << endl;
cout << "Convergence summary for BGS iteration ";
cout << IntIter << endl;
cout << endl;
cout << "\n-------------------------------------------------------------------------\n\n";
cout << "Convergence summary for BGS iteration " << IntIter << "\n\n";
/*--- TODO: This is a workaround until the TestCases.py script incorporates new classes for nested loops. ---*/
cout << "Iter[ID]" << " BGSRes[Psi_Rho]" << " BGSRes[Psi_E]" << " BGSRes[Psi_Ux]" << " BGSRes[Psi_Uy]" << endl;
cout << "Iter[ID]" << " BGSRes[Psi_Rho]" << " BGSRes[Psi_E]" << " BGSRes[Psi_Ux]" << " BGSRes[Psi_Uy]\n";
cout.precision(6); cout.setf(ios::fixed, ios::floatfield);
cout.width(8); cout << IntIter*1000;
cout.width(17); cout << residual_flow[0];
cout.width(15); cout << residual_flow[nVar_Flow-1];
cout.width(16); cout << residual_struct[0];
cout.width(16); cout << residual_struct[1];
cout << endl;
cout << endl;
cout << "-------------------------------------------------------------------------" << endl;
cout << "|"; cout.width(8); cout << IntIter*1000;
cout << "|"; cout.width(17); cout << residual_flow[0];
cout << "|"; cout.width(15); cout << residual_flow[nVar_Flow-1];
cout << "|"; cout.width(16); cout << residual_struct[0];
cout << "|"; cout.width(16); cout << residual_struct[1];
cout << "|"; cout << "\n\n-------------------------------------------------------------------------" << endl;


bool write_history = true;
Expand Down
Loading