VtkMeshWriter< ELEMENT_DIM, SPACE_DIM > Class Template Reference

#include <VtkMeshWriter.hpp>

Inherits AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >.

Collaboration diagram for VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 VtkMeshWriter (const std::string &rDirectory, const std::string &rBaseName, const bool &rCleanDirectory=true)
void WriteFiles ()
void AddCellData (std::string name, std::vector< double > data)
void AddCellData (std::string name, std::vector< c_vector< double, SPACE_DIM > > data)
void AddTensorCellData (std::string name, std::vector< c_vector< double, SPACE_DIM *(SPACE_DIM+1)/2 > > data)
void AddTensorCellData (std::string name, std::vector< c_matrix< double, SPACE_DIM, SPACE_DIM > > data)
void AddPointData (std::string name, std::vector< double > data)
void AddPointData (std::string name, std::vector< c_vector< double, SPACE_DIM > > data)
void AddTensorPointData (std::string name, std::vector< c_matrix< double, SPACE_DIM, SPACE_DIM > > data)
void SetParallelFiles (AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
void WriteFilesUsingMesh (AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
void AddProvenance (std::string fileName)
virtual ~VtkMeshWriter ()

Private Member Functions

void MakeVtkMesh ()
void AugmentCellData ()

Private Attributes

bool mWriteParallelFiles
std::map< unsigned, unsignedmGlobalToNodeIndexMap
std::vector< std::vector
< unsigned > > 
mNodesToSendPerProcess
std::vector< std::vector
< unsigned > > 
mNodesToReceivePerProcess
NodesOnlyMesh< SPACE_DIM > * mpNodesOnlyMesh
vtkUnstructuredGrid * mpVtkUnstructedMesh

Detailed Description

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
class VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >

VtkMeshWriter

Writes a mesh in VTK .vtu format (that's an XML-based, data compressed unstructured mesh)

Definition at line 71 of file VtkMeshWriter.hpp.


Constructor & Destructor Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::VtkMeshWriter ( const std::string &  rDirectory,
const std::string &  rBaseName,
const bool rCleanDirectory = true 
) [inline]

Constructor.

Parameters:
rDirectory the directory in which to write the mesh to file
rBaseName the base name of the files in which to write the mesh data
rCleanDirectory whether to clean the directory (defaults to true)

Definition at line 51 of file VtkMeshWriter.cpp.

References AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mIndexFromZero, and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::~VtkMeshWriter (  )  [inline, virtual]

Destructor.

Definition at line 64 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.


Member Function Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddCellData ( std::string  name,
std::vector< c_vector< double, SPACE_DIM > >  data 
) [inline]

Add a vector data field to each element (known as "cell" in VTK).

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the element numbering The length of the data vector is assumed to match the number of elements in the mesh. Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 260 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddCellData ( std::string  name,
std::vector< double data 
) [inline]

Add a scalar data field to each element (known as "cell" in VTK).

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the element numbering The length of the data vector is assumed to match the number of elements in the mesh. Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 212 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

Referenced by AbstractContinuumMechanicsSolver< DIM >::CreateVtkOutput(), VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::MakeVtkMesh(), VtkNonlinearElasticitySolutionWriter< DIM >::Write(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddPointData ( std::string  name,
std::vector< c_vector< double, SPACE_DIM > >  data 
) [inline]

Add a vector data field to each node (known as "point" in VTK).

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the node numbering The length of the data vector is assumed to match the number of nodes in the mesh Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 431 of file VtkMeshWriter.cpp.

References PetscTools::GetMyRank(), PetscTools::GetNumProcs(), VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mGlobalToNodeIndexMap, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mNodesToReceivePerProcess, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mNodesToSendPerProcess, AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpDistributedMesh, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mWriteParallelFiles, and UNUSED_OPT.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddPointData ( std::string  name,
std::vector< double data 
) [inline]
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddProvenance ( std::string  fileName  )  [inline]

Add Chaste provenance data to a VTK file as an XML comment string

Parameters:
fileName is the file name relative to mpOutputFileHandler The file is assumed have been written to and to be closed - so that it can safely be appended to.

Definition at line 173 of file VtkMeshWriter.cpp.

References ChasteBuildInfo::GetProvenanceString(), AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpOutputFileHandler, and OutputFileHandler::OpenOutputFile().

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFiles(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddTensorCellData ( std::string  name,
std::vector< c_matrix< double, SPACE_DIM, SPACE_DIM > >  data 
) [inline]

Add a tensor data field to each element (known as "cell" in VTK).

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the element numbering The length of the data vector is assumed to match the number of elements in the mesh. Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 320 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddTensorCellData ( std::string  name,
std::vector< c_vector< double, SPACE_DIM *(SPACE_DIM+1)/2 > >  data 
) [inline]

Add a symmetric tensor data field to each element (known as "cell" in VTK).

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the element numbering The length of the data vector is assumed to match the number of elements in the mesh. The data vector represents the lower half of the tensor Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 284 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

Referenced by VtkNonlinearElasticitySolutionWriter< DIM >::Write().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddTensorPointData ( std::string  name,
std::vector< c_matrix< double, SPACE_DIM, SPACE_DIM > >  data 
) [inline]

Add a tensor data field to each point.

Parameters:
name is a meaningful name with which to annotate the data
data is the data which should appear in the same order as the node numbering The length of the data vector is assumed to match the number of nodes in the mesh Checking cannot be done at this stage since the data is associated with an empty VTK mesh structure.

Definition at line 515 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh.

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AugmentCellData (  )  [inline, private]

At the time of adding VTK cell data, it is assumed that there is one piece of data for each element in the original mesh. If the mesh is mixed-dimension (elements and cable elements) the VTK mesh makes no distinction between the two types of cells. All data associated with cells must be the same length as the overall number of cells. This method inspects each cell data component and adds dummy data to cover the cable elements.

Definition at line 227 of file VtkMeshWriter.cpp.

References AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::GetNumCableElements(), AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::GetNumElements(), AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpDistributedMesh, AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpMixedMesh, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh, and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mWriteParallelFiles.

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::MakeVtkMesh(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::MakeVtkMesh (  )  [inline, private]
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::SetParallelFiles ( AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &  rMesh  )  [inline]
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFiles (  )  [inline, virtual]
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
void VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh ( AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &  rMesh,
bool  keepOriginalElementIndexing = true 
) [inline, virtual]

Write files. Overrides the method implemented in AbstractTetrahedralMeshWriter, which concentrates mesh data onto a single file in order to output a monolithic file. For VTK, a DistributedTetrahedralMesh in parallel is instead written out as a set of .vtu files (one for each sub-mesh) and a .pvtu file that provides the visualizer with information about them.

Parameters:
rMesh the mesh
keepOriginalElementIndexing Whether to write the mesh with the same element ordering. Optimisations can be applied if this is not needed.
Todo:
#1322 Mesh should really be const!
Todo:
#1322 Mesh should be const

Todo:
This ought to look exactly like the other MakeVtkMesh

Add to the main file

Todo:
#1494 Do we need a barrier?

Reimplemented from AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >.

Definition at line 601 of file VtkMeshWriter.cpp.

References VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddCellData(), VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddProvenance(), PetscTools::AmMaster(), VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AugmentCellData(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetElementIteratorBegin(), AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetElementIteratorEnd(), PetscTools::GetMyRank(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNodeIteratorBegin(), AbstractMesh< ELEMENT_DIM, SPACE_DIM >::GetNodeIteratorEnd(), DistributedTetrahedralMesh< ELEMENT_DIM, SPACE_DIM >::GetNumLocalElements(), PetscTools::GetNumProcs(), OutputFileHandler::GetOutputDirectoryFullPath(), PetscTools::IsSequential(), AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::mBaseName, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mGlobalToNodeIndexMap, AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpDistributedMesh, AbstractTetrahedralMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpMixedMesh, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpNodesOnlyMesh, AbstractMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpOutputFileHandler, VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh, and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mWriteParallelFiles.

Referenced by AbstractContinuumMechanicsSolver< DIM >::CreateVtkOutput(), Hdf5ToVtkConverter< ELEMENT_DIM, SPACE_DIM >::Hdf5ToVtkConverter(), VtkNonlinearElasticitySolutionWriter< DIM >::Write(), and CellBasedPdeHandler< DIM >::WritePdeSolution().


Member Data Documentation

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::map<unsigned, unsigned> VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mGlobalToNodeIndexMap [private]

Map a global node index into a local index (into mNodes and mHaloNodes as if they were concatenated)

Definition at line 79 of file VtkMeshWriter.hpp.

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddPointData(), VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::SetParallelFiles(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector<std::vector<unsigned> > VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mNodesToReceivePerProcess [private]

Used to communicate node-wise halo data

Definition at line 82 of file VtkMeshWriter.hpp.

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddPointData(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::SetParallelFiles().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
std::vector<std::vector<unsigned> > VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mNodesToSendPerProcess [private]

Used to communicate node-wise halo data

Definition at line 81 of file VtkMeshWriter.hpp.

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::AddPointData(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::SetParallelFiles().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
NodesOnlyMesh<SPACE_DIM>* VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpNodesOnlyMesh [private]

A pointer to a NodesOnlyMesh to write to file, created by dynamic cast

Definition at line 85 of file VtkMeshWriter.hpp.

Referenced by VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::SetParallelFiles(), and VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::WriteFilesUsingMesh().

template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
vtkUnstructuredGrid* VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mpVtkUnstructedMesh [private]
template<unsigned ELEMENT_DIM, unsigned SPACE_DIM>
bool VtkMeshWriter< ELEMENT_DIM, SPACE_DIM >::mWriteParallelFiles [private]

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

Generated by  doxygen 1.6.2