Line data Source code
1 : /*
2 : * Copyright (c) 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 : #include "grid_bridges.h"
34 : #include "common/profiler/profiler.h"
35 : #include "lib_grid/multi_grid.h"
36 : #include "lib_grid/file_io/file_io.h"
37 : #include "lib_grid/file_io/file_io_ugx.h"
38 :
39 : using namespace std;
40 :
41 : namespace ug{
42 : namespace bridge{
43 :
44 0 : bool LoadGrid(Grid& grid, ISubsetHandler& sh, const char* filename)
45 : {
46 : PROFILE_FUNC_GROUP("grid");
47 0 : return LoadGridFromFile(grid, sh, filename);
48 : }
49 :
50 0 : bool LoadGrid(Grid& grid, const char* filename)
51 : {
52 : PROFILE_FUNC_GROUP("grid");
53 0 : return LoadGridFromFile(grid, filename);
54 : }
55 :
56 0 : bool SaveGrid(Grid& grid, const char* filename)
57 : {
58 : PROFILE_FUNC_GROUP("grid");
59 0 : return SaveGridToFile(grid, filename);
60 : }
61 :
62 0 : bool SaveGrid(Grid& grid, ISubsetHandler& sh, const char* filename)
63 : {
64 : PROFILE_FUNC_GROUP("grid");
65 0 : return SaveGridToFile(grid, sh, filename);
66 : }
67 :
68 0 : bool SaveGrid(Grid& grid, const ISubsetHandler& sh, const char* filename)
69 : {
70 : PROFILE_FUNC_GROUP("grid");
71 0 : return SaveGridToFile(grid, *const_cast<ISubsetHandler*>(&sh), filename);
72 : }
73 :
74 0 : bool SaveGridHierarchy(MultiGrid& mg, const char* filename)
75 : {
76 : PROFILE_FUNC_GROUP("grid");
77 0 : return SaveGridToFile(mg, mg.get_hierarchy_handler(), filename);
78 : }
79 :
80 :
81 1 : void RegisterGridBridge_FileIO(Registry& reg, string parentGroup)
82 : {
83 : string grp = parentGroup;
84 :
85 : // UGXFileInfo
86 3 : reg.add_class_<UGXFileInfo>("UGXFileInfo", grp)
87 1 : .add_constructor()
88 2 : .add_method("parse_file", &UGXFileInfo::parse_file, "", "filename")
89 2 : .add_method("num_grids", &UGXFileInfo::num_grids)
90 2 : .add_method("num_subset_handlers", &UGXFileInfo::num_subset_handlers)
91 2 : .add_method("num_subsets", &UGXFileInfo::num_subsets)
92 2 : .add_method("grid_name", &UGXFileInfo::grid_name, "grid name", "gridInd")
93 2 : .add_method("subset_handler_name", &UGXFileInfo::subset_handler_name, "", "gridInd#shInd")
94 2 : .add_method("subset_name", &UGXFileInfo::subset_name, "", "gridInd#shInd#subsetInd")
95 2 : .add_method("grid_has_volumes", &UGXFileInfo::grid_has_volumes, "", "gridInd")
96 2 : .add_method("grid_has_faces", &UGXFileInfo::grid_has_faces, "", "gridInd")
97 2 : .add_method("grid_has_edges", &UGXFileInfo::grid_has_edges, "", "gridInd")
98 2 : .add_method("grid_has_vertices", &UGXFileInfo::grid_has_vertices, "", "gridInd")
99 2 : .add_method("physical_grid_dimension", &UGXFileInfo::physical_grid_dimension, "", "gridInd")
100 2 : .add_method("topological_grid_dimension", &UGXFileInfo::topological_grid_dimension, "", "gridInd")
101 2 : .add_method("grid_world_dimension", &UGXFileInfo::grid_world_dimension, "", "gridInd")
102 1 : .set_construct_as_smart_pointer(true);
103 :
104 : // GridObject functions
105 3 : reg.add_function("LoadGrid", static_cast<bool (*)(Grid&, ISubsetHandler&, const char*)>(&LoadGrid), grp,
106 : "", "grid#sh#filename")
107 3 : .add_function("LoadGrid", static_cast<bool (*)(Grid&, const char*)>(&LoadGrid), grp,
108 : "", "grid#filename")
109 3 : .add_function("SaveGrid", static_cast<bool (*)(Grid&, const ISubsetHandler&, const char*)>(&SaveGrid), grp,
110 : "", "grid#sh#filename")
111 3 : .add_function("SaveGrid", static_cast<bool (*)(Grid&, ISubsetHandler&, const char*)>(&SaveGrid), grp,
112 : "", "grid#sh#filename")
113 3 : .add_function("SaveGrid", static_cast<bool (*)(Grid&, const char*)>(&SaveGrid), grp,
114 : "", "grid#filename")
115 : // .add_function("LoadGridObject", &LoadGridObject, grp,
116 : // "", "go#filename")
117 : // .add_function("SaveGridObject", &SaveGridObject, grp,
118 : // "", "go#filename")
119 3 : .add_function("SaveGridHierarchy", &SaveGridHierarchy, grp,
120 : "", "mg#filename")
121 3 : .add_function("SaveGridHierarchyTransformed",
122 : static_cast<bool (*)(MultiGrid&, ISubsetHandler&, const char*, number)>(
123 : &SaveGridHierarchyTransformed),
124 : grp, "", "mg#sh#filename#offset")
125 3 : .add_function("SaveGridHierarchyTransformed",
126 : static_cast<bool (*)(MultiGrid&, const char*, number)>(
127 : &SaveGridHierarchyTransformed),
128 : grp, "", "mg#filename#offset")
129 3 : .add_function("SaveParallelGridLayout", &SaveParallelGridLayout,
130 : grp, "", "mg#filename#offset")
131 2 : .add_function("SaveSurfaceViewTransformed", &SaveSurfaceViewTransformed)
132 2 : .add_function("SaveGridLevelToFile", &SaveGridLevelToFile);
133 1 : }
134 :
135 : }// end of namespace
136 : }// end of namespace
|