Commit 2e4b24f8 authored by kraus's avatar kraus

Merge branch...

Merge branch '579-add-option-to-source-element-to-make-it-transparent-to-backtracking-particles' into 'master'

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

Closes #579

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