19#include "BDSArray1DCoords.hh"
20#include "BDSArray1DCoordsTransformed.hh"
21#include "BDSArray2DCoords.hh"
22#include "BDSArray2DCoordsTransformed.hh"
23#include "BDSArray3DCoords.hh"
24#include "BDSArray3DCoordsTransformed.hh"
25#include "BDSArray4DCoords.hh"
26#include "BDSArray4DCoordsTransformed.hh"
27#include "BDSArray2DCoordsRDipole.hh"
28#include "BDSArray2DCoordsRQuad.hh"
29#include "BDSArrayInfo.hh"
30#include "BDSArrayOperatorIndex.hh"
31#include "BDSArrayOperatorIndexFlip.hh"
32#include "BDSArrayOperatorIndexReflect.hh"
33#include "BDSArrayOperatorIndexV.hh"
34#include "BDSArrayOperatorValue.hh"
35#include "BDSArrayOperatorValueFlip.hh"
36#include "BDSArrayOperatorValueReflect.hh"
37#include "BDSArrayOperatorValueReflectDipoleXY.hh"
38#include "BDSArrayOperatorValueReflectDipoleY.hh"
39#include "BDSArrayOperatorValueReflectQuadrupoleXY.hh"
40#include "BDSArrayOperatorValueReflectSolenoidZ.hh"
41#include "BDSArrayOperatorValueV.hh"
42#include "BDSArrayReflectionType.hh"
44#include "BDSException.hh"
45#include "BDSFieldEInterpolated.hh"
46#include "BDSFieldEInterpolated1D.hh"
47#include "BDSFieldEInterpolated2D.hh"
48#include "BDSFieldEInterpolated3D.hh"
49#include "BDSFieldEInterpolated4D.hh"
50#include "BDSFieldEMInterpolated.hh"
51#include "BDSFieldEMInterpolated1D.hh"
52#include "BDSFieldEMInterpolated2D.hh"
53#include "BDSFieldEMInterpolated3D.hh"
54#include "BDSFieldEMInterpolated4D.hh"
55#include "BDSFieldFormat.hh"
56#include "BDSFieldInfo.hh"
57#include "BDSFieldLoader.hh"
58#include "BDSFieldLoaderBDSIM.hh"
59#include "BDSFieldLoaderPoisson.hh"
60#include "BDSFieldMagInterpolated.hh"
61#include "BDSFieldMagInterpolated1D.hh"
62#include "BDSFieldMagInterpolated2D.hh"
63#include "BDSFieldMagInterpolated3D.hh"
64#include "BDSFieldMagInterpolated4D.hh"
65#include "BDSFieldValue.hh"
66#include "BDSInterpolator1D.hh"
67#include "BDSInterpolator1DCubic.hh"
68#include "BDSInterpolator1DLinear.hh"
69#include "BDSInterpolator1DLinearMag.hh"
70#include "BDSInterpolator1DNearest.hh"
71#include "BDSInterpolator2D.hh"
72#include "BDSInterpolator2DCubic.hh"
73#include "BDSInterpolator2DLinear.hh"
74#include "BDSInterpolator2DLinearMag.hh"
75#include "BDSInterpolator2DNearest.hh"
76#include "BDSInterpolator3D.hh"
77#include "BDSInterpolator3DCubic.hh"
78#include "BDSInterpolator3DLinear.hh"
79#include "BDSInterpolator3DLinearMag.hh"
80#include "BDSInterpolator3DNearest.hh"
81#include "BDSInterpolator4D.hh"
82#include "BDSInterpolator4DCubic.hh"
83#include "BDSInterpolator4DLinear.hh"
84#include "BDSInterpolator4DLinearMag.hh"
85#include "BDSInterpolator4DNearest.hh"
86#include "BDSInterpolatorType.hh"
87#include "BDSFieldMagGradient.hh"
88#include "BDSMagnetStrength.hh"
89#include "BDSWarning.hh"
101#include "src-external/gzstream/gzstream.h"
116BDSFieldLoader::~BDSFieldLoader()
122void BDSFieldLoader::DeleteArrays()
136 const G4String& scalingKey)
142 G4Transform3D transform = info.
Transform();
143 G4double bScaling = info.
BScaling();
145 BDSArrayReflectionTypeSet* reflectionPointer = reflection.empty() ? nullptr : &reflection;
152 case BDSFieldFormat::bdsim1d:
153 {result =
LoadBDSIM1DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
154 case BDSFieldFormat::bdsim2d:
155 {result =
LoadBDSIM2DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
156 case BDSFieldFormat::bdsim3d:
157 {result =
LoadBDSIM3DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
158 case BDSFieldFormat::bdsim4d:
159 {result =
LoadBDSIM4DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
160 case BDSFieldFormat::poisson2d:
161 {result =
LoadPoissonSuperFishB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
162 case BDSFieldFormat::poisson2dquad:
164 case BDSFieldFormat::poisson2ddipole:
176 if (result && info.
AutoScale() && scalingStrength)
181 temporaryRecipe.SetAutoScale(
false);
182 temporaryRecipe.SetBScaling(1);
187 temporaryRecipe.SetMagneticInterpolatorType(magIntType);
200 G4double calculatedNumber = (*calculatedStrengths)[scalingKey];
201 G4double ratio = (*scalingStrength)[scalingKey] / calculatedNumber;
202 if (!std::isnormal(ratio))
204 G4cout << __METHOD_NAME__ <<
"invalid ratio detected (" << ratio <<
") setting to 1.0" << G4endl;
207 G4double newScale = result->Scaling() * ratio;
208 G4cout <<
"autoScale> Calculated " << scalingKey <<
" = " << calculatedNumber << G4endl;
209 G4cout <<
"autoScale> Ratio of supplied strength to calculated map strength: " << ratio << G4endl;
210 G4cout <<
"autoScale> New overall scaling factor: " << bScaling*ratio << G4endl;
211 result->SetScaling(newScale);
212 delete calculatedStrengths;
224 G4Transform3D transform = info.
Transform();
225 G4double eScaling = info.
EScaling();
227 BDSArrayReflectionTypeSet* reflectionPointer = reflection.empty() ? nullptr : &reflection;
234 case BDSFieldFormat::bdsim1d:
235 {result =
LoadBDSIM1DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
236 case BDSFieldFormat::bdsim2d:
237 {result =
LoadBDSIM2DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
238 case BDSFieldFormat::bdsim3d:
239 {result =
LoadBDSIM3DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
240 case BDSFieldFormat::bdsim4d:
241 {result =
LoadBDSIM4DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
264 G4Transform3D transform = info.
Transform();
265 G4double eScaling = info.
EScaling();
266 G4double bScaling = info.
BScaling();
268 BDSArrayReflectionTypeSet* bReflectionPointer = bReflection.empty() ? nullptr : &bReflection;
270 BDSArrayReflectionTypeSet* eReflectionPointer = eReflection.empty() ? nullptr : &eReflection;
276 if (bFormat != eFormat)
277 {
throw BDSException(__METHOD_NAME__,
"different formats for E and B fields are not currently supported for an EM field");}
284 case BDSFieldFormat::bdsim1d:
286 result =
LoadBDSIM1DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
287 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
290 case BDSFieldFormat::bdsim2d:
292 result =
LoadBDSIM2DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
293 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
296 case BDSFieldFormat::bdsim3d:
298 result =
LoadBDSIM3DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
299 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
302 case BDSFieldFormat::bdsim4d:
304 result =
LoadBDSIM4DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
305 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
323 if (filePath.empty())
333 if (filePath.empty())
342 auto result =
arrays1d.find(filePath);
344 {
return result->second;}
351 auto result =
arrays2d.find(filePath);
353 {
return result->second;}
360 auto result =
arrays3d.find(filePath);
362 {
return result->second;}
369 auto result =
arrays4d.find(filePath);
371 {
return result->second;}
383 if (filePath.rfind(
"gz") != std::string::npos)
389 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
410 if (filePath.rfind(
"gz") != std::string::npos)
414 result = loader.
Load1D(filePath);
416 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
422 result = loader.
Load1D(filePath);
435 if (filePath.rfind(
"gz") != std::string::npos)
439 result = loader.
Load2D(filePath);
441 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
447 result = loader.
Load2D(filePath);
460 if (filePath.rfind(
"gz") != std::string::npos )
464 result = loader.
Load3D(filePath);
466 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
472 result = loader.
Load3D(filePath);
485 if (filePath.rfind(
"gz") != std::string::npos)
489 result = loader.
Load4D(filePath);
491 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
497 result = loader.
Load4D(filePath);
509 case BDSInterpolatorType::nearest1d:
511 case BDSInterpolatorType::linear1d:
513 case BDSInterpolatorType::linearmag1d:
515 case BDSInterpolatorType::cubic1d:
518 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 1D field: " + interpolatorType.ToString());
break;}
529 case BDSInterpolatorType::nearest2d:
531 case BDSInterpolatorType::linear2d:
533 case BDSInterpolatorType::linearmag2d:
535 case BDSInterpolatorType::cubic2d:
538 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 2D field: " + interpolatorType.ToString());
break;}
549 case BDSInterpolatorType::nearest3d:
551 case BDSInterpolatorType::linear3d:
553 case BDSInterpolatorType::linearmag3d:
555 case BDSInterpolatorType::cubic3d:
558 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 3D field: " + interpolatorType.ToString());
break;}
569 case BDSInterpolatorType::nearest4d:
571 case BDSInterpolatorType::linear4d:
573 case BDSInterpolatorType::linearmag4d:
575 case BDSInterpolatorType::cubic4d:
578 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 4D field: " + interpolatorType.ToString());
break;}
592 G4String msg =
"Invalid combination of array transforms.\n";
599 std::vector<BDSArrayOperatorIndex*> indexOperators;
600 std::vector<BDSArrayOperatorValue*> valueOperators;
610 std::array<G4bool,4> flipIndexOperators = {
false,
false,
false,
false};
611 for (
auto& reflectionType : *reflectionTypes)
613 switch (reflectionType.underlying())
615 case BDSArrayReflectionType::flipx:
616 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::x)] =
true;
break;}
617 case BDSArrayReflectionType::flipy:
618 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::y)] =
true;
break;}
619 case BDSArrayReflectionType::flipz:
620 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::z)] =
true;
break;}
621 case BDSArrayReflectionType::flipt:
622 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::t)] =
true;
break;}
627 G4bool anyFlipIndexOperators = std::any_of(std::begin(flipIndexOperators), std::end(flipIndexOperators), [](
bool i){
return i;});
628 if (anyFlipIndexOperators)
635 std::array<G4bool,4> reflectIndexOperators = {
false,
false,
false,
false};
636 for (
auto& reflectionType : *reflectionTypes)
638 switch (reflectionType.underlying())
640 case BDSArrayReflectionType::reflectx:
641 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::x)] =
true;
break;}
642 case BDSArrayReflectionType::reflecty:
643 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::y)] =
true;
break;}
644 case BDSArrayReflectionType::reflectz:
645 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::z)] =
true;
break;}
646 case BDSArrayReflectionType::reflectt:
647 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::t)] =
true;
break;}
652 G4bool anyReflectIndexOperators = std::any_of(std::begin(reflectIndexOperators), std::end(reflectIndexOperators), [](
bool i){
return i;});
653 if (anyReflectIndexOperators)
660 for (
auto& reflectionType : *reflectionTypes)
662 switch (reflectionType.underlying())
664 case BDSArrayReflectionType::reflectxydipole:
670 case BDSArrayReflectionType::reflectxzdipole:
676 case BDSArrayReflectionType::reflectyzdipole:
682 case BDSArrayReflectionType::reflectzsolenoid:
688 case BDSArrayReflectionType::reflectxyquadrupole:
699 if (indexOperators.size() > 1)
702 for (
auto io : indexOperators)
703 {indexResult->push_back(io);}
705 for (
auto vo : valueOperators)
706 {valueResult->push_back(vo);}
707 indexOperator = indexResult;
708 valueOperator = valueResult;
712 indexOperator = indexOperators[0];
713 valueOperator = valueOperators[0];
718 G4cout <<
"Array ( index | value ) operator: (" << indexOperator->
Name() <<
" | " << valueOperator->
Name() <<
")" << G4endl;
722 const std::array<G4bool, 4>& operatesOnXYZT,
723 G4double tolerance)
const
725 G4String suffix[4] = {
"st",
"nd",
"rd",
"th"};
726 for (G4int i = 0; i < 4; i++)
728 G4double integerPart = 0;
729 if ( (std::modf(std::abs(info.zeroPoint[i]), &integerPart) > tolerance) && operatesOnXYZT[i])
731 G4String msg =
"Array reflection will not work as intended as the axis zero point is not an integer number of \n";
732 msg +=
"array steps from 0 in the " + std::to_string(i + 1) + suffix[i];
733 msg +=
" dimension of the array (tolerance 5% of array step size)";
741 if (!reflectionTypes)
745 if (reflectionTypes->empty())
753 const BDSArrayReflectionTypeSet* reflectionTypes)
const
756 {
return existingArray;}
760 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
766 const BDSArrayReflectionTypeSet* reflectionTypes)
const
769 {
return existingArray;}
773 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
779 const BDSArrayReflectionTypeSet* reflectionTypes)
const
782 {
return existingArray;}
786 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
792 const BDSArrayReflectionTypeSet* reflectionTypes)
const
795 {
return existingArray;}
799 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
806 const G4Transform3D& transform,
808 const BDSArrayReflectionTypeSet* reflection)
811 G4double bScalingUnits = bScaling * CLHEP::tesla;
821 const G4Transform3D& transform,
823 const BDSArrayReflectionTypeSet* reflection)
825 G4double bScalingUnits = bScaling * CLHEP::tesla;
835 const G4Transform3D& transform,
837 const BDSArrayReflectionTypeSet* reflection)
839 G4double bScalingUnits = bScaling * CLHEP::tesla;
849 const G4Transform3D& transform,
851 const BDSArrayReflectionTypeSet* reflection)
853 G4double bScalingUnits = bScaling * CLHEP::tesla;
863 const G4Transform3D& transform,
865 const BDSArrayReflectionTypeSet* reflection)
867 G4double bScalingUnits = bScaling * CLHEP::gauss;
877 const G4Transform3D& transform,
879 const BDSArrayReflectionTypeSet* )
881 G4double bScalingUnits = bScaling * CLHEP::gauss;
884 if (std::abs(array->
XStep() - array->
YStep()) > 1e-9)
885 {
throw BDSException(__METHOD_NAME__,
"asymmetric grid spacing for reflected quadrupole will result in a distorted field map - please regenerate the map with even spatial samples.");}
894 const G4Transform3D& transform,
896 const BDSArrayReflectionTypeSet* )
898 G4double bScalingUnits = bScaling * CLHEP::gauss;
909 const G4Transform3D& transform,
911 const BDSArrayReflectionTypeSet* reflection)
913 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
923 const G4Transform3D& transform,
925 const BDSArrayReflectionTypeSet* reflection)
927 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
937 const G4Transform3D& transform,
939 const BDSArrayReflectionTypeSet* reflection)
941 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
951 const G4Transform3D& transform,
953 const BDSArrayReflectionTypeSet* reflection)
955 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
964 const G4String& bFilePath,
967 const G4Transform3D& transform,
970 const BDSArrayReflectionTypeSet* eReflection,
971 const BDSArrayReflectionTypeSet* bReflection)
973 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
974 G4double bScalingUnits = bScaling * CLHEP::tesla;
982 eScalingUnits, bScalingUnits);
987 const G4String& bFilePath,
990 const G4Transform3D& transform,
993 const BDSArrayReflectionTypeSet* eReflection,
994 const BDSArrayReflectionTypeSet* bReflection)
996 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
997 G4double bScalingUnits = bScaling * CLHEP::tesla;
1005 eScalingUnits, bScalingUnits);
1010 const G4String& bFilePath,
1013 const G4Transform3D& transform,
1016 const BDSArrayReflectionTypeSet* eReflection,
1017 const BDSArrayReflectionTypeSet* bReflection)
1019 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
1020 G4double bScalingUnits = bScaling * CLHEP::tesla;
1028 eScalingUnits, bScalingUnits);
1033 const G4String& bFilePath,
1036 const G4Transform3D& transform,
1039 const BDSArrayReflectionTypeSet* eReflection,
1040 const BDSArrayReflectionTypeSet* bReflection)
1042 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
1043 G4double bScalingUnits = bScaling * CLHEP::tesla;
1051 eScalingUnits, bScalingUnits);
1D array with spatial mapping derived from BDSArray4DCoords.
A wrapper to achieve 2D reflection of a minimal dipole field solve.
A wrapper to achieve 2D reflection of a minimal quadrupole field solve.
2D array with spatial mapping derived from BDSArray4DCoords.
3D array with spatial mapping derived from BDSArray4DCoords.
Overlay of 4D array that provides uniform only spatial coordinate mapping.
G4double XStep() const
The distance in spatial coordinates between any two points in the array.
G4double YStep() const
The distance in spatial coordinates between any two points in the array.
G4int DimensionIndex(BDSDimensionType spatialDimension) const
Simple holder of information about an array.
1D array for completeness in array system.
1D array for completeness in array system.
Vectorised version of BDSArrayOperatorIndex.
Interface for modifying by reference array indices.
virtual G4String Name() const
Supply a name of this operator for feedback to the user in print out.
virtual std::array< G4bool, 4 > OperatesOnXYZT() const
Return which axes this object operates on overall.
Flip field component in individual dimensions if out of original array bounds.
Reflect field values for a dipolar field in the positive quadrant.
Reflect field values for a dipolar field about the x-z plane.
Reflect field values for a quadrupole field in the positive quadrant.
Reflect field values for a solenoid-like field in the z axis.
Reflect field component in individual dimensions.
A vectorised version of BDSArrayOperatorValueV.
Interface for modifying field values.
virtual G4String Name() const
Return a name of the operator for feedback to the user in print out.
General exception with possible name of object and message.
A 1D field from an interpolated array with any interpolation.
A 2D field from an interpolated array with any interpolation.
A 3D field from an interpolated array with any interpolation.
A 4D field from an interpolated array with any interpolation.
Class to provide scaling and a base class pointer for interpolator fields.
A 1D field from an interpolated array with any interpolation.
A 2D field from an interpolated array with any interpolation.
A 3D field from an interpolated array with any interpolation.
A 4D field from an interpolated array with any interpolation.
Class to provide scaling and a base class pointer for interpolator fields.
All info required to build complete field of any type.
G4double BScaling() const
Accessor.
const BDSArrayReflectionTypeSet & ElectricArrayReflectionType() const
Accessor.
BDSFieldFormat MagneticFormat() const
Accessor.
G4String NameOfParserDefinition() const
Accessor.
G4String ElectricFile() const
Accessor.
BDSInterpolatorType ElectricInterpolatorType() const
Accessor.
BDSInterpolatorType MagneticInterpolatorType() const
Accessor.
G4double EScaling() const
Accessor.
G4String MagneticFile() const
Accessor.
G4Transform3D Transform() const
Transform for the field definition only.
BDSFieldFormat ElectricFormat() const
Accessor.
const BDSArrayReflectionTypeSet & MagneticArrayReflectionType() const
Accessor.
G4double BRho() const
Accessor.
G4bool AutoScale() const
Accessor.
Loader for BDSIM format fields.
BDSArray3DCoords * Load3D(const G4String &fileName)
Load a 3D array.
BDSArray4DCoords * Load4D(const G4String &fileName)
Load a 4D array.
BDSArray1DCoords * Load1D(const G4String &fileName)
Load a 1D array.
BDSArray2DCoords * Load2D(const G4String &fileName)
Load a 2D array.
Loader for 2D Poisson SuperFish SF7 files.
BDSArray2DCoords * LoadMag2D(G4String fileName)
Load the 2D array of 3-Vector field values.
A loader for various field map formats.
BDSFieldEInterpolated * LoadBDSIM3DE(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 3D BDSIM format electric field.
static void EFilePathOK(const BDSFieldInfo &info)
Check file path isn't empty and throw exception if it is.
BDSFieldEMInterpolated * LoadBDSIM3DEM(const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr)
Load a 3D BDSIM format electro-magnetic field.
BDSInterpolator3D * CreateInterpolator3D(BDSArray3DCoords *array, BDSInterpolatorType interpolatorType) const
Create the appropriate 3D interpolator for an array.
std::map< G4String, BDSArray1DCoords * > arrays1d
Map of cached field map array.
BDSFieldEMInterpolated * LoadBDSIM4DEM(const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr)
Load a 4D BDSIM format electro-magnetic field.
std::map< G4String, BDSArray2DCoords * > arrays2d
Map of cached field map array.
BDSArray2DCoords * LoadPoissonMag2D(const G4String &filePath)
Utility function to use the right templated loader class (gz or normal).
BDSArray3DCoords * Get3DCached(const G4String &filePath)
Return the cached array if there is one - may return nullptr.
BDSArray2DCoords * LoadBDSIM2D(const G4String &filePath)
Utility function to use the right templated loader class (gz or normal).
BDSFieldEMInterpolated * LoadEMField(const BDSFieldInfo &info)
Main interface to load an electro-magnetic field.
BDSInterpolator1D * CreateInterpolator1D(BDSArray1DCoords *array, BDSInterpolatorType interpolatorType) const
Create the appropriate 1D interpolator for an array.
BDSFieldEInterpolated * LoadBDSIM2DE(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 2D BDSIM format electric field.
std::map< G4String, BDSArray3DCoords * > arrays3d
Map of cached field map array.
void ReportIfProblemWithReflection(const BDSArrayInfo &info, const std::array< G4bool, 4 > &operatesOnXYZT, G4double tolerance=0.05) const
BDSInterpolator2D * CreateInterpolator2D(BDSArray2DCoords *array, BDSInterpolatorType interpolatorType) const
Create the appropriate 2D interpolator for an array.
BDSFieldEInterpolated * LoadBDSIM4DE(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 4D BDSIM format electric field.
BDSFieldMagInterpolated * LoadPoissonSuperFishB(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 2D poisson superfish B field map.
BDSFieldLoader()
Private default constructor as singleton.
BDSFieldMagInterpolated * LoadPoissonSuperFishBQuad(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
BDSArray1DCoords * Get1DCached(const G4String &filePath)
Return the cached array if there is one - may return nullptr.
BDSFieldMagInterpolated * LoadBDSIM1DB(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 1D BDSIM format magnetic field.
BDSFieldEMInterpolated * LoadBDSIM1DEM(const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr)
Load a 1D BDSIM format electro-magnetic field.
BDSArray3DCoords * LoadBDSIM3D(const G4String &filePath)
Utility function to use the right templated loader class (gz or normal).
BDSFieldMagInterpolated * LoadBDSIM4DB(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 4D BDSIM format magnetic field.
BDSFieldMagInterpolated * LoadBDSIM2DB(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 2D BDSIM format magnetic field.
BDSFieldMagInterpolated * LoadMagField(const BDSFieldInfo &info, const BDSMagnetStrength *scalingStrength=nullptr, const G4String &scalingKey="none")
Main interface to load a magnetic field.
static BDSFieldLoader * instance
Singleton instance.
static BDSFieldLoader * Instance()
Singleton accessor.
BDSFieldEMInterpolated * LoadBDSIM2DEM(const G4String &eFilePath, const G4String &bFilePath, BDSInterpolatorType eInterpolatorType, BDSInterpolatorType bInterpolatorType, const G4Transform3D &transform, G4double eScaling, G4double bScaling, const BDSArrayReflectionTypeSet *eReflection=nullptr, const BDSArrayReflectionTypeSet *bReflection=nullptr)
Load a 2D BDSIM format electro-magnetic field.
BDSArray4DCoords * Get4DCached(const G4String &filePath)
Return the cached array if there is one - may return nullptr.
BDSFieldMagInterpolated * LoadPoissonSuperFishBDipole(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
BDSInterpolator4D * CreateInterpolator4D(BDSArray4DCoords *array, BDSInterpolatorType interpolatorType) const
Create the appropriate 4D interpolator for an array.
BDSFieldMagInterpolated * LoadBDSIM3DB(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double bScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 3D BDSIM format magnetic field.
BDSFieldEInterpolated * LoadEField(const BDSFieldInfo &info)
Main interface to load an electric field.
G4bool NeedToProvideTransform(const BDSArrayReflectionTypeSet *reflectionTypes) const
BDSFieldEInterpolated * LoadBDSIM1DE(const G4String &filePath, BDSInterpolatorType interpolatorType, const G4Transform3D &transform, G4double eScaling, const BDSArrayReflectionTypeSet *reflection=nullptr)
Load a 1D BDSIM format electric field.
void CreateOperators(const BDSArrayReflectionTypeSet *reflectionTypes, const BDSArray4DCoords *existingArray, BDSArrayOperatorIndex *&indexOperator, BDSArrayOperatorValue *&valueOperator) const
static void BFilePathOK(const BDSFieldInfo &info)
Check file path isn't empty and throw exception if it is.
BDSArray1DCoords * LoadBDSIM1D(const G4String &filePath)
Utility function to use the right templated loader class (gz or normal).
BDSArray4DCoords * LoadBDSIM4D(const G4String &filePath)
Utility function to use the right templated loader class (gz or normal).
std::map< G4String, BDSArray4DCoords * > arrays4d
Map of cached field map array.
BDSArray2DCoords * Get2DCached(const G4String &filePath)
Return the cached array if there is one - may return nullptr.
Find multipole components of fieldmaps by numerical differentiation.
BDSMagnetStrength * CalculateMultipoles(BDSFieldMag *BField, G4int order, G4double Brho=4)
Find the Magnet strengths of a multipole field to nth order.
A 1D field from an interpolated array with any interpolation.
A 2D field from an interpolated array with any interpolation.
A 3D field from an interpolated array with any interpolation.
A 4D field from an interpolated array with any interpolation.
Class to provide scaling and a base class pointer for interpolator fields.
Cubic interpolation over 1d array.
Linear interpolation over 1d array including magnitude interpolation.
Linear interpolation over 1d array.
Interpolated field array that gives the nearest neighbour value.
Interface for all 1D interpolators.
Cubic interpolation over 2d array.
Linear interpolation over 2d array including magnitude interpolation.
Linear interpolation over 2d array.
Interpolated field array that gives the nearest neighbour value.
Interface for all 2D interpolators.
Cubic interpolation over 3d array.
Linear interpolation over 3d array including magnitude interpolation.
Linear interpolation over 3d array.
Interpolated field array that gives the nearest neighbour value.
Interface for all 3D interpolators.
Cubic interpolation over 4d array.
Linear interpolation over 4d array including magnitude interpolation.
Linear interpolation over 4d array.
Interpolated field array that gives the nearest neighbour value.
Interface for all 4D interpolators.
Efficient storage of magnet strengths.
type underlying() const
return underlying value (can be used in switch statement)
BDSInterpolatorType InterpolatorTypeSpecificFromAuto(G4int nDimension, BDSInterpolatorType autoType)
G4bool ProblemWithArrayReflectionCombination(const BDSArrayReflectionTypeSet &setIn, G4String *details=nullptr)
Return true if there's a conceptual conflict with the set of field reflections requested.
G4int NDimensionsOfFieldFormat(const BDSFieldFormat &ff)
Report the number of dimensions for that format.