pointFieldReconstructorReconstructFields.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 | Copyright (C) 2011 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 
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 template<class Type>
33 {
34  // Read the field for all the processors
36  (
37  procMeshes_.size()
38  );
39 
40  forAll(procMeshes_, proci)
41  {
42  procFields.set
43  (
44  proci,
46  (
47  IOobject
48  (
49  fieldIoObject.name(),
50  procMeshes_[proci]().time().timeName(),
51  procMeshes_[proci](),
54  ),
55  procMeshes_[proci]
56  )
57  );
58  }
59 
60 
61  // Create the internalField
63 
64  // Create the patch fields
66 
67 
68  forAll(procMeshes_, proci)
69  {
71  procField = procFields[proci];
72 
73  // Get processor-to-global addressing for use in rmap
74  const labelList& procToGlobalAddr = pointProcAddressing_[proci];
75 
76  // Set the cell values in the reconstructed field
77  internalField.rmap
78  (
79  procField.internalField(),
80  procToGlobalAddr
81  );
82 
83  // Set the boundary patch values in the reconstructed field
85  {
86  // Get patch index of the original patch
87  const label curBPatch = boundaryProcAddressing_[proci][patchi];
88 
89  // check if the boundary patch is not a processor patch
90  if (curBPatch >= 0)
91  {
92  if (!patchFields(curBPatch))
93  {
94  patchFields.set(
95  curBPatch,
97  (
98  procField.boundaryField()[patchi],
99  mesh_.boundary()[curBPatch],
102  (
103  mesh_.boundary()[curBPatch].size()
104  )
105  )
106  );
107  }
108 
109  patchFields[curBPatch].rmap
110  (
111  procField.boundaryField()[patchi],
113  );
114  }
115  }
116  }
117 
118  // Construct and write the field
119  // setting the internalField and patchFields
121  (
123  (
124  IOobject
125  (
126  fieldIoObject.name(),
127  mesh_().time().timeName(),
128  mesh_(),
131  ),
132  mesh_,
133  procFields[0].dimensions(),
135  patchFields
136  )
137  );
138 }
139 
140 
141 // Reconstruct and write all point fields
142 template<class Type>
144 (
145  const IOobjectList& objects,
146  const HashSet<word>& selectedFields
147 )
148 {
149  word fieldClassName
150  (
152  );
153 
154  IOobjectList fields = objects.lookupClass(fieldClassName);
155 
156  if (fields.size())
157  {
158  Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
159 
160  forAllConstIter(IOobjectList, fields, fieldIter)
161  {
162  if
163  (
164  !selectedFields.size()
165  || selectedFields.found(fieldIter()->name())
166  )
167  {
168  Info<< " " << fieldIter()->name() << endl;
169 
170  reconstructField<Type>(*fieldIter())().write();
171  }
172  }
173 
174  Info<< endl;
175  }
176 }
177 
178 
179 // ************************************************************************* //
Foam::pointFieldReconstructor::mesh_
const pointMesh & mesh_
Reconstructed mesh reference.
Definition: pointFieldReconstructor.H:56
Foam::pointFieldReconstructor::pointProcAddressing_
const PtrList< labelIOList > & pointProcAddressing_
List of processor point addressing lists.
Definition: pointFieldReconstructor.H:62
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::pointMesh::boundary
const pointBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: pointMesh.H:106
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
fields
Info<< "Creating field dpdt\n"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar("dpdt", p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);p_rgh=p - rho *gh;mesh.setFluxRequired(p_rgh.name());multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:127
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::HashSet
A HashTable with keys but without contents.
Definition: HashSet.H:59
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:58
Foam::pointFieldReconstructor::patchPointAddressing_
labelListListList patchPointAddressing_
Point patch addressing.
Definition: pointFieldReconstructor.H:68
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
pointFieldReconstructor.H
Foam::PtrList::set
bool set(const label) const
Is element set.
Foam::label
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
Foam::Field< Type >
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::Info
messageStream Info
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
Foam::IOobject::name
const word & name() const
Return name.
Definition: IOobject.H:273
Foam::PtrList
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
Foam::pointFieldReconstructor::reconstructFields
void reconstructFields(const IOobjectList &objects, const HashSet< word > &selectedFields)
Reconstruct and write all fields.
Definition: pointFieldReconstructorReconstructFields.C:144
Foam::HashTable< nil, word, string::hash >::size
label size() const
Return number of elements in table.
Definition: HashTableI.H:65
Foam::HashTable< nil, word, string::hash >::found
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:109
Foam::IOobjectList::lookupClass
IOobjectList lookupClass(const word &className) const
Return the list for all IOobjects of a given class.
Definition: IOobjectList.C:199
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:50
internalField
conserve internalField()+
Foam::pointMesh::size
label size() const
Return number of points.
Definition: pointMesh.H:94
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::pointFieldReconstructor::pointPatchFieldReconstructor
Definition: pointFieldReconstructor.H:85
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::PtrList::size
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
timeName
word timeName
Definition: getTimeIndex.H:3
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::pointFieldReconstructor::reconstructField
tmp< GeometricField< Type, pointPatchField, pointMesh > > reconstructField(const IOobject &fieldIoObject)
Reconstruct field.
Foam::pointFieldReconstructor::procMeshes_
const PtrList< pointMesh > & procMeshes_
List of processor meshes.
Definition: pointFieldReconstructor.H:59
write
Tcoeff write()
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::pointFieldReconstructor::boundaryProcAddressing_
const PtrList< labelIOList > & boundaryProcAddressing_
List of processor boundary addressing lists.
Definition: pointFieldReconstructor.H:65