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