diff --git a/Apps/Common/SIMOverride.h b/Apps/Common/SIMOverride.h index 8c3742b2..cc4940e1 100644 --- a/Apps/Common/SIMOverride.h +++ b/Apps/Common/SIMOverride.h @@ -40,7 +40,7 @@ public: //! \brief Empty destructor. virtual ~SIMOverride() {} - //! \copydoc SIMinput::read(const char*) + //! \copydoc SIMadmin::read(const char*) bool read(const char* fileName) { return base.read(fileName); } //! \copydoc ISolver::setInitialConditions() diff --git a/Apps/Common/SIMSemi3D.h b/Apps/Common/SIMSemi3D.h index b7f7f745..e4776cd5 100644 --- a/Apps/Common/SIMSemi3D.h +++ b/Apps/Common/SIMSemi3D.h @@ -14,7 +14,7 @@ #ifndef _SIM_SEMI3D_H #define _SIM_SEMI3D_H -#include "SIMinput.h" +#include "SIMadmin.h" #include "SIMdependency.h" #include "SIMSolver.h" #include "IFEM.h" @@ -42,7 +42,7 @@ extern std::vector< std::shared_ptr > plane_log_files; */ template -class SIMSemi3D : public SIMinput, public SIMdependency +class SIMSemi3D : public SIMadmin, public SIMdependency { public: typedef typename PlaneSolver::SetupProps SetupProps; @@ -53,7 +53,7 @@ public: startCtx(0), planes(1), procs_per_plane(1), output_plane(-1), 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. @@ -212,7 +212,7 @@ public: //! \param[in] fileName Name of input file to read data from virtual bool read(const char* fileName) { - if (!this->SIMinput::read(fileName)) + if (!this->SIMadmin::read(fileName)) return false; // Setup our communicator diff --git a/Apps/Common/SIMSolver.h b/Apps/Common/SIMSolver.h index bca41f79..527fae3f 100644 --- a/Apps/Common/SIMSolver.h +++ b/Apps/Common/SIMSolver.h @@ -14,7 +14,7 @@ #ifndef _SIM_SOLVER_H_ #define _SIM_SOLVER_H_ -#include "SIMinput.h" +#include "SIMadmin.h" #include "DataExporter.h" #include "TimeStep.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. */ -template class SIMSolver : public SIMinput +template class SIMSolver : public SIMadmin { public: //! \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. virtual ~SIMSolver() {} diff --git a/src/SIM/AdaptiveSIM.C b/src/SIM/AdaptiveSIM.C index 57c76fe6..a458a0fa 100644 --- a/src/SIM/AdaptiveSIM.C +++ b/src/SIM/AdaptiveSIM.C @@ -24,7 +24,7 @@ #include -AdaptiveSIM::AdaptiveSIM (SIMoutput& sim, bool sa) : SIMinput(sim), model(sim) +AdaptiveSIM::AdaptiveSIM (SIMoutput& sim, bool sa) : SIMadmin(sim), model(sim) { alone = sa; geoBlk = nBlock = 0; diff --git a/src/SIM/AdaptiveSIM.h b/src/SIM/AdaptiveSIM.h index 7805530e..38a181e5 100644 --- a/src/SIM/AdaptiveSIM.h +++ b/src/SIM/AdaptiveSIM.h @@ -14,7 +14,7 @@ #ifndef _ADAPTIVE_SIM_H #define _ADAPTIVE_SIM_H -#include "SIMinput.h" +#include "SIMadmin.h" #include "MatVec.h" class SIMoutput; @@ -26,7 +26,7 @@ class SIMoutput; problems adaptively, based on element error norms as refinement indicators. */ -class AdaptiveSIM : public SIMinput +class AdaptiveSIM : public SIMadmin { public: //! \brief The constructor initializes default adaptation parameters. diff --git a/src/SIM/MultiStepSIM.C b/src/SIM/MultiStepSIM.C index 8e586b28..d7593d15 100644 --- a/src/SIM/MultiStepSIM.C +++ b/src/SIM/MultiStepSIM.C @@ -18,7 +18,7 @@ MultiStepSIM::MultiStepSIM (SIMbase& sim) - : SIMinput(sim), model(static_cast(sim)) + : SIMadmin(sim), model(static_cast(sim)) { #ifndef SP_DEBUG msgLevel = 1; // prints the convergence history only diff --git a/src/SIM/MultiStepSIM.h b/src/SIM/MultiStepSIM.h index b494d0f8..48c2bc57 100644 --- a/src/SIM/MultiStepSIM.h +++ b/src/SIM/MultiStepSIM.h @@ -14,7 +14,7 @@ #ifndef _MULTI_STEP_SIM_H #define _MULTI_STEP_SIM_H -#include "SIMinput.h" +#include "SIMadmin.h" #include "SIMenums.h" #include "MatVec.h" @@ -28,7 +28,7 @@ struct TimeDomain; \brief Base class for multi-step solution drivers. */ -class MultiStepSIM : public SIMinput +class MultiStepSIM : public SIMadmin { protected: //! \brief Enum describing reference norm options. diff --git a/src/SIM/SIMinput.C b/src/SIM/SIMadmin.C similarity index 71% rename from src/SIM/SIMinput.C rename to src/SIM/SIMadmin.C index f7080a3a..9cb9cfa6 100644 --- a/src/SIM/SIMinput.C +++ b/src/SIM/SIMadmin.C @@ -1,21 +1,20 @@ // $Id$ //============================================================================== //! -//! \file SIMinput.C +//! \file SIMadmin.C //! //! \date Jun 1 2010 //! //! \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 "IFEM.h" +#include "SIMadmin.h" #include "Utilities.h" +#include "IFEM.h" #include "tinyxml.h" -#include "SystemMatrix.h" #ifdef HAVE_MPI #include #endif @@ -25,10 +24,10 @@ #define strcasestr strstr #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 , adm(PETSC_COMM_WORLD) #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; 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()) 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; 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); if (!is) { - std::cerr <<"\n *** SIMinput::read: Failure opening input file " - << fileName << std::endl; + std::cerr <<"\n *** SIMadmin::read: Failure opening input file \"" + << fileName <<"\"."<< std::endl; return false; } IFEM::cout <<"\nReading input file "<< fileName << std::endl; - char* keyWord = 0; + char* keyWord = nullptr; while (is.good() && (keyWord = utl::readLine(is))) if (!this->parse(keyWord,is)) { - std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" - << keyWord <<"\""<< std::endl; + std::cerr <<" *** SIMadmin::read: Failure occured while parsing \"" + << keyWord <<"\"."<< std::endl; 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" <<" Use the XML format instead."<< std::endl; return false; diff --git a/src/SIM/SIMinput.h b/src/SIM/SIMadmin.h similarity index 57% rename from src/SIM/SIMinput.h rename to src/SIM/SIMadmin.h index eb2a852f..a68f058d 100644 --- a/src/SIM/SIMinput.h +++ b/src/SIM/SIMadmin.h @@ -1,50 +1,52 @@ // $Id$ //============================================================================== //! -//! \file SIMinput.h +//! \file SIMadmin.h //! //! \date Jun 1 2010 //! //! \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 -#define _SIM_INPUT_H +#ifndef _SIM_ADMIN_H +#define _SIM_ADMIN_H +#include "XMLInputBase.h" #include "SIMoptions.h" #include "ProcessAdm.h" -#include "XMLInputBase.h" #include -#include +#include /*! - \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: //! \brief The default constructor initializes the process administrator. - SIMinput(const char* heading = nullptr); + SIMadmin(const char* heading = nullptr); //! \brief Copy constructor. - SIMinput(SIMinput& anotherSIM); + SIMadmin(SIMadmin& anotherSIM); public: //! \brief Empty destructor. - virtual ~SIMinput() {} + virtual ~SIMadmin() {} //! \brief Reads model data from the specified input file \a *fileName. virtual bool read(const char* fileName); public: + using XMLInputBase::parse; //! \brief Parses a data section from an input stream. 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. const ProcessAdm& getProcessAdm() const { return adm; } @@ -59,24 +61,23 @@ public: void setHeading(const std::string& heading) { myHeading = heading; } 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; - //! \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); public: - static int msgLevel; //!< Controls the amount of console output during solving - SIMoptions& opt; //!< Simulation control parameters + static int msgLevel; //!< Controls the console output amount during solving + SIMoptions& opt; //!< Simulation control parameters private: - SIMoptions myOpts; //!< The actual control parameters owned by this simulator + SIMoptions myOpts; //!< Actual control parameters owned by this simulator protected: - ProcessAdm adm; //!< Parallel administrator - int myPid; //!< Processor ID in parallel simulations - int nProc; //!< Number of processors in parallel simulations - + ProcessAdm adm; //!< Parallel administrator + int myPid; //!< Processor ID in parallel simulations + int nProc; //!< Number of processors in parallel simulations std::string myHeading; //!< Heading written before reading the input file }; diff --git a/src/SIM/SIMbase.h b/src/SIM/SIMbase.h index 006b6f5d..dc40e17a 100644 --- a/src/SIM/SIMbase.h +++ b/src/SIM/SIMbase.h @@ -14,7 +14,7 @@ #ifndef _SIM_BASE_H #define _SIM_BASE_H -#include "SIMinput.h" +#include "SIMadmin.h" #include "SIMdependency.h" #include "TimeDomain.h" #include "TopologySet.h" @@ -61,7 +61,7 @@ struct Mode 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: //! \brief The constructor initializes the pointers to dynamic data members. diff --git a/src/SIM/SIMoptions.h b/src/SIM/SIMoptions.h index b2730702..be507028 100644 --- a/src/SIM/SIMoptions.h +++ b/src/SIM/SIMoptions.h @@ -15,7 +15,6 @@ #define SIM_OPTIONS_H_ #include "ASMenums.h" -#include #include #include diff --git a/src/SIM/XMLInputBase.C b/src/SIM/XMLInputBase.C index 15db8f4c..9a5f2cbe 100644 --- a/src/SIM/XMLInputBase.C +++ b/src/SIM/XMLInputBase.C @@ -13,7 +13,6 @@ #include "XMLInputBase.h" #include "IFEM.h" - #include "tinyxml.h" #include @@ -39,10 +38,10 @@ void XMLInputBase::injectIncludeFiles (TiXmlElement* tag) const foundIncludes = true; } else - std::cerr << __PRETTY_FUNCTION__ <<": Failed to load " - << elem->FirstChild()->Value() - <<"\n\tError at line "<< doc.ErrorRow() <<": " - << doc.ErrorDesc() << std::endl; + std::cerr <<" *** SIMadmin::read: Failed to load \"" + << elem->FirstChild()->Value() + <<"\".\n\tError at line "<< doc.ErrorRow() <<": " + << doc.ErrorDesc() << std::endl; } if (foundIncludes) @@ -56,16 +55,16 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose) { TiXmlDocument doc; if (!doc.LoadFile(fileName)) { - std::cerr << __PRETTY_FUNCTION__ <<": Failed to load "<< fileName - <<"\n\tError at line "<< doc.ErrorRow() <<": " - << doc.ErrorDesc() << std::endl; + std::cerr <<" *** SIMadmin::read: Failed to load \""<< fileName + <<"\".\n\tError at line "<< doc.ErrorRow() <<": " + << doc.ErrorDesc() << std::endl; return false; } const TiXmlElement* tag = doc.RootElement(); if (!tag || strcmp(tag->Value(),"simulation")) { - std::cerr << __PRETTY_FUNCTION__ <<": Malformatted input file "<< fileName - << std::endl; + std::cerr <<" *** SIMadmin::read: Malformatted input file \""<< fileName + <<"\"."<< std::endl; return false; } @@ -83,8 +82,8 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose) if (verbose) IFEM::cout <<"\nParsing <"<< tag->Value() <<">"<< std::endl; if (!this->parse(tag)) { - std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" - << tag->Value() <<"\""<< std::endl; + std::cerr <<" *** SIMadmin::read: Failure occured while parsing \"" + << tag->Value() <<"\"."<< std::endl; return false; } } @@ -97,7 +96,7 @@ bool XMLInputBase::readXML (const char* fileName, bool verbose) bool XMLInputBase::handlePriorityTags (const TiXmlElement* base, - std::vector& parsed, + std::vector& parsed, bool verbose) { const char** q = this->getPrioritizedTags(); @@ -108,8 +107,8 @@ bool XMLInputBase::handlePriorityTags (const TiXmlElement* base, if (verbose) IFEM::cout <<"\nParsing <"<< elem->Value() <<">"<< std::endl; if (!this->parse(elem)) { - std::cerr <<" *** SIMinput::read: Failure occured while parsing \"" - << elem->Value() <<"\""<< std::endl; + std::cerr <<" *** SIMadmin::read: Failure occured while parsing \"" + << elem->Value() <<"\"."<< std::endl; return false; } parsed.push_back(elem); diff --git a/src/SIM/XMLInputBase.h b/src/SIM/XMLInputBase.h index 8e30b61e..a18057f8 100644 --- a/src/SIM/XMLInputBase.h +++ b/src/SIM/XMLInputBase.h @@ -19,16 +19,18 @@ class TiXmlElement; -/*! \brief Base class for XML based input file parsing. - * \details This is inherited by SIMinput for input parsing handling, - * and is also used in applications for pre-parsing the input file. - */ +/*! + \brief Base class for XML based input file parsing. + \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 { public: //! \brief Reads an XML input file. - //! \param fileName File to read - //! \param verbose True to print the tags being parsed to output + //! \param[in] fileName File to read + //! \param[in] verbose True to print the tags being parsed to output bool readXML(const char* fileName, bool verbose = true); protected: