NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
gaussGreenLaplacian.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2024 NeoN authors
3
4#pragma once
5
13
15{
16
17template<typename ValueType>
23 const dsl::Coeff
24);
25
26template<typename ValueType>
29 const SurfaceField<scalar>& gamma,
31 const dsl::Coeff operatorScaling,
32 const SparsityPattern& sparsityPattern,
33 const FaceNormalGradient<ValueType>& faceNormalGradient
34);
35
36template<typename ValueType>
38 public LaplacianOperatorFactory<ValueType>::template Register<GaussGreenLaplacian<ValueType>>
39{
40 using Base =
42
43public:
44
45 static std::string name() { return "Gauss"; }
46
47 static std::string doc() { return "Gauss-Green Laplacian"; }
48
49 static std::string schema() { return "none"; }
50
51 GaussGreenLaplacian(const Executor& exec, const UnstructuredMesh& mesh, const Input& inputs)
52 : Base(exec, mesh), surfaceInterpolation_(exec, mesh, inputs),
53 faceNormalGradient_(exec, mesh, inputs),
54 sparsityPattern_(SparsityPattern::readOrCreate(mesh)) {};
55
56 virtual void laplacian(
58 const SurfaceField<scalar>& gamma,
60 const dsl::Coeff operatorScaling
61 ) override
62 {
63 computeLaplacianExp<ValueType>(
64 faceNormalGradient_, gamma, phi, lapPhi.internalVector(), operatorScaling
65 );
66 };
67
69 const SurfaceField<scalar>& gamma,
71 const dsl::Coeff operatorScaling
72 ) const override
73 {
74 std::string name = "laplacian(" + gamma.name + "," + phi.name + ")";
76 this->exec_,
77 name,
78 this->mesh_,
80 );
81 NeoN::fill(lapPhi.internalVector(), zero<ValueType>());
82 NeoN::fill(lapPhi.boundaryData().value(), zero<ValueType>());
83 computeLaplacianExp<ValueType>(
84 faceNormalGradient_, gamma, phi, lapPhi.internalVector(), operatorScaling
85 );
86 return lapPhi;
87 };
88
89 virtual void laplacian(
90 Vector<ValueType>& lapPhi,
91 const SurfaceField<scalar>& gamma,
93 const dsl::Coeff operatorScaling
94 ) override
95 {
96 computeLaplacianExp<ValueType>(faceNormalGradient_, gamma, phi, lapPhi, operatorScaling);
97 };
98
99 virtual void laplacian(
101 const SurfaceField<scalar>& gamma,
103 const dsl::Coeff operatorScaling
104 ) override
105 {
107 ls, gamma, phi, operatorScaling, *sparsityPattern_.get(), faceNormalGradient_
108 );
109 };
110
111 std::unique_ptr<LaplacianOperatorFactory<ValueType>> clone() const override
112 {
113 return std::make_unique<GaussGreenLaplacian<ValueType>>(*this);
114 };
115
116private:
117
118 SurfaceInterpolation<ValueType> surfaceInterpolation_;
119
120 FaceNormalGradient<ValueType> faceNormalGradient_;
121
122 const std::shared_ptr<SparsityPattern> sparsityPattern_;
123};
124
125// instantiate the template class
126template class GaussGreenLaplacian<scalar>;
127template class GaussGreenLaplacian<Vec3>;
128
129} // namespace NeoN
const Vector< T > & value() const
Get the view storing the computed values from the boundary condition.
Represents an unstructured mesh in NeoN.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:53
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:22
const BoundaryData< ValueType > & boundaryData() const
Returns a const reference to the boundary field.
Definition domain.hpp:100
const Vector< ValueType > & internalVector() const
Returns a const reference to the internal field.
Definition domain.hpp:79
GaussGreenLaplacian(const Executor &exec, const UnstructuredMesh &mesh, const Input &inputs)
virtual VolumeField< ValueType > laplacian(const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) const override
virtual void laplacian(la::LinearSystem< ValueType, localIdx > &ls, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) override
virtual void laplacian(VolumeField< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) override
virtual void laplacian(Vector< ValueType > &lapPhi, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling) override
std::unique_ptr< LaplacianOperatorFactory< ValueType > > clone() const override
Represents a surface field in a finite volume method.
Represents a volume boundary field for a cell-centered finite volume method.
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
A template class for registering derived classes with a base class.
void computeLaplacianExp(const FaceNormalGradient< ValueType > &, const SurfaceField< scalar > &, VolumeField< ValueType > &, Vector< ValueType > &, const dsl::Coeff)
std::vector< BoundaryType > createCalculatedBCs(const UnstructuredMesh &mesh)
Definition boundary.hpp:27
void computeLaplacianImpl(la::LinearSystem< ValueType, localIdx > &ls, const SurfaceField< scalar > &gamma, VolumeField< ValueType > &phi, const dsl::Coeff operatorScaling, const SparsityPattern &sparsityPattern, const FaceNormalGradient< ValueType > &faceNormalGradient)
std::variant< Dictionary, TokenList > Input
Definition input.hpp:13
void fill(Vector< ValueType > &a, const std::type_identity_t< ValueType > value, std::pair< localIdx, localIdx > range={0, 0})
Fill the field with a scalar value using a specific executor.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16