• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python mesh.mesh函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pySDC.datatype_classes.mesh.mesh函数的典型用法代码示例。如果您正苦于以下问题:Python mesh函数的具体用法?Python mesh怎么用?Python mesh使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了mesh函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __eval_fexpl

    def __eval_fexpl(self, u, t):
        """
        Helper routine to evaluate the explicit part of the RHS

        Args:
            u: current values (not used here)
            t: current time

        Returns:
            explicit part of RHS
        """

        fexpl = mesh(self.nvars)

        # Copy values of u into pyClaw state object
        self.state.q[0, :] = u.values[0, :]

        # Evaluate right hand side
        tmp = self.solver.dqdt(self.state)
        fexpl.values[0, :] = tmp.reshape(self.nvars[1:])

        # Copy values of u into pyClaw state object
        self.state.q[0, :] = u.values[1, :]

        # Evaluate right hand side
        tmp = self.solver.dqdt(self.state)
        fexpl.values[1, :] = tmp.reshape(self.nvars[1:])

        # DEBUGGING
        # fexpl.values[0,:] = 0.0*self.mesh
        # fexpl.values[1,:] = 0.0*self.mesh
        return fexpl
开发者ID:kidaa,项目名称:pySDC,代码行数:32,代码来源:ProblemClass.py


示例2: solve_system

    def solve_system(self,rhs,factor,u0,t):
        """
        Simple linear solver for (I-dtA)u = rhs

        Args:
            rhs: right-hand side for the nonlinear system
            factor: abbrev. for the node-to-node stepsize (or any other factor required)
            u0: initial guess for the iterative solver (not used here so far)
            t: current time (e.g. for time-dependent BCs)

        Returns:
            solution as mesh
        """

        b         = rhs.values.flatten()
        cb        = Callback()

        sol, info = LA.gmres( self.Id - factor*self.M, b, x0=u0.values.flatten(), tol=self.gmres_tol, restart=self.gmres_restart, maxiter=self.gmres_maxiter, callback=cb)
        # If this is a dummy call with factor==0.0, do not log because it should not be counted as a solver call
        if factor!=0.0:
          #print "SDC: Number of GMRES iterations: %3i --- Final residual: %6.3e" % ( cb.getcounter(), cb.getresidual() )
          self.logger.add(cb.getcounter())
        me        = mesh(self.nvars)
        me.values = unflatten(sol, 4, self.N[0], self.N[1])

        return me
开发者ID:lelou6666,项目名称:pySDC,代码行数:26,代码来源:ProblemClass.py


示例3: solve_system

    def solve_system(self, rhs, factor, u0, t):
        """
        Simple linear solver for (I-dtA)u = rhs

        Args:
            rhs: right-hand side for the nonlinear system
            factor: abbrev. for the node-to-node stepsize (or any other factor required)
            u0: initial guess for the iterative solver (not used here so far)
            t: current time (e.g. for time-dependent BCs)

        Returns:
            solution as mesh
        """

        M1 = sp.hstack((sp.eye(self.nvars[1]), -factor * self.A))
        M2 = sp.hstack((-factor * self.A, sp.eye(self.nvars[1])))
        M = sp.vstack((M1, M2))

        b = np.concatenate((rhs.values[0, :], rhs.values[1, :]))

        sol = LA.spsolve(M, b)

        me = mesh(self.nvars)
        me.values[0, :], me.values[1, :] = np.split(sol, 2)

        return me
开发者ID:kidaa,项目名称:pySDC,代码行数:26,代码来源:ProblemClass.py


示例4: __eval_fexpl

    def __eval_fexpl(self,u,t):
        """
        Helper routine to evaluate the explicit part of the RHS

        Args:
            u: current values (not used here)
            t: current time

        Returns:
            explicit part of RHS
        """


        fexpl        = mesh(self.nvars)

        # Copy values of u into pyClaw state object
        self.state.q[0,:,:] = u.values[0,:,:]

        # Evaluate right hand side
        self.solver.before_step(self.solver, self.state)
        tmp = self.solver.dqdt(self.state)
        
        fexpl.values[0,:,:] = unflatten(tmp, 1, self.nvars[1], self.nvars[2])


        # Copy values of u into pyClaw state object
        #self.state.q[0,:,:] = u.values[1,:,:]

        # Evaluate right hand side
        #tmp = self.solver.dqdt(self.state)
        #fexpl.values[1,:,:] = tmp.reshape(self.nvars[1:])

        return fexpl
开发者ID:kidaa,项目名称:pySDC,代码行数:33,代码来源:ProblemClass.py


