Esempio n. 1
0
def create_mesh(outfile, topo_dim, geom_dim, x_coord, y_coord, z_coord):

    rho_coords, rho_shape = get_coord_array(x_coord, y_coord, z_coord)

    print "shape of mesh: %s" % rho_shape
    print "number of points in mesh %s" % len(rho_coords)

    mesh_example = MeshExample(topo_dim,geom_dim) # topo_dim = 1, geom_dim = 3
    num_vertices = len(rho_coords)
    num_cells = num_vertices

    mesh_example.initializing_empty_grid(num_vertices, num_cells)
    mesh_example.create_vertices(rho_coords)
    mesh_example.create_cells(num_cells)
    mesh_example.close()

    fx=File(outfile)
    fx << mesh_example.mesh

    return mesh_example.mesh
Esempio n. 2
0
from netCDF4 import Dataset
import numpy as np
from pylab import *
import re
from dolfin import *
from mesh_class_example import MeshExample

#rho_coords = np.arange(750).reshape(10,15,5)

# TODO: Make Mesh from vertices (rho_coords)

mesh_example = MeshExample(1,3) # topo_dim = 1, geom_dim = 3

num_vertices = 750
num_cells = 1

mesh_example.initializing_empty_grid(num_vertices, num_cells)
mesh_example.create_vertices(10,15,5)

# make the cells
mesh_example.create_cells(num_cells)

fx=File('test_data/outmesh_topo1.xml')
fx << mesh_example.mesh

fr = File('test_data/outmesh_topo1.bin')
fr << mesh_example.mesh


# TODO: Repeat for other meshes (i.e. (lon_u, lat_u, s_rho), etc)