NeoN
A framework for CFD software
Loading...
Searching...
No Matches
linear.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2025 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
12
13#include <Kokkos_Core.hpp>
14
15#include <functional>
16
17
19{
20
21/* @brief computional kernel to perform a linear interpolation
22** from a source volumeVector to a surface field. It performs an interpolation
23** of the form
24**
25** d_f = w_f * s_O + ( 1 - w_f ) * s_N
26**
27**@param src the input field
28**@param weights weights for the interpolation
29**@param dst the target field
30*/
31template<typename ValueType>
33 const VolumeField<ValueType>& src,
34 const SurfaceField<scalar>& weights,
36);
37
38template<typename ValueType>
39class Linear : public SurfaceInterpolationFactory<ValueType>::template Register<Linear<ValueType>>
40{
42
43public:
44
45 Linear(const Executor& exec, const UnstructuredMesh& mesh, [[maybe_unused]] Input input)
46 : Base(exec, mesh), geometryScheme_(GeometryScheme::readOrCreate(mesh)) {};
47
48 Linear(const Executor& exec, const UnstructuredMesh& mesh)
49 : Base(exec, mesh), geometryScheme_(GeometryScheme::readOrCreate(mesh)) {};
50
51
52 static std::string name() { return "linear"; }
53
54 static std::string doc() { return "linear interpolation"; }
55
56 static std::string schema() { return "none"; }
57
58 void interpolate(const VolumeField<ValueType>& src, SurfaceField<ValueType>& dst) const override
59 {
60 computeLinearInterpolation(src, geometryScheme_->weights(), dst);
61 }
62
65 ) const override
66 {
67 interpolate(src, dst);
68 }
69
71 {
72 const SurfaceField<scalar>& linearWeight = geometryScheme_->weights();
73 weight.internalVector() = linearWeight.internalVector();
74 weight.boundaryData() = linearWeight.boundaryData();
75 }
76
77 void weight(
79 ) const override
80 {
81 const SurfaceField<scalar>& linearWeight = geometryScheme_->weights();
82 weight.internalVector() = linearWeight.internalVector();
83 weight.boundaryData() = linearWeight.boundaryData();
84 }
85
86
87 std::unique_ptr<SurfaceInterpolationFactory<ValueType>> clone() const override
88 {
89 return std::make_unique<Linear>(*this);
90 }
91
92private:
93
94 const std::shared_ptr<GeometryScheme> geometryScheme_;
95};
96
97} // namespace NeoN
98
99namespace NeoN
100{
101
102namespace fvcc = finiteVolume::cellCentred;
103
106
107template class fvcc::Linear<scalar>;
108template class fvcc::Linear<Vec3>;
109
110}
Represents an unstructured mesh in NeoN.
const BoundaryData< ValueType > & boundaryData() const
Returns a const reference to the boundary field.
Definition domain.hpp:101
const Vector< ValueType > & internalVector() const
Returns a const reference to the internal field.
Definition domain.hpp:80
std::unique_ptr< SurfaceInterpolationFactory< ValueType > > clone() const override
Definition linear.hpp:87
Linear(const Executor &exec, const UnstructuredMesh &mesh)
Definition linear.hpp:48
void weight(const SurfaceField< scalar > &, const VolumeField< ValueType > &, SurfaceField< scalar > &weight) const override
Definition linear.hpp:77
Linear(const Executor &exec, const UnstructuredMesh &mesh, Input input)
Definition linear.hpp:45
void interpolate(const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
Definition linear.hpp:58
void weight(const VolumeField< ValueType > &, SurfaceField< scalar > &weight) const override
Definition linear.hpp:70
void interpolate(const SurfaceField< scalar > &, const VolumeField< ValueType > &src, SurfaceField< ValueType > &dst) const override
Definition linear.hpp:63
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.
void computeLinearInterpolation(const VolumeField< ValueType > &src, const SurfaceField< scalar > &weights, SurfaceField< ValueType > &dst)
Definition array.hpp:20
std::variant< Dictionary, TokenList > Input
Definition input.hpp:15
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:18