-
-
Notifications
You must be signed in to change notification settings - Fork 361
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
Zerod connector nodes #1848
Open
ischoegl
wants to merge
17
commits into
Cantera:main
Choose a base branch
from
ischoegl:zerod-connector-nodes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+741
−654
Open
Zerod connector nodes #1848
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
cf9f0c1
[zeroD] Implement Connector base class
ischoegl ffb07cd
[zeroD] Implement ConnectorFactory
ischoegl 2cc3b82
[zeroD] Move newFlowDevice to ConnectorFactory
ischoegl 8d154e2
[zeroD] Move newWall to ConnectorFactory
ischoegl 9c24061
[clib] Switch to ConnectorCabinet
ischoegl 0bd7a2e
[zeroD] Add deprecations
ischoegl 4c3b22e
[zeroD] Install Reactors when instantiating connectors
ischoegl 5f531c5
[Python] Derive Wall/FlowDevice from ConnectorNode
ischoegl bed7f70
[unittests] Improve test-zeroD coverage
ischoegl e4723a9
[clib] Add new Connector functions
ischoegl 213b2f2
[MATLAB] Use CLib connector functions
ischoegl 66ba9e7
[clib] Remove obsolete functions
ischoegl e47524b
[sourcegen] Add Connector crosswalk
ischoegl 3dbf3fe
[zeroD] Remove ReactorSurface from wallGroup
ischoegl 5942f16
[zeroD] Deprecate Wall/FlowDevice factories
ischoegl af5cffb
[Python] Clarifiy reactor content nomenclature
ischoegl 3822451
[samples] Add plt.show() to Python samples
ischoegl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
//! @file ConnectorFactory.h | ||
|
||
// This file is part of Cantera. See License.txt in the top-level directory or | ||
// at https://cantera.org/license.txt for license and copyright information. | ||
|
||
#ifndef CONNECTOR_FACTORY_H | ||
#define CONNECTOR_FACTORY_H | ||
|
||
#include "cantera/base/FactoryBase.h" | ||
#include "cantera/zeroD/ConnectorNode.h" | ||
|
||
namespace Cantera | ||
{ | ||
|
||
class FlowDevice; | ||
class WallBase; | ||
|
||
//! Factory class to create ConnectorNode objects. | ||
//! | ||
//! This class is mainly used via the newConnectorNode() function, for example: | ||
//! | ||
//! ```cpp | ||
//! shared_ptr<ConnectorNode> valve = newConnectorNode("Valve", r0, r1, "my_valve"); | ||
//! ``` | ||
//! | ||
//! where `r0` and `r1` are reactor objects. | ||
class ConnectorFactory : | ||
public Factory<ConnectorNode, | ||
shared_ptr<ReactorBase>, shared_ptr<ReactorBase>, const string&> | ||
{ | ||
public: | ||
static ConnectorFactory* factory(); | ||
|
||
void deleteFactory() override; | ||
|
||
private: | ||
static ConnectorFactory* s_factory; | ||
static std::mutex connector_mutex; | ||
ConnectorFactory(); | ||
}; | ||
|
||
//! @defgroup connectorGroup Connectors | ||
//! %ConnectorNode objects connect zero-dimensional reactors. | ||
//! ConnectorNode objects should be instantiated via the newConnectorNode() function, | ||
//! for example: | ||
//! | ||
//! ```cpp | ||
//! shared_ptr<ConnectorNode> valve = newConnectorNode("Valve", r0, r1, "my_valve"); | ||
//! ``` | ||
//! | ||
//! where `r0` and `r1` are reactor objects. | ||
//! | ||
//! @since New in %Cantera 3.2. | ||
//! | ||
//! @ingroup zerodGroup | ||
//! @{ | ||
|
||
//! Create a %ConnectorNode object of the specified type | ||
//! @param model String specifying reactor type. | ||
//! @param r0 First reactor. | ||
//! @param r1 Second reactor. | ||
//! @param name Name of the connector. | ||
//! @since New in %Cantera 3.2. | ||
shared_ptr<ConnectorNode> newConnectorNode(const string& model, | ||
shared_ptr<ReactorBase> r0, | ||
shared_ptr<ReactorBase> r1, | ||
const string& name="(none)"); | ||
|
||
//! Create a FlowDevice object of the specified type | ||
//! @since Starting in %Cantera 3.1, this method returns a `shared_ptr<FlowDevice>` | ||
shared_ptr<FlowDevice> newFlowDevice(const string& model, const string& name="(none)"); | ||
|
||
//! Create a WallBase object of the specified type | ||
//! @since Starting in %Cantera 3.1, this method returns a `shared_ptr<WallBase>` | ||
shared_ptr<WallBase> newWall(const string& model, const string& name="(none)"); | ||
|
||
//! @} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,72 @@ | ||||||||||
//! @file ConnectorNode.h | ||||||||||
|
||||||||||
// This file is part of Cantera. See License.txt in the top-level directory or | ||||||||||
// at https://cantera.org/license.txt for license and copyright information. | ||||||||||
|
||||||||||
#ifndef CT_CONNECTOR_H | ||||||||||
#define CT_CONNECTOR_H | ||||||||||
|
||||||||||
#include "cantera/base/ct_defs.h" | ||||||||||
#include "cantera/base/global.h" | ||||||||||
|
||||||||||
namespace Cantera | ||||||||||
{ | ||||||||||
class ReactorBase; | ||||||||||
|
||||||||||
/** | ||||||||||
* Base class for walls and flow devices connecting reactors. | ||||||||||
* In a reactor network, walls and flow devices (valves, pressure regulators, etc.) | ||||||||||
* form edges of a directed graph that connect reactors that form nodes. | ||||||||||
* | ||||||||||
* @since New in %Cantera 3.1. | ||||||||||
* | ||||||||||
Comment on lines
+21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
* @ingroup connectorGroup | ||||||||||
*/ | ||||||||||
class ConnectorNode | ||||||||||
{ | ||||||||||
public: | ||||||||||
//! Transitional constructor. | ||||||||||
//! @todo Implement deprecation warning. | ||||||||||
ConnectorNode(const string& name="(none)") : m_name(name) {} | ||||||||||
|
||||||||||
//! Instantiate a ConnectorNode object with associated ReactorBase objects. | ||||||||||
//! @param r0 First reactor. | ||||||||||
//! @param r1 Second reactor. | ||||||||||
//! @param name Name of the connector. | ||||||||||
ConnectorNode(shared_ptr<ReactorBase> r0, shared_ptr<ReactorBase> r1, | ||||||||||
const string& name="(none)") : m_nodes({r0, r1}), m_name(name) {} | ||||||||||
|
||||||||||
virtual ~ConnectorNode() = default; | ||||||||||
ConnectorNode(const ConnectorNode&) = delete; | ||||||||||
ConnectorNode& operator=(const ConnectorNode&) = delete; | ||||||||||
|
||||||||||
//! String indicating the connector implemented. Usually | ||||||||||
//! corresponds to the name of the derived class. | ||||||||||
virtual string type() const { | ||||||||||
return "ConnectorNode"; | ||||||||||
} | ||||||||||
|
||||||||||
//! Retrieve connector name. | ||||||||||
string name() const { | ||||||||||
return m_name; | ||||||||||
} | ||||||||||
|
||||||||||
//! Set connector name. | ||||||||||
void setName(const string& name) { | ||||||||||
m_name = name; | ||||||||||
} | ||||||||||
|
||||||||||
//! Set the default name of a connector. Returns `false` if it was previously set. | ||||||||||
void setDefaultName(map<string, int>& counts); | ||||||||||
|
||||||||||
protected: | ||||||||||
//! Pair of reactors forming end points of the connector. | ||||||||||
pair<shared_ptr<ReactorBase>, shared_ptr<ReactorBase>> m_nodes; | ||||||||||
Comment on lines
+63
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think the |
||||||||||
|
||||||||||
string m_name; //!< ConnectorNode name. | ||||||||||
bool m_defaultNameSet = false; //!< `true` if default name has been previously set. | ||||||||||
}; | ||||||||||
|
||||||||||
} | ||||||||||
|
||||||||||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This seems to get into the nomenclature question -- are connectors nodes (vertices) as the name
ConnectorNode
implies, or edges, as described here?