abaqusCoordSetWriter.H
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) 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 Class
27  Foam::coordSetWriters::abaqusWriter
28 
29 Description
30  Write coordSet(s) as Abaqus point fields
31 
32  Example usage
33  \verbatim
34  T
35  {
36  type sets;
37  setFormat abaqus;
38  fields (T);
39  sets
40  {
41  ...
42  }
43  }
44  \endverbatim
45 
46  Optional format options
47  \verbatim
48  formatOptions
49  {
50  abaqus
51  {
52  format ascii;
53 
54  // Optional entries
55 
56  // Custom header: $ entries are substituions
57  header
58  (
59  "** OpenFOAM abaqus output"
60  "** Project $FOAM_CASE"
61  "** File $FILE_NAME"
62  "** $FIELD_NAME Time t=$TIME"
63  );
64 
65  // Write geometry in addition to field data
66  writeGeometry yes;
67 
68  // Null value when sample value is not found
69  // Default is scalar::min
70  nullValue 0;
71 
72  // Insert additional time sub-directory in the output path
73  // - yes : postProcessing/<fo-name>/<time>/<file>
74  // - no : postProcessing/<fo-name>/<file>
75  useTimeDir no;
76 
77  // Available when 'useTimeDir' is 'no' to disambiguate file names
78 
79  // Time base for output file names:
80  // - 'time' : <base>.inp_<field>.<time>
81  // - 'iteration' : <base>.inp_<field>.<iteration>
82  timeBase iteration;
83 
84  // Optional start counters when using timeBase iteration
85  writeIndex
86  (
87  T 1
88  );
89 
90 
91  ...
92  }
93  }
94  \endverbatim
95 
96 SourceFiles
97  abaqusCoordSetWriter.C
98 
99 \*---------------------------------------------------------------------------*/
100 
101 #ifndef Foam_coordSetWriters_abaqusWriter_H
102 #define Foam_coordSetWriters_abaqusWriter_H
103 
104 #include "coordSetWriter.H"
105 #include "Enum.H"
106 #include "HashTable.H"
107 
108 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
109 
110 namespace Foam
111 {
112 namespace coordSetWriters
113 {
115 /*---------------------------------------------------------------------------*\
116  Class abaqusWriter Declaration
117 \*---------------------------------------------------------------------------*/
118 
119 class abaqusWriter
120 :
121  public coordSetWriter
122 {
123 public:
124 
125  // Public enumerations
126 
127  //- Enumeration for time base
128  enum class timeBase { time, iter };
129 
130 
131 private:
132 
133  // Private Data
134 
135  //- Time base names
136  static const Enum<timeBase> timeBaseNames_;
137 
138  //- Optional user-defined header
139  List<string> outputHeader_;
140 
141  //- User flag to write the geometry
142  bool writeGeometry_;
143 
144  //- Null value; default = scalar::min
145  scalar nullValue_;
146 
147  //- Optional override of localTimeDir
148  bool useLocalTimeDir_;
149 
150  //- Optional time base when useLocalTimeDir_ = false
151  timeBase timeBase_;
152 
153  //- Write index
154  HashTable<label> writeIndex_;
155 
156 
157  // Private Member Functions
158 
159  //- Helper to replace $WORD entries in str
160  string replaceUserEntries
161  (
162  const string& str,
163  const dictionary& vars
164  ) const;
165 
166  //- Write the formatted keyword to the output stream
167  Ostream& writeKeyword(Ostream& os, const word& keyword) const;
168 
169  //- Append time name when useLocalTimeDir_ = false
170  void appendTimeName(const word& fieldName, fileName& fName) const;
171 
172 
173  //- Templated write operation
174  template<class Type>
175  fileName writeTemplate
176  (
177  const word& fieldName,
178  const Field<Type>& values
179  );
180 
181  //- Templated write operation
182  template<class Type>
183  fileName writeTemplate
184  (
185  const word& fieldName,
186  const List<Field<Type>>& fieldValues
187  );
188 
189  //- Write geometry to file.
190  void writeGeometry(Ostream& os, label nTracks) const;
191 
192 
193 public:
194 
195  //- Runtime type information (no debug)
196  TypeNameNoDebug("abaqus");
197 
198 
199  // Constructors
200 
201  //- Default construct
202  abaqusWriter();
203 
204  //- Default construct with specified options
205  explicit abaqusWriter(const dictionary& options);
206 
207  //- Construct from components
209  (
210  const coordSet& coords,
211  const fileName& outputPath,
212  const dictionary& options = dictionary()
213  );
214 
215  //- Construct from components
217  (
218  const UPtrList<coordSet>& tracks,
219  const fileName& outputPath,
220  const dictionary& options = dictionary()
221  );
222 
223 
224  //- Destructor. Calls close()
225  virtual ~abaqusWriter();
226 
227 
228  // Member Functions
229 
230  //- Characteristic output file name - information only
231  virtual fileName path() const; // override
232 
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace coordSetWriters
245 } // End namespace Foam
246 
247 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 
249 #endif
250 
251 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual fileName path() const
Characteristic output file name - information only.
TypeNameNoDebug("abaqus")
Runtime type information (no debug)
Write coordSet(s) as Abaqus point fields.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
Definition: HashOps.H:164
Holds list of sampling positions.
Definition: coordSet.H:49
Generic templated field type.
Definition: Field.H:62
A class for handling words, derived from Foam::string.
Definition: word.H:63
Base class for writing coordSet(s) and tracks with fields.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
virtual ~abaqusWriter()
Destructor. Calls close()
Tensor of scalars, i.e. Tensor<scalar>.
Namespace for OpenFOAM.