Commit 6655c45e authored by kraus's avatar kraus

Resolve 'Add option to source element to make it transparent to backtracking particles'

parent 241174e4
......@@ -22,14 +22,16 @@ Source::Source():
Source::Source(const Source &right):
Component(right),
startField_m(right.startField_m),
endField_m(right.endField_m)
endField_m(right.endField_m),
isTransparent_m(right.isTransparent_m)
{}
Source::Source(const std::string &name):
Component(name),
startField_m(0.0),
endField_m(0.0)
endField_m(0.0),
isTransparent_m(false)
{}
Source::~Source() {
......@@ -41,6 +43,10 @@ void Source::accept(BeamlineVisitor &visitor) const {
}
bool Source::apply(const size_t &i, const double &t, Vector_t &/*E*/, Vector_t &/*B*/) {
if (isTransparent_m) {
return false;
}
const Vector_t &R = RefPartBunch_m->R[i];
const Vector_t &P = RefPartBunch_m->P[i];
const double &dt = RefPartBunch_m->dt[i];
......@@ -94,4 +100,8 @@ void Source::getDimensions(double &zBegin, double &zEnd) const {
ElementBase::ElementType Source::getType() const {
return SOURCE;
}
void Source::setTransparent() {
isTransparent_m = true;
}
\ No newline at end of file
......@@ -39,11 +39,14 @@ public:
virtual void getDimensions(double &zBegin, double &zEnd) const override;
void setTransparent();
private:
double startField_m; /**< startingpoint of field, m*/
double endField_m;
bool isTransparent_m;
std::unique_ptr<LossDataSink> lossDs_m;
// Not implemented.
......
......@@ -26,8 +26,10 @@ OpalSource::OpalSource():
OpalElement(SIZE, "SOURCE",
"The \"SOURCE\" element defines a Source.") {
itsAttr[DISTRIBUTION] = Attributes::makeStringArray
("DISTRIBUTION", "List of particle distributions to be used ");
("DISTRIBUTION", "List of particle distributions to be used ");
itsAttr[TRANSPARENT] = Attributes::makeBool
("TRANSPARENT", "Make the source element transparent to impacting elements; Default value is FALSE", false);
registerOwnership();
setElement(new SourceRep("SOURCE"));
......@@ -58,6 +60,10 @@ void OpalSource::update() {
sol->setElementLength(length);
if (Attributes::getBool(itsAttr[TRANSPARENT])) {
sol->setTransparent();
}
// Transmit "unknown" attributes.
OpalElement::updateUnknown(sol);
}
\ No newline at end of file
......@@ -28,6 +28,7 @@ public:
/// The attributes of class OpalSource.
enum {
DISTRIBUTION = COMMON, // The longitudinal magnetic field.
TRANSPARENT,
SIZE
};
......@@ -52,4 +53,4 @@ private:
OpalSource(const std::string &name, OpalSource *parent);
};
#endif // OPAL_OPALSOURCE_HH
#endif // OPAL_OPALSOURCE_HH
\ No newline at end of file
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