15#include <Kokkos_Core.hpp>
29template<
typename ValueType>
67template<
typename ValueType>
74 const bool cellLimitedGradient =
false,
86template<
typename ValueType>
93 const bool cellLimitedGradient =
false,
101template<
typename ValueType,
bool CellLimited = false>
104 LinearUpwind<ValueType, CellLimited>>
112 : Base(exec, mesh), geometryScheme_(
GeometryScheme::readOrCreate(mesh)),
113 gradSchemeName_(readGradSchemeName(input)),
114 cellLimitedGradient_(readCellLimited(gradSchemeName_))
120 geometryScheme_->ensureFaceDeltas();
123 static std::string
name() {
return CellLimited ?
"linearUpwindV" :
"linearUpwind"; }
127 return CellLimited ?
"linearUpwindV interpolation (directionally limited correction)"
128 :
"linearUpwind interpolation";
131 static std::string
schema() {
return "none"; }
138 NF_ERROR_EXIT(
"linearUpwind interpolation scheme requires a faceFlux");
150 geometryScheme_->faceDeltaOwner(),
151 geometryScheme_->faceDeltaNeighbour(),
153 cellLimitedGradient_,
154 CellLimited ? &geometryScheme_->weights() :
nullptr
162 NF_ERROR_EXIT(
"linearUpwind interpolation scheme requires a faceFlux");
186 geometryScheme_->faceDeltaOwner(),
187 geometryScheme_->faceDeltaNeighbour(),
189 cellLimitedGradient_,
190 CellLimited ? &geometryScheme_->weights() :
nullptr
194 std::unique_ptr<SurfaceInterpolationFactory<ValueType>>
clone()
const override
196 return std::make_unique<LinearUpwind>(*
this);
211 static std::string readGradSchemeName(
Input& input)
213 if (std::holds_alternative<NeoN::TokenList>(input))
215 auto& tokens = std::get<NeoN::TokenList>(input);
216 if (tokens.peekIs<std::string>())
218 return tokens.next<std::string>();
226 static bool readCellLimited(
const std::string& gradSchemeName)
228 return gradSchemeName ==
"cellLimited";
231 const std::shared_ptr<GeometryScheme> geometryScheme_;
232 std::string gradSchemeName_;
233 bool cellLimitedGradient_;
A class for the representation of a 3x3 tensor.
Represents an unstructured mesh in NeoN.
A class for the representation of a 3D Vec3.
static std::string name()
LinearUpwind(const Executor &exec, const UnstructuredMesh &mesh, Input input)
void correction(const SurfaceField< scalar > &faceFlux, const VolumeField< ValueType > &src, SurfaceField< ValueType > &corr) const override
void interpolate(const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
void interpolate(const SurfaceField< scalar > &flux, const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
void weight(const VolumeField< ValueType > &, SurfaceField< scalar > &) const override
bool corrected() const override
static std::string schema()
std::unique_ptr< SurfaceInterpolationFactory< ValueType > > clone() const override
void weight(const SurfaceField< scalar > &faceFlux, const VolumeField< ValueType > &src, SurfaceField< scalar > &weights) const override
Represents a surface field in a finite volume method.
Represents a volume field in a finite volume method.
A template class for registering derived classes with a base class.
#define NF_ERROR_EXIT(message)
Macro for printing an error message and aborting the program.
void computeUpwindInterpolationWeights(const SurfaceField< scalar > &flux, const VolumeField< ValueType > &src, SurfaceField< scalar > &weights)
void computeLinearUpwindCorrection(const VolumeField< ValueType > &src, const SurfaceField< scalar > &flux, const SurfaceField< Vec3 > &faceDeltaOwner, const SurfaceField< Vec3 > &faceDeltaNeighbour, SurfaceField< ValueType > &dst, const bool cellLimitedGradient=false, const SurfaceField< scalar > *limiterWeights=nullptr)
void computeLinearUpwindInterpolation(const VolumeField< ValueType > &src, const SurfaceField< scalar > &flux, const SurfaceField< Vec3 > &faceDeltaOwner, const SurfaceField< Vec3 > &faceDeltaNeighbour, SurfaceField< ValueType > &dst, const bool cellLimitedGradient=false, const SurfaceField< scalar > *limiterWeights=nullptr)
Integer types used throughout NeoN.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
std::variant< Dictionary, TokenList > Input