Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
parallelization_util_impl.hpp
Go to the documentation of this file.
1/*
2 * Copyright (c) 2011-2015: G-CSC, Goethe University Frankfurt
3 * Author: Sebastian Reiter
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_GRID__parallelization_util_impl__
34#define __H__UG__LIB_GRID__parallelization_util_impl__
35
38
39namespace ug
40{
41
43template <class TGeomObj>
45 AGeomObjID& aID)
46{
47// make sure that aID is attached to the objects of the grid
48 if(!g.has_attachment<TGeomObj>(aID)){
49 g.attach_to<TGeomObj>(aID);
50 }
51
53
54// set up local ids
55 int rank = pcl::ProcRank();
56
57 typedef typename geometry_traits<TGeomObj>::iterator GeomObjIter;
58
59 size_t count = 0;
60 for(GeomObjIter iter = g.begin<TGeomObj>();
61 iter != g.end<TGeomObj>(); ++iter, ++count)
62 {
63 aaID[*iter] = MakeGeomObjID(rank, count);
64 }
65
66// distribute the ids master->slave
67 typedef typename GridLayoutMap::Types<TGeomObj>::Layout Layout;
70
71 com.exchange_data(glm, INT_H_MASTER, INT_H_SLAVE, compolCopy);
72 com.communicate();
73
74// we copy data from vertical slaves to vertical masters and not vice versa for
75// the following reason:
76// Multiple copies of low dimensional elements may reside in vertical master
77// interfaces and they do not necessarily have the same global id yet.
78// Elements in horizontal interfaces, however, already have the same ids yet.
79// Since all vertical slaves are either unique or in a horizontal interface,
80// we can simply copy their global ids to vertical master elements.
81 com.exchange_data(glm, INT_V_SLAVE, INT_V_MASTER, compolCopy);
82 com.communicate();
83}
84
85}// end of namespace
86
87#endif
Performs communication between interfaces on different processes.
Definition pcl_interface_communicator.h:68
bool communicate(int tag=749345)
sends and receives the collected data.
Definition pcl_interface_communicator_impl.hpp:409
void exchange_data(const TLayoutMap &layoutMap, const typename TLayoutMap::Key &keyFrom, const typename TLayoutMap::Key &keyTo, ICommunicationPolicy< TLayout > &commPol)
internally calls send_data and receive_data with the specified layouts.
Definition pcl_interface_communicator_impl.hpp:213
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
copies values from a specified attachment to a stream and back.
Definition compol_copy_attachment.h:54
the generic attachment-accessor for access to grids attachment pipes.
Definition grid.h:182
Manages the elements of a grid and their interconnection.
Definition grid.h:132
void attach_to(IAttachment &attachment, bool passOnValues)
attach with custom pass-on-behaviour and unspecified default value.
Definition grid_impl.hpp:296
bool has_attachment(IAttachment &attachment)
Definition grid.h:796
geometry_traits< TGeomObj >::iterator begin()
Definition grid_impl.hpp:164
geometry_traits< TGeomObj >::iterator end()
Definition grid_impl.hpp:175
lets you access layouts by type and key
Definition parallel_grid_layout.h:152
Definition grid_base_object_traits.h:68
GeomObjID MakeGeomObjID(int procRank, size_t localGeomObjID)
Can be used to construct a GeomObjID from a proc-rank and a local id.
Definition grid_object_id.h:60
void CreateAndDistributeGlobalIDs(Grid &g, GridLayoutMap &glm, AGeomObjID &aID=aGeomObjID)
Creates and distributes global ids for the given element type.
Definition parallelization_util_impl.hpp:44
int ProcRank()
returns the rank of the process
Definition pcl_base.cpp:83
the ug namespace
@ INT_V_MASTER
vertical master node
Definition parallel_grid_layout.h:106
@ INT_H_MASTER
horizontal master node
Definition parallel_grid_layout.h:104
@ INT_H_SLAVE
horizontal slave node
Definition parallel_grid_layout.h:105
@ INT_V_SLAVE
vertical slave node
Definition parallel_grid_layout.h:107
pcl::MultiLevelLayout< Interface > Layout
Definition parallel_grid_layout.h:161