Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consistent mass fluxes between bulk flow and scalar solvers and boundedness correction #1697

Merged
merged 74 commits into from
Nov 28, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
76c1f27
working commit for incompressible
bigfooted Jul 4, 2022
182a4b0
adding/removing comments on what still needs to be implemented
bigfooted Jul 4, 2022
38e396b
small cleanup
bigfooted Jul 4, 2022
2ad9eb6
small cleanup
bigfooted Jul 4, 2022
809a6d9
remove unused variable
bigfooted Jul 4, 2022
e0c53c9
Merge branch 'develop' into feature_conservative_scalars
bigfooted Jul 4, 2022
52606ae
Added correction factor to scalar convective residual to negate the e…
EvertBunschoten Jul 4, 2022
02de5e2
Added correction factor to scalar convective residual to negate the e…
EvertBunschoten Jul 4, 2022
6ab2076
Fixed unused variable warnings
EvertBunschoten Jul 4, 2022
ffb1a24
Update SU2_CFD/include/solvers/CSolver.hpp
bigfooted Jul 7, 2022
f4ddbcf
clean up
bigfooted Jul 9, 2022
0716445
Merge branch 'develop' into feature_conservative_scalars
bigfooted Jul 18, 2022
c929e65
Added SCALAR_ADVECTION option for the scalar convective numerical met…
EvertBunschoten Jul 28, 2022
b92b6ab
Added SCALAR_ADVECTION option for the scalar convective numerical met…
EvertBunschoten Jul 28, 2022
0ba6c2f
Merge branch 'develop' into feature_conservative_scalars
bigfooted Jul 28, 2022
5e4f69e
Merge branch 'develop' into feature_conservative_scalars
bigfooted Aug 23, 2022
caa9a6f
Changed the upwind and centered convective enums to enum class
EvertBunschoten Aug 24, 2022
dcb1ec5
Merge branch 'develop' into feature_conservative_scalars
bigfooted Aug 24, 2022
70a43d1
Added 'default' case to Rieman_Solver_FEM switch in CConfig.cpp
EvertBunschoten Aug 25, 2022
b4acebc
Merged 70a43d1 into 1025b8b which resulted in conflicts when auto-mer…
EvertBunschoten Sep 9, 2022
3dea05b
Added default in CNumericsSIMD.cpp switch for convective numerics con…
EvertBunschoten Sep 9, 2022
f39f1ab
Fixed bug resulting from merge, enabled storage of edge mass fluxes f…
EvertBunschoten Sep 9, 2022
5cf5435
Update SU2_CFD/include/solvers/CScalarSolver.inl
bigfooted Sep 10, 2022
109aa8a
Update SU2_CFD/include/solvers/CSolver.hpp
bigfooted Sep 10, 2022
b0bbc54
Merge branch 'develop' into feature_conservative_scalars
bigfooted Sep 11, 2022
b5ba7e1
Merge branch 'develop' into feature_conservative_scalars
bigfooted Sep 16, 2022
22dbc19
Update Common/include/option_structure.hpp
bigfooted Sep 20, 2022
c42ede6
Update Common/include/option_structure.hpp
bigfooted Sep 20, 2022
839c099
Update Common/include/CConfig.hpp
bigfooted Sep 20, 2022
4d5f93f
Merge branch 'develop' into feature_conservative_scalars
bigfooted Sep 20, 2022
5a44165
Pulled in develop
EvertBunschoten Oct 4, 2022
2e9f069
Changed SCALAR_ADVECTION upwind option to BOUNDED_SCALAR, added weak …
EvertBunschoten Oct 5, 2022
0b427c5
Added bounded scalar conditional statements to Upwind_Residual to ens…
EvertBunschoten Oct 5, 2022
97b8138
Added more conditional statements regarding the scalar upwind scheme …
EvertBunschoten Oct 5, 2022
a09c741
Merge branch 'develop' into feature_conservative_scalars
bigfooted Oct 5, 2022
56e3ca6
Update SU2_CFD/include/numerics/CNumerics.hpp
bigfooted Oct 5, 2022
540bd0f
Update SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp
bigfooted Oct 5, 2022
50deb72
Update SU2_CFD/include/solvers/CScalarSolver.inl
bigfooted Oct 5, 2022
f6c67a0
Update Common/include/option_structure.hpp
bigfooted Oct 5, 2022
44e1e18
Update SU2_CFD/include/numerics/scalar/scalar_convection.hpp
bigfooted Oct 5, 2022
2ad40dd
Update Common/include/option_structure.hpp
bigfooted Oct 5, 2022
aaf20c6
Merge branch 'develop' into feature_conservative_scalars
bigfooted Oct 13, 2022
e9382b5
Update SU2_CFD/include/numerics/scalar/scalar_convection.hpp
bigfooted Oct 13, 2022
bdfbdc8
Finalized weak inlet and outlet boundary conditions for scalar solver…
EvertBunschoten Oct 13, 2022
c4441d6
Added bounded scalar test case configuration file
EvertBunschoten Oct 13, 2022
9452883
Initialized the edge flux variable in the inlet and outlet boundary c…
EvertBunschoten Oct 13, 2022
e02fda4
Fixed units issue with the density in the flux calculation of the spe…
EvertBunschoten Oct 14, 2022
7d3b4b0
Added BOUNDED_SCALAR test cases under parallel regression for both co…
EvertBunschoten Oct 14, 2022
c2f3a35
Changed regression test values for bounded scalar test cases
EvertBunschoten Oct 14, 2022
a955bb3
Changed test values for primitiveVenturi test case according to the c…
EvertBunschoten Oct 18, 2022
ab947d0
Merge branch 'develop' of /~https://github.com/su2code/SU2 into feature…
EvertBunschoten Oct 18, 2022
dac5742
remove spacmove variable declaration to where they are used
bigfooted Oct 18, 2022
050d773
move density modification to definition of a0 and a1, fix preaccumula…
bigfooted Oct 18, 2022
28ec306
Merge branch 'develop' into feature_conservative_scalars
bigfooted Oct 19, 2022
1b35499
Disabed axisymmetric source term for bounded scalar simulations
EvertBunschoten Nov 9, 2022
6d06d35
Implemented fix for axisymmetric bounded scalar problems
EvertBunschoten Nov 9, 2022
c3a8e19
Fixed build error
EvertBunschoten Nov 9, 2022
9eb67d0
Reduced CFL number for species bounded scalar test case to prevent di…
EvertBunschoten Nov 9, 2022
924ba51
Updated regression test values for venturi test case with bounded scalar
EvertBunschoten Nov 10, 2022
986bdff
Merge branch 'develop' into feature_conservative_scalars
bigfooted Nov 15, 2022
c0eb4aa
Updated test values for bounded_scalar test cases
EvertBunschoten Nov 18, 2022
c61df43
merge with develop
bigfooted Nov 18, 2022
7d1c511
Apply suggestions from code review
pcarruscag Nov 21, 2022
a91de01
Merge branch 'develop' into feature_conservative_scalars
bigfooted Nov 22, 2022
d46b96c
Streamlined declarations of bounded scalar problem for turbulence and…
EvertBunschoten Nov 22, 2022
f515f83
Streamlined declarations of bounded scalar problem for turbulence and…
EvertBunschoten Nov 22, 2022
930d34a
Reduced code duplication, changed inlet and outlet turbulent and spec…
EvertBunschoten Nov 23, 2022
a64c542
pulled develop
EvertBunschoten Nov 25, 2022
09cadc6
fix bounded scalars for OpenMP, improve efficiency, fix for centered …
pcarruscag Nov 25, 2022
16f7c4c
avoid bounded scalar code duplication in BC's
pcarruscag Nov 26, 2022
5cee01a
add additional comments, update target mass flow rate output message
bigfooted Nov 28, 2022
294cad7
Merge branch 'develop' into feature_conservative_scalars
bigfooted Nov 28, 2022
32da59e
changed regression test results
bigfooted Nov 28, 2022
d9a3277
Merge branch 'feature_conservative_scalars' of /~https://github.com/su2…
bigfooted Nov 28, 2022
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
53 changes: 44 additions & 9 deletions SU2_CFD/include/solvers/CScalarSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#include "../../../Common/include/parallelization/omp_structure.hpp"
#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
#include "../variables/CScalarVariable.hpp"
#include "../variables/CFlowVariable.hpp"
#include "../variables/CPrimitiveIndices.hpp"
#include "CSolver.hpp"

