Creating a Domain

The first step in running an ANUGA model is to create a domain. This is done by creating a mesh and then creating a domain from that mesh.

rectangular_cross_domain

The domain (mesh) can be created in a number of ways. The simplest way is to create a simple rectangular domain using the rectangular_cross_domain() function.

For instance the following code creates a 1m by 1m rectangular domain, with a 10 by 10 mesh, with the bottom left corner at (0,0).

domain = anuga.rectangular_cross_domain(10, 10)

Check here for full documentation of the rectangular_cross_domain() function and check the Simple Script Example or Simple Notebook Example for examples of how to use it.

create_domain_from_regions

The usual method for creating a domain for practical problems is to create a domain by defining a boundary polygon and then a set of regions within the domain to define area of different refinement levels and holes in the domain. This is done using the create_domain_from_regions() function.

The regions are defined by a list of polygons. Each polygon is defined by a list of points. The most important polygon is the boundary polygon. This is the outer polygon that defines the boundary of the domain. The segments of the boundary need to be tagged with boundary tags which will allow different boundary conditions to be applied to different segments.

Other polygons are the interior polygons that define the regions within the domain. These other polygons can be used to define regions with different refinenment levels and holes in the domain.

The following example creates a domain with a rectangular boundary 20m by 10m with boundary tags on the 4 sides of the rectangle, and the mesh having a maximum triangle area of 0.2 m^2.

import anuga

bounding_polygon = [[0.0, 0.0],
                 [20.0, 0.0],
                 [20.0, 10.0],
                 [0.0, 10.0]]

boundary_tags={'bottom': [0],
             'right': [1],
             'top': [2],
             'left': [3]}

domain = anuga.create_domain_from_regions(bounding_polygon,
                            boundary_tags,
                            maximum_triangle_area = 0.2,
                            )

Check here for full documentation of the create_domain_from_regions() function and check the Simple Example using Create from Regions for an example of how to use it.

See also

Choosing a Flow Algorithm

How to choose between DE0, DE1, DE_ader2, and DE2 — trade-offs between cost, accuracy, and robustness.

Coordinate Reference Systems

How to attach a coordinate reference system (UTM zone, national grid, or arbitrary local CRS) to a domain via Geo_reference.

ANUGA User Manual — Chapter 7: The Domain

Covers domain construction in depth, including mesh generation from polygon regions, geo-referencing, flow algorithm choices, and domain attributes.

Reference

anuga.rectangular_cross_domain(*args, **kwargs)[source]

Create a rectangular domain.

The triangular mesh is made up of m by n uniform rectangular cells divided into 4 triangles in a cross pattern

Parameters

mint

Number of cells in x direction

nint

Number of cells in y direction

len1float, optional

Length of domain in x direction (left to right) (default 1.0)

len2float, optional

Length of domain in y direction (bottom to top) (default 1.0)

origintuple, optional

Tuple (x, y) specifying location of lower left corner of domain (default (0, 0))

verbosebool, optional

Boolean flag to output information (default False)

Returns

Domain

Shallow water domain instance

anuga.create_domain_from_regions(bounding_polygon, boundary_tags, maximum_triangle_area=None, interior_regions=None, interior_holes=None, hole_tags=None, poly_geo_reference=None, mesh_geo_reference=None, breaklines=None, regionPtArea=None, minimum_triangle_angle=28.0, fail_if_polygons_outside=True, use_cache=False, verbose=False)[source]

Create domain from bounding polygons and resolutions.

Parameters

bounding_polygonlist of tuples

Points in Eastings and Northings, relative to the zone stated in poly_geo_reference if specified. Otherwise points are just x, y coordinates with no particular association to any location.

boundary_tagsdict

Symbolic tags where each key maps to a list of indices referring to segments associated with that tag. Omitted segments are assigned the default tag ‘’.

maximum_triangle_areafloat, optional

Maximal area per triangle for the bounding polygon, excluding the interior regions.

interior_regionslist of tuples, optional

List of (polygon, resolution) tuples for each region to be separately refined. Polygon lines must not cross or overlap, and polygons should not be close to each other. Interior regions outside the bounding_polygon will raise an error.

interior_holeslist of polygons, optional

Polygons for each hole. These polygons do not need to be closed, but their points must be specified in counter-clockwise order.

hole_tagslist of dict, optional

List of tag segment dictionaries. Segments cannot share points.

poly_geo_referenceGeoReference, optional

Geo-reference of the bounding polygon and interior polygons. If None, assume absolute coordinates.

mesh_geo_referenceGeoReference, optional

Geo-reference of the mesh to be created. If None, one will be automatically generated using the lower left corner of bounding_polygon as the x and y values.

breaklineslist of polygons, optional

Lines to be preserved by the triangulation algorithm (e.g., coastlines, walls). Polygons are not closed.

regionPtArealist of 3-tuples, optional

Points with maximum area for the region containing each point.

minimum_triangle_anglefloat, optional

Minimum triangle angle in degrees (default: 28.0).

fail_if_polygons_outsidebool, optional

If True (default), raise an Exception when interior polygons fall outside the bounding polygon. If False, ignore and continue.

use_cachebool, optional

Whether to use caching (default: False).

verbosebool, optional

Output information (default: False).

Returns

Domain

A shallow water domain instance.

Notes

Interior regions should be fully nested, as overlaps may cause unintended resolutions.