NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
operator.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023-2024 NeoN authors
3#pragma once
4
5#include "NeoN/dsl/coeff.hpp"
6
7namespace NeoN::dsl
8{
9
11{
12public:
13
14 enum class Type
15 {
18 };
19};
20
21
22/* @class OperatorMixin
23 * @brief A mixin class to simplify implementations of concrete operators
24 * in NeoNs dsl
25 *
26 * @ingroup dsl
27 */
28template<typename VectorType>
30{
31
32public:
33
34 OperatorMixin(const Executor exec, const Coeff& coeffs, VectorType& field, Operator::Type type)
35 : exec_(exec), coeffs_(coeffs), field_(field), type_(type) {};
36
37
38 Operator::Type getType() const { return type_; }
39
40 virtual ~OperatorMixin() = default;
41
42 virtual const Executor& exec() const final { return exec_; }
43
45
46 const Coeff& getCoefficient() const { return coeffs_; }
47
48 VectorType& getVector() { return field_; }
49
50 const VectorType& getVector() const { return field_; }
51
52 /* @brief Given an input this function reads required coeffs */
53 void build([[maybe_unused]] const Input& input) {}
54
55protected:
56
58
60
61 VectorType& field_;
62
64};
65
66} // namespace NeoN::dsl
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:22
const VectorType & getVector() const
Definition operator.hpp:50
Operator::Type type_
Definition operator.hpp:63
const Coeff & getCoefficient() const
Definition operator.hpp:46
VectorType & getVector()
Definition operator.hpp:48
const Executor exec_
Executor associated with the field. (CPU, GPU, openMP, etc.)
Definition operator.hpp:57
OperatorMixin(const Executor exec, const Coeff &coeffs, VectorType &field, Operator::Type type)
Definition operator.hpp:34
Operator::Type getType() const
Definition operator.hpp:38
void build(const Input &input)
Definition operator.hpp:53
virtual ~OperatorMixin()=default
virtual const Executor & exec() const final
Definition operator.hpp:42
std::variant< Dictionary, TokenList > Input
Definition input.hpp:13
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16