1. Straight-Edged Boxes
HOPR has several simple built-in mesh generators.
1.1. Cartesian Box
This tutorial shows how to generate a simple mesh of a cubical box and the definition of boundary conditions. The parameter file can be found in
tutorials/1-01-cartbox/parameter.ini
See Cartesian Box: Exemplary Variations of Boundary Conditions for cases with different boundary conditions.
1.1.1. Cartesian Box: Description of Parameters
The following table describes all parameters present in the parameter file. Therefore, it is limited to the parameters needed to generate a Cartesian box mesh. A description of all parameters can be found in List of Parameters.
Parameters |
Setting |
Description |
---|---|---|
|
|
Defines the name embedded in the generated mesh file and is used as prefix for the output files ( |
|
|
Generation of visualization files for the volume and boundary mesh ( |
|
|
Mode of mesh generation; 1: Cartesian mesh (build-in), 3: CFD General Notation System (CGNS, extern) |
|
|
Number of Cartesian boxes |
|
|
Coordinates of the box’s corner nodes in the three-dimensional Cartesian coordinate system. Refer to Fig. 4.1 for the node ordering. |
|
|
Number of elements per box in the direction of the Cartesian coordinate axes; |
|
|
The |
|
|
Type of cells/elements used for discretization; |
|
|
Name of each boundary condition |
|
|
Type of each boundary condition, provided with the components |
1.1.2. Cartesian Box: Boundary Conditions and Sketch
Fig. 1.2 shows the sketch of the current flow setup. Fig. 1.3 gives the corresponding excerpt of the parameter file containing the boundary conditions. Entries are colored to highlight the connection between the BCIndex
and the boundary conditions. The same colors are used for the visualization below.
The index of the first component of the BCIndex
vector 1
assigns the boundary condition on position one, BC_zminus
, to the first surface. Consequently, the index of the second component of the BCIndex
vector 2
assigns the second boundary condition BC_yminus
to the second surface of the Cartesian box and so on. More examples are given in Cartesian Box: Exemplary Variations of Boundary Conditions.
1.1.3. Cartesian Box: Output Visualization
The following section highlights the visualization of the above setup. For more details on the HOPR visualization output, see Visualization.
Mesh
This is a visualization of the cartbox_Debugmesh.dat file.
Boundary Conditions
This is a visualization of the cartbox_Debugmesh_BC.dat
file. The colors of the surfaces represent the boundary conditions and are identical to the ones in the excerpt of the parameter file.
1.1.4. Cartesian Box: Exemplary Variations of Boundary Conditions
For a better understanding of the interaction between the parameter BCIndex
and the declaration of the boundary conditions, two different examples are presented below. Both examples are slight variations of the tutorial Cartesian Box in that way, that there are only three different boundary conditions: WALL
, INFLOW
and OUTFLOW
. This means the components belonging to the surfaces will be equal in the BCIndex
vector (see List of Parameters).
1.1.4.1. Example 1
Parameters and Sketch
The parameter file of this example can be found in
/tutorials/1-01-cartbox/parameter_ex1.ini
Fig. 1.11 shows a sketch of the current problem. Figure 1.12 shows a snippet of the parameter file which deals with the boundary conditions. In this code snippet, some text elements are colored to show the connection between the surfaces and their associated boundary conditions. The same colors are used for the visualization below.
The first four components of the BCIndex
vector are equal. The index of these components 1
means that the first boundary condition, BC_wall
, is assigned to the surfaces one to four. Furthermore, the fifth component of the BCIndex
vector with the index 2
means that the second boundary condition BC_inflow
is assigned to the fifth surface of the Cartesian box. The third boundary condition BC_outflow
is assigned to the the sixth surface. Therefore, the last or the sixth component of the BCIndex
vector is set to 3
.
Output Vizualisation
If you need help visualizing the HOPR output, visit the Visualization page.
Mesh
A visualization of the mesh of the cartbox_ex1_Debugmesh.dat file is given below.
Boundary Conditions
This is a visualization of the cartbox_ex1_Debugmesh_BC.dat file. The colors of the surfaces represent the boundary conditions and are the same as in the snippet of the parameter file.
1.1.4.2. Example 2
The parameter file of this example can be found in
/tutorials/1-01-cartbox/parameter_ex2.ini
Figure 1.17 shows the sketch of the current problem. Figure 1.18 shows a snippet of the parameter file which deals with the boundary conditions. In this code snippet, some text elements are colored to show the connection between the surfaces and their asociated boundary conditions. The same colors are used for the visualization below.
In this example the first, third, and sixth component of the BCIndex
vector are equal. The index of these components 1
means that the boundary condition at position one, BC_wall
, is assigned to the surfaces one, three and six. Furthermore, the fifth component of the BCIndex
vector with the index 2
means that the second boundary condition BC_inflow
is assigned to the fifth surface of the cartesian box. The third boundary condition BC_outflow
is assigned to the second and the forth surface. Therefore, the second and fourth component of the BCIndex
vector are set to 3
.
Parameters and Sketch
Output Vizualisation
If you need help visualizing the HOPR output, visit the Visualization page.
Mesh
A visualization of the mesh of the cartbox_ex2_Debugmesh.dat file is given below.
Boundary Conditions
This is a visualization of the cartbox_ex2_Debugmesh_BC.dat file. The colors of the surfaces represent the boundary conditions and are the same as in the snippet of the parameter file.
1.2. Periodic Boundary Conditions
This tutorial shows how to define periodic boundary conditions, using only slightly modified definitions from the Cartesian Box tutorial. The parameter file can be found in
tutorials/1-02-cartbox_periodic/parameter.ini
1.2.1. Periodic Boundary Conditions: Description of Parameters
In the following parameters of the parameter file are explained. This description consists only of parameters which are necessary to generate a periodic boundary condition. A description of all parameters of the parameterfile can be found in the previous tutorial Cartesian Box and List of Parameters.
Parameters |
Setting |
Description |
---|---|---|
|
|
Name of the boundary condition |
|
|
For each periodic boundary condition three parameters are mandatory, the |
|
|
The displacement vector must be specified in the three-dimensional Cartesian coordinate system and must be normal to a surface to which the vector was assigned. In addition, the displacement vector must |
1.2.2. Periodic Boundary Conditions: Boundary Conditions and Sketch
Figure 1.23 shows the sketch of the current problem. It is similar to the problem in the Cartesian Box tutorial, but instead of Dirichlet, periodic boundary conditions are assigned to the surfaces one, two, four, and six. Below is a code snippet of the parameter file that deals with the periodic boundary conditions. In this code snippet, some text elements are colored to show the connection between boundary conditions and their related displacement vectors. The same colors are used for the visualization in Fig. 1.17.
As one can see, the first four boundary conditions are periodic because the last alpha
components of the BoundaryType
parameters are not equal to zero. In the definitions of the first two boundary conditions which are assigned to the surfaces one and six (see BCindex
) the alpha
component is set to 1. This means that the assiciated displacement vector is the first defined displacement vector in the parameter file. The sign of alpha
can be explained by the position of the associated surfaces. On the one hand, the vector must point to the inside of the Cartesian box. On the other hand, the vector must also point to the other surfaces that have been assigned with the periodic boundary condition. The vector itself must point in the direction of the z-axis because it must be normal to the surface. In addition, the side length of the Cartesian box is one, so all defined displacement vectors have a length of one.
For the other two periodic boundary conditions of surfaces two and four, the second defined displacement vector is consulted (see alpha
value of the BoundaryType
parameters). The components of the displacement vector (/0.,1.,0./)
result from the required perpendicularity to the surfaces and the side length of the Cartesian box.
1.3. Multiple Cartesian Boxes
This tutorial shows how to create a mesh consisting of multiple Cartesian boxes and how to link them via boundary conditions. The parameter file can be found in
tutorials/1-03-cartbox_multiple/parameter.ini
1.3.1. Multiple Cartesian Boxes: Definition of Multiple Cartesian Boxes
The following general snippet of the parameter file shows how to define multiple Cartesian boxes in the parameter file.
!====================================================================== !
! MESH
!====================================================================== !
Mode =1 ! Mode for Cartesian boxes
nZones =n ! number of boxes
! === zone 1 ===
...
! === zone 2 ===
...
.
.
.
! === zone n ===
...
First, the parameter nZones
must be adapted to the number of Cartesian boxes to be defined. The Cartesian boxes can be defined simply by writing them and their specifications (Corner, nElems, BCIndex, elemtype, ...)
among themselves. Furthermore, it is important that the boxes are correctly defined to each other. If there is to be a contact between two boxes, it is mandatory that the corresponding surfaces will coincide. This means that the corner nodes of the surfaces must also coincide.
However, a correct definition of the corner nodes is not sufficient for the functionality. Therefore, the parameter BCIndex
, which assigns boundary conditions to the surfaces of the boxes must be adapted.
Parameters |
Setting |
Description |
---|---|---|
|
|
The |
A description of all parameters of the parameter file can be found in List of Parameters.
1.3.2. Multiple Cartesian Boxes: Sketch
Figure 1.25 shows the sketch of the current problem. As one can see, the generated mesh shall consist of three Cartesian boxes. These zones are defined in the parameter file in the following order:
1st zone: lower left zone
BCIndex setting: (/-,-,-,-,-,0/)
2nd zone: upper left zone
BCIndex setting: (/0,-,-,-,-,-/)
3rd zone: upper right zone
BCIndex setting: (/-,-,-,-,0,-/)
For a better understanding, the different settings of the parameter BCIndex
are also given. The given settings only consider the components that are set to 0 due to coinciding surfaces.
1.3.3. Multiple Cartesian Boxes: Output Visualization
If you need help visualizing the HOPR output, visit the Visualization page.
Mesh
A visualization of the mesh of the cartbox_multiple_Debugmesh.dat
file is given below.
Boundary Conditions
A visualization of the mesh of the cartbox_multiple_Debugmesh_BC.dat
file is given below. The colors of the surfaces represent the boundary conditions and are the same as in the snippet of the parameter file.
1.4. Stretching Functions
This tutorial shows how to create a mesh consisting of a boxes with a stretched element arrangement. The parameter file can be found in
tutorials/1-04-cartbox_multiple_stretch/parameter.ini
1.4.1. Stretching Functions: Definition of Stretching Functions
Stretching functions can be used to generate a mesh consisting of boxes with a stretched element arrangement. Therefore, two new parameters can be defined in the parameter file: factor
and l0
. Each of them can be used to stretch the elements of a box. Their meaning and connection is shown as one-dimensional case in Fig. 1.28.
In case of a stretched element arrangement, the next element of a box is always stretched by a factor \(f\) in the direction of the coordinate axis. The value of factor \(f\) can have a positive or a negative sign. Here \(f\) has either a negative and an absolute value >1 or a positive sign and an absolute value <1. The length of the first element is called \(l_{0}\). All streched elements \(N\) together have the length \(l_{ges}\).
1.4.2. Stretching Functions: Building a Cartesian Box with Stretched Elements
To obtain a single Cartesian box with a stretched element arrangement, it is important to know that the parameters \(l_{0}\) and \(N\) are defined even before the stretching parameters factor
and l0
are defined. The length \(l_{ges}\) is defined by the boundaries of the Cartesian box and the number of elements per box in the direction of the Cartesian coordinate axes, hereafter called \(N\), is defined by the parameter nElems
.
For a stretched element arrangement either the parameter factor
or the parameter l0
must be defined. The other missing parameter is calculated internally with the following equation:
The structure of the two parameters is explained below. A description of all parameters in the parameter file can be found in List of Parameters.
Parameters |
Setting |
Description |
---|---|---|
|
|
Stretching factor of the elements in the direction of the Cartesian coordinate axes. A value >1 means an increase of the element size in the direction of the coordinate axis, while a value in the |
|
|
The length of the first element of a stretched element arrangement of a Cartesian box. Each component of the vector represents an axis of the Cartesian coordinate system. A value of 0 disables |
Variable Definition of Stretching Functions
There are several ways to get a stretched element arrangement due to the two different stretching parameters factor
and l0
. These cases are:
Definition of
factor
: In this case, the next element of a box is stretched by a factor \(f\) in the direction of the coordinate axis. The parameterl0
is calculated internally by the equation provided above. The number of elements \(N\), defined by the parameternElems
, remains unchanged.Definition of
l0
: In this case, the length of the first element (or of the last, if the sign is negative) in the direction of the coordinate axis is defined. The parameterfactor
is calculated internally by the equation provided above. The number of elements \(N\), defined by the parameternElems
remains unchanged.Definition of
factor
andl0
: In this case, the parameters must be defined manually by the equation provided above. Otherwise, the stretched element arrangement will most likely not achieved the desired shape. In case of an inaccurate definition, the parameterfactor
will ne adjusted to the parameterl0
which means thatfactor
will changed internally. Furthermore, the number of elements \(N\), defined by the parameternElems
will probably not be kept. Instead, \(N\) will be rounded to nearest natural number.
These three different cases are illustrated below using a small cube with an edge length of one and with four elements per axis. For a better understanding, only the x- and y- values have been changed and visualized.
1.4.3. Stretching Functions: Building Multiple Cartesian Boxes with Stretched Elements
To create a mesh consisting of multiple Cartesian boxes with a stretched element arrangement at least one of the parameters factor
and l0
must be defined for each Cartesian box. The reason for this is that if there is to be a contact between two boxes, the corner nodes of the surfaces have to coincide. This means that defining a stretch function for one Cartesian box leads to the need of a stretch function for the neighboring Cartesian box. A visualization of this issue can be seen in the sketch of the tutorial’s problem.
1.4.4. Stretching Functions: Sketch
The following is an example of a mesh of multiple Cartesian boxes with a stretched element arrangement. The corresponding parameter file can be found in
tutorials/1-04-cartbox_multiple_stretch/parameter.ini
The arrangement of the Cartesian boxes is the same as in the Multiple Cartesian Boxes tutorial but instead of equidistant elements, a stretched element arrangement is created by inserting the parameters factor
and l0
. Furthermore, the number of elements of each box has been increased by changing the parameter nElems
to better visualize the stretched element arrangement. The figure below shows how the elements are stretched.
Note that the figure above only shows in which directions the elements are stretched or compressed. Neither the number of elements per box nor the Cartesian box sizes shown correspond to the parameters of the parameter file.
1.4.5. Stretching Functions: Output Visualization
If you need help visualizing the HOPR output, visit the Visualization page.
A visualization of the mesh of the cartbox_multiple_stretch_mesh.h5
file is given below.