Added: Serialize the minimum element size for restart

This commit is contained in:
Knut Morten Okstad
2021-05-20 14:36:40 +02:00
parent e860948ae9
commit 1561294100
4 changed files with 26 additions and 4 deletions

View File

@@ -165,8 +165,10 @@ public:
//! It must be invoked only before SIMbase::preprocess() is invoked.
void setNoFields(unsigned char n) { nf = n; }
//! \brief Sets the minimum element size for adaptive refinement.
virtual void setMinimumSize(double) {}
//! \brief Defines the minimum element size for adaptive refinement.
virtual double getMinimumSize(int) const { return 0.0; }
virtual double getMinimumSize(int = 0) const { return 0.0; }
//! \brief Checks if the specified element is larger than the minimum size.
virtual bool checkElementSize(int, bool = true) const { return false; }

View File

@@ -203,6 +203,8 @@ public:
//! \brief Creates a separate projection basis for this patch.
virtual bool createProjectionBasis(bool init);
//! \brief Sets the minimum element area for adaptive refinement.
virtual void setMinimumSize(double size) { aMin = size; }
//! \brief Defines the minimum element area for adaptive refinement.
//! \param[in] nrefinements Maximum number of adaptive refinement levels
virtual double getMinimumSize(int nrefinements) const;

View File

@@ -168,6 +168,8 @@ public:
//! \brief Creates a separate projection basis for this patch.
virtual bool createProjectionBasis(bool init);
//! \brief Sets the minimum element volume for adaptive refinement.
virtual void setMinimumSize(double size) { vMin = size; }
//! \brief Defines the minimum element volume for adaptive refinement.
//! \param[in] nrefinements Maximum number of adaptive refinement levels
virtual double getMinimumSize(int nrefinements) const;

View File

@@ -1694,7 +1694,9 @@ bool SIMinput::saveBasis (SerializeMap& data) const
if (!isRefined) return true; // no need to save unrefined basis
std::ostringstream str;
str << isRefined;
str << isRefined <<" "<< myModel.size();
for (const ASMbase* pch : myModel)
str <<" "<< pch->getMinimumSize();
for (const ASMbase* pch : myModel)
pch->write(str);
data[this->getName()+"::basis"] = str.str();
@@ -1711,10 +1713,24 @@ bool SIMinput::restoreBasis (const SerializeMap& data)
if (it == data.end()) return true; // no refined basis yet
std::istringstream str(it->second);
str >> isRefined;
if (!this->readPatches(str,nullptr))
size_t i, n = 0;
str >> isRefined >> n;
RealArray sMin(n,0.0);
for (i = 0; i < n && str.good(); i++)
str >> sMin[i];
if (!str.good() || !this->readPatches(str,nullptr))
return false;
for (i = 0; i < n && i < myModel.size(); i++)
if (sMin[i] > 0.0)
{
myModel[i]->setMinimumSize(sMin[i]);
IFEM::cout <<" element size";
if (myModel.size() > 1)
IFEM::cout <<" (patch "<< myModel[i]->idx+1 <<")";
IFEM::cout <<": "<< sMin[i] << std::endl;
}
if (myPatches.empty())
nGlPatches = myModel.size();