explicit TestHexGrad( size_t n ) : coord("coord",n) , gradient("grad",n) { std::cout << "TestHexGrad::coord(" << " " << coord.dimension_0() << " " << coord.dimension_1() << " " << coord.dimension_2() << " " << coord.dimension_3() << " )" << std::endl ; KokkosArray::parallel_for(n,InitCoord(coord)); }
void srTRadIntPowerDensity::SetupNativeRotation() { srTConstTrjDat* ConstTrjDatPtr = (srTConstTrjDat*)(TrjHndl.rep); TVector3d uLab(ConstTrjDatPtr->MagConst.Bx, 0., ConstTrjDatPtr->MagConst.Bz); double Bcon = sqrt(uLab.x*uLab.x + uLab.z*uLab.z); uLab = (1./Bcon)*uLab; TVector3d uLoc(0.,0.,1.), Zero(0.,0.,0.); BconG = Bcon; RmaG = 3.33564076253*(ConstTrjDatPtr->EbmDat.Energy)/BconG; // Magnet radius in m assuming Energy[GeV] and BconG[T] TVector3d uLab_mi_uLoc = uLab - uLoc; //double NormEst = Abs(uLab_mi_uLoc); double NormEst = uLab_mi_uLoc.Abs(); const double RelTolNotRotate = 1.E-05; // To steer if(NormEst < RelTolNotRotate) { //TrLab2Loc.SetupUnit(); TrLab2Loc.SetupIdent(); } else { TVector3d AxVect = uLab^uLoc; double uLab_uLoc = uLab*uLoc; double Angle = acos(uLab_uLoc); TrLab2Loc.SetupRotation(Zero, AxVect, Angle); TVector3d TestVect = TrLab2Loc.TrBiPoint(uLab); double TestScal = TestVect*uLab; if(TestScal < 0.) { TrLab2Loc.SetupRotation(Zero, AxVect, -Angle); } } TVector3d InitCoord(ConstTrjDatPtr->EbmDat.x0, 0., ConstTrjDatPtr->EbmDat.z0); InitCoord = TrLab2Loc.TrPoint(InitCoord); TVector3d InitAng(ConstTrjDatPtr->EbmDat.dxds0, 0., ConstTrjDatPtr->EbmDat.dzds0); InitAng = TrLab2Loc.TrPoint(InitAng); LocInitCoordAng.x0 = InitCoord.x; LocInitCoordAng.z0 = InitCoord.z; LocInitCoordAng.dxds0 = InitAng.x; LocInitCoordAng.dzds0 = InitAng.z; }
void srTConstTrjDat::DetermineIntegLimitsForArbTrj(srTWfrSmp& DistrInfoDat, double& sStart, double& sEnd) { const int AmOfSafetyInterv = 10; // To steer const double RelTolNotRotate = 1.E-05; // To steer TVector3d uLab(MagConst.Bx, 0., MagConst.Bz); double Bcon = sqrt(uLab.x*uLab.x + uLab.z*uLab.z); double Rmag = 3.33564076253*(EbmDat.Energy)/Bcon; double ds = 0; if(DistrInfoDat.AssumeAllPhotonEnergies) { ds = Rmag*sqrt(EbmDat.GammaEm2); } else { double LambMax_m; if(DistrInfoDat.TreatLambdaAsEnergyIn_eV) { double eMin = DistrInfoDat.LambStart; LambMax_m = 1.24E-06/eMin; } else { LambMax_m = 1.E-09*((DistrInfoDat.nLamb > 1)? DistrInfoDat.LambEnd : DistrInfoDat.LambStart); } double ds1 = pow(LambMax_m*Rmag*Rmag, 1./3.); double ds2 = LambMax_m/EbmDat.GammaEm2; //ds = (ds1 > ds2)? ds1 : ds2; ds = (ds1 < ds2)? ds1 : ds2; } uLab = (1./Bcon)*uLab; TVector3d uLoc(0.,0.,1.), Zero(0.,0.,0.); TVector3d uLab_mi_uLoc = uLab - uLoc; //double NormEst = Abs(uLab_mi_uLoc); double NormEst = uLab_mi_uLoc.Abs(); gmTrans Rot; if(NormEst < RelTolNotRotate) { Rot.SetupIdent(); } else { TVector3d AxVect = uLab^uLoc; double uLab_uLoc = uLab*uLoc; double Angle = acos(uLab_uLoc); Rot.SetupRotation(Zero, AxVect, Angle); TVector3d TestVect = Rot.TrBiPoint(uLab); double TestScal = TestVect*uLab; if(TestScal < 0.) { Rot.SetupRotation(Zero, AxVect, -Angle); } } TVector3d P1(DistrInfoDat.xStart, 0., DistrInfoDat.zStart); P1 = Rot.TrPoint(P1); double xLocMin = P1.x, xLocMax = P1.x; if(DistrInfoDat.nx > 1) { TVector3d P2(DistrInfoDat.xEnd, 0., DistrInfoDat.zStart); P2 = Rot.TrPoint(P2); if(xLocMin > P2.x) xLocMin = P2.x; if(xLocMax < P2.x) xLocMax = P2.x; } if(DistrInfoDat.nz > 1) { TVector3d P3(DistrInfoDat.xStart, 0., DistrInfoDat.zEnd); P3 = Rot.TrPoint(P3); if(xLocMin > P3.x) xLocMin = P3.x; if(xLocMax < P3.x) xLocMax = P3.x; if(DistrInfoDat.nx > 1) { TVector3d P4(DistrInfoDat.xEnd, 0., DistrInfoDat.zEnd); P4 = Rot.TrPoint(P4); if(xLocMin > P4.x) xLocMin = P4.x; if(xLocMax < P4.x) xLocMax = P4.x; } } TVector3d InitCoord(EbmDat.x0, 0., EbmDat.z0); InitCoord = Rot.TrPoint(InitCoord); TVector3d InitAng(EbmDat.dxds0, 0., EbmDat.dzds0); InitAng = Rot.TrPoint(InitAng); double y1Inv = 1./(DistrInfoDat.yStart - EbmDat.s0); double xAngMin = (xLocMin - InitCoord.x)*y1Inv - InitAng.x; double xAngMax = (xLocMax - InitCoord.x)*y1Inv - InitAng.x; sStart = EbmDat.s0 + xAngMin*Rmag - AmOfSafetyInterv*ds; sEnd = EbmDat.s0 + xAngMax*Rmag + AmOfSafetyInterv*ds; }