2018-06-11 15:19:05 -04:00
|
|
|
/*
|
|
|
|
|
Copyright 2013--2018 James E. McClure, Virginia Polytechnic & State University
|
|
|
|
|
|
|
|
|
|
This file is part of the Open Porous Media project (OPM).
|
|
|
|
|
OPM is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
(at your option) any later version.
|
|
|
|
|
OPM is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
|
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
2014-09-09 14:42:13 -04:00
|
|
|
#ifndef WRITER_INC
|
|
|
|
|
#define WRITER_INC
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include "IO/Mesh.h"
|
|
|
|
|
#include "IO/MeshDatabase.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace IO {
|
|
|
|
|
|
|
|
|
|
|
2017-01-23 10:42:21 -05:00
|
|
|
/*!
|
|
|
|
|
* @brief Initialize the writer
|
2021-03-17 10:24:14 -04:00
|
|
|
* @details This function initializes the writer to the given path.
|
|
|
|
|
* All subsequent writes will occur in this directory.
|
|
|
|
|
* If this is not called, then it will default to the current path.
|
2017-01-23 10:42:21 -05:00
|
|
|
* @param[in] path The path to use for writes
|
|
|
|
|
* @param[in] format The data format to use:
|
2021-03-17 10:24:14 -04:00
|
|
|
* old - Old mesh format
|
|
|
|
|
* (provided for backward compatibility, cannot write variables)
|
2021-06-02 15:36:44 -04:00
|
|
|
* new - New format, 1 file/process
|
|
|
|
|
* silo - Silo
|
|
|
|
|
* hdf5 - HDF5 + XMDF
|
2017-01-23 10:42:21 -05:00
|
|
|
* @param[in] append Append any existing data (default is false)
|
|
|
|
|
*/
|
2021-03-17 10:24:14 -04:00
|
|
|
void initialize(
|
2021-06-02 15:36:44 -04:00
|
|
|
const std::string &path = "", const std::string &format = "hdf5", bool append = false );
|
2017-01-23 10:42:21 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* @brief Write the data for the timestep
|
|
|
|
|
* @details This function writes the mesh and variable data provided for the current timestep
|
|
|
|
|
* @param[in] subdir The subdirectory to use for the timestep
|
|
|
|
|
* @param[in] meshData The data to write
|
|
|
|
|
* @param[in] comm The comm to use for writing (usually MPI_COMM_WORLD or a dup thereof)
|
|
|
|
|
*/
|
2021-03-17 10:24:14 -04:00
|
|
|
void writeData( const std::string &subdir, const std::vector<IO::MeshDataStruct> &meshData,
|
|
|
|
|
const Utilities::MPI &comm );
|
2017-01-23 10:42:21 -05:00
|
|
|
|
|
|
|
|
|
2014-11-04 21:58:20 -05:00
|
|
|
/*!
|
|
|
|
|
* @brief Write the data for the timestep
|
|
|
|
|
* @details This function writes the mesh and variable data provided for the current timestep
|
|
|
|
|
* @param[in] timestep The timestep iteration
|
|
|
|
|
* @param[in] meshData The data to write
|
2015-09-04 13:06:36 -04:00
|
|
|
* @param[in] comm The comm to use for writing (usually MPI_COMM_WORLD or a dup thereof)
|
2014-11-04 21:58:20 -05:00
|
|
|
*/
|
2021-03-17 10:24:14 -04:00
|
|
|
inline void writeData(
|
|
|
|
|
int timestep, const std::vector<IO::MeshDataStruct> &meshData, const Utilities::MPI &comm )
|
2017-01-23 10:42:21 -05:00
|
|
|
{
|
|
|
|
|
char subdir[100];
|
2021-03-17 10:24:14 -04:00
|
|
|
sprintf( subdir, "vis%03i", timestep );
|
2017-01-23 10:42:21 -05:00
|
|
|
writeData( subdir, meshData, comm );
|
|
|
|
|
}
|
2014-09-09 14:42:13 -04:00
|
|
|
|
|
|
|
|
|
2021-06-02 15:36:44 -04:00
|
|
|
// Create the database entry for the mesh data
|
|
|
|
|
IO::MeshDatabase getDatabase(
|
|
|
|
|
const std::string &filename, const IO::MeshDataStruct &mesh, IO::FileFormat format, int rank );
|
|
|
|
|
|
|
|
|
|
|
2021-03-17 10:24:14 -04:00
|
|
|
} // namespace IO
|
2014-09-09 14:42:13 -04:00
|
|
|
|
|
|
|
|
#endif
|