Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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
37namespace ug{
38namespace bridge{
39
42
44// Dimension - Suffix and Tag
46
48template <int dim>
49std::string GetDimensionSuffix()
50{
51// the dimension suffix
52 std::stringstream ss; ss << dim << "d";
53 return ss.str();
54}
55
57template <int dim>
58std::string GetDimensionTag()
59{
60 return std::string("dim=").append(GetDimensionSuffix<dim>()).append(";");
61}
62
64inline 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
76template <typename TDomain>
77std::string GetDomainSuffix(){return GetDimensionSuffix<TDomain::dim>();}
78
80template <typename TDomain>
81std::string GetDomainTag() {return GetDimensionTag<TDomain::dim>();}
82
84// Algebra - Suffix and Tag
86
88template<typename TAlgebraTypeType>
89inline 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
107template <typename TAlgebra>
108std::string GetAlgebraSuffix()
109{
110 return GetAlgebraSuffix(TAlgebra::get_type());
111}
112
114template<typename TAlgebraTypeType>
115inline 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
134template <typename TAlgebra>
135std::string GetAlgebraTag()
136{
137 return GetAlgebraTag(TAlgebra::get_type());
138}
139
141// Dimension + Algebra - Suffix and Tag
143
145template <int dim, typename TAlgebra>
147{
148 std::string dimAlgSuffix = GetDimensionSuffix<dim>();
149 dimAlgSuffix.append(GetAlgebraSuffix<TAlgebra>());
150 return dimAlgSuffix;
151}
152
154template <int dim, typename TAlgebra>
156{
157 std::string dimAlgTag = GetDimensionTag<dim>();
158 dimAlgTag.append(GetAlgebraTag<TAlgebra>());
159 return dimAlgTag;
160}
162template<typename TAlgebraTypeType>
163inline 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
175template <typename TDomain, typename TAlgebra>
176std::string GetDomainAlgebraSuffix(){return GetDimensionAlgebraSuffix<TDomain::dim, TAlgebra>();}
177
179template <typename TDomain, typename TAlgebra>
180std::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 GetAlgebraTag()
returns the algebra-suffix (e.g. "alg=CPU3", "alg=CPUVariable")
Definition suffix_tag.h:135
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 GetDomainSuffix()
returns the dim-suffix for a domain (e.g. "3d")
Definition suffix_tag.h:77
std::string GetAlgebraSuffix()
returns the algebra-suffix (e.g. "CPU3", "CPUFlex")
Definition suffix_tag.h:108
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
#define UG_THROW(msg)
Definition error.h:57
the ug namespace