.. _sma-gmc:

Generic Model Creator
=====================

The generic model creator node provides a tool for creating simulation
directories and input files from a template case by copying user selected
file extensions and replacing tagged variable names in the files. This node
is useful for automatically creating text input files for arbitrary
models based on samples generated from a :ref:`sma-doe`. This node is
demonstrated in the :ref:`sma-ex6` example.

.. figure:: ./images/gmc.png
   :align: center

The directories are either manually created by pressing the ``Create directories``
button or by running the sheet. The input variables are internally hashed and
associated with directories, which allows the node to ignore variables that have
already been written to a directory. The ``Delete directories`` button can be
used to remove all the created directories.

The ``Source directory`` is the directory used as the template model. Once a
``Source directory`` has been selected, the ``File extensions to copy`` and
``File extensions to replace`` lists will be populated with all the file
extensions in the ``Source directory``. The user can now select which file
extensions to simply copy in the ``File extensions to copy`` list and which file
extensions to search and replace in the ``File extensions to replace`` list.

Four different replace patterns are provided. The selected pattern will be used
during the search and replace of the files selected in the
``File extensions to replace`` list. The following patterns are available:

* ``${variable}``
* ``|variable|``
* ``<variable>``
* ``/variable``

where ``variable`` should be replaced with the sample variable name used in the
:ref:`sma-doe`. The user needs to manually edit the files in the
``Source directory``, inserting the selected ``Replace pattern`` where the sample
variables need to be written in the file during the directory creation.

For example, in the following ``MFiX-Exa`` input file excerpt, the z component
of the gas velocity at the bottom boundary condition has been replaced with
``${ug}`` pattern:

.. code-block:: guess

   #_______________________________________________________________________
   # Boundary Conditions
   #

   bc.regions = top bottom

   bc.bottom = mi
   bc.bottom.fluid.volfrac  =  1.0
   bc.bottom.fluid.velocity =  0.0  0.0  ${ug}

   bc.top = po
   bc.top.fluid.pressure = 101325.0


The ``${ug}`` will then be replaced with the appropriate sample value during the
creation of the simulation directories. For example, if the sample value for
``ug`` was ``1.23``:


.. code-block:: guess

   #_______________________________________________________________________
   # Boundary Conditions
   #

   bc.regions = top bottom

   bc.bottom = mi
   bc.bottom.fluid.volfrac  =  1.0
   bc.bottom.fluid.velocity =  0.0  0.0  1.23

   bc.top = po
   bc.top.fluid.pressure = 101325.0


The ``Export directory`` is the location where the simulation directories will
be created with the ``Directory prefix``. The resulting directory paths are
available be connecting to the ``directories`` terminal.