Skip to content
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

Remove vestigial onedim Python functions and methods #1464

Merged
merged 20 commits into from
Apr 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/cantera/base/SolutionArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ class SolutionArray
//! Set the state vector for a given location.
void setState(size_t loc, const vector<double>& state);

//! Normalize mass/mole fractions
void normalize();

/*!
* Add auxiliary component to SolutionArray. Initialization requires a subsequent
* call of setComponent.
Expand Down
14 changes: 7 additions & 7 deletions include/cantera/oneD/Boundary1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Inlet1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln);
virtual void fromArray(SolutionArray& arr, double* soln);

protected:
int m_ilr;
Expand Down Expand Up @@ -199,7 +199,7 @@ class Empty1D : public Boundary1D
integer* diagg, double rdt);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln) {}
virtual void fromArray(SolutionArray& arr, double* soln) {}
};

/**
Expand Down Expand Up @@ -229,7 +229,7 @@ class Symm1D : public Boundary1D
integer* diagg, double rdt);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln) {}
virtual void fromArray(SolutionArray& arr, double* soln) {}
};


Expand Down Expand Up @@ -259,7 +259,7 @@ class Outlet1D : public Boundary1D
integer* diagg, double rdt);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln) {}
virtual void fromArray(SolutionArray& arr, double* soln) {}
};


Expand Down Expand Up @@ -293,7 +293,7 @@ class OutletRes1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln);
virtual void fromArray(SolutionArray& arr, double* soln);

protected:
size_t m_nsp = 0;
Expand Down Expand Up @@ -330,7 +330,7 @@ class Surf1D : public Boundary1D
integer* diagg, double rdt);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln);
virtual void fromArray(SolutionArray& arr, double* soln);

virtual void show(std::ostream& s, const double* x);

Expand Down Expand Up @@ -373,7 +373,7 @@ class ReactingSurf1D : public Boundary1D
integer* diagg, double rdt);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln);
virtual void fromArray(SolutionArray& arr, double* soln);

virtual void _getInitialSoln(double* x) {
m_sphase->getCoverages(x);
Expand Down
33 changes: 30 additions & 3 deletions include/cantera/oneD/Domain1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -344,16 +344,28 @@ class Domain1D
*/
AnyMap serialize(const double* soln) const;

//! Save the state of this domain as a SolutionArray
//! Save the state of this domain as a SolutionArray.
/*!
* @param soln local solution vector for this domain
* @todo Despite the method's name, data are copied; the intent is to access data
* directly in future revisions, where a non-const version will be implemented.
*
* @since New in Cantera 3.0.
*/
virtual shared_ptr<SolutionArray> asArray(const double* soln) const {
throw NotImplementedError("Domain1D::asArray", "Needs to be overloaded.");
}

//! Save the state of this domain to a SolutionArray.
/*!
* This method serves as an external interface for high-level API's; it does not
* provide direct access to memory.
* @param normalize If true, normalize concentrations (default=false)
*
* @since New in Cantera 3.0.
*/
shared_ptr<SolutionArray> toArray(bool normalize=false) const;

//! Restore the solution for this domain from an AnyMap
/*!
* @param[in] state AnyMap defining the state of this domain
Expand All @@ -372,10 +384,18 @@ class Domain1D
*
* @since New in Cantera 3.0.
*/
virtual void restore(SolutionArray& arr, double* soln) {
throw NotImplementedError("Domain1D::restore", "Needs to be overloaded.");
virtual void fromArray(SolutionArray& arr, double* soln) {
throw NotImplementedError("Domain1D::fromArray", "Needs to be overloaded.");
}

//! Restore the solution for this domain from a SolutionArray.
/*!
* This method serves as an external interface for high-level API's.
* @param arr SolutionArray defining the state of this domain
* @since New in Cantera 3.0.
*/
void fromArray(const shared_ptr<SolutionArray>& arr);

//! Return thermo/kinetics/transport manager used in the domain
//! @since New in Cantera 3.0.
shared_ptr<Solution> solution() const {
Expand Down Expand Up @@ -540,13 +560,20 @@ class Domain1D
m_force_full_update = update;
}

//! Set shared data pointer
void setData(shared_ptr<vector<double>>& data) {
m_state = data;
}

protected:
//! Retrieve meta data
virtual AnyMap getMeta() const;

//! Retrieve meta data
virtual void setMeta(const AnyMap& meta);

shared_ptr<vector<double>> m_state; //!< data pointer shared from OneDim

double m_rdt = 0.0;
size_t m_nv = 0;
size_t m_points;
Expand Down
3 changes: 3 additions & 0 deletions include/cantera/oneD/OneDim.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class OneDim
*/
void writeStats(int printTime = 1);

//! @deprecated To be removed after Cantera 3.0; unused.
AnyMap serialize(const double* soln) const;

// options
Expand Down Expand Up @@ -339,6 +340,8 @@ class OneDim
//! factor time step is multiplied by if time stepping fails ( < 1 )
double m_tfactor = 0.5;

shared_ptr<vector<double>> m_state; //!< Solution vector

std::unique_ptr<MultiJac> m_jac; //!< Jacobian evaluator
std::unique_ptr<MultiNewton> m_newt; //!< Newton iterator
double m_rdt = 0.0; //!< reciprocal of time step
Expand Down
15 changes: 7 additions & 8 deletions include/cantera/oneD/Sim1D.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,13 @@ class Sim1D : public OneDim
/**
* Output information on current solution for all domains to stream.
* @param s Output stream
* @since New in Cantera 3.0.
*/
void show(std::ostream& s);

/**
* Show logging information on current solution for all domains.
* @since New in Cantera 3.0.
*/
void show();

Expand Down Expand Up @@ -196,20 +198,20 @@ class Sim1D : public OneDim
const doublereal* solution() {
warn_deprecated("Sim1D::solution",
"This method is unused and will be removed after Cantera 3.0.");
return m_x.data();
return m_state->data();
}

void setTimeStep(double stepsize, size_t n, const int* tsteps);

void solve(int loglevel = 0, bool refine_grid = true);

void eval(doublereal rdt=-1.0, int count = 1) {
OneDim::eval(npos, m_x.data(), m_xnew.data(), rdt, count);
OneDim::eval(npos, m_state->data(), m_xnew.data(), rdt, count);
}

// Evaluate the governing equations and return the vector of residuals
void getResidual(double rdt, double* resid) {
OneDim::eval(npos, m_x.data(), resid, rdt, 0);
OneDim::eval(npos, m_state->data(), resid, rdt, 0);
}

//! Refine the grid in all domains.
Expand Down Expand Up @@ -278,14 +280,14 @@ class Sim1D : public OneDim
void setSolution(const doublereal* soln) {
warn_deprecated("Sim1D::setSolution",
"This method is unused and will be removed after Cantera 3.0.");
std::copy(soln, soln + m_x.size(), m_x.data());
std::copy(soln, soln + m_state->size(), m_state->data());
}

// @deprecated To be removed after Cantera 3.0 (unused)
const doublereal* solution() const {
warn_deprecated("Sim1D::solution",
"This method is unused and will be removed after Cantera 3.0.");
return m_x.data();
return m_state->data();
}

doublereal jacobian(int i, int j);
Expand Down Expand Up @@ -317,9 +319,6 @@ class Sim1D : public OneDim
}

protected:
//! the solution vector
vector_fp m_x;

//! the solution vector after the last successful timestepping
vector_fp m_xlast_ts;

Expand Down
2 changes: 1 addition & 1 deletion include/cantera/oneD/StFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class StFlow : public Domain1D
virtual void show(const double* x);

virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln);
virtual void fromArray(SolutionArray& arr, double* soln);

//! Set flow configuration for freely-propagating flames, using an internal
//! point with a fixed temperature as the condition to determine the inlet
Expand Down
6 changes: 6 additions & 0 deletions include/cantera/thermo/Phase.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,12 @@ class Phase
//! and restoreState().
virtual std::map<std::string, size_t> nativeState() const;

//! Return string acronym representing the native state of a Phase.
//! Examples: "TP", "TDY", "TPY".
//! @see nativeState
//! @since New in Cantera 3.0
string nativeMode() const;

//! Return a vector containing full states defining a phase.
//! Full states list combinations of properties that allow for the
//! specification of a thermodynamic state based on user input.
Expand Down
2 changes: 2 additions & 0 deletions interfaces/cython/cantera/_onedim.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ cdef extern from "cantera/oneD/Domain1D.h":
void setID(string)
string& id()
string domainType "type"()
shared_ptr[CxxSolutionArray] toArray(cbool) except +translate_exception
void fromArray(shared_ptr[CxxSolutionArray]) except +translate_exception


cdef extern from "cantera/oneD/Boundary1D.h":
Expand Down
Loading