예제 #1
0
    void Physics::initialise(double& t, const mesh::Mesh& m,
                             iterator u, iterator udash, iterator temp,
                             Callback compute_residual)
    {
        // allocate storage
        initialise_vectors( m );

        // Set initial values
        set_initial_conditions(t, m);
        for( int i=0; i<m.local_nodes(); i++ ){
            u[i].h = h_vec[i];
            udash[i].M = 0;
        }

        // set M and C according to pressure and concentration 
        process_volumes_psk( m ); // find theta for each volume
        for( int i=0; i<m.local_nodes(); i++ ){
            u[i].M = rho_vec[i]*theta_vec[i];
            //std::cout << u[i].M << " " << rho_vec[i] << " " << theta_vec[i] << std::endl;
        }

        // Compute residual
        compute_residual(temp, true);

        // determine the derivative coefficients
        process_derivative_coefficients( m );

        // Set initial derivatives
        for( int f=0; f<m.interior_cvfaces(); f++ ){
            int front_id = m.cvface(f).front().id();
            double vol = m.volume(front_id).vol();
            if (front_id < m.local_nodes()){
                udash[front_id].M += M_flux_faces[f]/vol;
            }
            int back_id = m.cvface(f).back().id();
            vol = m.volume(back_id).vol();
            if (back_id < m.local_nodes()){
                udash[back_id].M -= M_flux_faces[f]/vol;
            }
        }
        for( int f=m.interior_cvfaces(); f<m.cvfaces(); f++){
            int back_id = m.cvface(f).back().id();
            double vol = m.volume(back_id).vol();
            if (back_id < m.local_nodes()){
                udash[back_id].M -= M_flux_faces[f]/vol;
            }
        }
        /*
        for(int i=0; i<m.local_nodes(); i++){
            if(fabs(udash[i].M)>1e-10)
                //std::cout << i << " " << u[i].h << " " << u[i].M << " " << udash[i].h  << " " << udash[i].M << std::endl;  
        }
        */
    }
예제 #2
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;
 }