KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
vtu_output.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Suneth Warnakulasuriya
11 //
12 
13 #pragma once
14 
15 // System includes
16 #include <string>
17 #include <variant>
18 #include <unordered_map>
19 #include <map>
20 
21 // External includes
22 
23 // Project includes
24 #include "includes/define.h"
25 #include "includes/io.h"
26 #include "includes/model_part.h"
27 #include "containers/variable.h"
28 #include "containers/flags.h"
30 
31 namespace Kratos {
41 class KRATOS_API(KRATOS_CORE) VtuOutput : public IO
42 {
43 public:
46 
47  using IndexType = std::size_t;
48 
49  using SupportedVariables = std::variant<
50  const Variable<int>*,
51  const Variable<double>*,
56 
57  using SupportedCellContainerExpressions = std::variant<
60 
62 
64  KRATOS_DEFINE_LOCAL_FLAG( CONDITIONS );
66 
70 
73  {
75  BINARY
76  };
77 
81 
90  VtuOutput(
91  ModelPart& rModelPart,
92  const bool IsInitialConfiguration = true,
93  const WriterFormat OutputFormat = WriterFormat::BINARY,
94  const IndexType Precision = 9);
95 
99 
106  template<class TDataType>
107  void AddHistoricalVariable(const Variable<TDataType>& rVariable);
108 
116  template<class TDataType>
117  void AddNonHistoricalVariable(
118  const Variable<TDataType>& rVariable,
119  const Flags& rEntityFlags);
120 
128  void AddFlagVariable(
129  const std::string& rFlagName,
130  const Flags& rFlagVariable,
131  const Flags& rEntityFlags);
132 
146  template <class TContainerType>
147  void AddContainerExpression(
148  const std::string& rExpressionName,
149  const typename ContainerExpression<TContainerType>::Pointer pContainerExpression);
150 
154  void ClearHistoricalVariables();
155 
159  void ClearNodalNonHistoricalVariables();
160 
164  void ClearCellNonHistoricalVariables();
165 
169  void ClearNodalFlags();
170 
174  void ClearCellFlags();
175 
179  void ClearNodalContainerExpressions();
180 
184  void ClearCellContainerExpressions();
185 
190  const ModelPart& GetModelPart() const;
191 
199  void PrintOutput(const std::string& rOutputFilenamePrefix);
200 
202 private:
205 
206  ModelPart& mrModelPart;
207 
208  const bool mIsInitialConfiguration;
209 
210  const WriterFormat mOutputFormat;
211 
212  const IndexType mPrecision;
213 
214  bool mIsConditionsConsidered;
215 
216  bool mIsElementsConsidered;
217 
218  // TODO: In the future study to replace the std::map
219  // TODO: Study replace string, expensive, with hashes or keys
220 
221  std::unordered_map<IndexType, IndexType> mKratosVtuIndicesMap;
222 
223  std::map<std::string, SupportedVariables> mHistoricalVariablesMap;
224 
225  std::map<std::string, SupportedVariables> mNonHistoricalNodalVariablesMap;
226 
227  std::map<std::string, SupportedVariables> mNonHistoricalCellVariablesMap;
228 
229  std::map<std::string, const Flags*> mNodalFlagsMap;
230 
231  std::map<std::string, const Flags*> mCellFlagsMap;
232 
233  std::map<std::string, ContainerExpression<ModelPart::NodesContainerType>::Pointer> mPointContainerExpressionsMap;
234 
235  std::map<std::string, SupportedCellContainerExpressions> mCellContainerExpressionsMap;
236 
240 
246  void PrintModelPart(
247  const std::string& rOutputFileNamePrefix,
248  ModelPart& rModelPart) const;
249 
251 };
252 } // namespace Kratos
Container variable data holder.
Definition: container_expression.h:80
Definition: flags.h:58
IO provides different implementation of input output procedures which can be used to read and write w...
Definition: io.h:58
This class aims to manage meshes for multi-physics simulations.
Definition: model_part.h:77
Class to output Kratos Flags, Variables and ContainerExpressions to vtu. Supports both shared and dis...
Definition: vtu_output.h:42
KRATOS_DEFINE_LOCAL_FLAG(ELEMENTS)
std::size_t IndexType
Definition: vtu_output.h:47
KRATOS_CLASS_POINTER_DEFINITION(VtuOutput)
std::variant< ContainerExpression< ModelPart::ConditionsContainerType >::Pointer, ContainerExpression< ModelPart::ElementsContainerType >::Pointer > SupportedCellContainerExpressions
Definition: vtu_output.h:59
std::variant< const Variable< int > *, const Variable< double > *, const Variable< array_1d< double, 3 > > *, const Variable< array_1d< double, 4 > > *, const Variable< array_1d< double, 6 > > *, const Variable< array_1d< double, 9 > > * > SupportedVariables
Definition: vtu_output.h:55
WriterFormat
Enumerations for the output writer format.
Definition: vtu_output.h:73
@ ASCII
Definition: vtu_output.h:74
KRATOS_DEFINE_LOCAL_FLAG(CONDITIONS)
KRATOS_DEFINE_LOCAL_FLAG(NODES)
std::size_t IndexType
The definition of the index type.
Definition: key_hash.h:35
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21