Skip to content

Bring C++ to parity with MATLAB/Octave: gradient, divergence, laplacian #303

@Tony-Drummond

Description

@Tony-Drummond

**Is your feature request related to a problem? Yes.
Currently the mimetic operators in MATLAB/Octave work for periodic and non-periodic boundary conditions. The C++ implementation needs to include functionality to support the periodic cases. The new MATLAB/Octave interface returns mimetic operators depending on whether or not the operator contain a periodic boundary condition type a0 U + b0 dU/dn = g. However, the current C++ gradient constructors do not check for these boundary conditions, nor has an implementation for periodic boundaries.

Describe the solution you'd like
We propose the creation of new C++ constructors that match the grad implementations in MATLAB/Octave. See attached figure.

Image

Cases; 1, 4, and 7 are obsolete and currently kept in the MATLAB/Octave implementation for compatibility with earlier versions of the library.
The new gradient interface include two extra parameters at the end, dc and nc, with the boundary conditions for 1D, 2D and 3D. These are the cases; 2, 3, 5, 6, 8, 9 in the figure.

Describe alternatives you've considered
We proposed to implement only cases 2, 3, 5, 6, 8, 9 in C++, as the absence of the dc and nc parameters in the calls suggest naturally a periodic boundary conditions, but in actuality it used to be the only interface to the nonperiodic case. If we keep the cases 1, 4, and 7 for backward compatibility, it may not promote logical congruence with the actual implementation.
Alternatively, we implement the 9 cases in the figure and plan to revisit deprecating cases 1, 4, and 7 in later software releases.

Notice that the above applies to the other operators (i.e., divergence and laplacian)

Additional context
Compare grad, grad.m, grad2D.m, grad3D.m, gradNonPeriodic.m, gradPeriodic.m, gradNonPeriodic2D.m, gradPeriodic2D.m, gradNonPeriodic3D.m, and gradPeriodic3D.m.

Any thoughts? @mdumett and @jbrzensk

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions