From f06b37dfade6522246ba6a6ba3e401b4f322df1d Mon Sep 17 00:00:00 2001 From: Christoph Niethammer Date: Mon, 26 Feb 2024 12:45:31 +0100 Subject: [PATCH] Remove VISWriter plugin as the file format is deprecated For writing of output files for the MegaMol visualisation tool, the new MMPLDWriter and MMPLD file format should be used instead of the deprecated VISWriter and file format. Signed-off-by: Christoph Niethammer --- doc/Plugins_Summary.dox | 1 - examples/all-options.xml | 11 --- src/io/VISWriter.cpp | 144 ---------------------------------- src/io/VISWriter.h | 55 ------------- src/plugins/PluginFactory.cpp | 2 - 5 files changed, 213 deletions(-) delete mode 100644 src/io/VISWriter.cpp delete mode 100644 src/io/VISWriter.h diff --git a/doc/Plugins_Summary.dox b/doc/Plugins_Summary.dox index 2993e3c07c..38f0022b5c 100644 --- a/doc/Plugins_Summary.dox +++ b/doc/Plugins_Summary.dox @@ -60,7 +60,6 @@ TestPlugin | test | Test correctness of plugin calls within Simulation. Simpler TimerWriter | Timers, mpi, print, load balance | Prints the average time for the specified timers as a transient. Separate output for each rank. Can be used to gather information of the load balance. VectorizationTuner | todo | todo VelocityExchange | temperature gradient | Swap the velocities and angular momentum of two particles. One particle is the warmest (fastest) in the specified cold region, the other one is the coldest (slowest) in the specified warm region. -VISWriter | visualization, particle configurations, MegaMol | Output plugin writing visualization files containing multiple subsequently sampled frames of particle configurations in the deprecated *.vis MegaMol file format. VTKGridWriter | vtk, grid | Write MPI rank, number of molecules in each cell in a .vtu or .pvtu file. Requires compiling with VTK=1. VTKMoleculeWriter | vtk, visualization | Write a .vtu or .pvtu file with the molecules for visualiziation in ParaView. Requires compiling with VTK=1. WallPotential | potential, Wall, Lennard-Jones | Exerts the force of a Lennard-Jones (9-3 or 10-4) potential on the specified components or all particles. diff --git a/examples/all-options.xml b/examples/all-options.xml index 64a3d9a9bc..98c3b7e78f 100644 --- a/examples/all-options.xml +++ b/examples/all-options.xml @@ -311,7 +311,6 @@ - CheckpointWriter - ResultWriter - XyzWriter - - VISWriter - MmspdWriter - PovWriter - StatisticsWriter @@ -385,16 +384,6 @@ default - - - 10 - default - - diff --git a/src/io/VISWriter.cpp b/src/io/VISWriter.cpp deleted file mode 100644 index 55e64e84d5..0000000000 --- a/src/io/VISWriter.cpp +++ /dev/null @@ -1,144 +0,0 @@ -#include "io/VISWriter.h" - -#include -#include -#include - -#include "Common.h" -#include "molecules/Molecule.h" -#include "parallel/DomainDecompBase.h" -#include "particleContainer/ParticleContainer.h" -#include "Simulation.h" -#include "utils/Logger.h" - -#ifdef ENABLE_MPI -#include -#endif - - -VISWriter::VISWriter(unsigned long writeFrequency, std::string outputPrefix) { - _outputPrefix = outputPrefix; - _writeFrequency = writeFrequency; - _wroteVIS = false; - - if (outputPrefix == "default") { - _appendTimestamp = true; - } - else { - _appendTimestamp = false; - } -} - -VISWriter::~VISWriter(){} - -void VISWriter::readXML(XMLfileUnits& xmlconfig) { - _writeFrequency = 1; - xmlconfig.getNodeValue("writefrequency", _writeFrequency); - Log::global_log->info() << "Write frequency: " << _writeFrequency << std::endl; - - _outputPrefix = "mardyn"; - xmlconfig.getNodeValue("outputprefix", _outputPrefix); - Log::global_log->info() << "Output prefix: " << _outputPrefix << std::endl; - - int appendTimestamp = 0; - xmlconfig.getNodeValue("appendTimestamp", appendTimestamp); - if(appendTimestamp > 0) { - _appendTimestamp = true; - } - Log::global_log->info() << "Append timestamp: " << _appendTimestamp << std::endl; -} - -void VISWriter::init(ParticleContainer * /*particleContainer*/, - DomainDecompBase * /*domainDecomp*/, Domain * /*domain*/) { - std::string filename = _outputPrefix + ".vis"; - std::ofstream fileout(filename.c_str(), std::ios::out); - fileout.close(); -} - -void VISWriter::endStep(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain * /*domain*/, - unsigned long simstep) { - if (simstep % _writeFrequency == 0) { - std::stringstream filenamestream, outputstream; - filenamestream << _outputPrefix; - - if(_appendTimestamp) { - filenamestream << "-" << gettimestring(); - } - filenamestream << ".vis"; - - std::vector filename(filenamestream.str().size()+1); - strcpy(filename.data(),filenamestream.str().c_str()); - -#ifdef ENABLE_MPI - int rank = domainDecomp->getRank(); - int numprocs = domainDecomp->getNumProcs(); - if (rank== 0){ -#endif - if (!_wroteVIS){ - outputstream << " id t x y z q0 q1 q2 q3 c\n"; - _wroteVIS = true; - } - else - outputstream << "#" << std::endl; -#ifdef ENABLE_MPI - } -#endif - - // originally VIS files had a fixed width of 8 (and no t), here I use 12 (with 2 for t) - //ostrm << "t x y z q0 q1 q2 q3" << std::endl; - for (auto pos = particleContainer->iterator(ParticleIterator::ONLY_INNER_AND_BOUNDARY); pos.isValid(); ++pos) { - bool halo = false; - for (unsigned short d = 0; d < 3; d++) { - if ((pos->r(d) < particleContainer->getBoundingBoxMin(d)) || (pos->r(d) > particleContainer->getBoundingBoxMax(d))) { - halo = true; - break; - } - } - if (!halo) { - outputstream << setiosflags(std::ios::fixed) << std::setw(8) << pos->getID() << std::setw(2) - << pos->componentid() << std::setprecision(3); - for (unsigned short d = 0; d < 3; d++) outputstream << std::setw(11) << pos->r(d); - outputstream << std::setprecision(3) << std::setw(7) << pos->q().qw() << std::setw(7) << pos->q().qx() - << std::setw(7) << pos->q().qy()<< std::setw(7) << pos->q().qz() - << std::setw(9) << std::right << 0 << "\n"; - } - } - long outputsize = outputstream.str().size(); - - std::vector output(outputsize+1); - strcpy(output.data(),outputstream.str().c_str()); -#ifdef ENABLE_MPI - MPI_File fh; - MPI_File_open(MPI_COMM_WORLD, filename.data(), MPI_MODE_WRONLY|MPI_MODE_APPEND, MPI_INFO_NULL, &fh); - - for (int dest = rank+1; dest < numprocs; dest++){ - int sendcount = 1; - int sendtag = 0; - MPI_Request request; - MPI_Isend(&outputsize, sendcount, MPI_LONG, dest, sendtag, MPI_COMM_WORLD, &request); - } - MPI_Status status; - long offset = 0; - long outputsize_get; - for (int source = 0; source < rank; source++){ - int recvcount = 1; - int recvtag = 0; - MPI_Recv(&outputsize_get, recvcount, MPI_LONG, source, recvtag, MPI_COMM_WORLD, &status); - offset += outputsize_get; - } - - MPI_File_seek(fh, offset, MPI_SEEK_END); - MPI_Barrier(MPI_COMM_WORLD); - MPI_File_write(fh, output.data(), outputsize, MPI_CHAR, &status); - MPI_File_close(&fh); -#else - std::ofstream fileout(filename.data(), std::ios::out|std::ios::app); - fileout << output.data(); - fileout.close(); -#endif - } -} - -void VISWriter::finish(ParticleContainer * /*particleContainer*/, DomainDecompBase * /*domainDecomp*/, - Domain * /*domain*/) {} diff --git a/src/io/VISWriter.h b/src/io/VISWriter.h deleted file mode 100644 index 6ac9133144..0000000000 --- a/src/io/VISWriter.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef VISWRITER_H_ -#define VISWRITER_H_ - -#include "plugins/PluginBase.h" -#include "Domain.h" -#include -#include - -class ParticleContainer; -class DomainDecompBase; -class Domain; - -class VISWriter : public PluginBase { -public: - VISWriter(){} - //! @brief Writes out a file (using *.vis-format) containing coordinates + orientation (using quaternions) - //! of each molecule for several timesteps. - //! - //! Depending on write frequency (for example: every timestep, or every 10th, 100th, 1000th ...) number of frames - //! can be controlled. The *.vis-file can be visualized by visualization software like: - //! - MolCloud (visit: http://www.visus.uni-stuttgart.de/index.php?id=995) - //! - MegaMol (visit: https://svn.vis.uni-stuttgart.de/trac/megamol/) - //! - //! @param filename Name of the *.vis-file (including path) - //! @param particleContainer The molecules that have to be written to the file are stored here - //! @param domainDecomp In the parallel version, the file has to be written by more than one process. - //! Methods to achieve this are available in domainDecomp - //! @param writeFrequency Controls the frequency of writing out the data (every timestep, every 10th, 100th, ... timestep) - VISWriter(unsigned long writeFrequency, std::string outputPrefix); - ~VISWriter(); - - void readXML(XMLfileUnits& xmlconfig); - - void init(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); - void endStep( - ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain, - unsigned long simstep - ); - void finish(ParticleContainer *particleContainer, - DomainDecompBase *domainDecomp, Domain *domain); - - std::string getPluginName() { - return std::string("VISWriter"); - } - static PluginBase* createInstance() { return new VISWriter(); } -private: - std::string _outputPrefix; - unsigned long _writeFrequency; - bool _appendTimestamp; - bool _wroteVIS; -}; - -#endif /* VISWRITER_H_ */ diff --git a/src/plugins/PluginFactory.cpp b/src/plugins/PluginFactory.cpp index 8781b56cfa..9c541562b7 100644 --- a/src/plugins/PluginFactory.cpp +++ b/src/plugins/PluginFactory.cpp @@ -35,7 +35,6 @@ #include "io/ResultWriter.h" #include "io/SysMonOutput.h" #include "io/TimerWriter.h" -#include "io/VISWriter.h" #include "io/XyzWriter.h" // General plugins @@ -133,7 +132,6 @@ void PluginFactory::registerDefaultPlugins() { REGISTER_PLUGIN(TestPlugin); REGISTER_PLUGIN(TimerWriter); REGISTER_PLUGIN(VectorizationTuner); - REGISTER_PLUGIN(VISWriter); REGISTER_PLUGIN(WallPotential); REGISTER_PLUGIN(XyzWriter); #ifdef VTK