Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
attachment_io_traits.h
Go to the documentation of this file.
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#ifndef __H__UG_attachment_io_traits
34#define __H__UG_attachment_io_traits
35
36namespace ug{
37
38
39template <class TAttachment>
41 typedef typename TAttachment::ValueType value_type;
44
45 static void write_value (std::ostream& out, const_reference_type v) {out << v;}
46 static void read_value(std::istream& in, reference_type v) {in >> v;}
47};
48
49template <>
51 typedef bool value_type;
54
55 static void write_value (std::ostream& out, const_reference_type v) {out << v;}
56 static void read_value(std::istream& in, reference_type v) {value_type tmp; in >> tmp; v = tmp;}
57};
58
59template <>
64
65 static void write_value (std::ostream& out, const_reference_type v)
66 {
67 out << v[0];
68 }
69 static void read_value(std::istream& in, reference_type v)
70 {
71 in >> v[0];
72 }
73};
74
75
76template <>
81
82 static void write_value (std::ostream& out, const_reference_type v)
83 {
84 out << v[0] << " " << v[1];
85 }
86 static void read_value(std::istream& in, reference_type v)
87 {
88 in >> v[0] >> v[1];
89 }
90};
91
92
93template <>
98
99 static void write_value (std::ostream& out, const_reference_type v)
100 {
101 out << v[0] << " " << v[1] << " " << v[2];
102 }
103 static void read_value(std::istream& in, reference_type v)
104 {
105 in >> v[0] >> v[1] >> v[2];
106 }
107};
108
109
110template <>
115
116 static void write_value (std::ostream& out, const_reference_type v)
117 {
118 out << v[0] << " " << v[1] << " " << v[2] << " " << v[3];
119 }
120 static void read_value(std::istream& in, reference_type v)
121 {
122 in >> v[0] >> v[1] >> v[2] >> v[3];
123 }
124};
125
126
130template <typename T>
137{
138 typedef typename std::vector<T> value_type;
141
142 static void write_value (std::ostream& out, const_reference_type v)
143 {
144 out << v.size() << " ";
145 for (size_t i = 0; i < v.size(); ++i)
147 }
148 static void read_value(std::istream& in, reference_type v)
149 {
150 size_t sz;
151 in >> sz;
152 v.resize(sz);
153 for (size_t i = 0; i < sz; ++i)
155 }
156};
157
158
159}// end of namespace
160
161#endif //__H__UG_attachment_io_traits
A generic specialization of IAttachment.
Definition attachment_pipe.h:263
MathVector< 1, number > vector1
a 1d vector
Definition ugmath_types.h:66
Definition smart_pointer.h:814
the ug namespace
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:53
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:56
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:55
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:52
bool value_type
Definition attachment_io_traits.h:51
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:140
std::vector< T > value_type
Definition attachment_io_traits.h:138
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:148
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:142
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:139
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:62
vector1 value_type
Definition attachment_io_traits.h:61
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:63
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:65
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:69
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:79
vector2 value_type
Definition attachment_io_traits.h:78
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:80
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:82
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:86
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:103
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:99
vector3 value_type
Definition attachment_io_traits.h:95
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:97
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:96
vector4 value_type
Definition attachment_io_traits.h:112
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:116
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:114
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:120
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:113
Definition attachment_io_traits.h:40
static void write_value(std::ostream &out, const_reference_type v)
Definition attachment_io_traits.h:45
static void read_value(std::istream &in, reference_type v)
Definition attachment_io_traits.h:46
attachment_value_traits< value_type >::reference reference_type
Definition attachment_io_traits.h:42
attachment_value_traits< value_type >::const_reference const_reference_type
Definition attachment_io_traits.h:43
TAttachment::ValueType value_type
Definition attachment_io_traits.h:41
TValue & reference
Definition attachment_pipe.h:112
const TValue & const_reference
Definition attachment_pipe.h:113