Flow123d  DF_patch_fe_data_tables-586fb30
field_add_potential.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 field_add_potential.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_ADD_POTENTIAL_HH_
19 #define FIELD_ADD_POTENTIAL_HH_
20 
21 #include <armadillo>
22 #include <memory>
23 
24 #include "fields/field.hh"
26 #include "fields/field_model.hh"
27 #include "fields/field_coords.hh"
28 
29 
30 /*******************************************************************************
31  * Functors of FieldModels
32  */
33 using Sclr = double;
34 using Vect = arma::vec3;
35 
36 // Functor computing piezo_head_p0
38  inline Sclr operator() (Vect gravity, Vect coords, Sclr pressure) {
39  return arma::dot(gravity, coords) + pressure;
40  }
41 };
42 
43 
44 /**
45  * Factory class (descendant of @p Field<...>::FactoryBase) that is necessary
46  * for setting pressure values are piezometric head values.
47  */
48 template <int spacedim, class Value> // <3, FieldValue<3>::Scalar>
49 class AddPotentialFactory : public Field<spacedim, Value>::FactoryBase {
50 public:
51  /// Constructor.
53  : gravity_(gravity),
54  coords_(coords),
55  inner_field_(inner_field),
56  field_name_(inner_field.input_name())
57  {}
58 
60  Input::AbstractRecord field_a_rec;
61  if (rec.opt_val(field_name_, field_a_rec)) {
63 
64  } else {
65  return typename Field<spacedim,Value>::FieldBasePtr();
66  }
67  }
68 
69  bool is_active_field_descriptor(const Input::Record &in_rec, FMT_UNUSED const std::string &input_name) override {
70  return in_rec.find<Input::AbstractRecord>(field_name_);
71  }
72 
76  std::string field_name_;
77 };
78 
79 #endif /* FIELD_ADD_POTENTIAL_HH_ */
bool is_active_field_descriptor(const Input::Record &in_rec, FMT_UNUSED const std::string &input_name) override
Field< 3, FieldValue< 3 >::VectorFixed > & gravity_
AddPotentialFactory(Field< 3, FieldValue< 3 >::VectorFixed > &gravity, FieldCoords &coords, Field< 3, FieldValue< 3 >::Scalar > &inner_field)
Constructor.
Field< 3, FieldValue< 3 >::Scalar > & inner_field_
Field< spacedim, Value >::FieldBasePtr create_field(Input::Record rec, const FieldCommon &) override
Common abstract parent of all Field<...> classes.
Definition: field_common.hh:77
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
std::shared_ptr< FieldBaseType > FieldBasePtr
Definition: field.hh:96
Accessor to the polymorphic input data of a type given by an AbstracRecord object.
Definition: accessors.hh:458
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
bool opt_val(const string &key, Ret &value) const
Iterator< Ret > find(const string &key) const
double Sclr
#define FMT_UNUSED
Definition: posix.h:75
Sclr operator()(Vect gravity, Vect coords, Sclr pressure)