Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add text about how to set default value in the code by passing name #1260

Merged
merged 1 commit into from
Aug 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion Docs/sphinx_documentation/source/Basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,34 @@ run with

to change the value of :cpp:`ncells` and :cpp:`hydro.cfl`.

Sometimes an application code may want to set a default that differs from the
default in AMReX. In this case, it is often convenient to define a function that
sets the variable(s), and pass the name of that function to :cpp:`amrex::Initialize`.
As an example, we may define :cpp:`add_par` to set :cpp:`extend_domain_face`
to true if it hasn't already been set in the inputs file.

.. highlight:: c++

::

void add_par () {
ParmParse pp("eb2");
if(not pp.contains("extend_domain_face")) {
pp.add("extend_domain_face",true);
}
};

Then we would pass :cpp:`add_par` into :cpp:`amrex::Initialize`:

.. highlight:: c++

::

amrex::Initialize(argc, argv, true, MPI_COMM_WORLD, add_par);

This value replaces the current default value of false in AMReX itself, but
can still be over-written by setting a value in the inputs file.


.. _sec:basics:initialize:

Expand Down Expand Up @@ -347,7 +375,7 @@ arguments.
main2d*.exe inputs amrex.v=1 amrex.fpe_trap_invalid=1 -- -tao_monitor

then AMReX will parse the inputs file and the optional AMReX's command
line arguments, but will ignore everything after "--".
line arguments, but will ignore everything after the double dashes.

.. _sec:basics:amrgrids:

Expand Down