Пример #1
0
 void DampedClassicalWavePropagator::dampVertical(unsigned int x, int delta, unsigned int numDampPts) {
     for (unsigned int j = 0; j < _largeLattice.getLength(); j++ ) {
         for (unsigned int step = 0; step < numDampPts; step++) {
             const unsigned int distFromDampBoundary = numDampPts - step;
             const LatticeVal damp = getDamp(distFromDampBoundary);
             unsigned int i = x + step * delta;
             _largeLattice.scaleLocation(i, j, damp);
             _priorLattice.scaleLocation(i, j, damp);
         }
     }
 }
Пример #2
0
 void DampedClassicalWavePropagator::dampHorizontal(unsigned int y, int delta, unsigned int numDampPts) {
     for (unsigned int i = 0; i < _largeLattice.getWidth(); i++) {
         for (unsigned int step = 0; step < numDampPts; step++) {
             const unsigned int distFromDampBoundary = numDampPts - step;
             const LatticeVal damp = getDamp(distFromDampBoundary);
             unsigned int j = y + step * delta;
             _largeLattice.scaleLocation(i, j, damp);
             _priorLattice.scaleLocation(i, j, damp);
         }
     }
 }
Пример #3
0
const Vector&
PFEMElement2DBubble::getResistingForceIncInertia()
{

    // resize P
    int ndf = this->getNumDOF();
    P.resize(ndf);
    P.Zero();

    // get velocity, accleration
    Vector v(ndf), vdot(ndf);
    for(int i=0; i<3; i++) {
        const Vector& accel = nodes[2*i]->getTrialAccel();
        vdot(numDOFs(2*i)) = accel(0);
        vdot(numDOFs(2*i)+1) = accel(1);

        const Vector& accel2 = nodes[2*i+1]->getTrialAccel();  // pressure
        vdot(numDOFs(2*i+1)) = accel2(0);

        const Vector& vel = nodes[2*i]->getTrialVel();
        v(numDOFs(2*i)) = vel(0);
        v(numDOFs(2*i)+1) = vel(1);

        const Vector& vel2 = nodes[2*i+1]->getTrialVel();   // pressure
        v(numDOFs(2*i+1)) = vel2(0);

    }

    // bubble force
    Vector fp(3);
    getFp(fp);

    // internal force
    P.addMatrixVector(1.0, getMass(), vdot, 1.0);
    P.addMatrixVector(1.0, getDamp(), v, 1.0);

    // external force
    Vector F(6);
    getF(F);
    for(int i=0; i<3; i++) {
        P(numDOFs(2*i)) -= F(2*i);
        P(numDOFs(2*i)+1) -= F(2*i+1);
        P(numDOFs(2*i+1)) -= fp(i);
    }

    //opserr<<"F = "<<F;
    return P;
}
const Vector&
PFEMElement2DCompressible::getResistingForceIncInertia()
{

    // resize P
    int ndf = this->getNumDOF();
    P.resize(ndf);
    P.Zero();

    // get velocity, accleration
    Vector v(ndf), vdot(ndf);
    for(int i=0; i<3; i++) {
        const Vector& accel = nodes[2*i]->getTrialAccel();
        vdot(numDOFs(2*i)) = accel(0);
        vdot(numDOFs(2*i)+1) = accel(1);

        const Vector& accel2 = nodes[2*i+1]->getTrialAccel();
        vdot(numDOFs(2*i+1)) = accel2(0);

        const Vector& vel = nodes[2*i]->getTrialVel();
        v(numDOFs(2*i)) = vel(0);
        v(numDOFs(2*i)+1) = vel(1);

        const Vector& vel2 = nodes[2*i+1]->getTrialVel();
        v(numDOFs(2*i+1)) = vel2(0);
    }

    // Ma+k1v-Gp
    // Gt*v+Mp*p
    P.addMatrixVector(1.0, getMass(), vdot, 1.0);
    P.addMatrixVector(1.0, getDamp(), v, 1.0);

    // f
    double J2 = J/2.0;
    for(int i=0; i<3; i++) {
        P(numDOFs(2*i)) -= rho*bx/3.*J2;
        P(numDOFs(2*i)+1) -= rho*by/3.*J2;
    }


    return P;
}
Пример #5
0
const Vector&
PFEMElement2D::getResistingForceIncInertia()
{
    // resize P
    P.resize(ndf);
    P.Zero();

    // get v and p
    Vector v(ndf), vdot(ndf);
    for(int a=0; a<3; a++) {

        const Vector& vel = nodes[2*a]->getTrialVel();
	const Vector& accel = nodes[2*a]->getTrialAccel();
	v(vxdof[a]) = vel(0);
	v(vydof[a]) = vel(1);
	vdot(vxdof[a]) = accel(0);
	vdot(vydof[a]) = accel(1);

	const Vector& pressure = nodes[2*a+1]->getTrialVel();
	const Vector& pressuredot = nodes[2*a+1]->getTrialAccel();
	v(pdof[a]) = pressure(0);
	vdot(pdof[a]) = pressuredot(0);

	// F, Fp
	P(vxdof[a]) = F(0);
	P(vydof[a]) = F(1);
	P(pdof[a]) = Fp[a];
    }

    // M*vdot+K*v
    P.addMatrixVector(-1.0, getMass(), vdot, 1.0);
    bool l = lumped;
    lumped = false;
    P.addMatrixVector(1.0, getDamp(), v, 1.0);
    lumped = l;

    return P;
}
Пример #6
0
        DirectionTypePtr Direction::createDirectionType( std::ostream& message, xml::XElementIterator& subIter, xml::XElementIterator& subIterEnd, bool& isSuccess )
        {
            auto directionType = makeDirectionType();
            
            if( subIter == subIterEnd )
            {
                message << "Direction: well thats weird - should not get here" << std::endl;
                isSuccess = false;
                return directionType;
            }
            
            if( subIter->getName() == "wedge" )
            {
                directionType->setChoice( DirectionType::Choice::wedge );
                isSuccess &= directionType->getWedge()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "dashes" )
            {
                directionType->setChoice( DirectionType::Choice::dashes );
                isSuccess &= directionType->getDashes()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "bracket" )
            {
                directionType->setChoice( DirectionType::Choice::bracket );
                isSuccess &= directionType->getBracket()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "pedal" )
            {
                directionType->setChoice( DirectionType::Choice::pedal );
                isSuccess &= directionType->getPedal()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "metronome" )
            {
                directionType->setChoice( DirectionType::Choice::metronome );
                isSuccess &= directionType->getMetronome()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "octave-shift" )
            {
                directionType->setChoice( DirectionType::Choice::octaveShift );
                isSuccess &= directionType->getOctaveShift()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "harp-pedals" )
            {
                directionType->setChoice( DirectionType::Choice::harpPedals );
                isSuccess &= directionType->getHarpPedals()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "damp" )
            {
                directionType->setChoice( DirectionType::Choice::damp );
                isSuccess &= directionType->getDamp()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "damp-all" )
            {
                directionType->setChoice( DirectionType::Choice::dampAll );
                isSuccess &= directionType->getDampAll()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "eyeglasses" )
            {
                directionType->setChoice( DirectionType::Choice::eyeglasses );
                isSuccess &= directionType->getEyeglasses()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "string-mute" )
            {
                directionType->setChoice( DirectionType::Choice::stringMute );
                isSuccess &= directionType->getStringMute()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "scordatura" )
            {
                directionType->setChoice( DirectionType::Choice::scordatura );
                isSuccess &= directionType->getScordatura()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "image" )
            {
                directionType->setChoice( DirectionType::Choice::image );
                isSuccess &= directionType->getImage()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "principal-voice" )
            {
                directionType->setChoice( DirectionType::Choice::principalVoice );
                isSuccess &= directionType->getPrincipalVoice()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "accordion-registration" )
            {
                directionType->setChoice( DirectionType::Choice::accordionRegistration );
                isSuccess &= directionType->getAccordionRegistration()->fromXElement( message, *subIter );
                return directionType;
            }
            
            if( subIter->getName() == "other-direction" )
            {
                directionType->setChoice( DirectionType::Choice::otherDirection );
                isSuccess &= directionType->getOtherDirection()->fromXElement( message, *subIter );
                return directionType;
            }
                
            std::string name = "rehearsal";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::rehearsal );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makeRehearsal();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getRehearsalSet().size() == 1 )
                    {
                        directionType->addRehearsal( itemToAdd );
                        directionType->removeRehearsal( directionType->getRehearsalSet().cbegin() );
                    }
                    else
                    {
                        directionType->addRehearsal( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end rehearsal
            
            
            name = "segno";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::segno );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makeSegno();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getSegnoSet().size() == 1 )
                    {
                        directionType->addSegno( itemToAdd );
                        directionType->removeSegno( directionType->getSegnoSet().cbegin() );
                    }
                    else
                    {
                        directionType->addSegno( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end segno
            
            
            name = "words";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::words );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makeWords();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getWordsSet().size() == 1 )
                    {
                        directionType->addWords( itemToAdd );
                        directionType->removeWords( directionType->getWordsSet().cbegin() );
                    }
                    else
                    {
                        directionType->addWords( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end words
            
            
            name = "coda";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::coda );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makeCoda();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getCodaSet().size() == 1 )
                    {
                        directionType->addCoda( itemToAdd );
                        directionType->removeCoda( directionType->getCodaSet().cbegin() );
                    }
                    else
                    {
                        directionType->addCoda( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end coda
            
            
            name = "dynamics";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::dynamics );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makeDynamics();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getDynamicsSet().size() == 1 )
                    {
                        directionType->addDynamics( itemToAdd );
                        directionType->removeDynamics( directionType->getDynamicsSet().cbegin() );
                    }
                    else
                    {
                        directionType->addDynamics( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end dynamics
            
            
            name = "percussion";
            if( subIter->getName() == name )
            {
                directionType->setChoice( DirectionType::Choice::percussion );
                bool isFirstSubItemAdded = false;
                
                while( subIter != subIterEnd )
                {
                    if( subIter->getName() != name )
                    {
                        message << "Direction: createDirectionType encountered an unexpected element '" << subIter->getName() << "' while parsing a collection of '" << name << "' elements" << std::endl;
                        isSuccess = false;
                        return directionType;
                    }
                    auto itemToAdd = makePercussion();
                    isSuccess &= itemToAdd->fromXElement( message, *subIter );
                    if( !isFirstSubItemAdded && directionType->getPercussionSet().size() == 1 )
                    {
                        directionType->addPercussion( itemToAdd );
                        directionType->removePercussion( directionType->getPercussionSet().cbegin() );
                    }
                    else
                    {
                        directionType->addPercussion( itemToAdd );
                    }
                    isFirstSubItemAdded = true;
                    ++subIter;
                } // end loop
                return directionType;
            } // end percussion

            return directionType;
        }