ug4
element_orientation_data.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2021 - : G-CSC, Goethe University Frankfurt
3  * Author: Arne Naegel
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  * User data of a subset indicator (1 in the subset, 0 everywhere else)
35  */
36 #ifndef __H__UG__LIB_DISC__SPATIAL_DISC__USER_DATA__LINE_USER_DATA__
37 #define __H__UG__LIB_DISC__SPATIAL_DISC__USER_DATA__LINE_USER_DATA__
38 
39 #include <vector>
40 
41 // ug4 headers
42 #include "common/common.h"
43 #include "common/math/ugmath.h"
45 
46 namespace ug {
47 
49 template <typename TDomain>
51  : public StdUserData<EdgeOrientation<TDomain>, MathVector<TDomain::dim>, TDomain::dim>
52 {
53 public:
55  static const int dim = TDomain::dim;
56 
59 
63 
64 
65 
66 public:
67 
70  {}
71 
73  virtual bool continuous () const {return false;}
74 
76  virtual bool requires_grid_fct () const {return true;}
77 
79  void operator() (return_type & vValue, const MathVector<dim> & globIP, number time, int si) const
80  { UG_THROW("SubsetIndicatorUserData: Element required for evaluation, but not passed. Cannot evaluate."); }
81 
83  void operator() (return_type vValue [], const MathVector<dim> vGlobIP [], number time, int si, const size_t nip) const
84  { UG_THROW("SubsetIndicatorUserData: Element required for evaluation, but not passed. Cannot evaluate."); }
85 
86 
87  inline void elem_evaluate(return_type &delta, GridObject * elem) const
88  {
89  auto& aaPos = m_spDomain->position_accessor();
90  EdgeVertices *e = dynamic_cast<EdgeVertices*> (elem);
91  UG_ASSERT(e != NULL, "ERROR: No edge! ");
92 
93  VecSubtract(delta, aaPos[e->vertex(1)], aaPos[e->vertex(0)]); // v = e_1 - e_0
94  delta /= VecLength(delta); // normalize
95  }
96 
97 
98 
100  template <int refDim>
101  inline void evaluate
102  (
103  return_type vValue [],
104  const MathVector<dim> vGlobIP [],
105  number time,
106  int si,
107  GridObject * elem,
108  const MathVector<dim> vCornerCoords [],
109  const MathVector<refDim> vLocIP [],
110  const size_t nip,
111  LocalVector * u,
112  const MathMatrix<refDim, dim> * vJT = NULL
113  ) const
114  {
115 
116  MathVector<dim> delta;
117  elem_evaluate(delta, elem);
118 
119  for (size_t i = 0; i < nip; i++)
120  {
121  vValue[i] = delta;
122  }
123 
124  };
125 
127  virtual void compute(LocalVector* u, GridObject* elem,
128  const MathVector<dim> vCornerCoords[], bool bDeriv = false)
129  {
130  for(size_t s = 0; s < this->num_series(); ++s)
131  for(size_t ip = 0; ip < this->num_ip(s); ++ip)
132  elem_evaluate(this->value(s,ip), elem);
133  }
134 
136  virtual void compute(LocalVectorTimeSeries* u, GridObject* elem,
137  const MathVector<dim> vCornerCoords[], bool bDeriv = false)
138  {
139  for(size_t s = 0; s < this->num_series(); ++s)
140  for(size_t ip = 0; ip < this->num_ip(s); ++ip)
141  elem_evaluate(this->value(s,ip), elem);
142  }
143 
144 
145 protected:
147 };
148 
149 } // end namespace ug
150 
151 #endif // __H__UG__LIB_DISC__SPATIAL_DISC__USER_DATA__LINE_USER_DATA__
152 
153 /* End of File */
parameterString s
Type based UserData.
Definition: user_data.h:501
size_t num_ip(size_t s) const
returns the number of integration points
Definition: user_data.h:327
size_t num_series() const
explicitly forward some functions
Definition: user_data.h:324
const TData & value(size_t s, size_t ip) const
returns the value at ip
Definition: user_data.h:512
User data for the orientation of a line element.
Definition: element_orientation_data.h:52
SmartPtr< TDomain > m_spDomain
Definition: element_orientation_data.h:146
void elem_evaluate(return_type &delta, GridObject *elem) const
Definition: element_orientation_data.h:87
virtual bool requires_grid_fct() const
Returns true to get the grid element in the evaluation routine.
Definition: element_orientation_data.h:76
static const int dim
World dimension.
Definition: element_orientation_data.h:55
virtual void compute(LocalVectorTimeSeries *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
implement as a UserData
Definition: element_orientation_data.h:136
EdgeOrientation(SmartPtr< TDomain > domain)
Constructor.
Definition: element_orientation_data.h:69
virtual void compute(LocalVector *u, GridObject *elem, const MathVector< dim > vCornerCoords[], bool bDeriv=false)
implement as a UserData
Definition: element_orientation_data.h:127
virtual bool continuous() const
Indicator functions are discontinuous.
Definition: element_orientation_data.h:73
StdUserData< EdgeOrientation< TDomain >, MathVector< TDomain::dim >, TDomain::dim, void > base_type
Type of domain.
Definition: element_orientation_data.h:61
MathVector< dim > return_type
Return type.
Definition: element_orientation_data.h:58
CplUserData< MathVector< TDomain::dim >, TDomain::dim > cpl_user_data
Definition: element_orientation_data.h:62
void evaluate(return_type 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, const MathMatrix< refDim, dim > *vJT=NULL) const
Evaluator.
Definition: element_orientation_data.h:102
void operator()(return_type &vValue, const MathVector< dim > &globIP, number time, int si) const
This function should not be used.
Definition: element_orientation_data.h:79
holds the vertices of an Edge or an EdgeDescriptor.
Definition: grid_base_objects.h:362
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:366
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: local_algebra.h:198
time series of local vectors
Definition: solution_time_series.h:167
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
Definition: std_user_data.h:63
static const int dim
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
vector_t::value_type VecLength(const vector_t &v)
returns the length of v. Slower than VecLengthSq.
Definition: math_vector_functions_common_impl.hpp:341
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
the ug namespace