Line data Source code
1 : /*
2 : * Copyright (c) 2010-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_algebra_dependent.h"
42 :
43 : // lib_disc includes
44 : #include "lib_disc/domain.h"
45 : #include "lib_disc/spatial_disc/domain_disc.h"
46 : #include "lib_disc/spatial_disc/dom_disc_embb.h"
47 : #include "lib_disc/parallelization/domain_distribution.h"
48 : #include "lib_disc/function_spaces/grid_function.h"
49 :
50 :
51 : using namespace std;
52 :
53 : namespace ug{
54 : namespace bridge{
55 : namespace DomainDisc{
56 :
57 : /**
58 : * \defgroup domaindisc_bridge Domain Discretization Bridge
59 : * \ingroup disc_bridge
60 : * \{
61 : */
62 :
63 : /**
64 : * Class exporting the functionality. All functionality that is to
65 : * be used in scripts or visualization must be registered here.
66 : */
67 : struct Functionality
68 : {
69 :
70 : /**
71 : * Function called for the registration of Domain and Algebra dependent parts.
72 : * All Functions and Classes depending on both Domain and Algebra
73 : * are to be placed here when registering. The method is called for all
74 : * available Domain and Algebra types, based on the current build options.
75 : *
76 : * @param reg registry
77 : * @param parentGroup group for sorting of functionality
78 : */
79 : template <typename TDomain, typename TAlgebra>
80 9 : static void DomainAlgebra(Registry& reg, string grp)
81 : {
82 : string suffix = GetDomainAlgebraSuffix<TDomain,TAlgebra>();
83 : string tag = GetDomainAlgebraTag<TDomain,TAlgebra>();
84 :
85 : // group string
86 9 : string approxGrp = grp; approxGrp.append("/ApproximationSpace");
87 9 : string domDiscGrp = grp; domDiscGrp.append("/SpatialDisc");
88 :
89 : // DomainDiscretization
90 : {
91 : typedef IDomainDiscretization<TAlgebra> TBase;
92 : typedef DomainDiscretization<TDomain, TAlgebra> T;
93 9 : string name = string("DomainDiscretization").append(suffix);
94 27 : reg.add_class_<T, TBase>(name, domDiscGrp)
95 18 : .template add_constructor<void (*)(SmartPtr<ApproximationSpace<TDomain> >)>("ApproximationSpace")
96 27 : .add_method("add", static_cast<void (T::*)(SmartPtr<IDomainConstraint<TDomain, TAlgebra> >)>(&T::add), "", "Post Process")
97 36 : .add_method("remove", static_cast<void (T::*)(SmartPtr<IDomainConstraint<TDomain, TAlgebra> >)>(&T::remove), "", "Post Process")
98 36 : .add_method("add", static_cast<void (T::*)(SmartPtr<IElemDisc<TDomain> >)>(&T::add), "", "Element Discretization")
99 36 : .add_method("remove", static_cast<void (T::*)(SmartPtr<IElemDisc<TDomain> >)>(&T::remove), "", "Element Discretization")
100 36 : .add_method("add", static_cast<void (T::*)(SmartPtr<IDiscretizationItem<TDomain, TAlgebra> >)>(&T::add), "", "DiscItem")
101 36 : .add_method("init_all_exports", static_cast<void (T::*)(bool)>(&T::init_all_exports))
102 36 : .add_method("assemble_linear", static_cast<void (T::*)(typename TAlgebra::matrix_type&, GridFunction<TDomain, TAlgebra>&)>(&T::assemble_linear))
103 36 : .add_method("assemble_rhs", static_cast<void (T::*)(typename TAlgebra::vector_type&, GridFunction<TDomain, TAlgebra>&)>(&T::assemble_rhs))
104 36 : .add_method("assemble_rhs", static_cast<void (T::*)(GridFunction<TDomain, TAlgebra>&)>(&T::assemble_rhs))
105 36 : .add_method("adjust_solution", static_cast<void (T::*)(GridFunction<TDomain, TAlgebra>&)>(&T::adjust_solution))
106 : // error indicator
107 36 : .add_method("add_elem_error_indicator", &T::add_elem_error_indicator, "","OPTIONAL: Add element-wise error indicator")
108 36 : .add_method("remove_elem_error_indicator", &T::remove_elem_error_indicator, "","OPTIONAL: Remove element-wise error indicator")
109 36 : .add_method("calc_error", static_cast<void (T::*)(const GridFunction<TDomain, TAlgebra>&)>(&T::calc_error), "", "Calculate element-wise error indicators from error estimator")
110 36 : .add_method("calc_error", static_cast<void (T::*)(const GridFunction<TDomain, TAlgebra>&, typename CPUAlgebra::vector_type*)>(&T::calc_error), "", "Calculate element-wise error indicators from error estimator")
111 36 : .add_method("mark_with_strategy", &T::mark_with_strategy)
112 36 : .add_method("invalidate_error", &T::invalidate_error, "", "Marks error indicators as invalid, "
113 : "which will prohibit refining and coarsening before a new call to calc_error.")
114 36 : .add_method("is_error_valid", &T::is_error_valid, "", "Returns whether error values are valid")
115 36 : .add_method("ass_tuner", static_cast<SmartPtr<AssemblingTuner<TAlgebra> > (T::*) ()> (&T::ass_tuner), "assembling tuner", "", "get this domain discretization's assembling tuner")
116 36 : .add_method("approximation_space", static_cast<SmartPtr<ApproximationSpace<TDomain> > (T::*) ()> (&T::approximation_space), "approximation space", "", "get this domain discretization's approximation space")
117 27 : .add_method("approximation_space", static_cast<ConstSmartPtr<ApproximationSpace<TDomain> > (T::*) () const> (&T::approximation_space), "approximation space", "", "get this domain discretization's approximation space")
118 9 : .set_construct_as_smart_pointer(true);
119 27 : reg.add_class_to_group(name, "DomainDiscretization", tag);
120 : }
121 :
122 : // IDiscretizationItem
123 : {
124 : typedef IDiscretizationItem<TDomain, TAlgebra> T;
125 9 : string name = string("IDiscretizationItem").append(suffix);
126 27 : reg.add_class_<T>(name, domDiscGrp);
127 27 : reg.add_class_to_group(name, "IDiscretizationItem", tag);
128 : }
129 :
130 : // IInterfaceExtrapolation
131 : {
132 : typedef IInterfaceExtrapolation<TDomain, TAlgebra> T;
133 9 : string name = string("IInterfaceExtrapolation").append(suffix);
134 27 : reg.add_class_<T>(name,grp);
135 27 : reg.add_class_to_group(name, "IInterfaceExtrapolation", tag);
136 : }
137 9 : }
138 :
139 : /**
140 : * Function called for the registration of Domain dependent parts.
141 : * All Functions and Classes depending on the Domain
142 : * are to be placed here when registering. The method is called for all
143 : * available Domain types, based on the current build options.
144 : *
145 : * @param reg registry
146 : * @param parentGroup group for sorting of functionality
147 : */
148 : template <typename TDomain>
149 3 : static void Domain(Registry& reg, string grp)
150 : {
151 : string suffix = GetDomainSuffix<TDomain>();
152 : string tag = GetDomainTag<TDomain>();
153 :
154 : // group string
155 3 : string domDiscGrp = grp; domDiscGrp.append("/SpatialDisc");
156 :
157 :
158 : // IErrEstData
159 : {
160 : typedef IErrEstData<TDomain> T;
161 3 : string name = string("IErrEstData").append(suffix);
162 9 : reg.add_class_<T>(name, domDiscGrp)
163 9 : .add_method("set_consider_me", &T::set_consider_me, "", "", "", "")
164 9 : .add_method("set_scaling_factor", &T::set_scaling_factor, "", "", "", "");
165 9 : reg.add_class_to_group(name, "ErrEstData", tag);
166 : }
167 :
168 : // SideFluxErrEstData
169 : {
170 : typedef SideFluxErrEstData<TDomain> T;
171 : typedef IErrEstData<TDomain> TBase;
172 3 : string name = string("SideFluxErrEstData").append(suffix);
173 9 : reg.add_class_<T, TBase>(name, domDiscGrp)
174 6 : .template add_constructor<void (*) ()>()
175 3 : .set_construct_as_smart_pointer(true);
176 9 : reg.add_class_to_group(name, "SideFluxErrEstData", tag);
177 : }
178 :
179 : // SideAndElemErrEstData
180 : {
181 : typedef SideAndElemErrEstData<TDomain> T;
182 : typedef IErrEstData<TDomain> TBase;
183 3 : string name = string("SideAndElemErrEstData").append(suffix);
184 9 : reg.add_class_<T, TBase>(name, domDiscGrp)
185 : .template add_constructor<void (*) (std::size_t, std::size_t)>
186 6 : ("integration order for sides#integration order for elements", "", "", "")
187 : .template add_constructor<void (*) (std::size_t, std::size_t, const char*)>
188 6 : ("integration order for sides#integration order for elements#subsets considered", "", "", "")
189 : .template add_constructor<void (*) (std::size_t, std::size_t, std::vector<std::string>)>
190 6 : ("integration order for sides#integration order for elements#subsets considered", "", "", "")
191 6 : .add_method("set_type", &T::set_type, "", "", "", "")
192 3 : .set_construct_as_smart_pointer(true);
193 9 : reg.add_class_to_group(name, "SideAndElemErrEstData", tag);
194 : }
195 :
196 : // MultipleSideAndElemErrEstData
197 : {
198 : typedef MultipleSideAndElemErrEstData<TDomain> T;
199 : typedef IErrEstData<TDomain> TBase;
200 3 : string name = string("MultipleSideAndElemErrEstData").append(suffix);
201 9 : reg.add_class_<T, TBase>(name, domDiscGrp)
202 6 : .template add_constructor<void (*) (ConstSmartPtr<ApproximationSpace<TDomain> >)> ()
203 6 : .add_method("add", static_cast<void (T::*)(SmartPtr<SideAndElemErrEstData<TDomain> >, const char* )>(&T::add),
204 : "ErrEstData object", "", "Add existing ErrEstData objects one at a time. "
205 : "+++ TAKE CARE: The order matters! +++ "
206 : "ElemDiscs given this object can access the underlying error estimator "
207 : "data objects in the order of addition.", "")
208 3 : .set_construct_as_smart_pointer(true);
209 9 : reg.add_class_to_group(name, "MultipleSideAndElemErrEstData", tag);
210 : }
211 3 : }
212 :
213 : /**
214 : * Function called for the registration of Dimension dependent parts.
215 : * All Functions and Classes depending on the Dimension
216 : * are to be placed here when registering. The method is called for all
217 : * available Dimension types, based on the current build options.
218 : *
219 : * @param reg registry
220 : * @param parentGroup group for sorting of functionality
221 : */
222 : template <int dim>
223 : static void Dimension(Registry& reg, string grp)
224 : {
225 : string suffix = GetDimensionSuffix<dim>();
226 : string tag = GetDimensionTag<dim>();
227 :
228 : }
229 :
230 : /**
231 : * Function called for the registration of Algebra dependent parts.
232 : * All Functions and Classes depending on Algebra
233 : * are to be placed here when registering. The method is called for all
234 : * available Algebra types, based on the current build options.
235 : *
236 : * @param reg registry
237 : * @param parentGroup group for sorting of functionality
238 : */
239 : template <typename TAlgebra>
240 3 : static void Algebra(Registry& reg, string grp)
241 : {
242 3 : string suffix = GetAlgebraSuffix<TAlgebra>();
243 3 : string tag = GetAlgebraTag<TAlgebra>();
244 :
245 : // AssemblingTuner
246 : {
247 : typedef AssemblingTuner<TAlgebra> T;
248 3 : std::string name = string("AssTuner");
249 9 : reg.add_class_<T>(name+suffix, grp)
250 9 : .add_method("set_matrix_is_const", &T::set_matrix_is_const, "",
251 : "whether matrix is constant in time", "")
252 9 : .add_method("set_matrix_structure_is_const", &T::set_matrix_structure_is_const, "",
253 : "whether matrix has constant in time structure", "")
254 3 : .set_construct_as_smart_pointer(true);
255 6 : reg.add_class_to_group(name+suffix, name, tag);
256 : }
257 3 : }
258 :
259 : /**
260 : * Function called for the registration of Domain and Algebra independent parts.
261 : * All Functions and Classes not depending on Domain and Algebra
262 : * are to be placed here when registering.
263 : *
264 : * @param reg registry
265 : * @param parentGroup group for sorting of functionality
266 : */
267 : static void Common(Registry& reg, string grp)
268 : {
269 : // group string
270 : string domDiscGrp = grp; domDiscGrp.append("/SpatialDisc");
271 : }
272 :
273 : }; // end Functionality
274 :
275 : // end group domaindisc_bridge
276 : /// \}
277 :
278 : }// namespace DomainDisc
279 :
280 : /// \addtogroup domaindisc_bridge
281 1 : void RegisterBridge_DomainDisc(Registry& reg, string grp)
282 : {
283 1 : grp.append("/Discretization");
284 : typedef DomainDisc::Functionality Functionality;
285 :
286 : try{
287 : // RegisterCommon<Functionality>(reg,grp);
288 : // RegisterDimensionDependent<Functionality>(reg,grp);
289 2 : RegisterDomainDependent<Functionality>(reg,grp);
290 2 : RegisterAlgebraDependent<Functionality>(reg,grp);
291 1 : RegisterDomainAlgebraDependent<Functionality>(reg,grp);
292 : }
293 0 : UG_REGISTRY_CATCH_THROW(grp);
294 1 : }
295 :
296 : }// end of namespace bridge
297 : }// end of namespace ug
|