-
Notifications
You must be signed in to change notification settings - Fork 441
Expand file tree
/
Copy pathAMReX_RealVect.cpp
More file actions
62 lines (53 loc) · 1.18 KB
/
AMReX_RealVect.cpp
File metadata and controls
62 lines (53 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#include <AMReX_RealVect.H>
#include <iostream>
/// \cond DOXYGEN_IGNORE
namespace amrex::detail {
std::ostream&
real_vector_write (std::ostream& os, const Real* p, int dim)
{
os << '(' << p[0];
for (int i=1; i<dim; ++i) {
os << ',' << p[i];
}
os << ')';
if (os.fail()) {
amrex::Error("operator<<(ostream&,RealVect&) failed");
}
return os;
}
#define BL_IGNORE_MAX 100000
std::istream&
real_vector_read (std::istream& is, Real* p, int dim)
{
is >> std::ws;
char c;
is >> c;
for (int i=0; i<dim; ++i) {
p[i] = 0;
}
if (c == '(')
{
is >> p[0];
for (int i=1; i<dim; ++i) {
is >> std::ws;
int ic = is.peek();
if (ic == static_cast<int>(',')) {
is.ignore(BL_IGNORE_MAX, ',');
is >> p[i];
continue;
}
break;
}
is.ignore(BL_IGNORE_MAX, ')');
}
else
{
amrex::Error("operator>>(istream&,RealVect&): expected \'(\'");
}
if (is.fail()) {
amrex::Error("operator>>(istream&,RealVect&) failed");
}
return is;
}
} //namespace amrex::detail
/// \endcond