NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
boundaryFields.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2024 NeoFOAM authors
3#pragma once
4
5#include <Kokkos_Core.hpp>
6
7#include <iostream>
8
13
14namespace NeoFOAM
15{
16
17
29template<typename T>
31{
32
33public:
34
40 : exec_(rhs.exec_), value_(rhs.value_), refValue_(rhs.refValue_),
41 valueFraction_(rhs.valueFraction_), refGrad_(rhs.refGrad_),
42 boundaryTypes_(rhs.boundaryTypes_), offset_(rhs.offset_), nBoundaries_(rhs.nBoundaries_),
43 nBoundaryFaces_(rhs.nBoundaryFaces_)
44 {}
45
46
52 : exec_(rhs.exec_), value_(exec, rhs.value_), refValue_(exec, rhs.refValue_),
53 valueFraction_(exec, rhs.valueFraction_), refGrad_(exec, rhs.refGrad_),
54 boundaryTypes_(exec, rhs.boundaryTypes_), offset_(exec, rhs.offset_),
55 nBoundaries_(rhs.nBoundaries_), nBoundaryFaces_(rhs.nBoundaryFaces_)
56 {}
57
58
60 : exec_(exec), value_(exec, nBoundaryFaces), refValue_(exec, nBoundaryFaces),
61 valueFraction_(exec, nBoundaryFaces), refGrad_(exec, nBoundaryFaces),
62 boundaryTypes_(exec, nBoundaries), offset_(exec, nBoundaries + 1),
63 nBoundaries_(nBoundaries), nBoundaryFaces_(nBoundaryFaces)
64 {}
65
66
68 const NeoFOAM::Field<T>& value() const { return value_; }
69
75 NeoFOAM::Field<T>& value() { return value_; }
76
78 const NeoFOAM::Field<T>& refValue() const { return refValue_; }
79
84 NeoFOAM::Field<T>& refValue() { return refValue_; }
85
87 const NeoFOAM::Field<scalar>& valueFraction() const { return valueFraction_; }
88
93 NeoFOAM::Field<scalar>& valueFraction() { return refValue_; }
94
96 const NeoFOAM::Field<T>& refGrad() const { return refGrad_; }
97
102 NeoFOAM::Field<T>& refGrad() { return refGrad_; }
103
108 const NeoFOAM::Field<int>& boundaryTypes() const { return boundaryTypes_; }
109
114 const NeoFOAM::Field<localIdx>& offset() const { return offset_; }
115
120 size_t nBoundaries() const { return nBoundaries_; }
121
126 size_t nBoundaryFaces() const { return nBoundaryFaces_; }
127
128 const Executor& exec() { return exec_; }
129
134 std::pair<localIdx, localIdx> range(localIdx patchId) const
135 {
136 return {offset_.data()[patchId], offset_.data()[patchId + 1]};
137 }
138
139private:
140
141 Executor exec_;
142 NeoFOAM::Field<T> value_;
144 NeoFOAM::Field<T> refValue_;
145 NeoFOAM::Field<scalar> valueFraction_;
147 NeoFOAM::Field<T> refGrad_;
148 NeoFOAM::Field<int> boundaryTypes_;
150 size_t nBoundaries_;
151 size_t nBoundaryFaces_;
152};
153
154}
Represents the boundary fields for a computational domain.
NeoFOAM::Field< T > & refValue()
Get the view storing the Dirichlet boundary values.
NeoFOAM::Field< T > & value()
Get the view storing the computed values from the boundary condition.
const NeoFOAM::Field< T > & refGrad() const
Get the view storing the Neumann boundary values.
const NeoFOAM::Field< int > & boundaryTypes() const
Get the view storing the boundary types.
BoundaryFields(const Executor &exec, const BoundaryFields< T > &rhs)
Copy constructor.
BoundaryFields(const Executor &exec, size_t nBoundaryFaces, size_t nBoundaries)
const NeoFOAM::Field< localIdx > & offset() const
Get the view storing the offsets of each boundary.
NeoFOAM::Field< T > & refGrad()
Get the view storing the Neumann boundary values.
BoundaryFields(const BoundaryFields< T > &rhs)
Copy constructor.
const NeoFOAM::Field< T > & value() const
Get the view storing the computed values from the boundary condition.
size_t nBoundaryFaces() const
Get the number of boundary faces.
const NeoFOAM::Field< T > & refValue() const
Get the view storing the Dirichlet boundary values.
const Executor & exec()
const NeoFOAM::Field< scalar > & valueFraction() const
Get the view storing the fraction of the boundary value.
NeoFOAM::Field< scalar > & valueFraction()
Get the view storing the fraction of the boundary value.
size_t nBoundaries() const
Get the number of boundaries.
std::pair< localIdx, localIdx > range(localIdx patchId) const
Get the range for a given patchId.
A class to contain the data and executors for a field and define some basic operations.
Definition field.hpp:49
ValueType * data()
Direct access to the underlying field data.
Definition field.hpp:337
uint32_t localIdx
Definition label.hpp:14
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16