Files
LBPM/IO/Reader.h

113 lines
4.2 KiB
C
Raw Normal View History

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/>.
*/
#ifndef READER_INC
#define READER_INC
#include <iostream>
2019-03-18 09:42:44 -04:00
#include <memory>
#include <string.h>
#include <vector>
#include "IO/Mesh.h"
#include "IO/MeshDatabase.h"
namespace IO {
//! Get the path to a file
2021-03-17 10:24:14 -04:00
std::string getPath( const std::string &filename );
2021-03-17 10:24:14 -04:00
/*!
* @brief Get the maximum number of domains written
* @details This function reads the summary files to determine the maximum
* number of domains in the output.
* @param[in] path The path to use for reading
* @param[in] format The data format to use:
* old - Old mesh format (provided for backward compatibility)
* new - New format, 1 file/process
* silo - Silo
* auto - Auto-determin the format
* @param[in] comm Optional comm to use to reduce IO load by
* reading on rank 0 and then communicating the result
*/
int maxDomains( const std::string &path, const std::string &format = "auto",
const Utilities::MPI &comm = MPI_COMM_SELF );
2021-03-16 17:21:52 -04:00
/*!
* @brief Read the timestep list
* @details This function reads the timestep list from the summary file.
* @param[in] path The path to use for reading
* @param[in] format The data format to use:
2021-03-17 10:24:14 -04:00
* old - Old mesh format (provided for backward compatibility)
* new - New format, 1 file/process
* silo - Silo
* auto - Auto-determin the format
* @return append Append any existing data (default is false)
2021-03-16 17:21:52 -04:00
*/
2021-03-17 10:24:14 -04:00
std::vector<std::string> readTimesteps(
const std::string &path, const std::string &format = "auto" );
2021-03-16 17:21:52 -04:00
/*!
* @brief Read the data for the timestep
* @details This function reads the mesh and variable data provided for the given timestep.
* @param[in] path The path to use for reading
* @param[in] timestep The timestep iteration
2021-03-17 10:24:14 -04:00
* @param[in] domain The desired domain to read
2021-03-16 17:21:52 -04:00
*/
2021-03-17 10:24:14 -04:00
std::vector<IO::MeshDataStruct> readData(
const std::string &path, const std::string &timestep, int domain );
//! Read the list of mesh databases for the given timestep
2021-03-17 10:24:14 -04:00
std::vector<IO::MeshDatabase> getMeshList( const std::string &path, const std::string &timestep );
//! Read the given mesh domain
2021-03-17 10:24:14 -04:00
std::shared_ptr<IO::Mesh> getMesh( const std::string &path, const std::string &timestep,
const MeshDatabase &meshDatabase, int domain );
2014-11-04 21:58:20 -05:00
/*!
* @brief Read the given variable
* @details This function reads the variable data provided for the current timestep
* @param[in] path The path to the file
* @param[in] timestep The timestep iteration
* @param[in] meshDatabase The mesh database (see getMeshList)
* @param[in] domain The index of the domain we want to read
* @param[in] variable The variable name to read
* @return Returns the variable data as a linear array
*/
2021-03-17 10:24:14 -04:00
std::shared_ptr<IO::Variable> getVariable( const std::string &path, const std::string &timestep,
const MeshDatabase &meshDatabase, int domain, const std::string &variable );
/*!
* @brief Reformat the variable to match the mesh
* @details This function modifies the dimensions of the array to match the mesh
* @param[in] mesh The underlying mesh
2021-09-13 11:51:21 -04:00
* @param[in,out] var The variable name to read
*/
2021-03-17 10:24:14 -04:00
void reformatVariable( const IO::Mesh &mesh, IO::Variable &var );
2021-03-17 10:24:14 -04:00
} // namespace IO
#endif