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.
List of all members
Kratos::VtuOutput Class Reference

Class to output Kratos Flags, Variables and ContainerExpressions to vtu. Supports both shared and distributed memory architectures. More...

#include <vtu_output.h>

Inheritance diagram for Kratos::VtuOutput:
Collaboration diagram for Kratos::VtuOutput:

Public Types

Public enums
enum  WriterFormat { ASCII , BINARY }
 Enumerations for the output writer format. More...
 
- Public Types inherited from Kratos::IO
typedef Node NodeType
 
typedef Geometry< NodeTypeGeometryType
 
typedef Mesh< NodeType, Properties, Element, ConditionMeshType
 
typedef MeshType::NodesContainerType NodesContainerType
 
typedef MeshType::PropertiesContainerType PropertiesContainerType
 
typedef ModelPart::GeometryContainerType GeometryContainerType
 
typedef MeshType::ElementsContainerType ElementsContainerType
 
typedef MeshType::ConditionsContainerType ConditionsContainerType
 
typedef std::vector< std::vector< std::size_t > > ConnectivitiesContainerType
 
typedef std::vector< std::vector< std::size_t > > PartitionIndicesContainerType
 
typedef std::vector< std::size_t > PartitionIndicesType
 
typedef std::size_t SizeType
 
typedef DenseMatrix< intGraphType
 

Public Member Functions

Life cycle
 VtuOutput (ModelPart &rModelPart, const bool IsInitialConfiguration=true, const WriterFormat OutputFormat=WriterFormat::BINARY, const IndexType Precision=9)
 Construct a new Vtu Output IO. More...
 
Public operations
template<class TDataType >
void AddHistoricalVariable (const Variable< TDataType > &rVariable)
 Adds historical variables to the output. More...
 
template<class TDataType >
void AddNonHistoricalVariable (const Variable< TDataType > &rVariable, const Flags &rEntityFlags)
 Adds non historical variables to the output. More...
 
void AddFlagVariable (const std::string &rFlagName, const Flags &rFlagVariable, const Flags &rEntityFlags)
 Adds flag output. More...
 
template<class TContainerType >
void AddContainerExpression (const std::string &rExpressionName, const typename ContainerExpression< TContainerType >::Pointer pContainerExpression)
 Adds container expressions to the vtu output. More...
 
void ClearHistoricalVariables ()
 Clears the historical variables. More...
 
void ClearNodalNonHistoricalVariables ()
 Clears the nodal non-historical variables. More...
 
void ClearCellNonHistoricalVariables ()
 Clears the cell non-historical variables. More...
 
void ClearNodalFlags ()
 Clears the nodal flags. More...
 
void ClearCellFlags ()
 Clears the cell flags. More...
 
void ClearNodalContainerExpressions ()
 Clears the nodal container expressions. More...
 
void ClearCellContainerExpressions ()
 Clears the cell container expressions. More...
 
const ModelPartGetModelPart () const
 Returns the model part. More...
 
void PrintOutput (const std::string &rOutputFilenamePrefix)
 Writes the Vtu file. More...
 
- Public Member Functions inherited from Kratos::IO
 IO ()=default
 Default constructor. More...
 
virtual ~IO ()=default
 Destructor. More...
 
 IO (IO const &rOther)=delete
 Copy constructor. More...
 
IOoperator= (IO const &rOther)=delete
 Assignment operator. More...
 
virtual bool ReadNode (NodeType &rThisNode)
 This method reads one node. More...
 
virtual bool ReadNodes (NodesContainerType &rThisNodes)
 This method reads the nodes from an array of nodes. More...
 
virtual std::size_t ReadNodesNumber ()
 This method reads the number of nodes. More...
 
virtual void WriteNodes (NodesContainerType const &rThisNodes)
 This method writes the nodes from an array of nodes. More...
 
virtual void ReadProperties (Properties &rThisProperties)
 This method reads one Properties. More...
 
virtual void ReadProperties (PropertiesContainerType &rThisProperties)
 This method reads the Properties from an array of Properties. More...
 
virtual void WriteProperties (Properties const &rThisProperties)
 This method writes one Properties. More...
 
