Skip to content

Commit

Permalink
[OneD] Remove legacy YAML serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
ischoegl authored and speth committed Jan 12, 2023
1 parent ef8b62d commit 834c39b
Show file tree
Hide file tree
Showing 10 changed files with 38 additions and 346 deletions.
11 changes: 0 additions & 11 deletions include/cantera/oneD/Boundary1D.h
Expand Up @@ -135,9 +135,7 @@ class Inlet1D : public Boundary1D
virtual void init();
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);
virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(const AnyMap& state, double* soln, int loglevel);
virtual void restore(SolutionArray& arr, double* soln, int loglevel);

protected:
Expand Down Expand Up @@ -171,7 +169,6 @@ class Empty1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln, int loglevel) {}
};
Expand All @@ -197,7 +194,6 @@ class Symm1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln, int loglevel) {}
};
Expand All @@ -223,7 +219,6 @@ class Outlet1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(SolutionArray& arr, double* soln, int loglevel) {}
};
Expand Down Expand Up @@ -256,9 +251,7 @@ class OutletRes1D : public Boundary1D
virtual void init();
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);
virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(const AnyMap& state, double* soln, int loglevel);
virtual void restore(SolutionArray& arr, double* soln, int loglevel);

protected:
Expand Down Expand Up @@ -290,9 +283,7 @@ class Surf1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(const AnyMap& state, double* soln, int loglevel);
virtual void restore(SolutionArray& arr, double* soln, int loglevel);

virtual void showSolution_s(std::ostream& s, const double* x);
Expand Down Expand Up @@ -328,9 +319,7 @@ class ReactingSurf1D : public Boundary1D
virtual void eval(size_t jg, double* xg, double* rg,
integer* diagg, double rdt);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(const AnyMap& state, double* soln, int loglevel);
virtual void restore(SolutionArray& arr, double* soln, int loglevel);

virtual void _getInitialSoln(double* x) {
Expand Down
13 changes: 10 additions & 3 deletions include/cantera/oneD/Domain1D.h
Expand Up @@ -313,8 +313,10 @@ class Domain1D
//! Save the state of this domain as an AnyMap
/*!
* @param soln local solution vector for this domain
*
* @deprecated To be removed after Cantera 3.0; superseded by asArray.
*/
virtual AnyMap serialize(const double* soln) const;
AnyMap serialize(const double* soln) const;

//! Save the state of this domain as a SolutionArray
/*!
Expand All @@ -323,7 +325,7 @@ class Domain1D
* @since New in Cantera 3.0.
*/
virtual shared_ptr<SolutionArray> asArray(const double* soln) const {
throw CanteraError("Domain1D::asArray", "Needs to be overloaded.");
throw NotImplementedError("Domain1D::asArray", "Needs to be overloaded.");
}

//! Restore the solution for this domain from an AnyMap
Expand All @@ -332,8 +334,10 @@ class Domain1D
* @param[out] soln Value of the solution vector, local to this domain
* @param[in] loglevel 0 to suppress all output; 1 to show warnings; 2 for
* verbose output
*
* @deprecated To be removed after Cantera 3.0; restore from SolutionArray instead.
*/
virtual void restore(const AnyMap& state, double* soln, int loglevel);
void restore(const AnyMap& state, double* soln, int loglevel);

//! Restore the solution for this domain from a SolutionArray
/*!
Expand Down Expand Up @@ -502,6 +506,9 @@ class Domain1D
//! Retrieve meta data
virtual AnyMap getMeta() const;

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

doublereal m_rdt;
size_t m_nv;
size_t m_points;
Expand Down
14 changes: 0 additions & 14 deletions include/cantera/oneD/Sim1D.h
Expand Up @@ -122,13 +122,6 @@ class Sim1D : public OneDim
void save(const std::string& fname, const std::string& id,
const std::string& desc, int loglevel=1, int compression=0);

/**
* Save the current solution to YAML (legacy implementation). @see save
* @since New in Cantera 3.0.
*/
void write_yaml(const std::string& fname, const std::string& id,
const std::string& desc, int loglevel=1);

/**
* Save the residual of the current solution to a container file.
* @param fname Name of output container file
Expand All @@ -148,13 +141,6 @@ class Sim1D : public OneDim
*/
AnyMap restore(const std::string& fname, const std::string& id, int loglevel=2);

/**
* Initialize the solution with a previously-saved solution (legacy implementation).
* @see restore
* @since New in Cantera 3.0.
*/
void read_yaml(const std::string& fname, const std::string& id, int loglevel=2);

//! @}

// @deprecated To be removed after Cantera 3.0 (unused)
Expand Down
4 changes: 1 addition & 3 deletions include/cantera/oneD/StFlow.h
Expand Up @@ -157,9 +157,7 @@ class StFlow : public Domain1D
//! Print the solution.
virtual void showSolution(const doublereal* x);

virtual AnyMap serialize(const double* soln) const;
virtual shared_ptr<SolutionArray> asArray(const double* soln) const;
virtual void restore(const AnyMap& state, double* soln, int loglevel);
virtual void restore(SolutionArray& arr, double* soln, int loglevel);

//! Set flow configuration for freely-propagating flames, using an internal
Expand Down Expand Up @@ -284,8 +282,8 @@ class StFlow : public Domain1D
}

protected:
void setMeta(const AnyMap& state);
virtual AnyMap getMeta() const;
virtual void setMeta(const AnyMap& state, int loglevel);

doublereal wdot(size_t k, size_t j) const {
return m_wdot(k,j);
Expand Down
2 changes: 0 additions & 2 deletions interfaces/cython/cantera/_onedim.pxd
Expand Up @@ -125,8 +125,6 @@ cdef extern from "cantera/oneD/Sim1D.h":
vector[double] getRefineCriteria(int) except +translate_exception
void save(string, string, string, int, int) except +translate_exception
CxxAnyMap restore(string, string, int) except +translate_exception
void write_yaml(string, string, string, int) except +translate_exception
void read_yaml(string, string, int) except +translate_exception
void writeStats(int) except +translate_exception
void clearStats()
void resize() except +translate_exception
Expand Down
21 changes: 0 additions & 21 deletions interfaces/cython/cantera/_onedim.pyx
Expand Up @@ -1484,17 +1484,6 @@ cdef class Sim1D:
self.sim.save(stringify(str(filename)), stringify(name),
stringify(description), loglevel, compression)

def write_yaml(self, filename, name='solution', description='none',
quiet=True):
"""
Save the solution in YAML format (legacy implementation)
.. versionadded:: 3.0
"""
loglevel = 1 - quiet
self.sim.write_yaml(stringify(str(filename)), stringify(name),
stringify(description), loglevel)

def restore(self, filename='soln.yaml', name='solution', loglevel=2):
"""Set the solution vector to a previously-saved solution.
Expand All @@ -1518,16 +1507,6 @@ cdef class Sim1D:
self._initialized = True
return anymap_to_dict(header)

def read_yaml(self, filename, name='solution', description='none', quiet=True):
"""
Set the solution vector to a previously-saved solution (legacy implementation)
.. versionadded:: 3.0
"""
loglevel = 2 * (1 - quiet)
self.sim.read_yaml(stringify(str(filename)), stringify(name), loglevel)
self._initialized = True

def restore_time_stepping_solution(self):
"""
Set the current solution vector to the last successful time-stepping
Expand Down

0 comments on commit 834c39b

Please sign in to comment.