@@ -905,110 +905,25 @@ class PolarGrid(Grid2d):
905905
906906 # pylint: disable=too-many-instance-attributes
907907
908- def __init__ (self , nx , ny , ng = 1 ,
909- xmin = 0.0 , xmax = 1.0 , ymin = 0.0 , ymax = 1.0 ):
910-
911- """
912- Create a PolarGrid object.
913-
914- The only data that we require is the number of points that
915- make up the mesh in each direction. Optionally we take the
916- extrema of the domain (default is [0,1]x[0,1]) and number of
917- ghost cells (default is 1).
918-
919- Note that the Grid2d object only defines the discretization,
920- it does not know about the boundary conditions, as these can
921- vary depending on the variable.
922-
923- Parameters
924- ----------
925- nx : int
926- Number of zones in the r-direction
927- ny : int
928- Number of zones in the theta-direction
929- ng : int, optional
930- Number of ghost cells
931- xmin : float, optional
932- Physical coordinate at the lower x boundary
933- xmax : float, optional
934- Physical coordinate at the upper x boundary
935- ymin : float, optional
936- Physical coordinate at the lower y boundary
937- ymax : float, optional
938- Physical coordinate at the upper y boundary
939- """
940-
941- # pylint: disable=too-many-arguments
942-
943- # size of grid
944- self .nx = int (nx )
945- self .ny = int (ny )
946- self .ng = int (ng )
947-
948- self .qx = int (2 * ng + nx )
949- self .qy = int (2 * ng + ny )
950908
951- # domain extrema
952- self .xmin = xmin
953- self .xmax = xmax
954-
955- self .ymin = ymin
956- self .ymax = ymax
957-
958- # compute the indices of the block interior (excluding guardcells)
959- self .ilo = self .ng
960- self .ihi = self .ng + self .nx - 1
961-
962- self .jlo = self .ng
963- self .jhi = self .ng + self .ny - 1
964-
965- # center of the grid (for convenience)
966- self .ic = self .ilo + self .nx // 2 - 1
967- self .jc = self .jlo + self .ny // 2 - 1
968-
969- # define the coordinate information at the left, center, and right
970- # zone coordinates
971- self .dx = (xmax - xmin )/ nx
972-
973- self .xl = (np .arange (self .qx ) - ng )* self .dx + xmin
974- self .xr = (np .arange (self .qx ) + 1.0 - ng )* self .dx + xmin
975- self .x = 0.5 * (self .xl + self .xr )
976-
977- self .dy = (ymax - ymin )/ ny
978-
979- self .yl = (np .arange (self .qy ) - ng )* self .dy + ymin
980- self .yr = (np .arange (self .qy ) + 1.0 - ng )* self .dy + ymin
981- self .y = 0.5 * (self .yl + self .yr )
982-
983- # 2-d versions of the zone coordinates (replace with meshgrid?)
984- x2d = np .repeat (self .x , self .qy )
985- x2d .shape = (self .qx , self .qy )
986- self .x2d = x2d
987-
988- y2d = np .repeat (self .y , self .qx )
989- y2d .shape = (self .qy , self .qx )
990- y2d = np .transpose (y2d )
991- self .y2d = y2d
992-
993-
994- def face_area (self ):
995- """
996- Return an array of the face areas.
997- The shape of the returned array is (ni, nj).
998- """
999- tr = lambda arr : arr .transpose (1 , 2 , 0 )
1000- x = self .cell_vertices ()[:,0 ]
1001- y = self .cell_vertices ()[0 ,:]
1002- r0 = x [:- 1 , :- 1 ]
1003- r1 = x [+ 1 :, :- 1 ]
1004- t0 = y [:- 1 , :- 1 ]
1005- t1 = y [+ 1 :, + 1 :]
1006-
1007- # ** the area of the arc
1008-
1009- area_i = np .pi * (r0 * np .sin (t0 ) + r0 * np .sin (t1 )) * np .sqrt (np .square (r0 * np .sin (t1 ) - r0 * np .sin (t0 )) + np .square (r0 * np .cos (t1 ) - r0 * np .cos (t0 )))
1010- area_j = np .pi * (r0 * np .sin (t0 ) + r1 * np .sin (t0 )) * np .sqrt (np .square (r1 * np .sin (t0 ) - r0 * np .sin (t0 )) + np .square (r1 * np .cos (t0 ) - r0 * np .cos (t0 )))
1011- return tr (np .array ([area_i , area_j ]))
909+ # def face_area(self):
910+ # """
911+ # Return an array of the face areas.
912+ # The shape of the returned array is (ni, nj).
913+ # """
914+ # tr = lambda arr: arr.transpose(1, 2, 0)
915+ # x = self.cell_vertices()[:,0]
916+ # y = self.cell_vertices()[0,:]
917+ # r0 = x[:-1, :-1]
918+ # r1 = x[+1:, :-1]
919+ # t0 = y[:-1, :-1]
920+ # t1 = y[+1:, +1:]
921+
922+ # # ** the area of the arc
923+
924+ # area_i = np.pi * (r0 * np.sin(t0) + r0 * np.sin(t1)) * np.sqrt(np.square(r0 * np.sin(t1) - r0 * np.sin(t0)) + np.square(r0 * np.cos(t1) - r0 * np.cos(t0)))
925+ # area_j = np.pi * (r0 * np.sin(t0) + r1 * np.sin(t0)) * np.sqrt(np.square(r1 * np.sin(t0) - r0 * np.sin(t0)) + np.square(r1 * np.cos(t0) - r0 * np.cos(t0)))
926+ # return tr(np.array([area_i, area_j]))
1012927
1013928 def area_x (self ):
1014929 """
0 commit comments