Exemplo n.º 1
0
 double Physics::compute_mass(const mesh::Mesh& m, const_iterator u) {
     double total_mass = 0.;
     const double* source = reinterpret_cast<const double*>(&u[0]);
     vdPackI(m.nodes(), &source[0], 2, &h_vec[0]);
     process_volumes_psk( m );
     for(int i=0; i<m.local_nodes(); i++)
         //total_mass += m.volume(i).vol()*u[i].M;
         total_mass += m.volume(i).vol()*theta_vec[i]*rho_vec[i];
     return total_mass;
 }
Exemplo n.º 2
0
    void Physics::preprocess_evaluation(double t, const mesh::Mesh& m,
                                        const_iterator u, const_iterator udash)
    {
        ++num_calls;

        for (int i = 0; i < m.nodes(); ++i) {
            assert(u[i].h == u[i].h &&
                   u[i].h !=  std::numeric_limits<double>::infinity() &&
                   u[i].h != -std::numeric_limits<double>::infinity()
            );
            assert(u[i].M == u[i].M &&
                   u[i].M !=  std::numeric_limits<double>::infinity() &&
                   u[i].M != -std::numeric_limits<double>::infinity()
            );
        }

        // Copy h from solution vector to h_vec and c_vec
        const double* source = reinterpret_cast<const double*>(&u[0]);
        vdPackI(m.nodes(), &source[0], 2, &h_vec[0]);

        // h and gradient at CV faces
        shape_matrix.matvec( h_vec, h_faces );
        shape_gradient_matrixX.matvec( h_vec, grad_h_faces_.x() );
        shape_gradient_matrixY.matvec( h_vec, grad_h_faces_.y() );
        if (dimension == 3)
            shape_gradient_matrixZ.matvec( h_vec, grad_h_faces_.z() );

        // determine the p-s-k values
        process_volumes_psk( m );
        // density at faces using shape functions
        process_faces_shape( m );
        // Compute psk values at faces using upwinding/limiting
        process_faces_lim( m );
        // compute fluxes
        process_fluxes( t, m );
    }