Skip to content
Open
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
20 changes: 9 additions & 11 deletions manual/sphinx/user_docs/variable_init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -328,22 +328,20 @@ to ``generate`` in the ``Context`` object.

Field3D shear = ...; // Value calculated in BOUT++

FieldFactory factory(mesh);
auto gen = factory->parse("model:viscosity");
Options& model_options = options["model"];
auto str = model_options["viscosity"].doc("Viscosity").as<std::string()>;

auto gen = FieldFactory::get()->parse(str, &model_options);

Field3D viscosity;
viscosity.allocate();

BOUT_FOR(i, viscosity.region("RGN_ALL")) {
viscosity[i] = gen->generate(bout::generator::Context(i, CELL_CENTRE, mesh, 0.0)
.set("shear", shear[i]));

BOUT_FOR(i, viscosity.getRegion("RGN_ALL")) {
viscosity[i] = gen->generate(bout::generator::Context().set("shear", shear[i]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will use the default Context() constructor (https://github.com/boutproject/BOUT-dev/blob/master/include/bout/sys/generator_context.hxx#L19) so "x", "y", "z", "t" will not be defined. Recommend instead using the original Context(i, CELL_CENTRE, mesh, 0.0)

}

Note that the ``Context`` constructor takes the index, the cell
location (e.g. staggered), a mesh, and then the time (set to 0.0
here). Additional variables can be ``set``, "shear" in this case. In
the input options file (or command line) the viscosity could now be a
function of ``{shear}``
Comment on lines -342 to -346
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tbody-cfs any reason why this has been deleted?

In the input options file (or command line) the viscosity can now be written as
a function of ``{shear}``

.. code-block:: cfg

Expand Down