NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
upwind.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023 NeoN authors
3
4#pragma once
5
11
12#include <Kokkos_Core.hpp>
13
14#include <functional>
15
17{
18
19/* @brief computional kernel to perform an upwind interpolation
20** from a source volumeVector to a surface field. It performs an interpolation
21** of the form
22**
23** d_f = w_f * s_O + ( 1 - w_f ) * s_N where w_1 is either 0,1 depending on the
24** direction of the flux
25**
26**@param src the input field
27**@param weights weights for the interpolation
28**@param dst the target field
29*/
30template<typename ValueType>
32 const VolumeField<ValueType>& src,
33 const SurfaceField<scalar>& flux,
34 const SurfaceField<scalar>& weights,
36);
37
38template<typename ValueType>
39class Upwind : public SurfaceInterpolationFactory<ValueType>::template Register<Upwind<ValueType>>
40{
41
43
44public:
45
46 Upwind(const Executor& exec, const UnstructuredMesh& mesh, [[maybe_unused]] Input input)
47 : Base(exec, mesh), geometryScheme_(GeometryScheme::readOrCreate(mesh)) {};
48
49 static std::string name() { return "upwind"; }
50
51 static std::string doc() { return "upwind interpolation"; }
52
53 static std::string schema() { return "none"; }
54
56 [[maybe_unused]] const VolumeField<ValueType>& src,
57 [[maybe_unused]] SurfaceField<ValueType>& dst
58 ) const override
59 {
60 NF_ERROR_EXIT("limited scheme require a faceFlux");
61 }
62
64 const SurfaceField<scalar>& flux,
65 const VolumeField<ValueType>& src,
67 ) const override
68 {
69 computeUpwindInterpolation(src, flux, geometryScheme_->weights(), dst);
70 }
71
72 // src weight
74 {
75 NF_ERROR_EXIT("limited scheme require a faceFlux");
76 }
77
78 // flux, src, weight
80 const override
81 {
82 // TODO should that be implemented?
83 // geometryScheme_->weights(flux, src, weight);
84 }
85
86 std::unique_ptr<SurfaceInterpolationFactory<ValueType>> clone() const override
87 {
88 return std::make_unique<Upwind>(*this);
89 }
90
91private:
92
93 const std::shared_ptr<GeometryScheme> geometryScheme_;
94};
95
96} // namespace NeoN
97
98
99namespace NeoN
100{
101
102namespace fvcc = finiteVolume::cellCentred;
103
104template class fvcc::Upwind<scalar>;
105template class fvcc::Upwind<Vec3>;
106
107}
Represents an unstructured mesh in NeoN.
Represents a surface field in a finite volume method.
Upwind(const Executor &exec, const UnstructuredMesh &mesh, Input input)
Definition upwind.hpp:46
void weight(const SurfaceField< scalar > &, const VolumeField< ValueType > &, SurfaceField< scalar > &) const override
Definition upwind.hpp:79
void weight(const VolumeField< ValueType > &, SurfaceField< scalar > &) const override
Definition upwind.hpp:73
std::unique_ptr< SurfaceInterpolationFactory< ValueType > > clone() const override
Definition upwind.hpp:86
void interpolate(const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
Definition upwind.hpp:55
void interpolate(const SurfaceField< scalar > &flux, const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
Definition upwind.hpp:63
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.
Definition error.hpp:108
void computeUpwindInterpolation(const VolumeField< ValueType > &src, const SurfaceField< scalar > &flux, const SurfaceField< scalar > &weights, SurfaceField< ValueType > &dst)
std::variant< Dictionary, TokenList > Input
Definition input.hpp:13
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16