18#include "BDSArray1DCoords.hh"
19#include "BDSArray1DCoordsTransformed.hh"
20#include "BDSArray2DCoords.hh"
21#include "BDSArray2DCoordsTransformed.hh"
22#include "BDSArray3DCoords.hh"
23#include "BDSArray3DCoordsTransformed.hh"
24#include "BDSArray4DCoords.hh"
25#include "BDSArray4DCoordsTransformed.hh"
26#include "BDSArray2DCoordsRDipole.hh"
27#include "BDSArray2DCoordsRQuad.hh"
28#include "BDSArrayInfo.hh"
29#include "BDSArrayOperatorIndex.hh"
30#include "BDSArrayOperatorIndexFlip.hh"
31#include "BDSArrayOperatorIndexReflect.hh"
32#include "BDSArrayOperatorIndexV.hh"
33#include "BDSArrayOperatorValue.hh"
34#include "BDSArrayOperatorValueFlip.hh"
35#include "BDSArrayOperatorValueReflect.hh"
36#include "BDSArrayOperatorValueReflectDipoleXY.hh"
37#include "BDSArrayOperatorValueReflectDipoleY.hh"
38#include "BDSArrayOperatorValueReflectQuadrupoleXY.hh"
39#include "BDSArrayOperatorValueReflectSolenoidZ.hh"
40#include "BDSArrayOperatorValueV.hh"
41#include "BDSArrayReflectionType.hh"
43#include "BDSException.hh"
44#include "BDSFieldEInterpolated.hh"
45#include "BDSFieldEInterpolated1D.hh"
46#include "BDSFieldEInterpolated2D.hh"
47#include "BDSFieldEInterpolated3D.hh"
48#include "BDSFieldEInterpolated4D.hh"
49#include "BDSFieldEMInterpolated.hh"
50#include "BDSFieldEMInterpolated1D.hh"
51#include "BDSFieldEMInterpolated2D.hh"
52#include "BDSFieldEMInterpolated3D.hh"
53#include "BDSFieldEMInterpolated4D.hh"
54#include "BDSFieldFormat.hh"
55#include "BDSFieldInfo.hh"
56#include "BDSFieldLoader.hh"
57#include "BDSFieldLoaderBDSIM.hh"
58#include "BDSFieldLoaderPoisson.hh"
59#include "BDSFieldMagInterpolated.hh"
60#include "BDSFieldMagInterpolated1D.hh"
61#include "BDSFieldMagInterpolated2D.hh"
62#include "BDSFieldMagInterpolated3D.hh"
63#include "BDSFieldMagInterpolated4D.hh"
64#include "BDSFieldValue.hh"
65#include "BDSInterpolator1D.hh"
66#include "BDSInterpolator1DCubic.hh"
67#include "BDSInterpolator1DLinear.hh"
68#include "BDSInterpolator1DLinearMag.hh"
69#include "BDSInterpolator1DNearest.hh"
70#include "BDSInterpolator2D.hh"
71#include "BDSInterpolator2DCubic.hh"
72#include "BDSInterpolator2DLinear.hh"
73#include "BDSInterpolator2DLinearMag.hh"
74#include "BDSInterpolator2DNearest.hh"
75#include "BDSInterpolator3D.hh"
76#include "BDSInterpolator3DCubic.hh"
77#include "BDSInterpolator3DLinear.hh"
78#include "BDSInterpolator3DLinearMag.hh"
79#include "BDSInterpolator3DNearest.hh"
80#include "BDSInterpolator4D.hh"
81#include "BDSInterpolator4DCubic.hh"
82#include "BDSInterpolator4DLinear.hh"
83#include "BDSInterpolator4DLinearMag.hh"
84#include "BDSInterpolator4DNearest.hh"
85#include "BDSInterpolatorType.hh"
86#include "BDSFieldMagGradient.hh"
87#include "BDSMagnetStrength.hh"
88#include "BDSWarning.hh"
100#include "src-external/gzstream/gzstream.h"
115BDSFieldLoader::~BDSFieldLoader()
121void BDSFieldLoader::DeleteArrays()
135 const G4String& scalingKey)
141 G4Transform3D transform = info.
Transform();
142 G4double bScaling = info.
BScaling();
144 BDSArrayReflectionTypeSet* reflectionPointer = reflection.empty() ? nullptr : &reflection;
151 case BDSFieldFormat::bdsim1d:
152 {result =
LoadBDSIM1DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
153 case BDSFieldFormat::bdsim2d:
154 {result =
LoadBDSIM2DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
155 case BDSFieldFormat::bdsim3d:
156 {result =
LoadBDSIM3DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
157 case BDSFieldFormat::bdsim4d:
158 {result =
LoadBDSIM4DB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
159 case BDSFieldFormat::poisson2d:
160 {result =
LoadPoissonSuperFishB(filePath, interpolatorType, transform, bScaling, reflectionPointer);
break;}
161 case BDSFieldFormat::poisson2dquad:
163 case BDSFieldFormat::poisson2ddipole:
175 if (result && info.
AutoScale() && scalingStrength)
180 temporaryRecipe.SetAutoScale(
false);
181 temporaryRecipe.SetBScaling(1);
186 temporaryRecipe.SetMagneticInterpolatorType(magIntType);
199 G4double calculatedNumber = (*calculatedStrengths)[scalingKey];
200 G4double ratio = (*scalingStrength)[scalingKey] / calculatedNumber;
201 if (!std::isnormal(ratio))
203 G4cout << __METHOD_NAME__ <<
"invalid ratio detected (" << ratio <<
") setting to 1.0" << G4endl;
206 G4double newScale = result->Scaling() * ratio;
207 G4cout <<
"autoScale> Calculated " << scalingKey <<
" = " << calculatedNumber << G4endl;
208 G4cout <<
"autoScale> Ratio of supplied strength to calculated map strength: " << ratio << G4endl;
209 G4cout <<
"autoScale> New overall scaling factor: " << bScaling*ratio << G4endl;
210 result->SetScaling(newScale);
211 delete calculatedStrengths;
223 G4Transform3D transform = info.
Transform();
224 G4double eScaling = info.
EScaling();
226 BDSArrayReflectionTypeSet* reflectionPointer = reflection.empty() ? nullptr : &reflection;
233 case BDSFieldFormat::bdsim1d:
234 {result =
LoadBDSIM1DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
235 case BDSFieldFormat::bdsim2d:
236 {result =
LoadBDSIM2DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
237 case BDSFieldFormat::bdsim3d:
238 {result =
LoadBDSIM3DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
239 case BDSFieldFormat::bdsim4d:
240 {result =
LoadBDSIM4DE(filePath, interpolatorType, transform, eScaling, reflectionPointer);
break;}
263 G4Transform3D transform = info.
Transform();
264 G4double eScaling = info.
EScaling();
265 G4double bScaling = info.
BScaling();
267 BDSArrayReflectionTypeSet* bReflectionPointer = bReflection.empty() ? nullptr : &bReflection;
269 BDSArrayReflectionTypeSet* eReflectionPointer = eReflection.empty() ? nullptr : &eReflection;
275 if (bFormat != eFormat)
276 {
throw BDSException(__METHOD_NAME__,
"different formats for E and B fields are not currently supported for an EM field");}
283 case BDSFieldFormat::bdsim1d:
285 result =
LoadBDSIM1DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
286 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
289 case BDSFieldFormat::bdsim2d:
291 result =
LoadBDSIM2DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
292 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
295 case BDSFieldFormat::bdsim3d:
297 result =
LoadBDSIM3DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
298 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
301 case BDSFieldFormat::bdsim4d:
303 result =
LoadBDSIM4DEM(eFilePath, bFilePath, eIntType, bIntType, transform,
304 eScaling, bScaling, eReflectionPointer, bReflectionPointer);
322 if (filePath.empty())
332 if (filePath.empty())
341 auto result =
arrays1d.find(filePath);
343 {
return result->second;}
350 auto result =
arrays2d.find(filePath);
352 {
return result->second;}
359 auto result =
arrays3d.find(filePath);
361 {
return result->second;}
368 auto result =
arrays4d.find(filePath);
370 {
return result->second;}
382 if (filePath.rfind(
"gz") != std::string::npos)
388 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
409 if (filePath.rfind(
"gz") != std::string::npos)
413 result = loader.
Load1D(filePath);
415 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
421 result = loader.
Load1D(filePath);
434 if (filePath.rfind(
"gz") != std::string::npos)
438 result = loader.
Load2D(filePath);
440 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
446 result = loader.
Load2D(filePath);
459 if (filePath.rfind(
"gz") != std::string::npos )
463 result = loader.
Load3D(filePath);
465 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
471 result = loader.
Load3D(filePath);
484 if (filePath.rfind(
"gz") != std::string::npos)
488 result = loader.
Load4D(filePath);
490 throw BDSException(__METHOD_NAME__,
"Compressed file loading - but BDSIM not compiled with ZLIB.");
496 result = loader.
Load4D(filePath);
508 case BDSInterpolatorType::nearest1d:
510 case BDSInterpolatorType::linear1d:
512 case BDSInterpolatorType::linearmag1d:
514 case BDSInterpolatorType::cubic1d:
517 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 1D field: " + interpolatorType.ToString());
break;}
528 case BDSInterpolatorType::nearest2d:
530 case BDSInterpolatorType::linear2d:
532 case BDSInterpolatorType::linearmag2d:
534 case BDSInterpolatorType::cubic2d:
537 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 2D field: " + interpolatorType.ToString());
break;}
548 case BDSInterpolatorType::nearest3d:
550 case BDSInterpolatorType::linear3d:
552 case BDSInterpolatorType::linearmag3d:
554 case BDSInterpolatorType::cubic3d:
557 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 3D field: " + interpolatorType.ToString());
break;}
568 case BDSInterpolatorType::nearest4d:
570 case BDSInterpolatorType::linear4d:
572 case BDSInterpolatorType::linearmag4d:
574 case BDSInterpolatorType::cubic4d:
577 {
throw BDSException(__METHOD_NAME__,
"Invalid interpolator type for 4D field: " + interpolatorType.ToString());
break;}
591 G4String msg =
"Invalid combination of array transforms.\n";
598 std::vector<BDSArrayOperatorIndex*> indexOperators;
599 std::vector<BDSArrayOperatorValue*> valueOperators;
609 std::array<G4bool,4> flipIndexOperators = {
false,
false,
false,
false};
610 for (
auto& reflectionType : *reflectionTypes)
612 switch (reflectionType.underlying())
614 case BDSArrayReflectionType::flipx:
615 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::x)] =
true;
break;}
616 case BDSArrayReflectionType::flipy:
617 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::y)] =
true;
break;}
618 case BDSArrayReflectionType::flipz:
619 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::z)] =
true;
break;}
620 case BDSArrayReflectionType::flipt:
621 {flipIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::t)] =
true;
break;}
626 G4bool anyFlipIndexOperators = std::any_of(std::begin(flipIndexOperators), std::end(flipIndexOperators), [](
bool i){
return i;});
627 if (anyFlipIndexOperators)
634 std::array<G4bool,4> reflectIndexOperators = {
false,
false,
false,
false};
635 for (
auto& reflectionType : *reflectionTypes)
637 switch (reflectionType.underlying())
639 case BDSArrayReflectionType::reflectx:
640 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::x)] =
true;
break;}
641 case BDSArrayReflectionType::reflecty:
642 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::y)] =
true;
break;}
643 case BDSArrayReflectionType::reflectz:
644 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::z)] =
true;
break;}
645 case BDSArrayReflectionType::reflectt:
646 {reflectIndexOperators[existingArray->
DimensionIndex(BDSDimensionType::t)] =
true;
break;}
651 G4bool anyReflectIndexOperators = std::any_of(std::begin(reflectIndexOperators), std::end(reflectIndexOperators), [](
bool i){
return i;});
652 if (anyReflectIndexOperators)
659 for (
auto& reflectionType : *reflectionTypes)
661 switch (reflectionType.underlying())
663 case BDSArrayReflectionType::reflectxydipole:
669 case BDSArrayReflectionType::reflectxzdipole:
675 case BDSArrayReflectionType::reflectyzdipole:
681 case BDSArrayReflectionType::reflectzsolenoid:
687 case BDSArrayReflectionType::reflectxyquadrupole:
698 if (indexOperators.size() > 1)
701 for (
auto io : indexOperators)
702 {indexResult->push_back(io);}
704 for (
auto vo : valueOperators)
705 {valueResult->push_back(vo);}
706 indexOperator = indexResult;
707 valueOperator = valueResult;
711 indexOperator = indexOperators[0];
712 valueOperator = valueOperators[0];
717 G4cout <<
"Array ( index | value ) operator: (" << indexOperator->
Name() <<
" | " << valueOperator->
Name() <<
")" << G4endl;
721 const std::array<G4bool, 4>& operatesOnXYZT,
722 G4double tolerance)
const
724 G4String suffix[4] = {
"st",
"nd",
"rd",
"th"};
725 for (G4int i = 0; i < 4; i++)
727 G4double integerPart = 0;
728 if ( (std::modf(std::abs(info.zeroPoint[i]), &integerPart) > tolerance) && operatesOnXYZT[i])
730 G4String msg =
"Array reflection will not work as intended as the axis zero point is not an integer number of \n";
731 msg +=
"array steps from 0 in the " + std::to_string(i + 1) + suffix[i];
732 msg +=
" dimension of the array (tolerance 5% of array step size)";
740 if (!reflectionTypes)
744 if (reflectionTypes->empty())
752 const BDSArrayReflectionTypeSet* reflectionTypes)
const
755 {
return existingArray;}
759 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
765 const BDSArrayReflectionTypeSet* reflectionTypes)
const
768 {
return existingArray;}
772 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
778 const BDSArrayReflectionTypeSet* reflectionTypes)
const
781 {
return existingArray;}
785 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
791 const BDSArrayReflectionTypeSet* reflectionTypes)
const
794 {
return existingArray;}
798 CreateOperators(reflectionTypes, existingArray, indexOperator, valueOperator);
805 const G4Transform3D& transform,
807 const BDSArrayReflectionTypeSet* reflection)
810 G4double bScalingUnits = bScaling * CLHEP::tesla;
820 const G4Transform3D& transform,
822 const BDSArrayReflectionTypeSet* reflection)
824 G4double bScalingUnits = bScaling * CLHEP::tesla;
834 const G4Transform3D& transform,
836 const BDSArrayReflectionTypeSet* reflection)
838 G4double bScalingUnits = bScaling * CLHEP::tesla;
848 const G4Transform3D& transform,
850 const BDSArrayReflectionTypeSet* reflection)
852 G4double bScalingUnits = bScaling * CLHEP::tesla;
862 const G4Transform3D& transform,
864 const BDSArrayReflectionTypeSet* reflection)
866 G4double bScalingUnits = bScaling * CLHEP::gauss;
876 const G4Transform3D& transform,
878 const BDSArrayReflectionTypeSet* )
880 G4double bScalingUnits = bScaling * CLHEP::gauss;
883 if (std::abs(array->
XStep() - array->
YStep()) > 1e-9)
884 {
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.");}
893 const G4Transform3D& transform,
895 const BDSArrayReflectionTypeSet* )
897 G4double bScalingUnits = bScaling * CLHEP::gauss;
908 const G4Transform3D& transform,
910 const BDSArrayReflectionTypeSet* reflection)
912 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
922 const G4Transform3D& transform,
924 const BDSArrayReflectionTypeSet* reflection)
926 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
936 const G4Transform3D& transform,
938 const BDSArrayReflectionTypeSet* reflection)
940 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
950 const G4Transform3D& transform,
952 const BDSArrayReflectionTypeSet* reflection)
954 G4double eScalingUnits = eScaling * CLHEP::volt/CLHEP::m;
963 const G4String& bFilePath,
966 const G4Transform3D& transform,
969 const BDSArrayReflectionTypeSet* eReflection,
970 const BDSArrayReflectionTypeSet* bReflection)
972 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
973 G4double bScalingUnits = bScaling * CLHEP::tesla;
981 eScalingUnits, bScalingUnits);
986 const G4String& bFilePath,
989 const G4Transform3D& transform,
992 const BDSArrayReflectionTypeSet* eReflection,
993 const BDSArrayReflectionTypeSet* bReflection)
995 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
996 G4double bScalingUnits = bScaling * CLHEP::tesla;
1004 eScalingUnits, bScalingUnits);
1009 const G4String& bFilePath,
1012 const G4Transform3D& transform,
1015 const BDSArrayReflectionTypeSet* eReflection,
1016 const BDSArrayReflectionTypeSet* bReflection)
1018 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
1019 G4double bScalingUnits = bScaling * CLHEP::tesla;
1027 eScalingUnits, bScalingUnits);
1032 const G4String& bFilePath,
1035 const G4Transform3D& transform,
1038 const BDSArrayReflectionTypeSet* eReflection,
1039 const BDSArrayReflectionTypeSet* bReflection)
1041 G4double eScalingUnits = eScaling * CLHEP::volt / CLHEP::m;
1042 G4double bScalingUnits = bScaling * CLHEP::tesla;
1050 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.