[G+smo] gsDofMapper 的使用

gsAssemblerBase 类中定义:    std::vector<gsDofMapper>  m_dofMappers;

这个类用来处理dirichlet边界条件,并管理多个patch内部单元的单元拓扑对应关系。

gsDofMapper的初始化:通过gsMultiBasis, gsBasis和gsBoundaryConditions进行初始化。

最常用的初始化方式是:

template<class T>
    gsDofMapper(
        const gsMultiBasis<T>         &bases
        ) : m_shift(0), m_bshift(0)
    {
        init(bases);
    }


template<class T>
void gsMultiBasis<T>::getMapper(bool conforming, 
                                gsDofMapper & mapper, 
                                bool finalize) const
{
    mapper = gsDofMapper(*this);//.init(*this);
    
    if ( conforming )  // Conforming boundaries ?
    {
        for ( gsBoxTopology::const_iiterator it = m_topology.iBegin();
              it != m_topology.iEnd(); ++it )
        {
            matchInterface(*it,mapper);
        }
    }
    
    if (finalize)
        mapper.finalize();
}


template<class T>
void gsMultiBasis<T>::getMapper(bool conforming, 
                                const gsBoundaryConditions<T> & bc, 
                                int unk,
                                gsDofMapper & mapper, 
                                bool finalize) const
{
    mapper = gsDofMapper(*this, bc, unk); //.init(*this, bc, unk);
    
    if ( conforming ) // Conforming boundaries ?
    {
        for ( gsBoxTopology::const_iiterator it = m_topology.iBegin();
              it != m_topology.iEnd(); ++it )
        {
            matchInterface(*it,mapper);
        }
    }


    if (finalize)
        mapper.finalize();
}


template <typename T>
gsDofMapper* makeVectorValuedDofMapper(std::vector<const gsMultiBasis<T> *> const & bases,
                                       gsBoundaryConditions<real_t> const & bc,
                                       dirichlet::strategy dirStrategy)
{
    //Assumes comforming patches
    //GISMO_ASSERT(m_patches.nPatches() == 1,"Only implemented for single Patch");


    // init dof mapper based on size of the patch spaces
    index_t TarDim = bases.size();


    gsDofMapper * result = new gsDofMapper(bases);


    //Active_shift is a memebr of gsGenericBasisEvaluator however I do not have access to it
    std::vector<unsigned> active_shift(TarDim);
    active_shift[0] = 0;
    for (int i = 1; i < TarDim; ++i)
        active_shift[i]=active_shift[i-1]+bases[i-1]->totalSize();


    //topology()
    for (index_t comp = 0; comp < TarDim; ++comp)
    {
        for ( gsBoxTopology::const_iiterator it = bases[comp]->topology().iBegin();
              it != bases[comp]->topology().iEnd(); ++it )
        {
            gsMatrix<unsigned> b1 = safe(bases[comp]->basis(it->first().patch).boundary( it->first().side() ))->array() + active_shift[comp];
            gsMatrix<unsigned> b2 = safe(bases[comp]->basis(it->second().patch).boundary( it->second().side() ))->array() + active_shift[comp];
            //result->matchInterface( it->first().patch, it->second().patch, b1, b2, it->orient());
            // Note: assuming matching interfaces without transform
            result->matchDofs(it->first().patch, b1, it->second().patch, b2);
        }
    }


    // mark Dirichlet Boundaries
    if(dirStrategy == dirichlet::elimination)
    {
        for (typename gsBoundaryConditions<T>::const_iterator it=bc.dirichletBegin();
                it!=bc.dirichletEnd(); ++it)
        {
            for (index_t k = 0; k < TarDim; ++k)
            {
                gsMatrix<unsigned> dof;
                gsMatrix<unsigned> *help = bases[k]->basis(it->patch()).boundary(it->ps.side());
                dof = help->array() + active_shift[k];
                //std::cout<< "Inside dofmapper creator number of dofs are " << dof.rows() << std::endl;
                result->markBoundary(it->patch(),dof);
                delete (help);
            }
        }
    }


    result->finalize();
    return result;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值