/*!
Expand All @@ -50,14 +52,15 @@ class CScalarSolver : public CSolver {

unsigned long omp_chunk_size; /*!< \brief Chunk size used in light point loops. */

su2double lowerlimit[MAXNVAR]; /*!< \brief contains lower limits for turbulence variables. Note that ::min()
returns the smallest positive value for floats. */
su2double upperlimit[MAXNVAR]; /*!< \brief contains upper limits for turbulence variables. */
su2double lowerlimit[MAXNVAR]; /*!< \brief contains lower limits for scalar variables. */
su2double upperlimit[MAXNVAR]; /*!< \brief contains upper limits for scalar variables. */

su2double Solution_Inf[MAXNVAR]; /*!< \brief Far-field solution. */

const bool Conservative; /*!< \brief Transported Variable is conservative. Solution has to be multiplied with rho. */

const CPrimitiveIndices<unsigned short> prim_idx; /*!< \brief Indices of the primitive flow variables. */

vector<su2matrix<su2double*> > SlidingState; // vector of matrix of pointers... inner dim alloc'd elsewhere (welcome, to the twilight zone)
vector<vector<int> > SlidingStateNodes;

Expand Down Expand Up @@ -86,7 +89,7 @@ class CScalarSolver : public CSolver {
inline CVariable* GetBaseClassPointerToNodes() final { return nodes; }

/*!
* \brief Compute the viscous flux for the turbulent equation at a particular edge.
* \brief Compute the viscous flux for the scalar equation at a particular edge.
* \tparam SolverSpecificNumericsFunc - lambda-function, that implements solver specific contributions to numerics.
* \note The functor has to implement (iPoint, jPoint)
* \param[in] iEdge - Edge for which we want to compute the flux
Expand All @@ -100,7 +103,7 @@ class CScalarSolver : public CSolver {
CGeometry* geometry, CSolver** solver_container, CNumerics* numerics,
CConfig* config) {
const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);
CVariable* flowNodes = solver_container[FLOW_SOL]->GetNodes();
auto* flowNodes = su2staticcast_p<CFlowVariable*>(solver_container[FLOW_SOL]->GetNodes());

/*--- Points in edge ---*/

Expand Down Expand Up @@ -177,7 +180,7 @@ class CScalarSolver : public CSolver {

su2double* PrimVar_i = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);

auto Jacobian_i = Jacobian.GetBlock(iPoint,iPoint);
auto* Jacobian_i = Jacobian.GetBlock(iPoint, iPoint);

/*--- Loop over the nDonorVertexes and compute the averaged flux ---*/

Expand Down Expand Up @@ -208,6 +211,12 @@ class CScalarSolver : public CSolver {
if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint));

if (conv_numerics->GetBoundedScalar()) {
const su2double* velocity = &PrimVar_j[prim_idx.Velocity()];
const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, true, density, velocity, Normal));
}

auto residual = conv_numerics->ComputeResidual(config);

/*--- Accumulate the residuals to compute the average ---*/
Expand Down Expand Up @@ -255,6 +264,20 @@ class CScalarSolver : public CSolver {
}
}

/*!
* \brief Applies a convective flux correction to negate the effects of flow divergence at a BC node.
* \note This function should be used for nodes that are part of a boundary marker, it computes a mass flux
* from density and velocity at the node, and the outward-poiting normal (-1 * normal of vertex).
* \return The mass flux.
*/
inline su2double BoundedScalarBCFlux(unsigned long iPoint, bool implicit, const su2double& density,
const su2double* velocity, const su2double* normal) {
const su2double edgeMassFlux = density * GeometryToolbox::DotProduct(nDim, velocity, normal);
LinSysRes.AddBlock(iPoint, nodes->GetSolution(iPoint), -edgeMassFlux);
if (implicit) Jacobian.AddVal2Diag(iPoint, -edgeMassFlux);
return edgeMassFlux;
}

/*!
* \brief Gradient and Limiter computation.
* \param[in] geometry - Geometrical definition of the problem.
Expand All @@ -265,7 +288,7 @@ class CScalarSolver : public CSolver {

private:
/*!
* \brief Compute the viscous flux for the turbulent equation at a particular edge.
* \brief Compute the viscous flux for the scalar equation at a particular edge.
* \param[in] iEdge - Edge for which we want to compute the flux
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
Expand Down Expand Up @@ -319,8 +342,20 @@ class CScalarSolver : public CSolver {
* \param[in] config - Definition of the particular problem.
* \param[in] iMesh - Index of the mesh in multigrid computations.
*/
void Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container, CConfig* config,
unsigned short iMesh) override;
void Upwind_Residual(CGeometry* geometry, CSolver** solver_container, CNumerics** numerics_container,
CConfig* config, unsigned short iMesh) override;

/*!
* \brief Impose the Far Field boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] conv_numerics - Description of the numerical method.
* \param[in] visc_numerics - Description of the numerical method.
* \param[in] config - Definition of the particular problem.
* \param[in] val_marker - Surface marker where the boundary condition is applied.
*/
void BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics,
CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final;

/*!
* \brief Impose the Symmetry Plane boundary condition.
Expand Down
73 changes: 66 additions & 7 deletions SU2_CFD/include/solvers/CScalarSolver.inl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@

template <class VariableType>
CScalarSolver<VariableType>::CScalarSolver(CGeometry* geometry, CConfig* config, bool conservative)
: CSolver(), Conservative(conservative) {
: CSolver(), Conservative(conservative),
prim_idx(config->GetKind_Regime() == ENUM_REGIME::INCOMPRESSIBLE,
config->GetNEMOProblem(), geometry->GetnDim(), config->GetnSpecies()) {
nMarker = config->GetnMarker_All();

/*--- Store the number of vertices on each marker for deallocation later ---*/
Expand Down Expand Up @@ -281,13 +283,9 @@ void CScalarSolver<VariableType>::Upwind_Residual(CGeometry* geometry, CSolver**
* to avoid race conditions in accessing nodes shared by edges handled by different threads. ---*/

if (bounded_scalar && !ReducerStrategy) {
for (iVar = 0; iVar < nVar; iVar++) {
const su2double FluxCorrection_i = nodes->GetSolution(iPoint, iVar) * EdgeMassFlux;
const su2double FluxCorrection_j = nodes->GetSolution(jPoint, iVar) * EdgeMassFlux;
LinSysRes.AddBlock(iPoint, nodes->GetSolution(iPoint), -EdgeMassFlux);
LinSysRes.AddBlock(jPoint, nodes->GetSolution(jPoint), EdgeMassFlux);

LinSysRes(iPoint, iVar) -= FluxCorrection_i;
LinSysRes(jPoint, iVar) += FluxCorrection_j;
}
if (implicit) {
Jacobian.AddVal2Diag(iPoint, -EdgeMassFlux);
Jacobian.AddVal2Diag(jPoint, EdgeMassFlux);
Expand Down Expand Up @@ -363,6 +361,67 @@ void CScalarSolver<VariableType>::BC_Periodic(CGeometry* geometry, CSolver** sol
}
}

template <class VariableType>
void CScalarSolver<VariableType>::BC_Far_Field(CGeometry* geometry, CSolver** solver_container,
CNumerics* conv_numerics, CNumerics*, CConfig *config,
unsigned short val_marker) {

const bool implicit = (config->GetKind_TimeIntScheme() == EULER_IMPLICIT);

SU2_OMP_FOR_STAT(OMP_MIN_SIZE)
for (auto iVertex = 0u; iVertex < geometry->nVertex[val_marker]; iVertex++) {

const auto iPoint = geometry->vertex[val_marker][iVertex]->GetNode();

/*--- Check if the node belongs to the domain (i.e, not a halo node) ---*/

if (geometry->nodes->GetDomain(iPoint)) {

/*--- Allocate the value at the infinity ---*/

auto V_infty = solver_container[FLOW_SOL]->GetCharacPrimVar(val_marker, iVertex);

/*--- Retrieve solution at the farfield boundary node ---*/

auto V_domain = solver_container[FLOW_SOL]->GetNodes()->GetPrimitive(iPoint);

/*--- Grid Movement ---*/

if (dynamic_grid)
conv_numerics->SetGridVel(geometry->nodes->GetGridVel(iPoint), geometry->nodes->GetGridVel(iPoint));

conv_numerics->SetPrimitive(V_domain, V_infty);

/*--- Set turbulent variable at the wall, and at infinity ---*/

conv_numerics->SetScalarVar(nodes->GetSolution(iPoint), Solution_Inf);

/*--- Set Normal (it is necessary to change the sign) ---*/

su2double Normal[MAXNDIM] = {0.0};
for (auto iDim = 0u; iDim < nDim; iDim++)
Normal[iDim] = -geometry->vertex[val_marker][iVertex]->GetNormal(iDim);
conv_numerics->SetNormal(Normal);

if (conv_numerics->GetBoundedScalar()) {
const su2double* velocity = &V_infty[prim_idx.Velocity()];
const su2double density = solver_container[FLOW_SOL]->GetNodes()->GetDensity(iPoint);
conv_numerics->SetMassFlux(BoundedScalarBCFlux(iPoint, implicit, density, velocity, Normal));
}

/*--- Compute residuals and Jacobians ---*/

auto residual = conv_numerics->ComputeResidual(config);

/*--- Add residuals and Jacobians ---*/

LinSysRes.AddBlock(iPoint, residual);
if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i);
}
}
END_SU2_OMP_FOR
}

template <class VariableType>
void CScalarSolver<VariableType>::PrepareImplicitIteration(CGeometry* geometry, CSolver** solver_container,
CConfig* config) {
Expand Down
18 changes: 1 addition & 17 deletions SU2_CFD/include/solvers/CTransLMSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,7 @@ class CTransLMSolver final : public CTurbSolver {
CNumerics *conv_numerics,
CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker) override;

/*!
* \brief Impose the Far Field boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] conv_numerics - Description of the numerical method.
* \param[in] visc_numerics - Description of the numerical method.
* \param[in] config - Definition of the particular problem.
* \param[in] val_marker - Surface marker where the boundary condition is applied.
*/
void BC_Far_Field(CGeometry *geometry,
CSolver **solver_container,
CNumerics *conv_numerics,
CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker) override;
unsigned short val_marker) override;

/*!
* \brief Impose the inlet boundary condition.
Expand Down
16 changes: 0 additions & 16 deletions SU2_CFD/include/solvers/CTurbSASolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,6 @@ class CTurbSASolver final : public CTurbSolver {
CConfig *config,
unsigned short val_marker) override;

/*!
* \brief Impose the Far Field boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] conv_numerics - Description of the numerical method.
* \param[in] visc_numerics - Description of the numerical method.
* \param[in] config - Definition of the particular problem.
* \param[in] val_marker - Surface marker where the boundary condition is applied.
*/
void BC_Far_Field(CGeometry *geometry,
CSolver **solver_container,
CNumerics *conv_numerics,
CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker) override;

/*!
* \brief Impose the inlet boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down
16 changes: 0 additions & 16 deletions SU2_CFD/include/solvers/CTurbSSTSolver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,22 +169,6 @@ class CTurbSSTSolver final : public CTurbSolver {
CConfig *config,
unsigned short val_marker) override;

/*!
* \brief Impose the Far Field boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
* \param[in] solver_container - Container vector with all the solutions.
* \param[in] conv_numerics - Description of the numerical method.
* \param[in] visc_numerics - Description of the numerical method.
* \param[in] config - Definition of the particular problem.
* \param[in] val_marker - Surface marker where the boundary condition is applied.
*/
void BC_Far_Field(CGeometry *geometry,
CSolver **solver_container,
CNumerics *conv_numerics,
CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker) override;

/*!
* \brief Impose the inlet boundary condition.
* \param[in] geometry - Geometrical definition of the problem.
Expand Down
Loading