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