Added an extra assembleSystem method to support external point loads directly in nodes

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@1200 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
kmo 2011-09-23 18:23:11 +00:00 committed by Knut Morten Okstad
parent 0a1d1cb377
commit de6cd8d40e
2 changed files with 52 additions and 7 deletions

View File

@ -180,20 +180,21 @@ bool SAM::initSystemEquations ()
if (!mpmceq && nceq > 0) return false;
// Initialize the DOF-to-equation connectivity array
int ierr = 0;
int i, j, ierr = 0;
meqn = new int[ndof];
memset(meqn,0,ndof*sizeof(int));
#ifdef USE_F77SAM
syseq_(msc,mpmceq,mmceq,6,mpar,meqn,ierr);
for (i = j = 0; i < ndof; i++)
if (msc[i] == 0) msc[i] = --j; // reaction force indices
#else
int i, j, idof;
int ndof1 = 0;
int ndof2 = 0;
int npdof = 0;
int nddof = 0;
for (i = 0; i < ndof; i++)
if (msc[i] == 0)
msc[i] = -(++nspdof);
msc[i] = -(++nspdof); // reaction force indices
else if (msc[i] == 1)
ndof1++;
else if (msc[i] == 2)
@ -209,7 +210,7 @@ bool SAM::initSystemEquations ()
{
int ip = mpmceq[i-1];
int jp = mpmceq[i]-1;
idof = mmceq[ip-1];
int idof = mmceq[ip-1];
if (idof < 1 || idof > ndof)
{
ierr--;
@ -254,7 +255,7 @@ bool SAM::initSystemEquations ()
i = 1;
j = ndof1+1;
for (idof = 0; idof < ndof; idof++)
for (int idof = 0; idof < ndof; idof++)
if (msc[idof] == 1)
meqn[idof] = i++;
else if (msc[idof] == 2)
@ -473,8 +474,6 @@ bool SAM::assembleSystem (SystemVector& sysRHS,
const RealArray& eS, int iel,
Vector* reactionForces) const
{
if (!meqn) return false;
real* sysrhsPtr = sysRHS.getPtr();
int ierr = 0;
#ifdef USE_F77SAM
@ -510,6 +509,42 @@ bool SAM::assembleSystem (SystemVector& sysRHS,
}
bool SAM::assembleSystem (SystemVector& sysRHS, const real* nS, int inod,
Vector* reactionForces) const
{
IntVec mnen;
if (!this->getNodeEqns(mnen,inod))
return false;
real* sysrhsPtr = sysRHS.getPtr();
for (size_t i = 0; i < mnen.size(); i++)
{
int ieq = mnen[i];
int iceq = -ieq;
if (ieq > 0)
sysrhsPtr[ieq-1] += nS[i];
else if (iceq > 0)
for (int ip = mpmceq[iceq-1]; ip < mpmceq[iceq]-1; ip++)
if (mmceq[ip] > 0)
{
ieq = meqn[mmceq[ip]-1];
sysrhsPtr[ieq-1] += ttcc[ip]*nS[i];
}
}
sysRHS.restore(sysrhsPtr);
if (reactionForces)
{
int ipR, j, k = 0;
for (j = madof[inod-1]; j < madof[inod]; j++, k++)
if ((ipR = -msc[j-1]) > 0 && (size_t)ipR <= reactionForces->size())
(*reactionForces)(ipR) += nS[k];
}
return true;
}
void SAM::assembleReactions (Vector& reac, const RealArray& eS, int iel) const
{
int i, j, k, ipR;

View File

@ -149,6 +149,16 @@ public:
const RealArray& eS, int iel = 0,
Vector* reactionForces = 0) const;
//! \brief Adds a node load vector into the system load vector.
//! \param sysRHS The right-hand-side system load vector
//! \param[in] nS The nodal load vector
//! \param[in] inod Identifier for the node that \a nS belongs to
//! \param reactionForces Pointer to vector of nodal reaction forces
//! \return \e true on successful assembly, otherwise \e false
virtual bool assembleSystem(SystemVector& sysRHS,
const real* eS, int inod = 0,
Vector* reactionForces = 0) const;
//! \brief Finds the matrix of equation numbers for an element.
//! \param[out] meen Matrix of element equation numbers
//! \param[in] iel Identifier for the element to get the equation numbers for