23#include <ncGroupAtt.h>
29std::string structureNameFromFile(
const std::string& filePath)
31 netCDF::NcFile ncf(filePath, netCDF::NcFile::read);
34 int len = att.getAttLength();
36 std::string structureName(len,
'\0');
38 att.getValues(&structureName[0]);
46 std::string structureName = structureNameFromFile(filePath);
48 if (DevGrid::structureName == structureName) {
49 Module::setImplementation<IStructure>(
"DevGrid");
53 }
else if (RectangularGrid::structureName == structureName) {
54 Module::setImplementation<IStructure>(
"RectangularGrid");
58 }
else if (ParametricGrid::structureName == structureName) {
59 Module::setImplementation<IStructure>(
"ParametricGrid");
64 throw std::invalid_argument(
65 std::string(
"fileFromName: structure not implemented: ") + structureName);
67 throw std::invalid_argument(std::string(
"fileFromName: structure not implemented: ")
68 + structureName +
"\nAlso, how did you get here?");
75 std::string structureName = Module::getImplementation<IStructure>().structureType();
77 if (DevGrid::structureName == structureName) {
81 }
else if (RectangularGrid::structureName == structureName) {
85 }
else if (ParametricGrid::structureName == structureName) {
90 throw std::invalid_argument(
91 std::string(
"fileFromName: structure not implemented: ") + structureName);
A class to hold a grid of ElementData instances in a fixed sized square grid.
void dumpModelState(const ModelState &state, const ModelMetadata &metadata, const std::string &filePath, bool isRestart=false) const override
Dumps the data to a file path.
void setIO(IDevGridIO *p)
Sets the pointer to the class that will perform the IO. Should be an instance of DevGridIO.
ModelState getModelState(const std::string &filePath) override
Dumps the data to a file path.
A class to implemented the actual IO for DevGrid, isolating the NetCDF libraries from the rest of the...
static const std::string typeNodeName()
The name of the node holding the name of the structure type processed by this class.
static const std::string structureNodeName()
The name of the group holding the definitive structure type.
A class to hold the grid data for parameterised rectangular grids.
void dumpModelState(const ModelState &state, const ModelMetadata &metadata, const std::string &filePath, bool isRestart=false) const override
Dumps the data to a file path.
ModelState getModelState(const std::string &filePath) override
Dumps the data to a file path.
void setIO(IParaGridIO *p)
ModelState getModelState(const std::string &filePath) override
Dumps the data to a file path.
void setIO(IRectGridIO *p)
Sets the pointer to the class that will perform the IO. Should be an instance of DevGridIO.
void dumpModelState(const ModelState &state, const ModelMetadata &metadata, const std::string &filePath, bool isRestart=false) const override
Dumps the data to a file path.
static void fileFromState(const ModelState &state, const ModelMetadata &meta, const std::string &filePath, bool isRestart=false)
Takes a ModelState and a template file name to write the state out to a target file path.
static ModelState stateFromFile(const std::string &filePath)
Returns the ModelState of the named restart file.