19#include "BDSArray2DCoordsTransformed.hh"
20#include "BDSArrayOperatorIndex.hh"
21#include "BDSArrayOperatorValue.hh"
22#include "BDSFieldValue.hh"
34 indexOperator(indexOperatorIn),
35 valueOperator(valueOperatorIn),
39BDSArray2DCoordsTransformed::~BDSArray2DCoordsTransformed()
49 G4double& yFrac)
const
51 G4double xArrayCoords, yArrayCoords;
53 auto x1 = (G4int)std::floor(xArrayCoords);
54 auto y1 = (G4int)std::floor(yArrayCoords);
55 xFrac = xArrayCoords - x1;
56 yFrac = yArrayCoords - y1;
58 std::array<G4int, 2> indexArrX = {x1, x1+1};
59 std::array<G4int, 2> indexArrY = {y1, y1+1};
60 G4int indexOriginalX, indexOriginalY, indexTransformedX, indexTransformedY;
61 for (G4int i = 0; i < 2; i++)
63 for (G4int j = 0; j < 2; j++)
65 indexOriginalX = indexArrX[i];
66 indexTransformedX = indexOriginalX;
67 indexOriginalY = indexArrY[j];
68 indexTransformedY = indexOriginalY;
69 indexOperator->
Apply(indexTransformedX, indexTransformedY);
71 localData[i][j] = valueOperator->
Apply(v, indexOriginalX, indexOriginalY);
80 G4double& yFrac)
const
84 auto x1 = (G4int)std::floor(xArrayCoords);
85 auto y1 = (G4int)std::floor(yArrayCoords);
86 xFrac = xArrayCoords - x1;
87 yFrac = yArrayCoords - y1;
89 std::array<G4int, 4> indexArrX = {x1-1, x1, x1+1, x1+2};
90 std::array<G4int, 4> indexArrY = {y1-1, y1, y1+1, y1+2};
91 G4int indexOriginalX, indexOriginalY, indexTransformedX, indexTransformedY;
92 for (G4int i = 0; i < 4; i++)
94 for (G4int j = 0; j < 4; j++)
96 indexOriginalX = indexArrX[i];
97 indexTransformedX = indexOriginalX;
98 indexOriginalY = indexArrY[j];
99 indexTransformedY = indexOriginalY;
100 indexOperator->
Apply(indexTransformedX, indexTransformedY);
102 localData[i][j] = valueOperator->
Apply(v, indexOriginalX, indexOriginalY);
114 G4int indexTransformedX = indexOriginalX;
115 G4int indexTransformedY = indexOriginalY;
116 indexOperator->
Apply(indexTransformedX, indexTransformedY);
118 v = valueOperator->
Apply(v, indexOriginalX, indexOriginalY);
124 out <<
"Spatial limits are the original ones" << G4endl;
125 out <<
"Array index operator: " << indexOperator->
Name() << G4endl;
126 out <<
"Array value operator: " << valueOperator->
Name() << G4endl;
2D array with spatial mapping derived from BDSArray4DCoords.
void ArrayCoordsFromXY(G4double &x, G4double &xArr, G4double &y, G4double &yArr) const
Utility version to forward to individual function.
virtual G4double ArrayCoordsFromX(G4double x) const
Not much point in being both virtual and inline (in our use case) but has to be virtual.
virtual G4int NearestY(G4double y) const
Not much point in being both virtual and inline (in our use case) but has to be virtual.
virtual G4int NearestX(G4double x) const
Not much point in being both virtual and inline (in our use case) but has to be virtual.
virtual G4double ArrayCoordsFromY(G4double y) const
Not much point in being both virtual and inline (in our use case) but has to be virtual.
virtual const BDSFieldValue & GetConst(G4int x, G4int y=0, G4int z=0, G4int t=0) const
virtual std::ostream & Print(std::ostream &out) const
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 void Apply(G4int &, G4int &, G4int &, G4int &) const
Interface for modifying field values.
virtual BDSFieldValue Apply(BDSFieldValue v, G4int, G4int=0, G4int=0, G4int=0) const
virtual G4String Name() const
Return a name of the operator for feedback to the user in print out.