Beispiel #1
0
        element_type exact_project(const space_ptrtype & Xh, const double & val)
        {
            ex solution = getSolution(val);

            auto mesh = Xh->mesh();
            auto gproj = vf::project( _space=Xh, _range=elements( mesh ), _expr=expr(solution,vars) );
            return gproj;
        }
Beispiel #2
0
        element_type rhs_project(const space_ptrtype & Xh)
        {
            ex solution = getRhs();

            auto mesh = Xh->mesh();
            auto gproj = vf::project( _space=Xh, _range=elements( mesh ), _expr=expr(solution,vars) );
            return gproj;
        }
Beispiel #3
0
        double L2_error(const space_ptrtype & Xh, const element_type & T, const double & values) const
        {
            // replace params by specified values
            ex solution = getSolution(values);

            auto g = expr(solution,vars);
            auto mesh = Xh->mesh();
            return  math::sqrt( integrate( elements(mesh), Px()*(idv(T) - g)*(idv(T) - g) ).evaluate()(0,0) );
        }
Beispiel #4
0
        element_type grad_exact_project(const space_ptrtype & Xh)
        {
            ex solution = getSolution();
            auto gradg = expr<1,Dim,2>(grad(solution,vars), vars );

            auto mesh = Xh->mesh();
            auto gproj = vf::project( _space=Xh, _range=elements( mesh ), _expr=expr(gradg,vars) );
            return gproj;
        }
Beispiel #5
0
        double H1_error(const space_ptrtype & Xh, const element_type & T, const double & values) const
        {
            // replace params by specified values
            ex solution = getSolution(values);

            auto gradg = expr<1,Dim,2>(grad(solution,vars), vars );
            auto mesh = Xh->mesh();

            double L2error = L2_error(Xh, T, values);
            double H1seminorm = math::sqrt( integrate( elements(mesh), Px()*(gradv(T) - gradg)*trans(gradv(T) - gradg) ).evaluate()(0,0) );
            return math::sqrt( L2error*L2error + H1seminorm*H1seminorm);
        }
Beispiel #6
0
PreconditionerAS<space_type,coef_space_type>::PreconditionerAS( std::string t,
                                                                space_ptrtype Xh,
                                                                coef_space_ptrtype Mh,
                                                                BoundaryConditions bcFlags,
                                                                std::string const& p,
                                                                sparse_matrix_ptrtype Pm,
                                                                double k )
    :
        M_type( AS ),
        M_Xh( Xh ),
        M_Vh(Xh->template functionSpace<0>() ),
        M_Qh(Xh->template functionSpace<1>() ),
        M_Mh( Mh ),
        M_Vh_indices( M_Vh->nLocalDofWithGhost() ),
        M_Qh_indices( M_Qh->nLocalDofWithGhost() ),
        M_Qh3_indices( Dim ),
        A(backend()->newVector(M_Vh)),
        B(backend()->newVector(M_Vh)),
        C(backend()->newVector(M_Vh)),
        M_r(backend()->newVector(M_Vh)),
        M_r_t(backend()->newVector(M_Vh)),
        M_uout(backend()->newVector(M_Vh)),
        M_diagPm(backend()->newVector(M_Vh)),
        //M_t(backend()->newVector(M_Vh)),
        U( M_Vh, "U" ),
        M_mu(M_Mh, "mu"),
        M_er(M_Mh, "er"),
        M_bcFlags( bcFlags ),
        M_prefix( p ),
        M_k(k),
        M_g(1.-k*k)
{
    tic();
    LOG(INFO) << "[PreconditionerAS] setup starts";
    this->setMatrix( Pm ); // Needed only if worldComm > 1

    // QH3 : Lagrange vectorial space type
    M_Qh3 = lag_v_space_type::New(Xh->mesh());

    M_qh3_elt = M_Qh3->element();
    M_qh_elt = M_Qh->element();
    M_vh_elt = M_Vh->element();

    // Block 11.1
    M_s = backend()->newVector(M_Qh3);
    M_y = backend()->newVector(M_Qh3);

    // Block 11.2
    M_z = backend()->newVector(M_Qh);
    M_t = backend()->newVector(M_Qh);

    // Create the interpolation and keep only the matrix
    auto pi_curl = I(_domainSpace=M_Qh3, _imageSpace=M_Vh);
    auto Igrad   = Grad( _domainSpace=M_Qh, _imageSpace=M_Vh);

    M_P = pi_curl.matPtr();
    M_C = Igrad.matPtr();

    M_Pt = backend()->newMatrix(M_Qh3,M_Vh);
    M_Ct = backend()->newMatrix(M_Qh3,M_Vh);

    M_P->transpose(M_Pt,MATRIX_TRANSPOSE_UNASSEMBLED);
    M_C->transpose(M_Ct,MATRIX_TRANSPOSE_UNASSEMBLED);

    LOG(INFO) << "size of M_C = " << M_C->size1() << ", " << M_C->size2() << std::endl;
    LOG(INFO) << "size of M_P = " << M_P->size1() << ", " << M_P->size2() << std::endl;

    // Create vector of indices to create subvectors/matrices
    std::iota( M_Vh_indices.begin(), M_Vh_indices.end(), 0 ); // Vh indices in Xh
    std::iota( M_Qh_indices.begin(), M_Qh_indices.end(), M_Vh->nLocalDofWithGhost() ); // Qh indices in Xh

    // "Components" of Qh3
    auto Qh3_dof_begin = M_Qh3->dof()->dofPointBegin();
    auto Qh3_dof_end = M_Qh3->dof()->dofPointEnd();

    int dof_comp, dof_idx;
    for( auto it = Qh3_dof_begin; it!= Qh3_dof_end; it++ )
    {
        dof_comp = it->template get<2>(); //Component
        dof_idx = it->template get<1>(); //Global index
        M_Qh3_indices[dof_comp].push_back( dof_idx );
    }

    // Subvectors for M_y (per component)
    M_y1 = M_y->createSubVector(M_Qh3_indices[0], true);
    M_y2 = M_y->createSubVector(M_Qh3_indices[1], true);
#if FEELPP_DIM == 3
    M_y3 = M_y->createSubVector(M_Qh3_indices[2], true);
#endif
    
    // Subvectors for M_s (per component)
    M_s1 = M_y->createSubVector(M_Qh3_indices[0], true);
    M_s2 = M_y->createSubVector(M_Qh3_indices[1], true);
#if FEELPP_DIM == 3
    M_s3 = M_y->createSubVector(M_Qh3_indices[2], true);
#endif

    this->setType ( t );
    toc( "[PreconditionerAS] setup done ", FLAGS_v > 0 );
}