Plugins
richards_elem_disc.h
Go to the documentation of this file.
1 #/*
2  * richards_equation.h
3  *
4  * Created on: 28.01.2020
5  * Author: anaegel
6  */
7 
8 
9 #ifndef RICHARDSEQPLUGIN_RICHARDS_EQUATION_H_
10 #define RICHARDSEQPLUGIN_RICHARDS_EQUATION_H_
11 
12 // UG4 lib
16 #include "lib_disc/io/vtkoutput.h"
17 
18 // Plugins
19 #include "../ConvectionDiffusion/convection_diffusion_base.h"
20 #include "../ConvectionDiffusion/fv1/convection_diffusion_fv1.h"
21 
22 namespace ug{
23 namespace Richards {
24 
25 
26 template <typename TDomain>
28 {
29 public:
30  static const int dim = TDomain::dim;
32 
35 
38 
40  RichardsElemDisc (const char *functions, const char* subsets)
41  : base_type(functions, subsets), m_spTotalConductivity(SPNULL)
42  {
43  // m_exDarcyVel = make_sp(new DataExport<MathVector<dim>, dim>(functions));
44  // m_exStorage = make_sp(new DataExport<number, dim>(functions));
45  }
46 
47 
51  m_spStorage = storage;
52  this->set_mass(m_spStorage);
53  this->set_mass_scale(0.0);
54  }
55 
56 
60  {
61  m_spFlux = myFlux;
62  this->set_flux(myFlux);
63  this->set_diffusion(0.0);
64  }
65 
69  {
70  m_spTotalConductivity = myCond;
71  }
72 
73 
74 protected:
77 
80 
83 
84 };
85 
86 template <typename TDomain>
88 {
89  typedef UserData<number, TDomain::dim> TUserDataNumber;
90  typedef UserData<MathVector<TDomain::dim>, TDomain::dim> TUserDataVector;
91 
92  spVtk->select_element(spElemDisc->get_flux_data().template cast_static<TUserDataVector> (), std::string("flux").append(myTag).c_str());
93  spVtk->select_element(spElemDisc->get_storage_data().template cast_static<TUserDataNumber> (), std::string("saturation").append(myTag).c_str());
94 };
95 
96 
97 
99 template <typename TDomain>
101 {
102 public:
103  static const int dim = TDomain::dim;
107 
112 
115 
118  m_functions("h"), m_dGravity(-1.0)
119  {}
120 
122 
129  {
131  SmartPtr<TRichards> base = make_sp<TRichards> (new TRichards(m_functions.c_str(), subsets));
132 
133  // Saturation and conductivity are functions of capillary head.
134  SmartPtr<TScaleAddLinkerNumber> myCapHead = make_sp<TScaleAddLinkerNumber> (new TScaleAddLinkerNumber());
135  myCapHead->add(-1.0, base->value());
136 
137  m_spSaturation->set_capillary(myCapHead);
138  m_spRelConductivity->set_capillary(myCapHead);
139 
140  // Gravity (= \nabla z).
141  SmartPtr<TConstUserVector> myGravity = make_sp<TConstUserVector> (new TConstUserVector(0.0));
142  myGravity->set_entry(dim-1, -m_dGravity);
143 
144  // Conductivity C=Cabs*Crel.
145  SmartPtr<TNumberData> spTotalConductivity;
146  SmartPtr<TNumberData> spRelConductivity = m_spRelConductivity.template cast_dynamic<TNumberData> ();
147  if (m_spAbsConductivity.valid())
148  {
149  auto spLinker = make_sp<TScaleAddLinkerNumber> (new TScaleAddLinkerNumber());
150  spLinker->add(m_spAbsConductivity, spRelConductivity);
151  spTotalConductivity = spLinker;
152 
153  } else
154  {
155  spTotalConductivity = m_spRelConductivity.template cast_dynamic<typename TRichards::TNumberData> ();
156  }
157  base->set_conductivity_data(spTotalConductivity);
158 
159 
160  // Flux C*\grad (h + z).
161  SmartPtr<TScaleAddLinkerVector> myFlux = make_sp<TScaleAddLinkerVector> (new TScaleAddLinkerVector());
162  myFlux->add(spTotalConductivity, base->gradient());
163  myFlux->add(spTotalConductivity, myGravity);
164 
165  SmartPtr<TScaleAddLinkerVector> myFlux2 = make_sp<TScaleAddLinkerVector> (new TScaleAddLinkerVector());
166  myFlux2->add(-1.0, myFlux);
167 
168  base->set_flux_data(myFlux2);
169  base->set_storage_data(m_spSaturation.template cast_dynamic<typename TRichards::TNumberData> ());
170  UG_ASSERT(m_spSaturation.template cast_dynamic<typename TRichards::TNumberData> ().valid(),
171  "Error: Failed to interprete saturation as number data!")
172 
173 
174  return base;
175  }
176 
177  // Classic Richards.
180  //typedef typename RichardsConductivity<dim>::richards_base_type TConductivity;
181 
184 
185  // Extensions.
187 
188  void set_function(const char * functions) { m_functions = functions; }
189  void set_gravity(number g) { m_dGravity = g; }
190 
191  const char* get_disc_type() {return "fv1";}
192 
193 protected:
196 
198 
199  std::string m_functions;
201 };
202 
203 }
204 }
205 #endif /* RICHARDSEQPLUGIN_RICHARDS_EQUATION_H_ */
void set_diffusion(SmartPtr< CplUserData< MathMatrix< dim, dim >, dim > > user)
sets the diffusion tensor
Definition: convection_diffusion_base.cpp:51
void set_mass_scale(SmartPtr< CplUserData< number, dim > > user)
sets mass scale
Definition: convection_diffusion_base.cpp:364
void set_flux(SmartPtr< CplUserData< MathVector< dim >, dim > > user)
sets the flux
Definition: convection_diffusion_base.cpp:116
void set_mass(SmartPtr< CplUserData< number, dim > > user)
sets mass
Definition: convection_diffusion_base.cpp:396
FV Discretization for the Convection-Diffusion Equation.
Definition: convection_diffusion_fv1.h:61
! Factory for creating elem discs.
Definition: richards_elem_disc.h:101
static const int dim
Definition: richards_elem_disc.h:103
void set_conductivity(SmartPtr< TConductivity > data)
Definition: richards_elem_disc.h:183
CplUserData< MathVector< dim >, dim > TVectorData
Definition: richards_elem_disc.h:113
IRichardsLinker< dim > TSaturation
Definition: richards_elem_disc.h:178
RichardsElemDiscFactory()
Definition: richards_elem_disc.h:116
number m_dGravity
Definition: richards_elem_disc.h:200
void set_abs_conductivity(SmartPtr< TNumberData > data)
Definition: richards_elem_disc.h:186
SmartPtr< TRichards > create_richards(const char *subsets)
Create classic Richards equation.
Definition: richards_elem_disc.h:128
IElemDisc< TDomain > TElemDisc
Definition: richards_elem_disc.h:104
SmartPtr< TNumberData > m_spAbsConductivity
Definition: richards_elem_disc.h:197
void set_function(const char *functions)
Definition: richards_elem_disc.h:188
void set_saturation(SmartPtr< TSaturation > data)
Definition: richards_elem_disc.h:182
ug::ConvectionDiffusionPlugin::ConvectionDiffusionFV1< TDomain > TConvDiff
Definition: richards_elem_disc.h:105
CplUserData< number, dim > TNumberData
Definition: richards_elem_disc.h:114
IRichardsLinker< dim > TConductivity
Definition: richards_elem_disc.h:179
ConstUserNumber< dim > TConstUserNumber
Definition: richards_elem_disc.h:109
SmartPtr< TConductivity > m_spRelConductivity
Definition: richards_elem_disc.h:195
void set_gravity(number g)
Definition: richards_elem_disc.h:189
ScaleAddLinker< number, dim, number > TScaleAddLinkerNumber
Definition: richards_elem_disc.h:111
ConstUserVector< dim > TConstUserVector
Definition: richards_elem_disc.h:108
std::string m_functions
Definition: richards_elem_disc.h:199
const char * get_disc_type()
Definition: richards_elem_disc.h:191
ScaleAddLinker< MathVector< dim >, dim, number > TScaleAddLinkerVector
Definition: richards_elem_disc.h:110
RichardsElemDisc< TDomain > TRichards
Definition: richards_elem_disc.h:106
SmartPtr< TSaturation > m_spSaturation
Definition: richards_elem_disc.h:194
Definition: richards_elem_disc.h:28
SmartPtr< TNumberData > m_spStorage
Export for the brine mass fraction.
Definition: richards_elem_disc.h:79
RichardsElemDisc(const char *functions, const char *subsets)
CTOR.
Definition: richards_elem_disc.h:40
SmartPtr< TNumberData > get_storage_data()
the export of storage terms
Definition: richards_elem_disc.h:49
SmartPtr< TNumberData > m_spTotalConductivity
Export for absolute conductivity.
Definition: richards_elem_disc.h:82
SmartPtr< TNumberData > get_conductivity_data()
conductivity
Definition: richards_elem_disc.h:67
SmartPtr< TVectorData > m_spFlux
Export for the Darcy velocity.
Definition: richards_elem_disc.h:76
static const int dim
Definition: richards_elem_disc.h:30
void set_flux_data(SmartPtr< TVectorData > myFlux)
Definition: richards_elem_disc.h:59
void set_storage_data(SmartPtr< TNumberData > storage)
Definition: richards_elem_disc.h:50
void set_conductivity_data(SmartPtr< TNumberData > myCond)
Definition: richards_elem_disc.h:68
ug::ConvectionDiffusionPlugin::ConvectionDiffusionFV1< TDomain > base_type
Definition: richards_elem_disc.h:31
SmartPtr< CplUserData< MathVector< dim >, dim > > VectorExport
Definition: richards_elem_disc.h:37
CplUserData< number, dim > TNumberData
Definition: richards_elem_disc.h:33
SmartPtr< CplUserData< number, dim > > NumberExport
Definition: richards_elem_disc.h:36
SmartPtr< TVectorData > get_flux_data()
returns the export of the darcy velocity
Definition: richards_elem_disc.h:58
CplUserData< MathVector< dim >, dim > TVectorData
Definition: richards_elem_disc.h:34
static const int dim
const NullSmartPtr SPNULL
#define UG_ASSERT(expr, msg)
double number
void SelectVTKData(SmartPtr< VTKOutput< TDomain::dim > > spVtk, SmartPtr< RichardsElemDisc< TDomain > > spElemDisc, const char *myTag)
Definition: richards_elem_disc.h:87
This is a 'dummy' base class. It indicates a pressure dependent linker.
Definition: richards_linker.h:82