コード例 #1
0
ファイル: BodyRigid.cpp プロジェクト: kollmanj/omd
 void BodyRigid::setMassInertia(Vect3 const &row0,Vect3 const &row1,Vect3 const &row2)
 {
     m_inertia(0,0)=row0.x(); m_inertia(0,1)=row0.y(); m_inertia(0,2)=row0.z();
     m_inertia(1,0)=row1.x(); m_inertia(1,1)=row1.y(); m_inertia(1,2)=row1.z();
     m_inertia(2,0)=row2.x(); m_inertia(2,1)=row2.y(); m_inertia(2,2)=row2.z();
     cout << m_inertia << std::endl;
 }
コード例 #2
0
ファイル: operators.cpp プロジェクト: eolivi/openmeeg
    // General routine for applying _operatorFerguson (see this function for further comments)
    // to an entire mesh, and storing coordinates of the output in a Matrix.
    void operatorFerguson(const Vect3& x,const Mesh& m,Matrix& mat,const unsigned& offsetI,const double& coeff)
    {
        #pragma omp parallel for
        #ifndef OPENMP_3_0
        for (int i=0;i<m.vertex_size();++i) {
            const Mesh::const_vertex_iterator vit=m.vertex_begin()+i;
        #else
        for (Mesh::const_vertex_iterator vit=m.vertex_begin();vit<m.vertex_end();++vit) {
        #endif
            Vect3 v = _operatorFerguson(x, **vit, m);
            mat(offsetI + 0, (*vit)->index()) += v.x() * coeff;
            mat(offsetI + 1, (*vit)->index()) += v.y() * coeff;
            mat(offsetI + 2, (*vit)->index()) += v.z() * coeff;
        }
    }

    void operatorDipolePotDer(const Vect3& r0,const Vect3& q,const Mesh& m,Vector& rhs,const double& coeff,const unsigned gauss_order,const bool adapt_rhs) 
    {
        static analyticDipPotDer anaDPD;

        Integrator<Vect3,analyticDipPotDer>* gauss = (adapt_rhs) ? new AdaptiveIntegrator<Vect3, analyticDipPotDer>(0.001) :
                                                                   new Integrator<Vect3, analyticDipPotDer>;

        gauss->setOrder(gauss_order);
        #pragma omp parallel for private(anaDPD)
        #ifndef OPENMP_3_0
        for (int i=0;i<m.size();++i) {
            const Mesh::const_iterator tit=m.begin()+i;
        #else
        for (Mesh::const_iterator tit=m.begin();tit<m.end();++tit) {
        #endif
            anaDPD.init(*tit, q, r0);
            Vect3 v = gauss->integrate(anaDPD, *tit);
            #pragma omp critical
            {
                rhs(tit->s1().index() ) += v(0) * coeff;
                rhs(tit->s2().index() ) += v(1) * coeff;
                rhs(tit->s3().index() ) += v(2) * coeff;
            }
        }
        delete gauss;
    }

    void operatorDipolePot(const Vect3& r0, const Vect3& q, const Mesh& m, Vector& rhs, const double& coeff, const unsigned gauss_order, const bool adapt_rhs) 
    {
        static analyticDipPot anaDP;

        anaDP.init(q, r0);
        Integrator<double, analyticDipPot> *gauss;
        if ( adapt_rhs ) {
            gauss = new AdaptiveIntegrator<double, analyticDipPot>(0.001);
        } else {
            gauss = new Integrator<double, analyticDipPot>;
        }

        gauss->setOrder(gauss_order);
        #pragma omp parallel for
        #ifndef OPENMP_3_0
        for (int i=0;i<m.size();++i) {
            const Mesh::const_iterator tit=m.begin()+i;
        #else
        for (Mesh::const_iterator tit=m.begin();tit<m.end();++tit) {
        #endif
            double d = gauss->integrate(anaDP, *tit);
            #pragma omp critical
            rhs(tit->index()) += d * coeff;
        }
        delete gauss;
    }

}