revision 943 by gross, Mon Jan 22 07:20:25 2007 UTC revision 944 by gross, Tue Jan 30 08:57:37 2007 UTC
2082          self.failUnless(p5 in cp, "inplace dilation must use p5")          self.failUnless(p5 in cp, "inplace dilation must use p5")
2083          self.failUnless(p6 in cp, "inplace dilation must use p6")          self.failUnless(p6 in cp, "inplace dilation must use p6")
2084
def test_PlaneSurface(self):
p0=Point(0,0,0,0.1)
p1=Point(10,0,0,0.2)
p2=Point(10,10,0,0.3)
p3=Point(0,10,3,0.4)
p4=Point(5,5,0,0.001)
p5=Point(7,5,0,0.001)
p6=Point(5,7,0,0.001)
p7=Point(8,8,0,0.001)
p8=Point(9,9,0,0.001)

l0=Line(p0,p1)
l1=Line(p1,p2)
l2=Line(p2,p3)
l3=Line(p3,p0)

l9=Line(p1,p8)
l10=Line(p8,p3)

l4=Line(p4,p5)
l5=Line(p5,p6)
l6=Line(p6,p4)
l7=Line(p6,p7)
l8=Line(p7,p4)

a1=Arc(p4,p3,p1)
a2=Arc(p7,p5,p6)

cl=CurveLoop(l0,l1,l2,l3)
h=CurveLoop(l4,l5,l6)
cl_s=CurveLoop(l0,l9,l10,l3)
h2=CurveLoop(l4,l5,l7,l8)
cl_a=CurveLoop(a1,l1,l2)
h_a=CurveLoop(a2,l6,l4)

self.failUnlessRaises(TypeError,PlaneSurface,l4)
self.failUnlessRaises(TypeError,PlaneSurface,cl_a,h)
self.failUnlessRaises(TypeError,PlaneSurface,cl,[h_a])

CC0=PlaneSurface(cl,holes=[h])
s=-CC0

cl2=s.getBoundaryLoop()
self.failUnless(cl == cl2, " wrong boundary loops")
self.failUnless(cl.hasSameOrientation(-cl2),"cl has incorrect orientation.")

hs=s.getHoles()
self.failUnless(len(hs) == 1, "one holes expected.")
self.failUnless(h==hs[0], "h is not defined as hole.")
self.failUnless(hs[0].hasSameOrientation(-h),"hs has incorrect orientation.")

self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself")
self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself")

crvs=s.getBoundary()
self.failUnless(len(crvs) == 7, "too many boundary corves.")
self.failUnless(l0 in crvs, "l0 is missing in boundary")
self.failUnless(crvs[crvs.index(l0)].hasSameOrientation(-l0),"l0 has incorrect orientation.")
self.failUnless(l1 in crvs, "l1 is missing in boundary")
self.failUnless(crvs[crvs.index(l1)].hasSameOrientation(-l1),"l1 has incorrect orientation.")
self.failUnless(l2 in crvs, "l2 is missing in boundary")
self.failUnless(crvs[crvs.index(l2)].hasSameOrientation(-l2),"l2 has incorrect orientation.")
self.failUnless(l3 in crvs, "l3 is missing in boundary")
self.failUnless(crvs[crvs.index(l3)].hasSameOrientation(-l3),"l3 has incorrect orientation.")
self.failUnless(l4 in crvs, "l4 is missing in boundary")
self.failUnless(crvs[crvs.index(l4)].hasSameOrientation(-l4),"l4 has incorrect orientation.")
self.failUnless(l5 in crvs, "l5 is missing in boundary")
self.failUnless(crvs[crvs.index(l5)].hasSameOrientation(-l5),"l5 has incorrect orientation.")
self.failUnless(l6 in crvs, "l6 is missing in boundary")
self.failUnless(crvs[crvs.index(l6)].hasSameOrientation(-l6),"l6 has incorrect orientation.")

code=s.getGmshCommand()
self.failUnless(code == "Plane Surface(29) = {23, 24};", "gmsh command wrong.")

self.failUnless(not s.isColocated(p4),"PlaneSurface is colocated with point.")
self.failUnless(s.isColocated(s),"PlaneSurface is not colocated with its self.")
self.failUnless(s.isColocated(PlaneSurface(cl,holes=[h])),"PlaneSurface is not colocated with its copy.")
self.failUnless(not s.isColocated(PlaneSurface(cl)),"PlaneSurface is colocated with PlaneSurface with same boundary but no hole")
self.failUnless(not s.isColocated(PlaneSurface(cl_s,holes=[h])),"PlaneSurface is colocated with PlaneSurface with deformed boundary")
self.failUnless(not s.isColocated(PlaneSurface(cl,holes=[h2])),"PlaneSurface is colocated with modified hole")

