.. _InputsGeometry:

Specifying a geometry
=====================

The following inputs are defined using the ``mfix`` prefix.

+------------------------+-------------------------------------------------------------------+----------+---------------------+
|                        | Description                                                       |   Type   | Default             |
+========================+===================================================================+==========+=====================+
| geometry               | Select a predefined EB geometry                                   |   String | ''                  |
+------------------------+-------------------------------------------------------------------+----------+---------------------+
| geometry_filename      | The CSG file that defines the EB geometry                         |   String | ''                  |
+------------------------+-------------------------------------------------------------------+----------+---------------------+
| levelset__refinement   | Refinement factor of levelset resolution relative to level 0      |   Int    | 1                   |
|                        | resolution                                                        |          |                     |
+------------------------+-------------------------------------------------------------------+----------+---------------------+

Most simulations require a user to specify some kind of geometry. For example, the geometry could be a basic cylinder used to
model flow inside a pipe, or it may be an irregularly shaped solid to study external flow around a bluff body, or the geometry
may be the proposed design of a complex, multi-stage chemical reactor undergoing performance assessment. In the following sections,
several options for specifying a geometry are described.

.. caution::

   Any domain extent that is not periodic or defined as a Dirichlet or Neumann :ref:`boundary condition<InputsBoundaryConditions>`
   must be fully covered. To state this another way, if a domain extent is not periodic or an inflow or outflow boundary condition,
   then it should be excluded from (outside of) the domain by the embedded boundary geometry.


Pre-defined geometries
----------------------

The ``mfix.geometry`` input is used to choose one of the basic pre-defined geometries, or to
select the option to use a user-defined geometry constructed from native AMReX implicit functions.


Constructive solid geometry
---------------------------

Use the ``mfix.geometry_filename`` input to select a *constructive solid geometry (CSG)* that defines
the system geometry.


Regions and boundary conditions
-------------------------------

Simple geometries can be created by combining planar :ref:`regions<InputsRegions>` and no-slip wall
:ref:`boundary conditions<InputsBoundaryConditions>`. The ``mfix.geometry`` and ``mfix.geometry_file``
inputs should remain undefined when using this method.

In the following example, the domain is periodic in the *x-* and *z-* directions; therefore,
walls only need to cover the low and high *xz* faces. First, ``wall1`` and ``wall2`` are defined
in the ``regions`` section, then they are used to specify two no-slip wall boundary conditions.

.. code-block:: bash
   :caption: Example geometry created using regions and boundary conditions.
   :name: define_geometry_with_regions

    # Define periodicity and domain extents
    # -------------------------------------------------------------
    geometry.coord_sys   = 0
    geometry.is_periodic = 1      0      1
    geometry.prob_lo     = 0.     0.     0.
    geometry.prob_hi     = 0.01   0.01   0.005

    # Define two planar regions
    # -------------------------------------------------------------
    mfix.regions = wall1  wall2

    regions.wall1.lo       = 0.000  1.25e-6  0.000
    regions.wall1.hi       = 0.010  1.25e-6  0.005

    regions.wall2.lo       = 0.000  9.99875e-3  0.000
    regions.wall2.hi       = 0.010  9.99875e-3  0.005

    # Use the regions to define no-slip wall boundaries
    # -------------------------------------------------------------
    bc.regions = wall1  wall2

    bc.wall1 = nsw
    bc.wall1.normal = 0.0  1.0  0.0

    bc.wall2 = nsw
    bc.wall2.normal = 0.0 -1.0  0.0

.. caution::

  It is highly recommended that planar regions not be defined coincident to domain
  boundaries. It is better to specify planes slightly offset from the domain as
  demonstrated in the :ref:`above example<define_geometry_with_regions>`.

