constSolidThermoTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "constSolidThermo.H"
27 
28 /* * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * */
29 
30 template<class Type>
32 (
33  const word& name,
34  const dimensionSet& dimensions
35 ) const
36 {
37  const dictionary& propDict(subDict(name));
38  const word propType(propDict.lookup("type"));
39 
40  if (propType == "uniform" || propType == "zonal")
41  {
42  VolField<Type> vtf
43  (
44  IOobject
45  (
47  mesh().time().constant(),
48  mesh(),
51  ),
52  mesh(),
53  dimensioned<Type>(dimensions, propDict.lookup<Type>("value"))
54  );
55 
56  if (propType == "zonal")
57  {
58  const dictionary& zonesDict(propDict.subDict("zones"));
59 
60  Info<< " Reading " << name << " for zones:" << endl;
61 
62  Field<Type>& vtfIf = vtf;
63 
64  forAllConstIter(dictionary, zonesDict, iter)
65  {
66  const word& zoneName = iter().keyword();
67  const Type value(pTraits<Type>(iter().stream()));
68 
69  Info<< " " << zoneName << " " << value << endl;
70 
71  const labelList& zoneCells = mesh().cellZones()[zoneName];
72 
73  // Set the internal field in the zone to the value
74  forAll(zoneCells, i)
75  {
76  vtfIf[zoneCells[i]] = value;
77  }
78 
79  // Set the patch field in the zone to the value
80 
81  const fvBoundaryMesh& patches = mesh().boundary();
82  const labelList& own = mesh().faceOwner();
83 
84  boolList cellInZone(mesh().nCells(), false);
85 
86  forAll(zoneCells, i)
87  {
88  cellInZone[zoneCells[i]] = true;
89  }
90 
92  {
93  const fvPatch& pp = patches[patchi];
94 
95  forAll(pp, patchFacei)
96  {
97  const label facei = pp.start() + patchFacei;
98 
99  if (cellInZone[own[facei]])
100  {
101  vtf.boundaryFieldRef()[patchi][patchFacei] = value;
102  }
103  }
104  }
105  }
106 
107  Info << endl;
108  }
109 
110  return vtf;
111  }
112  else if (propType == "file")
113  {
114  return VolField<Type>
115  (
116  IOobject
117  (
119  mesh().time().constant(),
120  mesh(),
123  ),
124  mesh()
125  );
126  }
127  else
128  {
130  << "Valid type entries are 'uniform' or 'file' for " << name
131  << abort(FatalError);
132 
133  return VolField<Type>::null();
134  }
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Pre-declare SubField and related Field type.
Definition: Field.H:82
Generic GeometricField class.
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const Time & time() const
Return time.
Definition: IOobject.C:318
virtual const fvMesh & mesh() const
Return const access to the mesh.
Definition: basicThermo.H:484
static word phasePropertyName(const word &name, const word &phaseName)
Name of a property for a given phase.
Definition: basicThermo.H:150
VolField< Type > readProperty(const word &name, const dimensionSet &dimensions) const
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:109
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:860
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:998
Dimension set for the base types.
Definition: dimensionSet.H:122
Generic dimensioned Type class.
Foam::fvBoundaryMesh.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:893
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
virtual label start() const
Return start label of this patch in the polyMesh face list.
Definition: fvPatch.H:151
virtual const labelList & faceOwner() const
Return face owner.
Definition: polyMesh.C:1387
const meshCellZones & cellZones() const
Return cell zones.
Definition: polyMesh.H:451
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
label patchi
const fvPatchList & patches
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
errorManip< error > abort(error &err)
Definition: errorManip.H:131
messageStream Info
error FatalError
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47