示例5: u_exact

    def u_exact(self,t):
        """
        Routine to compute the exact solution at time t

        Args:
            t: current time

        Returns:
            exact solution
        """
        
        dtheta = 0.01
        H      = 10.0
        a      = 5.0
        x_c    = -50.0
        
        me        = mesh(self.nvars)
        me.values[0,:,:] = 0.0*self.xx
        me.values[1,:,:] = 0.0*self.xx
        #me.values[2,:,:] = 0.0*self.xx
        #me.values[3,:,:] = np.exp(-0.5*(self.xx-0.0)**2.0/0.15**2.0)*np.exp(-0.5*(self.zz-0.5)**2/0.15**2)
        #me.values[2,:,:] = np.exp(-0.5*(self.xx-0.0)**2.0/0.05**2.0)*np.exp(-0.5*(self.zz-0.5)**2/0.2**2)
        me.values[2,:,:] = dtheta*np.sin( np.pi*self.zz/H )/( 1.0 + np.square(self.xx - x_c)/(a*a))
        me.values[3,:,:] = 0.0*self.xx
        return me
开发者ID:lelou6666,项目名称:pySDC,代码行数:25,代码来源:ProblemClass.py


示例6: check_datatypes_mesh

def check_datatypes_mesh(init):
    import pySDC.datatype_classes.mesh as m


    m1 = m.mesh(init)
    m2 = m.mesh(m1)


    m1.values[:] = 1.0
    m2.values[:] = 2.0

    m3 = m1 + m2
    m4 = m1 - m2
    m5 = 0.1*m1
    m6 = m1

    m7 = abs(m1)

    m8 = m.mesh(m1)

    assert isinstance(m3,type(m1))
    assert isinstance(m4,type(m1))
    assert isinstance(m5,type(m1))
    assert isinstance(m6,type(m1))
    assert isinstance(m7,float)

    assert m2 is not m1
    assert m3 is not m1
    assert m4 is not m1
    assert m5 is not m1
    assert m6 is m1

    assert np.shape(m3.values) == np.shape(m1.values)
    assert np.shape(m4.values) == np.shape(m1.values)
    assert np.shape(m5.values) == np.shape(m1.values)

    assert np.all(m1.values==1.0)
    assert np.all(m2.values==2.0)
    assert np.all(m3.values==3.0)
    assert np.all(m4.values==-1.0)
    assert np.all(m5.values==0.1)
    assert np.all(m8.values==1.0)
    assert m7 >= 0
开发者ID:kidaa,项目名称:pySDC,代码行数:43,代码来源:tests_core.py


示例7: u_exact

    def u_exact(self,t):
        """
        Routine to compute the exact solution at time t

        Args:
            t: current time

        Returns:
            exact solution
        """

        me = mesh(self.nvars)
        me.values = np.cos(2.0*np.pi*(self.mesh-self.c*t))
        return me
开发者ID:kidaa,项目名称:pySDC,代码行数:14,代码来源:ProblemClass.py


示例8: u_exact

    def u_exact(self,t):
        """
        Routine to compute the exact solution at time t

        Args:
            t: current time

        Returns:
            exact solution
        """
        
        me             = mesh(self.nvars)
        me.values[0,:] = 0.5*u_initial( self.mesh - (self.cadv + self.cs)*t , self.waveno) - 0.5*u_initial( self.mesh - (self.cadv - self.cs)*t , self.waveno)
        me.values[1,:] = 0.5*u_initial( self.mesh - (self.cadv + self.cs)*t , self.waveno) + 0.5*u_initial( self.mesh - (self.cadv - self.cs)*t , self.waveno)
        return me
开发者ID:lelou6666,项目名称:pySDC,代码行数:15,代码来源:ProblemClass_conv.py


示例9: __eval_fimpl

    def __eval_fimpl(self,u,t):
        """
        Helper routine to evaluate the implicit part of the RHS

        Args:
            u: current values
            t: current time (not used here)

        Returns:
            implicit part of RHS
        """

        fimpl = mesh(self.nvars)
        fimpl.values = self.A.dot(u.values)
        return fimpl
开发者ID:kidaa,项目名称:pySDC,代码行数:15,代码来源:ProblemClass.py


示例10: u_exact

    def u_exact(self, t):
        """
        Dummy routine for the exact solution, currently only passes the initial values

        Args:
            t: current time
        Returns:
            mesh type containing the initial values
        """

        # thou shall not call this at time > 0
        assert t is 0
        me = mesh(2)
        me.values = self.u0
        return me
开发者ID:kidaa,项目名称:pySDC,代码行数:15,代码来源:ProblemClass.py


示例11: prolong_space

    def prolong_space(self, G):
        """
        Dummy prolongation routine

        Args:
            G: the coarse level data (easier to access than via the coarse attribute)
        """

        if isinstance(G, mesh):
            F = mesh(G)
        elif isinstance(G, rhs_imex_mesh):
            F = rhs_imex_mesh(G)
        else:
            print("Transfer error")
            exit()
        return F
开发者ID:kidaa,项目名称:pySDC,代码行数:16,代码来源:TransferClass.py


