OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
FM3DH5Block_nonscale.cpp
Go to the documentation of this file.
1//
2// Class FM3DH5Block_nonscale
3// Class for dynamic non-scaled 3D field-maps stored in H5hut files.
4//
5// Copyright (c) 2020, Achim Gsell, Paul Scherrer Institut, Villigen PSI, Switzerland
6// All rights reserved.
7//
8// This file is part of OPAL.
9//
10// OPAL is free software: you can redistribute it and/or modify
11// it under the terms of the GNU General Public License as published by
12// the Free Software Foundation, either version 3 of the License, or
13// (at your option) any later version.
14//
15// You should have received a copy of the GNU General Public License
16// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
17//
18
20#include "Physics/Physics.h"
21#include "Physics/Units.h"
23
25 std::string aFilename
26 ) : Fieldmap (
27 aFilename),
29 ) {
31
32 openFileMPIOCollective (aFilename);
33 getFieldInfo ("Efield");
35 closeFile ();
36}
37
39 ) {
40 freeMap();
41}
42
44 ) {
45 if (!FieldstrengthEz_m.empty()) {
46 return;
47 }
49 long long last_step = getNumSteps () - 1;
50 setStep (last_step);
51
52 size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
53 FieldstrengthEx_m.resize (field_size);
54 FieldstrengthEy_m.resize (field_size);
55 FieldstrengthEz_m.resize (field_size);
56 FieldstrengthHx_m.resize (field_size);
57 FieldstrengthHy_m.resize (field_size);
58 FieldstrengthHz_m.resize (field_size);
59
60 readField (
61 "Efield",
64 &(FieldstrengthEz_m[0]));
65 readField (
66 "Hfield",
69 &(FieldstrengthHz_m[0]));
70
71 closeFile ();
72
73 for (long long i = 0; i < num_gridpx_m * num_gridpy_m * num_gridpz_m; i++) {
77 FieldstrengthHx_m[i] *= 1.0e6 * Physics::mu_0 ;
78 FieldstrengthHy_m[i] *= 1.0e6 * Physics::mu_0 ;
79 FieldstrengthHz_m[i] *= 1.0e6 * Physics::mu_0 ;
80 }
82 << typeset_msg("3d dynamic (non-scaled) fieldmap '"
83 + Filename_m + "' (H5hut format) read", "info")
84 << endl);
85}
86
88 ) {
89 if(FieldstrengthEz_m.empty ()) {
90 return;
91 }
92 FieldstrengthEx_m.clear ();
93 FieldstrengthEy_m.clear ();
94 FieldstrengthEz_m.clear ();
95 FieldstrengthHx_m.clear ();
96 FieldstrengthHy_m.clear ();
97 FieldstrengthHz_m.clear ();
98
99 INFOMSG(level3 << typeset_msg("freed fieldmap '" + Filename_m + "'", "info")
100 << endl);
101}
102
104 const Vector_t& R,
105 Vector_t& E,
106 Vector_t& B
107 ) const {
108 if (!isInside(R)) {
109 return true;
110 }
115
116 return false;
117}
@ T3DDynamicH5Block
Definition: Fieldmap.h:35
Inform & endl(Inform &inf)
Definition: Inform.cpp:42
Inform & level3(Inform &inf)
Definition: Inform.cpp:47
#define INFOMSG(msg)
Definition: IpplInfo.h:348
constexpr double mu_0
The permeability of vacuum in Vs/Am.
Definition: Physics.h:48
constexpr double MVpm2Vpm
Definition: Units.h:128
MapType Type
Definition: Fieldmap.h:114
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition: Fieldmap.cpp:652
std::string Filename_m
Definition: Fieldmap.h:117
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
FM3DH5Block_nonscale(std::string aFilename)
std::vector< double > FieldstrengthHx_m
std::vector< double > FieldstrengthHy_m
std::vector< double > FieldstrengthHz_m
void getFieldInfo(const char *)
long long getNumSteps(void)
void openFileMPIOCollective(const std::string aFilename)
std::vector< double > FieldstrengthEz_m
virtual bool isInside(const Vector_t &r) const
void setStep(const long long)
Vector_t interpolateTrilinearly(const std::vector< double > &, const std::vector< double > &, const std::vector< double > &, const Vector_t &X) const
void getResonanceFrequency(void)
std::vector< double > FieldstrengthEx_m
void readField(const char *name, double *x, double *y, double *z)
std::vector< double > FieldstrengthEy_m