Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include "AlbPUMI_FMDBVtk.hpp"
00008
00009 AlbPUMI::FMDBVtk::
00010 FMDBVtk(FMDBMeshStruct& meshStruct, const Teuchos::RCP<const Epetra_Comm>& comm_) :
00011 comm(comm_),
00012 doCollection(false),
00013 mesh(meshStruct.apfMesh),
00014 remeshFileIndex(1),
00015 outputFileName(meshStruct.outputFileName) {
00016
00017
00018 std::ostringstream ss;
00019 std::string str = outputFileName;
00020 size_t found = str.find("vtk");
00021
00022 if(found != std::string::npos){
00023
00024 doCollection = true;
00025
00026 if(comm->MyPID() == 0){
00027
00028 str.replace(found, 3, "pvd");
00029
00030 const char* cstr = str.c_str();
00031
00032 vtu_collection_file.open(cstr);
00033
00034 vtu_collection_file << "<\?xml version=\"1.0\"\?>" << std::endl
00035 << " <VTKFile type=\"Collection\" version=\"0.1\">" << std::endl
00036 << " <Collection>" << std::endl;
00037 }
00038
00039 }
00040
00041 }
00042
00043 AlbPUMI::FMDBVtk::
00044 ~FMDBVtk() {
00045
00046 if(doCollection && (comm->MyPID() == 0)){
00047
00048 vtu_collection_file << " </Collection>" << std::endl
00049 << "</VTKFile>" << std::endl;
00050 vtu_collection_file.close();
00051
00052 }
00053
00054 }
00055
00056 void
00057 AlbPUMI::FMDBVtk::
00058 writeFile(const double time_value){
00059 if(doCollection){
00060 if(comm->MyPID() == 0){
00061 std::string vtu_filename = outputFileName;
00062 std::ostringstream vtu_ss;
00063 vtu_ss << "_" << remeshFileIndex << "_.pvtu";
00064 vtu_filename.replace(vtu_filename.find(".vtk"), 4, vtu_ss.str());
00065 vtu_collection_file << " <DataSet timestep=\"" << time_value << "\" group=\"\" part=\"0\" file=\""
00066 << vtu_filename << "\"/>" << std::endl;
00067 }
00068 std::string filename = outputFileName;
00069 std::string vtk_filename = outputFileName;
00070 std::ostringstream vtk_ss;
00071 vtk_ss << "_" << remeshFileIndex << "_";
00072 vtk_filename.replace(vtk_filename.find(".vtk"), 4, vtk_ss.str());
00073 const char* cstr = vtk_filename.c_str();
00074 apf::writeVtkFiles(cstr,mesh);
00075 }
00076 else {
00077 std::string filename = outputFileName;
00078 filename.replace(filename.find(".vtk"), 4, "");
00079 const char* cstr = filename.c_str();
00080 apf::writeVtkFiles(cstr,mesh);
00081 }
00082 remeshFileIndex++;
00083
00084 }
00085
00086 void
00087 AlbPUMI::FMDBVtk::
00088 debugMeshWrite(const char* fn){
00089 apf::writeVtkFiles(fn,mesh);
00090 }