Flow123d  release_3.0.0-968-gc87a28e79
reaction_term.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file reaction_term.hh
15  * @brief Class ReactionTerm is an abstract class representing reaction term in transport.
16  *
17  * Descending classes implements different physical models - dual porosity, sorption, decays,
18  * chemical reactions.
19  */
20 
21 #ifndef REACTION_TERM_H
22 #define REACTION_TERM_H
23 
24 #include <memory> // for shared_ptr
25 #include <string> // for string
26 #include "coupling/equation.hh" // for EquationBase
27 #include "mesh/long_idx.hh" // for LongInt
28 #include "input/input_exception.hh" // for DECLARE_INPUT_EXCEPTION, Exception
29 #include "system/exceptions.hh" // for ExcStream, operator<<, EI, TYPED...
30 #include "transport/substance.hh" // for SubstanceList
31 #include "fem/dofhandler.hh" // for DOFHandlerMultiDim
32 
33 class Distribution;
34 class Mesh;
35 class OutputTime;
36 namespace Input {
37  class Record;
38  namespace Type {
39  class Abstract;
40  }
41 }
42 
43 
45 {
46 public:
47  TYPEDEF_ERR_INFO( EI_Substance, std::string);
48  TYPEDEF_ERR_INFO( EI_Model, std::string);
49  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
50  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
51 
52  /**
53  * Static variable for definition of common input record in reaction term.
54  */
59 
60  /// Constructor.
61  /** @param init_mesh is the reference to the computational mesh
62  * @param in_rec is the input record
63  */
64  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
65 
66  /// Destructor.
67  ~ReactionTerm(void);
68 
69 
70  ///@name Setters
71  //@{
72  ///Sets the names of substances considered in transport.
74  {substances_.initialize(substances); return *this;}
75 
76  ///Sets the output stream which is given from transport class.
77  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
78  {output_stream_=ostream; return *this;}
79 
80  /// Computes a constraint for time step.
81  virtual bool evaluate_time_constraint(double &time_constraint) = 0;
82 
83  /**
84  * Sets the pointer to concentration matrix for the mobile zone,
85  * all substances and on all elements (given by transport).
86  */
87  ReactionTerm &concentration_matrix(double **concentration, Distribution *conc_distr,
88  LongIdx *el_4_loc, LongIdx *row_4_el)
89  {
90  concentration_matrix_ = concentration;
91  distribution_ = conc_distr;
92  el_4_loc_ = el_4_loc;
93  row_4_el_ = row_4_el;
94  return *this;
95  }
96  //@}
97 
98  /** @brief Output method.
99  *
100  * Some reaction models have their own data to output (sorption, dual porosity)
101  * - this is where it must be reimplemented.
102  * On the other hand, some do not have (linear reaction, pade approximant)
103  * - that is why it is not pure virtual.
104  */
105  virtual void output_data(void) override {};
106 
107  /// Disable changes in TimeGovernor by empty method.
108  void choose_next_time(void) override;
109 
110  /// Sets the pointer to DOF handler (shared through the reaction tree)
111  ReactionTerm &set_dh(std::shared_ptr<DOFHandlerMultiDim> dof_handler)
112  {
113  dof_handler_ = dof_handler;
114  return *this;
115  }
116 
117 protected:
118  /**
119  * Computation of reaction term on a single element.
120  * Inputs should be loc_el and local copies of concentrations of the element, which is then returned.
121  */
122  virtual double **compute_reaction(double **concentrations, int loc_el) =0;
123 
124  /**
125  * Pointer to two-dimensional array[species][elements] containing concentrations.
126  */
128 
129  /// Indices of elements belonging to local dofs.
131  /// Indices of rows belonging to elements.
133 
134  /// Pointer to reference to distribution of elements between processors.
136 
137  /// Names belonging to substances.
138  /**
139  * Must be same as in the transport.
140  */
142 
143  /// Pointer to a transport output stream.
144  std::shared_ptr<OutputTime> output_stream_;
145 
146  /// Pointer to DOF handler used through the reaction tree
147  std::shared_ptr<DOFHandlerMultiDim> dof_handler_;
148 
149 };
150 
151 #endif // REACTION_TERM_H
ReactionTerm::output_stream_
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
Definition: reaction_term.hh:144
ReactionTerm::output_data
virtual void output_data(void) override
Output method.
Definition: reaction_term.hh:105
ReactionTerm::it_abstract_immobile_term
static Input::Type::Abstract & it_abstract_immobile_term()
Definition: reaction_term.cc:37
ReactionTerm::ReactionTerm
ReactionTerm(Mesh &init_mesh, Input::Record in_rec)
Constructor.
Definition: reaction_term.cc:51
Input
Abstract linear system class.
Definition: balance.hh:37
SubstanceList
Definition: substance.hh:70
LongIdx
int LongIdx
Define type that represents indices of large arrays (elements, nodes, dofs etc.)
Definition: long_idx.hh:22
ReactionTerm::evaluate_time_constraint
virtual bool evaluate_time_constraint(double &time_constraint)=0
Computes a constraint for time step.
ReactionTerm::TYPEDEF_ERR_INFO
TYPEDEF_ERR_INFO(EI_Substance, std::string)
substance.hh
Classes for storing substance data.
dofhandler.hh
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
ReactionTerm::dof_handler_
std::shared_ptr< DOFHandlerMultiDim > dof_handler_
Pointer to DOF handler used through the reaction tree.
Definition: reaction_term.hh:147
SubstanceList::initialize
void initialize(const Input::Array &in_array)
Read from input array.
Definition: substance.cc:58
exceptions.hh
ReactionTerm::concentration_matrix_
double ** concentration_matrix_
Definition: reaction_term.hh:127
ReactionTerm::choose_next_time
void choose_next_time(void) override
Disable changes in TimeGovernor by empty method.
Definition: reaction_term.cc:68
Distribution
Definition: distribution.hh:50
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
ReactionTerm::it_abstract_reaction
static Input::Type::Abstract & it_abstract_reaction()
Definition: reaction_term.cc:43
ReactionTerm::el_4_loc_
LongIdx * el_4_loc_
Indices of elements belonging to local dofs.
Definition: reaction_term.hh:130
Input::Type::Abstract
Class for declaration of polymorphic Record.
Definition: type_abstract.hh:62
ReactionTerm::distribution_
Distribution * distribution_
Pointer to reference to distribution of elements between processors.
Definition: reaction_term.hh:135
OutputTime
The class for outputting data during time.
Definition: output_time.hh:50
ReactionTerm::output_stream
ReactionTerm & output_stream(std::shared_ptr< OutputTime > ostream)
Sets the output stream which is given from transport class.
Definition: reaction_term.hh:77
input_exception.hh
ReactionTerm::substances
ReactionTerm & substances(SubstanceList &substances)
Sets the names of substances considered in transport.
Definition: reaction_term.hh:73
ReactionTerm::substances_
SubstanceList substances_
Names belonging to substances.
Definition: reaction_term.hh:141
equation.hh
Abstract base class for equation clasess.
EquationBase
Definition: equation.hh:57
ReactionTerm::~ReactionTerm
~ReactionTerm(void)
Destructor.
Definition: reaction_term.cc:61
Mesh
Definition: mesh.h:80
ReactionTerm::it_abstract_term
static Input::Type::Abstract & it_abstract_term()
Definition: reaction_term.cc:25
ReactionTerm::DECLARE_INPUT_EXCEPTION
DECLARE_INPUT_EXCEPTION(ExcUnknownSubstance,<< "Unknown substance name: "<< EI_Substance::qval)
ReactionTerm::row_4_el_
LongIdx * row_4_el_
Indices of rows belonging to elements.
Definition: reaction_term.hh:132
ReactionTerm::set_dh
ReactionTerm & set_dh(std::shared_ptr< DOFHandlerMultiDim > dof_handler)
Sets the pointer to DOF handler (shared through the reaction tree)
Definition: reaction_term.hh:111
long_idx.hh
ReactionTerm::it_abstract_mobile_term
static Input::Type::Abstract & it_abstract_mobile_term()
Definition: reaction_term.cc:31
ReactionTerm
Definition: reaction_term.hh:44
ReactionTerm::concentration_matrix
ReactionTerm & concentration_matrix(double **concentration, Distribution *conc_distr, LongIdx *el_4_loc, LongIdx *row_4_el)
Definition: reaction_term.hh:87
ReactionTerm::compute_reaction
virtual double ** compute_reaction(double **concentrations, int loc_el)=0