Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
9431716
tidy comments and indentation
cvencro Aug 21, 2019
7caf5ea
correct column look-up in restart file
cvencro Aug 21, 2019
7042b14
consistent definition for adjoint boolean
cvencro Aug 21, 2019
597c133
revert incompressible ale changes to prepare for PR
cvencro Aug 21, 2019
b805962
Revert excecutable file permission for cpp/hpp/inl files.
TobiKattmann Aug 22, 2019
8a4c291
Req. changes for PR766. GridVel allocation, indentation, error msg.
TobiKattmann Aug 22, 2019
85047c4
Renamed grid_movement_bool & fixed error catch for dynamic mesh+discAdj.
TobiKattmann Aug 22, 2019
c9f002b
Wrapped GridVel allocation in discAdj conditional. PR766.
TobiKattmann Aug 23, 2019
8e04358
Test without additional secondary and main recordings at the start of…
cvencro Aug 24, 2019
272ee6a
Merge branch 'feature_dynamic_mesh_discrete_adjoint' of https://githu…
cvencro Aug 24, 2019
585f702
Comment out get, set of additional containers and initial test using …
cvencro Aug 25, 2019
ae7460c
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Aug 25, 2019
1d1275a
Comment out unused containers
cvencro Aug 25, 2019
b23a2f7
FD grid velocity calc and remove old grid velocity containers
cvencro Aug 27, 2019
28b6802
Merge branch 'feature_dynamic_mesh_discrete_adjoint' of https://githu…
TobiKattmann Aug 29, 2019
b1020b4
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Aug 29, 2019
a3a8691
Removed unnecessary GridVel containers and methods for ALE discrete a…
TobiKattmann Aug 29, 2019
a2ca1b5
Removed unintentionally added blank lines.
TobiKattmann Aug 29, 2019
500b173
fix needed to allow update of old geometry for dynamic fsi
cvencro Aug 30, 2019
fd11480
Test case added - discrete adjoint of transonic pitching airfoil
cvencro Sep 1, 2019
101220e
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Sep 2, 2019
5694277
Merge remote-tracking branch 'origin/feature_dynamic_mesh_discrete_ad…
TobiKattmann Sep 2, 2019
aa52484
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Sep 4, 2019
bdead2e
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Sep 5, 2019
00ed905
Removed unused variable.
TobiKattmann Sep 5, 2019
f4974a2
Change of conditional in front of Restart_OldGeometry.
TobiKattmann Sep 5, 2019
aaecc65
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Sep 5, 2019
006e015
Merge remote-tracking branch 'origin/develop' into feature_dynamic_me…
TobiKattmann Sep 6, 2019
c3a6e7d
RestartOld_Geometry conditional fix for FSI cases.
TobiKattmann Sep 9, 2019
2d8b0ea
Re-add code deleted during merge conflicts.
TobiKattmann Sep 9, 2019
0d21ee0
Added serial+parallel reg test for pitching discAdj.
TobiKattmann Sep 9, 2019
96dec9c
Removed doubled SecondaryRecording, which errors unsteady adjoints.
TobiKattmann Sep 16, 2019
2d56130
Revert travis. Last little change for PR766 Regression test.
TobiKattmann Sep 21, 2019
d1262f1
Changed DV_* cfg lines such that parallel_computation.py works.
TobiKattmann Sep 23, 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
24 changes: 15 additions & 9 deletions Common/include/dual_grid_structure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,20 @@ class CPoint : public CDualGrid {
Boundary, /*!< \brief To see if a point belong to the boundary (including MPI). */
PhysicalBoundary, /*!< \brief To see if a point belong to the physical boundary (without includin MPI). */
SolidBoundary, /*!< \brief To see if a point belong to the physical boundary (without includin MPI). */
PeriodicBoundary; /*!< \brief To see if a point belongs to a periodic boundary (without including MPI). */
PeriodicBoundary; /*!< \brief To see if a point belongs to a periodic boundary (without including MPI). */
long *Vertex; /*!< \brief Index of the vertex that correspond which the control volume (we need one for each marker in the same node). */
su2double *Coord, /*!< \brief vector with the coordinates of the node. */
*Coord_Old, /*!< \brief Old coordinates vector for geometry smoothing. */
*Coord_Sum, /*!< \brief Sum of coordinates vector for geometry smoothing. */
*Coord_n, /*!< \brief Coordinates at time n for use with dynamic meshes. */
*Coord_n1, /*!< \brief Coordinates at time n-1 for use with dynamic meshes. */
*Coord_p1; /*!< \brief Coordinates at time n+1 for use with dynamic meshes. */
*Coord_Old, /*!< \brief Old coordinates vector for primal solution reloading for Disc.Adj. with dynamic grid. */
*Coord_Sum, /*!< \brief Sum of coordinates vector for geometry smoothing. */
*Coord_n, /*!< \brief Coordinates at time n for use with dynamic meshes. */
*Coord_n1, /*!< \brief Coordinates at time n-1 for use with dynamic meshes. */
*Coord_p1; /*!< \brief Coordinates at time n+1 for use with dynamic meshes. */
su2double *GridVel; /*!< \brief Velocity of the grid for dynamic mesh cases. */
su2double **GridVel_Grad; /*!< \brief Gradient of the grid velocity for dynamic meshes. */
unsigned long Parent_CV; /*!< \brief Index of the parent control volume in the agglomeration process. */
unsigned short nChildren_CV; /*!< \brief Number of children in the agglomeration process. */
vector<unsigned long> Children_CV; /*!< \brief Index of the children control volumes in the agglomeration process. */
bool Agglomerate_Indirect, /*!< \brief This flag indicates if the indirect points can be agglomerated. */
bool Agglomerate_Indirect, /*!< \brief This flag indicates if the indirect points can be agglomerated. */
Agglomerate; /*!< \brief This flag indicates if the element has been agglomerated. */
bool Move; /*!< \brief This flag indicates if the point is going to be move in the grid deformation process. */
unsigned long color; /*!< \brief Color of the point in the partitioning strategy. */
Expand Down Expand Up @@ -567,12 +567,12 @@ class CPoint : public CDualGrid {
su2double* GetCoord_p1(void);

/*!
* \brief Set the coordinates of the control volume at time n.
* \brief Set the coordinates of the control volume at time n to the ones in <i>Coord</i>.
*/
void SetCoord_n(void);

/*!
* \brief Set the coordinates of the control volume at time n-1.
* \brief Set the coordinates of the control volume at time n-1 to the ones in <i>Coord_n</i>.
*/
void SetCoord_n1(void);

Expand Down Expand Up @@ -708,6 +708,11 @@ class CPoint : public CDualGrid {
* \param[in] val_coord_old - Value of the coordinates.
*/
void SetCoord_Old(su2double *val_coord_old);

/*!
* \brief Set the value of the vector <i>Coord_Old</i> to <i>Coord</i>.
*/
void SetCoord_Old(void);

/*!
* \brief Set the value of the grid velocity at the point.
Expand All @@ -718,6 +723,7 @@ class CPoint : public CDualGrid {

/*!
* \overload
* \brief Set the value of the grid velocity at the point.
* \param[in] val_gridvel - Value of the grid velocity.
*/
void SetGridVel(su2double *val_gridvel);
Expand Down
9 changes: 7 additions & 2 deletions Common/include/dual_grid_structure.inl
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ inline void CPoint::SetnChildren_CV (unsigned short val_nchildren_CV) { nChildre
inline void CPoint::SetParent_CV (unsigned long val_parent_CV) { Parent_CV = val_parent_CV; Agglomerate = true; }

inline void CPoint::SetGridVel(su2double *val_gridvel) {
for (unsigned short iDim = 0; iDim < nDim; iDim++)
GridVel[iDim] = val_gridvel[iDim];
for (unsigned short iDim = 0; iDim < nDim; iDim++)
GridVel[iDim] = val_gridvel[iDim];
}

inline void CPoint::SetVolume_n (void) { Volume[1] = Volume[0]; }
Expand All @@ -184,6 +184,11 @@ inline su2double CPoint::GetVolume_n (void) { return Volume[1]; }

inline su2double CPoint::GetVolume_nM1 (void) { return Volume[2]; }

inline void CPoint::SetCoord_Old (void) {
for (unsigned short iDim = 0; iDim < nDim; iDim++)
Coord_Old[iDim] = Coord[iDim];
}

inline void CPoint::SetCoord_n (void) {
for (unsigned short iDim = 0; iDim < nDim; iDim++)
Coord_n[iDim] = Coord[iDim];
Expand Down
11 changes: 9 additions & 2 deletions Common/src/config_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4451,10 +4451,17 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_

Restart_Flow = false;

if (GetGrid_Movement()) {
SU2_MPI::Error("Dynamic mesh movement currently not supported for the discrete adjoint solver.", CURRENT_FUNCTION);
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);
}

/*--- Quickfix to not trigger the error message below if SINGLEZONE_DRIVER is used.
Once the old driver (i.e. EXT_ITER with it) is removed, the Error conditional
can be changed. ---*/
if (SinglezoneDriver) nExtIter = Time_Iter;

if (Unst_AdjointIter- long(nExtIter) < 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."),
Expand Down
3 changes: 3 additions & 0 deletions Common/src/dual_grid_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ CPoint::CPoint(unsigned short val_nDim, unsigned long val_globalindex, CConfig *
Coord_p1 = new su2double[nDim];
Coord_n = new su2double[nDim];
Coord_n1 = new su2double[nDim];
Coord_Old = new su2double[nDim];
}
}

Expand Down Expand Up @@ -241,6 +242,7 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, unsigned long val_g
Coord_p1 = new su2double[nDim];
Coord_n = new su2double[nDim];
Coord_n1 = new su2double[nDim];
Coord_Old = new su2double[nDim];
for (iDim = 0; iDim < nDim; iDim ++) {
Coord_p1[iDim] = Coord[iDim];
Coord_n[iDim] = Coord[iDim];
Expand Down Expand Up @@ -351,6 +353,7 @@ CPoint::CPoint(su2double val_coord_0, su2double val_coord_1, su2double val_coord
Coord_p1 = new su2double[nDim];
Coord_n = new su2double[nDim];
Coord_n1 = new su2double[nDim];
Coord_Old = new su2double[nDim];
for (iDim = 0; iDim < nDim; iDim ++) {
Coord_p1[iDim] = Coord[iDim];
Coord_n[iDim] = Coord[iDim];
Expand Down
2 changes: 0 additions & 2 deletions Common/src/geometry_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13464,7 +13464,6 @@ void CPhysicalGeometry::SetSensitivity(CConfig *config) {
bool sa = (config->GetKind_Turb_Model() == SA) || (config->GetKind_Turb_Model() == SA_NEG) ||
(config->GetKind_Turb_Model() == SA_E) || (config->GetKind_Turb_Model() == SA_COMP) ||
(config->GetKind_Turb_Model() == SA_E_COMP);
bool grid_movement = config->GetGrid_Movement();
bool frozen_visc = config->GetFrozen_Visc_Disc();
unsigned short Kind_Solver = config->GetKind_Solver();
bool flow = ((Kind_Solver == DISC_ADJ_EULER) ||
Expand Down Expand Up @@ -13499,7 +13498,6 @@ void CPhysicalGeometry::SetSensitivity(CConfig *config) {
skipVar += skipMult*(nDim+2);
if (sst && !frozen_visc) { skipVar += skipMult*2;}
if (sa && !frozen_visc) { skipVar += skipMult*1;}
if (grid_movement) { skipVar += nDim;}
}
else if (Kind_Solver == DISC_ADJ_HEAT) {
skipVar += 1;
Expand Down
12 changes: 6 additions & 6 deletions Common/src/grid_movement_structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1904,7 +1904,7 @@ void CVolumetricMovement::Rigid_Rotation(CGeometry *geometry, CConfig *config,
su2double dtheta, dphi, dpsi, cosTheta, sinTheta;
su2double cosPhi, sinPhi, cosPsi, sinPsi;
bool harmonic_balance = (config->GetUnsteady_Simulation() == HARMONIC_BALANCE);
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());


/*--- Problem dimension and physical time step ---*/
Expand Down Expand Up @@ -2067,7 +2067,7 @@ void CVolumetricMovement::Rigid_Pitching(CGeometry *geometry, CConfig *config, u
unsigned short nDim = geometry->GetnDim();
unsigned long iPoint;
bool harmonic_balance = (config->GetUnsteady_Simulation() == HARMONIC_BALANCE);
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());


/*--- Retrieve values from the config file ---*/
Expand Down Expand Up @@ -2214,7 +2214,7 @@ void CVolumetricMovement::Rigid_Plunging(CGeometry *geometry, CConfig *config, u
unsigned short iDim, nDim = geometry->GetnDim();
unsigned long iPoint;
bool harmonic_balance = (config->GetUnsteady_Simulation() == HARMONIC_BALANCE);
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());


/*--- Retrieve values from the config file ---*/
Expand Down Expand Up @@ -2346,7 +2346,7 @@ void CVolumetricMovement::Rigid_Translation(CGeometry *geometry, CConfig *config
unsigned short iDim, nDim = geometry->GetnDim();
unsigned long iPoint;
bool harmonic_balance = (config->GetUnsteady_Simulation() == HARMONIC_BALANCE);
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());


/*--- Retrieve values from the config file ---*/
Expand Down Expand Up @@ -6347,7 +6347,7 @@ void CSurfaceMovement::SetBoundary_Flutter3D(CGeometry *geometry, CConfig *confi
su2double time_new, time_old;
su2double Omega[3], Ampl[3];
su2double DEG2RAD = PI_NUMBER/180.0;
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());
unsigned short iDim = 0;

/*--- Retrieve values from the config file ---*/
Expand Down Expand Up @@ -6441,7 +6441,7 @@ void CSurfaceMovement::SetExternal_Deformation(CGeometry *geometry, CConfig *con
string DV_Filename, UnstExt, text_line;
ifstream surface_positions;
bool unsteady = config->GetUnsteady_Simulation();
bool adjoint = config->GetContinuous_Adjoint();
bool adjoint = (config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint());

/*--- Load stuff from config ---*/

Expand Down
45 changes: 14 additions & 31 deletions SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,6 @@ void CDiscAdjSinglezoneDriver::Run() {
if(!config->GetTime_Domain() && (MainVariables == FLOW_CONS_VARS))
config->SetExtIter(Adjoint_Iter);

/*--- Secondary sensitivities must be computed with a certain frequency. ---*/
/*--- It is also done at the beginning so all memory gets allocated. ---*/
if ((Adjoint_Iter % config->GetWrt_Sol_Freq() == 0) && (SecondaryVariables != NONE)){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This SecondaryRecording is now removed entirely, as it introduces a bug for the unsteady adjoint. The Volume Mesh Sensitivity setting is a += in each physical timestep for unsteady cases and SecondaryRecording is also called in Postprocess() right after the Run(). I.e. if it is called multiple times in one physical timestep the sensitivity adds up. With this code modification SecondaryRecording gets only called once per timestep in Postprocess.

For steady cases the implications are: The memory for the secondary recording gets allocated after the 'flow adjoint iteration' ... so it could be really annoying if the simulation crashes due to lack of memory after waiting for convergence. More importantly: You cannot use an intermediate restart file for e.g. DOT_AD as it is does not hold any/correct sensitivities. So it might be better to only disable this conditional for unsteady computations as I see the advantage of having this for steady computations. What do you think @rsanfer

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I honestly prefer it that way as it is much faster for steady-state computations in moving meshes (a lot less unnecessary recordings). In fact that was my first implementation, but then I added this SecondaryRecording after discussion with @talbring, because of the drawbacks you mention. No 100% what's the best approach...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is the memory thing, because usually the recording with coordinates as inputs takes more memory than the one with the solution variables. I am not so worried about the intermediate restart files, since you can just do a restart to get the correct sensitivity values.

Lets do it without the SecondaryRecording. If it really leads to problems, we can always change it back.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds good to me.


/*--- Computes secondary sensitivities ---*/
SecondaryRecording();

/*--- Recompute main sensitivities ---*/
MainRecording();

}

iteration->InitializeAdjoint(solver_container, geometry_container, config_container, ZONE_0, INST_0);

/*--- Initialize the adjoint of the objective function with 1.0. ---*/
Expand Down Expand Up @@ -201,29 +189,24 @@ void CDiscAdjSinglezoneDriver::Run() {

void CDiscAdjSinglezoneDriver::Postprocess() {

switch(config->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 :

/*--- Compute the geometrical sensitivities ---*/
SecondaryRecording();
break;

if (config->GetKind_Solver() == DISC_ADJ_EULER ||
config->GetKind_Solver() == DISC_ADJ_NAVIER_STOKES ||
config->GetKind_Solver() == DISC_ADJ_RANS ||
config->GetKind_Solver() == DISC_ADJ_INC_EULER ||
config->GetKind_Solver() == DISC_ADJ_INC_NAVIER_STOKES ||
config->GetKind_Solver() == DISC_ADJ_INC_RANS){

/*--- Compute the geometrical sensitivities ---*/
SecondaryRecording();

}

if (config->GetKind_Solver() == DISC_ADJ_FEM){

/*--- Apply the boundary condition to clamped nodes ---*/
iteration->Postprocess(output,integration_container,geometry_container,solver_container,numerics_container,
config_container,surface_movement,grid_movement,FFDBox,ZONE_0,INST_0);
case DISC_ADJ_FEM :

RecordingState = NONE;
/*--- Apply the boundary condition to clamped nodes ---*/
iteration->Postprocess(output,integration_container,geometry_container,solver_container,numerics_container,
config_container,surface_movement,grid_movement,FFDBox,ZONE_0,INST_0);

}
RecordingState = NONE;
break;
}//switch

}

Expand Down
10 changes: 6 additions & 4 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3831,10 +3831,12 @@ void CDriver::StartSolver(){
PreprocessExtIter(ExtIter);

/*--- Perform a dynamic mesh update if required. ---*/

if (!fem_solver && !(config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetDiscrete_Adjoint())) {
DynamicMeshUpdate(ExtIter);
}
/*--- For the Disc.Adj. of a case with (rigidly) moving grid, the appropriate
mesh cordinates are read from the restart files. ---*/
if (!fem_solver &&
!(config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetDiscrete_Adjoint())) {
DynamicMeshUpdate(ExtIter);
}

/*--- Run a single iteration of the problem (fluid, elasticity, heat, ...). ---*/

Expand Down
6 changes: 4 additions & 2 deletions SU2_CFD/src/drivers/CSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,10 @@ void CSinglezoneDriver::Preprocess(unsigned long TimeIter) {
numerics_container, config_container, surface_movement, grid_movement, FFDBox, ZONE_0, INST_0);

/*--- Perform a dynamic mesh update if required. ---*/

DynamicMeshUpdate(TimeIter);
/*--- For the Disc.Adj. of a case with (rigidly) moving grid, the appropriate
mesh cordinates are read from the restart files. ---*/
if (!(config_container[ZONE_0]->GetGrid_Movement() && config_container[ZONE_0]->GetDiscrete_Adjoint()))
DynamicMeshUpdate(TimeIter);

}

Expand Down
Loading