Changed: Renamed the base class SIMinput to SIMadmin

This commit is contained in:
Knut Morten Okstad 2016-12-13 11:44:17 +01:00
parent 4a5bafaa45
commit 1a43e1c694
13 changed files with 78 additions and 78 deletions

View File

@ -40,7 +40,7 @@ public:
//! \brief Empty destructor. //! \brief Empty destructor.
virtual ~SIMOverride() {} virtual ~SIMOverride() {}
//! \copydoc SIMinput::read(const char*) //! \copydoc SIMadmin::read(const char*)
bool read(const char* fileName) { return base.read(fileName); } bool read(const char* fileName) { return base.read(fileName); }
//! \copydoc ISolver::setInitialConditions() //! \copydoc ISolver::setInitialConditions()

View File

@ -14,7 +14,7 @@
#ifndef _SIM_SEMI3D_H #ifndef _SIM_SEMI3D_H
#define _SIM_SEMI3D_H #define _SIM_SEMI3D_H
#include "SIMinput.h" #include "SIMadmin.h"
#include "SIMdependency.h" #include "SIMdependency.h"
#include "SIMSolver.h" #include "SIMSolver.h"
#include "IFEM.h" #include "IFEM.h"
@ -42,7 +42,7 @@ extern std::vector< std::shared_ptr<std::ostream> > plane_log_files;
*/ */
template<class PlaneSolver> template<class PlaneSolver>
class SIMSemi3D : public SIMinput, public SIMdependency class SIMSemi3D : public SIMadmin, public SIMdependency
{ {
public: public:
typedef typename PlaneSolver::SetupProps SetupProps; typedef typename PlaneSolver::SetupProps SetupProps;
@ -53,7 +53,7 @@ public:
startCtx(0), planes(1), procs_per_plane(1), output_plane(-1), startCtx(0), planes(1), procs_per_plane(1), output_plane(-1),
direction('Z'), props(props_) direction('Z'), props(props_)
{ {
SIMinput::myHeading = "Plane-decoupled 3D simulation driver"; SIMadmin::myHeading = "Plane-decoupled 3D simulation driver";
} }
//! \brief The destructor deletes the plane-wise sub-step solvers. //! \brief The destructor deletes the plane-wise sub-step solvers.
@ -212,7 +212,7 @@ public:
//! \param[in] fileName Name of input file to read data from //! \param[in] fileName Name of input file to read data from
virtual bool read(const char* fileName) virtual bool read(const char* fileName)
{ {
if (!this->SIMinput::read(fileName)) if (!this->SIMadmin::read(fileName))
return false; return false;
// Setup our communicator // Setup our communicator

View File

@ -14,7 +14,7 @@
#ifndef _SIM_SOLVER_H_ #ifndef _SIM_SOLVER_H_
#define _SIM_SOLVER_H_ #define _SIM_SOLVER_H_
#include "SIMinput.h" #include "SIMadmin.h"
#include "DataExporter.h" #include "DataExporter.h"
#include "TimeStep.h" #include "TimeStep.h"
#include "IFEM.h" #include "IFEM.h"
@ -49,11 +49,11 @@ int ConfigureSIM(T& t, char* infile,
ISolver interface. It provides a time stepping loop with data output. ISolver interface. It provides a time stepping loop with data output.
*/ */
template<class T1> class SIMSolver : public SIMinput template<class T1> class SIMSolver : public SIMadmin
{ {
public: public:
//! \brief The constructor initializes the reference to the actual solver. //! \brief The constructor initializes the reference to the actual solver.
SIMSolver(T1& s1) : SIMinput("Time integration driver"), S1(s1) {} SIMSolver(T1& s1) : SIMadmin("Time integration driver"), S1(s1) {}
//! \brief Empty destructor. //! \brief Empty destructor.
virtual ~SIMSolver() {} virtual ~SIMSolver() {}

View File

@ -24,7 +24,7 @@
#include <cstdio> #include <cstdio>
AdaptiveSIM::AdaptiveSIM (SIMoutput& sim, bool sa) : SIMinput(sim), model(sim) AdaptiveSIM::AdaptiveSIM (SIMoutput& sim, bool sa) : SIMadmin(sim), model(sim)
{ {
alone = sa; alone = sa;
geoBlk = nBlock = 0; geoBlk = nBlock = 0;

View File

@ -14,7 +14,7 @@
#ifndef _ADAPTIVE_SIM_H #ifndef _ADAPTIVE_SIM_H
#define _ADAPTIVE_SIM_H #define _ADAPTIVE_SIM_H
#include "SIMinput.h" #include "SIMadmin.h"
#include "MatVec.h" #include "MatVec.h"
class SIMoutput; class SIMoutput;
@ -26,7 +26,7 @@ class SIMoutput;
problems adaptively, based on element error norms as refinement indicators. problems adaptively, based on element error norms as refinement indicators.
*/ */
class AdaptiveSIM : public SIMinput class AdaptiveSIM : public SIMadmin
{ {
public: public:
//! \brief The constructor initializes default adaptation parameters. //! \brief The constructor initializes default adaptation parameters.

View File

@ -18,7 +18,7 @@
MultiStepSIM::MultiStepSIM (SIMbase& sim) MultiStepSIM::MultiStepSIM (SIMbase& sim)
: SIMinput(sim), model(static_cast<SIMoutput&>(sim)) : SIMadmin(sim), model(static_cast<SIMoutput&>(sim))
{ {
#ifndef SP_DEBUG #ifndef SP_DEBUG
msgLevel = 1; // prints the convergence history only msgLevel = 1; // prints the convergence history only

View File

@ -14,7 +14,7 @@
#ifndef _MULTI_STEP_SIM_H #ifndef _MULTI_STEP_SIM_H
#define _MULTI_STEP_SIM_H #define _MULTI_STEP_SIM_H
#include "SIMinput.h" #include "SIMadmin.h"
#include "SIMenums.h" #include "SIMenums.h"
#include "MatVec.h" #include "MatVec.h"
@ -28,7 +28,7 @@ struct TimeDomain;
\brief Base class for multi-step solution drivers. \brief Base class for multi-step solution drivers.
*/ */
class MultiStepSIM : public SIMinput class MultiStepSIM : public SIMadmin
{ {
protected: protected:
//! \brief Enum describing reference norm options. //! \brief Enum describing reference norm options.

View File

@ -1,21 +1,20 @@
// $Id$ // $Id$
//============================================================================== //==============================================================================
//! //!
//! \file SIMinput.C //! \file SIMadmin.C
//! //!
//! \date Jun 1 2010 //! \date Jun 1 2010
//! //!
//! \author Knut Morten Okstad / SINTEF //! \author Knut Morten Okstad / SINTEF
//! //!
//! \brief Base class for simulators with input parsing functionality. //! \brief Administration base class for FEM simulators.
//! //!
//============================================================================== //==============================================================================
#include "SIMinput.h" #include "SIMadmin.h"
#include "IFEM.h"
#include "Utilities.h" #include "Utilities.h"
#include "IFEM.h"
#include "tinyxml.h" #include "tinyxml.h"
#include "SystemMatrix.h"
#ifdef HAVE_MPI #ifdef HAVE_MPI
#include <mpi.h> #include <mpi.h>
#endif #endif
@ -25,10 +24,10 @@
#define strcasestr strstr #define strcasestr strstr
#endif #endif
int SIMinput::msgLevel = 2; int SIMadmin::msgLevel = 2;
SIMinput::SIMinput (const char* heading) : opt(myOpts) SIMadmin::SIMadmin (const char* heading) : opt(myOpts)
#ifdef HAS_PETSC #ifdef HAS_PETSC
, adm(PETSC_COMM_WORLD) , adm(PETSC_COMM_WORLD)
#elif defined(HAVE_MPI) #elif defined(HAVE_MPI)
@ -44,7 +43,7 @@ SIMinput::SIMinput (const char* heading) : opt(myOpts)
} }
SIMinput::SIMinput (SIMinput& anotherSIM) : opt(anotherSIM.myOpts) SIMadmin::SIMadmin (SIMadmin& anotherSIM) : opt(anotherSIM.myOpts)
{ {
adm = anotherSIM.adm; adm = anotherSIM.adm;
myPid = anotherSIM.myPid; myPid = anotherSIM.myPid;
@ -52,7 +51,7 @@ SIMinput::SIMinput (SIMinput& anotherSIM) : opt(anotherSIM.myOpts)
} }
void SIMinput::printHeading (int& subStep) const void SIMadmin::printHeading (int& subStep) const
{ {
if (myHeading.empty()) if (myHeading.empty())
return; return;
@ -66,7 +65,7 @@ void SIMinput::printHeading (int& subStep) const
} }
bool SIMinput::read (const char* fileName) bool SIMadmin::read (const char* fileName)
{ {
static int substep = 0; static int substep = 0;
this->printHeading(substep); this->printHeading(substep);
@ -84,24 +83,24 @@ bool SIMinput::read (const char* fileName)
} }
bool SIMinput::readFlat (const char* fileName) bool SIMadmin::readFlat (const char* fileName)
{ {
std::ifstream is(fileName); std::ifstream is(fileName);
if (!is) if (!is)
{ {
std::cerr <<"\n *** SIMinput::read: Failure opening input file " std::cerr <<"\n *** SIMadmin::read: Failure opening input file \""
<< fileName << std::endl; << fileName <<"\"."<< std::endl;
return false; return false;
} }
IFEM::cout <<"\nReading input file "<< fileName << std::endl; IFEM::cout <<"\nReading input file "<< fileName << std::endl;
char* keyWord = 0; char* keyWord = nullptr;
while (is.good() && (keyWord = utl::readLine(is))) while (is.good() && (keyWord = utl::readLine(is)))
if (!this->parse(keyWord,is)) if (!this->parse(keyWord,is))
{ {
std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" std::cerr <<" *** SIMadmin::read: Failure occured while parsing \""
<< keyWord <<"\""<< std::endl; << keyWord <<"\"."<< std::endl;
return false; return false;
} }
@ -111,9 +110,9 @@ bool SIMinput::readFlat (const char* fileName)
} }
bool SIMinput::parse (char*, std::istream&) bool SIMadmin::parse (char*, std::istream&)
{ {
std::cerr <<" *** SIMinput::parse(char*,std::istream&):" std::cerr <<" *** SIMadmin::parse(char*,std::istream&):"
<<" The flat file format is depreciated.\n" <<" The flat file format is depreciated.\n"
<<" Use the XML format instead."<< std::endl; <<" Use the XML format instead."<< std::endl;
return false; return false;

View File

@ -1,50 +1,52 @@
// $Id$ // $Id$
//============================================================================== //==============================================================================
//! //!
//! \file SIMinput.h //! \file SIMadmin.h
//! //!
//! \date Jun 1 2010 //! \date Jun 1 2010
//! //!
//! \author Knut Morten Okstad / SINTEF //! \author Knut Morten Okstad / SINTEF
//! //!
//! \brief Base class for simulators with input parsing functionality. //! \brief Administration base class for FEM simulators.
//! //!
//============================================================================== //==============================================================================
#ifndef _SIM_INPUT_H #ifndef _SIM_ADMIN_H
#define _SIM_INPUT_H #define _SIM_ADMIN_H
#include "XMLInputBase.h"
#include "SIMoptions.h" #include "SIMoptions.h"
#include "ProcessAdm.h" #include "ProcessAdm.h"
#include "XMLInputBase.h"
#include <iostream> #include <iostream>
#include <vector> #include <string>
/*! /*!
\brief Base class for NURBS-based FEM simulators with input file parsing. \brief Administration base class for FEM simulators.
\details This class serves as a common base for all types of simulator drivers
in IFEM and contains the general top-level methods for reading the model input
file, as well as data for administration of parallel executions.
*/ */
class SIMinput : public XMLInputBase class SIMadmin : public XMLInputBase
{ {
protected: protected:
//! \brief The default constructor initializes the process administrator. //! \brief The default constructor initializes the process administrator.
SIMinput(const char* heading = nullptr); SIMadmin(const char* heading = nullptr);
//! \brief Copy constructor. //! \brief Copy constructor.
SIMinput(SIMinput& anotherSIM); SIMadmin(SIMadmin& anotherSIM);
public: public:
//! \brief Empty destructor. //! \brief Empty destructor.
virtual ~SIMinput() {} virtual ~SIMadmin() {}
//! \brief Reads model data from the specified input file \a *fileName. //! \brief Reads model data from the specified input file \a *fileName.
virtual bool read(const char* fileName); virtual bool read(const char* fileName);
public: public:
using XMLInputBase::parse;
//! \brief Parses a data section from an input stream. //! \brief Parses a data section from an input stream.
virtual bool parse(char* keyWord, std::istream& is); virtual bool parse(char* keyWord, std::istream& is);
//! \brief Parses a data section from an XML element.
virtual bool parse(const TiXmlElement* elem) = 0;
//! \brief Returns the parallel process administrator. //! \brief Returns the parallel process administrator.
const ProcessAdm& getProcessAdm() const { return adm; } const ProcessAdm& getProcessAdm() const { return adm; }
@ -59,24 +61,23 @@ public:
void setHeading(const std::string& heading) { myHeading = heading; } void setHeading(const std::string& heading) { myHeading = heading; }
protected: protected:
//! \brief Prints the heading of this (sub-step) solver, if any, to std::cout. //! \brief Prints the heading of this simulator, if any, to IFEM::cout.
void printHeading(int& supStep) const; void printHeading(int& supStep) const;
//! \brief Reads a flat text input file (obsolete file format). //! \brief Reads a flat text input file (the old file format).
bool readFlat(const char* fileName); bool readFlat(const char* fileName);
public: public:
static int msgLevel; //!< Controls the amount of console output during solving static int msgLevel; //!< Controls the console output amount during solving
SIMoptions& opt; //!< Simulation control parameters SIMoptions& opt; //!< Simulation control parameters
private: private:
SIMoptions myOpts; //!< The actual control parameters owned by this simulator SIMoptions myOpts; //!< Actual control parameters owned by this simulator
protected: protected:
ProcessAdm adm; //!< Parallel administrator ProcessAdm adm; //!< Parallel administrator
int myPid; //!< Processor ID in parallel simulations int myPid; //!< Processor ID in parallel simulations
int nProc; //!< Number of processors in parallel simulations int nProc; //!< Number of processors in parallel simulations
std::string myHeading; //!< Heading written before reading the input file std::string myHeading; //!< Heading written before reading the input file
}; };

View File

@ -14,7 +14,7 @@
#ifndef _SIM_BASE_H #ifndef _SIM_BASE_H
#define _SIM_BASE_H #define _SIM_BASE_H
#include "SIMinput.h" #include "SIMadmin.h"
#include "SIMdependency.h" #include "SIMdependency.h"
#include "TimeDomain.h" #include "TimeDomain.h"
#include "TopologySet.h" #include "TopologySet.h"
@ -61,7 +61,7 @@ struct Mode
Sub-classes are derived with additional info regarding the problem to solve. Sub-classes are derived with additional info regarding the problem to solve.
*/ */
class SIMbase : public SIMinput, public SIMdependency class SIMbase : public SIMadmin, public SIMdependency
{ {
protected: protected:
//! \brief The constructor initializes the pointers to dynamic data members. //! \brief The constructor initializes the pointers to dynamic data members.

View File

@ -15,7 +15,6 @@
#define SIM_OPTIONS_H_ #define SIM_OPTIONS_H_
#include "ASMenums.h" #include "ASMenums.h"
#include <iostream>
#include <string> #include <string>
#include <map> #include <map>

View File

@ -13,7 +13,6 @@
#include "XMLInputBase.h" #include "XMLInputBase.h"
#include "IFEM.h" #include "IFEM.h"
#include "tinyxml.h" #include "tinyxml.h"
#include <algorithm> #include <algorithm>
@ -39,10 +38,10 @@ void XMLInputBase::injectIncludeFiles (TiXmlElement* tag) const
foundIncludes = true; foundIncludes = true;
} }
else else
std::cerr << __PRETTY_FUNCTION__ <<": Failed to load " std::cerr <<" *** SIMadmin::read: Failed to load \""
<< elem->FirstChild()->Value() << elem->FirstChild()->Value()
<<"\n\tError at line "<< doc.ErrorRow() <<": " <<"\".\n\tError at line "<< doc.ErrorRow() <<": "
<< doc.ErrorDesc() << std::endl; << doc.ErrorDesc() << std::endl;
} }
if (foundIncludes) if (foundIncludes)
@ -56,16 +55,16 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose)
{ {
TiXmlDocument doc; TiXmlDocument doc;
if (!doc.LoadFile(fileName)) { if (!doc.LoadFile(fileName)) {
std::cerr << __PRETTY_FUNCTION__ <<": Failed to load "<< fileName std::cerr <<" *** SIMadmin::read: Failed to load \""<< fileName
<<"\n\tError at line "<< doc.ErrorRow() <<": " <<"\".\n\tError at line "<< doc.ErrorRow() <<": "
<< doc.ErrorDesc() << std::endl; << doc.ErrorDesc() << std::endl;
return false; return false;
} }
const TiXmlElement* tag = doc.RootElement(); const TiXmlElement* tag = doc.RootElement();
if (!tag || strcmp(tag->Value(),"simulation")) { if (!tag || strcmp(tag->Value(),"simulation")) {
std::cerr << __PRETTY_FUNCTION__ <<": Malformatted input file "<< fileName std::cerr <<" *** SIMadmin::read: Malformatted input file \""<< fileName
<< std::endl; <<"\"."<< std::endl;
return false; return false;
} }
@ -83,8 +82,8 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose)
if (verbose) if (verbose)
IFEM::cout <<"\nParsing <"<< tag->Value() <<">"<< std::endl; IFEM::cout <<"\nParsing <"<< tag->Value() <<">"<< std::endl;
if (!this->parse(tag)) { if (!this->parse(tag)) {
std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" std::cerr <<" *** SIMadmin::read: Failure occured while parsing \""
<< tag->Value() <<"\""<< std::endl; << tag->Value() <<"\"."<< std::endl;
return false; return false;
} }
} }
@ -97,7 +96,7 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose)
bool XMLInputBase::handlePriorityTags (const TiXmlElement* base, bool XMLInputBase::handlePriorityTags (const TiXmlElement* base,
std::vector<const TiXmlElement*>& parsed, std::vector<const TiXmlElement*>& parsed,
bool verbose) bool verbose)
{ {
const char** q = this->getPrioritizedTags(); const char** q = this->getPrioritizedTags();
@ -108,8 +107,8 @@ bool XMLInputBase::handlePriorityTags (const TiXmlElement* base,
if (verbose) if (verbose)
IFEM::cout <<"\nParsing <"<< elem->Value() <<">"<< std::endl; IFEM::cout <<"\nParsing <"<< elem->Value() <<">"<< std::endl;
if (!this->parse(elem)) { if (!this->parse(elem)) {
std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" std::cerr <<" *** SIMadmin::read: Failure occured while parsing \""
<< elem->Value() <<"\""<< std::endl; << elem->Value() <<"\"."<< std::endl;
return false; return false;
} }
parsed.push_back(elem); parsed.push_back(elem);

View File

@ -19,16 +19,18 @@
class TiXmlElement; class TiXmlElement;
/*! \brief Base class for XML based input file parsing. /*!
* \details This is inherited by SIMinput for input parsing handling, \brief Base class for XML based input file parsing.
* and is also used in applications for pre-parsing the input file. \details This class is inherited by SIMadmin for input parsing handling,
*/ and is also used in applications for pre-parsing of the input file.
*/
class XMLInputBase class XMLInputBase
{ {
public: public:
//! \brief Reads an XML input file. //! \brief Reads an XML input file.
//! \param fileName File to read //! \param[in] fileName File to read
//! \param verbose True to print the tags being parsed to output //! \param[in] verbose True to print the tags being parsed to output
bool readXML(const char* fileName, bool verbose = true); bool readXML(const char* fileName, bool verbose = true);
protected: protected: