areaWriteTemplates.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) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "areaWrite.H"
29 #include "areaFields.H"
30 #include "faMesh.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 template<class Type>
35 void Foam::areaWrite::writeSurface
36 (
37  surfaceWriter& writer,
38  const Field<Type>& values,
39  const word& fieldName
40 )
41 {
42  fileName outputName = writer.write(fieldName, values);
43 
44  // Case-local file name with "<case>" to make relocatable
45 
46  dictionary propsDict;
47  propsDict.add
48  (
49  "file",
50  time_.relativePath(outputName, true)
51  );
52  setProperty(fieldName, propsDict);
53 }
54 
55 
56 template<class GeoField>
57 void Foam::areaWrite::performAction
58 (
59  surfaceWriter& writer,
60  const faMesh& areaMesh,
61  const IOobjectList& objects
62 )
63 {
64  wordList fieldNames;
65  if (loadFromFiles_)
66  {
67  fieldNames = objects.sortedNames<GeoField>(fieldSelection_);
68  }
69  else
70  {
71  fieldNames = areaMesh.thisDb().sortedNames<GeoField>(fieldSelection_);
72  }
73 
74  for (const word& fieldName : fieldNames)
75  {
76  if (verbose_)
77  {
78  Info<< "write: " << fieldName << endl;
79  }
80 
81  if (loadFromFiles_)
82  {
83  const GeoField fld
84  (
85  IOobject
86  (
87  fieldName,
88  time_.timeName(),
89  areaMesh.thisDb(),
91  ),
92  areaMesh
93  );
94 
95  writeSurface(writer, fld, fieldName);
96  }
97  else
98  {
99  writeSurface
100  (
101  writer,
102  areaMesh.thisDb().lookupObject<GeoField>(fieldName),
103  fieldName
104  );
105  }
106  }
107 }
108 
109 
110 // ************************************************************************* //
Foam::HashTableOps::values
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:149
Foam::functionObjects::timeFunctionObject::time_
const Time & time_
Reference to the time database.
Definition: timeFunctionObject.H:65
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
faMesh.H
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:59
Foam::TimePaths::relativePath
fileName relativePath(const fileName &input, const bool caseTag=false) const
Definition: TimePathsI.H:79
areaWrite.H
writer
vtk::internalMeshWriter writer(topoMesh, topoCells, writeOpts, runTime.path()/"blockTopology")
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
propsDict
IOdictionary propsDict(IOobject("particleTrackProperties", runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED))
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
areaFields.H
Foam::functionObjects::stateFunctionObject::setProperty
void setProperty(const word &entryName, const Type &value)
Add generic property.
Definition: stateFunctionObjectTemplates.C:59
Foam::IOobject::MUST_READ
Definition: IOobject.H:120