예제 #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::mass_flux_per_time(const mesh::Mesh& m){
        double flux_per_time = 0.;
        for( int i=m.interior_cvfaces(); i<m.cvfaces(); i++ )
        {
            const mesh::CVFace& cvf = m.cvface(i);
            int boundary_tag = cvf.boundary();
            const BoundaryCondition& BC = boundary_condition_h( boundary_tag );
            double t=0.;
            if( BC.type()==3 )
                flux_per_time -= BC.value(t) * m.cvface(i).area();
        }

        return flux_per_time*constants().rho_0();
    }