Line data Source code
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 : #include "dof_index_storage.h"
34 :
35 : namespace ug{
36 :
37 0 : DoFIndexStorage::
38 : DoFIndexStorage(SmartPtr<MultiGrid> spMG,
39 0 : ConstSmartPtr<DoFDistributionInfo> spDDInfo)
40 : : DoFDistributionInfoProvider(spDDInfo),
41 0 : m_spMG(spMG)
42 : {
43 0 : init_attachments();
44 0 : }
45 :
46 0 : DoFIndexStorage::
47 : ~DoFIndexStorage()
48 : {
49 0 : clear_attachments();
50 0 : }
51 :
52 0 : void DoFIndexStorage::init_attachments()
53 : {
54 : // attach DoFs to vertices
55 0 : if(max_dofs(VERTEX)) {
56 0 : multi_grid()->attach_to_dv<Vertex>(m_aIndex, (size_t)-1);
57 0 : m_aaIndexVRT.access(*multi_grid(), m_aIndex);
58 : }
59 0 : if(max_dofs(EDGE)) {
60 0 : multi_grid()->attach_to_dv<Edge>(m_aIndex, (size_t)-1);
61 0 : m_aaIndexEDGE.access(*multi_grid(), m_aIndex);
62 : }
63 0 : if(max_dofs(FACE)) {
64 0 : multi_grid()->attach_to_dv<Face>(m_aIndex, (size_t)-1);
65 0 : m_aaIndexFACE.access(*multi_grid(), m_aIndex);
66 : }
67 0 : if(max_dofs(VOLUME)) {
68 0 : multi_grid()->attach_to_dv<Volume>(m_aIndex, (size_t)-1);
69 0 : m_aaIndexVOL.access(*multi_grid(), m_aIndex);
70 : }
71 0 : }
72 :
73 0 : void DoFIndexStorage::clear_attachments()
74 : {
75 : // detach DoFs
76 0 : if(m_aaIndexVRT.valid()) multi_grid()->detach_from<Vertex>(m_aIndex);
77 0 : if(m_aaIndexEDGE.valid()) multi_grid()->detach_from<Edge>(m_aIndex);
78 0 : if(m_aaIndexFACE.valid()) multi_grid()->detach_from<Face>(m_aIndex);
79 0 : if(m_aaIndexVOL.valid()) multi_grid()->detach_from<Volume>(m_aIndex);
80 :
81 : m_aaIndexVRT.invalidate();
82 : m_aaIndexEDGE.invalidate();
83 : m_aaIndexFACE.invalidate();
84 : m_aaIndexVOL.invalidate();
85 0 : }
86 :
87 0 : size_t& DoFIndexStorage::obj_index(GridObject* obj)
88 : {
89 0 : switch(obj->base_object_id())
90 : {
91 0 : case VERTEX: return obj_index(static_cast<Vertex*>(obj));
92 0 : case EDGE: return obj_index(static_cast<Edge*>(obj));
93 0 : case FACE: return obj_index(static_cast<Face*>(obj));
94 0 : case VOLUME: return obj_index(static_cast<Volume*>(obj));
95 0 : default: UG_THROW("Base Object type not found.");
96 : }
97 : }
98 :
99 0 : const size_t& DoFIndexStorage::obj_index(GridObject* obj) const
100 : {
101 0 : switch(obj->base_object_id())
102 : {
103 0 : case VERTEX: return obj_index(static_cast<Vertex*>(obj));
104 0 : case EDGE: return obj_index(static_cast<Edge*>(obj));
105 0 : case FACE: return obj_index(static_cast<Face*>(obj));
106 0 : case VOLUME: return obj_index(static_cast<Volume*>(obj));
107 0 : default: UG_THROW("Base Object type not found.");
108 : }
109 : };
110 :
111 : } // end namespace ug
|