Commit ddb2bf80 authored by kraus's avatar kraus
Browse files

Revert "remove endField_m"

This reverts commit 01ef5980.
parent 01ef5980
......@@ -331,64 +331,4 @@ void ElementBase::setCurrentSCoordinate(double s) {
elementEdge_m = actionRange_m.front().first;
}
}
}
bool ElementBase::isInsideTransverse(const Vector_t &r) const
{
double x = aperture_m.second[0];
double y = aperture_m.second[1];
double f = 1.0;
if (aperture_m.first == CONIC_RECTANGULAR ||
aperture_m.first == CONIC_ELLIPTIC) {
Vector_t rRelativeToBegin = getEdgeToBegin().transformTo(r);
double fractionLength = rRelativeToBegin(2) / getElementLength();
f = fractionLength * aperture_m.second[2];
}
switch(aperture_m.first) {
case RECTANGULAR:
return (std::abs(r[0]) < aperture_m.second[0] && std::abs(r[1]) < aperture_m.second[1]);
case ELLIPTICAL:
return (std::pow(r[0] / aperture_m.second[0], 2) + std::pow(r[1] / aperture_m.second[1], 2) < 1.0);
case CONIC_RECTANGULAR:
return (std::abs(r[0]) < f * aperture_m.second[0] && std::abs(r[1]) < f * aperture_m.second[1]);
case CONIC_ELLIPTICAL:
return (std::pow(r[0] / (f * aperture_m.second[0]), 2) + std::pow(r[1] / (f * aperture_m.second[1]), 2) < 1.0);
default:
return false;
}
}
BoundaryBox getBoundaryBoxInLabCoords() const {
CoordinateSystemTrafo toBegin = getEdgeToBegin() * csTrafoGlobal2Local_m;
CoordinateSystemTrafo toEnd = getEdgeToEnd() * csTrafoGlobal2Local_m;
double &x = aperture_m.second[0];
double &y = aperture_m.second[1];
double &f = aperture_m.second[2];
std::vector<Vector_t> corners(8);
for (int i = -1; i < 2; i += 2) {
for (int j = -1; j < 2; j += 2) {
unsigned int idx = (i + 1)/2 + (j + 1);
corners[idx] = toBegin.transformFrom(Vector_t(i * x, j * y, 0.0));
corners[idx + 4] = toEnd.transformFrom(Vector_t(i * f * x, j * f * y, 0.0));
}
}
BoundingBox bb;
bb.lowerLeftCorner = bb.upperRightCorner = corners[0];
for (unsigned int i = 1; i < 8u; ++ i) {
for (unsigned int d; d < 3u; ++ d) {
if (bb.lowerLeftCorner(d) > corners[i](d)) {
bb.lowerLeftCorner(d) = corners[i](d);
}
if (bb.upperLeftCorner(d) < corners[i](d)) {
bb.upperLeftCorner(d) = corners[i](d);
}
}
}
return bb;
}
\ No newline at end of file
......@@ -50,10 +50,7 @@ enum ElemType {
isOther
};
struct BoundaryBox {
Vector_t lowerLeftEdge;
Vector_t upperRightEdge;
};
class WakeFunction;
class ParticleMatterInteractionHandler;
......@@ -457,8 +454,6 @@ public:
void setRotationAboutZ(double rotation);
double getRotationAboutZ() const;
virtual BoundaryBox getBoundaryBoxInLabCoords() const;
protected:
bool isInsideTransverse(const Vector_t &r, double f = 1) const;
......@@ -641,7 +636,24 @@ inline
bool ElementBase::isInside(const Vector_t &r) const
{
const double length = getElementLength();
return r(2) >= 0.0 && r(2) < length && isInsideTransverse(r);
return isInsideTransverse(r, r(2) / length * aperture_m.second[2]) && r(2) >= 0.0 && r(2) < length;
}
inline
bool ElementBase::isInsideTransverse(const Vector_t &r, double f) const
{
switch(aperture_m.first) {
case RECTANGULAR:
return (std::abs(r[0]) < aperture_m.second[0] && std::abs(r[1]) < aperture_m.second[1]);
case ELLIPTICAL:
return (std::pow(r[0] / aperture_m.second[0], 2) + std::pow(r[1] / aperture_m.second[1], 2) < 1.0);
case CONIC_RECTANGULAR:
return (std::abs(r[0]) < f * aperture_m.second[0] && std::abs(r[1]) < f * aperture_m.second[1]);
case CONIC_ELLIPTICAL:
return (std::pow(r[0] / (f * aperture_m.second[0]), 2) + std::pow(r[1] / (f * aperture_m.second[1]), 2) < 1.0);
default:
return false;
}
}
inline
......@@ -710,4 +722,5 @@ inline
bool ElementBase::isElementPositionSet() const
{ return elemedgeSet_m; }
#endif // CLASSIC_ElementBase_HH
\ No newline at end of file
......@@ -65,6 +65,7 @@ RFCavity::RFCavity(const RFCavity &right):
fieldmap_m(right.fieldmap_m),
length_m(right.length_m),
startField_m(right.startField_m),
endField_m(right.endField_m),
type_m(right.type_m),
rmin_m(right.rmin_m),
rmax_m(right.rmax_m),
......@@ -100,6 +101,7 @@ RFCavity::RFCavity(const std::string &name):
fieldmap_m(nullptr),
length_m(0.0),
startField_m(0.0),
endField_m(0.0),
type_m(SW),
rmin_m(0.0),
rmax_m(0.0),
......@@ -242,22 +244,22 @@ bool RFCavity::applyToReferenceParticle(const Vector_t &R,
void RFCavity::initialise(PartBunchBase<double, 3> *bunch, double &startField, double &endField) {
using Physics::two_pi;
startField_m = 0.0;
startField_m = endField_m = 0.0;
if (bunch == NULL) {
startField = startField_m;
endField = startField_m;
endField = endField_m;
return;
}
double zEnd = 0.0, rBegin = 0.0, rEnd = 0.0;
double rBegin = 0.0, rEnd = 0.0;
Inform msg("RFCavity ", *gmsg);
std::stringstream errormsg;
RefPartBunch_m = bunch;
fieldmap_m = Fieldmap::getFieldmap(filename_m, fast_m);
fieldmap_m->getFieldDimensions(startField_m, zEnd, rBegin, rEnd);
if (zEnd <= startField_m) {
fieldmap_m->getFieldDimensions(startField_m, endField_m, rBegin, rEnd);
if (endField_m <= startField_m) {
throw GeneralClassicException("RFCavity::initialise",
"The length of the field map '" + filename_m + "' is zero or negativ");
}
......@@ -277,7 +279,7 @@ void RFCavity::initialise(PartBunchBase<double, 3> *bunch, double &startField, d
}
frequency_m = fieldmap_m->getFrequency();
}
length_m = zEnd - startField_m;
length_m = endField_m - startField_m;
endField = startField + length_m;
}
......@@ -570,7 +572,7 @@ double RFCavity::spline(double z, double *za) {
void RFCavity::getDimensions(double &zBegin, double &zEnd) const {
zBegin = startField_m;
zEnd = startField_m + length_m;
zEnd = endField_m;
}
......
......@@ -234,6 +234,8 @@ protected:
double startField_m; /**< starting point of field(m)*/
private:
double endField_m;
CavityType type_m;
double rmin_m;
......@@ -517,7 +519,7 @@ CoordinateSystemTrafo RFCavity::getEdgeToBegin() const
inline
CoordinateSystemTrafo RFCavity::getEdgeToEnd() const
{
CoordinateSystemTrafo ret(Vector_t(0, 0, startField_m + length_m),
CoordinateSystemTrafo ret(Vector_t(0, 0, endField_m),
Quaternion(1, 0, 0, 0));
return ret;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment