www.mooseframework.org
TotalConcentrationAux.C
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 #include "TotalConcentrationAux.h"
11 
12 registerMooseObject("ChemicalReactionsApp", TotalConcentrationAux);
13 
16 {
18  params.addCoupledVar("primary_species", "Primary species free concentration");
19  params.addParam<std::vector<Real>>(
20  "sto_v",
21  {},
22  "The stoichiometric coefficient of primary species in secondary equilibrium species");
23  params.addCoupledVar("v",
24  "Secondary equilibrium species in which the primary species is involved");
25  params.addClassDescription("Total concentration of primary species (including stoichiometric "
26  "contribution to secondary equilibrium species)");
27  return params;
28 }
29 
31  : AuxKernel(parameters),
32  _primary_species(coupledValue("primary_species")),
33  _sto_v(getParam<std::vector<Real>>("sto_v")),
34  _secondary_species(coupledValues("v"))
35 {
36  // Check that the correct number of stoichiometric coefficients have been included
37  if (_sto_v.size() != coupledComponents("v"))
38  mooseError("The number of stoichiometric coefficients and coupled species must be equal in ",
39  _name);
40 }
41 
42 Real
44 {
45  Real total_concentration = _primary_species[_qp];
46 
47  for (unsigned int i = 0; i < _secondary_species.size(); ++i)
48  total_concentration += _sto_v[i] * (*_secondary_species[i])[_qp];
49 
50  return total_concentration;
51 }
Computes the total concentration of given primary species, including its free concentration and its s...
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
static InputParameters validParams()
registerMooseObject("ChemicalReactionsApp", TotalConcentrationAux)
const VariableValue & _primary_species
Primary species that this AuxKernel acts on.
TotalConcentrationAux(const InputParameters &parameters)
const std::vector< Real > _sto_v
Stoichiometric coefficients for primary species in coupled secondary species.
const std::string _name
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int coupledComponents(const std::string &var_name) const
virtual Real computeValue() override
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void mooseError(Args &&... args) const
void addClassDescription(const std::string &doc_string)
static InputParameters validParams()
const std::vector< const VariableValue * > _secondary_species
Coupled secondary species concentration.