NeoN
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
domain.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2024 NeoN authors
3
4#pragma once
5
11
13{
14
25template<typename ValueType>
27{
28public:
29
30
31 typedef ValueType ElementType;
32
42 const Executor& exec,
43 std::string fieldName,
45 const Field<ValueType>& field
46 )
47 : name(fieldName), exec_(exec), mesh_(mesh), field_(field)
48 {}
49
60 const Executor& exec,
61 std::string fieldName,
64 const BoundaryData<ValueType>& boundaryVectors
65 )
66 : name(fieldName), exec_(exec), mesh_(mesh), field_({exec, internalVector, boundaryVectors})
67 {
68 if (mesh.nCells() != internalVector.size())
69 {
70 NF_ERROR_EXIT("Inconsistent size of mesh and internal field detected");
71 }
72 }
73
79 const Vector<ValueType>& internalVector() const { return field_.internalVector(); }
80
86 Vector<ValueType>& internalVector() { return field_.internalVector(); }
87
93 localIdx size() const { return field_.internalVector().size(); }
94
100 const BoundaryData<ValueType>& boundaryData() const { return field_.boundaryData(); }
101
107 BoundaryData<ValueType>& boundaryData() { return field_.boundaryData(); }
108
114 const Executor& exec() const { return exec_; }
115
121 const UnstructuredMesh& mesh() const { return mesh_; }
122
123 std::string name; // The name of the field
124
125protected:
126
127 Executor exec_; // The executor object
128 const UnstructuredMesh& mesh_; // The unstructured mesh object
129 Field<ValueType> field_; // The domain field object
130};
131
132} // namespace NeoN
Represents the boundary fields for a computational domain.
Represents the domain fields for a computational domain.
Definition field.hpp:34
Represents an unstructured mesh in NeoN.
localIdx nCells() const
Get the number of cells in the mesh.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:53
This class represents a mixin for a geometric field.
Definition domain.hpp:27
DomainMixin(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const Vector< ValueType > &internalVector, const BoundaryData< ValueType > &boundaryVectors)
Constructor for DomainMixin.
Definition domain.hpp:59
BoundaryData< ValueType > & boundaryData()
Returns a reference to the boundary field.
Definition domain.hpp:107
const UnstructuredMesh & mesh() const
Returns a const reference to the unstructured mesh object.
Definition domain.hpp:121
localIdx size() const
Returns the size of the internal field.
Definition domain.hpp:93
const BoundaryData< ValueType > & boundaryData() const
Returns a const reference to the boundary field.
Definition domain.hpp:100
Vector< ValueType > & internalVector()
Returns a reference to the internal field.
Definition domain.hpp:86
DomainMixin(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const Field< ValueType > &field)
Constructor for DomainMixin.
Definition domain.hpp:41
const Executor & exec() const
Returns a const reference to the executor object.
Definition domain.hpp:114
const Vector< ValueType > & internalVector() const
Returns a const reference to the internal field.
Definition domain.hpp:79
#define NF_ERROR_EXIT(message)
Macro for printing an error message and aborting the program.
Definition error.hpp:108
int32_t localIdx
Definition label.hpp:30
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16