Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
adaption_surface_grid_function_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2015: G-CSC, Goethe University Frankfurt
3 * Author: 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#ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION_IMPL__
34#define __H__UG__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION_IMPL__
35
39
40#define GFUNCADAPT_PROFILE_FUNC() PROFILE_FUNC_GROUP("gfunc-adapt")
41
42
43namespace ug{
44
45template <typename TDomain>
46template <typename TElem, typename TAlgebra>
48copy_from_surface(const GridFunction<TDomain,TAlgebra>& rSurfaceFct, TElem* elem)
49{
50 std::vector<DoFIndex> vInd;
51 const size_t numFct = m_spDDInfo->num_fct();
52
53 std::vector<std::vector<number> >& vvVal = m_aaValue[elem];
54 vvVal.resize(numFct);
55
56 for(size_t fct = 0; fct < numFct; ++fct){
57
58 std::vector<number>& vVal = vvVal[fct];
59
60 rSurfaceFct.inner_dof_indices(elem, fct, vInd);
61 vVal.resize(vInd.size());
62 for(size_t i = 0; i < vInd.size(); ++i)
63 vVal[i] = DoFRef(rSurfaceFct, vInd[i]);
64 }
65}
66
67template <typename TDomain>
68template <typename TElem, typename TAlgebra>
71{
72 ConstSmartPtr<SurfaceView> spSurfView = rSurfaceFct.approx_space()->surface_view();
73 ConstSmartPtr<MultiGrid> spGrid = m_spDomain->grid();
74 typedef typename GridFunction<TDomain,TAlgebra>::template traits<TElem>::const_iterator iter_type;
75 iter_type iter = rSurfaceFct.template begin<TElem>(SurfaceView::ALL);
76 iter_type iterEnd = rSurfaceFct.template end<TElem>(SurfaceView::ALL);
77
78 for( ; iter != iterEnd; ++iter){
79
80 // get surface element
81 TElem* elem = *iter;
82
83 // copy indices to attachment
84 copy_from_surface(rSurfaceFct, elem);
85 }
86}
87
88template <typename TDomain>
89template <typename TAlgebra>
92{
94 attach_entries(rSurfaceFct.dof_distribution()->dof_distribution_info());
95
96 if(rSurfaceFct.max_dofs(VERTEX))copy_from_surface<Vertex,TAlgebra>(rSurfaceFct);
97 if(rSurfaceFct.max_dofs(EDGE)) copy_from_surface<Edge,TAlgebra>(rSurfaceFct);
98 if(rSurfaceFct.max_dofs(FACE)) copy_from_surface<Face,TAlgebra>(rSurfaceFct);
99 if(rSurfaceFct.max_dofs(VOLUME))copy_from_surface<Volume,TAlgebra>(rSurfaceFct);
100
101 #ifdef UG_PARALLEL
102 m_ParallelStorageType = rSurfaceFct.get_storage_mask();
103 #endif
104
105// \todo: At this point the vert. slaves are not provided with the correct values
106// Thus, the vert. masters should sent their values there.
107}
108
109
110template <typename TDomain>
111template <typename TElem, typename TAlgebra>
113copy_to_surface(GridFunction<TDomain,TAlgebra>& rSurfaceFct, TElem* elem)
114{
115 std::vector<DoFIndex> vInd;
116 const std::vector<std::vector<number> >& vvVal = m_aaValue[elem];
117
118 UG_ASSERT(vvVal.size() == m_spDDInfo->num_fct(), "Array says numFct: "<<
119 vvVal.size()<<", but should be "<<m_spDDInfo->num_fct()<<" on "
120 << ElementDebugInfo(*m_spDomain->grid(), elem));
121
122 for(size_t fct = 0; fct < vvVal.size(); ++fct){
123
124 const std::vector<number>& vVal = vvVal[fct];
125 rSurfaceFct.inner_dof_indices(elem, fct, vInd);
126
127 UG_ASSERT(vVal.size() == vInd.size(), "Stored dofs are "<<vVal.size()<<
128 ", but fct "<<fct<<" has "<<vInd.size()<<" dofs on "<<
129 elem->reference_object_id())
130
131 for(size_t i = 0; i < vInd.size(); ++i){
132 UG_ASSERT(vInd[i][0] != size_t(-1),
133 "Bad dof-index encountered on: "
134 << ElementDebugInfo(*rSurfaceFct.domain()->grid(), elem));
135 DoFRef(rSurfaceFct, vInd[i]) = vVal[i];
136 }
137 }
138}
139
140template <typename TDomain>
141template <typename TElem, typename TAlgebra>
144{
145 ConstSmartPtr<SurfaceView> spSurfView = rSurfaceFct.approx_space()->surface_view();
146 ConstSmartPtr<MultiGrid> spGrid = m_spDomain->grid();
147
148 typedef typename GridFunction<TDomain,TAlgebra>::template traits<TElem>::const_iterator iter_type;
149 iter_type iter = rSurfaceFct.template begin<TElem>(SurfaceView::ALL);
150 iter_type iterEnd = rSurfaceFct.template end<TElem>(SurfaceView::ALL);
151
152 for( ; iter != iterEnd; ++iter)
153 {
154 TElem* elem = *iter;
155
156 copy_to_surface(rSurfaceFct, elem);
157 }
158}
159
160template <typename TDomain>
161template <typename TAlgebra>
164{
166 if(rSurfaceFct.max_dofs(VERTEX))copy_to_surface<Vertex,TAlgebra>(rSurfaceFct);
167 if(rSurfaceFct.max_dofs(EDGE)) copy_to_surface<Edge,TAlgebra>(rSurfaceFct);
168 if(rSurfaceFct.max_dofs(FACE)) copy_to_surface<Face,TAlgebra>(rSurfaceFct);
169 if(rSurfaceFct.max_dofs(VOLUME))copy_to_surface<Volume,TAlgebra>(rSurfaceFct);
170
171 #ifdef UG_PARALLEL
172 rSurfaceFct.set_storage_type(m_ParallelStorageType);
173 #endif
174
175 detach_entries();
176}
177
178
179template <typename TDomain>
180template <typename TBaseElem>
182
183// get value attachment
184 std::vector<std::vector<number> >& vvVal = m_aaValue[elem];
185
186// resize to number of functions
187 vvVal.resize(m_spDDInfo->num_fct());
188
189// get geom obj infos
190 const ReferenceObjectID roid = elem->reference_object_id();
191 const int si = m_spDomain->subset_handler()->get_subset_index(elem);
192
193// for each fct cmp resize to number of dofs associated with elem
194 for(size_t fct = 0; fct < vvVal.size(); ++fct){
195 vvVal[fct].resize(m_spDDInfo->num_fct_dofs(fct, roid, si));
196 }
197}
198
199} // end namespace ug
200
201#endif /* __H__UG__LIB_DISC__FUNCTION_SPACE__ADAPTION_SURFACE_GRID_FUNCTION_IMPL__ */
#define GFUNCADAPT_PROFILE_FUNC()
Definition adaption_surface_grid_function_impl.h:40
Definition smart_pointer.h:296
void copy_to_surface(GridFunction< TDomain, TAlgebra > &rSurfaceFct)
Definition adaption_surface_grid_function_impl.h:163
void obj_created(TBaseElem *elem)
creates storage when object created
Definition adaption_surface_grid_function_impl.h:181
void copy_from_surface(const GridFunction< TDomain, TAlgebra > &rSurfaceFct)
Definition adaption_surface_grid_function_impl.h:91
size_t max_dofs(const int dim) const
returns the maximum number of dofs on grid objects in a dimension
Definition dof_distribution_info.h:231
represents numerical solutions on a grid using an algebraic vector
Definition grid_function.h:121
size_t inner_dof_indices(TElem *elem, size_t fct, std::vector< DoFIndex > &ind, bool bClear=true) const
get multi indices on an geometric object in canonical order
Definition grid_function.h:327
SmartPtr< ApproximationSpace< TDomain > > approx_space()
returns approx space
Definition grid_function.h:348
SmartPtr< TDomain > domain()
returns domain
Definition grid_function.h:342
SmartPtr< DoFDistribution > dof_distribution()
Definition grid_function.h:236
@ ALL
Definition surface_view.h:102
std::string ElementDebugInfo(const Grid &grid, GridObject *e)
Returns a string containing information on the given element.
Definition debug_util.cpp:991
#define UG_ASSERT(expr, msg)
Definition assert.h:70
the ug namespace
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition grid_base_objects.h:74
@ VOLUME
Definition grid_base_objects.h:63
@ VERTEX
Definition grid_base_objects.h:60
@ EDGE
Definition grid_base_objects.h:61
@ FACE
Definition grid_base_objects.h:62
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition multi_index.h:276