25 h5_prop_t props = H5CreateFileProp();
26 MPI_Comm comm = ippl::Comm->getCommunicator();
27 if (H5SetPropFileMPIOCollective(props, &comm) == H5_ERR) {
29 "FM3DH5BlockBase::openFileMPIOCollective () ",
"Cannot set MPIO collective!");
31 file_m = H5OpenFile(aFilename.c_str(), H5_O_RDONLY, props);
32 if (
file_m == (h5_file_t)H5_ERR) {
34 "FM3DH5BlockBase::openFileMPIOCollective () ",
"Cannot open file '" + aFilename +
"'!");
40 long long num_steps = H5GetNumSteps(
file_m);
44 "FM3DH5BlockBase::getNumSteps () ",
45 "Number of time-steps in file '" +
Filename_m +
"' is zero!");
48 "FM3DH5BlockBase::getNumSteps () ",
49 "Query number of time-steps in file '" +
Filename_m +
"' failed!");
56 if (H5SetStep(
file_m, step) == H5_ERR) {
58 "FM3DH5BlockBase::setStep () ",
59 "Cannot set time-step to " + std::to_string(step) +
" in file '" +
Filename_m +
"'!");
67 h5_size_t grid_dims[3];
70 if (H5BlockGetFieldInfoByName(
file_m, name, &grid_rank, grid_dims, &field_dims, &ftype)
73 "FM3DH5BlockBase::GetFieldInfo () ",
"Query of field info for " + std::string(name)
74 +
" in time-step " + std::to_string(last_step)
83 "FM3DH5BlockBase::GetFieldInfo () ",
84 "Query of field spacing"
86 + std::to_string(last_step) +
" in file '" +
Filename_m +
"' failed!");
91 "FM3DH5BlockBase::GetFieldInfo () ",
92 "Query of field origin"
94 + std::to_string(last_step) +
" in file '" +
Filename_m +
"' failed!");
102 if (H5ReadFileAttribFloat64(
file_m,
"Resonance Frequency(Hz)", &
frequency_m) == H5_ERR) {
104 "FM3DH5BlockBase::GetResonanceFrequency () ",
105 "Cannot read file attribute 'Resonance Frequency(Hz)'"
116 "FM3DH5BlockBase::ReadField () ",
122 if (H5Block3dReadVector3dFieldFloat64(
file_m, name, x, y, z) == H5_ERR) {
124 "FM3DH5BlockBase::ReadField () ",
125 "Cannot read field " + std::string(name) +
" in file '" +
Filename_m +
"'!");
130 if (H5CloseFile(
file_m) == H5_ERR) {
132 "FM3DH5BlockBase::closeFile () ",
"Error closing file '" +
Filename_m +
"'!");
137 const std::vector<double>& data,
const IndexTriplet& idx,
unsigned short corner)
const {
138 unsigned short switchX = ((corner &
HX) >> 2);
139 unsigned short switchY = ((corner &
HY) >> 1);
140 unsigned short switchZ = (corner &
HZ);
141 double factorX = 0.5 + (1 - 2 * switchX) * (0.5 - idx.
weight(0));
142 double factorY = 0.5 + (1 - 2 * switchY) * (0.5 - idx.
weight(1));
143 double factorZ = 0.5 + (1 - 2 * switchZ) * (0.5 - idx.
weight(2));
145 unsigned long i = idx.
i + switchX, j = idx.
j + switchY, k = idx.
k + switchZ;
147 return factorX * factorY * factorZ * data[
getIndex(i, j, k)];
151 const std::vector<double>& field_strength_x,
const std::vector<double>& field_strength_y,
194 (*msg) <<
" hx= " <<
hx_m <<
" hy= " <<
hy_m <<
" hz= " <<
hz_m <<
" [mm] " << endl;
210 const int index_x = -
static_cast<int>(std::floor(
xbegin_m /
hx_m));
213 const int index_y = -
static_cast<int>(std::floor(
ybegin_m /
hy_m));
223 if (std::abs(F[i].second) > Ez_max) {
224 Ez_max = std::abs(F[i].second);
226 F[i].second /= Ez_max;
ippl::Vector< T, Dim > Vector_t
constexpr double two_pi
The value of.
virtual void setFrequency(double freq)
void getFieldInfo(const char *)
long long getNumSteps(void)
void openFileMPIOCollective(const std::string aFilename)
unsigned long getIndex(unsigned int i, unsigned int j, unsigned int k) const
std::vector< double > FieldstrengthEz_m
virtual double getFrequency() const
void setStep(const long long)
virtual void getOnaxisEz(std::vector< std::pair< double, double > > &F)
double getWeightedData(const std::vector< double > &data, const IndexTriplet &idx, unsigned short corner) const
void getResonanceFrequency(void)
void readField(const char *name, double *x, double *y, double *z)
virtual void getInfo(Inform *msg)
Vector_t< double, 3 > interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t< double, 3 > &X) const
Vector_t< double, 3 > weight