Skip to content

Commit

Permalink
[oneD] Introduce Domain1D::type
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Mar 18, 2023
1 parent a5172b1 commit 358512a
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 11 deletions.
36 changes: 36 additions & 0 deletions include/cantera/oneD/Boundary1D.h
Expand Up @@ -41,6 +41,14 @@ class Boundary1D : public Domain1D
_init(1);
}

virtual string type() const {
return "boundary";
}

virtual bool isConnector() {
return true;
}

//! Set the temperature.
virtual void setTemperature(double t) {
m_temp = t;
Expand Down Expand Up @@ -117,6 +125,10 @@ class Inlet1D : public Boundary1D

Inlet1D(shared_ptr<Solution> solution, const string& id="");

virtual string type() const {
return "inlet";
}

//! set spreading rate
virtual void setSpreadRate(double V0);

Expand Down Expand Up @@ -167,6 +179,10 @@ class Empty1D : public Boundary1D
m_id = id;
}

virtual string type() const {
return "empty";
}

virtual void showSolution(const double* x) {}

virtual void init();
Expand Down Expand Up @@ -195,6 +211,10 @@ class Symm1D : public Boundary1D
m_id = id;
}

virtual string type() const {
return "symmetry-plane";
}

virtual void init();

virtual void eval(size_t jg, double* xg, double* rg,
Expand All @@ -221,6 +241,10 @@ class Outlet1D : public Boundary1D
m_id = id;
}

virtual string type() const {
return "outlet";
}

virtual void init();

virtual void eval(size_t jg, double* xg, double* rg,
Expand All @@ -242,6 +266,10 @@ class OutletRes1D : public Boundary1D

OutletRes1D(shared_ptr<Solution> solution, const string& id="");

virtual string type() const {
return "outlet-reservoir";
}

virtual void showSolution(const double* x) {}

virtual size_t nSpecies() {
Expand Down Expand Up @@ -284,6 +312,10 @@ class Surf1D : public Boundary1D
m_id = id;
}

virtual string type() const {
return "surface";
}

virtual void init();

virtual void eval(size_t jg, double* xg, double* rg,
Expand All @@ -307,6 +339,10 @@ class ReactingSurf1D : public Boundary1D
ReactingSurf1D();
ReactingSurf1D(shared_ptr<Solution> solution, const std::string& id="");

virtual string type() const {
return "reacting-surface";
}

virtual void setKinetics(shared_ptr<Kinetics> kin);

//! @deprecated To be removed after Cantera 3.0; replaced by setKinetics
Expand Down
10 changes: 8 additions & 2 deletions include/cantera/oneD/Domain1D.h
Expand Up @@ -57,14 +57,20 @@ class Domain1D
return m_type;
}

//! String indicating the domain implemented.
//! @since New in Cantera 3.0.
virtual string type() const {
return "domain";
}

//! The left-to-right location of this domain.
size_t domainIndex() {
return m_index;
}

//! True if the domain is a connector domain.
bool isConnector() {
return (m_type >= cConnectorType);
virtual bool isConnector() {
return false;
}

//! Set the solution manager.
Expand Down
4 changes: 4 additions & 0 deletions include/cantera/oneD/IonFlow.h
Expand Up @@ -40,6 +40,10 @@ class IonFlow : public StFlow
//! @param points initial number of grid points
IonFlow(shared_ptr<Solution> sol, const std::string& id="", size_t points = 1);

virtual string type() const {
return "ion-flow";
}

//! set the solving stage
virtual void setSolvingStage(const size_t phase);

Expand Down
4 changes: 4 additions & 0 deletions include/cantera/oneD/StFlow.h
Expand Up @@ -63,6 +63,10 @@ class StFlow : public Domain1D

~StFlow();

virtual string type() const {
return "gas-flow";
}

//! @name Problem Specification
//! @{

Expand Down
11 changes: 2 additions & 9 deletions src/oneD/Boundary1D.cpp
Expand Up @@ -50,7 +50,7 @@ void Boundary1D::_init(size_t n)
} else {
throw CanteraError("Boundary1D::_init",
"Boundary domains can only be connected on the left to flow "
"domains, not type {} domains.", r.domainType());
"domains, not '{}' domains.", r.type());
}
}

Expand All @@ -72,7 +72,7 @@ void Boundary1D::_init(size_t n)
} else {
throw CanteraError("Boundary1D::_init",
"Boundary domains can only be connected on the right to flow "
"domains, not type {} domains.", r.domainType());
"domains, not '{}' domains.", r.type());
}
}
}
Expand Down Expand Up @@ -226,7 +226,6 @@ void Inlet1D::eval(size_t jg, double* xg, double* rg,
shared_ptr<SolutionArray> Inlet1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "inlet";
meta["mass-flux"] = m_mdot;
auto arr = SolutionArray::create(m_solution, 1, meta);

Expand Down Expand Up @@ -273,7 +272,6 @@ void Empty1D::eval(size_t jg, double* xg, double* rg,
shared_ptr<SolutionArray> Empty1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "empty";
return SolutionArray::create(m_solution, 0, meta);
}

Expand Down Expand Up @@ -326,7 +324,6 @@ void Symm1D::eval(size_t jg, double* xg, double* rg, integer* diagg,
shared_ptr<SolutionArray> Symm1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "symmetry";
return SolutionArray::create(m_solution, 0, meta);
}

Expand Down Expand Up @@ -408,7 +405,6 @@ void Outlet1D::eval(size_t jg, double* xg, double* rg, integer* diagg,
shared_ptr<SolutionArray> Outlet1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "outlet";
return SolutionArray::create(m_solution, 0, meta);
}

Expand Down Expand Up @@ -513,7 +509,6 @@ void OutletRes1D::eval(size_t jg, double* xg, double* rg,
shared_ptr<SolutionArray> OutletRes1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "outlet-reservoir";
meta["temperature"] = m_temp;
auto arr = SolutionArray::create(m_solution, 1, meta);

Expand Down Expand Up @@ -573,7 +568,6 @@ void Surf1D::eval(size_t jg, double* xg, double* rg,
shared_ptr<SolutionArray> Surf1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "surface";
meta["temperature"] = m_temp;
return SolutionArray::create(m_solution, 0, meta);
}
Expand Down Expand Up @@ -768,7 +762,6 @@ void ReactingSurf1D::eval(size_t jg, double* xg, double* rg,
shared_ptr<SolutionArray> ReactingSurf1D::asArray(const double* soln) const
{
AnyMap meta = Boundary1D::getMeta();
meta["type"] = "reacting-surface";
meta["temperature"] = m_temp;
meta["phase"]["name"] = m_sphase->name();
AnyValue source = m_sphase->input().getMetadata("filename");
Expand Down
1 change: 1 addition & 0 deletions src/oneD/Domain1D.cpp
Expand Up @@ -117,6 +117,7 @@ AnyMap Domain1D::getMeta() const
}
};
AnyMap state;
state["type"] = type();
state["points"] = static_cast<long int>(nPoints());
if (nComponents() && nPoints()) {
state["tolerances"]["transient-abstol"] = wrap_tols(m_atol_ts);
Expand Down

0 comments on commit 358512a

Please sign in to comment.