# In this example, we will set up a domain of triangles in the cartesian 2D # space. To do that, we have to import the appropriate data types for, whose # name is usually preceeded by a prefix formed by the type of cell (Triangular), # the coordinate system (Cartesian) and the space dimension (2D). # # Because a name formed like that is very long, it is not very handy to import # it as is, so we will rather rename the imported objects on rename, in order # to make the names shorter. from viennagrid.wrapper import TriangularCartesian2D_Domain as Domain from viennagrid.wrapper import TriangularCartesian2D_Segmentation as Segmentation from viennagrid.wrapper import PointCartesian2D as Point # Create an empty domain domain = Domain() # Add vertices to the domain. These vertices will then be used to define # cells. domain.make_vertex(Point(0, 0)) # Vertex with ID #0 domain.make_vertex(Point(1, 0)) # Vertex with ID #1 domain.make_vertex(Point(2, 0)) # Vertex with ID #2 domain.make_vertex(Point(2, 1)) # Vertex with ID #3 domain.make_vertex(Point(1, 1)) # Vertex with ID #4 domain.make_vertex(Point(0, 1)) # Vertex with ID #5 # This returns a list with all the vertices added until now domain.vertices
# create some vertices and cells (triangles) in it. Then we will store the surface # of the cells using accessors. Finally, we will write the mesh and the scalar data # to a VTK file and we will read it again from the mesh file, just to illustrate # how to read and write data stored using accessors. from viennagrid.wrapper import TriangularCartesian2D_Domain as Domain from viennagrid.wrapper import TriangularCartesian2D_Segmentation as Segmentation from viennagrid.wrapper import PointCartesian2D as Point from viennagrid.wrapper import TriangularCartesian2D_Cell_Accessor as CellAccessor from viennagrid.wrapper import surface from viennagrid.wrapper import read_vtk, write_vtk # Create an empty domain domain = Domain() # Add vertices to the domain. These vertices will then be used to define # cells. domain.make_vertex(Point(0, 0)) # Vertex with ID #0 domain.make_vertex(Point(1, 0)) # Vertex with ID #1 domain.make_vertex(Point(2, 0)) # Vertex with ID #2 domain.make_vertex(Point(2, 1)) # Vertex with ID #3 domain.make_vertex(Point(1, 1)) # Vertex with ID #4 domain.make_vertex(Point(0, 1)) # Vertex with ID #5 # Create a segmentation of the domain segmentation = Segmentation(domain) # Create 2 segments in the segmentation of the domain seg0 = segmentation.make_segment()
from viennagrid.wrapper import centroid from viennagrid.wrapper import circumcenter from viennagrid.wrapper import is_boundary from viennagrid.wrapper import is_interface from viennagrid.wrapper import refine from viennagrid.wrapper import refine_uniformly from viennagrid.wrapper import scale from viennagrid.wrapper import spanned_volume from viennagrid.wrapper import surface from viennagrid.wrapper import volume #################################### # Domain setup #################################### domain = Domain() p0 = Point(0, 0) p1 = Point(1, 0) p2 = Point(2, 0) p3 = Point(2, 1) p4 = Point(1, 1) p5 = Point(0, 1) domain.make_vertex(p0) # Vertex with ID #0 domain.make_vertex(p1) # Vertex with ID #1 domain.make_vertex(p2) # Vertex with ID #2 domain.make_vertex(p3) # Vertex with ID #3 domain.make_vertex(p4) # Vertex with ID #4 domain.make_vertex(p5) # Vertex with ID #5