NeoN
A framework for CFD software
Loading...
Searching...
No Matches
volumeField.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: MIT
2// SPDX-FileCopyrightText: 2024 NeoN authors
3
4#pragma once
5
9
10#include <vector>
11
13{
14
25template<typename ValueType>
26class VolumeField : public DomainMixin<ValueType>
27{
28
29public:
30
31 using VectorValueType = ValueType;
32
33
43 const Executor& exec,
44 std::string fieldName,
47 );
48
49
60 const Executor& exec,
61 std::string name,
65 );
66
77 const Executor& exec,
78 std::string name,
81 const BoundaryData<ValueType>& boundaryVectors,
83 );
84
98 const Executor& exec,
99 std::string fieldName,
100 const UnstructuredMesh& mesh,
101 const Field<ValueType>& domainVector,
103 Database& db,
104 std::string dbKey,
105 std::string collectionName
106 );
107
109
110 VolumeField<ValueType>& operator-=(const ValueType rhs);
111
112 VolumeField<ValueType>& operator+=(const ValueType rhs);
113
121
127 bool hasDatabase() const { return db_.has_value(); }
128
135 {
136 if (!db_.has_value())
137 {
138 throw std::runtime_error {
139 "Database not set: make sure the field is registered in the database"
140 };
141 }
142 return *db_.value();
143 }
144
150 const Database& db() const
151 {
152 if (!db_.has_value())
153 {
154 throw std::runtime_error(
155 "Database not set: make sure the field is registered in the database"
156 );
157 }
158 return *db_.value();
159 }
160
166 bool registered() const { return key != "" && fieldCollectionName != "" && db_.has_value(); }
167
168 std::vector<VolumeBoundary<ValueType>> boundaryConditions() const
169 {
170 return boundaryConditions_;
171 }
172
173 std::string key; // The key of the field in the database
174 std::string fieldCollectionName; // The name of the field collection in the database
175
176private:
177
178 std::vector<VolumeBoundary<ValueType>> boundaryConditions_; // The vector of boundary conditions
179 std::optional<Database*> db_; // The optional pointer to the database
180};
181
182} // 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.
A class to contain the data and executors for a field and define some basic operations.
Definition vector.hpp:28
This class represents a mixin for a geometric field.
Definition domain.hpp:27
const UnstructuredMesh & mesh() const
Returns a const reference to the unstructured mesh object.
Definition domain.hpp:121
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
Represents a volume boundary field for a cell-centered finite volume method.
Represents a volume field in a finite volume method.
Database & db()
Retrieves the database.
VolumeField(const Executor &exec, std::string name, const UnstructuredMesh &mesh, const Vector< ValueType > &internalVector, const std::vector< VolumeBoundary< ValueType > > &boundaryConditions)
Constructor for a VolumeField with a given internal field.
const Database & db() const
Retrieves the database.
bool hasDatabase() const
Returns true if the field has a database, false otherwise.
VolumeField< ValueType > & operator+=(const ValueType rhs)
void correctBoundaryConditions()
Corrects the boundary conditions of the surface field.
bool registered() const
Returns true if the field is registered in the database, false otherwise.
std::vector< VolumeBoundary< ValueType > > boundaryConditions() const
VolumeField(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const Field< ValueType > &domainVector, const std::vector< VolumeBoundary< ValueType > > &boundaryConditions, Database &db, std::string dbKey, std::string collectionName)
Constructor for a VolumeField with a given internal field and database.
VolumeField(const Executor &exec, std::string name, const UnstructuredMesh &mesh, const Vector< ValueType > &internalVector, const BoundaryData< ValueType > &boundaryVectors, const std::vector< VolumeBoundary< ValueType > > &boundaryConditions)
Constructor for a VolumeField with a given internal and boundary field.
VolumeField< ValueType > & operator-=(const ValueType rhs)
VolumeField(const Executor &exec, std::string fieldName, const UnstructuredMesh &mesh, const std::vector< VolumeBoundary< ValueType > > &boundaryConditions)
Constructor for a uninitialized VolumeField.
std::variant< SerialExecutor, CPUExecutor, GPUExecutor > Executor
Definition executor.hpp:16