virtual void WriteProperties (PropertiesContainerType const &rThisProperties)
 This method writes the Properties from an array of Properties. More...
 
virtual void ReadGeometry (NodesContainerType &rThisNodes, GeometryType::Pointer &pThisGeometry)
 This method reads one geometry. More...
 
virtual void ReadGeometries (NodesContainerType &rThisNodes, GeometryContainerType &rThisGeometries)
 This method reads an array of geometries. More...
 
virtual std::size_t ReadGeometriesConnectivities (ConnectivitiesContainerType &rGeometriesConnectivities)
 This method reads the geometries connectivities. More...
 
virtual void WriteGeometries (GeometryContainerType const &rThisGeometries)
 This method writes an array of geometries. More...
 
virtual void ReadElement (NodesContainerType &rThisNodes, PropertiesContainerType &rThisProperties, Element::Pointer &pThisElement)
 This method reads one element. More...
 
virtual void ReadElements (NodesContainerType &rThisNodes, PropertiesContainerType &rThisProperties, ElementsContainerType &rThisElements)
 This method reads an array of elements. More...
 
virtual std::size_t ReadElementsConnectivities (ConnectivitiesContainerType &rElementsConnectivities)
 This method reads the elements connectivities. More...
 
virtual void WriteElements (ElementsContainerType const &rThisElements)
 This method writes an array of elements. More...
 
virtual void ReadCondition (NodesContainerType &rThisNodes, PropertiesContainerType &rThisProperties, Condition::Pointer &pThisCondition)
 This method reads one condition. More...
 
virtual void ReadConditions (NodesContainerType &rThisNodes, PropertiesContainerType &rThisProperties, ConditionsContainerType &rThisConditions)
 This method reads an array of conditions. More...
 
virtual std::size_t ReadConditionsConnectivities (ConnectivitiesContainerType &rConditionsConnectivities)
 This method reads the conditions connectivities. More...
 
virtual void WriteConditions (ConditionsContainerType const &rThisConditions)
 This method writes an array of conditions. More...
 
virtual void ReadInitialValues (ModelPart &rThisModelPart)
 This method reads the initial values of the model part. More...
 
virtual void ReadInitialValues (NodesContainerType &rThisNodes, ElementsContainerType &rThisElements, ConditionsContainerType &rThisConditions)
 This method reads the initial values of the nodes, elements and conditios. More...
 
virtual void ReadMesh (MeshType &rThisMesh)
 This method reads the mesh. More...
 
virtual void WriteMesh (MeshType &rThisMesh)
 This method writes the mesh. More...
 
virtual void WriteMesh (const MeshType &rThisMesh)
 This method writes the mesh. More...
 
virtual void ReadModelPart (ModelPart &rThisModelPart)
 This method reads the model part. More...
 
virtual void WriteModelPart (ModelPart &rThisModelPart)
 This method writes the model part. More...
 
virtual void WriteModelPart (const ModelPart &rThisModelPart)
 This method writes the model part. More...
 
virtual void WriteNodeMesh (MeshType &rThisMesh)
 This method writes the node mesh. More...
 
virtual void WriteNodeMesh (const MeshType &rThisMesh)
 This method writes the node mesh. More...
 
virtual std::size_t ReadNodalGraph (ConnectivitiesContainerType &rAuxConnectivities)
 Read the input file and create the nodal connectivities graph, stored in CSR format. More...
 
virtual void DivideInputToPartitions (SizeType NumberOfPartitions, const PartitioningInfo &rPartitioningInfo)
 This method divides a model part into partitions. More...
 
virtual void DivideInputToPartitions (SizeType NumberOfPartitions, GraphType const &rDomainsColoredGraph, PartitionIndicesType const &rNodesPartitions, PartitionIndicesType const &rElementsPartitions, PartitionIndicesType const &rConditionsPartitions, PartitionIndicesContainerType const &rNodesAllPartitions, PartitionIndicesContainerType const &rElementsAllPartitions, PartitionIndicesContainerType const &rConditionsAllPartitions)
 This method divides a model part into partitions. More...
 
virtual void DivideInputToPartitions (Kratos::shared_ptr< std::iostream > *pStreams, SizeType NumberOfPartitions, const PartitioningInfo &rPartitioningInfo)
 This method divides a model part into partitions. More...
 
virtual void DivideInputToPartitions (Kratos::shared_ptr< std::iostream > *pStreams, SizeType NumberOfPartitions, GraphType const &rDomainsColoredGraph, PartitionIndicesType const &rNodesPartitions, PartitionIndicesType const &rElementsPartitions, PartitionIndicesType const &rConditionsPartitions, PartitionIndicesContainerType const &rNodesAllPartitions, PartitionIndicesContainerType const &rElementsAllPartitions, PartitionIndicesContainerType const &rConditionsAllPartitions)
 This method divides a model part into partitions. More...
 
virtual void ReadSubModelPartElementsAndConditionsIds (std::string const &rModelPartName, std::unordered_set< SizeType > &rElementsIds, std::unordered_set< SizeType > &rConditionsIds)
 
virtual std::size_t ReadNodalGraphFromEntitiesList (ConnectivitiesContainerType &rAuxConnectivities, std::unordered_set< SizeType > &rElementsIds, std::unordered_set< SizeType > &rConditionsIds)
 
virtual std::string Info () const
 Turn back information as a string. More...
 
virtual void PrintInfo (std::ostream &rOStream) const
 Print information about this object. More...
 
virtual void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 
 KRATOS_CLASS_POINTER_DEFINITION (IO)
 Pointer definition of IO. More...
 
 KRATOS_DEFINE_LOCAL_FLAG (READ)
 Local Flags. More...
 
 KRATOS_DEFINE_LOCAL_FLAG (WRITE)
 
 KRATOS_DEFINE_LOCAL_FLAG (APPEND)
 
 KRATOS_DEFINE_LOCAL_FLAG (IGNORE_VARIABLES_ERROR)
 
 KRATOS_DEFINE_LOCAL_FLAG (SKIP_TIMER)
 
 KRATOS_DEFINE_LOCAL_FLAG (MESH_ONLY)
 
 KRATOS_DEFINE_LOCAL_FLAG (SCIENTIFIC_PRECISION)
 

Type definitions

using IndexType = std::size_t
 
using SupportedVariables = 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 > > * >
 
using SupportedCellContainerExpressions = std::variant< ContainerExpression< ModelPart::ConditionsContainerType >::Pointer, ContainerExpression< ModelPart::ElementsContainerType >::Pointer >
 
 KRATOS_CLASS_POINTER_DEFINITION (VtuOutput)
 
 KRATOS_DEFINE_LOCAL_FLAG (NODES)
 
 KRATOS_DEFINE_LOCAL_FLAG (CONDITIONS)
 
 KRATOS_DEFINE_LOCAL_FLAG (ELEMENTS)
 

Detailed Description

Class to output Kratos Flags, Variables and ContainerExpressions to vtu. Supports both shared and distributed memory architectures.

This class does not create or destroy any folder structures, hence the output file name prefix should have a valid parent directory.

Author
Suneth Warnakulasuriya

Member Typedef Documentation

◆ IndexType

using Kratos::VtuOutput::IndexType = std::size_t

◆ SupportedCellContainerExpressions

◆ SupportedVariables

using Kratos::VtuOutput::SupportedVariables = 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> >*>

Member Enumeration Documentation

◆ WriterFormat

Enumerations for the output writer format.

Enumerator
ASCII 
BINARY 

ASCII format.

Binary format.

Constructor & Destructor Documentation

◆ VtuOutput()

Kratos::VtuOutput::VtuOutput ( ModelPart rModelPart,
const bool  IsInitialConfiguration = true,
const WriterFormat  OutputFormat = WriterFormat::BINARY,
const IndexType  Precision = 9 
)

Construct a new Vtu Output IO.

Constructs a new VtuOuput IO instance with the given parameters.

Parameters
rModelPartModel part to be used.
IsInitialConfigurationIf true, the initial configuration is written.
OutputFormatOutput format. Either ASCII or BINARY supported.
PrecisionPrecision of the double output.

Member Function Documentation

◆ AddContainerExpression()