s.setLocalScale(3.)
self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
self.failUnless(p3.getLocalScale()==3., "p3 has wrong local scale.")
self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
self.failUnless(p5.getLocalScale()==3., "p5 has wrong local scale.")
self.failUnless(p6.getLocalScale()==3., "p6 has wrong local scale.")

p=s.getPrimitives()
self.failUnless(len(p) == 17, "too many primitives.")
self.failUnless(s in p, "cl is missing")
self.failUnless(cl in p, "cl is missing")
self.failUnless(h in p, "h is missing")
self.failUnless(l0 in p, "l0 is missing")
self.failUnless(l1 in p, "l1 is missing")
self.failUnless(l2 in p, "l2 is missing")
self.failUnless(l3 in p, "l3 is missing")
self.failUnless(l4 in p, "l4 is missing")
self.failUnless(l5 in p, "l5 is missing")
self.failUnless(l6 in p, "l6 is missing")
self.failUnless(p0 in p, "p0 is missing")
self.failUnless(p1 in p, "p1 is missing")
self.failUnless(p2 in p, "p2 is missing")
self.failUnless(p3 in p, "p3 is missing")
self.failUnless(p4 in p, "p4 is missing")
self.failUnless(p5 in p, "p5 is missing")
self.failUnless(p6 in p, "p6 is missing")

sp=s.copy()
self.failUnless(isinstance(sp,ReversePlaneSurface), "copy returns is not a PlaneSurface.")
self.failUnless(not sp == s, "copy equals source")
self.failUnless(sp.isColocated(s),"copy is not colocated with its source.")
cbl=sp.getBoundaryLoop()
self.failUnless(not cbl == cl,"copy uses cl1.")
hs=sp.getHoles()
self.failUnless(len(hs)==1,"copy is missing holes.")
self.failUnless(not hs[0]== h,"copy contains h as a hole.")
cp=sp.getPrimitives()
self.failUnless(len(cp) == 17, "copy as too many primitives.")
self.failUnless(not s in cp, "copy contains s")
self.failUnless(not cl in cp, "copy contains cl")
self.failUnless(not h in cp, "copy contains h")
self.failUnless(not l0 in cp, "copy contains l0")
self.failUnless(not l1 in cp, "copy contains l1")
self.failUnless(not l2 in cp, "copy contains l2")
self.failUnless(not l3 in cp, "copy contains l3")
self.failUnless(not l4 in cp, "copy contains l4")
self.failUnless(not l5 in cp, "copy contains l5")
self.failUnless(not l6 in cp, "copy contains l6")
self.failUnless(not p0 in cp, "copy contains p0")
self.failUnless(not p1 in cp, "copy contains p1")
self.failUnless(not p2 in cp, "copy contains p2")
self.failUnless(not p3 in cp, "copy contains p3")
self.failUnless(not p4 in cp, "copy contains p4")
self.failUnless(not p5 in cp, "copy contains p5")
self.failUnless(not p6 in cp, "copy contains p6")
del sp

p0_m=Point(0,0,0,0.1)
p1_m=Point(-10,0,0,0.2)
p2_m=Point(-10,-10,0,0.3)
p3_m=Point(0,-10,-3,0.4)
p4_m=Point(-5,-5,0,0.001)
p5_m=Point(-7,-5,0,0.001)
p6_m=Point(-5,-7,0,0.001)

l0_m=Line(p0_m,p1_m)
l1_m=Line(p1_m,p2_m)
l2_m=Line(p2_m,p3_m)
l3_m=Line(p3_m,p0_m)

l4_m=Line(p4_m,p5_m)
l5_m=Line(p5_m,p6_m)
l6_m=Line(p6_m,p4_m)

cl_m=CurveLoop(l0_m,l1_m,l2_m,l3_m)
h_m=CurveLoop(l4_m,l5_m,l6_m)

ds=s.apply(Dilation(-1.))
self.failUnless(ds.isColocated(PlaneSurface(cl_m,holes=[h_m])),"dilation is wrong.")
cbl=ds.getBoundaryLoop()
self.failUnless(not cbl == cl,"dilation uses cl1.")
hs=ds.getHoles()
self.failUnless(len(hs)==1,"dilation is missing holes.")
self.failUnless(not hs[0]== h,"dilation contains h as a hole.")
cp=ds.getPrimitives()
self.failUnless(len(cp) == 17, "dilation as too many primitives.")
self.failUnless(not s in cp, "dilation contains s")
self.failUnless(not cl in cp, "dilation contains cl")
self.failUnless(not h in cp, "dilation contains h")
self.failUnless(not l0 in cp, "dilation contains l0")
self.failUnless(not l1 in cp, "dilation contains l1")
self.failUnless(not l2 in cp, "dilation contains l2")
self.failUnless(not l3 in cp, "dilation contains l3")
self.failUnless(not l4 in cp, "dilation contains l4")
self.failUnless(not l5 in cp, "dilation contains l5")
self.failUnless(not l6 in cp, "dilation contains l6")
self.failUnless(not p0 in cp, "dilation contains p0")
self.failUnless(not p1 in cp, "dilation contains p1")
self.failUnless(not p2 in cp, "dilation contains p2")
self.failUnless(not p3 in cp, "dilation contains p3")
self.failUnless(not p4 in cp, "dilation contains p4")
self.failUnless(not p5 in cp, "dilation contains p5")
self.failUnless(not p6 in cp, "dilation contains p6")

s.modifyBy(Dilation(-1.))
self.failUnless(s.isColocated(PlaneSurface(cl_m,holes=[h_m])),"inplace dilation is wrong.")
cbl=s.getBoundaryLoop()
self.failUnless(cbl == cl,"inplace dilation does not use cl1.")
self.failUnless(cl.hasSameOrientation(-cbl),"cl has incorrect orientation.")
hs=s.getHoles()
self.failUnless(len(hs)==1,"inplace dilation is missing holes.")
self.failUnless(hs[0]== h,"inplace dilation must contain h as a hole.")
self.failUnless(hs[0].hasSameOrientation(-h),"hole in inplace dilation has incorrect orientation.")

cp=s.getPrimitives()
self.failUnless(len(cp) == 17, "inplace dilation as too many primitives.")
self.failUnless(s in cp, "inplace dilation must use s")
self.failUnless(cl in cp, "inplace dilation must use cl")
self.failUnless(h in cp, "inplace dilation must use h")
self.failUnless(l0 in cp, "inplace dilation must use l0")
self.failUnless(l1 in cp, "inplace dilation must use l1")
self.failUnless(l2 in cp, "inplace dilation must use l2")
self.failUnless(l3 in cp, "inplace dilation must use l3")
self.failUnless(l4 in cp, "inplace dilation must use l4")
self.failUnless(l5 in cp, "inplace dilation must use l5")
self.failUnless(l6 in cp, "inplace dilation must use l6")
self.failUnless(p0 in cp, "inplace dilation must use p0")
self.failUnless(p1 in cp, "inplace dilation must use p1")
self.failUnless(p2 in cp, "inplace dilation must use p2")
self.failUnless(p3 in cp, "inplace dilation must use p3")
self.failUnless(p4 in cp, "inplace dilation must use p4")
self.failUnless(p5 in cp, "inplace dilation must use p5")
self.failUnless(p6 in cp, "inplace dilation must use p6")

2085     def test_SurfaceLoop(self):     def test_SurfaceLoop(self):
2086          p0=Point( 0, 0, 0,0.1)          p0=Point( 0, 0, 0,0.1)
2087          p1=Point(10, 0, 0,0.1)          p1=Point(10, 0, 0,0.1)
3090          self.failUnless(cc[cc.index(s6_i)].hasSameOrientation(s6_i),"s6_i in modified object has wrong orientation.")          self.failUnless(cc[cc.index(s6_i)].hasSameOrientation(s6_i),"s6_i in modified object has wrong orientation.")
3091          self.failUnless(s6_i.isColocated(s6_i_m),"s6_i in dilated object as wrong location.")          self.failUnless(s6_i.isColocated(s6_i_m),"s6_i in dilated object as wrong location.")
3092
3093       def test_PropertySet0D(self):
3094           p0=Point(1.,2.,3.,local_scale=9.)
3095           p1=Point(0.,0.,0.,local_scale=9.)
3096           p3=Point(8.,6,6,local_scale=9.)
3097           p4=Point(8.,6,-6,local_scale=9.)
3098
3099           # create property set with dim:
3100           self.failUnlessRaises(ValueError,PropertySet,"test0")
3101           self.failUnlessRaises(TypeError,PropertySet,"test0",p0, Line(p0,p1))
3102
3103           ps=PropertySet("test0",p0, p1)
3104           self.failUnless(ps.getManifoldClass() == Point, "wrong manifold")
3105           self.failUnless(ps.getDim() == 0, "wrong dimension")
3106           self.failUnless(ps.getName() == "test0", "wrong name")
3107           ps.setName("test1")
3108           self.failUnless(ps.getName() == "test1", "wrong new name")
3109
3110           self.failUnless(ps.getTag() == 8, "wrong tag")
3111
3114           pp=ps.getItems()
3115           self.failUnless(len(pp) == 4, "wrong number of items")
3116           self.failUnless(p0 in pp, "p0 missing in items.")
3117           self.failUnless(p1 in pp, "p1 missing in items.")
3118           self.failUnless(p3 in pp, "p3 missing in items.")
3119           self.failUnless(p4 in pp, "p4 missing in items.")
3120
3121           code=ps.getGmshCommand()
3122           self.failUnless(code == "Physical Point(8) = {1, 2, 3, 4};","wrong gmsh code")
3123
3124           pp=ps.getPrimitives()
3125           self.failUnless(len(pp) == 5, "wrong number of items")
3126           self.failUnless(ps in pp, "ps missing in items.")
3127           self.failUnless(p0 in pp, "p0 missing in items.")
3128           self.failUnless(p1 in pp, "p1 missing in items.")
3129           self.failUnless(p3 in pp, "p3 missing in items.")
3130           self.failUnless(p4 in pp, "p4 missing in items.")
3131
3132           ps.clearItems()
3133           self.failUnless(len(ps.getItems()) == 0, "cleaning items failed.")
3134
3135
3136       def test_PropertySet1D(self):
3137           p0=Point(1.,2.,3.,local_scale=9.)
3138           p1=Point(0.,0.,0.,local_scale=9.)
3139           p3=Point(8.,6,6,local_scale=9.)
3140           p4=Point(8.,6,-6,local_scale=9.)
3141
3142           l0=Line(p0,p1)
3143           l1=Arc(p3,p1,p4)
3144           l2=Line(p4,p0)
3145           # create property set with dim:
3146           self.failUnlessRaises(ValueError,PropertySet,"test0")
3147           self.failUnlessRaises(TypeError,PropertySet,"test0",l0, p0)
3148
3149           ps=PropertySet("test0", l0, l1)
3150           self.failUnless(ps.getManifoldClass() == Manifold1D, "wrong manifold")
3151           self.failUnless(ps.getDim() == 1, "wrong dimension")
3152           self.failUnless(ps.getName() == "test0", "wrong name")
3153           ps.setName("test1")
3154           self.failUnless(ps.getName() == "test1", "wrong new name")
3155
3156           self.failUnless(ps.getTag() == 10, "wrong tag")
3157
3160           pp=ps.getItems()
3161           self.failUnless(len(pp) == 3, "wrong number of items")
3162           self.failUnless(l0 in pp, "l0 missing in items.")
3163           self.failUnless(l1 in pp, "l1 missing in items.")
3164           self.failUnless(l2 in pp, "l2 missing in items.")
3165
3166           code=ps.getGmshCommand()
3167           self.failUnless(code == "Physical Line(10) = {5, 6, 7};","wrong gmsh code")
3168
3169           pp=ps.getPrimitives()
3170           self.failUnless(len(pp) == 8, "wrong number of items")
3171           self.failUnless(ps in pp, "ps missing in items.")
3172           self.failUnless(l0 in pp, "l0 missing in items.")
3173           self.failUnless(l1 in pp, "l1 missing in items.")
3174           self.failUnless(l2 in pp, "l2 missing in items.")
3175           self.failUnless(p0 in pp, "p0 missing in items.")
3176           self.failUnless(p1 in pp, "p1 missing in items.")
3177           self.failUnless(p3 in pp, "p3 missing in items.")
3178           self.failUnless(p4 in pp, "p4 missing in items.")
3179
3180           ps.clearItems()
3181           self.failUnless(len(ps.getItems()) == 0, "cleaning items failed.")
3182
3183       def test_PropertySet2D(self):
3184           p0=Point(0,0,0,0.1)
3185           p1=Point(10,0,0,0.2)
3186           p2=Point(10,10,0,0.3)
3187           p3=Point(0,10,3,0.4)
3188           p4=Point(5,5,0,0.001)
3189           p5=Point(7,5,0,0.001)
3190           p6=Point(5,7,0,0.001)
3191
3192           l0=Line(p0,p1)
3193           l1=Line(p1,p2)
3194           l2=Line(p2,p3)
3195           l3=Line(p3,p0)
3196
3197           l4=Line(p4,p5)
3198           l5=Line(p5,p6)
3199           l6=Line(p6,p4)
3200
3201           cl=CurveLoop(l0,l1,l2,l3)
3202           h=CurveLoop(l4,l5,l6)
3203
3204           s=PlaneSurface(cl,holes=[h])
3205
3206           # create property set with dim:
3207           self.failUnlessRaises(ValueError,PropertySet,"test0")
3208           self.failUnlessRaises(TypeError,PropertySet,"test0",s, p0)
3209
3210           ps=PropertySet("test0", s)
3211           self.failUnless(ps.getManifoldClass() == Manifold2D, "wrong manifold")
3212           self.failUnless(ps.getDim() == 2, "wrong dimension")
3213           self.failUnless(ps.getName() == "test0", "wrong name")
3214           ps.setName("test1")
3215           self.failUnless(ps.getName() == "test1", "wrong new name")
3216
3217           self.failUnless(ps.getTag() == 20, "wrong tag")
3218
3219           code=ps.getGmshCommand()
3220           self.failUnless(code == "Physical Surface(20) = {17};","wrong gmsh code")
3221
3222           pp=ps.getPrimitives()
3223           self.failUnless(len(pp) == 18, "wrong number of items")
3224           self.failUnless(ps in pp, "ps missing in items.")
3225           self.failUnless(s in pp, "s missing in items.")
3226           self.failUnless(h in pp, "h missing in items.")
3227           self.failUnless(cl in pp, "cl missing in items.")
3228           self.failUnless(l0 in pp, "l0 missing in items.")
3229           self.failUnless(l1 in pp, "l1 missing in items.")
3230           self.failUnless(l2 in pp, "l2 missing in items.")
3231           self.failUnless(l3 in pp, "l3 missing in items.")
3232           self.failUnless(l4 in pp, "l4 missing in items.")
3233           self.failUnless(l5 in pp, "l5 missing in items.")
3234           self.failUnless(l6 in pp, "l6 missing in items.")
3235           self.failUnless(p0 in pp, "p0 missing in items.")
3236           self.failUnless(p1 in pp, "p1 missing in items.")
3237           self.failUnless(p3 in pp, "p3 missing in items.")
3238           self.failUnless(p4 in pp, "p4 missing in items.")
3239           self.failUnless(p5 in pp, "p5 missing in items.")
3240           self.failUnless(p6 in pp, "p6 missing in items.")
3241
3243           pp=ps.getItems()
3244           self.failUnless(len(pp) == 1, "wrong number of items")
3245           self.failUnless(s in pp, "s missing in items.")
3246
3247           ps.clearItems()
3248           self.failUnless(len(ps.getItems()) == 0, "cleaning items failed.")
3250           self.failUnless(len(ps.getItems()) == 1, "missing added item")
3251           self.failUnless(s in ps.getItems(), "missing added item")
3252
3253       def test_PropertySet3D(self):
3254           p0=Point(-2,-2,-2,0.1)
3255           p1=Point(2,-2,-2,0.1)
3256           p2=Point(-2,2,-2,0.1)
3257           p3=Point(2,2,-2,0.1)
3258           p4=Point(-2,-2,2,0.1)
3259           p5=Point(2,-2,2,0.1)
3260           p6=Point(-2,2,2,0.1)
3261           p7=Point(2,2,2,0.1)
3262           l01=Line(p0,p1)
3263           l15=Line(p1,p5)
3264           l54=Line(p5,p4)
3265           l40=Line(p4,p0)
3266           l23=Line(p2,p3)
3267           l37=Line(p3,p7)
3268           l76=Line(p7,p6)
3269           l62=Line(p6,p2)
3270           l13=Line(p1,p3)
3271           l57=Line(p5,p7)
3272           l02=Line(p0,p2)
3273           l46=Line(p4,p6)
3274           cl1=CurveLoop(l01,l15,l54,l40)
3275           s1=PlaneSurface(cl1)
3276           cl2=CurveLoop(l23,l37,l76,l62)
3277           s2=PlaneSurface(-cl2)
3278           cl3=CurveLoop(l13,l37,-l57,-l15)
3279           s3=PlaneSurface(cl3)
3280           cl4=CurveLoop(l46,l62,-l02,-l40)
3281           s4=PlaneSurface(-cl4)
3282           cl5=CurveLoop(-l01,l02,l23,-l13)
3283           s5=PlaneSurface(-cl5)
3284           cl6=CurveLoop(-l54,l57,l76,-l46)
3285           s6=PlaneSurface(-cl6)
3286           s_out=SurfaceLoop(s1,s2,s3,s4,s5,s6)
3287
3288           p0_i=Point(-1,-1,-1,0.1)
3289           p1_i=Point(1,-1,-1,0.1)
3290           p2_i=Point(-1,1,-1,0.1)
3291           p3_i=Point(1,1,-1,0.1)
3292           p4_i=Point(-1,-1,1,0.1)
3293           p5_i=Point(1,-1,1,0.1)
3294           p6_i=Point(-1,1,1,0.1)
3295           p7_i=Point(1,1,1,0.1)
3296           l01_i=Line(p0_i,p1_i)
3297           l15_i=Line(p1_i,p5_i)
3298           l54_i=Line(p5_i,p4_i)
3299           l40_i=Line(p4_i,p0_i)
3300           l23_i=Line(p2_i,p3_i)
3301           l37_i=Line(p3_i,p7_i)
3302           l76_i=Line(p7_i,p6_i)
3303           l62_i=Line(p6_i,p2_i)
3304           l13_i=Line(p1_i,p3_i)
3305           l57_i=Line(p5_i,p7_i)
3306           l02_i=Line(p0_i,p2_i)
3307           l46_i=Line(p4_i,p6_i)
3308           cl1_i=CurveLoop(l01_i,l15_i,l54_i,l40_i)
3309           s1_i=PlaneSurface(cl1_i)
3310           cl2_i=CurveLoop(l23_i,l37_i,l76_i,l62_i)
3311           s2_i=PlaneSurface(-cl2_i)
3312           cl3_i=CurveLoop(l13_i,l37_i,-l57_i,-l15_i)
3313           s3_i=PlaneSurface(cl3_i)
3314           cl4_i=CurveLoop(l46_i,l62_i,-l02_i,-l40_i)
3315           s4_i=PlaneSurface(-cl4_i)
3316           cl5_i=CurveLoop(-l01_i,l02_i,l23_i,-l13_i)
3317           s5_i=PlaneSurface(-cl5_i)
3318           cl6_i=CurveLoop(-l54_i,l57_i,l76_i,-l46_i)
3319           s6_i=PlaneSurface(-cl6_i)
3320           s_inner=SurfaceLoop(s1_i,s2_i,s3_i,s4_i,s5_i,s6_i)
3321
3322           v=Volume(s_out,holes=[s_inner])
3323
3324           # create property set with dim:
3325           self.failUnlessRaises(ValueError,PropertySet,"test0")
3326           self.failUnlessRaises(TypeError,PropertySet,"test0",v, p0)
3327
3328           ps=PropertySet("test0", v)
3329           self.failUnless(ps.getManifoldClass() == Manifold3D, "wrong manifold")
3330           self.failUnless(ps.getDim() == 3, "wrong dimension")
3331           self.failUnless(ps.getName() == "test0", "wrong name")
3332           ps.setName("test1")
3333           self.failUnless(ps.getName() == "test1", "wrong new name")
3334
3335           self.failUnless(ps.getTag() == 70, "wrong tag")
3336
3337           code=ps.getGmshCommand()
3338           self.failUnless(code == "Physical Volume(70) = {67};","wrong gmsh code")
3339
3340           pp=ps.getPrimitives()
3341           self.failUnless(len(pp) == 68, "too many primitives.")
3342           self.failUnless(ps in pp, "ps is missing")
3343           self.failUnless(v in pp, "v is missing")
3344           self.failUnless(p0 in pp, "p0 is missing")
3345           self.failUnless(p1 in pp, "p1 is missing")
3346           self.failUnless(p2 in pp, "p2 is missing")
3347           self.failUnless(p3 in pp, "p3 is missing")
3348           self.failUnless(p4 in pp, "p4 is missing")
3349           self.failUnless(p5 in pp, "p5 is missing")
3350           self.failUnless(p6 in pp, "p6 is missing")
3351           self.failUnless(p7 in pp, "p7 is missing")
3352           self.failUnless(l01 in pp, "l01 is missing")
3353           self.failUnless(l15 in pp, "l15 is missing")
3354           self.failUnless(l54 in pp, "l54 is missing")
3355           self.failUnless(l40 in pp, "l40 is missing")
3356           self.failUnless(l23 in pp, "l23 is missing")
3357           self.failUnless(l37 in pp, "l37 is missing")
3358           self.failUnless(l76 in pp, "l76 is missing")
3359           self.failUnless(l62 in pp, "l62 is missing")
3360           self.failUnless(l13 in pp, "l13 is missing")
3361           self.failUnless(l57 in pp, "l57 is missing")
3362           self.failUnless(l02 in pp, "l02 is missing")
3363           self.failUnless(l46 in pp, "l46 is missing")
3364           self.failUnless(cl1 in pp, "cl1 is missing")
3365           self.failUnless(s1 in pp, "s1 is missing")
3366           self.failUnless(cl2 in pp, "cl2 is missing")
3367           self.failUnless(s2 in pp, "s2 is missing")
3368           self.failUnless(cl3 in pp, "cl3  is missing")
3369           self.failUnless(s3 in pp, "s3  is missing")
3370           self.failUnless(cl4 in pp, "cl4  is missing")
3371           self.failUnless(s4 in pp, "s4  is missing")
3372           self.failUnless(cl5 in pp, "cl5  is missing")
3373           self.failUnless(s5 in pp, "s5  is missing")
3374           self.failUnless(cl6 in pp, "cl6  is missing")
3375           self.failUnless(s6 in pp, "s6  is missing")
3376           self.failUnless(s_out in pp, "s_out is missing")
3377           self.failUnless(p0_i in pp, "p0_i is missing")
3378           self.failUnless(p1_i in pp, "p1_i is missing")
3379           self.failUnless(p2_i in pp, "p2_i is missing")
3380           self.failUnless(p3_i in pp, "p3_i is missing")
3381           self.failUnless(p4_i in pp, "p4_i is missing")
3382           self.failUnless(p5_i in pp, "p5_i is missing")
3383           self.failUnless(p6_i in pp, "p6_i is missing")
3384           self.failUnless(p7_i in pp, "p7_i is missing")
3385           self.failUnless(l01_i in pp, "l01_i is missing")
3386           self.failUnless(l15_i in pp, "l15_i is missing")
3387           self.failUnless(l54_i in pp, "l54_i is missing")
3388           self.failUnless(l40_i in pp, "l40_i is missing")
3389           self.failUnless(l23_i in pp, "l23_i is missing")
3390           self.failUnless(l37_i in pp, "l37_i is missing")
3391           self.failUnless(l76_i in pp, "l76_i is missing")
3392           self.failUnless(l62_i in pp, "l62_i is missing")
3393           self.failUnless(l13_i in pp, "l13_i is missing")
3394           self.failUnless(l57_i in pp, "l57_i is missing")
3395           self.failUnless(l02_i in pp, "l02_i is missing")
3396           self.failUnless(l46_i in pp, "l46_i is missing")
3397           self.failUnless(cl1_i in pp, "cl1_i is missing")
3398           self.failUnless(s1_i in pp, "s1_i is missing")
3399           self.failUnless(cl2_i in pp, "cl2_i is missing")
3400           self.failUnless(s2_i in pp, "s2_i is missing")
3401           self.failUnless(cl3_i in pp, "cl3_i  is missing")
3402           self.failUnless(s3_i in pp, "s3_i  is missing")
3403           self.failUnless(cl4_i in pp, "cl4_i  is missing")
3404           self.failUnless(s4_i in pp, "s4_i  is missing")
3405           self.failUnless(cl5_i in pp, "cl5_i  is missing")
3406           self.failUnless(s5_i in pp, "s5_i  is missing")
3407           self.failUnless(cl6_i in pp, "cl6_i  is missing")
3408           self.failUnless(s6_i in pp, "s6_i  is missing")
3409           self.failUnless(s_inner in pp, "s_inner  is missing")
3410
3412           pp=ps.getItems()
3413           self.failUnless(len(pp) == 1, "wrong number of items")
3414           self.failUnless(v in pp, "s missing in items.")
3415
3416           ps.clearItems()
3417           self.failUnless(len(ps.getItems()) == 0, "cleaning items failed.")
3419           self.failUnless(len(ps.getItems()) == 1, "missing added item")
3420           self.failUnless(v in ps.getItems(), "missing added item")
3421
3423     def setUp(self):     def setUp(self):
3424           resetGlobalPrimitiveIdCounter()           resetGlobalPrimitiveIdCounter()
3425
3426       def test_tagMap(self):
3427           self.failUnlessRaises(TypeError,TagMap, { "x" : 5 } )
3428           self.failUnlessRaises(TypeError,TagMap, { 5 : 10 } )
3429
3430           m=TagMap({ 5 : "x" })
3431
3432           m.setMap(x=4,a=6)
3433           m.setMap(b=6,c=1)
3434
3435           t=m.getTags()
3436           self.failUnless(len(t) == 4)
3437           self.failUnless(1 in t)
3438           self.failUnless(6 in t)
3439           self.failUnless(5 in t)
3440           self.failUnless(4 in t)
3441           self.failUnless(m.getTags("c") == [1])
3442           self.failUnless(m.getTags("x") == [4, 5])
3443           self.failUnless(m.getTags("b") == [6])
3444
3445           self.failUnless(m.getName(1) == "c")
3446           self.failUnless(m.getName(4) == "x")
3447           self.failUnless(m.getName(5) == "x")
3448           self.failUnless(m.getName(6) == "b")
3449
3450           t=m.getMapping()
3451           self.failUnless(len(t)==4)
3452           self.failUnless(t.has_key(1))
3453           self.failUnless(t.has_key(4))
3454           self.failUnless(t.has_key(5))
3455           self.failUnless(t.has_key(6))
3456           self.failUnless(t[1] == "c")
3457           self.failUnless(t[4] == "x")
3458           self.failUnless(t[5] == "x")
3459           self.failUnless(t[6] == "b")
3460
3461           d=m.map(c=10, x = -10, b =60, default =1)
3462           self.failUnless(d[1] == 10)
3463           self.failUnless(d[4] == -10)
3464           self.failUnless(d[5] == -10)
3465           self.failUnless(d[6] == 60)
3466
3467
3468           d=m.map(c=10, x = -10, default =60)
3469           self.failUnless(d[1] == 10)
3470           self.failUnless(d[4] == -10)
3471           self.failUnless(d[5] == -10)
3472           self.failUnless(d[6] == 60)
3473
3474           mxml=m.writeXML()
3475           m2=TagMap()
3476           m2.fillFromXML(mxml)
3477           t=m2.getMapping()
3478           self.failUnless(len(t)==4)
3479           self.failUnless(t.has_key(1))
3480           self.failUnless(t.has_key(4))
3481           self.failUnless(t.has_key(5))
3482           self.failUnless(t.has_key(6))
3483           self.failUnless(t[1] == "c")
3484           self.failUnless(t[4] == "x")
3485           self.failUnless(t[5] == "x")
3486           self.failUnless(t[6] == "b")
3487
3488     def test_Design(self):     def test_Design(self):
3489
3490         d=Design0(dim=2, element_size=0.01, order=1, keep_files=False)         d=Design0(dim=2, element_size=0.01, order=1, keep_files=False)
3519         c=CurveLoop(l01,l12,l23,l30)         c=CurveLoop(l01,l12,l23,l30)
3520         s=PlaneSurface(c)         s=PlaneSurface(c)
3521
3522           ps=PropertySet("XXXX",s)
3523           pl1=PropertySet("A",l01,l30)
3524           pl2=PropertySet("B",l12,l23)
3527         i=d.getItems()         i=d.getItems()
3528         self.failUnless(isinstance(i,list))         self.failUnless(isinstance(i,list))
3529         self.failUnless(len(i)==1)         self.failUnless(len(i)==3)
3530         self.failUnless(s in i)         self.failUnless(ps in i)
3531           self.failUnless(pl1 in i)
3532           self.failUnless(pl2 in i)
3533
3534         p=d.getAllPrimitives()         p=d.getAllPrimitives()
3535         self.failUnless(isinstance(p,list))         self.failUnless(isinstance(p,list))
3536         self.failUnless(len(p)==10)         self.failUnless(len(p)==13)
3537         self.failUnless(p0 in p)         self.failUnless(p0 in p)
3538         self.failUnless(p1 in p)         self.failUnless(p1 in p)
3539         self.failUnless(p2 in p)         self.failUnless(p2 in p)
3544         self.failUnless(l30 in p)         self.failUnless(l30 in p)
3545         self.failUnless(c in p)         self.failUnless(c in p)
3546         self.failUnless(s in p)         self.failUnless(s in p)
3547           self.failUnless(ps in p)
3548           self.failUnless(pl1 in p)
3549           self.failUnless(pl2 in p)
3550           # get tag maps:
3551           m1=d.getCurveTagMap()
3552           mm1=m1.getMapping()
3553           self.failUnless(len(mm1)==2)
3554           self.failUnless(mm1[12]=="A")
3555           self.failUnless(mm1[13]=="B")
3556
3557           m2=d.getSurfaceTagMap()
3558           mm2=m2.getMapping()
3559           self.failUnless(len(mm2)==1)
3560           self.failUnless(mm2[11]=="XXXX")
3561         # clear things:         # clear things:
3562         d.clearItems()         d.clearItems()
3563         i=d.getItems()         i=d.getItems()
3564         self.failUnless(isinstance(i,list))         self.failUnless(isinstance(i,list))
3565         self.failUnless(len(i)==0)         self.failUnless(len(i)==0)
3566
3567
3568
3569     def test_GMSH(self):     def test_GMSH(self):
3570
3571         d=GMSHDesign(dim=2, element_size=0.01, order=1, keep_files=False)         d=GMSHDesign(dim=2, element_size=0.01, order=1, keep_files=False)
3590
3591         d.setOptions(optimize_quality=True)         d.setOptions(optimize_quality=True)
3592         cmd=d.getCommandString()         cmd=d.getCommandString()
print cmd
3593         self.failUnless("gmsh -2 -algo iso -smooth 3 -optimize  -v 0 -order 1 -o .%smesh.msh .%sscript.geo"%(os.sep,os.sep) == cmd)         self.failUnless("gmsh -2 -algo iso -smooth 3 -optimize  -v 0 -order 1 -o .%smesh.msh .%sscript.geo"%(os.sep,os.sep) == cmd)
3594
3595         p0=Point(0.,0.,0.)         p0=Point(0.,0.,0.)
3602         l30=Line(p3,p0)         l30=Line(p3,p0)
3603         c=CurveLoop(l01,l12,l23,l30)         c=CurveLoop(l01,l12,l23,l30)
3604         s=PlaneSurface(c)         s=PlaneSurface(c)
3606           pl1=PropertySet("A",l01,l30)
3607           pl2=PropertySet("B",l12,l23)
3610         srpt=d.getScriptString()         srpt=d.getScriptString()
3611         ref = \         ref = \
# Line 3422  Line(7) = {3, 4}; Line 3620  Line(7) = {3, 4};
3620  Line(8) = {4, 1};  Line(8) = {4, 1};
3621  Line Loop(9) = {5, 6, 7, 8};  Line Loop(9) = {5, 6, 7, 8};
3622  Plane Surface(10) = {9};  Plane Surface(10) = {9};
3623    Physical Surface(11) = {10};
3624    Physical Line(12) = {5, 8};
3625    Physical Line(13) = {6, 7};
3626  """  """
3627         self.failUnless(srpt == ref )         self.failUnless(srpt == ref )
3628

Legend:
 Removed from v.943 changed lines Added in v.944