Changed: Moved some methods related to adaptive simulation
from SIMoutput to SIMgeneric such that SIMoutput only deals with result output, and not much else. Retained virtual interfaces for some methods that are used by AdaptiveSIM.
This commit is contained in:
@@ -14,6 +14,9 @@
|
||||
#include "SIMgeneric.h"
|
||||
#include "ModelGenerator.h"
|
||||
#include "ASMbase.h"
|
||||
#include "IntegrandBase.h"
|
||||
#include "Utilities.h"
|
||||
#include "IFEM.h"
|
||||
|
||||
|
||||
ASMbase* SIMgeneric::createDefaultModel ()
|
||||
@@ -76,3 +79,71 @@ int SIMgeneric::findElementContaining (const double* param,
|
||||
int iel = pch->findElementContaining(param);
|
||||
return iel > 0 && global ? pch->getElmID(iel) : iel;
|
||||
}
|
||||
|
||||
|
||||
double SIMgeneric::getReferenceNorm (const Vectors& gNorm, size_t adaptor) const
|
||||
{
|
||||
if (gNorm.empty() || gNorm.front().empty())
|
||||
return 0.0;
|
||||
|
||||
const Vector& fNorm = gNorm.front();
|
||||
if (adaptor < 1 && fNorm.size() > 2)
|
||||
return fNorm(3); // Using the analytical solution, |u|_ref = |u|
|
||||
else if (adaptor >= gNorm.size() || gNorm[adaptor].size() < 2)
|
||||
return -(double)adaptor; // Norm group index is out of range
|
||||
|
||||
// |u|_ref = sqrt( |u^h|^2 + |e^*|^2 )
|
||||
return hypot(fNorm(1),gNorm[adaptor](2));
|
||||
}
|
||||
|
||||
|
||||
double SIMgeneric::getEffectivityIndex (const Vectors& gNorm,
|
||||
size_t idx, size_t inorm) const
|
||||
{
|
||||
return gNorm[idx](inorm) / gNorm.front()(4);
|
||||
}
|
||||
|
||||
|
||||
size_t SIMgeneric::getVCPindex (size_t idx) const
|
||||
{
|
||||
if (extrFunc.empty() || idx == 0)
|
||||
return 0;
|
||||
else if (idx > extrFunc.size())
|
||||
return 0;
|
||||
|
||||
return (this->haveAnaSol() ? 4 : 2) + idx;
|
||||
}
|
||||
|
||||
|
||||
void SIMgeneric::printNorms (const Vectors& norms, size_t w) const
|
||||
{
|
||||
if (norms.empty()) return;
|
||||
|
||||
NormBase* norm = this->getNormIntegrand();
|
||||
const Vector& n = norms.front();
|
||||
|
||||
IFEM::cout <<"Energy norm"
|
||||
<< utl::adjustRight(w-11,norm->getName(1,1)) << n(1);
|
||||
if (n(2) != 0.0)
|
||||
IFEM::cout <<"\nExternal energy"
|
||||
<< utl::adjustRight(w-15,norm->getName(1,2)) << n(2);
|
||||
|
||||
if (this->haveAnaSol() && n.size() >= 4)
|
||||
IFEM::cout <<"\nExact norm"
|
||||
<< utl::adjustRight(w-10,norm->getName(1,3)) << n(3)
|
||||
<<"\nExact error"
|
||||
<< utl::adjustRight(w-11,norm->getName(1,4)) << n(4)
|
||||
<<"\nExact relative error (%) : "<< 100.0*n(4)/n(3);
|
||||
|
||||
size_t i, j = 0, k = 0;
|
||||
while ((i = this->getVCPindex(++k)) && i <= n.size())
|
||||
IFEM::cout <<"\nVCP quantity"
|
||||
<< utl::adjustRight(w-12,norm->getName(1,i)) << n(i);
|
||||
|
||||
for (const SIMoptions::ProjectionMap::value_type& prj : opt.project)
|
||||
if (++j < norms.size())
|
||||
this->printNormGroup(norms[j],n,prj.second);
|
||||
|
||||
IFEM::cout << std::endl;
|
||||
delete norm;
|
||||
}
|
||||
|
||||
@@ -64,6 +64,33 @@ public:
|
||||
//! \return Patch-local or global number of the element containing the point
|
||||
int findElementContaining(const double* param,
|
||||
int patch = 1, bool global = false) const;
|
||||
|
||||
//! \brief Calculates surface traction resultants.
|
||||
virtual bool calcBouForces(Vectors&, const Vectors&) { return false; }
|
||||
|
||||
//! \brief Returns the norm index for the a VCP-recovered quantity.
|
||||
size_t getVCPindex(size_t idx = 1) const;
|
||||
|
||||
//! \brief Prints integrated solution norms to the log stream.
|
||||
//! \param[in] gNorm Global norm values
|
||||
//! \param[in] w Total number of characters in the norm labels
|
||||
virtual void printNorms(const Vectors& gNorm, size_t w = 36) const;
|
||||
|
||||
//! \brief Prints a norm group to the log stream (app-specific).
|
||||
virtual void printNormGroup(const Vector&, const Vector&,
|
||||
const std::string&) const {}
|
||||
|
||||
//! \brief Returns the reference norm to base mesh adaptation upon.
|
||||
//! \param[in] gNorm Global norm values
|
||||
//! \param[in] adaptor 0-based norm group index to be used for mesh adaptation
|
||||
virtual double getReferenceNorm(const Vectors& gNorm, size_t adaptor) const;
|
||||
|
||||
//! \brief Returns the global effectivity index.
|
||||
//! \param[in] gNorm Global norm values
|
||||
//! \param[in] idx 0-based norm group index
|
||||
//! \param[in] inorm 1-based norm index within the specified norm group
|
||||
virtual double getEffectivityIndex(const Vectors& gNorm,
|
||||
size_t idx, size_t inorm) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1871,73 +1871,6 @@ bool SIMoutput::hasPointResultFile () const
|
||||
}
|
||||
|
||||
|
||||
size_t SIMoutput::getVCPindex (size_t idx) const
|
||||
{
|
||||
if (extrFunc.empty() || idx == 0 || idx > extrFunc.size())
|
||||
return 0;
|
||||
|
||||
return (this->haveAnaSol() ? 4 : 2) + idx;
|
||||
}
|
||||
|
||||
|
||||
void SIMoutput::printNorms (const Vectors& norms, size_t w) const
|
||||
{
|
||||
if (norms.empty()) return;
|
||||
|
||||
NormBase* norm = this->getNormIntegrand();
|
||||
const Vector& n = norms.front();
|
||||
|
||||
IFEM::cout <<"Energy norm"
|
||||
<< utl::adjustRight(w-11,norm->getName(1,1)) << n(1);
|
||||
if (n(2) != 0.0)
|
||||
IFEM::cout <<"\nExternal energy"
|
||||
<< utl::adjustRight(w-15,norm->getName(1,2)) << n(2);
|
||||
|
||||
if (this->haveAnaSol() && n.size() >= 4)
|
||||
IFEM::cout <<"\nExact norm"
|
||||
<< utl::adjustRight(w-10,norm->getName(1,3)) << n(3)
|
||||
<<"\nExact error"
|
||||
<< utl::adjustRight(w-11,norm->getName(1,4)) << n(4)
|
||||
<<"\nExact relative error (%) : "<< 100.0*n(4)/n(3);
|
||||
|
||||
size_t i, k = 0;
|
||||
while ((i = this->getVCPindex(++k)) && i <= n.size())
|
||||
IFEM::cout <<"\nVCP quantity"
|
||||
<< utl::adjustRight(w-12,norm->getName(1,i)) << n(i);
|
||||
|
||||
size_t j = 0;
|
||||
for (const SIMoptions::ProjectionMap::value_type& prj : opt.project)
|
||||
if (++j < norms.size())
|
||||
this->printNormGroup(norms[j],n,prj.second);
|
||||
|
||||
IFEM::cout << std::endl;
|
||||
delete norm;
|
||||
}
|
||||
|
||||
|
||||
double SIMoutput::getReferenceNorm (const Vectors& gNorm, size_t adaptor) const
|
||||
{
|
||||
if (gNorm.empty() || gNorm.front().empty())
|
||||
return 0.0;
|
||||
|
||||
const Vector& fNorm = gNorm.front();
|
||||
if (adaptor < 1 && fNorm.size() > 2)
|
||||
return fNorm(3); // Using the analytical solution, |u|_ref = |u|
|
||||
else if (adaptor >= gNorm.size() || gNorm[adaptor].size() < 2)
|
||||
return -(double)adaptor; // Norm group index is out of range
|
||||
|
||||
// |u|_ref = sqrt( |u^h|^2 + |e^*|^2 )
|
||||
return hypot(fNorm(1),gNorm[adaptor](2));
|
||||
}
|
||||
|
||||
|
||||
double SIMoutput::getEffectivityIndex (const Vectors& gNorm,
|
||||
size_t idx, size_t inorm) const
|
||||
{
|
||||
return gNorm[idx](inorm) / gNorm.front()(4);
|
||||
}
|
||||
|
||||
|
||||
bool SIMoutput::serialize (std::map<std::string,std::string>&) const
|
||||
{
|
||||
std::cerr <<" *** SIMoutput::serialize: Must be implemented in sub-class.\n"
|
||||
|
||||
@@ -282,30 +282,17 @@ public:
|
||||
bool hasPointResultFile() const;
|
||||
//! \brief Checks whether result points have been defined or not.
|
||||
bool hasResultPoints() const { return !myPoints.empty(); }
|
||||
//! \brief Returns the norm index for a VCP-recovered quantity.
|
||||
size_t getVCPindex(size_t idx = 1) const;
|
||||
|
||||
//! \brief Calculates surface traction resultants.
|
||||
virtual bool calcBouForces(Vectors&, const Vectors&) { return false; }
|
||||
|
||||
//! \brief Prints integrated solution norms to the log stream.
|
||||
//! \param[in] norms The norm values
|
||||
//! \param[in] w Total number of characters in the norm labels
|
||||
virtual void printNorms(const Vectors& norms, size_t w = 36) const;
|
||||
//! \brief Prints a norm group to the log stream (app-specific).
|
||||
virtual void printNormGroup(const Vector&, const Vector&,
|
||||
const std::string&) const {}
|
||||
|
||||
//! \brief Returns the reference norm to base mesh adaptation upon.
|
||||
virtual double getReferenceNorm(const Vectors& gNorm, size_t adaptor) const;
|
||||
|
||||
//! \brief Returns the global effectivity index.
|
||||
virtual double getEffectivityIndex(const Vectors& gNorm,
|
||||
size_t idx, size_t inorm) const;
|
||||
|
||||
//! \brief Serialization support.
|
||||
virtual bool serialize(std::map<std::string,std::string>&) const;
|
||||
|
||||
//! \brief Returns the reference norm to base mesh adaptation upon.
|
||||
virtual double getReferenceNorm(const Vectors&, size_t) const = 0;
|
||||
//! \brief Returns the global effectivity index.
|
||||
virtual double getEffectivityIndex(const Vectors&, size_t, size_t) const = 0;
|
||||
//! \brief Prints integrated solution norms to the log stream.
|
||||
virtual void printNorms(const Vectors&, size_t = 36) const = 0;
|
||||
|
||||
protected:
|
||||
//! \brief Writes out the additional functions to VTF-file.
|
||||
virtual bool writeAddFuncs(int iStep, int& nBlock, int idBlock, double time);
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "SAM.h"
|
||||
#include "IntegrandBase.h"
|
||||
#include "SIMoutput.h"
|
||||
#include "SIMgeneric.h"
|
||||
#include "SIMdummy.h"
|
||||
|
||||
#include "GenAlphaSIM.h"
|
||||
@@ -111,10 +111,10 @@ private:
|
||||
|
||||
|
||||
// Common base class for the test simulators.
|
||||
class TestSIMbase : public SIMdummy<SIMoutput>
|
||||
class TestSIMbase : public SIMdummy<SIMgeneric>
|
||||
{
|
||||
public:
|
||||
TestSIMbase() : SIMdummy<SIMoutput>(new Problem) {}
|
||||
TestSIMbase() : SIMdummy<SIMgeneric>(new Problem) {}
|
||||
virtual ~TestSIMbase() {}
|
||||
virtual double getInitAcc(size_t = 0) const { return 0.0; }
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include "SAM.h"
|
||||
#include "SIMoutput.h"
|
||||
#include "SIMgeneric.h"
|
||||
#include "SIMdummy.h"
|
||||
|
||||
#include "NonLinSIM.h"
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
|
||||
// Simulator class for a single-DOF skew bar.
|
||||
class Bar1DOF : public SIMdummy<SIMoutput>
|
||||
class Bar1DOF : public SIMdummy<SIMgeneric>
|
||||
{
|
||||
public:
|
||||
Bar1DOF() { mySam = new SAM1DOF(); }
|
||||
|
||||
Reference in New Issue
Block a user