template<class TContainerType >
void Kratos::VtuOutput::AddContainerExpression ( const std::string &  rExpressionName,
const typename ContainerExpression< TContainerType >::Pointer  pContainerExpression 
)

Adds container expressions to the vtu output.

This adds container expressions to the output. Proper care should be taken when updating ContainerExpressions because In python, when a container expression is assigned with a new container expression, it does not call the assignment operator. Hence, the new expression takes place. Therefore, when container expressions required to be outputted, then it is best to always clear the existing container expressions and add the new ones. Otherwise, the vtu output may be writing not the latest container expression.

Template Parameters
TContainerType
Parameters
rExpressionNameName for the container expression.
pContainerExpressionContainer expression.

◆ AddFlagVariable()

void Kratos::VtuOutput::AddFlagVariable ( const std::string &  rFlagName,
const Flags rFlagVariable,
const Flags rEntityFlags 
)

Adds flag output.

Parameters
rFlagNameFlag name.
rFlagVariableVariable to be added.
rEntityFlagsConsidered container for the variable. Either NODES, CONDITIONS or ELEMENTS

◆ AddHistoricalVariable()

template<class TDataType >
template void Kratos::VtuOutput::AddHistoricalVariable ( const Variable< TDataType > &  rVariable)

Adds historical variables to the output.

Template Parameters
TDataType
Parameters
rVariable

◆ AddNonHistoricalVariable()

template<class TDataType >
template void Kratos::VtuOutput::AddNonHistoricalVariable ( const Variable< TDataType > &  rVariable,
const Flags rEntityFlags 
)

Adds non historical variables to the output.

Template Parameters
TDataType
Parameters
rVariableVariable to be added.
rEntityFlagsConsidered container for the variable. Either NODES, CONDITIONS or ELEMENTS

◆ ClearCellContainerExpressions()

void Kratos::VtuOutput::ClearCellContainerExpressions ( )

Clears the cell container expressions.

◆ ClearCellFlags()

void Kratos::VtuOutput::ClearCellFlags ( )

Clears the cell flags.

◆ ClearCellNonHistoricalVariables()

void Kratos::VtuOutput::ClearCellNonHistoricalVariables ( )

Clears the cell non-historical variables.

◆ ClearHistoricalVariables()

void Kratos::VtuOutput::ClearHistoricalVariables ( )

Clears the historical variables.

◆ ClearNodalContainerExpressions()

void Kratos::VtuOutput::ClearNodalContainerExpressions ( )

Clears the nodal container expressions.

◆ ClearNodalFlags()

void Kratos::VtuOutput::ClearNodalFlags ( )

Clears the nodal flags.

◆ ClearNodalNonHistoricalVariables()

void Kratos::VtuOutput::ClearNodalNonHistoricalVariables ( )

Clears the nodal non-historical variables.

◆ GetModelPart()

const ModelPart & Kratos::VtuOutput::GetModelPart ( ) const

Returns the model part.

Returns
The constant reference to the model part.

◆ KRATOS_CLASS_POINTER_DEFINITION()

Kratos::VtuOutput::KRATOS_CLASS_POINTER_DEFINITION ( VtuOutput  )

◆ KRATOS_DEFINE_LOCAL_FLAG() [1/3]

Kratos::VtuOutput::KRATOS_DEFINE_LOCAL_FLAG ( CONDITIONS  )

◆ KRATOS_DEFINE_LOCAL_FLAG() [2/3]

Kratos::VtuOutput::KRATOS_DEFINE_LOCAL_FLAG ( ELEMENTS  )

◆ KRATOS_DEFINE_LOCAL_FLAG() [3/3]

Kratos::VtuOutput::KRATOS_DEFINE_LOCAL_FLAG ( NODES  )

◆ PrintOutput()

void Kratos::VtuOutput::PrintOutput ( const std::string &  rOutputFilenamePrefix)

Writes the Vtu file.

This writes the final vtu file. If this is a transient output, then rOutputFilenamePrefix should have indication of the step, otherwise this will overwrite the same file. In the MPI case, this will create one .vtu file per rank, and a .pvtu file to combine them.

Parameters
rOutputFilenamePrefixOutput file name prefix.

The documentation for this class was generated from the following files: