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-2023 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 (UPstream::master())
44  {
45  const ensight::VarName varName(name);
46  output = createDataFile(varName);
47 
48  // Description
49  output().writeString
50  (
51  padded(timeIndex_) / varName
52  + " <" + pTraits<Type>::typeName + ">"
53  );
54  output().newline();
55 
56  // Remember the field variable for later use
57  noteVariable(varName, ensightPTraits<Type>::typeName);
58 
59  // Could warn about existing variables that changed representation
60  if (isPointData)
61  {
62  nodeVariables_.set(varName);
63  }
64  }
65 
66  return output;
67 }
68 
69 
70 template<class Type>
73 (
74  const word& name
75 ) const
76 {
77  return newData<Type>(name, true); // POINT_DATA
78 }
79 
80 
81 template<class Type>
84 (
85  const word& cloudName,
86  const word& name
87 ) const
88 {
90 
91  if (UPstream::master())
92  {
93  const ensight::VarName varName(name);
94  output = createCloudFile(cloudName, varName);
95 
96  // Description
97  output().writeString
98  (
99  padded(timeIndex_) / cloudName / varName
100  + " <" + pTraits<Type>::typeName + ">"
101  );
102  output().newline();
103 
104  // Remember the cloud variable for later use
105  noteCloud(cloudName, varName, ensightPTraits<Type>::typeName);
106  }
107 
108  return output;
109 }
110 
111 
112 // ************************************************************************* //
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 and vector-space.
Definition: pTraits.H:75
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
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
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:1082
static Ostream & output(Ostream &os, const IntRange< T > &range)
Definition: IntRanges.C:44
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...