37 #include "Hdf5ToVtkConverter.hpp"
40 #include "ReplicatableVector.hpp"
41 #include "DistributedVector.hpp"
42 #include "DistributedVectorFactory.hpp"
43 #include "VtkMeshWriter.hpp"
44 #include "GenericMeshReader.hpp"
45 #include "DistributedTetrahedralMesh.hpp"
46 #include "Warnings.hpp"
48 template <
unsigned ELEMENT_DIM,
unsigned SPACE_DIM>
50 const std::string& rFileBaseName,
53 bool usingOriginalNodeOrdering)
54 :
AbstractHdf5Converter<ELEMENT_DIM,SPACE_DIM>(rInputDirectory, rFileBaseName, pMesh,
"vtk_output",0u)
56 #ifdef CHASTE_VTK // Requires "sudo aptitude install libvtk5-dev" or similar
75 if (p_distributed_mesh == NULL)
77 WARNING(
"Can only write parallel VTK from a DistributedTetrahedralMesh - writing sequential VTK instead");
82 if (usingOriginalNodeOrdering)
84 WARNING(
"Can't write parallel VTK (pvtu) files with original ordering - writing sequential VTK instead");
103 unsigned num_timesteps = this->
mpReader->GetUnlimitedDimensionValues().size();
106 for (
unsigned time_step=0; time_step<num_timesteps; time_step++)
109 for (
unsigned variable=0; variable<this->
mNumVariables; variable++)
111 std::string variable_name = this->
mpReader->GetVariableNames()[variable];
114 this->
mpReader->GetVariableOverNodes(data, variable_name, time_step);
116 std::vector<double> data_for_vtk;
117 data_for_vtk.resize(num_nodes);
118 std::ostringstream variable_point_data_name;
119 variable_point_data_name << variable_name <<
"_" << std::setw(6) << std::setfill(
'0') << time_step;
125 VecGetArray(data, &p_data);
126 for (
unsigned index=0; index<num_nodes; index++)
128 data_for_vtk[index] = p_data[index];
130 VecRestoreArray(data, &p_data);
136 for (
unsigned index=0; index<num_nodes; index++)
138 data_for_vtk[index] = repl_data[index];
142 vtk_writer.
AddPointData(variable_point_data_name.str(), data_for_vtk);
152 if (!usingOriginalNodeOrdering)
161 std::string original_file = this->
mpMesh->GetMeshFileBaseName();
162 std::auto_ptr<AbstractMeshReader<ELEMENT_DIM, SPACE_DIM> > p_original_mesh_reader
163 = GenericMeshReader<ELEMENT_DIM, SPACE_DIM>(original_file);
virtual DistributedVectorFactory * GetDistributedVectorFactory()
Hdf5ToVtkConverter(const FileFinder &rInputDirectory, const std::string &rFileBaseName, AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > *pMesh, bool parallelVtk, bool usingOriginalNodeOrdering)
unsigned GetNumLocalNodes() const
std::string mRelativeSubdirectory
boost::shared_ptr< Hdf5DataReader > mpReader
void SetParallelFiles(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh)
void WriteFilesUsingMeshReader(AbstractMeshReader< ELEMENT_DIM, SPACE_DIM > &rMeshReader)
virtual unsigned GetNumNodes() const
void WriteFilesUsingMesh(AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > &rMesh, bool keepOriginalElementIndexing=true)
bool MoveOntoNextDataset()
AbstractTetrahedralMesh< ELEMENT_DIM, SPACE_DIM > * mpMesh
std::string GetRelativePath(const FileFinder &rBasePath) const
void AddPointData(std::string name, std::vector< double > data)