NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
geometricField.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2024 NeoFOAM authors
3
4#pragma once
5
11
13{
14
25template<typename ValueType>
27{
28public:
29
39 const Executor& exec,
40 std::string fieldName,
42 const DomainField<ValueType>& field
43 )
44 : name(fieldName), exec_(exec), mesh_(mesh), field_(field)
45 {}
46
57 const Executor& exec,
58 std::string fieldName,
61 const BoundaryFields<ValueType>& boundaryFields
62 )
63 : name(fieldName), exec_(exec), mesh_(mesh), field_({exec, internalField, boundaryFields})
64 {
65 if (mesh.nCells() != internalField.size())
66 {
67 NF_ERROR_EXIT("Inconsistent size of mesh and internal field detected");
68 }
69 }
70
76 const Field<ValueType>& internalField() const { return field_.internalField(); }
77
83 Field<ValueType>& internalField() { return field_.internalField(); }
84
90 size_t size() const { return field_.internalField().size(); }
91
97 const BoundaryFields<ValueType>& boundaryField() const { return field_.boundaryField(); }
98
104 BoundaryFields<ValueType>& boundaryField() { return field_.boundaryField(); }
105
111 const Executor& exec() const { return exec_; }
112
118 const UnstructuredMesh& mesh() const { return mesh_; }
119
120 std::string name; // The name of the field
121
122protected:
123
124 Executor exec_; // The executor object
125 const UnstructuredMesh& mesh_; // The unstructured mesh object
126 DomainField<ValueType> field_; // The domain field object
127};
128
129} // namespace NeoFOAM
Represents the boundary fields for a computational domain.
Represents the domain fields for a computational domain.
A class to contain the data and executors for a field and define some basic operations.
Definition field.hpp:49
Represents an unstructured mesh in NeoFOAM.
size_t nCells() const
Get the number of cells in the mesh.
This class represents a mixin for a geometric field.
const UnstructuredMesh & mesh() const
Returns a const reference to the unstructured mesh object.
GeometricFieldMixin(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const Field< ValueType > &internalField, const BoundaryFields< ValueType > &boundaryFields)
Constructor for GeometricFieldMixin.
GeometricFieldMixin(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const DomainField< ValueType > &field)
Constructor for GeometricFieldMixin.
const Executor & exec() const
Returns a const reference to the executor object.
const Field< ValueType > & internalField() const
Returns a const reference to the internal field.
const BoundaryFields< ValueType > & boundaryField() const
Returns a const reference to the boundary field.
BoundaryFields< ValueType > & boundaryField()
Returns a reference to the boundary field.
size_t size() const
Returns the size of the internal field.
Field< ValueType > & internalField()
Returns a reference to the internal field.
#define NF_ERROR_EXIT(message)
Macro for printing an error message and aborting the program.
Definition error.hpp:108
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16