ug4
inverse_linker.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3  * Authors: Ivo Muha, Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 /*
34  * andreasvogel used scale_add_linker ass template
35  */
36 
37 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__INVERSE_LINKER__
38 #define __H__UG__LIB_DISC__SPATIAL_DISC__INVERSE_LINKER__
39 
40 #include "linker.h"
41 
42 namespace ug{
43 
44 
46 // Scaled adding of Data
48 
57 template <int dim>
59  : public StdDataLinker<InverseLinker<dim>, number, dim>
60 {
61  public:
62  // type of base class
64 
65  public:
68 
70  InverseLinker(const InverseLinker& linker);
71 
74  void divide(number dividend,
77  number divisor);
78  void divide(number dividend,
79  number divisor);
80 
81  inline void evaluate (number& value,
82  const MathVector<dim>& globIP,
83  number time, int si) const;
84 
85  template <int refDim>
86  inline void evaluate(number vValue[],
87  const MathVector<dim> vGlobIP[],
88  number time, int si,
89  GridObject* elem,
90  const MathVector<dim> vCornerCoords[],
91  const MathVector<refDim> vLocIP[],
92  const size_t nip,
93  LocalVector* u,
94  const MathMatrix<refDim, dim>* vJT = NULL) const;
95 
96  template <int refDim>
97  void eval_and_deriv(number vValue[],
98  const MathVector<dim> vGlobIP[],
99  number time, int si,
100  GridObject* elem,
101  const MathVector<dim> vCornerCoords[],
102  const MathVector<refDim> vLocIP[],
103  const size_t nip,
104  LocalVector* u,
105  bool bDeriv,
106  int s,
107  std::vector<std::vector<number> > vvvDeriv[],
108  const MathMatrix<refDim, dim>* vJT = NULL) const;
109 
110  protected:
112  const number& divisor_value(size_t i, size_t s, size_t ip) const
113  {
114  UG_ASSERT(i < m_vpDivisorData.size(), "Input not needed");
115  UG_ASSERT(m_vpDivisorData[i].valid(), "Input invalid");
116  return m_vpDivisorData[i]->value(this->series_id(2*i,s), ip);
117  }
118 
120  const number& divisor_deriv(size_t i, size_t s, size_t ip, size_t fct, size_t dof) const
121  {
122  UG_ASSERT(i < m_vpDependData.size(), "Input not needed");
123  UG_ASSERT(m_vpDependData[i].valid(), "Input invalid");
124  return m_vpDependData[i]->deriv(this->series_id(2*i,s), ip, fct, dof);
125  }
126 
128  const number& dividend_value(size_t i, size_t s, size_t ip) const
129  {
130  UG_ASSERT(i < m_vpDividendData.size(), "Input not needed");
131  UG_ASSERT(m_vpDividendData[i].valid(), "Input invalid");
132  return m_vpDividendData[i]->value(this->series_id(2*i+1,s), ip);
133  }
134 
136  const number& dividend_deriv(size_t i, size_t s, size_t ip, size_t fct, size_t dof) const
137  {
138  UG_ASSERT(i < m_vpDividendDependData.size(), "Input not needed");
139  UG_ASSERT(m_vpDividendDependData[i].valid(), "Input invalid");
140  return m_vpDividendDependData[i]->deriv(this->series_id(2*i+1,s), ip, fct, dof);
141  }
142 
144  size_t divisor_num_fct(size_t i) const {return base_type::input_num_fct(2*i);}
145 
147  size_t divisor_common_fct(size_t i, size_t fct) const {return base_type::input_common_fct(2*i, fct);}
148 
150  size_t dividend_num_fct(size_t i) const {return base_type::input_num_fct(2*i+1);}
151 
153  size_t dividend_common_fct(size_t i, size_t fct) const {return base_type::input_common_fct(2*i+1, fct);}
154 
155  protected:
157  std::vector<SmartPtr<CplUserData<number, dim> > > m_vpDividendData;
158 
160  std::vector<SmartPtr<DependentUserData<number, dim> > > m_vpDividendDependData;
161 
163  std::vector<SmartPtr<CplUserData<number, dim> > > m_vpDivisorData;
164 
166  std::vector<SmartPtr<DependentUserData<number, dim> > > m_vpDependData;
167 };
168 
169 } // end namespace ug
170 
171 #include "inverse_linker_impl.h"
172 
173 #endif /* __H__UG__LIB_DISC__SPATIAL_DISC__INVERSE_LINKER__ */
parameterString s
Definition: smart_pointer.h:108
Type based UserData.
Definition: user_data.h:501
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
const MathVector< dim > & ip(size_t s, size_t ip) const
returns global ip
Definition: user_data.h:401
number time() const
get the current evaluation time
Definition: user_data.h:285
Definition: inverse_linker.h:60
const number & divisor_deriv(size_t i, size_t s, size_t ip, size_t fct, size_t dof) const
divisor of data at input at ip
Definition: inverse_linker.h:120
std::vector< SmartPtr< DependentUserData< number, dim > > > m_vpDividendDependData
data Dividend casted to dependend data
Definition: inverse_linker.h:160
StdDataLinker< InverseLinker< dim >, number, dim > base_type
Definition: inverse_linker.h:63
InverseLinker()
constructor
Definition: inverse_linker.h:67
const number & dividend_deriv(size_t i, size_t s, size_t ip, size_t fct, size_t dof) const
derivative of dividend at input at ip
Definition: inverse_linker.h:136
void evaluate(number &value, const MathVector< dim > &globIP, number time, int si) const
Definition: inverse_linker_impl.h:119
size_t divisor_num_fct(size_t i) const
returns number of functions the divisor depends on
Definition: inverse_linker.h:144
std::vector< SmartPtr< CplUserData< number, dim > > > m_vpDivisorData
data Divisor
Definition: inverse_linker.h:163
void eval_and_deriv(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< refDim > vLocIP[], const size_t nip, LocalVector *u, bool bDeriv, int s, std::vector< std::vector< number > > vvvDeriv[], const MathMatrix< refDim, dim > *vJT=NULL) const
Definition: inverse_linker_impl.h:176
const number & divisor_value(size_t i, size_t s, size_t ip) const
divisor at ip of input
Definition: inverse_linker.h:112
void divide(SmartPtr< CplUserData< number, dim > > dividend, SmartPtr< CplUserData< number, dim > > divisor)
Definition: inverse_linker_impl.h:66
size_t dividend_num_fct(size_t i) const
returns number of functions the dividend depends on
Definition: inverse_linker.h:150
const number & dividend_value(size_t i, size_t s, size_t ip) const
dividend at ip of input
Definition: inverse_linker.h:128
std::vector< SmartPtr< DependentUserData< number, dim > > > m_vpDependData
data Divisor casted to dependend data
Definition: inverse_linker.h:166
size_t divisor_common_fct(size_t i, size_t fct) const
returns the number in the common FctGrp for a fct of an divisor
Definition: inverse_linker.h:147
std::vector< SmartPtr< CplUserData< number, dim > > > m_vpDividendData
data Dividend
Definition: inverse_linker.h:157
size_t dividend_common_fct(size_t i, size_t fct) const
returns the number in the common FctGrp for a fct of a dividend
Definition: inverse_linker.h:153
Definition: local_algebra.h:198
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
combines several UserDatas to a new UserData of a specified type
Definition: linker.h:54
size_t series_id(size_t i, size_t s) const
returns the series id set for the i'th input
Definition: linker.h:161
size_t input_common_fct(size_t i, size_t fct) const
returns the number in the common FctGrp for a fct of an input
Definition: linker.h:153
size_t input_num_fct(size_t i) const
returns number of functions the input depends on
Definition: linker.h:145
static const int dim
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
double number
Definition: types.h:124
the ug namespace