Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions Common/include/CConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3642,6 +3642,19 @@ class CConfig {
return (Kind_Solver == HEAT_EQUATION) || (Kind_Solver == DISC_ADJ_HEAT);
}

/*!
* \brief Return true if a high order FEM solver is in use.
*/
bool GetFEMSolver(void) const {
switch (Kind_Solver) {
case FEM_EULER: case FEM_NAVIER_STOKES: case FEM_RANS: case FEM_LES:
case DISC_ADJ_FEM_EULER: case DISC_ADJ_FEM_NS: case DISC_ADJ_FEM_RANS:
return true;
default:
return false;
}
}

/*!
* \brief Kind of Multizone Solver.
* \return Governing equation that we are solving.
Expand Down
10 changes: 2 additions & 8 deletions Common/src/geometry/CPhysicalGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,7 @@ CPhysicalGeometry::CPhysicalGeometry(CConfig *config, unsigned short val_iZone,

/*--- Determine whether or not a FEM discretization is used ---*/

const bool fem_solver = ((config->GetKind_Solver() == FEM_EULER) ||
(config->GetKind_Solver() == FEM_NAVIER_STOKES) ||
(config->GetKind_Solver() == FEM_RANS) ||
(config->GetKind_Solver() == FEM_LES) ||
(config->GetKind_Solver() == DISC_ADJ_FEM_EULER) ||
(config->GetKind_Solver() == DISC_ADJ_FEM_NS) ||
(config->GetKind_Solver() == DISC_ADJ_FEM_RANS));
const bool fem_solver = config->GetFEMSolver();

/*--- Initialize counters for local/global points & elements ---*/

Expand Down Expand Up @@ -11756,4 +11750,4 @@ void CPhysicalGeometry::SetWallDistance(const CConfig *config, CADTElemClass *Wa
node[iPoint]->SetWall_Distance(dist);
}
}
}
}
3 changes: 3 additions & 0 deletions SU2_CFD/src/drivers/CDiscAdjSinglezoneDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ CDiscAdjSinglezoneDriver::CDiscAdjSinglezoneDriver(char* confFile,

CDiscAdjSinglezoneDriver::~CDiscAdjSinglezoneDriver(void) {

delete direct_iteration;
delete direct_output;

}

void CDiscAdjSinglezoneDriver::Preprocess(unsigned long TimeIter) {
Expand Down
14 changes: 4 additions & 10 deletions SU2_CFD/src/drivers/CDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,16 +649,10 @@ void CDriver::Input_Preprocessing(CConfig **&config, CConfig *&driver_config) {
}
}

/*--- Determine whether or not the FEM solver is used, which decides the
type of geometry classes that are instantiated. Only adapted for single-zone problems ---*/

fem_solver = ((config_container[ZONE_0]->GetKind_Solver() == FEM_EULER) ||
(config_container[ZONE_0]->GetKind_Solver() == FEM_NAVIER_STOKES) ||
(config_container[ZONE_0]->GetKind_Solver() == FEM_RANS) ||
(config_container[ZONE_0]->GetKind_Solver() == FEM_LES) ||
(config_container[ZONE_0]->GetKind_Solver() == DISC_ADJ_FEM_EULER) ||
(config_container[ZONE_0]->GetKind_Solver() == DISC_ADJ_FEM_NS) ||
(config_container[ZONE_0]->GetKind_Solver() == DISC_ADJ_FEM_RANS));
/*--- Determine whether or not the FEM solver is used, which decides the type of
* geometry classes that are instantiated. Only adapted for single-zone problems ---*/

fem_solver = config_container[ZONE_0]->GetFEMSolver();

fsi = config_container[ZONE_0]->GetFSI_Simulation();
}
Expand Down
17 changes: 3 additions & 14 deletions SU2_CFD/src/output/output_structure_legacy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4162,10 +4162,7 @@ void COutputLegacy::SetRestart(CConfig *config, CGeometry *geometry, CSolver **s

/*--- Determine whether or not the FEM solver is used, which decides the
type of geometry classes that are instantiated. ---*/
bool fem_solver = ((config->GetKind_Solver() == FEM_EULER) ||
(config->GetKind_Solver() == FEM_NAVIER_STOKES) ||
(config->GetKind_Solver() == FEM_RANS) ||
(config->GetKind_Solver() == FEM_LES));
const bool fem_solver = config->GetFEMSolver();

unsigned long nPointTotal = 0;
if ( fem_solver ) {
Expand Down Expand Up @@ -11880,11 +11877,7 @@ void COutputLegacy::SetResult_Files_Parallel(CSolver *****solver_container,
for (iZone = 0; iZone < val_nZone; iZone++) {

/*--- Bool to distinguish between the FVM and FEM solvers. ---*/
unsigned short KindSolver = config[iZone]->GetKind_Solver();
bool fem_solver = ((KindSolver == FEM_EULER) ||
(KindSolver == FEM_NAVIER_STOKES) ||
(KindSolver == FEM_RANS) ||
(KindSolver == FEM_LES));
const bool fem_solver = config[iZone]->GetFEMSolver();

/*--- Get the file output format ---*/

Expand Down Expand Up @@ -20393,11 +20386,7 @@ void COutputLegacy::PrepareOffsets(CConfig *config, CGeometry *geometry) {

/*--- Bool to distinguish between the FVM and FEM solvers. ---*/

unsigned short KindSolver = config->GetKind_Solver();
bool fem_solver = ((KindSolver == FEM_EULER) ||
(KindSolver == FEM_NAVIER_STOKES) ||
(KindSolver == FEM_RANS) ||
(KindSolver == FEM_LES));
const bool fem_solver = config->GetFEMSolver();

/*--- Reset point sorting counters ---*/

Expand Down
109 changes: 43 additions & 66 deletions SU2_DOT/src/SU2_DOT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* SU2 Project Website: https://su2code.github.io
*
* The SU2 Project is maintained by the SU2 Foundation
* The SU2 Project is maintained by the SU2 Foundation
* (http://su2foundation.org)
*
* Copyright 2012-2020, SU2 Contributors (cf. AUTHORS.md)
Expand All @@ -31,16 +31,10 @@ using namespace std;

int main(int argc, char *argv[]) {

unsigned short iZone, nZone = SINGLE_ZONE, iInst;
unsigned short iZone, iInst;
su2double StartTime = 0.0, StopTime = 0.0, UsedTime = 0.0;

char config_file_name[MAX_STRING_SIZE];
ofstream Gradient_file;
bool fem_solver = false;

su2double** Gradient;
unsigned short iDV, iDV_Value;
int rank, size;

/*--- MPI initialization, and buffer setting ---*/

Expand All @@ -56,17 +50,17 @@ int main(int argc, char *argv[]) {
SU2_Comm MPICommunicator(0);
#endif

rank = SU2_MPI::GetRank();
size = SU2_MPI::GetSize();
const int rank = SU2_MPI::GetRank();
const int size = SU2_MPI::GetSize();

/*--- Pointer to different structures that will be used throughout the entire code ---*/

CConfig **config_container = NULL;
CConfig *driver_config = NULL;
CGeometry ***geometry_container = NULL;
CSurfaceMovement **surface_movement = NULL;
CVolumetricMovement **grid_movement = NULL;
unsigned short *nInst = NULL;
CConfig **config_container = nullptr;
CConfig *driver_config = nullptr;
CGeometry ***geometry_container = nullptr;
CSurfaceMovement **surface_movement = nullptr;
CVolumetricMovement **grid_movement = nullptr;
unsigned short *nInst = nullptr;

/*--- Load in the number of zones and spatial dimensions in the mesh file (if no config
file is specified, default.cfg is used) ---*/
Expand All @@ -78,27 +72,23 @@ int main(int argc, char *argv[]) {
file the number of zones and dimensions from the numerical grid (required
for variables allocation) ---*/

CConfig *config = NULL;
CConfig *config = nullptr;
config = new CConfig(config_file_name, SU2_DOT);

nZone = config->GetnZone();
const auto nZone = config->GetnZone();

/*--- Definition of the containers per zones ---*/

config_container = new CConfig*[nZone];
geometry_container = new CGeometry**[nZone];
surface_movement = new CSurfaceMovement*[nZone];
grid_movement = new CVolumetricMovement*[nZone];
config_container = new CConfig*[nZone] ();
geometry_container = new CGeometry**[nZone] ();
surface_movement = new CSurfaceMovement*[nZone] ();
grid_movement = new CVolumetricMovement*[nZone] ();

nInst = new unsigned short[nZone];
driver_config = NULL;
driver_config = nullptr;

for (iZone = 0; iZone < nZone; iZone++) {
config_container[iZone] = NULL;
geometry_container[iZone] = NULL;
grid_movement [iZone] = NULL;
surface_movement[iZone] = NULL;
nInst[iZone] = 1;
nInst[iZone] = 1;
}

/*--- Initialize the configuration of the driver ---*/
Expand Down Expand Up @@ -144,13 +134,7 @@ int main(int argc, char *argv[]) {

/*--- Determine whether or not the FEM solver is used, which decides the
type of geometry classes that are instantiated. ---*/
fem_solver = ((config_container[iZone]->GetKind_Solver() == FEM_EULER) ||
(config_container[iZone]->GetKind_Solver() == FEM_NAVIER_STOKES) ||
(config_container[iZone]->GetKind_Solver() == FEM_RANS) ||
(config_container[iZone]->GetKind_Solver() == FEM_LES) ||
(config_container[iZone]->GetKind_Solver() == DISC_ADJ_FEM_EULER) ||
(config_container[iZone]->GetKind_Solver() == DISC_ADJ_FEM_NS) ||
(config_container[iZone]->GetKind_Solver() == DISC_ADJ_FEM_RANS));
const bool fem_solver = config_container[iZone]->GetFEMSolver();

/*--- Read the number of instances for each zone ---*/

Expand All @@ -162,7 +146,7 @@ int main(int argc, char *argv[]) {

/*--- Definition of the geometry class to store the primal grid in the partitioning process. ---*/

CGeometry *geometry_aux = NULL;
CGeometry *geometry_aux = nullptr;

/*--- All ranks process the grid and call ParMETIS for partitioning ---*/

Expand Down Expand Up @@ -318,20 +302,18 @@ int main(int argc, char *argv[]) {

/*--- Initialize structure to store the gradient ---*/

Gradient = new su2double*[config_container[ZONE_0]->GetnDV()];
su2double** Gradient = new su2double*[config_container[ZONE_0]->GetnDV()];

for (iDV = 0; iDV < config_container[iZone]->GetnDV(); iDV++){
Gradient[iDV] = new su2double[config_container[iZone]->GetnDV_Value(iDV)];
for (iDV_Value = 0; iDV_Value < config_container[iZone]->GetnDV_Value(iDV); iDV_Value++){
Gradient[iDV][iDV_Value] = 0.0;
}
for (auto iDV = 0u; iDV < config_container[iZone]->GetnDV(); iDV++) {
Gradient[iDV] = new su2double[config_container[iZone]->GetnDV_Value(iDV)] ();
}

if (rank == MASTER_NODE)
cout << "\n---------- Start gradient evaluation using sensitivity information ----------" << endl;

/*--- Write the gradient in a external file ---*/

ofstream Gradient_file;
if (rank == MASTER_NODE)
Gradient_file.open(config_container[iZone]->GetObjFunc_Grad_FileName().c_str(), ios::out);

Expand All @@ -355,27 +337,24 @@ int main(int argc, char *argv[]) {

OutputGradient(Gradient, config_container[iZone], Gradient_file);

if (rank == MASTER_NODE)
Gradient_file.close();

for (iDV = 0; iDV < config_container[iZone]->GetnDV(); iDV++){
for (auto iDV = 0u; iDV < config_container[iZone]->GetnDV(); iDV++){
delete [] Gradient[iDV];
}
delete [] Gradient;
}
}
delete [] Gradient;

delete config;
config = NULL;
config = nullptr;

if (rank == MASTER_NODE)
cout << "\n------------------------- Solver Postprocessing -------------------------" << endl;

if (geometry_container != NULL) {
if (geometry_container != nullptr) {
for (iZone = 0; iZone < nZone; iZone++) {
if (geometry_container[iZone] != NULL) {
if (geometry_container[iZone] != nullptr) {
for (iInst = 0; iInst < nInst[iZone]; iInst++){
if (geometry_container[iZone][iInst] != NULL) {
if (geometry_container[iZone][iInst] != nullptr) {
delete geometry_container[iZone][iInst];
}
}
Expand All @@ -386,19 +365,19 @@ int main(int argc, char *argv[]) {
}
if (rank == MASTER_NODE) cout << "Deleted CGeometry container." << endl;

if (surface_movement != NULL) {
if (surface_movement != nullptr) {
for (iZone = 0; iZone < nZone; iZone++) {
if (surface_movement[iZone] != NULL) {
if (surface_movement[iZone] != nullptr) {
delete surface_movement[iZone];
}
}
delete [] surface_movement;
}
if (rank == MASTER_NODE) cout << "Deleted CSurfaceMovement class." << endl;

if (grid_movement != NULL) {
if (grid_movement != nullptr) {
for (iZone = 0; iZone < nZone; iZone++) {
if (grid_movement[iZone] != NULL) {
if (grid_movement[iZone] != nullptr) {
delete grid_movement[iZone];
}
}
Expand All @@ -407,10 +386,10 @@ int main(int argc, char *argv[]) {
if (rank == MASTER_NODE) cout << "Deleted CVolumetricMovement class." << endl;

delete config;
config = NULL;
if (config_container != NULL) {
config = nullptr;
if (config_container != nullptr) {
for (iZone = 0; iZone < nZone; iZone++) {
if (config_container[iZone] != NULL) {
if (config_container[iZone] != nullptr) {
delete config_container[iZone];
}
}
Expand Down Expand Up @@ -471,7 +450,7 @@ void SetProjection_FD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su

unsigned short nFFDBox = MAX_NUMBER_FFD;
FFDBox = new CFreeFormDefBox*[nFFDBox];
for (iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; iFFDBox++) FFDBox[iFFDBox] = NULL;
for (iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; iFFDBox++) FFDBox[iFFDBox] = nullptr;

for (iDV = 0; iDV < nDV; iDV++){
nDV_Value = config->GetnDV_Value(iDV);
Expand Down Expand Up @@ -692,9 +671,9 @@ void SetProjection_FD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su

/*--- Delete memory for parameterization. ---*/

if (FFDBox != NULL) {
if (FFDBox != nullptr) {
for (iFFDBox = 0; iFFDBox < MAX_NUMBER_FFD; iFFDBox++) {
if (FFDBox[iFFDBox] != NULL) {
if (FFDBox[iFFDBox] != nullptr) {
delete FFDBox[iFFDBox];
}
}
Expand All @@ -718,7 +697,7 @@ void SetProjection_AD(CGeometry *geometry, CConfig *config, CSurfaceMovement *su
nDim = geometry->GetnDim();
nDV = config->GetnDV();

VarCoord = NULL;
VarCoord = nullptr;

/*--- Discrete adjoint gradient computation ---*/

Expand Down Expand Up @@ -888,9 +867,8 @@ void SetSensitivity_Files(CGeometry ***geometry, CConfig **config, unsigned shor

unsigned short iZone;

CSolver *solver = NULL;
COutput *output = NULL;

CSolver *solver = nullptr;
COutput *output = nullptr;

for (iZone = 0; iZone < val_nZone; iZone++) {

Expand Down Expand Up @@ -1000,4 +978,3 @@ void SetSensitivity_Files(CGeometry ***geometry, CConfig **config, unsigned shor
}

}

Loading