Skip to content

Commit

Permalink
Changed: Some members and methods are now in the parent class SIMmodal
Browse files Browse the repository at this point in the history
  • Loading branch information
kmokstad committed May 15, 2024
1 parent 85659e5 commit d883a9d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 110 deletions.
60 changes: 10 additions & 50 deletions Linear/SIMLinElModal.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ template<class Dim> class SIMLinElModal : public SIMLinEl<Dim>, public SIMmodal
//! \param[in] modes Array of eigenmodes for the elasticity problem
//! \param[in] checkRHS If \e true, ensure the model is in a right-hand system
explicit SIMLinElModal(std::vector<Mode>& modes, bool checkRHS = false)
: SIMLinEl<Dim>(nullptr,checkRHS,'m'), SIMmodal(modes)
{
parsed = false;
alpha1 = alpha2 = 0.0;
}
: SIMLinEl<Dim>(nullptr,checkRHS,'m'), SIMmodal(modes) {}
//! \brief Empty destructor.
virtual ~SIMLinElModal() {}

Expand Down Expand Up @@ -68,18 +64,17 @@ template<class Dim> class SIMLinElModal : public SIMLinEl<Dim>, public SIMmodal
// We need to do this in the first iteration only, as for linear systems
// the load vector is not supposed to change during the iterations.
if (!this->Dim::assembleSystem(time,sol,false))
return false;
return false;

// Extract the load vector in DOF-order
if (!this->Dim::extractLoadVec(Rhs))
return false;
return false;
}

// Assemble the modal equation system
if (!this->assembleModalSystem(time,mSol,Rhs,
if (!this->assembleModalSystem(time,mSol,
Dim::myProblem->getIntegrationPrm(2),
Dim::myProblem->getIntegrationPrm(3),
alpha1,alpha2))
Dim::myProblem->getIntegrationPrm(3)))
return false;

// Swap the equation systems such that the dynamic simulation driver
Expand All @@ -93,31 +88,14 @@ template<class Dim> class SIMLinElModal : public SIMLinEl<Dim>, public SIMmodal
//! \param[in] swapBack If \e true, the equation systems are swapped
virtual const Vectors& expandSolution(const Vectors& mSol, bool swapBack)
{
if (!this->expandSolution(mSol,sol))
sol.clear();

// Swap back to the full equation system data for postprocessing
// and assembly of load vector for the next time step
if (swapBack)
this->swapSystem(Dim::myEqSys,Dim::mySam);

return sol;
}

//! \brief Returns the current expanded dynamic solution.
//! \param[in] idx Solution vector index
virtual const Vector& expandedSolution(int idx) const
{
if (idx >= 0 && idx < (int)sol.size())
return sol[idx];

static Vector empty;
return empty;
return this->expandSolution(mSol);
}

//! \brief Returns the number of expanded dynamic solution vectors.
virtual size_t numExpSolution() const { return sol.size(); }

//! \brief Serialization support, for the eigenmodes.
virtual bool serialize(std::map<std::string,std::string>& data) const
{
Expand Down Expand Up @@ -157,39 +135,21 @@ template<class Dim> class SIMLinElModal : public SIMLinEl<Dim>, public SIMmodal
//! during the second time parsing for the time integration setup only.
virtual bool parse(const tinyxml2::XMLElement* elem)
{
if (parsed)
IFEM::cout <<"\t(skipped)"<< std::endl;
else if (!strcasecmp(elem->Value(),"newmarksolver"))
{
utl::getAttribute(elem,"alpha1",alpha1);
utl::getAttribute(elem,"alpha2",alpha2);
}
else
return this->SIMLinEl<Dim>::parse(elem);

return true;
return this->parseParams(elem) || this->SIMLinEl<Dim>::parse(elem);
}

//! \brief Performs some pre-processing tasks on the FE model.
//! \details In addition to invoking the inherited method,
//! this method sets the \a parsed flag, such that the model parsing
//! is skipped when the input file is parsed for the second time,
//! for the time integration setup.
//! this method sets the \a parsed flag of the parent class SIMmodal,
//! such that the model parsing is skipped when the input file is parsed
//! for the second time while doing the time integration setup.
virtual bool preprocessB()
{
parsed = true;
this->setIntegrationPrm(0,alpha1);
this->setIntegrationPrm(1,alpha2);
return this->SIMLinEl<Dim>::preprocessB();
}

private:
bool parsed; //!< Set to \e true after the model has been initialized
double alpha1; //!< Mass-proportional damping parameter
double alpha2; //!< Stiffness-proportional damping parameter

Vector Rhs; //!< Current right-hand-side load vector of the dynamic system
Vectors sol; //!< Expanded solution vectors from the modal solution
};

#endif
46 changes: 5 additions & 41 deletions Linear/SIMLinKLModal.C
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,7 @@
//==============================================================================

#include "SIMLinKLModal.h"
#include "KirchhoffLovePlate.h"
#include "KirchhoffLoveShell.h"
#include "Utilities.h"
#include "IFEM.h"
#include "tinyxml2.h"


SIMLinKLModal::SIMLinKLModal (std::vector<Mode>& modes, bool shell)
: SIMLinElKL(nullptr,shell,true), SIMmodal(modes)
{
parsed = false;
alpha1 = alpha2 = 0.0;
}
#include "IntegrandBase.h"


bool SIMLinKLModal::assembleSystem (const TimeDomain& time,
Expand Down Expand Up @@ -52,10 +40,9 @@ bool SIMLinKLModal::assembleSystem (const TimeDomain& time,
}

// Assemble the modal equation system
if (!this->assembleModalSystem(time,mSol,Rhs,
if (!this->assembleModalSystem(time,mSol,
myProblem->getIntegrationPrm(2),
myProblem->getIntegrationPrm(3),
alpha1,alpha2))
myProblem->getIntegrationPrm(3)))
return false;

// Swap the equation systems such that the dynamic simulation driver
Expand All @@ -66,25 +53,12 @@ bool SIMLinKLModal::assembleSystem (const TimeDomain& time,

const Vectors& SIMLinKLModal::expandSolution (const Vectors& mSol, bool swapBck)
{
if (!this->expandSolution(mSol,sol))
sol.clear();

// Swap back to the full equation system data for postprocessing
// and assembly of load vector for the next time step
if (swapBck)
this->swapSystem(myEqSys,mySam);

return sol;
}


const Vector& SIMLinKLModal::expandedSolution (int idx) const
{
if (idx >= 0 && idx < (int)sol.size())
return sol[idx];

static Vector empty;
return empty;
return this->expandSolution(mSol);
}


Expand Down Expand Up @@ -119,17 +93,7 @@ bool SIMLinKLModal::projectModes (Matrices& sesol,

bool SIMLinKLModal::parse (const tinyxml2::XMLElement* elem)
{
if (parsed)
IFEM::cout <<"\t(skipped)"<< std::endl;
else if (!strcasecmp(elem->Value(),"newmarksolver"))
{
utl::getAttribute(elem,"alpha1",alpha1);
utl::getAttribute(elem,"alpha2",alpha2);
}
else
return this->SIMLinElKL::parse(elem);

return true;
return this->parseParams(elem) || this->SIMLinElKL::parse(elem);
}


Expand Down
24 changes: 5 additions & 19 deletions Linear/SIMLinKLModal.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class SIMLinKLModal : public SIMLinElKL, public SIMmodal
//! \brief The constructor forwards to the parent class constructors.
//! \param[in] modes Array of eigenmodes for the elasticity problem
//! \param[in] shell If \e true, 3 DOFs per node is assumed, otherwise 1
explicit SIMLinKLModal(std::vector<Mode>& modes, bool shell = false);
explicit SIMLinKLModal(std::vector<Mode>& modes, bool shell = false)
: SIMLinElKL(nullptr,shell,true), SIMmodal(modes) {}
//! \brief Empty destructor.
virtual ~SIMLinKLModal() {}

Expand All @@ -55,13 +56,6 @@ class SIMLinKLModal : public SIMLinElKL, public SIMmodal
//! \param[in] swapBck If \e true, the equation systems are swapped
virtual const Vectors& expandSolution(const Vectors& mSol, bool swapBck);

//! \brief Returns the current expanded dynamic solution.
//! \param[in] idx Solution vector index
virtual const Vector& expandedSolution(int idx) const;

//! \brief Returns the number of expanded dynamic solution vectors.
virtual size_t numExpSolution() const { return sol.size(); }

//! \brief Serialization support, for the eigenmodes.
virtual bool serialize(std::map<std::string,std::string>& data) const;
//! \brief Deserialization support (for simulation restart).
Expand All @@ -84,18 +78,10 @@ class SIMLinKLModal : public SIMLinElKL, public SIMmodal

//! \brief Performs some pre-processing tasks on the FE model.
//! \details In addition to invoking the inherited method,
//! this method sets the \a parsed flag, such that the model parsing
//! is skipped when the input file is parsed for the second time,
//! for the time integration setup.
//! this method sets the \a parsed flag of the parent class SIMmodal,
//! such that the model parsing is skipped when the input file is parsed
//! for the second time while doing the time integration setup.
virtual bool preprocessB();

private:
bool parsed; //!< Set to \e true after the model has been initialized
double alpha1; //!< Mass-proportional damping parameter
double alpha2; //!< Stiffness-proportional damping parameter

Vector Rhs; //!< Current right-hand-side load vector of the dynamic system
Vectors sol; //!< Expanded solution vectors from the modal solution
};

#endif

0 comments on commit d883a9d

Please sign in to comment.