Line data Source code
1 : /*
2 : * Copyright (c) 2012-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 : // extern headers
34 : #include <iostream>
35 : #include <sstream>
36 : #include <string>
37 :
38 : // include bridge
39 : #include "bridge/bridge.h"
40 : #include "bridge/util.h"
41 : #include "bridge/util_domain_dependent.h"
42 : #include "bridge/util_domain_algebra_dependent.h"
43 :
44 : // lib_disc includes
45 : #include "lib_disc/domain.h"
46 : //#include "lib_disc/function_spaces/approximation_space.h"
47 :
48 : // ordering algorithms
49 : #include "lib_disc/ordering_strategies/algorithms/ordering_algorithms.cpp"
50 :
51 : #include "lib_disc/ordering_strategies/io_grid_points_ordering.cpp"
52 : #include "lib_disc/ordering_strategies/io_grid_function_ordering.cpp"
53 : #include "lib_disc/ordering_strategies/io_sorted_grid_function_ordering.cpp"
54 :
55 : using namespace std;
56 :
57 : namespace ug{
58 : namespace bridge{
59 : namespace Ordering{
60 :
61 : /**
62 : * \defgroup ordering_bridge Ordering Bridge
63 : * \ingroup disc_bridge
64 : * \{
65 : */
66 :
67 : /**
68 : * Class exporting the functionality. All functionality that is to
69 : * be used in scripts or visualization must be registered here.
70 : */
71 : struct Functionality
72 : {
73 :
74 : /**
75 : * Function called for the registration of Domain and Algebra dependent parts.
76 : * All Functions and Classes depending on both Domain and Algebra
77 : * are to be placed here when registering. The method is called for all
78 : * available Domain and Algebra types, based on the current build options.
79 : *
80 : * @param reg registry
81 : * @param parentGroup group for sorting of functionality
82 : */
83 : template <typename TDomain, typename TAlgebra>
84 9 : static void DomainAlgebra(Registry& reg, string grp)
85 : {
86 : string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
87 : string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
88 :
89 : typedef ug::GridFunction<TDomain, TAlgebra> TFct;
90 :
91 : typedef std::vector<size_t> ordering_container_type;
92 :
93 : typedef ug::GridFunction<TDomain, TAlgebra> TFct;
94 :
95 : typedef SmartPtr<UserData<MathVector<TDomain::dim>, TDomain::dim> > TSpUserData;
96 : typedef MathVector<TDomain::dim> small_vec_t;
97 :
98 : // Lexicographic ordering
99 : {
100 : typedef LexOrdering<TAlgebra, TDomain, ordering_container_type> T;
101 : typedef IOrderingAlgorithm<TAlgebra, ordering_container_type> TBase;
102 9 : string name = string("LexOrdering").append(suffix);
103 27 : reg.add_class_<T, TBase>(name, grp, "LexOrdering")
104 9 : .add_constructor()
105 18 : .add_method("set_direction", &T::set_direction)
106 9 : .set_construct_as_smart_pointer(true);
107 27 : reg.add_class_to_group(name, "LexOrdering", tag);
108 : }
109 :
110 : // River ordering (topological ordering beginning at selected sources)
111 : {
112 : typedef RiverOrdering<TAlgebra, TDomain, ordering_container_type> T;
113 : typedef IOrderingAlgorithm<TAlgebra, ordering_container_type> TBase;
114 9 : string name = string("RiverOrdering").append(suffix);
115 27 : reg.add_class_<T, TBase>(name, grp, "RiverOrdering")
116 9 : .add_constructor()
117 18 : .add_method("select_sources", static_cast<void (T::*)(const char*)>(&T::select_sources))
118 9 : .set_construct_as_smart_pointer(true);
119 27 : reg.add_class_to_group(name, "RiverOrdering", tag);
120 : }
121 :
122 : // Directional ordering
123 : {
124 : typedef DirectionalOrdering<TAlgebra, TDomain, ordering_container_type> T;
125 : typedef IOrderingAlgorithm<TAlgebra, ordering_container_type> TBase;
126 9 : string name = string("DirectionalOrdering").append(suffix);
127 27 : reg.add_class_<T, TBase>(name, grp, "DirectionalOrdering")
128 9 : .add_constructor()
129 : //.add_method("set_direction", static_cast<void (T::*)(const char*)>(&T::set_direction))
130 : //.add_method("set_direction", static_cast<void (T::*)(TSpUserData)>(&T::set_direction))
131 18 : .add_method("set_direction", static_cast<void (T::*)(small_vec_t*)>(&T::set_direction))
132 9 : .set_construct_as_smart_pointer(true);
133 27 : reg.add_class_to_group(name, "DirectionalOrdering", tag);
134 : }
135 :
136 : /* IO */
137 :
138 : // GridPointsOrdering
139 : {
140 : typedef GridPointsOrdering<TDomain, TAlgebra> T;
141 9 : string name = string("GridPointsOrdering").append(suffix);
142 27 : reg.add_class_<T>(name, grp)
143 18 : .template add_constructor<void (*)(SmartPtr<TFct>, const char*)>("GridPointsOrdering")
144 18 : .add_method("get", &T::get)
145 9 : .set_construct_as_smart_pointer(true);
146 27 : reg.add_class_to_group(name, "GridPointsOrdering", tag);
147 : }
148 :
149 : // GridFunctionOrdering
150 : {
151 : typedef GridFunctionOrdering<TDomain, TAlgebra> T;
152 9 : string name = string("GridFunctionOrdering").append(suffix);
153 27 : reg.add_class_<T>(name, grp)
154 18 : .template add_constructor<void (*)(SmartPtr<TFct>, const char*)>("GridFunctionOrdering")
155 18 : .add_method("get", &T::get)
156 9 : .set_construct_as_smart_pointer(true);
157 27 : reg.add_class_to_group(name, "GridFunctionOrdering", tag);
158 : }
159 :
160 : // SortedGridFunctionOrdering
161 : {
162 : typedef SortedGridFunctionOrdering<TDomain, TAlgebra> T;
163 : typedef IOrderingAlgorithm<TAlgebra, ordering_container_type> TOrdAlgo;
164 9 : string name = string("SortedGridFunctionOrdering").append(suffix);
165 27 : reg.add_class_<T>(name, grp)
166 18 : .template add_constructor<void (*)(SmartPtr<TFct>, SmartPtr<TOrdAlgo>, const char*)>("SortedGridFunctionOrdering")
167 18 : .add_method("get", &T::get)
168 9 : .set_construct_as_smart_pointer(true);
169 27 : reg.add_class_to_group(name, "SortedGridFunctionOrdering", tag);
170 : }
171 9 : }
172 :
173 : /**
174 : * Function called for the registration of Domain dependent parts.
175 : * All Functions and Classes depending on the Domain
176 : * are to be placed here when registering. The method is called for all
177 : * available Domain types, based on the current build options.
178 : *
179 : * @param reg registry
180 : * @param parentGroup group for sorting of functionality
181 : */
182 : template <typename TDomain>
183 3 : static void Domain(Registry& reg, string grp)
184 : {
185 : string suffix = GetDomainSuffix<TDomain>();
186 : string tag = GetDomainTag<TDomain>();
187 : typedef ApproximationSpace<TDomain> approximation_space_type;
188 :
189 : // group string
190 3 : grp.append("/ApproximationSpace");
191 :
192 : // Order Cuthill-McKee
193 : {
194 9 : reg.add_function("OrderCuthillMcKee", static_cast<void (*)(approximation_space_type&, bool)>(&OrderCuthillMcKee), grp);
195 : }
196 :
197 : // Order lexicographically
198 : {
199 9 : reg.add_function("OrderLex", static_cast<void (*)(approximation_space_type&, const char*)>(&OrderLex<TDomain>), grp);
200 : }
201 : // Order in downwind direction
202 : {
203 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, SmartPtr<UserData<MathVector<TDomain::dim>, TDomain::dim> >)> (&ug::OrderDownwind<TDomain>), grp);
204 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, const std::vector<number>&)>(&ug::OrderDownwind<TDomain>), grp);
205 :
206 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, SmartPtr<UserData<MathVector<TDomain::dim>, TDomain::dim> >, number)> (&ug::OrderDownwind<TDomain>), grp);
207 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, const std::vector<number>&, number)>(&ug::OrderDownwind<TDomain>), grp);
208 :
209 : #ifdef UG_FOR_LUA
210 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, const char*)>(&ug::OrderDownwind<TDomain>), grp);
211 9 : reg.add_function("OrderDownwind", static_cast<void (*)(approximation_space_type&, const char*, number)>(&ug::OrderDownwind<TDomain>), grp);
212 : #endif
213 : }
214 :
215 3 : }
216 :
217 : /**
218 : * Function called for the registration of Dimension dependent parts.
219 : * All Functions and Classes depending on the Dimension
220 : * are to be placed here when registering. The method is called for all
221 : * available Dimension types, based on the current build options.
222 : *
223 : * @param reg registry
224 : * @param parentGroup group for sorting of functionality
225 : */
226 : template <int dim>
227 : static void Dimension(Registry& reg, string grp)
228 : {
229 : string suffix = GetDimensionSuffix<dim>();
230 : string tag = GetDimensionTag<dim>();
231 :
232 : }
233 :
234 : /**
235 : * Function called for the registration of Algebra dependent parts.
236 : * All Functions and Classes depending on Algebra
237 : * are to be placed here when registering. The method is called for all
238 : * available Algebra types, based on the current build options.
239 : *
240 : * @param reg registry
241 : * @param parentGroup group for sorting of functionality
242 : */
243 : template <typename TAlgebra>
244 : static void Algebra(Registry& reg, string grp)
245 : {
246 : string suffix = GetAlgebraSuffix<TAlgebra>();
247 : string tag = GetAlgebraTag<TAlgebra>();
248 :
249 : }
250 :
251 : /**
252 : * Function called for the registration of Domain and Algebra independent parts.
253 : * All Functions and Classes not depending on Domain and Algebra
254 : * are to be placed here when registering.
255 : *
256 : * @param reg registry
257 : * @param parentGroup group for sorting of functionality
258 : */
259 : static void Common(Registry& reg, string grp)
260 : {}
261 :
262 : }; // end Functionality
263 :
264 : // end group ordering_bridge
265 : /// \}
266 :
267 : }// namespace Ordering
268 :
269 : /// \addtogroup ordering_bridge
270 1 : void RegisterBridge_Ordering(Registry& reg, string grp)
271 : {
272 1 : grp.append("/Discretization");
273 : typedef Ordering::Functionality Functionality;
274 :
275 : try{
276 : //RegisterCommon<Functionality>(reg,grp);
277 : // RegisterDimensionDependent<Functionality>(reg,grp);
278 2 : RegisterDomainDependent<Functionality>(reg,grp);
279 : // RegisterAlgebraDependent<Functionality>(reg,grp);
280 1 : RegisterDomainAlgebraDependent<Functionality>(reg,grp);
281 : }
282 0 : UG_REGISTRY_CATCH_THROW(grp);
283 1 : }
284 :
285 : }// end of namespace bridge
286 : }// end of namespace ug
|