www.mooseframework.org
VaporMixtureFluidProperties.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #pragma once
11 
12 #include "FluidProperties.h"
20 #define propfuncAD(want, prop1, prop2) \
21  virtual DualReal want##_from_##prop1##_##prop2( \
22  const DualReal & p1, const DualReal & p2, const std::vector<DualReal> & x) const \
23  { \
24  Real p1_raw = p1.value(); \
25  Real p2_raw = p2.value(); \
26  std::vector<Real> x_raw(x.size(), 0); \
27  for (unsigned int i = 0; i < x.size(); ++i) \
28  x_raw[i] = x[i].value(); \
29  \
30  Real y_raw = 0; \
31  Real dy_dp1 = 0; \
32  Real dy_dp2 = 0; \
33  std::vector<Real> dy_dx(x.size(), 0); \
34  want##_from_##prop1##_##prop2(p1_raw, p2_raw, x_raw, y_raw, dy_dp1, dy_dp2, dy_dx); \
35  \
36  DualReal result = y_raw; \
37  result.derivatives() = p1.derivatives() * dy_dp1 + p2.derivatives() * dy_dp2; \
38  for (unsigned int i = 0; i < x.size(); ++i) \
39  result.derivatives() += x[i].derivatives() * dy_dx[i]; \
40  return result; \
41  } \
42  \
43  virtual void want##_from_##prop1##_##prop2(const DualReal & prop1, \
44  const DualReal & prop2, \
45  std::vector<DualReal> & x, \
46  DualReal & val, \
47  DualReal & d##want##d1, \
48  DualReal & d##want##d2, \
49  std::vector<DualReal> & d##want##dx) const \
50  { \
51  fluidPropError( \
52  name(), ": ", __PRETTY_FUNCTION__, " derivative derivatives not implemented."); \
53  Real dummy, tmp1, tmp2; \
54  std::vector<Real> x_raw(x.size(), 0); \
55  std::vector<Real> tmp3(x.size(), 0); \
56  for (unsigned int i = 0; i < x.size(); ++i) \
57  x_raw[i] = x[i].value(); \
58  val = want##_from_##prop1##_##prop2(prop1, prop2, x); \
59  want##_from_##prop1##_##prop2(prop1.value(), prop2.value(), x_raw, dummy, tmp1, tmp2, tmp3); \
60  d##want##d1 = tmp1; \
61  d##want##d2 = tmp2; \
62  for (unsigned int i = 0; i < x.size(); ++i) \
63  d##want##dx[i] = tmp3[i]; \
64  }
65 
70 #define propfunc(want, prop1, prop2) \
71  virtual Real want##_from_##prop1##_##prop2(Real, Real, const std::vector<Real> &) const \
72  { \
73  mooseError(name(), ": ", __PRETTY_FUNCTION__, " not implemented."); \
74  } \
75  \
76  virtual void want##_from_##prop1##_##prop2(Real prop1, \
77  Real prop2, \
78  const std::vector<Real> & x, \
79  Real & val, \
80  Real & d##want##d1, \
81  Real & d##want##d2, \
82  std::vector<Real> & d##want##dx) const \
83  { \
84  fluidPropError(name(), ": ", __PRETTY_FUNCTION__, " derivatives not implemented."); \
85  d##want##d1 = 0; \
86  d##want##d2 = 0; \
87  std::fill(d##want##dx.begin(), d##want##dx.end(), 0.); \
88  val = want##_from_##prop1##_##prop2(prop1, prop2, x); \
89  } \
90  \
91  propfuncAD(want, prop1, prop2)
92 
102 {
103 public:
104  static InputParameters validParams();
105 
108 
109 #pragma GCC diagnostic push
110 #pragma GCC diagnostic ignored "-Woverloaded-virtual"
111  // clang-format off
112 
114  propfunc(p, v, e)
115  propfunc(T, v, e)
116  propfunc(c, v, e)
117  propfunc(rho, p, T)
118  propfunc(e, p, T)
119  propfunc(c, p, T)
120  propfunc(cp, p, T)
121  propfunc(cv, p, T)
122  propfunc(mu, p, T)
123  propfunc(k, p, T)
124  propfunc(e, p, rho)
126 
127  // clang-format on
128 
129 #undef propfunc
130 #undef propfuncAD
131 
135  virtual unsigned int getNumberOfSecondaryVapors() const = 0;
136 
148  Real primaryMassFraction(const std::vector<Real> & x) const;
149 
150 private:
151  template <typename... Args>
152  void fluidPropError(Args... args) const
153  {
155  mooseDoOnce(mooseWarning(std::forward<Args>(args)...));
156  else
157  mooseError(std::forward<Args>(args)...);
158  }
159 };
160 
161 #pragma GCC diagnostic pop
Base class for fluid properties of vapor mixtures.
static const std::string cv
Definition: NS.h:121
const bool _allow_imperfect_jacobians
Flag to set unimplemented Jacobian entries to zero.
VaporMixtureFluidProperties(const InputParameters &parameters)
void fluidPropError(Args... args) const
void mooseWarning(Args &&... args) const
static const std::string cp
Definition: NS.h:120
const std::vector< double > x
static InputParameters validParams()
static const std::string mu
Definition: NS.h:122
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real primaryMassFraction(const std::vector< Real > &x) const
Computes the mass fraction of the primary vapor given mass fractions of the secondary vapors...
void mooseError(Args &&... args) const
const InputParameters & parameters() const
static const std::string k
Definition: NS.h:124