Fixup for commit 64164d22fa:

Only the first and last patch files need to be marked.
This commit is contained in:
Knut Morten Okstad 2021-06-03 15:01:00 +02:00
parent a73c1b5a12
commit 865b27a90d
2 changed files with 26 additions and 13 deletions

View File

@ -35,6 +35,13 @@
#include <numeric>
SIMinput::SIMinput (IntegrandBase* itg) : SIMbase(itg)
{
myGen = nullptr;
isReading = false;
}
std::istream* SIMinput::getPatchStream (const char* tag, const char* patch)
{
if (!strcasecmp(tag+5,"file"))
@ -90,28 +97,31 @@ bool SIMinput::parseGeometryTag (const TiXmlElement* elem)
if (!strncasecmp(elem->Value(),"patch",5) && elem->FirstChild())
{
std::string fileNum;
utl::getAttribute(elem,"num",fileNum,true);
if (!myModel.empty() && (fileNum == "first" || fileNum.empty()))
if (!myModel.empty() && !isReading)
return true; // We already have a model, skip geometry definition
size_t oldPatches = myModel.size();
const char* patch = elem->FirstChild()->Value();
std::istream* isp = getPatchStream(elem->Value(),patch);
if (isp)
{
this->readPatches(*isp,"\t");
delete isp;
}
else
return true;
if (!isp) return true; // Neither <patch>, <patches> nor <patchfile>
size_t oldPatches = myModel.size();
this->readPatches(*isp,"\t");
delete isp;
if (myModel.size() == oldPatches)
{
std::cerr <<" *** SIMinput::parse: No patches read."<< std::endl;
return false;
}
if (myPatches.empty() && (fileNum == "last" || fileNum.empty()))
std::string fileNum;
utl::getAttribute(elem,"num",fileNum,true);
if (fileNum == "first" || fileNum == "1")
isReading = true;
else if (fileNum == "last")
isReading = false;
if (myPatches.empty() && !isReading)
nGlPatches = myModel.size();
}

View File

@ -61,7 +61,7 @@ public:
protected:
//! \brief The constructor just forwards to the base class constructor.
explicit SIMinput(IntegrandBase* itg) : SIMbase(itg), myGen(nullptr) {}
explicit SIMinput(IntegrandBase* itg);
public:
//! \brief Empty destructor.
@ -292,6 +292,9 @@ protected:
std::vector<ASM::Interface> myInterfaces; //!< Topology interface descriptions
std::map<std::string,InitialCondVec> myICs; //!< Initial condition definitions
private:
bool isReading; //!< If \e true, we are reading multiple patch tags
};
#endif