# For that purpose, we need to define a domain and, eventually, also a segmentation
# (in case we want to read segmentation data from the mesh file), and we need the
# Netgen reader function, too.
# 
# (Notice that the 'read_netgen' function and all other I/O functions
# work with any type of domain and segmentation without name change.)

from viennagrid import Domain, Point, Segmentation
from viennagrid import config
from viennagrid.algorithms import *

####################################
# Domain setup
####################################

domain = Domain(config.triangular_2d)

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
Beispiel #2
0
# mesh files using accessors and the VTK reader and writer, respectively.
# 
# We will start defining a domain of triangles in the cartesian 2D space and will
# 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 import Domain, Point, Segmentation
from viennagrid import config
from viennagrid import io
from viennagrid import accessors
from viennagrid.algorithms import surface

# Create an empty domain
domain = Domain(config.triangular_2d)

# 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()