fvMeshSubsetProxyTemplates.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "fvMeshSubsetProxy.H"
30#include "volFields.H"
31
32// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
33
34template<class Type>
36<
38>
40(
42)
43{
44 IOobject io(df);
47 io.registerObject(false);
48
50 (
51 io,
52 df.mesh(),
55 );
56 tfield.ref().primitiveFieldRef() = df;
57 tfield.ref().oriented() = df.oriented();
58 tfield.ref().correctBoundaryConditions();
59
60 return tfield;
61}
62
63
64template<class Type>
67(
68 const fvMeshSubset& subsetter,
70)
71{
72 auto tfield = zeroGradientField<Type>(df);
73
74 if (subsetter.hasSubMesh())
75 {
76 return interpolate(subsetter, tfield());
77 }
78
79 return tfield;
80}
81
82
83template<class Type>
86(
87 const fvMeshSubset& subsetter,
89)
90{
91 // TODO - move dimensioned mesh into internal,
92 // but needs different GeometricField constructors
93
94 if (tdf.valid())
95 {
96 if (subsetter.hasSubMesh())
97 {
98 auto tproxied = interpolate(subsetter, tdf);
99 auto tfield = zeroGradientField<Type>(tproxied());
100
101 tdf.clear();
102 tproxied.clear();
103 return tfield;
104 }
105 else
106 {
107 auto tfield = zeroGradientField<Type>(tdf());
108
109 tdf.clear();
110 return tfield;
111 }
112 }
113
114 return nullptr;
115}
116
117
118template<class GeoField>
121(
122 const fvMeshSubset& subsetter,
123 const GeoField& fld
124)
125{
126 if (subsetter.hasSubMesh())
127 {
128 auto tfield = subsetter.interpolate(fld);
129
130 tfield.ref().checkOut();
131 tfield.ref().rename(fld.name());
132 return tfield;
133 }
134
135 return fld;
136}
137
138
139template<class GeoField>
142(
143 const fvMeshSubset& subsetter,
144 const tmp<GeoField>& tfield
145)
146{
147 if (tfield.valid() && subsetter.hasSubMesh())
148 {
149 auto tproxied = interpolate(subsetter, tfield());
150 tfield.clear();
151
152 return tproxied;
153 }
154
155 // Nothing to be done
156 return tfield;
157}
158
159
160// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
161
162template<class Type>
165(
167) const
168{
169 return interpolateInternal(subsetter_, df);
170}
171
172
173template<class Type>
176(
178) const
179{
180 return interpolateInternal(subsetter_, tdf);
181}
182
183
184template<class GeoField>
187{
188 return interpolate(subsetter_, fld);
189}
190
191
192template<class GeoField>
195{
196 return interpolate(subsetter_, tfield);
197}
198
199
200// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
const orientedType & oriented() const noexcept
Return oriented type.
Generic GeometricField class.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
bool registerObject() const noexcept
Should object created with this IOobject be registered?
Definition: IOobjectI.H:107
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
Generic dimensioned Type class.
static tmp< GeometricField< Type, fvPatchField, volMesh > > zeroGradientField(const DimensionedField< Type, volMesh > &df)
Construct volField (with zeroGradient) from an internal field.
static tmp< GeometricField< Type, fvPatchField, volMesh > > interpolateInternal(const fvMeshSubset &subsetter, const DimensionedField< Type, volMesh > &df)
Convert an internal field to a volume field (with zeroGradient)
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: fvMeshSubset.H:80
static tmp< DimensionedField< Type, volMesh > > interpolate(const DimensionedField< Type, volMesh > &, const fvMesh &sMesh, const labelUList &cellMap)
Map volume internal (dimensioned) field.
bool hasSubMesh() const noexcept
Have subMesh?
Definition: fvMeshSubsetI.H:42
bool interpolate() const noexcept
Same as isPointData()
A class for managing temporary objects.
Definition: tmp.H:65
void clear() const noexcept
Definition: tmpI.H:287
bool valid() const noexcept
Identical to good(), or bool operator.
Definition: tmp.H:292
This boundary condition applies a zero-gradient condition from the patch internal field onto the patc...
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.