polySurfaceTemplates.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2019-2022 OpenCFD Ltd.
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
28#include "polySurface.H"
29#include "polySurfaceFields.H"
30
31// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32
33template<class GeoMeshType>
35(
36 const word& fieldName
37) const
38{
39 // Face Data first (main registry)
40
41 const objectRegistry& obr = *this;
42
43 const auto* ioptr = obr.cfindObject<regIOobject>(fieldName);
44
45 if (ioptr)
46 {
47 return ioptr;
48 }
49
50 forAllConstIters(obr, iter)
51 {
52 const objectRegistry* subreg = isA<objectRegistry>(iter.val());
53
54 if (subreg && (ioptr = subreg->cfindObject<regIOobject>(fieldName)))
55 {
56 return ioptr;
57 }
58 }
59
60 return ioptr;
61}
62
63
64template<class GeoMeshType>
66(
67 const word& fieldName
68) const
69{
70 // Face Data first (main registry)
71
72 const objectRegistry& obr = *this;
73
74 if (obr.found(fieldName))
75 {
76 return this;
77 }
78
79 forAllConstIters(obr, iter)
80 {
81 const objectRegistry* subreg = isA<objectRegistry>(iter.val());
82
83 if (subreg && subreg->found(fieldName))
84 {
85 return subreg;
86 }
87 }
88
89 return nullptr;
90}
91
92
93template<class Type, class GeoMeshType>
95(
96 const word& fieldName,
97 const dimensionSet& dims,
98 const Field<Type>& values
99)
100{
101 // Force creates field database if needed.
102 const objectRegistry& fieldDb = this->fieldData<GeoMeshType>();
103
104 auto* dimfield =
106
107 if (dimfield)
108 {
109 dimfield->dimensions().reset(dims); // Dimensions may have changed
110 dimfield->field() = values;
111 }
112 else
113 {
115 (
117 (
118 fieldName,
119 fieldDb,
122 true
123 ),
124 *this,
125 dims,
126 values
127 );
128
129 dimfield->store();
130 }
131}
132
133
134template<class Type, class GeoMeshType>
136(
137 const word& fieldName,
138 const dimensionSet& dims,
139 Field<Type>&& values
140)
141{
142 // Force creates field database if needed.
143 const objectRegistry& fieldDb = this->fieldData<GeoMeshType>();
144
145 auto* dimfield =
147
148 if (dimfield)
149 {
150 dimfield->dimensions().reset(dims); // Dimensions may have changed
151 dimfield->field() = std::move(values);
152 }
153 else
154 {
156 (
158 (
159 fieldName,
160 fieldDb,
163 true
164 ),
165 *this,
166 dims,
167 std::move(values)
168 );
169
170 dimfield->store();
171 }
172}
173
174
175// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Generic templated field type.
Definition: Field.H:82
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
void reset(const dimensionSet &ds)
Copy assign the exponents from the dimensionSet.
Definition: dimensionSet.C:149
Registry of regIOobjects.
objectRegistry(const Time &db, const label nObjects=128)
Type * getObjectPtr(const word &name, const bool recursive=false) const
const objectRegistry * whichRegistry(const word &fieldName) const
void storeField(const word &fieldName, const dimensionSet &dims, const Field< Type > &values)
Copy/store named field as face or point data (template parameter).
const regIOobject * findFieldObject(const word &fieldName, const FieldAssociation association) const
Definition: polySurface.C:242
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:76
regIOobject(const IOobject &io, const bool isTimeObject=false)
Definition: regIOobject.C:47
A class for handling words, derived from Foam::string.
Definition: word.H:68
Fields (face and point) for polySurface.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278