libantioch / antioch

C++ Chemical Kinetics, Thermodynaimics, and Transport Library
https://libantioch.github.io/
Other
22 stars 17 forks source link

VectorCoeffType definition #137

Open SylvainPlessis opened 9 years ago

SylvainPlessis commented 9 years ago

I'm putting this here to be sure I won't forget it.

The VectorCoeffType type is required for photochemistry. It is defined in _read_reaction_setdata.h at line 430. The type of the data defined at that line is the VectorCoeffType and is std::vector<CoeffType>, using the CoeffType denomination.

The chain of template inheritance is:

KineticsType<CoeffType,VectorCoeffType = std::vector<CoeffType> > ----> Reaction<CoeffType, VectorCoeffType = std::vector<CoeffType> > --////--> ReactionSet<CoeffType> --////--> KineticsEvaluator<CoeffType,StateType>

VectorCoeffType custom definition stops at ReactionSet<CoeffType> as it contains a std::vector<Reaction<CoeffType>*>.

So we need to finish the template inheritance with ReactionSet and KineticsEvaluator. One consequence will be that _read_reaction_setdata will require to be templated around VectorCoeffType too.

Once the template inheritance chain is done, VectorCoeffType will be defined by the declaration of ReactionSet and KineticsEvaluator, and the world will be a better place.

SylvainPlessis commented 9 years ago

The default problem:

when building/resetting kinetics rate constant:

method_name(KineticsType<CoeffType,VectorCoeffType> & rate, other stuff)
{
  switch(rate.type())
  {
 ...
    static_cast<HercourtEssenRate<CoeffType>*>(&rate)->do_something;
 ...
    static_cast<PhotochemicalRate<CoeffType,VectorCoeffType>*>(&rate)->do_something;
  }
}

VectorCoeffType is always std::vector<CoeffType>, so it never arose that a default declaration of VectorCoeffType implies it cannot be otherwise:

KineticsType<CoeffType,VectorCoeffType> in the Hercourt-Essen static cast is necessarily a KineticsType<CoeffType,DefaultVectorType> whereas, if passing a photochemical rate, we have in the argument a KineticsType<CoeffType,CustomVectorType>. It can't work if Custom =/ Default.

Basically, either we move the VectorCoeffType up to the other kinetics model, or we totally separate the particle flux reaction rates. The second choice seems more appropriate. We derive from KineticsType<CoeffType> a FluxKineticsType<CoeffType,VectorCoeffType> and we overload all the necessary methods.