Skip to content

Fix uninitialized coordinates in ForcingBody

Ankang Gao requested to merge gaoak/nektar:fix/ForcingBody into master

Issue/feature addressed

If equation variables are used in the ForcingBody function, the coordinate Arrays are allocated but uninitialized. The default value, 0, is used for all coordinate variables. As a result, the spatial coordinate is not correctly passed to the body force.

In addition, the number and order of variables listed in the EVASR property must be the same as the solver variables, which is inconvenient in applications when only one variable is involved. For example, in the heating problem, the body force should be defined as

        <FUNCTION NAME="BodyForce">
            <E VAR="u" VALUE="0"  EVARS="u v teta p" />
            <E VAR="v" VALUE="teta*Ra_uni/Pr" EVARS="u v teta p" />
            <E VAR="teta" VALUE="0" EVARS="u v teta p"/>
        </FUNCTION>

whereas u v are not used in the equation.

Besides, p is not an advective variable and cannot be used in the body force expression.

Proposed solution

The body force function can be defined as

        <FUNCTION NAME="BodyForce">
            <E VAR="v" VALUE="teta*Ra_uni/Pr" EVARS="teta" />
            <E VAR="teta" VALUE="0"/>
        </FUNCTION>

In the v_InitObject function, automatically find which variable is defined in EVARS and cache the equation variables list in a map std::map<int, std::vector<int>> m_evarsList. In this example, m_evarsList is

key value
1 2
2
  • If m_evarsList[i] is not defined, the force function will not be evaluated.
  • If m_evarsList[i] is defined but empty, the expression or file function is evaluated.
  • If m_evarsList[i] is not empty, equation variables is used.

Implementation

A map m_evarsList, which contains the equation variables used in the i-th body force, is generated first in the v_InitObject. This map is then used to decide how to evaluate the force in the Update function.

Tests

Notes

Please add any other information that could be useful for reviewers.

Checklist

  • Functions and classes, or changes to them, are documented.
  • User guide/documentation is updated.
  • Changelog is updated.
  • Suitable tests added for new functionality.
  • Newly added files are correctly formatted.
  • License added to any new files.
  • No extraneous files have been added (e.g. compiler output or test data files). fix issue #310 (closed)
Edited by Ankang Gao

Merge request reports