Added: public method SIMinput::readTopologyOnly()

This commit is contained in:
Knut Morten Okstad 2021-10-25 21:55:15 +02:00
parent d1520df805
commit fc57eed844
6 changed files with 70 additions and 19 deletions

View File

@ -29,7 +29,7 @@ public:
//! \brief Default constructor.
//! \param[in] n1 Dimension of the primary solution field
SIM1D(unsigned char n1 = 1, bool = false);
explicit SIM1D(unsigned char n1 = 1, bool = false);
//! \brief Constructor used for mixed problems.
//! \param[in] unf Dimension of the primary solution fields
explicit SIM1D(const CharVec& unf, bool = false);
@ -63,6 +63,12 @@ protected:
//! \param[in] elem The XML element to parse
virtual bool parse(const TiXmlElement* elem);
//! \brief Parses a dimension-specific subelement of the \a geometry XML-tag.
virtual bool parseGeometryDimTag(const TiXmlElement* elem)
{
return this->parseGeometryTag(elem);
}
//! \brief Parses or generates app-specific explicit knots for refinement.
virtual bool parseXi(const TiXmlElement*, RealArray&) const { return false; }

View File

@ -32,7 +32,7 @@ public:
//! \brief Default constructor.
//! \param[in] n1 Dimension of the primary solution field
//! \param[in] check If \e true, ensure the model is in a right-hand system
SIM2D(unsigned char n1 = 2, bool check = false);
explicit SIM2D(unsigned char n1 = 2, bool check = false);
//! \brief Constructor used for mixed problems.
//! \param[in] unf Dimension of the primary solution fields
//! \param[in] check If \e true, ensure the model is in a right-hand system
@ -83,6 +83,12 @@ protected:
//! \param is The file stream to read from
virtual bool parse(char* keyWord, std::istream& is);
//! \brief Parses a dimension-specific subelement of the \a geometry XML-tag.
virtual bool parseGeometryDimTag(const TiXmlElement* elem)
{
return this->parseGeometryTag(elem);
}
//! \brief Reads global node data for a patch from given input stream.
//! \param[in] isn The input stream to read from
//! \param[in] pchInd 0-based index of the patch to read node data for

View File

@ -32,7 +32,7 @@ public:
//! \brief Default constructor.
//! \param[in] n1 Dimension of the primary solution field
//! \param[in] check If \e true, ensure the model is in a right-hand system
SIM3D(unsigned char n1 = 3, bool check = false);
explicit SIM3D(unsigned char n1 = 3, bool check = false);
//! \brief Constructor used for mixed problems.
//! \param[in] unf Dimension of the primary solution fields
//! \param[in] check If \e true, ensure the model is in a right-hand system
@ -84,6 +84,12 @@ protected:
//! \param is The file stream to read from
virtual bool parse(char* keyWord, std::istream& is);
//! \brief Parses a dimension-specific subelement of the \a geometry XML-tag.
virtual bool parseGeometryDimTag(const TiXmlElement* elem)
{
return this->parseGeometryTag(elem);
}
//! \brief Reads global node data for a patch from given input stream.
//! \param[in] isn The input stream to read from
//! \param[in] pchInd 0-based index of the patch to read node data for

View File

