Enable parallel tests.
[hoomd-blue.git] / libhoomd / analyzers / HOOMDBinaryDumpWriter.h
blobb587c46656d16ddd3c3253293ee33abed16a9aa3
1 /*
2 Highly Optimized Object-oriented Many-particle Dynamics -- Blue Edition
3 (HOOMD-blue) Open Source Software License Copyright 2009-2014 The Regents of
4 the University of Michigan All rights reserved.
6 HOOMD-blue may contain modifications ("Contributions") provided, and to which
7 copyright is held, by various Contributors who have granted The Regents of the
8 University of Michigan the right to modify and/or distribute such Contributions.
10 You may redistribute, use, and create derivate works of HOOMD-blue, in source
11 and binary forms, provided you abide by the following conditions:
13 * Redistributions of source code must retain the above copyright notice, this
14 list of conditions, and the following disclaimer both in the code and
15 prominently in any materials provided with the distribution.
17 * Redistributions in binary form must reproduce the above copyright notice, this
18 list of conditions, and the following disclaimer in the documentation and/or
19 other materials provided with the distribution.
21 * All publications and presentations based on HOOMD-blue, including any reports
22 or published results obtained, in whole or in part, with HOOMD-blue, will
23 acknowledge its use according to the terms posted at the time of submission on:
24 http://codeblue.umich.edu/hoomd-blue/citations.html
26 * Any electronic documents citing HOOMD-Blue will link to the HOOMD-Blue website:
27 http://codeblue.umich.edu/hoomd-blue/
29 * Apart from the above required attributions, neither the name of the copyright
30 holder nor the names of HOOMD-blue's contributors may be used to endorse or
31 promote products derived from this software without specific prior written
32 permission.
34 Disclaimer
36 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ``AS IS'' AND
37 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
38 WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND/OR ANY
39 WARRANTIES THAT THIS SOFTWARE IS FREE OF INFRINGEMENT ARE DISCLAIMED.
41 IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
42 INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
43 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
44 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
45 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46 OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
47 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50 // Maintainer: joaander
52 /*! \file HOOMDBinaryDumpWriter.h
53 \brief Declares the HOOMDBinaryDumpWriter class
56 #ifdef NVCC
57 #error This header cannot be compiled by nvcc
58 #endif
60 #include <string>
62 #include <boost/shared_ptr.hpp>
64 #include "Analyzer.h"
65 #include "BondedGroupData.h"
67 #ifndef __HOOMD_BINARY_DUMP_WRITER_H__
68 #define __HOOMD_BINARY_DUMP_WRITER_H__
70 //! Analyzer for writing out HOOMD dump files
71 /*! HOOMDBinaryDumpWriter can be used to write out xml files containing various levels of information
72 of the current time step of the simulation. At a minimum, the current time step and box
73 dimensions are output. Optionally, particle positions, velocities and types can be included
74 in the file.
76 Usage:<br>
77 Construct a HOOMDBinaryDumpWriter, attaching it to a ParticleData and specifying a base file name.
78 Call analyze(timestep) to output a dump file with the state of the current time step
79 of the simulation. It will create base_file.timestep.xml where timestep is a 0-padded
80 10 digit number. The 0 padding is so files sorted "alphabetically" will be read in
81 numberical order.
83 To include positions, velocities and types, see: setOutputPosition() setOutputVelocity()
84 and setOutputType(). Similarly, walls and bonds can be included with setOutputWall() and
85 setOutputBond().
87 Future versions will include the ability to dump forces on each particle to the file also.
89 For information on the structure of the xml file format: see \ref page_dev_info
90 Although, HOOMD's user guide probably has a more up to date documentation on the format.
91 \ingroup analyzers
93 class HOOMDBinaryDumpWriter : public Analyzer
95 public:
96 //! Construct the writer
97 HOOMDBinaryDumpWriter(boost::shared_ptr<SystemDefinition> sysdef, std::string base_fname);
99 //! Destructor
100 ~HOOMDBinaryDumpWriter();
102 //! Write out the data for the current timestep
103 void analyze(unsigned int timestep);
104 //! Writes a file at the current time step
105 void writeFile(std::string fname, unsigned int timestep);
106 //! Set the alternating mode
107 void setAlternatingWrites(const std::string& fname1, const std::string& fname2);
108 //! Enable or disable gzip compression of the binary output files
109 void enableCompression(bool enable_compression);
110 private:
111 std::string m_base_fname; //!< String used to store the file name of the XML file
112 std::string m_fname1; //!< File name for the first file to write to in alternating mode
113 std::string m_fname2; //!< File name for the second file to write to in alternating mode
114 bool m_alternating; //!< True if we are to write to m_fname1 and m_fname in an alternating fasion
115 unsigned int m_cur_file; //!< Current index of the file we are writing to (1 or 2)
116 bool m_enable_compression; //!< True if gzip compression should be enabled
119 //! Exports the HOOMDBinaryDumpWriter class to python
120 void export_HOOMDBinaryDumpWriter();
122 #endif