Getting Started

Create complex two-dimensional geometries, called domains, using the pargeo.domain.Domain module.

A domain is made of multiple subdomains, which are shapely polygons or multi-plolygons. You can use the pargeo.domain.Geometry to access a variety of shapes.

The domain is then build sequentially, by adding one subdomain after the other starting with the background domain.

Initialize your Domain

[11]:
import pargeo as pg

background_subdomain = pg.geometry.Box((0,0), (1,1)).to_polygon()

domain = pg.Domain(background_subdomain)

Add Subdomains

To add other subdomains, use the Domain.add_subdomain method. At this point you will need to specify a level for the subdomain. The level will then decide how the new subdomain is added to the domain following these rules:

  • Subdomains with the same level are merged together (set union)

  • Subdomains with higher level are cut out of those with a lower one (set difference)

You can plot your domain at any time using the Domain.plot method, or by using the pargeo. plot_subdomain utility function.

[12]:
# Create some other subdomains.
subdomain1 = pg.geometry.Box((.25,.25), (.75, .75)).to_polygon()
subdomain2 = pg.geometry.Circle(center=(.75, .75), radius=.2).to_polygon(refs=50)

# Subdomains are just shapely polygons or multi-polygons, so you can use shapely directly.
import shapely
subdomain3 = shapely.Polygon([(.5, .5), (.7, .5), (.5, .6)])

# Add subdomains to the domain
domain.add_subdomain(subdomain1, level=1)
domain.add_subdomain(subdomain2, level=2)
domain.add_subdomain(subdomain3, level=3)

# Plot the domain
domain.plot()
../_images/notebooks_getting-started_4_0.png
[13]:
# Create a subdomain that should be merged with the circle.
subdomain4 = pg.geometry.Circle(center=(.5, .6), radius=.12).to_polygon(50)
domain.add_subdomain(subdomain4, level=2)

# Plot the domain again
domain.plot()
../_images/notebooks_getting-started_5_0.png

Add Holes

Your domain can contain holes. Holes will be plotted differently (per deafult in white) and will not be passed to Gmsh and therefore not be meshed.

[14]:
domain.set_holes({2})

# plot the updated domain
domain.plot()
../_images/notebooks_getting-started_7_0.png