geometry.Geometry#

class geometry.Geometry#

Bases: ABC

A virtual base class for all geometry classes in HelloTriangle.

The Geometry class is a generic parent class for all geometry classes in HelloTriangle. It is not intended to be used directly, but only through derived classes, like Mesh.

The basic entity of geometry is the point, defined by its coordinates. The Geometry class expects these to be stored in a Coords object assigned to the coords attribute.

The Geometry class exposes the following attributes or property methods of the coords attribute, so that they can be directly used on the Geometry object: xyz, x, y, z, xy, yz, xz.

The Geometry class exposes a large set of Coords methods for direct use on the derived class objects. These methods are automatically executed on the coords attribute of the object.

Thus, if M is an instance of class Mesh, then one can use M.center() as a convenient shorthand for M.coords.center().

When calling the transformation methods of the Coords class, they will return a new object identical to the original, except for the coordinates, which are transformed by the specified method. Refer to the correponding Coords method for the precise arguments of these methods.

Geometry is a lot more than points however. Therefore the Geometry and its derived classes can represent higher level entities, such as lines, planes, circles, triangles, cubes,… These entities are often represented by multiple points: a line segment would e.g. need two points, a triangle three. Geometry subclasses can implement collections of many such entities, just like the Coords can hold many points. We call these geometric entities ‘elements’. The subclass must at least define a method n_elems() returning the number of elements in the object, even if there is only one.

The Geometry class supports assigning a property number to each element. A property number is an integer that can be used freely by subclasses or users — for example, as a simple element identifier, or as a key linking the element to additional attributes in an external database. The class provides methods to manage these property numbers.

The Geometry class provides functionality for adding fields to instances of the derived classes. Fields are numerical data (scalar or vectorial) that are defined over the geometry. For example, if the geometry represents a surface, the gaussian curvature of that surface is a field defined over the surface. Field data are stored in Field objects and the Geometry object stores them internally in a dict object with the field name as key. The dict is kept in an attribute fields that is only created when the first Field is added to the object.

Attributes#

coords: Coords

A Coords object that holds the coordinates of the points required to describe the type of geometry.

prop: int array

Element property numbers. This is a 1-dim int array with length n_elems(). Each element of the Geometry can thus be assigned an integer value. It is up to the subclass to define if and how its instances are divided into elements, and how to use this element property number.

fields: dict

A dict with the Fields defined on the object. This atribute only exists when at least one Field has been defined. See add_field().