⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 norm.py

📁 利用C
💻 PY
字号:
"""This module provides a simple way to compute various norms ofFunctions, including the standard L2 norm and other norms"""__author__ = "Anders Logg (logg@simula.no)"__date__ = "2008-03-19 -- 2008-03-19"__copyright__ = "Copyright (C) 2008 Anders Logg"__license__  = "GNU LGPL Version 2.1"__all__ = ['norm']from assemble import assemblefrom ffc import dot, grad, div, curl, dxfrom math import sqrtfrom constants import DOLFIN_EPS def norm(v, mesh, type="l2"):    """Return norm of given function. Example usage includes:        norm(v, mesh)        norm(u0 - u1, mesh)        norm(v, mesh, 'Hdiv')            If the type is not specified, the standard L_2 norm is    computed. Possible norm types include:      L_2:     norm(v, mesh, 'L2')      H^1:     norm(v, mesh, 'H1')      H^1_0:   norm(v, mesh, 'H10')      H(div):  norm(v, mesh, 'Hdiv')      H(curl): norm(v, mesh, 'Hcurl')    """    if type.lower() == "l2":        M = dot(v, v)*dx    elif type.lower() == "h1":        M = dot(v, v)*dx + dot(grad(v), grad(v))*dx    elif type.lower() == "h10":        M = dot(grad(v), grad(v))*dx    elif type.lower() == "hdiv":        M = div(v)*div(v)*dx    elif type.lower() == "hcurl":        M = dot(curl(v), curl(v))*dx    r = assemble(M, mesh)     if r < DOLFIN_EPS: return 0.0     else: return sqrt(r)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -