Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 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 "GeneralUserObject.h" 13 : #include "PorousFlowCapillaryPressure.h" 14 : 15 : /// Phase state enum 16 : enum class FluidStatePhaseEnum 17 : { 18 : LIQUID, 19 : GAS, 20 : TWOPHASE 21 : }; 22 : 23 : /// AD data structure to pass calculated thermophysical properties 24 396100 : struct FluidStateProperties 25 : { 26 838 : FluidStateProperties(){}; 27 132604 : FluidStateProperties(unsigned int n) 28 132604 : : pressure(0.0), 29 132604 : temperature(0, 0), 30 132604 : saturation(0.0), 31 132604 : density(0.0), 32 132604 : viscosity(1.0), // to guard against division by zero 33 132604 : enthalpy(0.0), 34 132604 : internal_energy(0.0), 35 132604 : mass_fraction(n, 0.0){}; 36 : 37 : ADReal pressure; 38 : ADReal temperature; 39 : ADReal saturation; 40 : ADReal density; 41 : ADReal viscosity; 42 : ADReal enthalpy; 43 : ADReal internal_energy; 44 : std::vector<ADReal> mass_fraction; 45 : }; 46 : 47 : /** 48 : * Base class for fluid states for miscible multiphase flow in porous media. 49 : */ 50 : class PorousFlowFluidStateBase : public GeneralUserObject 51 : { 52 : public: 53 : static InputParameters validParams(); 54 : 55 : PorousFlowFluidStateBase(const InputParameters & parameters); 56 : 57 1748 : void initialize() final{}; 58 1748 : void execute() final{}; 59 1748 : void finalize() final{}; 60 : 61 : /** 62 : * The maximum number of phases in this model 63 : * @return number of phases 64 : */ 65 4771 : unsigned int numPhases() const { return _num_phases; }; 66 : 67 : /** 68 : * The maximum number of components in this model 69 : * @return number of components 70 : */ 71 6 : unsigned int numComponents() const { return _num_components; }; 72 : 73 : /** 74 : * The index of the aqueous phase 75 : * @return aqueous phase number 76 : */ 77 4771 : unsigned int aqueousPhaseIndex() const { return _aqueous_phase_number; }; 78 : 79 : /** 80 : * The index of the gas phase 81 : * @return gas phase number 82 : */ 83 4771 : unsigned int gasPhaseIndex() const { return _gas_phase_number; }; 84 : 85 : /** 86 : * Name of FluidState 87 : */ 88 : virtual std::string fluidStateName() const = 0; 89 : 90 : /** 91 : * Clears the contents of the FluidStateProperties data structure 92 : * @param[out] fsp FluidStateProperties data structure with all data initialized to 0 93 : */ 94 : void clearFluidStateProperties(std::vector<FluidStateProperties> & fsp) const; 95 : 96 : protected: 97 : /// Number of phases 98 : unsigned int _num_phases; 99 : /// Number of components 100 : unsigned int _num_components; 101 : /// Phase number of the aqueous phase 102 : const unsigned int _aqueous_phase_number; 103 : /// Phase number of the gas phase 104 : unsigned int _gas_phase_number; 105 : /// Universal gas constant (J/mol/K) 106 : const Real _R; 107 : /// Conversion from C to K 108 : const Real _T_c2k; 109 : /// Capillary pressure UserObject 110 : const PorousFlowCapillaryPressure & _pc; 111 : /// Empty FluidStateProperties object 112 : FluidStateProperties _empty_fsp; 113 : };