NeoN
A framework for CFD software
Loading...
Searching...
No Matches
gaussGreenDdtDivLaplacian.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
13
15{
16
17/* @brief
18 *
19 */
20template<typename ValueType>
21class GaussGreenDdtDivLaplacian : public dsl::OperatorMixin<VolumeField<ValueType>>
22{
23
24public:
25
26 using VectorValueType = ValueType;
27
29 : dsl::OperatorMixin<VolumeField<ValueType>>(
30 exec,
31 dsl::Coeff(1.0),
32 divConfig.get<NeoN::detail::RefHolder<VolumeField<ValueType>>>("field").c,
33 dsl::Operator::Type::Implicit
34 ),
35 coeffA_(divConfig.get<NeoN::detail::RefHolder<dsl::Coeff>>("coeff").c),
36 coeffB_(lapConfig.get<NeoN::detail::RefHolder<dsl::Coeff>>("coeff").c),
37 gamma_(lapConfig.get<NeoN::detail::RefHolder<SurfaceField<scalar>>>("gamma").c),
38 flux_(divConfig.get<NeoN::detail::RefHolder<SurfaceField<scalar>>>("flux").c)
39 {}
40
41
42 void explicitOperation(Vector<ValueType>& source, scalar t, scalar dt) const {};
43
45
46 void read(const Input& input)
47 {
48 const UnstructuredMesh& mesh = this->field_.mesh();
49 TokenList laplTokens;
50 TokenList divTokens;
51 if (std::holds_alternative<Dictionary>(input))
52 {
53 auto dict = std::get<Dictionary>(input);
54 std::string lapSchemeName = "laplacian(" + gamma_.name + "," + this->field_.name + ")";
55 std::string divSchemeName = "div(" + flux_.name + "," + this->getVector().name + ")";
56 laplTokens = dict.subDict("laplacianSchemes").get<NeoN::TokenList>(lapSchemeName);
57 divTokens = dict.subDict("divSchemes").get<NeoN::TokenList>(divSchemeName);
58 }
59 else
60 {
61 NF_ERROR_EXIT("only dictionary input supported");
62 }
63 laplTokens.remove(0);
64 divTokens.remove(0);
65 // lapSurfaceInterpolation_ =
66 // std::make_shared<SurfaceInterpolation<ValueType>>(this->exec(), mesh,
67 // laplTokens);
68 divSurfaceInterpolation_ =
69 std::make_shared<SurfaceInterpolation<ValueType>>(this->field_.exec(), mesh, divTokens);
70 laplTokens.remove(0);
71 faceNormalGradient_ =
72 std::make_shared<FaceNormalGradient<ValueType>>(this->field_.exec(), mesh, laplTokens);
73 }
74
75 std::string getName() const { return "FusedDivLapOperator"; }
76
77 Dictionary getConfig() const { return {}; }
78
79private:
80
81 // SurfaceInterpolation<ValueType> surfaceInterpolation_;
82
83 dsl::Coeff coeffA_; // div coeff
84 dsl::Coeff coeffB_; // lap coeff
85
86 const SurfaceField<scalar>& gamma_;
87 const SurfaceField<scalar>& flux_;
88
89 std::shared_ptr<SurfaceInterpolation<ValueType>> divSurfaceInterpolation_;
90 // std::shared_ptr<SurfaceInterpolation<scalar>> lapSurfaceInterpolation_;
91 std::shared_ptr<FaceNormalGradient<ValueType>> faceNormalGradient_;
92};
93
94extern template class GaussGreenDdtDivLaplacian<scalar>;
95extern template class GaussGreenDdtDivLaplacian<Vec3>;
96
97} // namespace NeoN
A class representing a dictionary that stores key-value pairs.
A class representing a list of tokens.
Definition tokenList.hpp:31
ReturnType & get(const size_t &idx)
Retrieves the value associated with the given index, casting it to the specified type.
void remove(size_t index)
Removes a value from the token list based on the specified index.
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:27
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:24
const VolumeField< ValueType > & field_
Definition operator.hpp:69
OperatorMixin(const Executor exec, const Coeff &coeffs, const VolumeField< ValueType > &field, Operator::Type type)
Definition operator.hpp:42
const VolumeField< ValueType > & getVector() const
Definition operator.hpp:58
virtual const Executor & exec() const final
Definition operator.hpp:52
GaussGreenDdtDivLaplacian(const Executor &exec, Dictionary divConfig, Dictionary lapConfig)
void implicitOperation(la::LinearSystem< ValueType > &ls, scalar t, scalar dt) const
void explicitOperation(Vector< ValueType > &source, scalar t, scalar dt) const
Represents a surface field in a finite volume method.
Represents a volume field in a finite volume method.
A class representing a linear system of equations.
#define NF_ERROR_EXIT(message)
Macro for printing an error message and aborting the program.
Definition error.hpp:90
Integer types used throughout NeoN.
Definition array.hpp:18
std::variant< Dictionary, TokenList > Input
Definition input.hpp:15
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:20
float scalar
Definition scalar.hpp:17