-
-
Notifications
You must be signed in to change notification settings - Fork 346
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
Replace convenience classes by C++ Solution object #735
Conversation
ec82d24
to
9d9f588
Compare
c519b86
to
5b3c41c
Compare
db19dad
to
5b3c41c
Compare
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.
I'm very much in favor of getting rid of these supposed "convenience" classes, and I think this is a good start to extending the use of the Solution
class.
I don't understand the need for the methods getIdealGasPhasePtr
and getGasKineticsPtr
- I don't think there are any important methods of these classes that aren't available from a pointer to the base class. For surface phases / kinetics, there are a few unique methods like getCoverages
, but I'd be inclined to handle those by having a class analogous to Solution
which always returns instances of SurfPhase
and InterfaceKinetics
. Naming this class Interface
might be slightly complicated by the existing, now-deprecated Interface
class, though.
After seeing the Solution
class in action a bit more, I'm wondering if it would make more sense for the thermo()
method and friends to return shared_ptr
and avoid the need to also having a thermoPtr()
(etc.) method. If you then wanted a reference, you could always just write auto& gas = *sol.thermo();
.
This is true, but for some of the older examples, having to type std::dynamic_pointer_cast<IdealGasPhase>(sol->thermoPtr()) and std::dynamic_pointer_cast<GasKinetics>(sol->kineticsPtr()) every time is pretty onerous. As I didn't want to introduce some of the nastier looking C++ 11 features in the simple example, I decided to create the 'convenience' accessors. The main issue is that a more straight-forward type cast of a pointer to the base class is currently blocked here cantera/include/cantera/thermo/Phase.h Lines 102 to 103 in ce47733
Agreed. From what I've seen, there isn't a way around having If you want me to switch to |
- implement constructor that loads ThermoPhase, Kinetics, and Transport from input files (wrapping factory class methods) - logic for selection of transport manager follows Python object - add convenience methods to type-cast frequently used classes
- Remove dependence on IdealGasMix.h
- Edge.h, IncompressibleSolid.h and Metal.h
- IdealGasMix.h and Interface.h
5b3c41c
to
bcde29d
Compare
@speth ... alright. I consolidated everything to |
Under what circumstances is a
Can you give an example of what you think is being blocked? The quoted code should not affect any pointer casting, but just disable copying and assignment. |
8043e5b
to
cfb54d4
Compare
@speth ... yes, there really isn't any special feature in
Regarding the blocked type cast, I misspoke. It appears to be difficult to change the type once a variable is passed by reference, but casting of pointers works regardless (I guess my original point is moot). Since much of the passing happens by reference, I was overly cautious. |
- allow for 'ThermoPhase`, and cast to 'IdealGasPhase' internally
e4d2942
to
07e0e2f
Compare
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.
Thanks, this is looking pretty good. I mostly have just a few suggestions for simplifications and a couple of minor formatting nitpicks.
That's a fair point. Will update once our PROCI manuscript is submitted (or I need to take a break) ... |
8f8f297
to
6693eff
Compare
Done, i.e. |
Codecov Report
@@ Coverage Diff @@
## master #735 +/- ##
==========================================
+ Coverage 70.86% 70.87% +0.01%
==========================================
Files 374 372 -2
Lines 43683 43684 +1
==========================================
+ Hits 30954 30963 +9
+ Misses 12729 12721 -8
Continue to review full report at Codecov.
|
This PR introduces the C++
Solution
object (previously only instantiated from the Python front-end) to the C++ test suite and examples.Changes proposed in this pull request:
Solution
objects from input filesIdealGasMix
,Interface
) for test_problems and samplesAnyMap
)