Skip to content

Commit f361b13

Browse files
authored
Merge pull request #1330 from su2code/feature_scalarbase
Base class for transported scalars
2 parents d940308 + 0b88e40 commit f361b13

38 files changed

Lines changed: 2002 additions & 1695 deletions

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ class CNumerics {
130130
*Psi_i, /*!< \brief Vector of adjoint variables at point i. */
131131
*Psi_j; /*!< \brief Vector of adjoint variables at point j. */
132132
const su2double
133-
*TurbVar_i, /*!< \brief Vector of turbulent variables at point i. */
134-
*TurbVar_j; /*!< \brief Vector of turbulent variables at point j. */
133+
*ScalarVar_i, /*!< \brief Vector of scalar variables at point i. */
134+
*ScalarVar_j; /*!< \brief Vector of scalar variables at point j. */
135135
const su2double
136136
*TransVar_i, /*!< \brief Vector of turbulent variables at point i. */
137137
*TransVar_j; /*!< \brief Vector of turbulent variables at point j. */
@@ -146,8 +146,8 @@ class CNumerics {
146146
PrimVar_Grad_j, /*!< \brief Gradient of primitive variables at point j. */
147147
PsiVar_Grad_i, /*!< \brief Gradient of adjoint variables at point i. */
148148
PsiVar_Grad_j, /*!< \brief Gradient of adjoint variables at point j. */
149-
TurbVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */
150-
TurbVar_Grad_j, /*!< \brief Gradient of turbulent variables at point j. */
149+
ScalarVar_Grad_i, /*!< \brief Gradient of scalar variables at point i. */
150+
ScalarVar_Grad_j, /*!< \brief Gradient of scalar variables at point j. */
151151
TransVar_Grad_i, /*!< \brief Gradient of turbulent variables at point i. */
152152
TransVar_Grad_j, /*!< \brief Gradient of turbulent variables at point j. */
153153
TurbPsi_Grad_i, /*!< \brief Gradient of adjoint turbulent variables at point i. */
@@ -347,13 +347,13 @@ class CNumerics {
347347
}
348348

349349
/*!
350-
* \brief Set the value of the turbulent variable.
351-
* \param[in] val_turbvar_i - Value of the turbulent variable at point i.
352-
* \param[in] val_turbvar_j - Value of the turbulent variable at point j.
350+
* \brief Set the value of the scalar variable.
351+
* \param[in] val_scalarvar_i - Value of the scalar variable at point i.
352+
* \param[in] val_scalarvar_j - Value of the scalar variable at point j.
353353
*/
354-
inline void SetTurbVar(const su2double *val_turbvar_i, const su2double *val_turbvar_j) {
355-
TurbVar_i = val_turbvar_i;
356-
TurbVar_j = val_turbvar_j;
354+
inline void SetScalarVar(const su2double *val_scalarvar_i, const su2double *val_scalarvar_j) {
355+
ScalarVar_i = val_scalarvar_i;
356+
ScalarVar_j = val_scalarvar_j;
357357
}
358358

359359
/*!
@@ -367,14 +367,14 @@ class CNumerics {
367367
}
368368

369369
/*!
370-
* \brief Set the gradient of the turbulent variables.
371-
* \param[in] val_turbvar_grad_i - Gradient of the turbulent variable at point i.
372-
* \param[in] val_turbvar_grad_j - Gradient of the turbulent variable at point j.
370+
* \brief Set the gradient of the scalar variables.
371+
* \param[in] val_scalarvar_grad_i - Gradient of the scalar variable at point i.
372+
* \param[in] val_scalarvar_grad_j - Gradient of the scalar variable at point j.
373373
*/
374-
inline void SetTurbVarGradient(CMatrixView<const su2double> val_turbvar_grad_i,
375-
CMatrixView<const su2double> val_turbvar_grad_j) {
376-
TurbVar_Grad_i = val_turbvar_grad_i;
377-
TurbVar_Grad_j = val_turbvar_grad_j;
374+
inline void SetScalarVarGradient(CMatrixView<const su2double> val_scalarvar_grad_i,
375+
CMatrixView<const su2double> val_scalarvar_grad_j) {
376+
ScalarVar_Grad_i = val_scalarvar_grad_i;
377+
ScalarVar_Grad_j = val_scalarvar_grad_j;
378378
}
379379

380380
/*!
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*!
2+
* \file scalar_convection.hpp
3+
* \brief Delarations of numerics classes for discretization of
4+
* convective fluxes in scalar problems.
5+
* \author F. Palacios, T. Economon
6+
* \version 7.2.0 "Blackbird"
7+
*
8+
* SU2 Project Website: https://su2code.github.io
9+
*
10+
* The SU2 Project is maintained by the SU2 Foundation
11+
* (http://su2foundation.org)
12+
*
13+
* Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md)
14+
*
15+
* SU2 is free software; you can redistribute it and/or
16+
* modify it under the terms of the GNU Lesser General Public
17+
* License as published by the Free Software Foundation; either
18+
* version 2.1 of the License, or (at your option) any later version.
19+
*
20+
* SU2 is distributed in the hope that it will be useful,
21+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23+
* Lesser General Public License for more details.
24+
*
25+
* You should have received a copy of the GNU Lesser General Public
26+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
27+
*/
28+
29+
#pragma once
30+
31+
#include "../CNumerics.hpp"
32+
33+
/*!
34+
* \class CUpwScalar
35+
* \brief Template class for scalar upwind fluxes between nodes i and j.
36+
* \details This class serves as a template for the scalar upwinding residual
37+
* classes. The general structure of a scalar upwinding calculation is the
38+
* same for many different models, which leads to a lot of repeated code.
39+
* By using the template design pattern, these sections of repeated code are
40+
* moved to this shared base class, and the specifics of each model
41+
* are implemented by derived classes. In order to add a new residual
42+
* calculation for a convection residual, extend this class and implement
43+
* the pure virtual functions with model-specific behavior.
44+
* \ingroup ConvDiscr
45+
* \author C. Pederson, A. Bueno., and A. Campos.
46+
*/
47+
class CUpwScalar : public CNumerics {
48+
protected:
49+
su2double a0 = 0.0; /*!< \brief The maximum of the face-normal velocity and 0 */
50+
su2double a1 = 0.0; /*!< \brief The minimum of the face-normal velocity and 0 */
51+
su2double* Flux = nullptr; /*!< \brief Final result, diffusive flux/residual. */
52+
su2double** Jacobian_i = nullptr; /*!< \brief Flux Jacobian w.r.t. node i. */
53+
su2double** Jacobian_j = nullptr; /*!< \brief Flux Jacobian w.r.t. node j. */
54+
55+
const bool implicit = false, incompressible = false, dynamic_grid = false;
56+
57+
/*!
58+
* \brief A pure virtual function; Adds any extra variables to AD
59+
*/
60+
virtual void ExtraADPreaccIn() = 0;
61+
62+
/*!
63+
* \brief Model-specific steps in the ComputeResidual method, derived classes
64+
* compute the Flux and its Jacobians via this method.
65+
* \param[in] config - Definition of the particular problem.
66+
*/
67+
virtual void FinishResidualCalc(const CConfig* config) = 0;
68+
69+
public:
70+
/*!
71+
* \brief Constructor of the class.
72+
* \param[in] val_nDim - Number of dimensions of the problem.
73+
* \param[in] val_nVar - Number of variables of the problem.
74+
* \param[in] config - Definition of the particular problem.
75+
*/
76+
CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config);
77+
78+
/*!
79+
* \brief Destructor of the class.
80+
*/
81+
~CUpwScalar(void) override;
82+
83+
/*!
84+
* \brief Compute the scalar upwind flux between two nodes i and j.
85+
* \param[in] config - Definition of the particular problem.
86+
* \return A lightweight const-view (read-only) of the residual/flux and Jacobians.
87+
*/
88+
ResidualType<> ComputeResidual(const CConfig* config) override;
89+
};
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*!
2+
* \file scalar_diffusion.hpp
3+
* \brief Declarations of numerics classes for discretization of
4+
* viscous fluxes in scalar problems.
5+
* \author F. Palacios, T. Economon
6+
* \version 7.2.0 "Blackbird"
7+
*
8+
* SU2 Project Website: https://su2code.github.io
9+
*
10+
* The SU2 Project is maintained by the SU2 Foundation
11+
* (http://su2foundation.org)
12+
*
13+
* Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md)
14+
*
15+
* SU2 is free software; you can redistribute it and/or
16+
* modify it under the terms of the GNU Lesser General Public
17+
* License as published by the Free Software Foundation; either
18+
* version 2.1 of the License, or (at your option) any later version.
19+
*
20+
* SU2 is distributed in the hope that it will be useful,
21+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23+
* Lesser General Public License for more details.
24+
*
25+
* You should have received a copy of the GNU Lesser General Public
26+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
27+
*/
28+
29+
#pragma once
30+
31+
#include "../CNumerics.hpp"
32+
33+
/*!
34+
* \class CAvgGrad_Scalar
35+
* \brief Template class for computing viscous residual of scalar values
36+
* \details This class serves as a template for the scalar viscous residual
37+
* classes. The general structure of a viscous residual calculation is the
38+
* same for many different models, which leads to a lot of repeated code.
39+
* By using the template design pattern, these sections of repeated code are
40+
* moved to a shared base class, and the specifics of each model
41+
* are implemented by derived classes. In order to add a new residual
42+
* calculation for a viscous residual, extend this class and implement
43+
* the pure virtual functions with model-specific behavior.
44+
* \ingroup ViscDiscr
45+
* \author C. Pederson, A. Bueno, and F. Palacios
46+
*/
47+
class CAvgGrad_Scalar : public CNumerics {
48+
protected:
49+
su2double* Proj_Mean_GradScalarVar_Normal = nullptr; /*!< \brief Mean_gradScalarVar DOT normal. */
50+
su2double* Proj_Mean_GradScalarVar = nullptr; /*!< \brief Mean_gradScalarVar DOT normal, corrected if required. */
51+
su2double proj_vector_ij = 0.0; /*!< \brief (Edge_Vector DOT normal)/|Edge_Vector|^2 */
52+
su2double* Flux = nullptr; /*!< \brief Final result, diffusive flux/residual. */
53+
su2double** Jacobian_i = nullptr; /*!< \brief Flux Jacobian w.r.t. node i. */
54+
su2double** Jacobian_j = nullptr; /*!< \brief Flux Jacobian w.r.t. node j. */
55+
56+
const bool correct_gradient = false, implicit = false, incompressible = false;
57+
58+
/*!
59+
* \brief A pure virtual function; Adds any extra variables to AD
60+
*/
61+
virtual void ExtraADPreaccIn() = 0;
62+
63+
/*!
64+
* \brief Model-specific steps in the ComputeResidual method, derived classes
65+
* should compute the Flux and Jacobians (i/j) inside this method.
66+
* \param[in] config - Definition of the particular problem.
67+
*/
68+
virtual void FinishResidualCalc(const CConfig* config) = 0;
69+
70+
public:
71+
/*!
72+
* \brief Constructor of the class.
73+
* \param[in] val_nDim - Number of dimensions of the problem.
74+
* \param[in] val_nVar - Number of variables of the problem.
75+
* \param[in] correct_gradient - Whether to correct gradient for skewness.
76+
* \param[in] config - Definition of the particular problem.
77+
*/
78+
CAvgGrad_Scalar(unsigned short val_nDim, unsigned short val_nVar, bool correct_gradient, const CConfig* config);
79+
80+
/*!
81+
* \brief Destructor of the class.
82+
*/
83+
~CAvgGrad_Scalar(void) override;
84+
85+
/*!
86+
* \brief Compute the viscous residual using an average of gradients without correction.
87+
* \param[in] config - Definition of the particular problem.
88+
* \return A lightweight const-view (read-only) of the residual/flux and Jacobians.
89+
*/
90+
ResidualType<> ComputeResidual(const CConfig* config) override;
91+
};
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*!
2+
* \file scalar_sources.hpp
3+
* \brief Delarations of numerics classes for integration of source terms in scalar problems.
4+
* \version 7.2.0 "Blackbird"
5+
*
6+
* SU2 Project Website: https://su2code.github.io
7+
*
8+
* The SU2 Project is maintained by the SU2 Foundation
9+
* (http://su2foundation.org)
10+
*
11+
* Copyright 2012-2021, SU2 Contributors (cf. AUTHORS.md)
12+
*
13+
* SU2 is free software; you can redistribute it and/or
14+
* modify it under the terms of the GNU Lesser General Public
15+
* License as published by the Free Software Foundation; either
16+
* version 2.1 of the License, or (at your option) any later version.
17+
*
18+
* SU2 is distributed in the hope that it will be useful,
19+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21+
* Lesser General Public License for more details.
22+
*
23+
* You should have received a copy of the GNU Lesser General Public
24+
* License along with SU2. If not, see <http://www.gnu.org/licenses/>.
25+
*/
26+
27+
#pragma once
28+
29+
#include "../CNumerics.hpp"

SU2_CFD/include/numerics/turbulent/turb_convection.hpp

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -28,67 +28,7 @@
2828

2929
#pragma once
3030

31-
#include "../CNumerics.hpp"
32-
33-
/*!
34-
* \class CUpwScalar
35-
* \brief Template class for scalar upwind fluxes between nodes i and j.
36-
* \details This class serves as a template for the scalar upwinding residual
37-
* classes. The general structure of a scalar upwinding calculation is the
38-
* same for many different models, which leads to a lot of repeated code.
39-
* By using the template design pattern, these sections of repeated code are
40-
* moved to this shared base class, and the specifics of each model
41-
* are implemented by derived classes. In order to add a new residual
42-
* calculation for a convection residual, extend this class and implement
43-
* the pure virtual functions with model-specific behavior.
44-
* \ingroup ConvDiscr
45-
* \author C. Pederson, A. Bueno., and A. Campos.
46-
*/
47-
class CUpwScalar : public CNumerics {
48-
protected:
49-
su2double
50-
a0 = 0.0, /*!< \brief The maximum of the face-normal velocity and 0 */
51-
a1 = 0.0, /*!< \brief The minimum of the face-normal velocity and 0 */
52-
*Flux = nullptr, /*!< \brief Final result, diffusive flux/residual. */
53-
**Jacobian_i = nullptr, /*!< \brief Flux Jacobian w.r.t. node i. */
54-
**Jacobian_j = nullptr; /*!< \brief Flux Jacobian w.r.t. node j. */
55-
56-
const bool implicit = false, incompressible = false, dynamic_grid = false;
57-
58-
/*!
59-
* \brief A pure virtual function; Adds any extra variables to AD
60-
*/
61-
virtual void ExtraADPreaccIn() = 0;
62-
63-
/*!
64-
* \brief Model-specific steps in the ComputeResidual method, derived classes
65-
* compute the Flux and its Jacobians via this method.
66-
* \param[in] config - Definition of the particular problem.
67-
*/
68-
virtual void FinishResidualCalc(const CConfig* config) = 0;
69-
70-
public:
71-
/*!
72-
* \brief Constructor of the class.
73-
* \param[in] val_nDim - Number of dimensions of the problem.
74-
* \param[in] val_nVar - Number of variables of the problem.
75-
* \param[in] config - Definition of the particular problem.
76-
*/
77-
CUpwScalar(unsigned short val_nDim, unsigned short val_nVar, const CConfig* config);
78-
79-
/*!
80-
* \brief Destructor of the class.
81-
*/
82-
~CUpwScalar(void) override;
83-
84-
/*!
85-
* \brief Compute the scalar upwind flux between two nodes i and j.
86-
* \param[in] config - Definition of the particular problem.
87-
* \return A lightweight const-view (read-only) of the residual/flux and Jacobians.
88-
*/
89-
ResidualType<> ComputeResidual(const CConfig* config) override;
90-
91-
};
31+
#include "../scalar/scalar_convection.hpp"
9232

9333
/*!
9434
* \class CUpwSca_TurbSA

0 commit comments

Comments
 (0)