NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
coeff.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2023 NeoN authors
3#pragma once
4
7
8namespace NeoN::dsl
9{
10
21class Coeff
22{
23
24public:
25
27
28 Coeff(scalar value);
29
30 Coeff(scalar coeff, const Vector<scalar>& field);
31
32 Coeff(const Vector<scalar>& field);
33
34 KOKKOS_INLINE_FUNCTION
35 scalar operator[](const localIdx i) const { return (hasView_) ? view_[i] * coeff_ : coeff_; }
36
37 bool hasSpan();
38
40
42
43
44 Coeff& operator*=(const Coeff& rhs);
45
46
47private:
48
49 scalar coeff_;
50
52
53 bool hasView_;
54};
55
56
57[[nodiscard]] inline Coeff operator*(const Coeff& lhs, const Coeff& rhs)
58{
59 Coeff result = lhs;
60 result *= rhs;
61 return result;
62}
63
64namespace detail
65{
66/* @brief function to force evaluation to a field, the field will be resized to hold either a
67 * single value or the full field
68 *
69 * @param field to store the result
70 */
71void toVector(Coeff& coeff, Vector<scalar>& rhs);
72
73} // namespace detail
74
75} // namespace NeoN::dsl
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
Coeff & operator*=(scalar rhs)
Coeff(scalar coeff, const Vector< scalar > &field)
Coeff(const Vector< scalar > &field)
View< const scalar > view()
KOKKOS_INLINE_FUNCTION scalar operator[](const localIdx i) const
Definition coeff.hpp:35
Coeff & operator*=(const Coeff &rhs)
Coeff(scalar value)
Coeff operator*(const Coeff &lhs, const Coeff &rhs)
Definition coeff.hpp:57
int32_t localIdx
Definition label.hpp:30
float scalar
Definition scalar.hpp:14