-
-
Notifications
You must be signed in to change notification settings - Fork 381
Clone Solution objects used by Reactor / ReactorSurface #1921
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
76fc4be
to
2038ba6
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1921 +/- ##
==========================================
+ Coverage 74.28% 74.30% +0.01%
==========================================
Files 448 448
Lines 55744 55862 +118
Branches 9190 9211 +21
==========================================
+ Hits 41411 41507 +96
- Misses 11232 11248 +16
- Partials 3101 3107 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
9244690
to
f410da9
Compare
With this implementation now largely working, I have a couple of observations in relation to the discussion in Cantera/enhancements#201:
As such, I think the next steps for this PR are:
|
@speth ... thanks for your work on this, as well as the thoughts for the roadmap, which looks 👍. I was somewhat surprised that Beyond, it appears that #1923 fixes other sample tests that are currently failing. |
I didn't anticipate this either, but it's pretty clear in retrospect. Indeed, the issue is that such lambdas cannot be serialized.
This affects all Likewise, The "next steps" I mentioned before are now completed, but I'm currently struggling with how to get this to play nice with the generated CLib. I added a new method, |
Thanks, @speth for further context.
It should be pretty straight-forward to come up with
Hmm. This makes sense - it wasn't straightforward to get the initial accessors to work properly (most relevant example: At the same time, the existing logic may be sufficient to handle this situation using your new clib-constructor: |-
## CLib constructor template: instantiates new object
// constructor: {{ cxx_wraps }}
try {
{% for line in lines %}
## add lines used for CLib/C++ variable crosswalk
{{ line }}
{% endfor %}
{% if shared %}
## instantiated object manages associated objects (see: sol3_newSolution)
## storage of associated objects requires id (handle) of new object
auto obj = {{ cxx_name }}({{ ', '.join(cxx_args) }});
int id = {{ base }}Cabinet::add(obj);
{% for typ, getter in shared %}
## add associated objects (see: sol3_newSolution, sol3_adjacent)
if (obj->{{ getter }}()) {
{{ typ }}Cabinet::add(obj->{{ getter }}(), id);
}
{% endfor %}
return id;
{% else %}{# not shared #}
## instantiated object has no associated objects; no id is needed
return {{ base }}Cabinet::add({{ cxx_name }}({{ ', '.join(cxx_args) }}));
{% endif %}{# shared #}
} catch (...) {
return handleAllExceptions({{ error[0] }}, {{ error[1] }});
} Specifically, you'd need to get the
As the cloned As an aside, I noticed that there are some stray PS: In a nutshell, you may need to update - name: new
wraps: newReactorBase
uses: [solution]
[...]
- name: del
uses: [solution] I haven't tested it, though. |
@@ -84,6 +94,9 @@ class ReactorBase | |||
//! ReactorBase with Solution object. | |||
void setSolution(shared_ptr<Solution> sol); | |||
|
|||
//! Access the Solution object used to represent the contents of this reactor. | |||
shared_ptr<Solution> solution() { return m_solution; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In other contexts (specifically Python), we use contents
. I don't have strong opinions, though.
Fwiw, we're not consistent in Python, either:
property thermo:
"""
The `ThermoPhase` object representing the reactor's contents.
"""
def __get__(self):
self.rbase.restoreState()
return self._contents
The docstring here isn't correct any longer as it has become the Solution
object (it refers to the same object as the new C++ method). The situation is the also same for an existing kinetics
property. It still all works due to inheritance, but is overall misleading.
Obviously, this is a pre-existing condition. Introducing the C++ method does, however, provide an opportunity to make things consistent across all APIs.
Changes proposed in this pull request
If applicable, fill in the issue number this pull request is fixing
Closes #
If applicable, provide an example illustrating new features this pull request is introducing
Checklist
scons build
&scons test
) and unit tests address code coverage