Flow123d  jenkins-Flow123d-windows32-release-multijob-51
field_add_potential.hh
Go to the documentation of this file.
1 /*
2  * field_add_potential.hh
3  *
4  * Created on: Jan 19, 2013
5  * Author: jb
6  */
7 
8 #ifndef FIELD_ADD_POTENTIAL_HH_
9 #define FIELD_ADD_POTENTIAL_HH_
10 
11 #include <armadillo>
12 #include <memory>
13 
14 
15 /**
16  * This field is meant to be used to implement two possibilities for initialization of pressure fields in
17  * Darcy flows. You can either use pressure of piezo-metric head which are related by adding gravity potential.
18  * For various reasons we use pressure as the primary variable, so if the user enters piezo-head we need to add the potential to
19  * the field he/she has provided. This is done by this class. Unfortunately it introduce one more level of indirection,
20  * namely one more virtual call for getting the field value.
21  *
22  * - The field can not be initialized form the input.
23  * - We allow only Scalar Value with element_type double.
24  */
25 template <int spacedim, class Value>
26 class FieldAddPotential : public FieldAlgorithmBase<spacedim, Value> {
27 public:
28  typedef typename Space<spacedim>::Point Point;
29  /**
30  *
31  */
32  FieldAddPotential( const arma::vec::fixed<spacedim+1> &potential_grad, const Input::AbstractRecord &rec, unsigned int n_comp=0);
33 
34  /**
35  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
36  */
37  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
38 
39  /**
40  * Returns std::vector of scalar values in several points at once.
41  */
42  virtual void value_list (const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
44 
45 
46  /**
47  * Update time and possibly update data.
48  */
49  virtual bool set_time(double time);
50 
51 
52  virtual ~FieldAddPotential();
53 
54 private:
55  /// Field to which we add linear potential.
56  std::shared_ptr< FieldAlgorithmBase<spacedim, Value> > inner_field_;
57  /// Potential gradient.
58  arma::vec::fixed<spacedim> grad_;
59  /// Potential constant term.
60  double zero_level_;
61 };
62 
63 
64 #endif /* FIELD_ADD_POTENTIAL_HH_ */
arma::vec::fixed< spacedim > grad_
Potential gradient.
FieldAddPotential(const arma::vec::fixed< spacedim+1 > &potential_grad, const Input::AbstractRecord &rec, unsigned int n_comp=0)
arma::vec::fixed< spacedim > Point
Definition: point.hh:23
double zero_level_
Potential constant term.
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:423
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
virtual bool set_time(double time)
std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > inner_field_
Field to which we add linear potential.
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Space< spacedim >::Point Point
unsigned int n_comp() const