Skip to content

Operator constructors silently accept zero, negative, NaN and Inf for dx/dy/dz #387

Description

@gpagallo

Describe the bug
The values dx/dy/dz are currently accepted unchecked. Passing dx = 0 produces
silent Inf/NaN propagation through the assembled operator (the 1-D
Gradient and Divergence constructors both end with *this /= dx;); passing
a negative spacing yields a sign-flipped operator with no warning.

To Reproduce
There is no input validation for the cell-spacing arguments (dx, dy, dz)
across every C++ operator constructor and AddScalarBC free function.

Expected behavior
Each spacing will now be required to be strictly positive and finite;
violations throw std::invalid_argument with a descriptive message naming
the offending parameter and value.

Screenshots
NA

Desktop (please complete the following information):

  • OS: MacOS 26.5
  • Browser Safari
  • Version: 26.5

Smartphone (please complete the following information):
NA

Additional context
NA

Keep-open request

  • I am requesting maintainer review for keep-open.

Reason:
Make MOLE C++ more resilient to input errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++Issues related to the MOLE C++ APIOctave/MATLAB

    Type

    Fields

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions