NeoN
A framework for CFD software
Loading...
Searching...
No Matches
volumeField.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2024 - 2025 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
10
11#include <vector>
12
14{
15
26template<typename ValueType>
27class VolumeField : public DomainMixin<ValueType>
28{
29
30public:
31
32 using VectorValueType = ValueType;
33
34
44 const Executor& exec,
45 std::string fieldName,
48 );
49
50
61 const Executor& exec,
62 std::string name,
66 );
67
78 const Executor& exec,
79 std::string name,
82 const BoundaryData<ValueType>& boundaryVectors,
84 );
85
99 const Executor& exec,
100 std::string fieldName,
101 const UnstructuredMesh& mesh,
102 const Field<ValueType>& domainVector,
104 Database& db,
105 std::string dbKey,
106 std::string collectionName
107 );
108
110
111 VolumeField<ValueType>& operator-=(const ValueType rhs);
112
113 VolumeField<ValueType>& operator+=(const ValueType rhs);
114
122
128 bool hasDatabase() const { return db_.has_value(); }
129
136 {
137 if (!db_.has_value())
138 {
139 throw std::runtime_error {
140 "Database not set: make sure the field is registered in the database"
141 };
142 }
143 return *db_.value();
144 }
145
151 const Database& db() const
152 {
153 if (!db_.has_value())
154 {
155 throw std::runtime_error(
156 "Database not set: make sure the field is registered in the database"
157 );
158 }
159 return *db_.value();
160 }
161
167 bool registered() const { return key != "" && fieldCollectionName != "" && db_.has_value(); }
168
169 std::vector<VolumeBoundary<ValueType>> boundaryConditions() const
170 {
171 return boundaryConditions_;
172 }
173
174 std::string key; // The key of the field in the database
175 std::string fieldCollectionName; // The name of the field collection in the database
176
177private:
178
179 std::vector<VolumeBoundary<ValueType>> boundaryConditions_; // The vector of boundary conditions
180 std::optional<Database*> db_; // The optional pointer to the database
181};
182
183} // namespace NeoN
Represents the boundary fields for a computational domain.
Represents the domain fields for a computational domain.
Definition field.hpp:36
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:30
This class represents a mixin for a geometric field.
Definition domain.hpp:28
const UnstructuredMesh & mesh() const
Returns a const reference to the unstructured mesh object.
Definition domain.hpp:122
const Executor & exec() const
Returns a const reference to the executor object.
Definition domain.hpp:115
const Vector< ValueType > & internalVector() const
Returns a const reference to the internal field.
Definition domain.hpp:80
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:18