NeoN
A framework for CFD software
Loading...
Searching...
No Matches
volumeBoundaryFactory.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2023 - 2026 NeoN authors
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
10#include "NeoN/fields/field.hpp"
13
15{
16
17template<typename ValueType>
18class VolumeField;
19
20class BoundaryContext;
21
22/* collects attributes of a boundary for simple queries
23 *
24 */
26{
31 bool transformImplicit = false;
36};
37
38template<typename ValueType>
41 VolumeBoundaryFactory<ValueType>,
42 Parameters<const UnstructuredMesh&, const Dictionary&, localIdx>>,
44{
45public:
46
47 static std::string name() { return "VolumeBoundaryFactory"; }
48
56
57 virtual ~VolumeBoundaryFactory() = default;
58
59 virtual void correctBoundaryCondition(Field<ValueType>& domainVector) = 0;
60
61 virtual void correctBoundaryCondition(Field<ValueType>& domainVector, const BoundaryContext&)
62 {
63 correctBoundaryCondition(domainVector);
64 }
65
73 virtual void set([[maybe_unused]] Field<ValueType>& domainVector) {}
74
82 virtual void update(Field<ValueType>& domainVector) { correctBoundaryCondition(domainVector); }
83
84 virtual std::unique_ptr<VolumeBoundaryFactory> clone() const = 0;
85
86 virtual std::string getName() const = 0;
87
89
90protected:
91
93};
94
95
101template<typename ValueType>
103{
104public:
105
108 mesh.boundaryMesh().offset()[static_cast<size_t>(patchID)],
109 mesh.boundaryMesh().offset()[static_cast<size_t>(patchID) + 1],
110 patchID
111 ),
112 boundaryCorrectionStrategy_(VolumeBoundaryFactory<ValueType>::create(
113 dict.get<std::string>("type"), mesh, dict, patchID
114 ))
115 {}
116
118 : BoundaryPatchMixin(other),
119 boundaryCorrectionStrategy_(other.boundaryCorrectionStrategy_->clone())
120 {}
121
122 virtual void correctBoundaryCondition(Field<ValueType>& domainVector)
123 {
124 boundaryCorrectionStrategy_->correctBoundaryCondition(domainVector);
125 }
126
127 virtual void
129 {
130 boundaryCorrectionStrategy_->correctBoundaryCondition(domainVector, ctx);
131 }
132
133 virtual void set(Field<ValueType>& domainVector)
134 {
135 boundaryCorrectionStrategy_->set(domainVector);
136 }
137
138 virtual void update(Field<ValueType>& domainVector)
139 {
140 boundaryCorrectionStrategy_->update(domainVector);
141 }
142
144 {
145 return boundaryCorrectionStrategy_->attributes();
146 }
147
148 const std::string name() const { return boundaryCorrectionStrategy_->getName(); }
149
150private:
151
152 // NOTE needs full namespace to be not ambiguous
153 std::unique_ptr<NeoN::finiteVolume::cellCentred::VolumeBoundaryFactory<ValueType>>
154 boundaryCorrectionStrategy_;
155};
156
157}
A class representing a dictionary that stores key-value pairs.
Represents the domain fields for a computational domain.
Definition field.hpp:34
A factory class for runtime selection of derived classes.
Represents an unstructured mesh in NeoN.
Carries named field references for context-aware boundary conditions.
A base class for implementing derived boundary conditions.
virtual std::unique_ptr< VolumeBoundaryFactory > clone() const =0
virtual void set(Field< ValueType > &domainVector)
One-time patch initialisation, applied once per field before the first update().
virtual void correctBoundaryCondition(Field< ValueType > &domainVector)=0
virtual void update(Field< ValueType > &domainVector)
Per-iteration boundary update, applied on every correctBoundaryConditions() call.
VolumeBoundaryFactory(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID, BoundaryAttributes attributes)
BoundaryAttributes attributes_
The attributes of the patch.
virtual void correctBoundaryCondition(Field< ValueType > &domainVector, const BoundaryContext &)
Represents a volume boundary field for a cell-centered finite volume method.
virtual void update(Field< ValueType > &domainVector)
VolumeBoundary(const UnstructuredMesh &mesh, const Dictionary &dict, localIdx patchID)
virtual void set(Field< ValueType > &domainVector)
virtual void correctBoundaryCondition(Field< ValueType > &domainVector, const BoundaryContext &ctx)
virtual void correctBoundaryCondition(Field< ValueType > &domainVector)
int32_t localIdx
Definition label.hpp:50
std::size_t size_t
Definition label.hpp:56
bool assignable
whether values can be assigned to the boundary patch