ug4
|
The ug::Domain class holds a grid (ug::MultiGrid), which stores the elements on which discretization is performed, a SubsetHandler (ug::MGSubsetHandler), which stores a partition of the grid into different subsets, and holds a position attachment, which provides coordinates in the vertices of the grid. The domain class is defined in ugbase/lib_disc/domain.h
libGrid - Overview gives more information on the ug::MultiGrid and related classes.
The domain class is actually a template class, depending on the space-dimension and the grid type. While the grid-type for now is fixed to ug::MultiGrid (supports adaptivity, mixed element types, parallelization, ...), the dimension is used to define the number of coordinates, that the grid's position attachment carries.
A Domain defines a couple of types:
Furthermore the Domain defines the constant dim, which simply equals the dimension template argument of the domain.
Methods which operate on a domain are template methods, most of which simply take a template parameter TDomain. In the following we'll develop a simple method CalculateDomainCenter to demonstrate how the domain class can be used. Note that center in this example simply means the average of all vertex positions:
The method returns a ug::MathVector<1>, ug::MathVector<2>, or ug::MathVector<3> (ug::vector1, ug::vector2, or ug::vector3) depending on the domains dimension.
We'll iterate over all vertices of the grid and average their coordinates. For this we'll first retrieve the domain's grid and the domain's position accessor. We'll then access the vertices in the grid through iterators and sum their corrdinates. When this is done, we'll divide the sum through the number of grid-vertices to retrieve the center.
ug::VecSet, ug::VecAdd and ug::VecScale are thereby methods to perform basic vec-math operations. Their first argument is always the target-value, where the result shall be stored. They are defined in ugbase/common/math/math_vector_matrix/math_vector_functions.h
aaPos[vrt] returns a TDomain::position_type (vector1, vector2 or vector3)
number is ug4's floating point type and either float (single precision) or double (double precision). The floating-point type can be set through a cmake parameter. The default is double precision.
libGrid - Overview gives more information on how to access elements of grids and on the different element types them selves.