Flow123d  master-7cbe9e2
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 "system/index_types.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 #include "fields/field_fe.hh" // for FieldFE
33 #include "fields/field_set.hh" // for FieldSet
34 
35 class Distribution;
36 class Mesh;
37 class OutputTime;
38 namespace Input {
39  class Record;
40  namespace Type {
41  class Abstract;
42  }
43 }
44 
45 
47 {
48 public:
49  TYPEDEF_ERR_INFO( EI_Substance, std::string);
50  TYPEDEF_ERR_INFO( EI_Model, std::string);
51  DECLARE_INPUT_EXCEPTION( ExcUnknownSubstance, << "Unknown substance name: " << EI_Substance::qval);
52  DECLARE_INPUT_EXCEPTION( ExcWrongDescendantModel, << "Impossible descendant model: " << EI_Model::qval);
53 
55 
56  /**
57  * Static variable for definition of common input record in reaction term.
58  */
63 
64  /// Reaction data
65  class EqFields : public FieldSet
66  {
67  public:
68  /// Constructor
70  {}
71 
72  /// FieldFEs representing P0 interpolation of mobile concentration (passed from transport).
74  };
75 
76  /// Reaction data
77  class EqData
78  {
79  public:
80  /// Constructor
81  EqData();
82 
83  /**
84  * Names belonging to substances.
85  *
86  * Must be same as in the transport.
87  */
89 
90  /// Pointer to DOF handler used through the reaction tree
91  std::shared_ptr<DOFHandlerMultiDim> dof_handler_;
92  };
93 
94  /**
95  * Constructor.
96  *
97  * @param init_mesh is the reference to the computational mesh
98  * @param in_rec is the input record
99  */
100  ReactionTerm(Mesh &init_mesh, Input::Record in_rec);
101 
102  /// Destructor.
103  ~ReactionTerm(void);
104 
105 
106  ///@name Setters
107  //@{
108  ///Sets the names of substances considered in transport.
110  {eq_data_base_->substances_.initialize(substances); return *this;}
111 
112  ///Sets the output stream which is given from transport class.
113  ReactionTerm &output_stream(std::shared_ptr<OutputTime> ostream)
114  {output_stream_=ostream; return *this;}
115 
116  /**
117  * Sets the pointer to concentration matrix for the mobile zone,
118  * all substances and on all elements (given by transport).
119  */
121  {
123  eq_fields_base_->conc_mobile_fe = conc_mobile;
124  eq_data_base_->dof_handler_ = eq_fields_base_->conc_mobile_fe[0]->get_dofhandler();
125  return *this;
126  }
127  //@}
128 
129  /** @brief Output method.
130  *
131  * Some reaction models have their own data to output (sorption, dual porosity)
132  * - this is where it must be reimplemented.
133  * On the other hand, some do not have (linear reaction, pade approximant)
134  * - that is why it is not pure virtual.
135  */
136  virtual void output_data(void) override {};
137 
138  /// Disable changes in TimeGovernor by empty method.
139  void choose_next_time(void) override;
140 
141 protected:
142  /// Compute reaction on a single element.
143  virtual void compute_reaction(const DHCellAccessor& dh_cell) = 0;
144 
145  /// Pointer to a transport output stream.
146  std::shared_ptr<OutputTime> output_stream_;
147 
148  /// Equation data - all fields needs in assembly class.
149  std::shared_ptr<EqFields> eq_fields_base_;
150 
151  /// Equation data - all data needs in assembly class.
152  std::shared_ptr<EqData> eq_data_base_;
153 };
154 
155 #endif // REACTION_TERM_H
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
Definition: asserts.hh:341
Cell accessor allow iterate over DOF handler cells.
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
Class for declaration of polymorphic Record.
Definition: mesh.h:362
The class for outputting data during time.
Definition: output_time.hh:51
Reaction data.
std::shared_ptr< DOFHandlerMultiDim > dof_handler_
Pointer to DOF handler used through the reaction tree.
SubstanceList substances_
EqData()
Constructor.
FieldFEScalarVec conc_mobile_fe
FieldFEs representing P0 interpolation of mobile concentration (passed from transport).
EqFields()
Constructor.
std::shared_ptr< OutputTime > output_stream_
Pointer to a transport output stream.
static Input::Type::Abstract & it_abstract_immobile_term()
~ReactionTerm(void)
Destructor.
virtual void compute_reaction(const DHCellAccessor &dh_cell)=0
Compute reaction on a single element.
TYPEDEF_ERR_INFO(EI_Model, std::string)
std::shared_ptr< EqFields > eq_fields_base_
Equation data - all fields needs in assembly class.
TYPEDEF_ERR_INFO(EI_Substance, std::string)
std::shared_ptr< EqData > eq_data_base_
Equation data - all data needs in assembly class.
virtual void output_data(void) override
Output method.
static Input::Type::Abstract & it_abstract_term()
ReactionTerm & output_stream(std::shared_ptr< OutputTime > ostream)
Sets the output stream which is given from transport class.
ReactionTerm & substances(SubstanceList &substances)
Sets the names of substances considered in transport.
ReactionTerm & concentration_fields(FieldFEScalarVec &conc_mobile)
DECLARE_INPUT_EXCEPTION(ExcWrongDescendantModel,<< "Impossible descendant model: "<< EI_Model::qval)
void choose_next_time(void) override
Disable changes in TimeGovernor by empty method.
static Input::Type::Abstract & it_abstract_reaction()
static Input::Type::Abstract & it_abstract_mobile_term()
DECLARE_INPUT_EXCEPTION(ExcUnknownSubstance,<< "Unknown substance name: "<< EI_Substance::qval)
std::vector< std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > > FieldFEScalarVec
ReactionTerm(Mesh &init_mesh, Input::Record in_rec)
Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between loca...
Abstract base class for equation clasess.
Abstract linear system class.
Definition: balance.hh:40
Classes for storing substance data.