Changeset 672


Ignore:
Timestamp:
01/30/18 17:58:02 (6 years ago)
Author:
dubos
Message:

devel/unstructured : Fix partitioning

Location:
codes/icosagcm/devel/Python
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • codes/icosagcm/devel/Python/dynamico/meshes.py

    r642 r672  
    55import matplotlib.tri as tri 
    66import matplotlib.pyplot as plt 
    7 from unstructured import init_mesh 
     7from unstructured import init_mesh, list_stencil 
    88 
    99radian=180/math.pi 
  • codes/icosagcm/devel/Python/test/py/RSW_MPAS_W02.py

    r632 r672  
     1print 'Loading DYNAMICO modules ...' 
     2from dynamico import unstructured as unst 
     3from dynamico.meshes import MPAS_Mesh as Mesh 
     4from dynamico import time_step 
     5print '...Done' 
     6 
    17print 'Loading modules ...' 
    28import math as math 
    39import matplotlib.pyplot as plt 
    410import numpy as np 
    5 print '...Done' 
    6  
    7 print 'Loading DYNAMICO modules ...' 
    8 from dynamico import unstructured as unst 
    9 from dynamico.meshes import MPAS_Mesh as Mesh 
    10 from dynamico import time_step 
    1111print '...Done' 
    1212 
  • codes/icosagcm/devel/Python/test/py/partition.py

    r620 r672  
    66print '%d/%d starting'%(mpi_rank,mpi_size) 
    77 
    8 import sys 
     8#from dynamico import partition 
     9from dynamico import parallel, meshes 
     10from dynamico import unstructured as unst 
     11 
    912import math as math 
    1013import numpy as np 
     
    1518from matplotlib.collections import PatchCollection 
    1619 
    17 #from dynamico import partition 
    18 from dynamico import parallel 
    19 from dynamico import unstructured as unst 
    20 from dynamico.unstructured import list_stencil, reindex 
    21  
    2220print 'Done loading modules' 
    23  
    24 sys.stdout.flush() 
    2521 
    2622#----------------- partition hand-written 15-cell mesh ------------------# 
     
    9086    mydegree, mybounds = [get_mycells(x) for x in nEdgesOnCell, verticesOnCell] 
    9187    print '%d : len(mydegree)=%d'%(mpi_rank, len(mydegree)) 
    92     vertex_list = sorted(set(list_stencil(mydegree,mybounds)))  
     88    vertex_list = sorted(set(unst.list_stencil(mydegree,mybounds)))  
    9389    print '%d : len(vertex_list))=%d'%(mpi_rank, len(vertex_list)) 
    9490    get_myvertices = parallel.Get_Indices(dim_vertex, vertex_list) 
    9591    mylon, mylat = [get_myvertices(x)*180./math.pi for x in lonVertex, latVertex] 
    9692    vertex_dict = parallel.inverse_list(vertex_list) 
    97     reindex(vertex_dict, mydegree, mybounds) 
     93    meshes.reindex(vertex_dict, mydegree, mybounds) 
    9894    return vertex_list, mydegree, mybounds, mylon, mylat 
    9995 
     
    104100#grid = 'x4.163842' 
    105101print 'Reading MPAS file %s ...'%grid 
    106 sys.stdout.flush() 
    107102 
    108103nc = cdf.Dataset('grids/%s.grid.nc'%grid, "r") 
     
    127122          cellsOnEdge, edgesOnEdge, verticesOnEdge) : x.data = x.data-1 
    128123edge2cell, cell2edge, edge2vertex, vertex2edge, cell2cell, edge2edge = [ 
    129     unst.Stencil_glob(a,b) for a,b in  
     124    meshes.Stencil_glob(a,b) for a,b in  
    130125    (edge_degree, cellsOnEdge), (nEdgesOnCell, edgesOnCell), 
    131126    (edge_degree, verticesOnEdge), (vertex_degree, edgesOnVertex), 
     
    135130 
    136131print 'Partitioning ...' 
    137 sys.stdout.flush() 
    138132 
    139133edge_owner = unst.partition_mesh(nEdgesOnEdge, edgesOnEdge, mpi_size) 
    140134edge_owner = parallel.LocPArray1D(dim_edge, edge_owner) 
    141 cell_owner = unst.partition_from_stencil(edge_owner, nEdgesOnCell, edgesOnCell) 
     135cell_owner = meshes.partition_from_stencil(edge_owner, nEdgesOnCell, edgesOnCell) 
    142136cell_owner = parallel.LocPArray1D(dim_cell, cell_owner) 
    143137 
     
    145139 
    146140print 'Constructing halos ...' 
    147 sys.stdout.flush() 
    148141 
    149142def chain(start, links): 
     
    152145        yield start 
    153146 
    154 edges_E0 = unst.find_my_cells(edge_owner) 
     147edges_E0 = meshes.find_my_cells(edge_owner) 
    155148cells_C0, edges_E1, vertices_V1, edges_E2, cells_C1 = chain( 
    156149    edges_E0, ( edge2cell, cell2edge, edge2vertex, vertex2edge, edge2cell) ) 
    157150 
    158 edges_E0, edges_E1, edges_E2 = unst.progressive_list(edges_E0, edges_E1, edges_E2) 
    159 cells_C0, cells_C1 = unst.progressive_list(cells_C0, cells_C1) 
     151edges_E0, edges_E1, edges_E2 = meshes.progressive_list(edges_E0, edges_E1, edges_E2) 
     152cells_C0, cells_C1 = meshes.progressive_list(cells_C0, cells_C1) 
    160153 
    161154print 'E2,E1,E0 ; C1,C0 : ', map(len, (edges_E2, edges_E1, edges_E0, cells_C1, cells_C0)) 
    162 sys.stdout.flush() 
    163155 
    164156#com_edges = parallel.Halo_Xchange(24, dim_edge, edges_E2, dim_edge.get(edges_E2, edge_owner)) 
     
    172164comm.Reduce(local_num, total_num, op=MPI.SUM, root=0) 
    173165if(mpi_rank==0): print 'total num :', total_num[0], dim_cell.n 
    174 sys.stdout.flush() 
    175166 
    176167#---------------------------- plot -----------------------------# 
     
    178169if True: 
    179170    print 'Plotting ...' 
    180     sys.stdout.flush() 
    181171 
    182172    halo_vertex_list, mydegree, mybounds, mylon, mylat = local_mesh(com_cells.get_all) 
Note: See TracChangeset for help on using the changeset viewer.