@ -7,7 +7,7 @@
//!
//! \author Knut Morten Okstad / SINTEF
//!
//! \brief Dummy SIM template class for drivers not associated with a FE model.
//! \brief Dummy %SIM template class for drivers not associated with a FE model.
//!
//==============================================================================
@ -25,7 +25,7 @@ namespace ASM { struct Interface; }
/*!
\brief Template SIM class with some dummy implementations.
\brief Template %SIM class with some dummy implementations.
\details This class only implements dummy versions for the pure virtual
virtual methods of the base class SIMbase, and can be used as a base for
simulator drivers that do not require any FE model.
@ -33,11 +33,12 @@ namespace ASM { struct Interface; }
template<class Base> class SIMdummy : public Base
{
public:
protected:
//! \brief Default constructor.
SIMdummy(IntegrandBase* p = nullptr) : Base(p) {}
explicit SIMdummy(IntegrandBase* p = nullptr) : Base(p) {}
//! \brief Empty destructor.
virtual ~SIMdummy() {}
public:
//! \brief Returns the number of parameter dimensions in the model.
virtual unsigned short int getNoParamDim() const { return 0; }
//! \brief Creates the computational FEM model from the spline patches.
@ -46,6 +47,8 @@ public:
virtual std::vector<std::vector<int>> getElmConnectivities() const
{ return std::vector<std::vector<int>>(); }
protected:
//! \brief Parses a dimension-specific subelement of the \a geometry XML-tag.
virtual bool parseGeometryDimTag(const TiXmlElement*) { return false; }
//! \brief Preprocesses a user-defined Dirichlet boundary property.
virtual bool addConstraint(int,int,int,int,int,int&,char) { return false; }
//! \brief Preprocesses the result sampling points.

View File

@ -986,6 +986,30 @@ const char** SIMinput::getPrioritizedTags () const
}
/*!
This method is typically invoked by coupled simulators using shared grids.
It is then invoked for the simulator that owns the grid to resolve the
patch topology, in case the other simulators using the grid invokes
SIMbase::preprocess() first.
*/
bool SIMinput::readTopologyOnly (const std::string& fileName)
{
TiXmlDocument doc;
const TiXmlElement* elem = this->loadFile(doc,fileName.c_str());
if (!elem) return false;
for (elem = elem->FirstChildElement("geometry"); elem;
elem = elem->NextSiblingElement("geometry"))
for (const TiXmlElement* child = elem->FirstChildElement("topology"); child;
child = child->NextSiblingElement("topology"))
if (!this->parseGeometryDimTag(child))
return false;
return true;
}
bool SIMinput::parse (char* keyWord, std::istream& is)
{
char* cline = 0;

View File

@ -67,18 +67,13 @@ public:
//! \brief Empty destructor.
virtual ~SIMinput() {}
//! \brief Parses a data section from an input stream.
//! \param[in] keyWord Keyword of current data section to read
//! \param is The file stream to read from
virtual bool parse(char* keyWord, std::istream& is);
//! \brief Parses a data section from an XML document.
//! \param[in] elem The XML element to parse
virtual bool parse(const TiXmlElement* elem);
//! \brief Returns a list of prioritized XML-tags.
virtual const char** getPrioritizedTags() const;
//! \brief Reads patch topology from the specified input file.
//! \param[in] fileName Path to XML file to read patch topology from
bool readTopologyOnly(const std::string& fileName);
//! \brief Returns a unique integer code for a Property set.
//! \param[in] setName Name of the topology set the property is defined on
//! \param[in] comp The solution components on which the property is applied
@ -114,6 +109,17 @@ private:
bool parseLinSolTag(const TiXmlElement* elem);
protected:
//! \brief Parses a data section from an input stream.
//! \param[in] keyWord Keyword of current data section to read
//! \param is The file stream to read from
virtual bool parse(char* keyWord, std::istream& is);
//! \brief Parses a data section from an XML document.
//! \param[in] elem The XML element to parse
virtual bool parse(const TiXmlElement* elem);
//! \brief Parses a dimension-specific subelement of the \a geometry XML-tag.
virtual bool parseGeometryDimTag(const TiXmlElement* elem) = 0;
//! \brief Parses the \a periodic XML-tag.
bool parsePeriodic(const TiXmlElement* elem);
//! \brief Parses a subelement of the \a resultoutput XML-tag.
@ -206,7 +212,7 @@ protected:
//! \brief Helper method returning a stream for patch geometry input.
//! \param[in] tag The XML-tag containing the patch geometry definition
//! \param[in] patch The value of the \a tag, either a file name or g2 string
static std::istream* getPatchStream (const char* tag, const char* patch);
static std::istream* getPatchStream(const char* tag, const char* patch);
//! \brief Reads a patch from given input stream.
//! \param[in] isp The input stream to read from
@ -250,7 +256,7 @@ protected:
public:
//! \brief Handles application restarts by reading a serialized basis.
//! \param[in] restartFile File to read restart basis from
//! \param[in] restartFile Path to file to read restart basis from
//! \param[in] restartStep Index of the time step to read restart basis for
//! \return One-based index of the first time step to solve after restart.
//! If zero, no restart specified. If one, no serialized basis stored.
@ -294,7 +300,7 @@ public:
private:
//! \brief Sets initial conditions from a file.
//! \param fieldHolder The SIM-object to inject the initial conditions into
//! \param[in] fileName Name of file to read the initial conditions from
//! \param[in] fileName Path to file to read the initial conditions from
//! \param[in] info Initial condition information
bool setInitialCondition(SIMdependency* fieldHolder,
const std::string& fileName,