19#ifndef BDSARRAYOPERATORVALUEREFLECT_H
20#define BDSARRAYOPERATORVALUEREFLECT_H
21#include "BDSArrayOperatorValue.hh"
22#include "BDSFieldValue.hh"
42 xyz{
false,
false,
false},
43 zeroInArrayCoords{0,0,0},
44 dimensionInverted{
false,
false,
false},
45 arrayToSpatialIndex{0,1,2,3}
51 for (G4int i = 0; i < 3; i++)
54 arrayToSpatialIndex = arrayInfo.arrayToSpatialIndex;
56 G4String newName =
"Reflect(";
57 for (
const auto& v : xyz)
58 {newName += std::to_string(v);}
62 auto zeroV = arrayInfo.zeroPoint;
63 auto nPoints = arrayInfo.nPoints;
64 for (G4int i = 0; i < 3; i++)
66 G4bool inverted = (zeroV[i] >= nPoints[i] - 1) && (nPoints[i] > 1);
67 dimensionInverted[i] = inverted;
68 zeroInArrayCoords[i] = inverted ? nPoints[i] - 1 : (G4int)std::floor(zeroV[i]);
79 std::array<G4double, 4> m = {1,1,1,1};
80 std::array<G4int, 4> inds = {xInd, yInd, zInd, tInd};
81 for (G4int i = 0; i < 3; i++)
83 if (dimensionInverted[i])
84 {m[arrayToSpatialIndex[i]] = xyz[i] && inds[i] > zeroInArrayCoords[i] ? -1.0 : 1.0;}
86 {m[arrayToSpatialIndex[i]] = xyz[i] && inds[i] < zeroInArrayCoords[i] ? -1.0 : 1.0;}
93 std::array<G4bool,3> xyz;
94 std::array<G4int, 4> zeroInArrayCoords;
95 std::array<G4bool,4> dimensionInverted;
96 std::array<G4int, 4> arrayToSpatialIndex;
Simple holder of information about an array.
Reflect field component in individual dimensions.
virtual BDSFieldValue Apply(BDSFieldValue v, G4int xInd, G4int yInd=0, G4int zInd=0, G4int tInd=0) const
Interface for modifying field values.
const T & z() const
Accessor by name.
const T & x() const
Accessor by name.
const T & y() const
Accessor by name.