Some kernel modifications to support adaptivity
git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1183 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
parent
02183f4e5d
commit
bcc84da438
@ -23,6 +23,13 @@ IntegrandBase::~IntegrandBase ()
|
||||
}
|
||||
|
||||
|
||||
void IntegrandBase::resetSolution ()
|
||||
{
|
||||
for (size_t i = 0; i < primsol.size(); i++)
|
||||
primsol[i].clear();
|
||||
}
|
||||
|
||||
|
||||
bool IntegrandBase::initElement (const std::vector<int>& MNPC,
|
||||
const Vec3&, size_t)
|
||||
{
|
||||
@ -233,16 +240,20 @@ ElmNorm& NormBase::getElmNormBuffer (LocalIntegral*& elmInt, const size_t nn)
|
||||
}
|
||||
|
||||
|
||||
const char* NormBase::getName(size_t i, const char* prefix)
|
||||
const char* NormBase::getName (size_t i, const char* prefix)
|
||||
{
|
||||
static const char* s[9] = { "a(u^h,u^h)^0.5", "a(u,u)^0.5",
|
||||
"a(e,e)^0.5, e=u-u^h", "a(u^r,u^r)^0.5",
|
||||
"a(e,e)^0.5, e=u^r-u^h", "a(e,e)^0.5, e=u-u^r",
|
||||
"a(u^rr,u^rr)^0.5", "a(e,e)^0.5, e=u^rr-u^h",
|
||||
"a(e,e)^0.5, e=u-u^rr"};
|
||||
static const char* s[9] = {
|
||||
"a(u^h,u^h)^0.5",
|
||||
"a(u,u)^0.5",
|
||||
"a(e,e)^0.5, e=u-u^h",
|
||||
"a(u^r,u^r)^0.5",
|
||||
"a(e,e)^0.5, e=u^r-u^h",
|
||||
"a(e,e)^0.5, e=u-u^r",
|
||||
"a(u^rr,u^rr)^0.5",
|
||||
"a(e,e)^0.5, e=u^rr-u^h",
|
||||
"a(e,e)^0.5, e=u-u^rr"
|
||||
};
|
||||
if (!prefix) return s[i];
|
||||
|
||||
std::cout << i << std::endl;
|
||||
|
||||
static std::string name;
|
||||
name = prefix + std::string(" ") + s[i];
|
||||
|
@ -168,6 +168,9 @@ public:
|
||||
//! \brief Accesses the primary solution vector of current patch.
|
||||
Vector& getSolution(size_t n = 0) { return primsol[n]; }
|
||||
|
||||
//! \brief Resets the primary solution vectors.
|
||||
void resetSolution();
|
||||
|
||||
protected:
|
||||
Vectors primsol; //!< Primary solution vectors for current patch
|
||||
ElmMats* myMats; //!< Local element matrices
|
||||
@ -215,9 +218,6 @@ public:
|
||||
//! \brief Returns whether this norm has explicit boundary contributions.
|
||||
virtual bool hasBoundaryTerms() const { return false; }
|
||||
|
||||
//! \brief Returns a 1-based index of the external energy norm.
|
||||
virtual size_t indExt() const { return 0; }
|
||||
|
||||
//! \brief Returns the number of field components.
|
||||
virtual size_t getNoFields() const { return 0; }
|
||||
|
||||
|
@ -231,8 +231,6 @@ public:
|
||||
|
||||
//! \brief Returns whether this norm has explicit boundary contributions.
|
||||
virtual bool hasBoundaryTerms() const { return true; }
|
||||
//! \brief Returns a 1-based index of the external energy norm.
|
||||
virtual size_t indExt() const { return 2; }
|
||||
|
||||
//! \brief Returns the number of norm quantities.
|
||||
virtual size_t getNoFields() const;
|
||||
|
@ -201,8 +201,6 @@ public:
|
||||
|
||||
//! \brief Returns whether this norm has explicit boundary contributions.
|
||||
virtual bool hasBoundaryTerms() const { return true; }
|
||||
//! \brief Returns a 1-based index of the external energy norm.
|
||||
virtual size_t indExt() const { return 2; }
|
||||
|
||||
//! \brief Returns the number of norm quantities.
|
||||
virtual size_t getNoFields() const;
|
||||
|
@ -80,6 +80,17 @@ SIMbase::~SIMbase ()
|
||||
|
||||
for (FEModelVec::iterator i1 = myModel.begin(); i1 != myModel.end(); i1++)
|
||||
delete *i1;
|
||||
|
||||
this->clearProperties();
|
||||
|
||||
#ifdef SP_DEBUG
|
||||
std::cout <<"Leaving SIMbase destructor"<< std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void SIMbase::clearProperties ()
|
||||
{
|
||||
for (SclFuncMap::iterator i2 = myScalars.begin(); i2 != myScalars.end(); i2++)
|
||||
delete i2->second;
|
||||
for (VecFuncMap::iterator i3 = myVectors.begin(); i3 != myVectors.end(); i3++)
|
||||
@ -87,9 +98,11 @@ SIMbase::~SIMbase ()
|
||||
for (TracFuncMap::iterator i4 = myTracs.begin(); i4 != myTracs.end(); i4++)
|
||||
delete i4->second;
|
||||
|
||||
#ifdef SP_DEBUG
|
||||
std::cout <<"Leaving SIMbase destructor"<< std::endl;
|
||||
#endif
|
||||
myPatches.clear();
|
||||
myScalars.clear();
|
||||
myVectors.clear();
|
||||
myTracs.clear();
|
||||
myProps.clear();
|
||||
}
|
||||
|
||||
|
||||
@ -339,10 +352,11 @@ bool SIMbase::preprocess (const std::vector<int>& ignoredPatches, bool fixDup)
|
||||
}
|
||||
|
||||
// Initialize data structures for the algebraic system
|
||||
if (mySam) delete mySam;
|
||||
#ifdef PARALLEL_PETSC
|
||||
mySam = new SAMpatchPara(l2gn);
|
||||
mySam = new SAMpatchPara(l2gn);
|
||||
#else
|
||||
mySam = new SAMpatch();
|
||||
mySam = new SAMpatch();
|
||||
#endif
|
||||
|
||||
return mySam->init(myModel,nnod) && ok;
|
||||
@ -381,6 +395,7 @@ bool SIMbase::initSystem (SystemMatrix::Type mType, size_t nMats, size_t nVec)
|
||||
myModel[i]->printNodes(std::cout,heading.c_str());
|
||||
#endif
|
||||
|
||||
if (myEqSys) delete myEqSys;
|
||||
myEqSys = new AlgEqSystem(*mySam);
|
||||
myEqSys->init(mType,mySolParams,nMats,nVec,num_threads_SLU);
|
||||
myEqSys->initAssembly();
|
||||
@ -396,11 +411,12 @@ bool SIMbase::setAssociatedRHS (size_t iMat, size_t iVec)
|
||||
}
|
||||
|
||||
|
||||
bool SIMbase::setMode (int mode)
|
||||
bool SIMbase::setMode (int mode, bool resetSol)
|
||||
{
|
||||
if (!myProblem) return false;
|
||||
|
||||
myProblem->setMode((SIM::SolutionMode)mode);
|
||||
if (resetSol) myProblem->resetSolution();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -812,21 +828,21 @@ bool SIMbase::solutionNorms (const TimeDomain& time,
|
||||
else
|
||||
ok = false;
|
||||
|
||||
// Add norm contributions due to inhomogeneous Dirichlet boundary conditions
|
||||
// (if any), that is, the path integral of the total solution vector
|
||||
// times the reaction forces at the prescribed DOFs
|
||||
// Add norm contributions due to inhomogeneous Dirichlet boundary conditions.
|
||||
// That is, the path integral of the total solution vector times the reaction
|
||||
// forces at the prescribed DOFs.
|
||||
const Vector* reactionForces = myEqSys->getReactions();
|
||||
if (reactionForces && norm->indExt() > 0)
|
||||
if (reactionForces)
|
||||
if (psol.size() > 1)
|
||||
{
|
||||
static double extEnergy = 0.0;
|
||||
static Vector prevForces(reactionForces->size());
|
||||
extEnergy += mySam->normReact(psol[0]-psol[1],*reactionForces+prevForces);
|
||||
gNorm(norm->indExt()) += extEnergy;
|
||||
gNorm(2) += extEnergy;
|
||||
prevForces = *reactionForces;
|
||||
}
|
||||
else
|
||||
gNorm(norm->indExt()) += mySam->normReact(psol.front(),*reactionForces);
|
||||
gNorm(2) += mySam->normReact(psol.front(),*reactionForces);
|
||||
|
||||
#ifdef PARALLEL_PETSC
|
||||
if (nProc > 1)
|
||||
|
@ -85,14 +85,19 @@ public:
|
||||
// Model input and pre-processing methods
|
||||
// ======================================
|
||||
|
||||
//! \brief Initializes the property containers of the model.
|
||||
//! \details Use this method to clear the model before re-reading
|
||||
//! the input file in the refinement step of an adaptive simulation.
|
||||
virtual void clearProperties();
|
||||
|
||||
//! \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 Reads patches from a given stream.
|
||||
//! \param[in] isp The stream to read from
|
||||
virtual void readPatches(std::istream& isp) {}
|
||||
//! \brief Refines a list of elements.
|
||||
virtual bool refine(const std::vector<int>&,
|
||||
const char* = 0) { return false; }
|
||||
|
||||
//! \brief Performs some pre-processing tasks on the FE model.
|
||||
//! \param[in] ignoredPatches Indices of patches to ignore in the analysis
|
||||
@ -114,7 +119,8 @@ public:
|
||||
|
||||
//! \brief Defines the solution mode before the element assembly is started.
|
||||
//! \param[in] mode The solution mode to use
|
||||
bool setMode(int mode);
|
||||
//! \param[in] resetSol If \e true, the internal solution vectors are cleared
|
||||
bool setMode(int mode, bool resetSol = false);
|
||||
|
||||
//! \brief Defines the spatial numerical integration scheme to use.
|
||||
virtual void setQuadratureRule(size_t) {}
|
||||
|
Loading…
Reference in New Issue
Block a user