Flow123d  JS_before_hm-1727-ga1133b990
field_divide.cc
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_divide.cc
15  * @brief
16  */
17 
18 #include "fields/field_divide.hh"
19 #include "fields/field_instances.hh" // for instantiation macros
20 
21 
22 template <int spacedim, class Value>
24  Field<3, FieldValue<3>::Scalar> inner_divisor, unsigned int n_comp)
25 : FieldAlgorithmBase<spacedim, Value>(n_comp),
26  inner_dividend_(inner_dividend),
27  inner_divisor_(inner_divisor)
28 {
30 }
31 
32 
33 
34 template <int spacedim, class Value>
35 typename Value::return_type const & FieldDivide<spacedim, Value>::value(const Point &p, const ElementAccessor<spacedim> &elm)
36 {
37  this->r_value_ = inner_dividend_->value(p,elm);
38  double div_val = inner_divisor_.value(p,elm);
39 
40  for(unsigned int row=0; row < this->value_.n_rows(); row++)
41  for(unsigned int col=0; col < this->value_.n_cols(); col++) {
42  this->value_(row,col) /= div_val;
43  }
44 
45  return this->r_value_;
46 }
47 
48 
49 
50 /**
51  * Returns std::vector of scalar values in several points at once.
52  */
53 template <int spacedim, class Value>
56 {
57  ASSERT_EQ( point_list.size(), value_list.size() ).error();
58  ASSERT_DBG( point_list.n_rows() == spacedim && point_list.n_cols() == 1 ).error("Invalid point size.\n");
59 
60  inner_dividend_->value_list(point_list, elm, value_list);
61 
62  for(unsigned int i=0; i< point_list.size(); i++) {
63  double div_val = inner_divisor_.value(point_list.vec<spacedim>(i),elm);
64  Value envelope(value_list[i]);
65 
66  for(unsigned int row=0; row < this->value_.n_rows(); row++)
67  for(unsigned int col=0; col < this->value_.n_cols(); col++)
68  envelope(row,col) /= div_val;
69  }
70 }
71 
72 
73 
74 template <int spacedim, class Value>
76 {
77  ASSERT_PTR(inner_dividend_).error("Null data pointer.\n");
78  bool changed = inner_divisor_.set_time(time, LimitSide::right);
79  return inner_dividend_->set_time(time) && changed;
80 }
81 
82 
83 
84 template <int spacedim, class Value>
86 }
87 
88 
89 // Instantiations of FieldConstant
91 
LimitSide::right
@ right
FieldDivide::set_time
bool set_time(const TimeStep &time) override
Definition: field_divide.cc:75
Armor::Array::vec
ArmaVec< Type, nr > vec(uint mat_index) const
Definition: armor.hh:821
ASSERT_DBG
#define ASSERT_DBG(expr)
Definition: include_fadbad.hh:28
std::vector
Definition: doxy_dummy_defs.hh:7
ElementAccessor
Definition: dh_cell_accessor.hh:32
FieldDivide::FieldDivide
FieldDivide(std::shared_ptr< FieldAlgorithmBase< spacedim, Value > > inner_dividend, Field< 3, FieldValue< 3 >::Scalar > inner_divisor, unsigned int n_comp=0)
Definition: field_divide.cc:23
FieldAlgorithmBase::Point
Space< spacedim >::Point Point
Definition: field_algo_base.hh:115
FieldCommon::flags_add
FieldCommon & flags_add(FieldFlag::Flags::Mask mask)
Definition: field_common.hh:195
Armor::Array::n_rows
uint n_rows() const
Definition: armor.hh:715
TimeStep
Representation of one time step..
Definition: time_governor.hh:123
FieldDivide::inner_divisor_
Field< 3, FieldValue< 3 >::Scalar > inner_divisor_
Field to which we add linear potential.
Definition: field_divide.hh:64
ASSERT_EQ
#define ASSERT_EQ(a, b)
Definition of comparative assert macro (EQual)
Definition: asserts.hh:328
FieldDivide::value
virtual const Value::return_type & value(const Point &p, const ElementAccessor< spacedim > &elm)
Definition: field_divide.cc:35
Armor::Array::n_cols
uint n_cols() const
Definition: armor.hh:720
Armor::Array::size
unsigned int size() const
Definition: armor.hh:728
Value
@ Value
Definition: finite_element.hh:43
FieldAlgorithmBase
Definition: field_algo_base.hh:112
INSTANCE_ALL
#define INSTANCE_ALL(field)
Definition: field_instances.hh:43
FieldDivide
Definition: field_divide.hh:33
field_instances.hh
FieldDivide::value_list
virtual void value_list(const Armor::array &point_list, const ElementAccessor< spacedim > &elm, std::vector< typename Value::return_type > &value_list)
Definition: field_divide.cc:54
Armor::Array< double >
FieldFlag::declare_input
static constexpr Mask declare_input
The field can be set from input. The key in input field descriptor is declared. (default on)
Definition: field_flag.hh:35
FieldDivide::~FieldDivide
virtual ~FieldDivide()
Definition: field_divide.cc:85
field_divide.hh
Field
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:95
ASSERT_PTR
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
Definition: asserts.hh:336
FieldValue
Definition: field_values.hh:645