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