NeoN
A framework for CFD software
Loading...
Searching...
No Matches
operator.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
9#include "NeoN/dsl/coeff.hpp"
10
11namespace NeoN::dsl
12{
13
15{
16public:
17
18 enum class Type
19 {
22 };
23};
24
25
26/* @class OperatorMixin
27 * @brief A mixin class to simplify implementations of concrete operators
28 * in NeoNs dsl.
29 *
30 * @detail Operators perform either an explicit or implicit operation on a field or vector.
31 *
32 * @ingroup dsl
33 * @tparam OutType the type of the resulting field after evaluation
34 * @tparam InType the type of the input field
35 */
36template<typename OutType, typename InType = OutType>
38{
39
40public:
41
43 const Executor exec, const Coeff& coeffs, const InType& field, Operator::Type type
44 )
45 : exec_(exec), coeffs_(coeffs), field_(field), type_(type) {};
46
47 /*@brief return the type of the operator i.e. Implicit or Explicit */
48 Operator::Type getType() const { return type_; }
49
50 virtual ~OperatorMixin() = default;
51
52 virtual const Executor& exec() const final { return exec_; }
53
55
56 const Coeff& getCoefficient() const { return coeffs_; }
57
58 const InType& getVector() const { return field_; }
59
60 /* @brief Given an input this function reads required coeffs */
61 void read([[maybe_unused]] const Input& input) {}
62
63protected:
64
66
68
69 const InType& field_;
70
72};
73
74} // namespace NeoN::dsl
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:24
virtual ~OperatorMixin()=default
const InType & field_
Definition operator.hpp:69
const Executor exec_
Executor associated with the field. (CPU, GPU, openMP, etc.)
Definition operator.hpp:65
const Coeff & getCoefficient() const
Definition operator.hpp:56
Operator::Type getType() const
Definition operator.hpp:48
OperatorMixin(const Executor exec, const Coeff &coeffs, const InType &field, Operator::Type type)
Definition operator.hpp:42
void read(const Input &input)
Definition operator.hpp:61
const InType & getVector() const
Definition operator.hpp:58
Operator::Type type_
Definition operator.hpp:71
virtual const Executor & exec() const final
Definition operator.hpp:52
std::variant< Dictionary, TokenList > Input
Definition input.hpp:15
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:20