Flow123d  release_3.0.0-1190-g0f314ad
field_interpolated_p0.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_interpolated_p0.hh
15  * @brief
16  */
17 
18 #ifndef FIELD_INTERPOLATED_P0_HH_
19 #define FIELD_INTERPOLATED_P0_HH_
20 
21 #include <string.h> // for memcpy
22 #include <boost/exception/info.hpp> // for operator<<, error_info:...
23 #include <limits> // for numeric_limits
24 #include <memory> // for shared_ptr
25 #include <string> // for string
26 #include <vector> // for vector
27 #include <armadillo>
28 #include "field_algo_base.hh" // for FieldAlgorithmBase
29 #include "fields/field_values.hh" // for FieldValue<>::Enum, Fie...
30 #include "input/accessors.hh" // for ExcAccessorForNullStorage
31 #include "input/accessors_impl.hh" // for Record::val
32 #include "input/storage.hh" // for ExcStorageTypeMismatch
33 #include "input/type_record.hh" // for Record::ExcRecordKeyNot...
34 #include "mesh/elements.h" // for Element::dim
35 #include "system/exceptions.hh" // for ExcAssertMsg::~ExcAsser...
36 #include "system/file_path.hh" // for FilePath
37 #include "tools/time_governor.hh" // for TimeStep
38 class BIHTree;
39 class Mesh;
40 template <int spacedim> class ElementAccessor;
41 
42 
43 template <int spacedim, class Value>
44 class FieldInterpolatedP0: public FieldAlgorithmBase<spacedim, Value> {
45 public:
46 
49 
50  /**
51  * Constructor
52  */
53  FieldInterpolatedP0(unsigned int n_comp=0);
54 
55  /**
56  * Declare Input type.
57  */
58  static const Input::Type::Record & get_input_type();
59 
60  /**
61  * Initialization from the input interface.
62  */
63  virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData& init_data);
64 
65  /**
66  * Update time and possibly update data from GMSH file.
67  */
68  bool set_time(const TimeStep &time) override;
69 
70  /**
71  * Returns one value in one given point. ResultType can be used to avoid some costly calculation if the result is trivial.
72  */
73  virtual typename Value::return_type const &value(const Point &p, const ElementAccessor<spacedim> &elm);
74 
75  /**
76  * Returns std::vector of scalar values in several points at once.
77  */
78  virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor<spacedim> &elm,
80 
81 protected:
82  /// mesh, which is interpolated
83  std::shared_ptr<Mesh> source_mesh_;
84 
85  /// mesh reader file
87 
88  /// Raw buffer of n_entities rows each containing Value::size() doubles.
89  std::shared_ptr< std::vector<typename Value::element_type> > data_;
90 
91  /// vector stored suspect elements in calculating the intersection
93 
94  /// field name read from input
95  std::string field_name_;
96 
97  /// tree of mesh elements
99 
100  /// stored index to last computed element
101  unsigned int computed_elm_idx_ = numeric_limits<unsigned int>::max();
102 
103  /// stored flag if last computed element is boundary
105 
106 
107  /// Default value of element if not set in mesh data file
109 
110  /// Accessor to Input::Record
112 private:
113  /// Registrar of class to factory
114  static const int registrar;
115 
116 };
117 
118 
119 
120 #endif /* FUNCTION_INTERPOLATED_P0_HH_ */
unsigned int computed_elm_boundary_
stored flag if last computed element is boundary
double default_value_
Default value of element if not set in mesh data file.
bool set_time(const TimeStep &time) override
FieldAlgorithmBase< spacedim, Value >::Point Point
FilePath reader_file_
mesh reader file
virtual void init_from_input(const Input::Record &rec, const struct FieldAlgoBaseInitData &init_data)
virtual Value::return_type const & value(const Point &p, const ElementAccessor< spacedim > &elm)
Definition: mesh.h:76
Helper struct stores data for initizalize descentants of FieldAlgorithmBase.
unsigned int computed_elm_idx_
stored index to last computed element
static const int registrar
Registrar of class to factory.
Basic time management class.
virtual void value_list(const std::vector< Point > &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
FieldAlgorithmBase< spacedim, Value > FactoryBaseType
FieldInterpolatedP0(unsigned int n_comp=0)
Input::Record in_rec_
Accessor to Input::Record.
Class for O(log N) lookup for intersections with a set of bounding boxes.
Definition: bih_tree.hh:38
std::shared_ptr< Mesh > source_mesh_
mesh, which is interpolated
Space< spacedim >::Point Point
BIHTree * bih_tree_
tree of mesh elements
static const Input::Type::Record & get_input_type()
Dedicated class for storing path to input and output files.
Definition: file_path.hh:54
std::vector< unsigned int > searched_elements_
vector stored suspect elements in calculating the intersection
Record type proxy class.
Definition: type_record.hh:182
std::string field_name_
field name read from input
std::shared_ptr< std::vector< typename Value::element_type > > data_
Raw buffer of n_entities rows each containing Value::size() doubles.
Representation of one time step..
unsigned int n_comp() const