Skip to content

Expose directional derivative and input/output derivative APIs#15

Merged
kyllingstad merged 3 commits into
masterfrom
feature/fmi2-dir-der
May 4, 2026
Merged

Expose directional derivative and input/output derivative APIs#15
kyllingstad merged 3 commits into
masterfrom
feature/fmi2-dir-der

Conversation

@joakimono
Copy link
Copy Markdown
Contributor

Add GetDirectionalDerivative, SetRealInputDerivatives, and GetRealOutputDerivatives virtual methods to SlaveInstance, replacing the previous stub implementations that always returned errors. Available for both FMI 1.0 and FMI 2.0.

Also fix ctest invocation for Conan 2: cmake.ctest() in Conan 2 requires cli_args as a list, not a positional string argument.

Add GetDirectionalDerivative, SetRealInputDerivatives, and
GetRealOutputDerivatives virtual methods to SlaveInstance, replacing
the previous stub implementations that always returned errors.
Available for both FMI 1.0 and FMI 2.0.

Fix ctest invocation for Conan 2: cmake.ctest() in Conan 2 requires
cli_args as a list, not a positional string argument.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes previously-stubbed FMI derivative-related APIs by adding virtual methods to cppfmu::SlaveInstance and wiring the corresponding FMI 1.0 and FMI 2.0 C-entrypoints to forward to the slave implementation. It also updates Conan 2 usage for cmake.ctest() and bumps the project version.

Changes:

  • Add GetDirectionalDerivative, SetRealInputDerivatives, and GetRealOutputDerivatives as virtual APIs on cppfmu::SlaveInstance with default “not supported” implementations.
  • Replace FMI 1.0 / FMI 2.0 stub C functions for these derivative APIs with real forwarding implementations.
  • Fix Conan 2 cmake.ctest() invocation and bump version to 1.2.0.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.txt Bumps library version to 1.2.0.
fmi_functions.cpp Implements FMI 1.0/2.0 derivative API entrypoints by forwarding to SlaveInstance methods with standard error mapping.
cppfmu_cs.hpp Adds new derivative-related virtual methods to the SlaveInstance interface.
cppfmu_cs.cpp Adds default “operation not supported” implementations for the new virtual methods.
conanfile.py Updates Conan 2 cmake.ctest() call to use cli_args list.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread fmi_functions.cpp
… 1.0 function

Extend cs_test fixture to cover fmi2GetDirectionalDerivative,
fmi2SetRealInputDerivatives, and fmi2GetRealOutputDerivatives (FMI 2.0)
plus fmiSetRealInputDerivatives and fmiGetRealOutputDerivatives (FMI 1.0).

Tests cover both the default 'not supported' error path and the
success path with a simple linear derivative model in TestSlave.

Remove fmiGetDirectionalDerivative from FMI 1.0 build since it is not
part of the FMI 1.0 co-simulation standard.

Add cs_test_fmi1 executable target for FMI 1.0 test coverage.
Copy link
Copy Markdown
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

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

Thanks! This mostly looks good, I just had a small question.

Comment thread tests/cs_slave.cpp Outdated
if (vr[i] == 0) {
value_ = value[i];
} else if (vr[i] == 1) {
derivativeSupported_ = (value[i] != 0.0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why use a real variable to set whether derivatives are supported? Using a boolean would be more natural and, as a bonus, broaden the test coverage to also include SetBoolean() and GetBoolean().

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed to suggested data type to broaden test coverage.

@kyllingstad
Copy link
Copy Markdown
Member

Also wondering if the CI failures are pointing to some needed improvements in our workflow.

Replace the vr=1 Real control variable with a Boolean, which is more
semantically natural for an enable/disable flag. This also exercises
the SetBoolean and GetBoolean virtuals, which previously had zero
test coverage.

The vr=1 value reference now throws in SetReal/GetReal, extending
the invalid value reference error path coverage.
@joakimono
Copy link
Copy Markdown
Contributor Author

Also wondering if the CI failures are pointing to some needed improvements in our workflow.

Unfortunately, this is a quirk of our new conan remote that I know no robust solution to yet. Rerunning the failed jobs resolves the build failure. When I have figured out how to avoid it altogether, a solution will appear here too.

Copy link
Copy Markdown
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

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

Great, thanks!

@kyllingstad kyllingstad merged commit 7360006 into master May 4, 2026
12 checks passed
@kyllingstad kyllingstad deleted the feature/fmi2-dir-der branch May 4, 2026 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants