virtual bool assembleSystem(const TimeDomain& time, const Vectors& prevSol, bool newLHSmatrix, bool) { const double M = 1.0; // Mass of the oscillator const double K = 1000.0; // Stiffness of the oscillator myEqSys->initialize(newLHSmatrix); bool ok; if (myProblem->getMode() == SIM::MASS_ONLY) { ElmMats elm; elm.resize(1,1); elm.redim(2); elm.A[0](1,1) = elm.A[0](2,2) = M; // Mass matrix ok = myEqSys->assemble(&elm,1); } else { const double* intPrm = static_cast<Problem*>(myProblem)->getIntPrm(); NewmarkMats elm(intPrm[0],intPrm[1],intPrm[2],intPrm[3]); elm.resize(3,1); elm.redim(2); elm.vec.resize(3); elm.setStepSize(time.dt,0); elm.A[1](1,1) = elm.A[1](2,2) = M; // Mass Matrix elm.A[2](1,1) = elm.A[2](2,2) = K; // Stiffness matrix elm.A[2](2,1) = elm.A[2](1,2) = -K; elm.b[0] = elm.A[2]*prevSol.front(); // Elastic forces elm.b[0] *= -1.0; for (int i = 0; i < 3; i++) elm.vec[i] = prevSol[i]; ok = myEqSys->assemble(&elm,1); } return ok && myEqSys->finalize(newLHSmatrix); }
virtual bool assembleSystem(const TimeDomain& time, const Vectors& prevSol, bool newLHSmatrix, bool) { const double M = 10.0; // Mass of the oscillator const double K = 1000.0; // Stiffness of the oscillator const double F = 1.0; // External load (constant) myEqSys->initialize(newLHSmatrix); bool ok; if (myProblem->getMode() == SIM::MASS_ONLY) { ElmMats elm; elm.resize(1,1); elm.redim(1); elm.A[0].fill(M); // Mass Matrix ok = myEqSys->assemble(&elm,1); } else { const double* intPrm = static_cast<Problem*>(myProblem)->getIntPrm(); NewmarkMats elm(intPrm[0],intPrm[1],intPrm[2],intPrm[3]); elm.resize(3,1); elm.redim(1); elm.vec.resize(3); elm.setStepSize(time.dt,0); elm.A[1].fill(M); // Mass matrix elm.A[2].fill(K); // Stiffness matrix elm.b[0] = -K*prevSol.front(); // Elastic forces for (int i = 0; i < 3; i++) elm.vec[i] = prevSol[i]; ok = myEqSys->assemble(&elm,1); } // Add in the external load ok &= mySam->assembleSystem(*myEqSys->getVector(),&F,1); return ok && myEqSys->finalize(newLHSmatrix); }
LocalIntegral* ElasticityForce::getLocalIntegral (size_t nen, size_t iEl, bool) const { if (nodal) { ElmMats* result = new ElmMats(false); result->resize(0,1); result->redim(static_cast<Elasticity&>(myProblem).getNoSpaceDim()*nen); return result; } return this->ForceBase::getLocalIntegral(nen,iEl); }
LocalIntegral* Elasticity::getLocalIntegral (size_t nen, size_t, bool neumann) const { ElmMats* result; if (m_mode != SIM::DYNAMIC) // linear or nonlinear (quasi-)static analysis result = new ElmMats(); else if (!intPrm[0] && !intPrm[1] && !intPrm[2] && !intPrm[3]) result = new BDFMats(bdf); else if (intPrm[3] > 0.0) // linear dynamic analysis result = new NewmarkMats(intPrm[0], intPrm[1], intPrm[2], intPrm[3], intPrm[4] == 2.0); else // nonlinear dynamic analysis result = new HHTMats(intPrm[2], intPrm[0], intPrm[1], intPrm[4] != 1.0); switch (m_mode) { case SIM::STATIC: case SIM::MASS_ONLY: result->rhsOnly = neumann; result->withLHS = !neumann; result->resize(neumann ? 0 : 1, 1); break; case SIM::DYNAMIC: result->rhsOnly = neumann; result->withLHS = !neumann; result->resize(neumann ? 0 : (intPrm[3] >= 0.0 ? 3 : 4), intPrm[4] == 1.0 ? 3 : (neumann || intPrm[3] > 0.0 ? 1:2)); break; case SIM::VIBRATION: case SIM::BUCKLING: result->resize(2,0); break; case SIM::STIFF_ONLY: result->resize(1,0); break; case SIM::RHS_ONLY: case SIM::INT_FORCES: result->resize(neumann ? 0 : 1, 1); case SIM::RECOVERY: result->rhsOnly = true; result->withLHS = false; break; default: ; } result->redim(nsd*nen); return result; }
LocalIntegral* ElasticBeam::getLocalIntegral (size_t, size_t, bool) const { ElmMats* result; if (m_mode != SIM::DYNAMIC) result = new BeamElmMats(); else if (intPrm[3] > 0.0) result = new NewmarkBeamMats(intPrm[0],intPrm[1],intPrm[2],intPrm[3]); else result = new HHTBeamMats(intPrm[2],intPrm[0],intPrm[1]); switch (m_mode) { case SIM::STATIC: case SIM::MASS_ONLY: result->resize(1,1); break; case SIM::ARCLEN: result->resize(1,2); break; case SIM::DYNAMIC: result->resize(intPrm[3] >= 0.0 ? 3 : 4, intPrm[3] > 0.0 ? 1 : 2); break; case SIM::VIBRATION: case SIM::BUCKLING: result->resize(2,0); break; case SIM::STIFF_ONLY: result->resize(1,0); break; case SIM::RHS_ONLY: case SIM::INT_FORCES: result->resize(0,1); result->rhsOnly = true; result->withLHS = false; break; default: ; } result->redim(12); return result; }