示例12: solve_system

    def solve_system(self,rhs,factor,u0,t):
        """
        Simple linear solver for (I-dtA)u = rhs

        Args:
            rhs: right-hand side for the nonlinear system
            factor: abbrev. for the node-to-node stepsize (or any other factor required)
            u0: initial guess for the iterative solver (not used here so far)
            t: current time (e.g. for time-dependent BCs)

        Returns:
            solution as mesh
        """

        me = mesh(self.nvars)
        me.values = LA.spsolve(sp.eye(self.nvars)-factor*self.A,rhs.values)
        return me
开发者ID:kidaa,项目名称:pySDC,代码行数:17,代码来源:ProblemClass.py


示例13: u_exact

    def u_exact(self,t):
        """
        Routine to compute the exact solution at time t

        Args:
            t: current time

        Returns:
            exact solution
        """
        
        xc,yc = self.state.grid.p_centers
        me        = mesh(self.nvars)
        me.values[0,:,:] = np.sin(2*np.pi*xc)*np.sin(2*np.pi*yc)
        me.values[1,:,:] = np.sin(2*np.pi*xc)*np.sin(2*np.pi*yc)

        return me
开发者ID:torbjoernk,项目名称:pySDC,代码行数:17,代码来源:ProblemClass.py


示例14: eval_f

    def eval_f(self,u,t):
        """
        Routine to compute the RHS for both components simultaneously

        Args:
            t: current time (not used here)
            u: the current values
        Returns:
            RHS, 2 components
        """

        x1 = u.values[0]
        x2 = u.values[1]
        f = mesh(2)
        f.values[0] = -x2 + x1*(1 - x1**2 - x2**2)
        f.values[1] = x1 + 3*x2*(1 - x1**2 - x2**2)
        return f
开发者ID:kidaa,项目名称:pySDC,代码行数:17,代码来源:ProblemClass.py


示例15: prolong_space

    def prolong_space(self,G):
        """
        Prolongation implementation

        Args:
            G: the coarse level data (easier to access than via the coarse attribute)
        """

        if isinstance(G,mesh):
            u_fine = mesh(self.init_c,val=0)
            u_fine.values = self.Pspace.dot(G.values)
        elif isinstance(G,rhs_imex_mesh):
            u_fine = rhs_imex_mesh(self.init_c)
            u_fine.impl.values = self.Pspace.dot(G.impl.values)
            u_fine.expl.values = self.Pspace.dot(G.expl.values)

        return u_fine
开发者ID:lelou6666,项目名称:pySDC,代码行数:17,代码来源:TransferClass.py


示例16: restrict_space

    def restrict_space(self,F):
        """
        Restriction implementation

        Args:
            F: the fine level data (easier to access than via the fine attribute)
        """

        if isinstance(F,mesh):
            u_coarse = mesh(self.init_c,val=0)
            u_coarse.values = self.Rspace.dot(F.values)
        elif isinstance(F,rhs_imex_mesh):
            u_coarse = rhs_imex_mesh(self.init_c)
            u_coarse.impl.values = self.Rspace.dot(F.impl.values)
            u_coarse.expl.values = self.Rspace.dot(F.expl.values)

        return u_coarse
开发者ID:lelou6666,项目名称:pySDC,代码行数:17,代码来源:TransferClass.py


示例17: restrict_space

    def restrict_space(self, F):
        """
        Dummy restriction routine

        Args:
            F: the fine level data (easier to access than via the fine attribute)

        """

        if isinstance(F, mesh):
            G = mesh(F)
        elif isinstance(F, rhs_imex_mesh):
            G = rhs_imex_mesh(F)
        else:
            print("Transfer error")
            exit()
        return G
开发者ID:kidaa,项目名称:pySDC,代码行数:17,代码来源:TransferClass.py


示例18: __eval_fimpl

    def __eval_fimpl(self,u,t):
        """
        Helper routine to evaluate the implicit part of the RHS

        Args:
            u: current values
            t: current time (not used here)

        Returns:
            implicit part of RHS
        """

        temp         = u.values.flatten()
        temp         = self.M.dot(temp)
        fimpl        = mesh(self.nvars,val=0.0)
        fimpl.values = unflatten(temp, 4, self.N[0], self.N[1])
        
        return fimpl
开发者ID:lelou6666,项目名称:pySDC,代码行数:18,代码来源:ProblemClass.py


示例19: __eval_fexpl

    def __eval_fexpl(self,u,t):
        """
        Helper routine to evaluate the explicit part of the RHS

        Args:
            u: current values (not used here)
            t: current time

        Returns:
            explicit part of RHS
        """
        
        # Evaluate right hand side
        fexpl        = mesh(self.nvars,val=0.0)
        temp         = u.values.flatten()
        temp         = self.D_upwind.dot(temp)
        fexpl.values = unflatten( temp, 4, self.N[0], self.N[1])
              
        return fexpl
开发者ID:lelou6666,项目名称:pySDC,代码行数:19,代码来源:ProblemClass.py



注:本文中的pySDC.datatype_classes.mesh.mesh函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python time_series.TimeSeries类代码示例发布时间:2022-05-25
下一篇:
Python pyPgSQL.PgSQL类代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap