OPAL (Object Oriented Parallel Accelerator Library) 2024.2
OPAL
FM3DMagnetoStaticH5Block.cpp
Go to the documentation of this file.
1//
2// Class FM3DMagnetoStaticH5Block
3// Class for magneto-static 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 "Fields/Fieldmap.h"
21#include "Utility/Inform.h"
22#include "Utility/IpplInfo.h"
23
24#include <cstddef>
25
27 : _Fieldmap(filename)
28 , _FM3DH5BlockBase () {
30
31 openFileMPIOCollective (filename);
32 getFieldInfo ("Efield");
34 closeFile ();
35}
36
40
45
47 ) {
48 if (!FieldstrengthEz_m.empty()) {
49 return;
50 }
52 long long last_step = getNumSteps () - 1;
53 setStep (last_step);
54
55 std::size_t field_size = num_gridpx_m * num_gridpy_m * num_gridpz_m;
56
57 // One physical copy per node instead of one per rank, when the file allows it.
58 if (tryMapComponents ("Efield", last_step,
60 if (tryMapComponents ("Bfield", last_step,
62 FieldstrengthBz_m, field_size)) {
63 closeFile ();
64 return;
65 }
69 }
70 FieldstrengthEx_m.allocate (field_size);
71 FieldstrengthEy_m.allocate (field_size);
72 FieldstrengthEz_m.allocate (field_size);
73 FieldstrengthBx_m.allocate (field_size);
74 FieldstrengthBy_m.allocate (field_size);
75 FieldstrengthBz_m.allocate (field_size);
76
77 readField (
78 "Efield",
82 readField (
83 "Bfield",
87
88 closeFile ();
90 << typeset_msg("3d magneto static fieldmap '"
91 + Filename_m + "' (H5hut format) read", "info")
92 << endl);
93}
106
108 const Vector_t& R,
109 Vector_t& E,
110 Vector_t& B
111 ) const {
112 if (!isInside(R)) {
113 return true;
114 }
119
120 return false;
121}
122
124 ) const {
125 return 0.0;
126}
std::shared_ptr< _FM3DMagnetoStaticH5Block > FM3DMagnetoStaticH5Block
@ T3DMagnetoStaticH5Block
Definition Fieldmap.h:35
#define INFOMSG(msg)
Definition IpplInfo.h:348
Inform & endl(Inform &inf)
Definition Inform.cpp:42
Inform & level3(Inform &inf)
Definition Inform.cpp:47
bool empty() const
Definition FieldArray.h:48
void allocate(std::size_t n)
void reset()
Release the buffer or the mapping.
double * mutableData()
Definition FieldArray.h:71
static std::string typeset_msg(const std::string &msg, const std::string &title)
Definition Fieldmap.cpp:649
std::string Filename_m
Definition Fieldmap.h:118
MapType Type
Definition Fieldmap.h:116
virtual bool isInside(const Vector_t &r) const
void setStep(const long long)
FieldArray FieldstrengthEx_m
void getResonanceFrequency(void)
unsigned int num_gridpx_m
void getFieldInfo(const char *)
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
FieldArray FieldstrengthEy_m
bool tryMapComponents(const char *name, long long step, FieldArray &x, FieldArray &y, FieldArray &z, std::size_t n)
_FM3DMagnetoStaticH5Block(const std::string &filename)
virtual bool getFieldstrength(const Vector_t &R, Vector_t &E, Vector_t &B) const
static FM3DMagnetoStaticH5Block create(const std::string &filename)