Flow123d  JS_before_hm-62-ge56f9d5
richards_lmh.hh
Go to the documentation of this file.
1 /*
2  * richards_lmh.hh
3  *
4  * Created on: Sep 16, 2015
5  * Author: jb
6  */
7 
8 #ifndef SRC_FLOW_RICHARDS_LMH_HH_
9 #define SRC_FLOW_RICHARDS_LMH_HH_
10 
11 #include <boost/exception/info.hpp> // for operator<<, error_info::error_in...
12 #include <memory> // for shared_ptr
13 #include "fields/field.hh" // for Field
14 #include "fields/field_values.hh" // for FieldValue<>::Scalar, FieldValue
15 #include "la/vector_mpi.hh" // for VectorMPI
16 #include "flow/darcy_flow_mh.hh" // for DarcyMH, DarcyMH::EqData
17 #include "flow/darcy_flow_mh_output.hh" // for DarcyFlowMHOutput
18 #include "input/type_base.hh" // for Array
19 #include "input/type_generic.hh" // for Instance
20 #include "petscvec.h" // for VecScatter, _p_VecScatter
21 
22 class Mesh;
23 class SoilModelBase;
24 namespace Input {
25  class Record;
26  namespace Type {
27  class Record;
28  }
29 }
30 
31 /**
32  * @brief Edge lumped mixed-hybrid solution of unsteady Darcy flow.
33  *
34  * The time term and sources are evenly distributed form an element to its edges.
35  * This applies directly to the second Schur complement. After this system for pressure traces is solved we reconstruct pressures and side flows as follows:
36  *
37  * -# Element pressure is average of edge pressure. This is in fact same as the MH for steady case so we let SchurComplement class do its job.
38  *
39  * -# We let SchurComplement to reconstruct fluxes and then account time term and sources which are evenly distributed from an element to its sides.
40  * It can be proved, that this keeps continuity of the fluxes over the edges.
41  *
42  * This lumping technique preserves discrete maximum principle for any time step provided one use acute mesh. But in practice even worse meshes are tractable.
43  *
44  * Ideas how to unify steady and unsteady flow:
45  * zero_time_step:
46  *
47  * -# Set initial time.
48  * -# Read initial condition. Reconstruct pressures.
49  * -# Assembly system (possibly in matrix free way).
50  * -# Reconstruct velocities (schur complement resolve).
51  * -# Solve iteratively as regular time step if an input flag "steady_initial_time" is set.
52  * -# (Detect that there is no time term. I such case use arbitrary long time step up to next change of data.
53  * Some kind of time step estimator would be nice.
54  *
55  * update solution:
56  *
57  * -# Move to the next time.
58  * -# Update fields
59  * -# Nonlinear solve.
60  * -# In case of slow convergence, use shorter time-step, within estimated limits. Otherwise there is a different problem.
61  */
62 class RichardsLMH : public DarcyMH
63 {
64 public:
65  /// Class with all fields used in the equation DarcyFlow.
66  /// This is common to all implementations since this provides interface
67  /// to this equation for possible coupling.
68  class EqData : public DarcyMH::EqData {
69  public:
70  EqData();
71  // input fields
76 
77  //output fields
78 
79  // Auxiliary assembly fields.
80  //std::unordered_map<unsigned int, unsigned int> *edge_new_local_4_mesh_idx_;
85  // source terms to be added to the side fluxes, in order to get proper (continuous) velocity field
87 
88 
89  // This is necessary in the assembly
90  // TODO: store time information in the field set and in fields, is it ok also for more complex discretization methods?
91  double time_step_;
92  std::shared_ptr<SoilModelBase> soil_model_;
93  };
94 
95  RichardsLMH(Mesh &mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
96 
97  static const Input::Type::Record & get_input_type();
98 
100  { return this->output_object->get_output_fields(); }
101 
102 protected:
103  /// Registrar of class to factory
104  static const int registrar;
105 
106  bool zero_time_term(bool time_global=false) override;
107 
108  void initialize_specific() override;
109  //void local_assembly_specific(LocalAssemblyData &local_data) override;
110  void assembly_source_term() override;
111 
112  void read_initial_condition() override;
113  void assembly_linear_system() override;
114  void setup_time_term() override;
115  void prepare_new_time_step() override;
116  void postprocess() override;
117 private:
118 
119  std::shared_ptr<EqData> data_;
120  /// PETSC scatter from the solution vector to the parallel edge vector with ghost values.
122 
123  /*
124  Vec steady_diagonal;
125  Vec steady_rhs;
126  Vec new_diagonal;
127  Vec previous_solution;
128 */
129 
130  //Vec time_term;
131 };
132 
133 
134 
135 
136 #endif /* SRC_FLOW_RICHARDS_LMH_HH_ */
Output class for darcy_flow_mh model.
Abstract linear system class.
Definition: balance.hh:37
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:83
std::shared_ptr< SoilModelBase > soil_model_
Definition: richards_lmh.hh:92
Standard quantities for output in DarcyFlowMH.
Definition: mesh.h:76
VectorMPI postprocess_side_sources
Definition: richards_lmh.hh:86
Basic time management functionality for unsteady (and steady) solvers (class Equation).
const DarcyFlowMHOutput::OutputFields & output_fields()
Definition: richards_lmh.hh:99
VectorMPI water_content_previous_time
Definition: richards_lmh.hh:83
VecScatter solution_2_edge_scatter_
PETSC scatter from the solution vector to the parallel edge vector with ghost values.
Edge lumped mixed-hybrid solution of unsteady Darcy flow.
Definition: richards_lmh.hh:62
Field< 3, FieldValue< 3 >::Scalar > water_content_saturated
Definition: richards_lmh.hh:72
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
std::shared_ptr< EqData > data_
Field< 3, FieldValue< 3 >::Scalar > genuchten_p_head_scale
Definition: richards_lmh.hh:74
Field< 3, FieldValue< 3 >::Scalar > water_content_residual
Definition: richards_lmh.hh:73
Field< 3, FieldValue< 3 >::Scalar > genuchten_n_exponent
Definition: richards_lmh.hh:75
mixed-hybrid model of linear Darcy flow, possibly unsteady.
Record type proxy class.
Definition: type_record.hh:182
static const int registrar
Registrar of class to factory.
VectorMPI water_content_previous_it
Definition: richards_lmh.hh:82
Mixed-hybrid model of linear Darcy flow, possibly unsteady.