|
| 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 | +}; |
0 commit comments