level.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Fluid2d 作者: pvthinker 项目源码 文件源码
def set_msk_laplacian(self,prevlev=0,mskf=0):
        """ set the good mask and the laplacian using previous level """
        if prevlev==0:
            self.msk=mskf
            self.compute_A_atfinest()
        else:
            mskf=prevlev.msk*1.0
            coef=ones((self.mv,self.nv))
            finetocoarse(prevlev,self,mskf,coef)
            self.msk[coef<=0.5]=0
            np=self.np
            mp=self.mp
            myrank=self.myrank
            iloc=myrank%np
            jloc=(myrank//np)%mp
            nh=self.nh
            self.compute_A_atcoarser(prevlev,self.msk)

        # # coefficient for the Jacobi iteration, A[:,:,4] is the main diagonal
        # val=abs(self.A[:,:,4]).max()        
        # self.coef = MPI.COMM_WORLD.allreduce(val, op=MPI.MAX)
        # if self.coef!=0.:
        #     self.coef=1./self.coef
        # else:
        #     if self.myrank==0:
        #         print('matrix diagonal is zero')
        #         print('fix something!')
        #     exit()


        # buffer for 'smoothertwice' the Fortran subroutine
        self.yo=zeros((3,self.nv))

#----------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号