30 const std::string& filename
32 h5_prop_t props = H5CreateFileProp ();
34 if (H5SetPropFileMPIOCollective (props, &comm) == H5_ERR) {
36 "_FM3DH5BlockBase::openFileMPIOCollective () ",
37 "Cannot set MPIO collective!");
39 file_m = H5OpenFile (filename.c_str(), H5_O_RDONLY, props);
40 if (
file_m == (h5_file_t)H5_ERR) {
42 "_FM3DH5BlockBase::openFileMPIOCollective () ",
43 "Cannot open file '" + filename +
"'!");
49 long long num_steps = H5GetNumSteps(
file_m);
53 "_FM3DH5BlockBase::getNumSteps () ",
54 "Number of time-steps in file '" +
Filename_m +
"' is zero!");
57 "_FM3DH5BlockBase::getNumSteps () ",
58 "Query number of time-steps in file '" +
Filename_m +
"' failed!");
65 if (H5SetStep(
file_m, step) == H5_ERR) {
67 "_FM3DH5BlockBase::setStep () ",
68 "Cannot set time-step to " + std::to_string (step) +
77 h5_size_t grid_dims[3];
80 if (H5BlockGetFieldInfoByName (
82 &grid_rank, grid_dims, &field_dims, &ftype
85 "_FM3DH5BlockBase::GetFieldInfo () ",
86 "Query of field info for " + std::string (
name) +
87 " in time-step " + std::to_string (last_step) +
94 if (H5Block3dGetFieldSpacing (
98 "_FM3DH5BlockBase::GetFieldInfo () ",
99 "Query of field spacing"
100 " in time-step " + std::to_string (last_step) +
108 if (H5Block3dGetFieldOrigin(
111 "_FM3DH5BlockBase::GetFieldInfo () ",
112 "Query of field origin"
113 " in time-step " + std::to_string (last_step) +
122 if (H5ReadFileAttribFloat64 (
126 "_FM3DH5BlockBase::GetResonanceFrequency () ",
127 "Cannot read file attribute 'Resonance Frequency(Hz)'"
139 if (H5Block3dSetView(
file_m,
144 "_FM3DH5BlockBase::ReadField () ",
151 if (H5Block3dReadVector3dFieldFloat64 (
154 x, y, z) == H5_ERR) {
156 "_FM3DH5BlockBase::ReadField () ",
157 "Cannot read field " + std::string (
name) +
167 const std::size_t n = x.
size ();
170 const std::size_t
begin = n * rank / nodes;
171 const std::size_t
end = n * (rank + 1) / nodes;
177 MPI_Allreduce (&local, &global, 1, MPI_INT, MPI_MAX,
Ippl::getComm ());
182 if (H5CloseFile (
file_m) == H5_ERR) {
184 "_FM3DH5BlockBase::closeFile () ",
192 unsigned short corner
194 unsigned short switchX = ((corner &
HX) >> 2);
195 unsigned short switchY = ((corner &
HY) >> 1);
196 unsigned short switchZ = (corner &
HZ);
197 double factorX = 0.5 + (1 - 2 * switchX) * (0.5 - idx.
weight(0));
198 double factorY = 0.5 + (1 - 2 * switchY) * (0.5 - idx.
weight(1));
199 double factorZ = 0.5 + (1 - 2 * switchZ) * (0.5 - idx.
weight(2));
201 unsigned long i = idx.
i + switchX, j = idx.
j + switchY, k = idx.
k + switchZ;
203 return factorX * factorY * factorZ * data[
getIndex(i, j, k)];
250 (*msg) <<
" hx= " <<
hx_m <<
" hy= " <<
hy_m <<
" hz= " <<
hz_m <<
" [mm] " <<
endl;
262 std::vector<std::pair<double, double>>& F
273 F[i].second = std::numeric_limits<double>::quiet_NaN();
277 const int index_x = -
static_cast<int>(std::floor(
xbegin_m /
hx_m));
280 const int index_y = -
static_cast<int>(std::floor(
ybegin_m /
hy_m));
283 for (
unsigned long int i = 0;
294 if(std::abs(F[i].second) > Ez_max) {
295 Ez_max = std::abs(F[i].second);
297 F[i].second /= Ez_max;
308 static bool disabled = (std::getenv (
"OPAL_NO_MMAP_FIELDMAPS") !=
nullptr);
312 <<
": reading into private memory (OPAL_NO_MMAP_FIELDMAPS is set)" <<
endl);
316 const std::string base =
317 "/Step#" + std::to_string (step) +
"/Block/" + std::string (
name) +
"/";
320 for (
int i = 0; i < 3; ++ i) {
321 if (!comp[i]->tryMap (
Filename_m, base + std::to_string (i), n, why)) {
323 for (
int j = 0; j < 3; ++ j) {
328 <<
": reading into private memory (" << why <<
")" <<
endl);
334 <<
": mapped read-only, "
335 << (3 * n *
sizeof (
double)) / (1024 * 1024) <<
" MiB shared per node" <<
endl);
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
Inform & endl(Inform &inf)
Inform & level1(Inform &inf)
constexpr double two_pi
The value of.
std::size_t size() const
Number of samples. Zero for an array that has not been filled.
void reset()
Release the buffer or the mapping.
bool anyNonZero(std::size_t begin, std::size_t end) const
virtual double getFrequency() const
bool anyNonZero(const FieldArray &x, const FieldArray &y, const FieldArray &z) const
void setStep(const long long)
void getResonanceFrequency(void)
virtual void getInfo(Inform *msg)
unsigned int num_gridpx_m
unsigned long getIndex(unsigned int i, unsigned int j, unsigned int k) const
virtual void setFrequency(double freq)
double getWeightedData(const FieldArray &data, const IndexTriplet &idx, unsigned short corner) const
void getFieldInfo(const char *)
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F)
Vector_t interpolateTrilinearly(const FieldArray &, const FieldArray &, const FieldArray &, const Vector_t &X) const
void readField(const char *name, double *x, double *y, double *z)
void openFileMPIOCollective(const std::string &filename)
long long getNumSteps(void)
unsigned int num_gridpz_m
unsigned int num_gridpy_m
FieldArray FieldstrengthEz_m
bool tryMapComponents(const char *name, long long step, FieldArray &x, FieldArray &y, FieldArray &z, std::size_t n)
static MPI_Comm getComm()