ensightCaseTemplates.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) 2016-2020 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 "cloud.H"
29 #include "ensightPTraits.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
36 (
37  const word& name,
38  const bool isPointData
39 ) const
40 {
42 
43  if (Pstream::master())
44  {
45  const ensight::VarName varName(name);
46  output = createDataFile(varName);
47 
48  // Description
49  output().write
50  (
51  string
52  (
53  padded(timeIndex_) / varName
54  + " <" + pTraits<Type>::typeName + ">"
55  )
56  );
57  output().newline();
58 
59  // Remember the field variable for later use
60  noteVariable(varName, ensightPTraits<Type>::typeName);
61 
62  // Could warn about existing variables that changed representation
63  if (isPointData)
64  {
65  nodeVariables_.set(varName);
66  }
67  }
68 
69  return output;
70 }
71 
72 
73 template<class Type>
76 (
77  const word& name
78 ) const
79 {
80  return newData<Type>(name, true); // POINT_DATA
81 }
82 
83 
84 template<class Type>
87 (
88  const word& cloudName,
89  const word& name
90 ) const
91 {
93 
94  if (Pstream::master())
95  {
96  const ensight::VarName varName(name);
97  output = createCloudFile(cloudName, varName);
98 
99  // Description
100  output().write
101  (
102  string
103  (
104  padded(timeIndex_) / cloudName / varName
105  + " <" + pTraits<Type>::typeName + ">"
106  )
107  );
108  output().newline();
109 
110  // Remember the cloud variable for later use
111  noteCloud(cloudName, varName, ensightPTraits<Type>::typeName);
112  }
113 
114  return output;
115 }
116 
117 
118 // ************************************************************************* //
autoPtr< ensightFile > newCloudData(const word &cloudName, const word &varName) const
Open stream for new cloud data file (on master), with current index.
static word padded(const int nwidth, const label value)
Stringified zero-padded integer value.
Definition: ensightCase.C:38
Ensight names and component order for base types.
A traits class, which is primarily used for primitives.
Definition: pTraits.H:51
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
const word cloudName(propsDict.get< word >("cloud"))
autoPtr< ensightFile > newData(const word &varName, const bool isPointData=false) const
Open stream for new data file (on master), with current index.
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Specification of a valid Ensight variable-name.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
Definition: UPstream.H:1037
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:58
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
autoPtr< ensightFile > newPointData(const word &varName) const
Open stream for new data file (on master), with current index and marking as containing POINT_DATA...