MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / parse

Method parse

Src/Particle/AMReX_ParticleHeader.cpp:15–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13namespace amrex {
14
15void
16ParticleHeader::parse (std::istream& is)
17{
18 is >> version;
19 AMREX_ASSERT(!version.empty());
20
21 // What do our version strings mean?
22 // "Version_One_Dot_Zero" -- hard-wired to write out in double precision.
23 // "Version_One_Dot_One" -- can write out either as either single or double precision.
24 // Appended to the latter version string are either "_single" or "_double" to
25 // indicate how the particles were written.
26 // "Version_Two_Dot_Zero" -- this is the AMReX particle file format
27 // "Version_Two_Dot_One" -- expanded particle ids to allow for 2**39-1 per proc
28 convert_ids = false;
29 if (version.find("Version_Two_Dot_One") != std::string::npos) {
30 convert_ids = true;
31 }
32 if (version.find("Version_One_Dot_Zero") != std::string::npos) {
33 how = "double";
34 }
35 else if (version.find("Version_One_Dot_One") != std::string::npos ||
36 version.find("Version_Two_Dot_Zero") != std::string::npos ||
37 version.find("Version_Two_Dot_One") != std::string::npos) {
38 if (version.find("_single") != std::string::npos) {
39 how = "single";
40 }
41 else if (version.find("_double") != std::string::npos) {
42 how = "double";
43 }
44 else {
45 std::string msg("ParticleHeader::parse(): bad version string: ");
46 msg += version;
47 amrex::Error(msg.c_str());
48 }
49 }
50 else {
51 std::string msg("ParticleHeader::parse(): unknown version string: ");
52 msg += version;
53 amrex::Abort(msg.c_str());
54 }
55
56 is >> dim;
57
58 is >> num_real;
59 real_comp_names.resize(num_real);
60 for (int i = 0; i < num_real; ++i) {
61 is >> real_comp_names[i];
62 }
63
64 is >> num_int;
65 int_comp_names.resize(num_int);
66 for (int i = 0; i < num_int; ++i) {
67 is >> int_comp_names[i];
68 }
69
70 is >> is_checkpoint;
71
72 is >> num_particles;

Callers 2

RestartMethod · 0.80
readMethod · 0.80

Calls 3

AbortFunction · 0.85
emptyMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected