.. _geometry_definition: Domain and geometry definition =================================== This chapter describes the preprocessing actions for a ComFLOW simulation, including amongst others the geometry definition and the initialization of the flow solution. The preprocessing program GEODEF has been developed to make it possible to define arbitrary complex geometries for fluid flow simulations. Finite element modeling has many advantages. It is a wide-spread method and there exist many packages that can make finite element descriptions of a geometry that can be as complex as desired. .. _geometry_definition/domain: Domain definition ------------------- The computational domain, in which the simulation is performed, always has a box-like shape, which makes it very easy to define a (semi-)structured grid. The geometry within the domain is defined by means of the preprocessor GEODEF, which produces a file that contains volume and edge apertures for every cell. The volume aperture of a cell defines which part of the cell is open for fluid and which part is closed by the geometry. The edge apertures give similar information for the cell faces. For explanation of the geometry preparation, see :numref:`Chapter %s `. The domain extents are given by the input parameters ``xmin``, ``xmax``, ``ymin``, ``ymax``, ``zmin``, ``zmax``. These can be specified in the body of ``domain/extents/`` using the same ordering, for example: .. code-block:: xml 0.0 100.0 -10.0 10.0 -30.0 3.0 results in the computational domain :math:`\textstyle\{ (x,y,z)\; | \; 0 < x < 100, -10]{nrintp}{1} gives a more fluent geometry. ``nrintp`` is a positive integer. It is advised to use a default value of 3 or 4, higher values may give stability problems in exceptional cases, because of small area apertures. In case of moving bodies, when \param{mvbd}{1} the value of ``nrintp`` should not be taken too small, for sufficient accuracy (say, $\geq4$) and should not be taken too large (say $\leq 8$) for computational efficiency. However, when \param{mvbd}{2} (see \cref{section:comflowin:general}) the procedures from \geodef\ are used every time step to compute the apertures of the moving geometry. In that case also larger values can be used and it is advised to take ``nrintp`` sufficiently large for accuracy, e.g. \param{nrintp}{40}.} In \cref{fig:T_geometry} an example of a computational cell with 2 (left) and 4 (right) integration points is given. Cell volume apertures are calculated by counting the number of internal integration points ($\bullet$) that are inside the geometry. The cell face apertures are calculated by counting the number of integration points on the cell faces ($\times$) that are inside the geometry. The volume aperture ($F^b$) is calculated as the number of points outside the solid geometry, divided by the total number of points: $F^b=\frac{3}{4}=0.75$. Following the same procedure on the edges leads to $A^y=0.5$ and $A^x=0$. For the example with 4 integration points the same procedure leads to $F^b=\frac{10}{16}=0.625$, $A^y=\frac{3}{4}=0.75$ and $A^x=\frac{3}{4}=0.75$ which is already significantly more accurate. .. figure:: figures/fixedform/integration_points.png :scale: 70% Example of the calculation of geometry apertures using 2 (left) or 4 (right) integration points (gray grids) per grid cell (thick rectangles). The more integration points, the smoother the geometry. The gray area is solid geometry. The attribute of an integration point (solid or empty) is determined according to the *last* element in which the point lies. So the attribute of a point can change if it is inside a geometrical entity that is defined later in the ``geometry.in`` input file with a different attribute. In this way, it is possible to create an object as an union or intersection of geometrical entities. For example, if fluid flow inside a sphere is simulated, two elements should be defined. The first one is a solid brick, which has sizes equal to the domain given in ``comflow.in``. The second one is an empty sphere. The first element takes care of the solid outside the sphere, which is necessary because the starting geometry is an empty (non-solid) domain (see :numref:`geometry_definition/examples/flow_inside_sphere`). Consistent volume and face apertures. ............................................................ As of ComFLOW v2.3, special care is taken to create consistent volume and face apertures. Moreover, the search algorithm in GEODEF has been improved to prevent the occurrence of faulty 'virtual walls'. With old versions, in exceptional cases such virtual walls may have been computed. In those cases, the fluid is hampered to move through a ComFLOW cell face, although this face should be fully open for flow. In the left figure an example is depicted of such a virtual wall; the cell face is partly closed. If a ComFLOW sub-cell is closed (because of a solid body) and its neighbor is open, in principle no flow can move through the face fraction between these two sub-cells. With old versions of GEODEF this may not always have been the case; in such a case the volume and face aperture are not in agreement. In the right figure the depicted volume and face apertures are fully consistent, as computed with the new version of GEODEF. .. figure:: figures/virtualwall.png :scale: 75 % :alt: Virtual walls due to inconsistent cell (face) apertures Left: possible virtual walls computed with old versions of GEODEF. Right: consistent volume and face apertures. The blue and dark colors denote ComFLOW sub-cells filled with fluid and solid, respectively. The green and red part of the cell face are open and closed for flow, respectively. Efficiency of the pre-processor. ............................................................ Because of computation time, the number of elements should be as small as possible. The process described above gives a computation time of GEODEF that is *linear* in the number of elements, *linear* in the number of grid points and *cubic* in the number of integration points ``nrintp`` (defined in the input file ``comflow.in``). To make GEODEF more efficient, the apertures of the cells are initialized first. At this stage, for every computational cell it is checked whether it is in the neighborhood of a solid element. If it is not in the neighborhood of a solid element, the volume and edge apertures are set open for this cell. In that case, it is not necessary to check all elements for each integration point in this cell, which makes a large difference in computational time. Output files. ............................................................ GEODEF produces two output files that are used by ComFLOW: ``apertures.in`` and ``geomoving.in``. The file ``apertures.in`` contains the volume and edge apertures of every grid cell. In ``geomoving.in``, for every cell it is determined whether it is (partly) a fixed geometry, a moving geometry or completely open for fluid flow. Calling sequence. .............................. When ComFLOW starts, the file ``apertures.in`` is read, thus it should exist. So the right way to call the programs is: first GEODEF, with input files ``geometry.in`` and ``comflow.in`` (and optionally ``grid.in``). Output are the files ``apertures.in`` and ``geomoving.in``. Finally, call ComFLOW with a value of 0 for the variable ``liqcnf`` in ``comflow.in`` to make sure that ``liquid_distr.in`` will be used. This will start the simulation. In \cref{fig:callingsequence:fixedbodies} this is shown in a graphical way. Visualizing the geometry ----------------------------------------------- Sometimes it is useful to have information on the values of the apertures, i.e. the fractions of ComFLOW cells that are open for flow. With the MATLAB GUI it is possible to view the contents of an individual cell by means of the probe function as explained in the manual for the ComFLOW pre- & post-processor. The files ``apertures.in`` and ``liquid_distr.in`` are stored in the same format as snapshot files. Please consult :numref:`Chapter %s ` for more information about the file format. Due to the inclusion of local grid refinement in ComFLOW |COMFLOW_CURRENT_VERSION|, the format of the GEODEF output file ``apertures.in`` has changed drastically with respect to previous versions. For now we advise to use the visualization functionality provided in the MATLAB pre- & post-processing tool. .. _preprocessing/examples: Examples ------------- In this section several examples will be discussed how to build a geometry with the pre-processor GEODEF. As ``comflow.in`` and ``geometry.in`` are input for GEODEF, both files are discussed for each case. Note that only the most important lines of ``comflow.in`` are discussed. A full description of this input file is given in :numref:`fixed_form_input`. Flow around a solid sphere .............................. The fluid flow around a sphere will be simulated. The domain is defined in ``${INPUT}/comflow.in`` by means of .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -10.0 10.0 -2.0 2.0 -2.0 2.0 ------------------------------------------------------------------------ To simulate fluid flow around a sphere located at the origin :math:`(0.0,0.0,0.0)` with radius 1.0, the file ``geometry.in`` should contain the following lines: .. code-block:: none 4 0 0 0.0 0.0 0.0 1.0 1.0 1.0 Number 4 in the first line means the geometrical entity has shape number 4, which is a sphere. The following 0 means that the sphere is solid. The other 0 means that the sphere is not moving. In the second line coordinates of the sphere centre are given. In the last line radii of the ellipsoid along the X, Y and Z-axes are given. After GEODEF and ComFLOW have been run, the result of the geometry can be shown using Matlab (see :numref:`figure/flow_around_sphere`). .. _figure/flow_around_sphere: .. figure:: figures/aroundsphere.png :scale: 50 % :alt: Fluid flow around a solid sphere, cross-section in the XZ-plane. Fluid flow around a solid sphere, cross-section in the XZ-plane. .. _geometry_definition/examples/flow_inside_sphere: Flow inside a sphere .............................. To simulate flow inside a sphere with radius 1.0, the domain should be defined in the file ``comflow.in`` as .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -1.0 1.0 -1.0 1.0 -1.0 1.0 ------------------------------------------------------------------------ The file ``geometry.in`` should contain two geometrical entities: .. code-block:: none 3 0 0 -1.0 -1.0 -1.0 1.0 -1.0 -1.0 1.0 1.0 -1.0 -1.0 1.0 -1.0 -1.0 -1.0 1.0 1.0 -1.0 1.0 1.0 1.0 1.0 -1.0 1.0 1.0 4 1 0 0.0 0.0 0.0 1.0 1.0 1.0 The first geometrical entity has number 3, a brick, and is solid inside. This brick has exactly the same size as the fluid domain defined in ``comflow.in``. This geometrical entity is necessary, because without it, the sphere would be surrounded by empty cells (because of the initial condition that the domain is empty) and would have empty cells inside. By defining a solid brick and after that an empty sphere, only flow in the sphere is possible. The sphere is the second element. It has element number 4 and is empty inside. The center of the sphere is point :math:`(0.0,0.0,0.0)`, the radius is 1.0 (so all the three radii must be 1.0). The resulting geometry is shown in (see :numref:`figure/flow_inside_sphere`). .. _figure/flow_inside_sphere: .. figure:: figures/insidesphere.png :scale: 75 % Fluid inside a sphere with radius 1, cross-section in XZ-plane. Flow around a solid square ............................................................ In this example, a solid square is built from four smaller squares (as if building a finite element model). The example is displayed in the XZ-plane. The domain is defined as follows: .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -10.0 10.0 -2.0 2.0 -2.0 2.0 ------------------------------------------------------------------------ The file ``geometry.in`` contains descriptions of 4 quadrilaterals: .. code-block:: none 12 0 0 -1.0 -1.0 0.0 -1.0 0.0 0.0 -1.0 0.0 12 0 0 0.0 -1.0 1.0 -1.0 1.0 0.0 0.0 0.0 12 0 0 -1.0 0.0 0.0 0.0 0.0 1.0 -1.0 1.0 12 0 0 0.0 0.0 1.0 0.0 1.0 1.0 0.0 1.0 The four quadrilaterals (geometrical entity number 12) are solid. As a union they form a solid square shown in :numref:`figure/solid_square`. .. _figure/solid_square: .. figure:: figures/solidsquare.png :scale: 75 % Fluid flow around a solid square in two dimensions. Flow in and around a rising bubble ............................................................ In this example, the program GEODEF is used to model a rising bubble in a water column. The bubble is modeled as a sphere in a 3D environment, with the following input in ``comflow.in`` for the domain definition: .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -0.5 0.5 -0.5 0.5 -2.0 1.0 ------------------------------------------------------------------------ and the following for the initial liquid configuration: .. code-block:: none ------------------------------------------------------------------------ -- definition initial liquid configuration ----------------------------- liqcnf lqxmin lqxmax lqymin lqymax lqzmin lqzmax 0 -0.5 0.5 -0.5 0.5 -2.0 0.0 ------------------------------------------------------------------------ The value of 0 for the variable ``liqcnf`` indicates that the initial liquid configuration is not read from the input line in ``comflow.in``, but from the separate ``liquid.in`` input file. The file ``geometry.in`` is empty in this case. Note that GEODEF requires ``geometry.in`` as input, so this file should always exist. The file ``liquid.in`` contains two entities: .. code-block:: none 3 0 -0.5 -0.5 -2.0 0.5 -0.5 -2.0 0.5 0.5 -2.0 -0.5 0.5 -2.0 -0.5 -0.5 0.0 0.5 -0.5 0.0 0.5 0.5 0.0 -0.5 0.5 0.0 4 1 0.0 0.0 -1.5 0.25 0.25 0.25 The first 'liquid' entity has number 3, a brick, and is filled with liquid. This brick has the same sizes as the fluid domain defined in ``comflow.in``, but is less high in Z-direction, indicating a free surface at :math:`z = 0.0`. The second entity has number 4, a sphere, and is filled with the second gas phase. It is important to define the liquid brick first and after that the empty sphere, because doing it in the other way would fill the sphere again with liquid. The resulting initial liquid configuration is shown in :numref:`figure/sphere_inside_liquid`. .. _figure/sphere_inside_liquid: .. figure:: figures/risingbubble.png :scale: 75 % Spherical bubble inside a column of fluid. Flow in Sloshsat .............................. In this example, the way to build the Sloshsat geometry is shown. Sloshsat is an experimental satellite, launched to investigate sloshing liquid in space, and its influence on overall spacecraft dynamics. Sloshsat can be built as a union of two spheres with radius 0.228 m and a connecting cylinder with an axis and radius of 0.228 m. The domain in ``comflow.in`` is given by .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -0.342 0.342 -0.228 0.228 -0.228 0.228 ------------------------------------------------------------------------ In ``geometry.in``, four geometrical entities are defined, as given below. The first entity is a brick with size of the domain with solid inside. The second and third entities are the spheres, the fourth entity is the cylinder in-between. As the last three entities have an empty interior, the resulting geometry is a union of these elements. The geometry is shown in :numref:`figure/sloshsat`. .. code-block:: none 3 0 0 -0.342 -0.228 -0.228 0.342 -0.228 -0.228 0.342 0.228 -0.228 -0.342 0.228 -0.228 -0.342 -0.228 0.228 0.342 -0.228 0.228 0.342 0.228 0.228 -0.342 0.228 0.228 4 1 0 -0.114 0.0 0.0 0.228 0.228 0.228 4 1 0 0.114 0.0 0.0 0.228 0.228 0.228 5 1 0 -0.114 0.0 0.0 0.114 0.0 0.0 0.228 .. _figure/sloshsat: .. figure:: figures/sloshsat3D.png :scale: 50 % Geometry of sloshsat, 3-D overview picture .. figure:: figures/sloshsat2D.png :scale: 75 % Geometry of sloshsat, cross section in XZ-plane Coarse finite element model of the bow of a moving ship ............................................................ In order to give an example of the geometry produced with a finite element modeling package, a very rough finite element model of the bow of a moving ship is built using the finite element package SEPRAN. The number of elements is rather small. To build this geometry the following steps are made (see \cref{seprancall}). First the finite element package SEPRAN is used to make a finite element description of the bow of the ship, as shown in \cref{sepran}. The package SEPRAN produces an output file wherein the finite elements are described. A conversion is needed to rewrite the finite element description to the format of the file ``geometry.in`` (this data format converter is different for each finite element package and should be written by the user). After the conversion is performed, the pre-processor GEODEF is invoked to calculate the apertures needed by ComFLOW. .. figure:: figures/callingseq-4.png :scale: 50 % Calling sequence when the geometry is defined in the finite element package SEPRAN. .. figure:: figures/sepplot_grofschip3.png :scale: 50 % Finite element model of the bow of a ship produced by SEPRAN. The domain definition in ``comflow.in`` is given by: .. code-block:: none ------------------------------------------------------------------------ -- domain definition --------------------------------------------------- xmin xmax ymin ymax zmin zmax -40.0 15.0 -30.0 30.0 -6.0 20.0 ------------------------------------------------------------------------ The contents of ``geometry.in`` is given below. Out of 27 tetrahedra only the first two entities and last entity are shown. \cref{grofschip} shows the resulting geometry in ComFLOW. .. code-block:: none 1 0 1 -.4000E+02 -.2350E+02 -.6000E+01 -.4000E+02 .2350E+02 .0000E+00 -.4000E+02 -.2350E+02 .0000E+00 -.2600E+02 .2350E+02 .0000E+00 1 0 1 -.4000E+02 -.2350E+02 -.6000E+01 -.4000E+02 .2350E+02 -.6000E+01 -.4000E+02 .2350E+02 .0000E+00 -.2600E+02 .2350E+02 .0000E+00 ... ....24 other tetrahedra.... ... 1 0 1 -.3200E+02 -.7500E+01 .0000E+00 -.3200E+02 -.7500E+01 .2000E+02 -.3000E+02 -.7500E+01 .2000E+02 -.3000E+02 .7500E+01 .2000E+02 .. figure:: figures/matlgrofschip.png :scale: 50 % The geometry of the bow of a ship in ComFLOW. .. .. rubric:: Footnotes .. .. rubric:: References .. .. bibliography:: references.bib