MURE
Loading...
Searching...
No Matches
BinaryFormat2.hxx
Go to the documentation of this file.
1/*
2 This file is part of MURE,
3 Copyright (C) 2007-2021 MURE developers.
4
5 MURE is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 MURE is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with MURE. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#ifndef _BINARYFORMAT2_
20#define _BINARYFORMAT2_
21
22#include <fstream>
23using namespace std;
24
40{
42 {
43 Version = 2;
44 }
45 short Version;
46 float Time;
47 float K;
48 float Kerr;
49 float Power;
50 int NCells;
51 void write(ofstream &out);
52 void read(ifstream &in, int version);
53};
54
57{
59 float Volume;
60 float Flux;
61 float FluxErr;
62 float Power;
63 float Burnup;
65 void write(ofstream &out);
66 void read(ifstream &in, int version);
67};
68
71{
72 short Z;
73 short A;
74 short I;
75 float Mass;
76 float Proportion;
78 void write(ofstream &out);
79 void read(ifstream &in, int version);
80};
81
84{
85 short Code;
86 float Sigma;
87 float SigmaErr;
88 void write(ofstream &out);
89 void read(ifstream &in, int version = 1);
90};
91//--------------------------------------------------------
92// Implementation of methods
93//-------------------------------------------------------
94void FileHeader::write(ofstream &out)
95{
96 out.write((char *) & Version, sizeof(Version));
97 out.write((char *) & Time, sizeof(Time));
98 out.write((char *) & K, sizeof(K));
99 out.write((char *) & Kerr, sizeof(Kerr));
100 out.write((char *) & Power, sizeof(Power));
101 out.write((char *) & NCells, sizeof(NCells));
102}
103
104void FileHeader::read(ifstream &in, int version)
105{
106 in.read((char *) & Version, sizeof(Version));
107 in.read((char *) & Time, sizeof(Time));
108 in.read((char *) & K, sizeof(K));
109 in.read((char *) & Kerr, sizeof(Kerr));
110 if(version > 1)
111 in.read((char *) & Power, sizeof(Power));
112 in.read((char *) & NCells, sizeof(NCells));
113}
114
115void CellHeader::write(ofstream &out)
116{
117 out.write((char *) & CellNumber, sizeof(CellNumber));
118 out.write((char *) & Volume, sizeof(Volume));
119 out.write((char *) & Flux, sizeof(Flux));
120 out.write((char *) & FluxErr, sizeof(FluxErr));
121 out.write((char *) & Power, sizeof(Power));
122 out.write((char *) & Burnup, sizeof(Burnup));
123 out.write((char *) & NNucleusRecords, sizeof(NNucleusRecords));
124}
125
126void CellHeader::read(ifstream &in, int version)
127{
128 in.read((char *) & CellNumber, sizeof(CellNumber));
129 in.read((char *) & Volume, sizeof(Volume));
130 in.read((char *) & Flux, sizeof(Flux));
131 in.read((char *) & FluxErr, sizeof(FluxErr));
132 if ( version > 2 )
133 {
134 in.read((char *) & Power, sizeof(Power));
135 in.read((char *) & Burnup, sizeof(Burnup));
136 }
137 else
138 {
139 Power = 0.;
140 Burnup = 0.;
141 }
142
143 in.read((char *) & NNucleusRecords, sizeof(NNucleusRecords));
144}
145
146void NucleusRecord::write(ofstream &out)
147{
148 out.write((char *) & Z, sizeof(Z));
149 out.write((char *) & A, sizeof(A));
150 out.write((char *) & I, sizeof(I));
151 out.write((char *) & Mass, sizeof(Mass));
152 out.write((char *) & Proportion, sizeof(Proportion));
153 out.write((char *) & NReactionRecords, sizeof(NReactionRecords));
154}
155
156void NucleusRecord::read(ifstream &in, int version)
157{
158 in.read((char *) & Z, sizeof(Z));
159 in.read((char *) & A, sizeof(A));
160 in.read((char *) & I, sizeof(I));
161 in.read((char *) & Mass, sizeof(Mass));
162 in.read((char *) & Proportion, sizeof(Proportion));
163 in.read((char *) & NReactionRecords, sizeof(NReactionRecords));
164}
165
166void ReactionRecord::write(ofstream &out)
167{
168 out.write((char *) & Code, sizeof(Code));
169 out.write((char *) & Sigma, sizeof(Sigma));
170 out.write((char *) & SigmaErr, sizeof(SigmaErr));
171}
172
173void ReactionRecord::read(ifstream &in, int version)
174{
175 in.read((char *) & Code, sizeof(Code));
176 in.read((char *) & Sigma, sizeof(Sigma));
177 in.read((char *) & SigmaErr, sizeof(SigmaErr));
178}
179
180
181#endif
the namespace of the Standard C++
Header of an evolving cell in a binary file.
Definition BinaryFormat2.hxx:57
float Volume
Volume of the cell.
Definition BinaryFormat2.hxx:59
int NNucleusRecords
Number of nuclei records in this cell.
Definition BinaryFormat2.hxx:64
void read(ifstream &in, int version)
Read the header from a stream.
Definition BinaryFormat2.hxx:126
float FluxErr
Flux error.
Definition BinaryFormat2.hxx:61
void write(ofstream &out)
Write the header into a stream.
Definition BinaryFormat2.hxx:115
float Burnup
Burnup in cell.
Definition BinaryFormat2.hxx:63
float Power
Power in cell.
Definition BinaryFormat2.hxx:62
float Flux
Flux in this cell.
Definition BinaryFormat2.hxx:60
int CellNumber
MCNP number of this cell.
Definition BinaryFormat2.hxx:58
Header of MURE output binary file.
Definition BinaryFormat2.hxx:40
void read(ifstream &in, int version)
Read the header from a stream.
Definition BinaryFormat2.hxx:104
int NCells
Number of evolving cells.
Definition BinaryFormat2.hxx:50
FileHeader()
Definition BinaryFormat2.hxx:41
float Time
Time of MCNP step at which this file is printed.
Definition BinaryFormat2.hxx:46
float Power
keff error
Definition BinaryFormat2.hxx:49
float K
keff
Definition BinaryFormat2.hxx:47
short Version
Binary gile version.
Definition BinaryFormat2.hxx:45
float Kerr
keff error
Definition BinaryFormat2.hxx:48
void write(ofstream &out)
Write the header into a stream.
Definition BinaryFormat2.hxx:94
Record of a nucleus in a binary file.
Definition BinaryFormat2.hxx:71
short A
Nucleon number of the nucleus.
Definition BinaryFormat2.hxx:73
short Z
Proton number of the nucleus.
Definition BinaryFormat2.hxx:72
void write(ofstream &out)
Write the record into a stream.
Definition BinaryFormat2.hxx:146
float Proportion
Number of this nuclei in cell.
Definition BinaryFormat2.hxx:76
short I
Isomeric state of the nucleus.
Definition BinaryFormat2.hxx:74
void read(ifstream &in, int version)
Read the record from a stream.
Definition BinaryFormat2.hxx:156
short NReactionRecords
Number of reaction records of this nucleus.
Definition BinaryFormat2.hxx:77
float Mass
Atomic mass.
Definition BinaryFormat2.hxx:75
Record of a reaction in a binary file.
Definition BinaryFormat2.hxx:84
float Sigma
Reaction cross-section.
Definition BinaryFormat2.hxx:86
short Code
Reaction code.
Definition BinaryFormat2.hxx:85
void write(ofstream &out)
Write the record into a stream.
Definition BinaryFormat2.hxx:166
void read(ifstream &in, int version=1)
Read the record from a stream.
Definition BinaryFormat2.hxx:173
float SigmaErr
Cross-section error.
Definition BinaryFormat2.hxx:87

MURE Project, documentation generated by Doxygen 1.9.7 - Fri Jan 19 2024