PartitionGBR.py 1.81 KB
Newer Older
bseny's avatar
bseny committed
1
2
3
4
5
from dgpy import *
from InputGBR import *
from termcolor import colored
import time, math, os, sys

6
7
8
9
10
11
print ''
print(colored('********** Partition mesh with algorithm %d **********', "red")%(algo))
print ''
m2 = GModel()
m2.load(filename+'_tan' + '.msh')
pOpt = meshPartitionOptions()
bseny's avatar
update    
bseny committed
12
pOpt.setNumOfPartitions(int(sys.argv[2]))
13
14
15
16
17
18
19
20
21

groups = dgGroupCollection(m2, dimension, order, True)
xyz = groups.getFunctionCoordinates();
lonLatDegrees = functionC(glib,"lonLatDegrees",3,[xyz])
lonLat = functionC(glib,"lonLat",3,[xyz])
bath = dgDofContainer(groups, 1);
if(not os.path.exists(bathname)):
  Msg.Fatal('No valid bathymetry file :' + bathname + ' found,  please launch "rundgpy DiffuseBathymetryTsunami.py"')

22
bath.importIdx(bathname)
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Define Conservation Law
claw = dgConservationLawShallowWater2d()
solution = dgDofContainer(groups, claw.getNbFields())

ld = functionConstant(0)
Cd = functionC(glib, "bottomDrag", 1, [solution.getFunction(), bath.getFunction()])
Di = functionConstant(diff)
Coriolis = functionC(glib, "coriolis", 1, [xyz])

claw.setCoriolisFactor(Coriolis)
claw.setQuadraticDissipation(Cd)
claw.setLinearDissipation(ld)
claw.setDiffusivity(Di)
claw.setBathymetry(bath.getFunction())
claw.setBathymetryGradient(bath.getFunctionGradient())


rk = dgMultirateERK(groups, claw, RK_TYPE)
dt = rk.splitGroupsForMultirate(mL, solution, [solution, bath])
rk.printMultirateInfo()

44
rk.computeMultiConstrainedPartition(pOpt, algo)
45
PartitionMesh(m2, pOpt)
bseny's avatar
update    
bseny committed
46
47
rk.updatePartitionInfo(int(sys.argv[2]))
rk.printPartitionInfo()
48

bseny's avatar
update    
bseny committed
49
m2.save(filename + '_partitioned%d_tan%d.msh'%(int(sys.argv[2]),mL))
50
51
print ''
print(colored('**********       Partition Done            **********', "red"))
bseny's avatar
update    
bseny committed
52
print("%d %f %f %f %f %f"%(int(sys.argv[2]),rk.bestImbalance(),rk.globalImbalance(),rk.speedUp(),rk.speedUp()/rk.bestImbalance(),rk.speedUp()/rk.globalImbalance()))
53
print ''