createZeroField.H
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) 2007-2019 PCOpt/NTUA
9 Copyright (C) 2013-2019 FOSS GP
10 Copyright (C) 2019 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
13 This file is part of OpenFOAM.
14
15 OpenFOAM is free software: you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27
28
29\*---------------------------------------------------------------------------*/
30
31// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32
33#ifndef createZeroField_H
34#define createZeroField_H
35
36namespace Foam
37{
38
39// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
40
41template<class Type>
42autoPtr<GeometricField<Type, fvPatchField, volMesh>>
44(
45 const fvMesh& mesh,
46 const word& name,
47 const dimensionSet dims,
48 bool printAllocation = false
49)
50{
51 if (printAllocation)
52 {
53 Info<< "Allocating new volField " << name << nl << endl;
54 }
55
56 return
57 (
59 (
61 (
62 name,
63 mesh.time().timeName(),
64 mesh,
67 ),
68 mesh,
70 )
71 );
72}
73
74
75template<class Type>
76autoPtr<typename GeometricField<Type, fvPatchField, volMesh>::Boundary>
78(
79 const fvMesh& mesh,
80 bool printAllocation = false
81)
82{
83 if (printAllocation)
84 {
85 Info<< "Allocating new boundaryField " << nl << endl;
86 }
87
89 Boundary;
90
91 // Make sure that the patchFields to be generated will be of type
92 // calculated, even if they are of constraint type
93 // Necessary to avoid unexpected behaviour when computing sensitivities
94 // on symmetry patches (not a good practice either way)
95 const fvBoundaryMesh& bm = mesh.boundary();
96 wordList actualPatchTypes(bm.size(), word::null);
97 forAll(actualPatchTypes, pI)
98 {
99 auto patchTypeCstrIter =
101 if (patchTypeCstrIter.found())
102 {
103 actualPatchTypes[pI] = bm[pI].type();
104 }
105 }
106
108 (
109 new Boundary
110 (
111 mesh.boundary(),
112 mesh.V()*pTraits<Type>::zero, // Dummy internal field,
114 actualPatchTypes
115 )
116 );
117
118 // Values are not assigned! Assign manually
119 Boundary& bRef = bPtr();
120 forAll(bRef, pI)
121 {
122 bRef[pI] = pTraits<Type>::zero;
123 }
124
125 return (bPtr);
126}
127
128
129template<class Type>
130autoPtr<List<Field<Type>>>
132(
133 const fvMesh& mesh,
134 bool printAllocation = false
135)
136{
137 if (printAllocation)
138 {
139 Info<< "Allocating new point boundaryField " << nl << endl;
140 }
141
143 (
144 new List<Field<Type>>
145 (
146 mesh.boundary().size()
147 )
148 );
149
150 List<Field<Type>>& bRef = bPtr();
151 forAll(bRef, pI)
152 {
153 bRef[pI] =
155 (
156 mesh.boundaryMesh()[pI].nPoints(),
158 );
159 }
160
161 return (bPtr);
162}
163
164
165// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166
167} // End namespace Foam
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171#endif
172
173// ************************************************************************* //
Generic templated field type.
Definition: Field.H:82
Generic GeometricBoundaryField class.
Generic GeometricField class.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
This boundary condition is not designed to be evaluated; it is assmued that the value is assigned via...
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Definition: dimensionSet.H:109
Generic dimensioned Type class.
Foam::fvBoundaryMesh.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:712
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
autoPtr< GeometricField< Type, fvPatchField, volMesh > > createZeroFieldPtr(const fvMesh &mesh, const word &name, const dimensionSet dims, bool printAllocation=false)
autoPtr< List< Field< Type > > > createZeroBoundaryPointFieldPtr(const fvMesh &mesh, bool printAllocation=false)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
autoPtr< typename GeometricField< Type, fvPatchField, volMesh >::Boundary > createZeroBoundaryPtr(const fvMesh &mesh, bool printAllocation=false)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
A non-counting (dummy) refCount.
Definition: refCount.H:59