PRAgMaTIc
master
|
Functions | |
def | ellipse_convergence |
def | boundary |
Variables | |
tuple | ddtestsol = ddtestsol.replace('a**2','(a*a)') |
testsol = '(0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + stepfunc + ')) : (0.25<sqrt(x[0]*x[0]+x[1]*x[1]) ? 1 : 0)' ddtestsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + ddstepfunc + ') : 0' else: # problem == 0: rrpy = pysqrt(sx*sx+sy*sy) #'if(t<2*WeMax,0,if(t<4*WeMax,0.5+3/2/(2*WeMax)*(t-3*WeMax)-2/(2*WeMax)^3*(t-3*WeMax)^3,1))'; %0.5+3/2/dx*(x-xc)-2/dx^3*(x-xc)^3 ddstepfunc = str(diff(stepfunc,sx,sx)+diff(stepfunc,sy,sy)).replace('sx','x[0]').replace('sy','x[1]').replace('x[0]**2','(x[0]*x[0])').replace('x[1]**2','(x[1]*x[1])') stepfunc = str(stepfunc).replace('sx','x[0]').replace('sy','x[1]').replace('x[0]**2','(x[0]*x[0])').replace('x[1]**2','(x[1]*x[1])') #REPLACE ** with pow ddstepfunc = ddstepfunc.replace('(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25)**2','pow(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25,2.)') ddstepfunc = ddstepfunc.replace('(a*(x[1]*x[1]) + (x[0]*x[0])/a)**(3/2)','pow(a*(x[1]*x[1]) + (x[0]*x[0])/a,1.5)') stepfunc = stepfunc.replace('(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25)**3','pow(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25,3.)') testsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + stepfunc + ') : (0.25<sqrt(x[0]*x[0]+x[1]*x[1]) ? 1 : 0)' ddtestsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + ddstepfunc + ') : 0' More... | |
tuple | testsol = testsol.replace('ww**2','(ww*ww)') |
list | dofs = [] |
list | L2errors = [] |
tuple | meshsz = int(round(80*0.005/(eta*(bool(use_adapt)==False)+0.05*(bool(use_adapt)==True)))) |
SETUP MESH. More... | |
tuple | mesh = RectangleMesh(-0.0,-0.0,0.5*sqrt(asp),0.5/sqrt(asp),meshsz,meshsz,"left/right") |
tuple | V = FunctionSpace(mesh, "CG", CGorder) |
tuple | R = Expression(ddtestsol) |
tuple | a = inner(grad(dis), grad(dus)) |
L = R*dus*dx | |
tuple | bc = DirichletBC(V, Expression(testsol), boundary) |
tuple | H = metric_pnorm(u, eta, max_edge_ratio=1+49*(use_adapt!=2), p=2) |
tuple | L2error = errornorm(Expression(testsol), u, degree_rise=CGorder+2, norm_type='L2') |
tuple | testf = interpolate(u ,FunctionSpace(mesh,'CG',1)) |
tuple | testfe = interpolate(Expression(testsol),FunctionSpace(mesh,'CG',1)) |
tuple | vtx2dof = vertex_to_dof_map(FunctionSpace(mesh, "CG" ,1)) |
tuple | zz = testf.vector() |
tuple | hh = tricontourf(mesh.coordinates()[:,0],mesh.coordinates()[:,1],mesh.cells(),zz,100,cmap=get_cmap('binary')) |
tuple | fid = open("DOFS_L2errors_CG"+str(CGorder)+outname+".mpy",'w') |
int | NfitP = 9 |
tuple | I = array(range(len(dofs)-NfitP,len(dofs))) |
def ellipse_convergence.boundary | ( | x | ) |
Definition at line 95 of file ellipse_convergence.py.
def ellipse_convergence.ellipse_convergence | ( | asp = 2 , |
|
width = 1e-2 , |
|||
Nadapt = 10 , |
|||
eta_list = 0.04*pyexp2(-array(range(15))*pylog(2)/2) , |
|||
use_adapt = True , |
|||
problem = 2 , |
|||
outname = '' , |
|||
CGorderL = [2 , |
|||
noplot = False , |
|||
octaveimpl = False |
|||
) |
Definition at line 30 of file ellipse_convergence.py.
tuple ellipse_convergence.a = inner(grad(dis), grad(dus)) |
Definition at line 114 of file ellipse_convergence.py.
Definition at line 116 of file ellipse_convergence.py.
testsol = '(0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + stepfunc + ')) : (0.25<sqrt(x[0]*x[0]+x[1]*x[1]) ? 1 : 0)' ddtestsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + ddstepfunc + ') : 0' else: # problem == 0: rrpy = pysqrt(sx*sx+sy*sy) #'if(t<2*WeMax,0,if(t<4*WeMax,0.5+3/2/(2*WeMax)*(t-3*WeMax)-2/(2*WeMax)^3*(t-3*WeMax)^3,1))'; %0.5+3/2/dx*(x-xc)-2/dx^3*(x-xc)^3 ddstepfunc = str(diff(stepfunc,sx,sx)+diff(stepfunc,sy,sy)).replace('sx','x[0]').replace('sy','x[1]').replace('x[0]**2','(x[0]*x[0])').replace('x[1]**2','(x[1]*x[1])') stepfunc = str(stepfunc).replace('sx','x[0]').replace('sy','x[1]').replace('x[0]**2','(x[0]*x[0])').replace('x[1]**2','(x[1]*x[1])') #REPLACE ** with pow ddstepfunc = ddstepfunc.replace('(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25)**2','pow(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25,2.)') ddstepfunc = ddstepfunc.replace('(a*(x[1]*x[1]) + (x[0]*x[0])/a)**(3/2)','pow(a*(x[1]*x[1]) + (x[0]*x[0])/a,1.5)') stepfunc = stepfunc.replace('(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25)**3','pow(sqrt(a*(x[1]*x[1]) + (x[0]*x[0])/a) - 0.25,3.)') testsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + stepfunc + ') : (0.25<sqrt(x[0]*x[0]+x[1]*x[1]) ? 1 : 0)' ddtestsol = '0.25-ww/2<sqrt(x[0]*x[0]+x[1]*x[1]) && sqrt(x[0]*x[0]+x[1]*x[1]) < 0.25+ww/2 ? (' + ddstepfunc + ') : 0'
Definition at line 89 of file ellipse_convergence.py.
tuple ellipse_convergence.dofs = [] |
Definition at line 99 of file ellipse_convergence.py.
tuple ellipse_convergence.fid = open("DOFS_L2errors_CG"+str(CGorder)+outname+".mpy",'w') |
Definition at line 154 of file ellipse_convergence.py.
tuple ellipse_convergence.H = metric_pnorm(u, eta, max_edge_ratio=1+49*(use_adapt!=2), p=2) |
Definition at line 120 of file ellipse_convergence.py.
tuple ellipse_convergence.hh = tricontourf(mesh.coordinates()[:,0],mesh.coordinates()[:,1],mesh.cells(),zz,100,cmap=get_cmap('binary')) |
Definition at line 136 of file ellipse_convergence.py.
Definition at line 165 of file ellipse_convergence.py.
ellipse_convergence.L = R*dus*dx |
Definition at line 115 of file ellipse_convergence.py.
tuple ellipse_convergence.L2error = errornorm(Expression(testsol), u, degree_rise=CGorder+2, norm_type='L2') |
Definition at line 125 of file ellipse_convergence.py.
list ellipse_convergence.L2errors = [] |
Definition at line 100 of file ellipse_convergence.py.
tuple ellipse_convergence.mesh = RectangleMesh(-0.0,-0.0,0.5*sqrt(asp),0.5/sqrt(asp),meshsz,meshsz,"left/right") |
Definition at line 108 of file ellipse_convergence.py.
tuple ellipse_convergence.meshsz = int(round(80*0.005/(eta*(bool(use_adapt)==False)+0.05*(bool(use_adapt)==True)))) |
SETUP MESH.
Definition at line 104 of file ellipse_convergence.py.
int ellipse_convergence.NfitP = 9 |
Definition at line 164 of file ellipse_convergence.py.
tuple ellipse_convergence.R = Expression(ddtestsol) |
Definition at line 113 of file ellipse_convergence.py.
tuple ellipse_convergence.testf = interpolate(u ,FunctionSpace(mesh,'CG',1)) |
Definition at line 132 of file ellipse_convergence.py.
Definition at line 133 of file ellipse_convergence.py.
tuple ellipse_convergence.testsol = testsol.replace('ww**2','(ww*ww)') |
Definition at line 90 of file ellipse_convergence.py.
tuple ellipse_convergence.V = FunctionSpace(mesh, "CG", CGorder) |
Definition at line 111 of file ellipse_convergence.py.
tuple ellipse_convergence.vtx2dof = vertex_to_dof_map(FunctionSpace(mesh, "CG" ,1)) |
Definition at line 134 of file ellipse_convergence.py.
tuple ellipse_convergence.zz = testf.vector() |
Definition at line 135 of file ellipse_convergence.py.