31#include "../../../Common/include/parallelization/omp_structure.hpp"
32#include "../../../Common/include/toolboxes/geometry_toolbox.hpp"
33#include "../numerics/scalar/scalar_edge_flux.hpp"
34#include "../variables/CScalarVariable.hpp"
35#include "../variables/CEulerVariable.hpp"
36#include "../variables/CFlowVariable.hpp"
37#include "../variables/CGhostFlowVariable.hpp"
38#include "../variables/CIncEulerVariable.hpp"
39#include "../variables/CPrimitiveIndices.hpp"
58template <
class VariableType>
62 static constexpr size_t MAXNVAR = VariableType::MAXNVAR;
129 template <
class SolverSpecificNumericsFunc>
133 if (solver_container[
FLOW_SOL] ==
nullptr)
return;
139 for (
auto iMarker = 0u; iMarker < config->
GetnMarker_All(); iMarker++) {
144 for (
auto iVertex = 0u; iVertex < geometry->
nVertex[iMarker]; iVertex++) {
146 const auto iPoint = geometry->
vertex[iMarker][iVertex]->
GetNode();
154 for (
auto iDim = 0u; iDim <
nDim; iDim++)
163 for (
auto jVertex = 0; jVertex < nDonorVertex; jVertex++) {
165 for (
auto iVar = 0u; iVar <
nPrimVar; iVar++)
178 for (
auto iVar = 0u; iVar <
nVar; ++iVar)
200 for (
auto iVar = 0u; iVar <
nVar; iVar++) {
201 LinSysRes(iPoint,iVar) += weight*residual[iVar];
202 for (
auto jVar = 0u; jVar <
nVar; jVar++)
226 SolverSpecificNumerics(iPoint);
284 template <
class Scheme>
315 template <
class Scheme>
331 template <
class Scheme,
class GhostFunc>
334 const GhostFunc& fillGhostExtras);
342 for (
auto iDim = 0u; iDim <
nDim; ++iDim)
355 unsigned long jPoint) {
359 for (
auto iDim = 0u; iDim <
nDim; ++iDim)
ghostCoord(iVertex, iDim) = Coord_Reflected[iDim];
361 auto ghostGrad =
ghostNodes->GetGradient(iVertex);
362 const auto interiorGrad =
nodes->GetGradient(iPoint);
363 for (
auto iVar = 0u; iVar <
nVar; ++iVar)
364 for (
auto iDim = 0u; iDim <
nDim; ++iDim) ghostGrad(iVar, iDim) = interiorGrad(iVar, iDim);
379 template <
template <
class,
class,
int,
size_t>
class Model,
size_t... nVarList,
class F>
382 DispatchDim<Model, CIncEulerVariable::CIndices<unsigned short>, nVarList...>(std::forward<F>(f));
384 DispatchDim<Model, CEulerVariable::CIndices<unsigned short>, nVarList...>(std::forward<F>(f));
389 template <
template <
class,
class,
int,
size_t>
class Model,
class Indices,
size_t... nVarList,
class F>
390 void DispatchDim(F&& f) {
392 DispatchEqnCount<Model, Indices, 2, nVarList...>(std::forward<F>(f));
394 DispatchEqnCount<Model, Indices, 3, nVarList...>(std::forward<F>(f));
399 template <
template <
class,
class,
int,
size_t>
class Model,
class Indices,
int nDim_,
class F>
400 void DispatchEqnCount(F&&) {
404 template <
template <
class,
class,
int,
size_t>
class Model,
class Indices,
int nDim_,
size_t nVar_,
405 size_t... others,
class F>
406 void DispatchEqnCount(F&& f) {
408 f(
CTypeTag<Model<su2double, Indices, nDim_, nVar_>>{});
410 DispatchEqnCount<Model, Indices, nDim_, others...>(std::forward<F>(f));
419 virtual void ComputeUnderRelaxationFactor(
CSolver** solver_container,
const CConfig* config) {}
447 CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker)
override;
459 CNumerics* visc_numerics,
CConfig* config,
unsigned short val_marker)
override {
473 CNumerics* visc_numerics,
CConfig* config,
unsigned short val_marker)
final {
490 unsigned short val_marker)
final;
497 CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker)
final {
498 BC_Inlet(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker);
505 CNumerics *visc_numerics,
CConfig *config,
unsigned short val_marker)
final {
506 BC_Outlet(geometry, solver_container, conv_numerics, visc_numerics, config, val_marker);
529 BC_Fluid_Interface_impl([](
unsigned long){}, geometry, solver_container, conv_numerics, visc_numerics, config);
538 for (
unsigned long iPoint = 0; iPoint <
nPoint; iPoint++) {
553 unsigned short iMesh,
unsigned long Iteration)
override;
597 unsigned short iMesh,
unsigned short RunTime_EqSystem)
override;
608 bool val_update_geo)
override = 0;
623 unsigned long val_vertex,
624 unsigned short val_state,
625 unsigned long donor_index)
const final {
626 return SlidingState[val_marker][val_vertex][val_state][donor_index];
637 for( iVar = 0; iVar <
nVar+1; iVar++){
638 if(
SlidingState[val_marker][val_vertex][iVar] !=
nullptr )
642 for( iVar = 0; iVar <
nVar+1; iVar++)
655 unsigned long val_vertex,
656 unsigned short val_state,
657 unsigned long donor_index,
659 SlidingState[val_marker][val_vertex][val_state][donor_index] = component;
669 unsigned long val_vertex,
Headers of the CSolver class which is inherited by all of the other solvers.
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
static void Error(const std::string &ErrorMsg, const std::string &FunctionName)
Definition mpi_structure.cpp:131
Main class for defining the problem; basically this class reads the configuration file,...
Definition CConfig.hpp:64
unsigned short GetnMarker_All(void) const
Get the total number of boundary markers of the local process including send/receive domains.
Definition CConfig.hpp:3183
unsigned short GetMarker_All_KindBC(unsigned short val_marker) const
Get the kind of boundary for each marker.
Definition CConfig.hpp:3556
ENUM_REGIME GetKind_Regime(void) const
Governing equations of the flow (it can be different from the run time equation).
Definition CConfig.hpp:4026
Parent class for defining the geometry of the problem (complete geometry, multigrid agglomerated geom...
Definition CGeometry.hpp:75
CPoint * nodes
Node vector (dual grid information).
Definition CGeometry.hpp:253
CVertex *** vertex
Boundary Vertex vector (dual grid information).
Definition CGeometry.hpp:255
unsigned long * nVertex
Number of vertex for each marker.
Definition CGeometry.hpp:258
Class for defining the numerical methods.
Definition CNumerics.hpp:48
void SetPrimitive(const su2double *val_v_i, const su2double *val_v_j)
Set the value of the primitive variables.
Definition CNumerics.hpp:301
bool GetBoundedScalar() const
Obtain information on bounded scalar problem.
Definition CNumerics.hpp:1864
void SetGridVel(const su2double *val_gridvel_i, const su2double *val_gridvel_j)
Set the velocity of the computational grid.
Definition CNumerics.hpp:987
void SetCoord(const su2double *val_coord_i, const su2double *val_coord_j)
Set coordinates of the points.
Definition CNumerics.hpp:977
void SetScalarVar(const su2double *val_scalarvar_i, const su2double *val_scalarvar_j)
Set the value of the scalar variable.
Definition CNumerics.hpp:370
void SetScalarVarGradient(CMatrixView< const su2double > val_scalarvar_grad_i, CMatrixView< const su2double > val_scalarvar_grad_j)
Set the gradient of the scalar variables.
Definition CNumerics.hpp:390
void SetNormal(const su2double *val_normal)
Set the value of the normal vector to the face between two points.
Definition CNumerics.hpp:1086
virtual void ComputeResidual(su2double *val_residual, CConfig *config)
Compute the numerical residual.
Definition CNumerics.hpp:1543
void SetMassFlux(const su2double val_MassFlux)
SetMassFlux.
Definition CNumerics.hpp:1858
bool GetDomain(unsigned long iPoint) const
For parallel computation, its indicates if a point must be computed or not.
Definition CPoint.hpp:423
su2double GetCoord(unsigned long iPoint, unsigned long iDim) const
Get the coordinates dor the control volume.
Definition CPoint.hpp:158
su2double * GetGridVel(unsigned long iPoint)
Get the value of the grid velocity at the point.
Definition CPoint.hpp:816
Main class for defining a scalar solver.
Definition CScalarSolver.hpp:59
~CScalarSolver() override
Destructor of the class.
Definition CScalarSolver.inl:109
@ OMP_MAX_SIZE
Definition CScalarSolver.hpp:65
void SumEdgeFluxes(const CGeometry *geometry)
Sum the edge fluxes for each cell to populate the residual vector, only used on coarse grids.
Definition CScalarSolver.inl:154
const CPrimitiveIndices< unsigned short > prim_idx
Indices of the primitive flow variables.
Definition CScalarSolver.hpp:78
void BC_Supersonic_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final
Impose the supersonic outlet boundary condition (same as outlet, see BC_Outlet).
Definition CScalarSolver.hpp:504
void SetGhostPrimitives(unsigned long iVertex, const su2double *V)
Write the four flow primitives the flux kernels read into one row of ghostFlowNodes.
Definition CScalarSolver.hpp:293
vector< vector< int > > SlidingStateNodes
Definition CScalarSolver.hpp:81
VariableType * nodes
The highest level in the variable hierarchy this solver can safely use.
Definition CScalarSolver.hpp:112
void SetResidual_DualTime(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep, unsigned short iMesh, unsigned short RunTime_EqSystem) override
Set the total residual adding the term that comes from the Dual Time-Stepping Strategy.
Definition CScalarSolver.inl:631
void SetnSlidingStates(unsigned short val_marker, unsigned long val_vertex, int value) final
Set the number of outer state for fluid interface nodes.
Definition CScalarSolver.hpp:668
void BoundaryFluxResidual(const CGeometry *geometry, CSolver **solver_container, const CConfig *config, const ScalarFluxOptions &opt, unsigned short val_marker)
Generic boundary flux pass, run after a boundary's fill pass has written the ghost row,...
Definition CScalarSolver.inl:259
void SetSlidingStateStructure(unsigned short val_marker, unsigned long val_vertex) final
Allocates the final pointer of SlidingState depending on how many donor vertex donate to it....
Definition CScalarSolver.hpp:634
su2activematrix ghostNormal
Outward normals, sign flipped from the vertex normals.
Definition CScalarSolver.hpp:105
array< DummyGridColor<>, 1 > EdgeColoring
Definition CScalarSolver.hpp:89
CSysVector< su2double > EdgeFluxes
Flux across each edge.
Definition CScalarSolver.hpp:95
void SetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, unsigned long donor_index, su2double component) final
Set the outer state for fluid interface nodes.
Definition CScalarSolver.hpp:654
void BC_Sym_Plane(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) override
Impose the Symmetry Plane boundary condition.
Definition CScalarSolver.hpp:458
void SetGhostGeometry(const CGeometry *geometry, unsigned short val_marker, unsigned long iVertex)
Write the outward normal of one vertex into the ghost row and mark the vertex as contributing a flux.
Definition CScalarSolver.hpp:341
@ MAXNDIM
Definition CScalarSolver.hpp:61
su2double Solution_Inf[MAXNVAR]
Far-field solution.
Definition CScalarSolver.hpp:73
unique_ptr< CGhostFlowVariable > ghostFlowNodes
Sized from the flow solver, see the constructor.
Definition CScalarSolver.hpp:104
void EdgeFluxResidual(const CGeometry *geometry, CSolver **solver_container, const CConfig *config, const ScalarFluxOptions &opt)
Generic interior edge loop for a scalar model expressed through the CUpwScalarBase CRTP chain (numeri...
Definition CScalarSolver.inl:176
void BC_Euler_Wall(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final
Impose via the residual the Euler wall boundary condition.
Definition CScalarSolver.hpp:472
void PushSolutionBackInTime(unsigned long TimeIter, bool restart, CSolver ***solver_container, CGeometry **geometry, CConfig *config)
Move solution to previous time levels (for restarts).
Definition CScalarSolver.inl:870
void BC_Periodic(CGeometry *geometry, CSolver **solver_container, CNumerics *numerics, CConfig *config) final
Impose a periodic boundary condition by summing contributions from the complete control volume.
Definition CScalarSolver.inl:389
su2double upperlimit[MAXNVAR]
contains upper limits for scalar variables.
Definition CScalarSolver.hpp:71
void BC_Riemann(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final
Impose the boundary condition using characteristic recostruction.
Definition CScalarSolver.inl:372
void PrepareImplicitIteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) final
Prepare an implicit iteration.
Definition CScalarSolver.inl:481
const bool Conservative
Transported Variable is conservative. Solution has to be multiplied with rho.
Definition CScalarSolver.hpp:75
void BC_Fluid_Interface_impl(const SolverSpecificNumericsFunc &SolverSpecificNumerics, CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config)
Generic implementation of the fluid interface boundary condition for scalar solvers.
Definition CScalarSolver.hpp:130
void SetFreeStream_Solution(const CConfig *config) final
Set the solution using the Freestream values.
Definition CScalarSolver.hpp:536
su2double BoundedScalarBCFlux(unsigned long iPoint, bool implicit, const su2double &density, const su2double *velocity, const su2double *normal)
Applies a convective flux correction to negate the effects of flow divergence at a BC node.
Definition CScalarSolver.hpp:249
static constexpr size_t MAXNVAR
Max number of variables, for static arrays.
Definition CScalarSolver.hpp:62
su2double lowerlimit[MAXNVAR]
contains lower limits for scalar variables.
Definition CScalarSolver.hpp:70
const bool BoundedScalar
Whether the derived solver uses the bounded-scalar convective scheme.
Definition CScalarSolver.hpp:76
CSysVector< su2double > EdgeFluxesDiff
Flux difference between ij and ji for non-conservative discretisation.
Definition CScalarSolver.hpp:96
void CompleteImplicitIteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) final
Complete an implicit iteration.
Definition CScalarSolver.inl:525
su2vector< uint8_t > ghostSkip
Whether a vertex contributes no flux, set by the fill pass.
Definition CScalarSolver.hpp:107
void CommonPreprocessing(CGeometry *geometry, const CConfig *config, const bool Output)
Gradient and Limiter computation.
Definition CScalarSolver.inl:114
void ExplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) final
Update the solution using the explicit Euler scheme.
Definition CScalarSolver.inl:601
@ OMP_MIN_SIZE
Definition CScalarSolver.hpp:66
int GetnSlidingStates(unsigned short val_marker, unsigned long val_vertex) const final
Get the number of outer state for fluid interface nodes.
Definition CScalarSolver.hpp:677
void SetGhostDiffusionState(const CGeometry *geometry, unsigned long iVertex, unsigned long iPoint, unsigned long jPoint)
Write what the diffusion term of a boundary reads beyond the ghost solution: the coordinate of the in...
Definition CScalarSolver.hpp:354
void FluidInterfaceFluxResidual(const CGeometry *geometry, CSolver **solver_container, const CConfig *config, const ScalarFluxOptions &optConv, const ScalarFluxOptions &optVisc, const GhostFunc &fillGhostExtras)
Generic fluid interface (sliding mesh) flux pass, shared by every model. The convective term is a per...
Definition CScalarSolver.inl:300
void ImplicitEuler_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config) override
Update the solution using an implicit solver.
Definition CScalarSolver.inl:574
su2activematrix ghostCoord
Reflected coordinates, read by the diffusion sites.
Definition CScalarSolver.hpp:106
su2double GetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, unsigned long donor_index) const final
Get the outer state for fluid interface nodes.
Definition CScalarSolver.hpp:622
void BC_Fluid_Interface(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config) override
Impose the fluid interface boundary condition using transfer data.
Definition CScalarSolver.hpp:526
void DispatchScheme(const CConfig *config, F &&f)
Resolve the compile-time parameters of a scalar flux kernel, the flow indices, the dimension and the ...
Definition CScalarSolver.hpp:380
unique_ptr< VariableType > ghostNodes
Allocated by the derived solver, whose VariableType constructor it alone knows how to call.
Definition CScalarSolver.hpp:103
static constexpr bool ReducerStrategy
Definition CScalarSolver.hpp:91
unsigned long omp_chunk_size
Chunk size used in light point loops.
Definition CScalarSolver.hpp:68
vector< su2matrix< su2double * > > SlidingState
Definition CScalarSolver.hpp:80
void BC_Far_Field(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) override
Impose the Far Field boundary condition.
Definition CScalarSolver.inl:405
bool GetHasHybridParallel() const override
Scalar solvers support OpenMP+MPI.
Definition CScalarSolver.hpp:613
void BC_Supersonic_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) final
Impose the supersonic inlet boundary condition (same as inlet, see BC_Inlet).
Definition CScalarSolver.hpp:496
void LoadRestart(CGeometry **geometry, CSolver ***solver, CConfig *config, int val_iter, bool val_update_geo) override=0
Load a solution from a restart file.
CVariable * GetBaseClassPointerToNodes() final
Return nodes to allow CSolver::base_nodes to be set.
Definition CScalarSolver.hpp:117
void SetTime_Step(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iMesh, unsigned long Iteration) override
This base implementation simply copies the time step of the flow solver.
Definition CScalarSolver.inl:466
@ MAXNVARFLOW
Definition CScalarSolver.hpp:63
Definition CSolver.hpp:71
CSysMatrix< su2mixedfloat > Jacobian
Complete sparse Jacobian structure for implicit computations.
Definition CSolver.hpp:201
virtual su2double GetSlidingState(unsigned short val_marker, unsigned long val_vertex, unsigned short val_state, unsigned long donor_index) const
Get the outer state for fluid interface nodes.
Definition CSolver.hpp:1365
unsigned short nDim
Number of dimensions of the problem.
Definition CSolver.hpp:90
su2double ** Jacobian_i
Auxiliary matrices for storing point to point Jacobians at point i.
Definition CSolver.hpp:128
unsigned long nPoint
Number of points of the computational grid.
Definition CSolver.hpp:91
unsigned short nVar
Number of variables of the problem.
Definition CSolver.hpp:85
CSysVector< su2double > LinSysRes
vector to store iterative residual of implicit linear system.
Definition CSolver.hpp:200
unsigned short GetnPrimVar(void) const
Get the number of variables of the problem.
Definition CSolver.hpp:421
virtual void BC_Inlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker)
A virtual member.
Definition CSolver.hpp:1163
unsigned short nPrimVar
Number of primitive variables of the problem.
Definition CSolver.hpp:86
virtual void BC_Outlet(CGeometry *geometry, CSolver **solver_container, CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker)
A virtual member.
Definition CSolver.hpp:1258
bool dynamic_grid
Flag that determines whether the grid is dynamic (moving or deforming + grid velocities).
Definition CSolver.hpp:153
CVariable * GetNodes()
Allow outside access to the nodes of the solver, containing conservatives, primitives,...
Definition CSolver.hpp:229
void SubtractBlock2Diag(unsigned long block_i, const OtherType &val_block)
Short-hand to AddBlock2Diag with alpha = -1, i.e. subtracts from the current diagonal.
Definition CSysMatrix.hpp:1226
const ScalarType * GetBlock(unsigned long block_i, unsigned long block_j) const
Get a pointer to the start of block "ij".
Definition CSysMatrix.hpp:760
void AddVal2Diag(unsigned long block_i, OtherType val_matrix)
Adds the specified value to the diagonal of the (i, i) subblock of the matrix-by-blocks structure.
Definition CSysMatrix.hpp:1237
Class for holding and manipulating vectors needed by linear solvers.
Definition CSysVector.hpp:195
void SubtractBlock(unsigned long iPoint, const VectorType &block)
Subtract "block" from the vector, see AddBlock.
Definition CSysVector.hpp:639
void AddBlock(unsigned long iPoint, const VectorType &block, ScalarType alpha=1)
Add "block" to the vector, see SetBlock.
Definition CSysVector.hpp:631
Main class for defining the variables.
Definition CVariable.hpp:50
virtual const MatrixType & GetPrimitive() const
Get the primitive variables for all points.
Definition CVariable.hpp:1319
virtual su2double GetDensity(unsigned long iPoint) const
A virtual member.
Definition CVariable.hpp:1009
void GetNormal(su2double *val_normal) const override
Copy the the normal vector of a face.
Definition CVertex.hpp:94
unsigned long GetNode() const
Get the node of the vertex.
Definition CVertex.hpp:70
unsigned long GetNormal_Neighbor() const
Get the value of the closest neighbor.
Definition CVertex.hpp:322
Scalar_t * data() noexcept
Definition C2DContainer.hpp:222
passivedouble su2double
Definition code_config.hpp:181
#define CURRENT_FUNCTION
Definition mpi_structure.hpp:59
passivedouble GetValue(const su2double &data)
Get the (primitive) value of the datatype (needs to be specialized for active types).
Definition datatype_structure.hpp:113
constexpr size_t Dynamic
Equation count of a model whose value is only known at runtime.
Definition util.hpp:152
#define END_SU2_OMP_FOR
Definition omp_structure.hpp:158
#define SU2_OMP_FOR_STAT(CHUNK)
Definition omp_structure.hpp:151
@ INCOMPRESSIBLE
Definition of incompressible solver.
@ V
Menter k-w SST model with vorticity production terms.
@ FLOW_SOL
Position of the mean flow solution in the solver container array.
Definition option_structure.hpp:577
@ FLUID_INTERFACE
Domain interface definition.
Definition option_structure.hpp:1841
LINEAR_SOLVER_MODE
Type of operation for the linear system solver, changes the source of solver options.
Definition option_structure.hpp:3027
@ STANDARD
Operate in standard mode.
Abstract wrapper for the CIndices classes of CEulerVariable, CIncEulerVariable, etc....
Definition CPrimitiveIndices.hpp:45
IndexType Density() const
Definition CPrimitiveIndices.hpp:79
IndexType EddyViscosity() const
Definition CPrimitiveIndices.hpp:83
IndexType LaminarViscosity() const
Definition CPrimitiveIndices.hpp:82
IndexType ThermalConductivity() const
Definition CPrimitiveIndices.hpp:84
IndexType CpTotal() const
Definition CPrimitiveIndices.hpp:85
IndexType Velocity() const
Definition CPrimitiveIndices.hpp:77
Carries a type through a value, so a runtime branch can hand a compile-time type to a generic lambda ...
Definition CScalarSolver.hpp:49
T type
Definition CScalarSolver.hpp:50
Loop invariant flags for a scalar edge flux, built once outside the edge loop so the compiler can uns...
Definition scalar_edge_flux.hpp:55