![]() |
Gowdy solver
|
Reads the initial data from the given file. More...
#include <gridInitialData.h>
Public Member Functions | |
GridInitialData (Parameters ¶ms, UniformGrid &ug) | |
The list of grid functions. | |
void | gridFunctions (const std::vector< Int > &gfs) |
The given grid functions will be read as the initial data. | |
bool | load () |
Loads the initial data. | |
Private Attributes | |
UniformGrid * | gridDriver |
The grid. | |
bool | binaryFormat |
Read binary data from the input file. | |
std::string | fileName |
Input filename. | |
std::vector< Int > | input |
Reads the initial data from the given file.
Definition at line 10 of file gridInitialData.h.
GridInitialData::GridInitialData | ( | Parameters & | params, |
UniformGrid & | ug | ||
) | [inline] |
The list of grid functions.
Constructs the initial data reader as specified in the parameter file.
Definition at line 21 of file gridInitialData.h.
References binaryFormat, fileName, Parameters::get(), input, fld::r, and slog.
: gridDriver(&ug), binaryFormat(false) { input.reserve( 100 ); input.push_back( fld::r ); params.get( "input.file", fileName, "stdin" ); params.get( "input.binary", binaryFormat, true ); slog << "Initial Data:" << std::endl << std::endl << " file = " << fileName << ", binary = " << binaryFormat << std::endl << std::endl; }
void GridInitialData::gridFunctions | ( | const std::vector< Int > & | gfs | ) | [inline] |
The given grid functions will be read as the initial data.
Definition at line 37 of file gridInitialData.h.
References input.
bool GridInitialData::load | ( | ) | [inline] |
Loads the initial data.
Definition at line 44 of file gridInitialData.h.
References binaryFormat, fileName, UniformGrid::get_grid(), UniformGrid::get_nGhost(), UniformGrid::get_nLen(), gridDriver, input, UniformGrid::mpiRank(), UniformGrid::mpiSize(), and IORecord::read().
{ GridPoint** grid = gridDriver->get_grid (); Int nLen = gridDriver->get_nLen (); Int nGhost = gridDriver->get_nGhost (); FILE* inf = fileName == "stdin" ? stdin : fopen( fileName.c_str(), binaryFormat ? "rb" : "r" ); if( ! inf ) { std::cerr << "Error: Could not open " << fileName << std::endl; return false; } // If using MPI, offset the initial data depending on our rank if ( gridDriver->mpiSize () > 1 ) { for( Int n = 0; n < nLen * gridDriver->mpiRank(); ++n ) { if( ! IORecord( grid[0][0] ).read( inf, binaryFormat, input ) ) { // dummy read return false; } } } for( Int n = nGhost; n < nGhost + nLen; ++n ) { if( ! IORecord( grid[0][n] ).read( inf, binaryFormat, input ) ) { return false; } } if ( inf != stdin ) { fclose( inf ); } return true; }
bool GridInitialData::binaryFormat [private] |
Read binary data from the input file.
Definition at line 13 of file gridInitialData.h.
Referenced by GridInitialData(), and load().
std::string GridInitialData::fileName [private] |
Input filename.
Definition at line 14 of file gridInitialData.h.
Referenced by GridInitialData(), and load().
UniformGrid* GridInitialData::gridDriver [private] |
std::vector<Int> GridInitialData::input [private] |
Definition at line 15 of file gridInitialData.h.
Referenced by gridFunctions(), GridInitialData(), and load().