Line data Source code
1 : /*
2 : * Copyright (c) 2014-2019: G-CSC, Goethe University Frankfurt
3 : * Author: Martin Stepniewski
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 "global_subdivision_multi_grid_refiner.h"
34 :
35 :
36 : using namespace std;
37 :
38 : namespace ug
39 : {
40 :
41 : template <class TAPosition>
42 0 : GlobalSubdivisionMultiGridRefiner<TAPosition>::
43 : GlobalSubdivisionMultiGridRefiner(SPRefinementProjector projector) :
44 0 : GlobalMultiGridRefiner(projector)
45 : {
46 0 : m_pMG = NULL;
47 0 : m_pSH = NULL;
48 0 : m_pMarkSH = NULL;
49 0 : m_spLinearManifoldSH = NULL;
50 0 : m_pAPos = NULL;
51 0 : m_bConstrained = false;
52 0 : }
53 :
54 : template <class TAPosition>
55 0 : GlobalSubdivisionMultiGridRefiner<TAPosition>::
56 : GlobalSubdivisionMultiGridRefiner(MultiGrid& mg, SPRefinementProjector projector) :
57 0 : GlobalMultiGridRefiner(mg, projector)
58 : {
59 0 : m_pSH = NULL;
60 0 : m_pMarkSH = NULL;
61 0 : m_spLinearManifoldSH = NULL;
62 0 : m_pAPos = NULL;
63 0 : m_bConstrained = false;
64 0 : }
65 :
66 : template <class TAPosition>
67 0 : GlobalSubdivisionMultiGridRefiner<TAPosition>::
68 : GlobalSubdivisionMultiGridRefiner(MultiGrid& mg, TAPosition& aPos, MGSubsetHandler& sh,
69 : MGSubsetHandler& markSH,
70 : SPRefinementProjector projector) :
71 0 : GlobalMultiGridRefiner(mg, projector)
72 : {
73 : m_pSH = NULL;
74 : assign_subset_handler(sh);
75 :
76 : m_pMarkSH = NULL;
77 : assign_mark_subset_handler(markSH);
78 :
79 : // m_spLinearManifoldSH = SmartPtr<MGSubsetHandler>(new MGSubsetHandler(*m_pMG));
80 0 : m_spLinearManifoldSH = NULL;
81 : // set_linear_manifold_subsets(*m_spLinearManifoldSH, "");
82 :
83 0 : m_pAPos = NULL;
84 0 : assign_position_attachment(aPos);
85 0 : }
86 :
87 : template <class TAPosition>
88 0 : GlobalSubdivisionMultiGridRefiner<TAPosition>::~GlobalSubdivisionMultiGridRefiner()
89 : {
90 0 : if(m_pMG)
91 0 : m_pMG->unregister_observer(this);
92 0 : }
93 :
94 : template <class TAPosition>
95 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::set_linear_manifold_subsets(MGSubsetHandler& linearManifoldSH,
96 : const char* linearManifoldSubsets)
97 : {
98 0 : m_spLinearManifoldSH = &linearManifoldSH;
99 0 : InitLinearManifoldSubsetHandler(*m_pMG, *m_pSH, *m_spLinearManifoldSH, linearManifoldSubsets);
100 0 : }
101 :
102 : template <class TAPosition>
103 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::assign_position_attachment(TAPosition& aPos)
104 : {
105 : if(TAPosition::ValueType::Size == 1){
106 0 : UG_THROW("Error in GlobalSubdivisionMultiGridRefiner::assign_position_attachment:\n"
107 : "Currently only dimensions 2 and 3 are supported.\n");
108 : }
109 : else
110 0 : m_pAPos = &aPos;
111 0 : }
112 :
113 : template <class TAPosition>
114 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::assign_position_attachment(TAPosition* aPos)
115 : {
116 : if(TAPosition::ValueType::Size == 1){
117 0 : UG_THROW("Error in GlobalSubdivisionMultiGridRefiner::assign_position_attachment:\n"
118 : "Currently only dimensions 2 and 3 are supported.\n");
119 : }
120 : else
121 0 : m_pAPos = aPos;
122 0 : }
123 :
124 : template <class TAPosition>
125 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::nest_hierarchy()
126 : {
127 : if(TAPosition::ValueType::Size == 1){
128 0 : UG_THROW("Error in GlobalSubdivisionMultiGridRefiner::project_to_subdivision_limit:\n"
129 : "Currently only dimensions 2 and 3 are supported.\n");
130 : }
131 :
132 0 : ProjectHierarchyToSubdivisionLimit(*m_pMG, *m_pAPos);
133 0 : }
134 :
135 : template <class TAPosition>
136 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::refinement_step_ends()
137 : {
138 0 : smooth();
139 0 : }
140 :
141 : template <class TAPosition>
142 0 : void GlobalSubdivisionMultiGridRefiner<TAPosition>::smooth()
143 : {
144 : if(TAPosition::ValueType::Size == 1){
145 0 : UG_THROW("Error in GlobalSubdivisionMultiGridRefiner::refinement_step_ends:\n"
146 : "Currently only dimensions 2 and 3 are supported.\n");
147 : }
148 :
149 0 : ApplySmoothSubdivisionVolumesToTopLevel(*m_pMG, *m_pSH, *m_pMarkSH,
150 0 : *m_spLinearManifoldSH, m_bConstrained);
151 0 : }
152 :
153 :
154 : ////////////////////////////////////////////////////////////////////////
155 : // Explicit instantiations
156 : template class GlobalSubdivisionMultiGridRefiner<APosition1>;
157 : template class GlobalSubdivisionMultiGridRefiner<APosition2>;
158 : template class GlobalSubdivisionMultiGridRefiner<APosition>;
159 :
160 :
161 : }// end of namespace
|