1
########################################################
3
# Copyright (c) 2003-2010 by University of Queensland
4
# Earth Systems Science Computational Center (ESSCC)
5
# http://www.uq.edu.au/esscc
7
# Primary Business: Queensland, Australia
8
# Licensed under the Open Software License version 3.0
9
# http://www.opensource.org/licenses/osl-3.0.php
11
########################################################
13
__copyright__="""Copyright (c) 2003-2010 by University of Queensland
14
Earth Systems Science Computational Center (ESSCC)
15
http://www.uq.edu.au/esscc
16
Primary Business: Queensland, Australia"""
17
__license__="""Licensed under the Open Software License version 3.0
18
http://www.opensource.org/licenses/osl-3.0.php"""
19
__url__="https://launchpad.net/escript-finley"
21
this script generates a variety of meshes in the fly format on a unit square with a
22
fixed number of elements NE (approximatively).
24
This script will not run under MPI.
26
generated file names are:
28
mesh_D<d>_o<O>_T<t>_Contacts<c>_Rich<r>.fly
30
wehere <d>= spatial dimension 2,3
32
<t>= element type = hex, tet
33
<c>= Yes if contact elements are present, No otherwise.
34
<r>= YEs is rich surface elements are used, No otherwise
36
any item with x[d]<CUT will be tagged with 1 the rest will be marked 100.
39
MESH_DIRECTORY="./tmp_meshes"
43
from esys.escript import *
44
from esys.dudley import Rectangle, Brick, Merge, JoinFaces
45
from esys.pycad import Point, Line,PlaneSurface, CurveLoop, Volume,SurfaceLoop
46
from esys.pycad.gmsh import Design
47
from esys.dudley import MakeDomain
50
def getMesh(NE_X, NE_Y, t,d,o,fullOrder,r,l_X):
53
dom=Rectangle(n0=NE_X, n1=NE_Y, l0=l_X,order=o, useFullElementOrder=fullOrder,useElementsOnFace=r,optimize=True)
56
dom=Brick(n0=NE_X, n1=NE_Y, n2=NE_Y,l0=l_X,order=o, useFullElementOrder=fullOrder,useElementsOnFace=r,optimize=True)
58
des=Design(dim=d, order=o, element_size =min(l_X/max(3,NE_X),1./max(3,NE_Y)), keep_files=True)
59
des.setScriptFileName("tester.geo")
69
s=PlaneSurface(CurveLoop(l01,l12,l23,l30))
70
des.addItems(s,l01,l12,l23,l30)
96
bottom=PlaneSurface(-CurveLoop(l10,l20,l30,l40))
97
top=PlaneSurface(CurveLoop(l12,l22,l32,l42))
99
front=PlaneSurface(CurveLoop(l10,l21,-l12,-l11))
100
back=PlaneSurface(CurveLoop(l30,l41,-l32,-l31))
102
left=PlaneSurface(CurveLoop(l11,-l42,-l41,l40))
103
right=PlaneSurface(CurveLoop(-l21,l20,l31,-l22))
105
vol=Volume(SurfaceLoop(bottom,top,front,back,left,right))
111
# test if out put dir exists:
112
if not os.path.isdir(MESH_DIRECTORY): os.mkdir(MESH_DIRECTORY)
115
for o in ["1", "2", "2F"]:
116
for t in [ "Hex", "Tet" ]:
117
for c in ["Yes", "No"]:
118
for r in ["Yes", "No"]:
119
filename="mesh_D%s_o%s_T%s_Contacts%s_Rich%s.fly"%(d,o,t,c,r)
120
# certain cases are excluded:
121
if ( o == "2F" and t == "Tet" ) or \
122
( t == "Tet" and r == "Yes" ) or \
123
( o == "2F" and r == "Yes" ) :
126
print "generate file ",filename
128
NE_X=int(NE**(1./d)/2+0.5)
129
NE_Y=int(NE**(1./d)+0.5)
131
NE_X=int(NE**(1./d)+0.5)
134
print "generating ",NE_X, NE_Y
145
dom1=getMesh(NE_X, NE_Y,t,d,o2,full,r=="Yes",0.5)
146
dom2=getMesh(NE_X, NE_Y,t,d,o2,full,r=="Yes",0.5)
150
dom=JoinFaces([dom1,dom2])
152
dom=getMesh(NE_X, NE_Y,t,d,o2,full,r=="Yes",1.)
154
for fs in [ContinuousFunction(dom), Function(dom), FunctionOnBoundary(dom), FunctionOnContactOne(dom)]:
155
m=whereNegative(fs.getX()[d-1]-CUT)
156
fs.getDomain().setTagMap('tag1',1)
159
dom.write(os.path.join(MESH_DIRECTORY,filename))
160
# saveVTK(os.path.join(MESH_DIRECTORY,filename+".vtu"),dom)