//! @file MoleReactor.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_MOLEREACTOR_H
#define CT_MOLEREACTOR_H

#include "Reactor.h"

namespace Cantera
{

/**
 * MoleReactor is meant to serve the same purpose as the reactor class but with a state
 * vector composed of moles. It also serves as the base class for other mole reactors.
 * @since New in %Cantera 3.0
 * @ingroup reactorGroup
 */
class MoleReactor : public Reactor
{
public:
    MoleReactor() {}

    virtual std::string type() const {
        return "MoleReactor";
    }

    virtual void initialize(double t0 = 0.0);

    virtual void getState(double* y);

    virtual void updateState(double* y);

    virtual void eval(double t, double* LHS, double* RHS);

    size_t componentIndex(const std::string& nm) const;

    std::string componentName(size_t k);

protected:
    //! For each surface in the reactor, update vector of triplets with all relevant
    //! surface jacobian derivatives of species with respect to species
    //! which are appropriately offset to align with the reactor's state vector.
    virtual void addSurfaceJacobian(vector<Eigen::Triplet<double>> &triplets);

    //! Get moles of the system from mass fractions stored by thermo object
    //! @param y vector for moles to be put into
    virtual void getMoles(double* y);

    //! Set internal mass variable based on moles given
    //! @param y vector of moles of the system
    virtual void setMassFromMoles(double* y);

    virtual void evalSurfaces(double* LHS, double* RHS, double* sdot);

    virtual void updateSurfaceState(double* y);

    virtual void getSurfaceInitialConditions(double* y);

    //! const value for the species start index
    const size_t m_sidx = 2;
};

}

#endif
