NeoN
A framework for CFD software
Loading...
Searching...
No Matches
coeff.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
9
10namespace NeoN::dsl
11{
12
23class Coeff
24{
25
26public:
27
29
30 Coeff(scalar value);
31
32 Coeff(scalar coeff, const Vector<scalar>& field);
33
34 Coeff(const Vector<scalar>& field);
35
36 KOKKOS_INLINE_FUNCTION
37 scalar operator[](const localIdx i) const { return (hasView_) ? view_[i] * coeff_ : coeff_; }
38
39 bool hasView();
40
42
44
45
46 Coeff& operator*=(const Coeff& rhs);
47
48
49private:
50
51 scalar coeff_;
52
54
55 bool hasView_;
56};
57
58
59[[nodiscard]] inline Coeff operator*(const Coeff& lhs, const Coeff& rhs)
60{
61 Coeff result = lhs;
62 result *= rhs;
63 return result;
64}
65
66namespace detail
67{
68/* @brief function to force evaluation to a field, the field will be resized to hold either a
69 * single value or the full field
70 *
71 * @param field to store the result
72 */
73void toVector(Coeff& coeff, Vector<scalar>& rhs);
74
75} // namespace detail
76
77} // namespace NeoN::dsl
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:30
A class that represents a coefficient for the NeoN dsl.
Definition coeff.hpp:24
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:37
Coeff & operator*=(const Coeff &rhs)
Coeff(scalar value)
Coeff operator*(const Coeff &lhs, const Coeff &rhs)
Definition coeff.hpp:59
int32_t localIdx
Definition label.hpp:32
float scalar
Definition scalar.hpp:16