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 "GeochemicalModelDefinition.h" 13 : #include "GeochemicalSystem.h" 14 : #include "NodalUserObject.h" 15 : 16 : /** 17 : * Base class that controls the spatio-temporal solution of geochemistry reactions 18 : */ 19 : class GeochemistryReactorBase : public NodalUserObject 20 : { 21 : public: 22 : /// contains params that are shared with AddGeochemistrySolverAction and its children 23 : static InputParameters sharedParams(); 24 : 25 : static InputParameters validParams(); 26 : GeochemistryReactorBase(const InputParameters & parameters); 27 0 : virtual void initialize() override {} 28 1476 : virtual void threadJoin(const UserObject & /*uo*/) override {} 29 0 : virtual void finalize() override {} 30 0 : virtual void execute() override {} 31 : 32 : /** 33 : * @return a reference to the equilibrium geochemical system at the given node 34 : * @param node_id the ID of the node 35 : */ 36 : virtual const GeochemicalSystem & getGeochemicalSystem(dof_id_type node_id) const = 0; 37 : 38 : /** 39 : * @return a reference to the most recent solver output (containing iteration info, swap info, 40 : * residuals, etc) at the specified node_id 41 : * @param node_id the node ID 42 : */ 43 : virtual const std::stringstream & getSolverOutput(dof_id_type node_id) const = 0; 44 : 45 : /** 46 : * @return the total number of iterations used by the most recent solve at the specified node_id 47 : * @param node_id the node ID 48 : */ 49 : virtual unsigned getSolverIterations(dof_id_type node_id) const = 0; 50 : 51 : /** 52 : * @return the L1norm of the residual at the end of the most recent solve at the specified node_id 53 : * @param node_id the node ID 54 : */ 55 : virtual Real getSolverResidual(dof_id_type node_id) const = 0; 56 : 57 : /** 58 : * @return the mole additions (the first num_basis of these are additions to the bulk composition 59 : * of the equilibrium system, the last num_kin of these are -dt*kinetic_reaction_rate, ie 60 : * dt*dissolution_rate) at the specified node_id 61 : * @param node_id the node ID 62 : */ 63 : virtual const DenseVector<Real> & getMoleAdditions(dof_id_type node_id) const = 0; 64 : 65 : /** 66 : * @return the moles dumped of the given species at the specified node_id 67 : * @param species the name of the species 68 : * @param node_id the node ID 69 : */ 70 : virtual Real getMolesDumped(dof_id_type node_id, const std::string & species) const = 0; 71 : 72 : /// returns a reference to the PertinentGeochemicalSystem used to creat the ModelGeochemicalDatabase 73 764619 : const PertinentGeochemicalSystem & getPertinentGeochemicalSystem() const { return _pgs; }; 74 : 75 : protected: 76 : /// Number of nodes handled by this processor (will need to be made un-const when mesh adaptivity is handled) 77 : const unsigned _num_my_nodes; 78 : /// my copy of the underlying ModelGeochemicalDatabase 79 : ModelGeochemicalDatabase _mgd; 80 : /// Reference to the original PertinentGeochemicalSystem used to create the ModelGeochemicalDatabase 81 : const PertinentGeochemicalSystem & _pgs; 82 : /// number of basis species 83 : const unsigned _num_basis; 84 : /// number of equilibrium species 85 : const unsigned _num_eqm; 86 : /// Initial value of maximum ionic strength 87 : const Real _initial_max_ionic_str; 88 : /// The ionic strength calculator 89 : GeochemistryIonicStrength _is; 90 : /// The activity calculator 91 : GeochemistryActivityCoefficientsDebyeHuckel _gac; 92 : /// Maximum number of swaps allowed during a single solve 93 : const unsigned _max_swaps_allowed; 94 : /// The species swapper 95 : GeochemistrySpeciesSwapper _swapper; 96 : /// A small value of molality 97 : const Real _small_molality; 98 : /// The solver output at each node 99 : std::vector<std::stringstream> _solver_output; 100 : /// Number of iterations used by the solver at each node 101 : std::vector<unsigned> _tot_iter; 102 : /// L1norm of the solver residual at each node 103 : std::vector<Real> _abs_residual; 104 : };