Input File: Geometry

Basic geometric shapes are created using a region block. Named regions can be embedded inside a compound region to perform boolean operations on the volumes. This can be done recursively to build up complex geometries.

The geometry can be viewed using twcad, a Python program that reads a turboWAVE input file and displays the geometry in a CAD style window.

An important distinction in creating geometries is whether an object is defined in parameter space or real space.

Parameter Space

Objects in parameter space are defined in a specific coordinate system, and become a different object when the coordinate system is changed. For example, the circle is defined in Cartesian coordinates as x^2+z^2=1. If cylindrical coordinates are used, the equation retains its form, \varrho^2+z^2=1, which implies the geometry of the object changes. This can sometimes be used to advantage, e.g., one can create a torus in real space using a circle in parameter space, (\varrho-5)^2+z^2=1.

Real Space

Objects in real space are the same object regardless of coordinates. If a sphere is created in real space, it remains a sphere no matter what the grid geometry is.

At present most objects are created in parameter space. This distinction is only important on a curvilinear grid.

When defining geometry using the input file, 3-tuples are often used to specify spatial coordinates. The meaning of the tuple components depends on the coordinate system, as shown in Table I.

Table I. Input File Tuple Coordinate Mappings.

System

Tuple Order

Comment

Cartesian

(x,y,z)

{\bf e}_x\times{\bf e}_y = {\bf e}_z

Cylindrical

(\varrho,\varphi,z)

\varrho^2 = x^2 + y^2

Spherical

(r,\varphi,\theta)

Polar angle is last

TurboWAVE CAD Viewer

There is a Python program for viewing turboWAVE geometries in turboWAVE/tools/twcad/. If the program is run with stdin in the working directory, a 3D viewing window is created allowing the user to inspect the geometry from any angle. This program has to be run from a special Python environment. For more on how to install and run this program see the documentation in turboWAVE/tools/twcad/.

Geometry Shared Directives

The following directives may be used with any type of region.

translation = ( x , y , z )

Displace region from the current position. Each type of region has a standard initial position, generally corresponding to being centered at the origin. This directive can be repeated to create a sequence of operations.

Parameters:
  • x (float) – translation in the x direction

  • y (float) – translation in the y direction

  • z (float) – translation in the z direction

rotation about axis = angle

Rotate about the given global axis. This directive can be repeated to create a sequence of operations. Rotations about a shifted axis can be carried out by performing the sequence TRT^{-1} with T a translation and R a rotation.

Parameters:
  • axis (enum) – can be x, y, or z

  • angle (float) – the rotation angle in radians. You can use degrees by adding a dimension, e.g., rotation about axis = 45 [deg].

complement = tst
Parameters:

tst (bool) – if true, transforms the region into its complement

move with window = tst
Parameters:

tst (bool) – if true, the region moves with the window

Basic Region Types

new region rect <name> { <directives> }

Creates a rectangular box.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    bounds = ( x0 , x1 , y0 , y1 , z0 , z1 )

    Defines the limits of the rectangular box. This implies a translation transformation, so ordering with respect to other transformations matters.

new region circ <name> { <directives> }

Creates a circle or sphere in parameter space.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    radius = R
    Parameters:

    R (float) – defines the radius of the circle

new region true_sphere <name> { <directives> }

Creates a sphere in real space.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    radius = R
    Parameters:

    R (float) – defines the radius of the sphere

new region prism <name> { <directives> }

Creates a prism in parameter space.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    bounds = ( x0 , x1 , y0 , y1 , z0 , z1 )

    Defines the limits of the bounding rectangular box. This implies a translation transformation, so ordering with respect to other transformations matters. The tip points in the +x direction.

new region ellipsoid <name> { <directives> }

Creates an ellipsoid in parameter space.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    bounds = ( x0 , x1 , y0 , y1 , z0 , z1 )

    Defines the limits of the bounding rectangular box. This implies a translation transformation, so ordering with respect to other transformations matters.

new region cylinder <name> { <directives> }

Creates a cylinder in parameter space. Default orientation is centered on the z-axis.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    radius = R
    Parameters:

    R (float) – radius of the cylinder

    length = L
    Parameters:

    L (float) – length of cylinder

new region rounded_cylinder <name> { <directives> }

Creates a cylinder in parameter space, with hemispherical end-caps. Default orientation is centered on the z-axis.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    radius = R
    Parameters:

    R (float) – radius of the cylinder

    length = L
    Parameters:

    L (float) – length of cylinder, does not count the end-caps

new region cylindrical_shell <name> { <directives> }

Creates a cylindrical shell, or “tube”, in parameter space. Default orientation is centered on the z-axis.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    inner radius = R1
    Parameters:

    R1 (float) – inner radius of the tube

    outer radius = R2
    Parameters:

    R2 (float) – outer radius of the tube

    length = L
    Parameters:

    L (float) – length of tube

new region torus <name> { <directives> }

Creates a torus in parameter space. Default orientation is centered on the z-axis.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    minor radius = R1
    Parameters:

    R1 (float) – radius of tube that is bent to make the torus

    major radius = R2
    Parameters:

    R2 (float) – distance from the torus center to the tube center

new region cone <name> { <directives> }

Creates a cone in parameter space. Default orientation is centered on the z-axis, i.e., the origin is mid-way between the base and the tip.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    tip radius = R1
    Parameters:

    R1 (float) – radius of blunted tip

    base radius = R2
    Parameters:

    R2 (float) – radius of the cone base

    length = L
    Parameters:

    L (float) – distance between base and tip

new region tangent_ogive <name> { <directives> }

Creates a spherically blunted tangent ogive in parameter space. Default orientation is centered on the z-axis, with the tip on the +z side.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    tip radius = R1
    Parameters:

    R1 (float) – radius of blunted tip

    base radius = R2
    Parameters:

    R2 (float) – radius of the cone base

    length = L
    Parameters:

    L (float) – distance between base and spherical tip

new region box_array <name> { <directives> }

Creates an infinite array of box shaped regions.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    size = ( dx , dy , dz )

    size of each box

    spacing = ( lx , ly , lz )

    center-to-center distance between boxes

Compound Regions

new region union <name> { <directives> }

Create the union of several other regions. This is the boolean or, i.e., if the union has elements A, B, and C, then a point in the union must be in A or in B or in C. If C is the complement of D, then the point must be in A or in B or not in D.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    elements = { R1 , R2 , R3 , ... }

    variable length list of names of regions forming the union

new region intersection <name> { <directives> }

Create the intersection of several other regions. This is the boolean and, i.e., if the intersection has elements A, B, and C, then a point in the intersection must be in A and in B and in C. If C is the complement of D, then the point must be in A and in B and not in D.

Parameters:
  • name (str) – assigns a name to the region

  • directives (block) –

    The following directives are supported:

    Shared directives: see Geometry Shared Directives

    elements = { R1 , R2 , R3 , ... }

    variable length list of names of regions forming the intersection

Tip

You can create what most CAD software calls a difference using intersections. The difference of A and B is the intersection of A and the complement of B.

Specific Example in 2D

In this example we make a square with a rounded top in the x-z plane, with a hole in it. First define the elements of the compound region:

new region rect r1
{
        bounds =  -1.0 1.0 -1.0 1.0 -1.0 1.0
}

new region circ c1
{
        translation = 0.0 0.0 1.0
        radius = 1.0
}

new region circ !c2 // exclamation point just reminds us this is the complement of a circle
{
        radius = 0.5
        complement = true
}

Now make the square with rounded top:

new region union u1
{
        elements = { r1 , c1 }
}

Now put a hole in it by using the union in an intersection:

new region intersection i1
{
        elements = { u1 , !c2 }
}

The named region “i1” can now be used as the clipping region in Matter Loading, in certain diagnostics, or in Conducting Regions.