Loading...
Searching...
No Matches
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>
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, patchi)
98 {
99 if
100 (
102 (
103 bm[patchi].type()
104 )
105 )
106 {
107 actualPatchTypes[patchi] = bm[patchi].type();
108 }
109 }
110
112 (
113 new Boundary
114 (
115 mesh.boundary(),
118 actualPatchTypes
119 )
120 );
121
122 // Values are not assigned! Assign manually
123 Boundary& bRef = bPtr();
124 forAll(bRef, pI)
125 {
126 bRef[pI] = pTraits<Type>::zero;
127 }
129 return (bPtr);
130}
131
132
133template<class Type>
134autoPtr<List<Field<Type>>>
136(
137 const fvMesh& mesh,
138 bool printAllocation = false
139)
140{
141 if (printAllocation)
142 {
143 Info<< "Allocating new point boundaryField " << nl << endl;
144 }
145
147 (
148 new List<Field<Type>>
149 (
150 mesh.boundary().size()
151 )
152 );
153
154 List<Field<Type>>& bRef = bPtr();
155 forAll(bRef, pI)
156 {
157 bRef[pI] =
159 (
160 mesh.boundaryMesh()[pI].nPoints(),
162 );
163 }
164
165 return (bPtr);
166}
167
168
169// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170
171} // End namespace Foam
172
173// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174
175#endif
176
177// ************************************************************************* //
static const this_type & null() noexcept
Return a null DimensionedField (reference to a nullObject).
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Generic GeometricField class.
GeometricBoundaryField< Type, PatchField, GeoMesh > Boundary
Type of boundary fields.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
label size() const noexcept
The number of entries in the list.
Definition UPtrListI.H:106
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Generic dimensioned Type class.
A fvBoundaryMesh is a fvPatch list with a reference to the associated fvMesh, with additional search ...
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition fvMesh.H:395
static const word & calculatedType() noexcept
The type name for calculated patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
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 POSIX.C:801
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
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 expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
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:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299