44Module containing BoxClaw geometry.
55"""
66
7+ import fboxlib
8+ import math
9+
710from clawpack import pyclaw
811from clawpack .pyclaw import geometry as pyclaw_geometry
912
@@ -16,43 +19,25 @@ class Patch(pyclaw_geometry.Patch):
1619 __doc__ += pyclaw .util .add_parent_doc (pyclaw_geometry .Patch )
1720
1821 def __deepcopy__ (self ,memo ):
19- # don't recreate boxarrays
2022 return self
2123
2224 def __init__ (self ,dimensions ):
2325
24- import boxlib
25- import numpy as np
26-
2726 super (Patch ,self ).__init__ (dimensions )
2827
29- self ._ba , self ._gbox = self ._create_boxarray ()
30-
31- is_per = np .asarray (self .num_dim * [ 1 ], np .int32 )
32- rb = boxlib .RealBox (boxlib .lo (self ._gbox ), boxlib .hi (self ._gbox ))
33- self ._geom = boxlib .bl [self .num_dim ].Geometry (self ._gbox , rb , 0 , is_per )
28+ self ._la = self ._create_layout ()
3429
35- # XXX: create a multifab from the boxarray to get geometry information
36- tmp = boxlib . MultiFab ( self ._ba )
30+ bxs = self . _la . local_boxes
31+ lo , hi = self ._la . get_box ( bxs [ 0 ] )
3732
38- fab = None
39- for i in range (tmp .size ()):
40- fab = tmp [i ]
41- if fab is not None :
42- break
43-
44- assert (fab is not None )
45-
46- lo = boxlib .lo (fab .box ())
47- hi = boxlib .hi (fab .box ())
4833 grid_dimensions = []
4934 for i in range (self .num_dim ):
5035 lower = (lo [i ]+ 0 ) * self .delta [i ]
5136 upper = (hi [i ]+ 1 ) * self .delta [i ]
5237 num_cells = hi [i ]- lo [i ]+ 1
5338
5439 grid_dimensions .append (pyclaw_geometry .Dimension (lower ,upper ,
55- num_cells ,name = dimensions [i ].name ))
40+ num_cells ,name = dimensions [i ].name ))
5641
5742 if lower == self .lower_global [i ]:
5843 grid_dimensions [- 1 ].on_lower_boundary = True
@@ -66,17 +51,9 @@ def __init__(self,dimensions):
6651
6752 self .grid = pyclaw_geometry .Grid (grid_dimensions )
6853
69- del tmp
70-
7154
72- def _create_boxarray (self ):
73- """Returns a BoxLib BoxArray."""
74-
75- # note that boxlib supports more than one box per processor
76-
77- import boxlib
78- import math
79- import numpy as np
55+ def _create_layout (self ):
56+ """Returns a FBoxLib layout."""
8057
8158 dx = self .delta
8259 lg = self .lower_global
@@ -85,12 +62,8 @@ def _create_boxarray(self):
8562 lo = [ int (lg [d ]/ dx [d ]) for d in range (self .num_dim ) ]
8663 hi = [ lo [d ]+ nc [d ]- 1 for d in range (self .num_dim ) ]
8764
88- box = boxlib .Box (lo , hi )
89- ba = boxlib .BoxArray ([box ])
90-
9165 max_sizes = self .num_dim * [ 1 ]
92-
93- nprocs = boxlib .size ()
66+ nprocs = fboxlib .mpi_size ()
9467 if (self .num_dim > 1 ) and (nprocs % 2 ** self .num_dim == 0 ):
9568 # divide domain into cubes
9669 nproc_per_dim = nprocs / 2 ** self .num_dim + 1
@@ -102,14 +75,10 @@ def _create_boxarray(self):
10275 for d in range (1 , self .num_dim ):
10376 max_sizes [d ] = hi [d ] - lo [d ] + 1
10477
105- max_sizes = boxlib .bl [self .num_dim ].IntVect (* max_sizes )
106- ba .maxSize (max_sizes )
107-
108- if boxlib .rank () == 0 :
109- logger .info ("max_sizes: " + str (max_sizes ))
110- logger .info ("boxarray: " + str (ba ))
111-
112- return ba , box
78+ ba = fboxlib .boxarray (boxes = [[lo , hi ]])
79+ ba .maxsize (max_sizes )
80+ la = fboxlib .layout (ba )
81+ return la
11382
11483
11584class Domain (pyclaw_geometry .Domain ):
0 commit comments