ABLATE Source Documentation  0.12.34
stateVectorSoot.hpp
1 #ifndef ABLATELIBRARY_STATEVECTORSOOT_HPP
2 #define ABLATELIBRARY_STATEVECTORSOOT_HPP
3 #include "TChem_Util.hpp"
4 #include "sootConstants.hpp"
5 
6 namespace ablate::eos::tChemSoot {
7 
13 template <typename RealType1DView>
15  private:
16  const ::TChem::ordinal_type _nSpec;
17  const RealType1DView _v;
18 
19  public:
20  using real_value_type = typename RealType1DView::non_const_value_type;
21  using range_type = Kokkos::pair<::TChem::ordinal_type, ::TChem::ordinal_type>;
22 
23  KOKKOS_INLINE_FUNCTION StateVectorSoot(const ::TChem::ordinal_type nGasSpec, const RealType1DView &v) : _nSpec(nGasSpec), _v(v) {}
24 
26  KOKKOS_INLINE_FUNCTION bool isValid() const {
27  const bool is_valid_rank = (RealType1DView::Rank == 1);
28  const bool is_extent_valid = (_v.extent(0) <= (3 + _nSpec + 1 ));
29  return (is_valid_rank && is_extent_valid);
30  }
31 
33  KOKKOS_INLINE_FUNCTION ::TChem::ordinal_type size() const { return _nSpec + 3 + 1; }
34  KOKKOS_INLINE_FUNCTION void assign_data(real_value_type *ptr) { _v.assign_data(ptr); }
35 
37  KOKKOS_INLINE_FUNCTION RealType1DView KokkosView() const { return _v; }
38  KOKKOS_INLINE_FUNCTION ::TChem::ordinal_type NumGasSpecies() const { return _nSpec; }
39  KOKKOS_INLINE_FUNCTION ::TChem::ordinal_type NumSpecies() const { return _nSpec + 1; }
40 
42  KOKKOS_INLINE_FUNCTION real_value_type &Density() const { return _v(0); }
43  KOKKOS_INLINE_FUNCTION real_value_type &Pressure() const { return _v(1); }
44  KOKKOS_INLINE_FUNCTION real_value_type &Temperature() const { return _v(2); }
45  KOKKOS_INLINE_FUNCTION auto MassFractions() const -> decltype(Kokkos::subview(_v, range_type(3, 3 + _nSpec + 1))) { return Kokkos::subview(_v, range_type(3, 3 + _nSpec + 1)); }
46  KOKKOS_INLINE_FUNCTION real_value_type &MassFractionCarbon() const { return _v(3 + _nSpec); }
47  KOKKOS_INLINE_FUNCTION real_value_type &SootNumberDensity() const { return _v(3 + _nSpec + 1); }
48 
49  KOKKOS_INLINE_FUNCTION real_value_type *DensityPtr() const { return &_v(0); }
50  KOKKOS_INLINE_FUNCTION real_value_type *PressurePtr() const { return &_v(1); }
51  KOKKOS_INLINE_FUNCTION real_value_type *TemperaturePtr() const { return &_v(2); }
52  KOKKOS_INLINE_FUNCTION real_value_type *MassFractionsPtr() const { return &_v(3); }
53 
54  // Helper Function to split the total state vector into an appropriate gaseous state vector
55  // Currently assumes all species were already normalized
56  template <typename real_1d_viewType>
57  inline void SplitYiState(Impl::StateVector<real_1d_viewType> &gaseousState) const {
58  double Yc = MassFractionCarbon();
59 
60  // pressure, temperature (assumed the same in both phases)
61  gaseousState.Temperature() = Temperature();
62  gaseousState.Pressure() = Pressure();
63  auto yiGaseousState = gaseousState.MassFractions();
64  auto yi = MassFractions();
65 
66  for (auto ns = 0; ns < _nSpec; ns++) {
67  yiGaseousState(ns) = yi(ns) / (1.0 - Yc);
68  }
69  // Need to calculate the gaseous density at this state
70  gaseousState.Density() = (1 - Yc) / (1 / Density() - Yc / ablate::eos::tChemSoot::solidCarbonDensity);
71  }
72 };
73 
74 static KOKKOS_INLINE_FUNCTION ordinal_type getStateVectorSootSize(const ordinal_type nGasSpec) { return nGasSpec + 3 + 2 /*yc, ndd */; }
75 
76 } // namespace ablate::eos::tChemSoot
77 #endif // ABLATELIBRARY_STATEVECTORSOOT_HPP
Definition: densityFcn.hpp:11
Definition: pressure.hpp:10
Definition: stateVectorSoot.hpp:14
KOKKOS_INLINE_FUNCTION real_value_type & Density() const
interface to state vector
Definition: stateVectorSoot.hpp:42
KOKKOS_INLINE_FUNCTION bool isValid() const
validate input vector
Definition: stateVectorSoot.hpp:26
KOKKOS_INLINE_FUNCTION RealType1DView KokkosView() const
copy access to private members
Definition: stateVectorSoot.hpp:37
KOKKOS_INLINE_FUNCTION ::TChem::ordinal_type size() const
assign a pointer to update the vector in a batch fashion
Definition: stateVectorSoot.hpp:33