Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects
Commit 4a699d99 authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Merge branch '631-verifying-particle-matter-interaction-type' into 'master'

Resolve "Verifying particle matter interaction type"

Closes #631

See merge request !466
parents 5d40669a 78ba7db4
No related branches found
No related tags found
1 merge request!466Resolve "Verifying particle matter interaction type"
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Class ParticleMatterInteraction // Class ParticleMatterInteraction
// The class for the OPAL PARTICLEMATTERINTERACTION command. // The class for the OPAL PARTICLEMATTERINTERACTION command.
// //
// Copyright (c) 2012-2019, Andreas Adelmann, Paul Scherrer Institut, Villigen PSI, Switzerland // Copyright (c) 2012-2021, Andreas Adelmann, Paul Scherrer Institut, Villigen PSI, Switzerland
// Christof Metzger-Kraus, Helmholtz-Zentrum Berlin // Christof Metzger-Kraus, Helmholtz-Zentrum Berlin
// Pedro Calvo, CIEMAT, Spain // Pedro Calvo, CIEMAT, Spain
// All rights reserved // All rights reserved
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>. // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
// //
#include "Structure/ParticleMatterInteraction.h" #include "Structure/ParticleMatterInteraction.h"
#include "AbsBeamline/ElementBase.h" #include "AbsBeamline/ElementBase.h"
...@@ -33,13 +32,13 @@ ...@@ -33,13 +32,13 @@
#include "Utilities/OpalException.h" #include "Utilities/OpalException.h"
#include "Utilities/Util.h" #include "Utilities/Util.h"
extern Inform *gmsg; extern Inform* gmsg;
namespace { namespace {
enum { enum {
// DESCRIPTION OF SINGLE PARTICLE: // DESCRIPTION OF PARTICLE MATTER INTERACTION:
TYPE, // The type of the wake TYPE,
MATERIAL, // From of the tube MATERIAL,
ENABLERUTHERFORD, ENABLERUTHERFORD,
SIZE SIZE
}; };
...@@ -47,19 +46,19 @@ namespace { ...@@ -47,19 +46,19 @@ namespace {
ParticleMatterInteraction::ParticleMatterInteraction(): ParticleMatterInteraction::ParticleMatterInteraction():
Definition(SIZE, "PARTICLEMATTERINTERACTION", Definition(SIZE, "PARTICLEMATTERINTERACTION",
"The \"SURFACE_PHYSICS\" statement defines data for the particle mater interaction handler " "The \"PARTICLEMATTERINTERACTION\" statement defines data for "
"on an element."), "the particle matter interaction handler on an element."),
handler_m(0) { handler_m(0) {
itsAttr[TYPE] = Attributes::makeUpperCaseString itsAttr[TYPE] = Attributes::makeUpperCaseString
("TYPE", "Specifies the particle mater interaction handler: Collimator"); ("TYPE", "Specifies the particle matter interaction handler: COLLIMATOR, DEGRADER, BEAMSTRIPPING");
itsAttr[MATERIAL] = Attributes::makeUpperCaseString itsAttr[MATERIAL] = Attributes::makeUpperCaseString
("MATERIAL", "The material of the surface"); ("MATERIAL", "The material of the surface");
itsAttr[ENABLERUTHERFORD] = Attributes::makeBool("ENABLERUTHERFORD", itsAttr[ENABLERUTHERFORD] = Attributes::makeBool
"Enable large angle scattering", true); ("ENABLERUTHERFORD", "Enable large angle scattering", true);
ParticleMatterInteraction *defParticleMatterInteraction = clone("UNNAMED_PARTICLEMATTERINTERACTION"); ParticleMatterInteraction* defParticleMatterInteraction = clone("UNNAMED_PARTICLEMATTERINTERACTION");
defParticleMatterInteraction->builtin = true; defParticleMatterInteraction->builtin = true;
try { try {
...@@ -73,7 +72,7 @@ ParticleMatterInteraction::ParticleMatterInteraction(): ...@@ -73,7 +72,7 @@ ParticleMatterInteraction::ParticleMatterInteraction():
} }
ParticleMatterInteraction::ParticleMatterInteraction(const std::string &name, ParticleMatterInteraction *parent): ParticleMatterInteraction::ParticleMatterInteraction(const std::string& name, ParticleMatterInteraction* parent):
Definition(name, parent), Definition(name, parent),
handler_m(parent->handler_m) handler_m(parent->handler_m)
{} {}
...@@ -85,13 +84,13 @@ ParticleMatterInteraction::~ParticleMatterInteraction() { ...@@ -85,13 +84,13 @@ ParticleMatterInteraction::~ParticleMatterInteraction() {
} }
bool ParticleMatterInteraction::canReplaceBy(Object *object) { bool ParticleMatterInteraction::canReplaceBy(Object* object) {
// Can replace only by another PARTICLEMATTERINTERACTION. // Can replace only by another PARTICLEMATTERINTERACTION.
return dynamic_cast<ParticleMatterInteraction *>(object) != 0; return dynamic_cast<ParticleMatterInteraction*>(object) != 0;
} }
ParticleMatterInteraction *ParticleMatterInteraction::clone(const std::string &name) { ParticleMatterInteraction* ParticleMatterInteraction::clone(const std::string& name) {
return new ParticleMatterInteraction(name, this); return new ParticleMatterInteraction(name, this);
} }
...@@ -101,8 +100,8 @@ void ParticleMatterInteraction::execute() { ...@@ -101,8 +100,8 @@ void ParticleMatterInteraction::execute() {
} }
ParticleMatterInteraction *ParticleMatterInteraction::find(const std::string &name) { ParticleMatterInteraction* ParticleMatterInteraction::find(const std::string& name) {
ParticleMatterInteraction *parmatint = dynamic_cast<ParticleMatterInteraction *>(OpalData::getInstance()->find(name)); ParticleMatterInteraction* parmatint = dynamic_cast<ParticleMatterInteraction*>(OpalData::getInstance()->find(name));
if (parmatint == 0) { if (parmatint == 0) {
throw OpalException("ParticleMatterInteraction::find()", "ParticleMatterInteraction \"" + name + "\" not found."); throw OpalException("ParticleMatterInteraction::find()", "ParticleMatterInteraction \"" + name + "\" not found.");
...@@ -117,34 +116,33 @@ void ParticleMatterInteraction::update() { ...@@ -117,34 +116,33 @@ void ParticleMatterInteraction::update() {
} }
void ParticleMatterInteraction::initParticleMatterInteractionHandler(ElementBase &element) { void ParticleMatterInteraction::initParticleMatterInteractionHandler(ElementBase& element) {
std::string material = Attributes::getString(itsAttr[MATERIAL]); std::string material = Attributes::getString(itsAttr[MATERIAL]);
bool enableRutherford = Attributes::getBool(itsAttr[ENABLERUTHERFORD]); bool enableRutherford = Attributes::getBool(itsAttr[ENABLERUTHERFORD]);
const std::string type = Attributes::getString(itsAttr[TYPE]); const std::string type = Attributes::getString(itsAttr[TYPE]);
if (type == "CCOLLIMATOR" || if (type.empty()) {
type == "COLLIMATOR" || throw OpalException("ParticleMatterInteraction::initParticleMatterInteractionHandler",
type == "DEGRADER") { "TYPE is not defined for PARTICLEMATTERINTERACTION");
} else if (type == "COLLIMATOR" || type == "DEGRADER") {
handler_m = new CollimatorPhysics(getOpalName(), &element, material, enableRutherford); handler_m = new CollimatorPhysics(getOpalName(), &element, material, enableRutherford);
*gmsg << *this << endl; *gmsg << *this << endl;
} } else if (type == "BEAMSTRIPPING") {
else if (type == "BEAMSTRIPPING") { handler_m = new BeamStrippingPhysics(getOpalName(), &element);
handler_m = new BeamStrippingPhysics(getOpalName(), &element); *gmsg << *this << endl;
*gmsg << *this << endl; } else {
} throw OpalException("ParticleMatterInteraction::initParticleMatterInteractionHandler",
else { getOpalName() + ": TYPE == " + Attributes::getString(itsAttr[TYPE])
handler_m = 0; + " is not defined!");
INFOMSG(getOpalName() + ": no particle mater interaction handler attached, TYPE == " << Attributes::getString(itsAttr[TYPE]) << endl);
} }
} }
void ParticleMatterInteraction::updateElement(ElementBase *element) { void ParticleMatterInteraction::updateElement(ElementBase* element) {
handler_m->updateElement(element); handler_m->updateElement(element);
} }
void ParticleMatterInteraction::print(std::ostream &os) const { void ParticleMatterInteraction::print(std::ostream& os) const {
os << "* ************* P A R T I C L E M A T T E R I N T E R A C T I O N ****************** " << std::endl; os << "* ************* P A R T I C L E M A T T E R I N T E R A C T I O N ****************** " << std::endl;
os << "* PARTICLEMATTERINTERACTION " << getOpalName() << '\n' os << "* PARTICLEMATTERINTERACTION " << getOpalName() << '\n'
<< "* TYPE " << Attributes::getString(itsAttr[TYPE]) << '\n'; << "* TYPE " << Attributes::getString(itsAttr[TYPE]) << '\n';
...@@ -153,4 +151,4 @@ void ParticleMatterInteraction::print(std::ostream &os) const { ...@@ -153,4 +151,4 @@ void ParticleMatterInteraction::print(std::ostream &os) const {
os << "* MATERIAL " << Attributes::getString(itsAttr[MATERIAL]) << '\n'; os << "* MATERIAL " << Attributes::getString(itsAttr[MATERIAL]) << '\n';
os << "* ********************************************************************************** " << std::endl; os << "* ********************************************************************************** " << std::endl;
} }
\ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Class ParticleMatterInteraction // Class ParticleMatterInteraction
// The class for the OPAL PARTICLEMATTERINTERACTION command. // The class for the OPAL PARTICLEMATTERINTERACTION command.
// //
// Copyright (c) 2012-2019, Andreas Adelmann, Paul Scherrer Institut, Villigen PSI, Switzerland // Copyright (c) 2012-2021, Andreas Adelmann, Paul Scherrer Institut, Villigen PSI, Switzerland
// Christof Metzger-Kraus, Helmholtz-Zentrum Berlin // Christof Metzger-Kraus, Helmholtz-Zentrum Berlin
// Pedro Calvo, CIEMAT, Spain // Pedro Calvo, CIEMAT, Spain
// All rights reserved // All rights reserved
...@@ -24,23 +24,6 @@ ...@@ -24,23 +24,6 @@
#ifndef OPAL_PARTICLEMATTERINTERACTION_HH #ifndef OPAL_PARTICLEMATTERINTERACTION_HH
#define OPAL_PARTICLEMATTERINTERACTION_HH #define OPAL_PARTICLEMATTERINTERACTION_HH
// ------------------------------------------------------------------------
// $RCSfile: Wake.h,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Wake
//
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:33:44 $
// $Author: Andreas Adelmann $
//
// ------------------------------------------------------------------------
#include "AbstractObjects/Definition.h" #include "AbstractObjects/Definition.h"
#include "Algorithms/PartData.h" #include "Algorithms/PartData.h"
#include "Solvers/ParticleMatterInteractionHandler.hh" #include "Solvers/ParticleMatterInteractionHandler.hh"
...@@ -48,13 +31,6 @@ ...@@ -48,13 +31,6 @@
class ElementBase; class ElementBase;
class Inform; class Inform;
// Class Wake
// ------------------------------------------------------------------------
/// The WAKE definition.
// A WAKE definition is used by most physics commands to define the
// particle charge and the reference momentum, together with some other
// data.
class ParticleMatterInteraction: public Definition { class ParticleMatterInteraction: public Definition {
public: public:
...@@ -65,42 +41,41 @@ public: ...@@ -65,42 +41,41 @@ public:
virtual ~ParticleMatterInteraction(); virtual ~ParticleMatterInteraction();
/// Test if replacement is allowed. /// Test if replacement is allowed.
// Can replace only by another WAKE. virtual bool canReplaceBy(Object* object);
virtual bool canReplaceBy(Object *object);
/// Make clone. /// Make clone.
virtual ParticleMatterInteraction *clone(const std::string &name); virtual ParticleMatterInteraction* clone(const std::string& name);
/// Check the PARTICLEMATTERINTERACTION data. /// Check the PARTICLEMATTERINTERACTION data.
virtual void execute(); virtual void execute();
/// Find named PARTICLEMATTERINTERACTION. /// Find named PARTICLEMATTERINTERACTION.
static ParticleMatterInteraction *find(const std::string &name); static ParticleMatterInteraction* find(const std::string& name);
/// Update the PARTICLEMATTERINTERACTION data. /// Update the PARTICLEMATTERINTERACTION data.
virtual void update(); virtual void update();
void print(std::ostream &os) const; void print(std::ostream& os) const;
void initParticleMatterInteractionHandler(ElementBase &element); void initParticleMatterInteractionHandler(ElementBase& element);
void updateElement(ElementBase *element); void updateElement(ElementBase* element);
ParticleMatterInteractionHandler *handler_m; ParticleMatterInteractionHandler* handler_m;
private: private:
// Not implemented. // Not implemented.
ParticleMatterInteraction(const ParticleMatterInteraction &); ParticleMatterInteraction(const ParticleMatterInteraction&);
void operator=(const ParticleMatterInteraction &); void operator=(const ParticleMatterInteraction&);
// Clone constructor. // Clone constructor.
ParticleMatterInteraction(const std::string &name, ParticleMatterInteraction *parent); ParticleMatterInteraction(const std::string& name, ParticleMatterInteraction* parent);
}; };
inline std::ostream &operator<<(std::ostream &os, const ParticleMatterInteraction &b) { inline std::ostream& operator<<(std::ostream& os, const ParticleMatterInteraction& b) {
b.print(os); b.print(os);
return os; return os;
} }
#endif // OPAL_PARTICLEMATTERINTERACTION_HH #endif // OPAL_PARTICLEMATTERINTERACTION_HH
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment