Recompute density and enthalpy instead of reconstructing by pcarruscag · Pull Request #2356 · su2code/SU2 · GitHub
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
52 changes: 35 additions & 17 deletions SU2_CFD/include/numerics_simd/flow/convection/common.hpp
4 changes: 3 additions & 1 deletion SU2_CFD/include/numerics_simd/flow/convection/roe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class CRoeBase : public Base {

const su2double kappa;
const su2double gamma;
const su2double gasConst;
const su2double entropyFix;
const bool finestGrid;
const bool dynamicGrid;
Expand All @@ -69,6 +70,7 @@ class CRoeBase : public Base {
CRoeBase(const CConfig& config, unsigned iMesh, Ts&... args) : Base(config, iMesh, args...),
kappa(config.GetRoe_Kappa()),
gamma(config.GetGamma()),
gasConst(config.GetGas_ConstantND()),
entropyFix(config.GetEntropyFix_Coeff()),
finestGrid(iMesh == MESH_0),
dynamicGrid(config.GetDynamic_Grid()),
Expand Down Expand Up @@ -117,7 +119,7 @@ class CRoeBase : public Base {
V1st.j.all = gatherVariables<nPrimVar>(jPoint, solution.GetPrimitive());

auto V = reconstructPrimitives<CCompressiblePrimitives<nDim,nPrimVarGrad> >(
iEdge, iPoint, jPoint, muscl, typeLimiter, V1st, vector_ij, solution);
iEdge, iPoint, jPoint, gamma, gasConst, muscl, typeLimiter, V1st, vector_ij, solution);

/*--- Compute conservative variables. ---*/

Expand Down
5 changes: 5 additions & 0 deletions SU2_CFD/include/solvers/CFVMFlowSolverBase.inl
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,11 @@ void CFVMFlowSolverBase<V, R>::EdgeFluxResidual(const CGeometry *geometry,
"by the SIMD length (2, 4, or 8).", CURRENT_FUNCTION);
}
InstantiateEdgeNumerics(solvers, config);

/*--- The SIMD numerics do not use gradients of density and enthalpy. ---*/
if (!config->GetContinuous_Adjoint()) {
SU2_OMP_SAFE_GLOBAL_ACCESS(nPrimVarGrad = std::min<unsigned short>(nDim + 2, nPrimVarGrad);)
}
}

/*--- Non-physical counter. ---*/
Expand Down
6 changes: 2 additions & 4 deletions SU2_CFD/include/variables/CEulerVariable.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ class CEulerVariable : public CFlowVariable {
*/
bool SetSoundSpeed(unsigned long iPoint, su2double soundspeed2) final {
if (soundspeed2 < 0.0) return true;
else {
Primitive(iPoint,nDim+4) = sqrt(soundspeed2);
return false;
}
Primitive(iPoint,nDim+4) = sqrt(soundspeed2);
return false;
}

/*!
Expand Down
1 change: 0 additions & 1 deletion SU2_CFD/src/output/CElasticityOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ void CElasticityOutput::LoadHistoryData(CConfig *config, CGeometry *geometry, CS
/*--- Linear analysis: RMS of the displacements in the nDim coordinates ---*/
/*--- Nonlinear analysis: UTOL, RTOL and DTOL (defined in the Postprocessing function) ---*/


if (linear_analysis){
SetHistoryOutputValue("RMS_DISP_X", log10(fea_solver->GetRes_RMS(0)));
SetHistoryOutputValue("RMS_DISP_Y", log10(fea_solver->GetRes_RMS(1)));
Expand Down
10 changes: 7 additions & 3 deletions SU2_CFD/src/solvers/CEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
const bool time_stepping = (config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING);
const bool adjoint = config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint();
const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED;

int Unst_RestartIter = 0;
unsigned long iPoint, iMarker, counter_local = 0, counter_global = 0;
Expand Down Expand Up @@ -116,9 +117,12 @@ CEulerSolver::CEulerSolver(CGeometry *geometry, CConfig *config,

nDim = geometry->GetnDim();

nVar = nDim+2;
nPrimVar = nDim+9; nPrimVarGrad = nDim+4;
nSecondaryVar = nSecVar; nSecondaryVarGrad = 2;
nVar = nDim + 2;
nPrimVar = nDim + 9;
/*--- Centered schemes only need gradients for viscous fluxes (T and v). ---*/
nPrimVarGrad = nDim + (centered && !config->GetContinuous_Adjoint() ? 1 : 4);
nSecondaryVar = nSecVar;
nSecondaryVarGrad = 2;

/*--- Initialize nVarGrad for deallocation ---*/

Expand Down
6 changes: 5 additions & 1 deletion SU2_CFD/src/solvers/CIncEulerSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING;
bool adjoint = (config->GetContinuous_Adjoint()) || (config->GetDiscrete_Adjoint());
const bool centered = config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED;

/* A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain */
dynamic_grid = config->GetDynamic_Grid();
Expand Down Expand Up @@ -117,7 +118,10 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
nDim = geometry->GetnDim();

/*--- Make sure to align the sizes with the constructor of CIncEulerVariable. ---*/
nVar = nDim+2; nPrimVar = nDim+9; nPrimVarGrad = nDim+4;
nVar = nDim + 2;
nPrimVar = nDim + 9;
/*--- Centered schemes only need gradients for viscous fluxes (T and v, but we need also to include P). ---*/
nPrimVarGrad = nDim + (centered ? 2 : 4);

/*--- Initialize nVarGrad for deallocation ---*/

Expand Down
5 changes: 3 additions & 2 deletions SU2_CFD/src/variables/CEulerVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2double energy, unsigned long npoint,
unsigned long ndim, unsigned long nvar, const CConfig *config)
: CFlowVariable(npoint, ndim, nvar, ndim + 9, ndim + 4, config),
: CFlowVariable(npoint, ndim, nvar, ndim + 9,
ndim + (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED && !config->GetContinuous_Adjoint() ? 1 : 4), config),
indices(ndim, 0) {

const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
Expand Down Expand Up @@ -77,7 +78,7 @@ CEulerVariable::CEulerVariable(su2double density, const su2double *velocity, su2
Grad_AuxVar.resize(nPoint, nAuxVar, nDim, 0.0);
AuxVar.resize(nPoint, nAuxVar) = su2double(0.0);
}

if (config->GetKind_FluidModel() == ENUM_FLUIDMODEL::DATADRIVEN_FLUID){
DataDrivenFluid = true;
DatasetExtrapolation.resize(nPoint) = 0;
Expand Down
3 changes: 2 additions & 1 deletion SU2_CFD/src/variables/CIncEulerVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@

CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *velocity, su2double temperature,
unsigned long npoint, unsigned long ndim, unsigned long nvar, const CConfig *config)
: CFlowVariable(npoint, ndim, nvar, ndim + 9, ndim + 4, config),
: CFlowVariable(npoint, ndim, nvar, ndim + 9,
ndim + (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED ? 2 : 4), config),
indices(ndim, 0) {

const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
Expand Down
3 changes: 3 additions & 0 deletions TestCases/TestCase.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ def run_filediff(self, with_tsan=False, with_asan=False):
print('Ignored entries: ' + str(ignore_counter))
print('Maximum difference: ' + str(max_delta) + '%')

if not passed:
print(open(self.test_file).readlines())

print('==================== End Test: %s ====================\n'%self.tag)

sys.stdout.flush()
Expand Down
8 changes: 4 additions & 4 deletions TestCases/cont_adj_euler/wedge/of_grad_combo.dat.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
VARIABLES="VARIABLE" , "GRADIENT" , "FINDIFF_STEP"
0 , 0.00767644 , 0.0001
1 , 0.00498358 , 0.0001
2 , 0.00246134 , 0.0001
3 , 0.000893054 , 0.0001
0 , 0.00770904 , 0.0001
1 , 0.00500468 , 0.0001
2 , 0.00247269 , 0.0001
3 , 0.000899035 , 0.0001
2 changes: 1 addition & 1 deletion TestCases/disc_adj_fsi/config.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SOLVER= MULTIPHYSICS
MATH_PROBLEM= DISCRETE_ADJOINT
RESTART_SOL= NO
CONFIG_LIST=(configFlow.cfg, configFEA.cfg)

MARKER_ZONE_INTERFACE = (UpperWall, UpperWallS, LowerWall, LowerWallS)
Expand Down
18 changes: 6 additions & 12 deletions TestCases/disc_adj_fsi/configFEA.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@
% Author: R.Sanchez %
% Institution: Imperial College London %
% Date: 2017.11.29 %
% File Version 8.1.0 "Harrier" %
% File Version 8.1.0 "Harrier" %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SOLVER= ELASTICITY

MATH_PROBLEM= DISCRETE_ADJOINT

RESTART_SOL= NO

PRESTRETCH = YES
PRESTRETCH_FILENAME = prestretch.dat

Expand All @@ -27,8 +23,6 @@ REFERENCE_GEOMETRY_FORMAT = SU2
% Consider only the surface
REFERENCE_GEOMETRY_SURFACE = NO

READ_BINARY_RESTART=NO

STAT_RELAX_PARAMETER= 1.0
BGS_RELAXATION = FIXED_PARAMETER
PREDICTOR_ORDER=0
Expand All @@ -49,13 +43,13 @@ MARKER_CLAMPED = ( Clamped_Right, Clamped_Left )
MARKER_FLUID_LOAD= ( LowerWallS, UpperWallS)


LINEAR_SOLVER= CONJUGATE_GRADIENT
LINEAR_SOLVER_PREC= JACOBI
LINEAR_SOLVER= FGMRES
LINEAR_SOLVER_PREC= ILU
LINEAR_SOLVER_ERROR= 1E-9
LINEAR_SOLVER_ITER= 50000
LINEAR_SOLVER_ITER= 100

DISCADJ_LIN_SOLVER = CONJUGATE_GRADIENT
DISCADJ_LIN_PREC = JACOBI
DISCADJ_LIN_SOLVER = FGMRES
DISCADJ_LIN_PREC = ILU

CONV_RESIDUAL_MINVAL= -10
CONV_STARTITER= 10
Expand Down
11 changes: 2 additions & 9 deletions TestCases/disc_adj_fsi/configFlow.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,14 @@
% Author: R.Sanchez %
% Institution: Imperial College London %
% Date: 2017.11.29 %
% File Version 8.1.0 "Harrier" %
% File Version 8.1.0 "Harrier" %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

SOLVER= NAVIER_STOKES

MATH_PROBLEM= DISCRETE_ADJOINT

RESTART_SOL= NO

READ_BINARY_RESTART=NO

INNER_ITER= 50

STAT_RELAX_PARAMETER= 1.0
STAT_RELAX_PARAMETER= 1
BGS_RELAXATION = FIXED_PARAMETER
PREDICTOR_ORDER=0

Expand Down Expand Up @@ -48,7 +42,6 @@ MARKER_MONITORING= ( UpperWall, LowerWall, Wall)
DEFORM_MESH= YES
MARKER_DEFORM_MESH= ( UpperWall, LowerWall )


DEFORM_STIFFNESS_TYPE = INVERSE_VOLUME
DEFORM_POISSONS_RATIO = 1e6
DEFORM_LINEAR_SOLVER = CONJUGATE_GRADIENT
Expand Down
6 changes: 3 additions & 3 deletions TestCases/disc_adj_rans/naca0012/turb_NACA0012_sa.cfg
Loading