Commit d2baa7cd authored by Dave Moxey's avatar Dave Moxey
Browse files

Rename utility functions to make them static inside FieldIO

parent 6fd7189a
......@@ -29,7 +29,7 @@ int main(int argc, char *argv[])
exit(1);
}
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -41,7 +41,7 @@ int main(int argc, char *argv[])
exit(1);
}
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -40,7 +40,7 @@ int main(int argc, char *argv[])
exit(1);
}
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
exit(1);
}
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -34,7 +34,7 @@ int main(int argc, char *argv[])
try
{
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -44,7 +44,8 @@ int main(int argc, char *argv[])
try
{
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -83,7 +83,8 @@ int main(int argc, char *argv[])
try
{
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -33,7 +33,8 @@ int main(int argc, char *argv[])
exit(1);
}
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeDefaultFieldIO(vSession);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::FieldIO::CreateDefault(vSession);
//----------------------------------------------
// Read in mesh from input file
......
......@@ -85,7 +85,7 @@ Mapping::Mapping(const LibUtilities::SessionReaderSharedPtr& pSession,
break;
}
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
/**
......@@ -443,7 +443,7 @@ void Mapping::EvaluateFunction(
Vmath::Zero(vCoeffs.num_elements(), vCoeffs, 1);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::MakeFieldIOForFile(pSession, filename);
LibUtilities::FieldIO::CreateForFile(pSession, filename);
fld->Import(filename, FieldDef, FieldData);
int idx = -1;
......
......@@ -155,6 +155,31 @@ const std::string FieldIO::GetFileType(const std::string &filename,
return iofmt;
}
/**
* @brief Returns an object for the default FieldIO method.
*
* This function returns a FieldIO class as determined by the hard-coded default
* (XML), which can be overridden by changing the session reader SOLVERINFO
* variable FieldIOFormat.
*
* @param session Session reader
*
* @return FieldIO object
*/
FieldIOSharedPtr FieldIO::CreateDefault(
const LibUtilities::SessionReaderSharedPtr session)
{
std::string iofmt("Xml");
if (session->DefinesSolverInfo("FieldIOFormat"))
{
iofmt = session->GetSolverInfo("FieldIOFormat");
}
return GetFieldIOFactory().CreateInstance(
iofmt,
session->GetComm(),
session->DefinesCmdLineArgument("shared-filesystem"));
}
/**
* @brief Construct a FieldIO object for a given input filename.
*
......@@ -166,7 +191,7 @@ const std::string FieldIO::GetFileType(const std::string &filename,
*
* @return FieldIO class reader for @p filename.
*/
FieldIOSharedPtr MakeFieldIOForFile(
FieldIOSharedPtr FieldIO::CreateForFile(
const LibUtilities::SessionReaderSharedPtr session,
const std::string &filename)
{
......
......@@ -248,6 +248,12 @@ public:
CommSharedPtr comm);
virtual const std::string &GetClassName() const = 0;
static boost::shared_ptr<FieldIO> CreateDefault(
const LibUtilities::SessionReaderSharedPtr session);
static boost::shared_ptr<FieldIO> CreateForFile(
const LibUtilities::SessionReaderSharedPtr session,
const std::string &filename);
protected:
/// Communicator to use when writing parallel format
LibUtilities::CommSharedPtr m_comm;
......@@ -295,35 +301,6 @@ protected:
typedef boost::shared_ptr<FieldIO> FieldIOSharedPtr;
/**
* @brief Returns an object for the default FieldIO method.
*
* This function returns a FieldIO class as determined by the hard-coded default
* (XML), which can be overridden by changing the session reader SOLVERINFO
* variable FieldIOFormat.
*
* @param session Session reader
*
* @return FieldIO object
*/
inline FieldIOSharedPtr MakeDefaultFieldIO(
const LibUtilities::SessionReaderSharedPtr session)
{
std::string iofmt("Xml");
if (session->DefinesSolverInfo("FieldIOFormat"))
{
iofmt = session->GetSolverInfo("FieldIOFormat");
}
return GetFieldIOFactory().CreateInstance(
iofmt,
session->GetComm(),
session->DefinesCmdLineArgument("shared-filesystem"));
}
FieldIOSharedPtr MakeFieldIOForFile(
const LibUtilities::SessionReaderSharedPtr session,
const std::string &filename);
/**
* @brief Write out the field information to the file @p outFile.
*
......
......@@ -122,7 +122,7 @@ namespace Nektar
m_sessionName = m_session->GetSessionName();
// Instantiate a field reader/writer
m_fld = LibUtilities::MakeDefaultFieldIO(m_session);
m_fld = LibUtilities::FieldIO::CreateDefault(m_session);
// Read the geometry and the expansion information
m_graph = SpatialDomains::MeshGraph::Read(m_session);
......@@ -850,7 +850,7 @@ namespace Nektar
if (boost::filesystem::path(filename).extension() != ".pts")
{
LibUtilities::FieldIOSharedPtr pts_fld =
LibUtilities::MakeFieldIOForFile(m_session, filename);
LibUtilities::FieldIO::CreateForFile(m_session, filename);
pts_fld->Import(filename, FieldDef, FieldData,
LibUtilities::NullFieldMetaDataMap,
ElementGIDs);
......@@ -1441,7 +1441,7 @@ namespace Nektar
//Get Homogeneous
LibUtilities::FieldIOSharedPtr base_fld =
LibUtilities::MakeFieldIOForFile(m_session, pInfile);
LibUtilities::FieldIO::CreateForFile(m_session, pInfile);
base_fld->Import(pInfile,FieldDef,FieldData);
int nvar = m_session->GetVariables().size();
......@@ -2098,7 +2098,7 @@ namespace Nektar
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef;
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIOSharedPtr field_fld =
LibUtilities::MakeFieldIOForFile(m_session, infile);
LibUtilities::FieldIO::CreateForFile(m_session, infile);
field_fld->Import(infile,FieldDef,FieldData);
// Copy FieldData into m_fields
......@@ -2185,7 +2185,7 @@ namespace Nektar
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIOSharedPtr field_fld =
LibUtilities::MakeFieldIOForFile(m_session, infile);
LibUtilities::FieldIO::CreateForFile(m_session, infile);
field_fld->Import(infile,FieldDef,FieldData);
int idx = -1;
......@@ -2230,7 +2230,7 @@ namespace Nektar
std::vector<std::vector<NekDouble> > FieldData;
LibUtilities::FieldIOSharedPtr field_fld =
LibUtilities::MakeFieldIOForFile(m_session, infile);
LibUtilities::FieldIO::CreateForFile(m_session, infile);
field_fld->Import(infile,FieldDef,FieldData);
// Copy FieldData into m_fields
......
......@@ -69,7 +69,7 @@ FilterCheckpoint::FilterCheckpoint(
m_outputIndex = 0;
m_index = 0;
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
FilterCheckpoint::~FilterCheckpoint()
......
......@@ -111,7 +111,7 @@ FilterModalEnergy::FilterModalEnergy(
}
}
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
/**
......
......@@ -88,7 +88,7 @@ FilterSampler::FilterSampler(
m_numSamples = 0;
m_index = 0;
m_outputIndex = 0;
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
FilterSampler::~FilterSampler()
......
......@@ -97,7 +97,7 @@ FilterThresholdMax::FilterThresholdMax(
m_thresholdVar = x - varlist.begin();
}
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
FilterThresholdMax::~FilterThresholdMax()
......
......@@ -101,7 +101,7 @@ FilterThresholdMin::FilterThresholdMin(
m_thresholdVar = x - varlist.begin();
}
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
......
......@@ -190,7 +190,8 @@ namespace Nektar
Array<OneD, NekDouble> vCoeffs(pFields[0]->GetNcoeffs());
Vmath::Zero(vCoeffs.num_elements(), vCoeffs, 1);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeFieldIOForFile(m_session, filename);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::FieldIO::CreateForFile(m_session, filename);
fld->Import(filename, FieldDef, FieldData);
int idx = -1;
......
......@@ -373,7 +373,8 @@ namespace Nektar
}
FieldDef[*setIt] = FDef(0);
FieldData[*setIt] = FData(0);
LibUtilities::FieldIOSharedPtr fld = LibUtilities::MakeFieldIOForFile(m_session, *setIt);
LibUtilities::FieldIOSharedPtr fld =
LibUtilities::FieldIO::CreateForFile(m_session, *setIt);
fld->Import(*setIt, FieldDef[*setIt], FieldData[*setIt],
fieldMetaDataMap);
}
......
......@@ -91,7 +91,7 @@ FilterBenchmark::FilterBenchmark(
m_startTime = floor(equ.Evaluate());
}
m_fld = LibUtilities::MakeDefaultFieldIO(pSession);
m_fld = LibUtilities::FieldIO::CreateDefault(pSession);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment