ug4
suffix_tag.h
Go to the documentation of this file.
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 #ifndef __H__UG_BRIDGE__SUFFIX_TAG__
34 #define __H__UG_BRIDGE__SUFFIX_TAG__
35 
36 
37 namespace ug{
38 namespace bridge{
39 
42 
44 // Dimension - Suffix and Tag
46 
48 template <int dim>
49 std::string GetDimensionSuffix()
50 {
51 // the dimension suffix
52  std::stringstream ss; ss << dim << "d";
53  return ss.str();
54 }
55 
57 template <int dim>
58 std::string GetDimensionTag()
59 {
60  return std::string("dim=").append(GetDimensionSuffix<dim>()).append(";");
61 }
62 
64 inline std::string GetDimensionTag(int dim)
65 {
66 // the dimension tag
67  std::stringstream ss; ss << "dim=" << dim << "d;";
68  return ss.str();
69 }
70 
72 // Domain - Suffix and Tag
74 
76 template <typename TDomain>
77 std::string GetDomainSuffix(){return GetDimensionSuffix<TDomain::dim>();}
78 
80 template <typename TDomain>
81 std::string GetDomainTag() {return GetDimensionTag<TDomain::dim>();}
82 
84 // Algebra - Suffix and Tag
86 
88 template<typename TAlgebraTypeType>
89 inline std::string GetAlgebraSuffix(const TAlgebraTypeType& algType)
90 {
91 // the algebra suffix
92  std::stringstream ss;
93 
94 // add type
95  if(algType.type() == TAlgebraTypeType::CPU) ss << "CPU";
96  else if(algType.type() == TAlgebraTypeType::GPU) ss << "GPU";
97  else UG_THROW("Unknown algebra type.");
98 
99 // add blocktype
100  if(algType.blocksize() == TAlgebraTypeType::VariableBlockSize) ss << "Variable";
101  else ss << algType.blocksize();
102 
103  return ss.str();
104 }
105 
107 template <typename TAlgebra>
108 std::string GetAlgebraSuffix()
109 {
110  return GetAlgebraSuffix(TAlgebra::get_type());
111 }
112 
114 template<typename TAlgebraTypeType>
115 inline std::string GetAlgebraTag(const TAlgebraTypeType& algType)
116 {
117 // the algebra suffix
118  std::stringstream ss; ss << "alg=";
119 
120 // add type
121  if(algType.type() == TAlgebraTypeType::CPU) ss << "CPU";
122  else if(algType.type() == TAlgebraTypeType::GPU) ss << "GPU";
123  else UG_THROW("Unknown algebra type.");
124 
125 // add blocktype
126  if(algType.blocksize() == TAlgebraTypeType::VariableBlockSize) ss << "Variable;";
127  else ss << algType.blocksize() << ";";
128 
129  return ss.str();
130 }
131 
132 
134 template <typename TAlgebra>
135 std::string GetAlgebraTag()
136 {
137  return GetAlgebraTag(TAlgebra::get_type());
138 }
139 
141 // Dimension + Algebra - Suffix and Tag
143 
145 template <int dim, typename TAlgebra>
147 {
148  std::string dimAlgSuffix = GetDimensionSuffix<dim>();
149  dimAlgSuffix.append(GetAlgebraSuffix<TAlgebra>());
150  return dimAlgSuffix;
151 }
152 
154 template <int dim, typename TAlgebra>
156 {
157  std::string dimAlgTag = GetDimensionTag<dim>();
158  dimAlgTag.append(GetAlgebraTag<TAlgebra>());
159  return dimAlgTag;
160 }
162 template<typename TAlgebraTypeType>
163 inline std::string GetDimensionAlgebraTag(int dim, const TAlgebraTypeType& algType)
164 {
165  std::string dimAlgTag = GetDimensionTag(dim);
166  dimAlgTag.append(GetAlgebraTag(algType));
167  return dimAlgTag;
168 }
169 
171 // Domain + Algebra - Suffix and Tag
173 
175 template <typename TDomain, typename TAlgebra>
176 std::string GetDomainAlgebraSuffix(){return GetDimensionAlgebraSuffix<TDomain::dim, TAlgebra>();}
177 
179 template <typename TDomain, typename TAlgebra>
180 std::string GetDomainAlgebraTag(){return GetDimensionAlgebraTag<TDomain::dim, TAlgebra>();}
181 
182 // end group bridge
184 
185 }// end bridge
186 }// end ug
187 
188 #endif /* __H__UG_BRIDGE__SUFFIX_TAG__ */
std::string GetDomainAlgebraSuffix()
returns the dim-suffix for a domain (e.g. "3dCPU1")
Definition: suffix_tag.h:176
std::string GetDomainAlgebraTag()
returns the dim-tag for a domain (e.g. "dim=3d;alg=CPU1;")
Definition: suffix_tag.h:180
std::string GetDimensionAlgebraSuffix()
returns the algebra-dim-suffix for a domain (e.g. "3dCPU1")
Definition: suffix_tag.h:146
std::string GetDimensionSuffix()
returns the dim-suffix for a domain (e.g. "3d")
Definition: suffix_tag.h:49
std::string GetAlgebraTag(const TAlgebraTypeType &algType)
returns the algebra-suffix (e.g. "alg=CPU3", "alg=CPUVariable")
Definition: suffix_tag.h:115
std::string GetDomainSuffix()
returns the dim-suffix for a domain (e.g. "3d")
Definition: suffix_tag.h:77
std::string GetAlgebraSuffix(const TAlgebraTypeType &algType)
returns the algebra-suffix (e.g. "CPU3", "CPUFlex")
Definition: suffix_tag.h:89
std::string GetDomainTag()
returns the dim-tag for a domain (e.g. "dim=3d")
Definition: suffix_tag.h:81
std::string GetDimensionTag()
returns the dim-tag for a domain (e.g. "dim=3d")
Definition: suffix_tag.h:58
std::string GetDimensionAlgebraTag()
returns the dim-tag for a domain (e.g. "dim=3d;alg=CPU1;")
Definition: suffix_tag.h:155
static const int dim
#define UG_THROW(msg)
Definition: error.h:57
the ug namespace