Commit 2accb7ce authored by ext-calvo_p's avatar ext-calvo_p
Browse files

Resolve "Define OUTFN as common attribute"

parent b0812f57
......@@ -936,7 +936,7 @@ void Cyclotron::initialise(PartBunchBase<double, 3>* bunch, double& /*startField
void Cyclotron::initialise(PartBunchBase<double, 3>* bunch, const double& scaleFactor) {
RefPartBunch_m = bunch;
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(getName(), !Options::asciidump));
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(getOutputFN(), !Options::asciidump));
this->read(scaleFactor);
}
......
......@@ -247,14 +247,14 @@ protected:
private:
std::string fmapfn_m; /* stores the filename of the fieldmap */
std::string fmapfn_m; /**< Stores the filename of the B-fieldmap*/
std::vector<double> rffrequ_m;
std::vector< std::vector<double> > rffc_m;
std::vector<double> rfvrequ_m;
std::vector< std::vector<double> > rfvc_m;
std::vector<double> rfphi_m;
std::vector<double> escale_m; // a scale factor for the E-field
std::vector<bool> superpose_m; // electric fields are superposed or not
std::vector<double> escale_m; /**< A scale factor for the E-field*/
std::vector<bool> superpose_m; /**< A flag for superpose electric fields*/
double symmetry_m;
......@@ -265,15 +265,14 @@ private:
double pzinit_m;
bool spiral_flag_m;
double trimCoilThreshold_m; ///< B-field threshold for applying trim coil
double trimCoilThreshold_m; /**< B-field threshold for applying trim coil*/
std::string typeName_m; // name of the TYPE parameter in cyclotron
std::string typeName_m; /**< Name of the TYPE parameter in cyclotron*/
double harm_m;
double bscale_m; // a scale factor for the B-field
double bscale_m; /**< A scale factor for the B-field*/
/// Trim coils
std::vector<TrimCoil*> trimcoils_m;
std::vector<TrimCoil*> trimcoils_m; /**< Trim coils*/
double minr_m;
double maxr_m;
......@@ -294,8 +293,7 @@ private:
std::vector<std::string> RFFCoeff_fn_m;
std::vector<std::string> RFVCoeff_fn_m;
// handling for store the particle out of region
std::unique_ptr<LossDataSink> lossDs_m;
std::unique_ptr<LossDataSink> lossDs_m; /**< Handling for store the particle out of region*/
// Necessary for quick and dirty phase output -DW
int waiting_for_gap = 1;
......@@ -308,4 +306,4 @@ protected:
BPositions BP;
};
#endif // CLASSIC_Cyclotron_HH
\ No newline at end of file
#endif // CLASSIC_Cyclotron_HH
// ------------------------------------------------------------------------
// $RCSfile: Degrader.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.1.1.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Degrader
// Defines the abstract interface for a beam Degrader.
// Class Degrader
// Defines the abstract interface for a beam degrader.
//
// ------------------------------------------------------------------------
// Class category: AbsBeamline
// ------------------------------------------------------------------------
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
// This file is part of OPAL.
//
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
// ------------------------------------------------------------------------
#include "AbsBeamline/Degrader.h"
#include "Algorithms/PartBunchBase.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Algorithms/PartBunchBase.h"
#include "Physics/Physics.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Physics/Physics.h"
#include <memory>
#include <string>
extern Inform *gmsg;
// Class Degrader
// ------------------------------------------------------------------------
Degrader::Degrader():
Degrader("")
......@@ -39,7 +36,6 @@ Degrader::Degrader():
Degrader::Degrader(const Degrader &right):
Component(right),
filename_m(right.filename_m),
PosX_m(right.PosX_m),
PosY_m(right.PosY_m),
PosZ_m(right.PosZ_m),
......@@ -56,7 +52,6 @@ Degrader::Degrader(const std::string &name):
Degrader::~Degrader() {
if(online_m)
goOffline();
}
......@@ -84,11 +79,11 @@ bool Degrader::apply(const size_t &i, const double &t, Vector_t &/*E*/, Vector_t
if (isInMaterial(R(2))) {
//if particle was allready marked as -1 (it means it should have gone into degrader but didn't)
//set the label to -2 (will not go into degrader and will be deleted when particles per core > 2)
if (RefPartBunch_m->Bin[i] < 0)
if (RefPartBunch_m->Bin[i] < 0) {
RefPartBunch_m->Bin[i] = -2;
else
} else {
RefPartBunch_m->Bin[i] = -1;
}
double frac = -R(2) / P(2) * recpgamma;
PosX_m.push_back(R(0));
PosY_m.push_back(R(1));
......@@ -125,15 +120,10 @@ void Degrader::initialise(PartBunchBase<double, 3> *bunch, double &startField, d
void Degrader::initialise(PartBunchBase<double, 3> *bunch) {
RefPartBunch_m = bunch;
if (filename_m == std::string(""))
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(getName(), !Options::asciidump));
else
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(filename_m.substr(0, filename_m.rfind(".")), !Options::asciidump));
lossDs_m = std::unique_ptr<LossDataSink>(new LossDataSink(getOutputFN(), !Options::asciidump));
}
void Degrader::finalise()
{
void Degrader::finalise() {
*gmsg << "* Finalize Degrader" << endl;
}
......@@ -164,21 +154,9 @@ bool Degrader::bends() const {
return false;
}
void Degrader::setOutputFN(std::string fn) {
filename_m = fn;
}
std::string Degrader::getOutputFN() {
if (filename_m == std::string(""))
return getName();
else
return filename_m.substr(0, filename_m.rfind("."));
}
void Degrader::getDimensions(double &zBegin, double &zEnd) const {
zBegin = 0.0;
zEnd = getElementLength();
}
ElementBase::ElementType Degrader::getType() const {
......@@ -187,5 +165,4 @@ ElementBase::ElementType Degrader::getType() const {
std::string Degrader::getDegraderShape() {
return "DEGRADER";
}
#ifndef CLASSIC_Degrader_HH
#define CLASSIC_Degrader_HH
// Class category: AbsBeamline
// ------------------------------------------------------------------------
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
// Class Degrader
// Defines the abstract interface for a beam degrader.
//
// Copyright (c) 2000 - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// Class: Degrader
// Defines the abstract interface for a beam Degrader.
// *** MISSING *** Degrader interface is still incomplete.
// This file is part of OPAL.
//
// ------------------------------------------------------------------------
// Class category: AbsBeamline
// ------------------------------------------------------------------------
// OPAL is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// $Date: 2000/03/27 09:32:31 $
// $Author: fci $
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
// ------------------------------------------------------------------------
#ifndef CLASSIC_Degrader_HH
#define CLASSIC_Degrader_HH
#include "AbsBeamline/Component.h"
#include "AbsBeamline/BeamlineVisitor.h"
......@@ -31,11 +27,6 @@
class LossDataSink;
// Class Degrader
// ------------------------------------------------------------------------
/// Abstract collimator.
// Class Degrader defines the abstract interface for a collimator.
class Degrader: public Component {
public:
......@@ -88,9 +79,6 @@ public:
std::string getDegraderShape(); // AAA
void setOutputFN(std::string fn);
std::string getOutputFN();
virtual bool isInMaterial(double z);
private:
......@@ -98,8 +86,6 @@ private:
// Not implemented.
void operator=(const Degrader &);
std::string filename_m; /**< The name of the outputfile*/
std::vector<double> PosX_m;
std::vector<double> PosY_m;
std::vector<double> PosZ_m;
......@@ -112,4 +98,4 @@ private:
std::unique_ptr<LossDataSink> lossDs_m;
};
#endif // CLASSIC_Degrader_HH
\ No newline at end of file
#endif // CLASSIC_Degrader_HH
//
// Class ElementBase
// The very base class for beam line representation objects. A beam line
// The very base class for beam line representation objects. A beam line
// is modelled as a composite structure having a single root object
// (the top level beam line), which contains both ``single'' leaf-type
// elements (Components), as well as sub-lines (composites).
......@@ -47,7 +47,7 @@
// This returns a full deep copy.
// [/OL]
//
// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// Copyright (c) 200x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
......@@ -61,13 +61,13 @@
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#include "AbsBeamline/ElementBase.h"
#include "Channels/Channel.h"
#include <string>
#include "Structure/BoundaryGeometry.h" // OPAL file
#include "Solvers/WakeFunction.h"
#include "Channels/Channel.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Solvers/WakeFunction.h"
#include "Structure/BoundaryGeometry.h"
#include <string>
ElementBase::ElementBase():
ElementBase("")
......@@ -89,14 +89,16 @@ ElementBase::ElementBase(const ElementBase &right):
parmatint_m(right.parmatint_m),
positionIsFixed(right.positionIsFixed),
elementPosition_m(right.elementPosition_m),
elemedgeSet_m(right.elemedgeSet_m)
elemedgeSet_m(right.elemedgeSet_m),
outputfn_m(right.outputfn_m)
{
if(parmatint_m) {
if (parmatint_m) {
parmatint_m->updateElement(this);
}
if(bgeometry_m)
if (bgeometry_m) {
bgeometry_m->updateElement(this);
}
}
......@@ -114,7 +116,8 @@ ElementBase::ElementBase(const std::string &name):
parmatint_m(NULL),
positionIsFixed(false),
elementPosition_m(0.0),
elemedgeSet_m(false)
elemedgeSet_m(false),
outputfn_m("")
{}
......@@ -123,9 +126,7 @@ ElementBase::~ElementBase()
{}
const std::string &ElementBase::getName() const
{
const std::string &ElementBase::getName() const {
return elementID;
}
......@@ -138,7 +139,7 @@ void ElementBase::setName(const std::string &name) {
double ElementBase::getAttribute(const std::string &aKey) const {
const ConstChannel *aChannel = getConstChannel(aKey);
if(aChannel != NULL) {
if (aChannel != NULL) {
double val = *aChannel;
delete aChannel;
return val;
......@@ -151,7 +152,7 @@ double ElementBase::getAttribute(const std::string &aKey) const {
bool ElementBase::hasAttribute(const std::string &aKey) const {
const ConstChannel *aChannel = getConstChannel(aKey);
if(aChannel != NULL) {
if (aChannel != NULL) {
delete aChannel;
return true;
} else {
......@@ -168,7 +169,7 @@ void ElementBase::removeAttribute(const std::string &aKey) {
void ElementBase::setAttribute(const std::string &aKey, double val) {
Channel *aChannel = getChannel(aKey, true);
if(aChannel != NULL && aChannel->isSettable()) {
if (aChannel != NULL && aChannel->isSettable()) {
*aChannel = val;
delete aChannel;
} else
......@@ -230,12 +231,12 @@ std::string ElementBase::getTypeString(ElementBase::ElementType type) {
return "Stripper";
case TRAVELINGWAVE:
return "TravelingWave";
case VACUUM:
return "Vacuum";
#ifdef ENABLE_OPAL_FEL
case UNDULATOR:
return "Undulator";
#endif
case VACUUM:
return "Vacuum";
case VARIABLERFCAVITY:
return "VariableRFCavity";
case ANY:
......@@ -245,7 +246,7 @@ std::string ElementBase::getTypeString(ElementBase::ElementType type) {
}
ElementBase *ElementBase::copyStructure() {
if(isSharable()) {
if (isSharable()) {
return this;
} else {
return clone();
......@@ -259,7 +260,7 @@ void ElementBase::makeSharable() {
bool ElementBase::update(const AttributeSet &set) {
for(AttributeSet::const_iterator i = set.begin(); i != set.end(); ++i) {
for (AttributeSet::const_iterator i = set.begin(); i != set.end(); ++i) {
setAttribute(i->first, i->second);
}
......
//
// Class ElementBase
// The very base class for beam line representation objects. A beam line
// The very base class for beam line representation objects. A beam line
// is modelled as a composite structure having a single root object
// (the top level beam line), which contains both ``single'' leaf-type
// elements (Components), as well as sub-lines (composites).
......@@ -47,7 +47,7 @@
// This returns a full deep copy.
// [/OL]
//
// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// Copyright (c) 200x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// This file is part of OPAL.
......@@ -64,11 +64,11 @@
#define CLASSIC_ElementBase_HH
#include "AbsBeamline/AttributeSet.h"
#include "BeamlineGeometry/Geometry.h"
#include "Algorithms/CoordinateSystemTrafo.h"
#include "Algorithms/Quaternion.h"
#include "BeamlineGeometry/Euclid3D.h"
#include "BeamlineGeometry/Geometry.h"
#include "MemoryManagement/RCObject.h"
#include "Algorithms/Quaternion.h"
#include "Algorithms/CoordinateSystemTrafo.h"
#include "Utilities/GeneralClassicException.h"
#include <boost/optional.hpp>
......@@ -86,7 +86,6 @@ class WakeFunction;
class ElementBase: public RCObject {
public:
/// Constructor with given name.
explicit ElementBase(const std::string &name);
......@@ -145,12 +144,12 @@ public:
/// Get geometry.
// Return the element geometry.
// Version for non-constant object.
virtual BGeometryBase &getGeometry() = 0;
virtual BGeometryBase &getGeometry() = 0;
/// Get geometry.
// Return the element geometry
// Version for constant object.
virtual const BGeometryBase &getGeometry() const = 0;
virtual const BGeometryBase &getGeometry() const = 0;
/// Get arc length.
// Return the entire arc length measured along the design orbit
......@@ -264,7 +263,6 @@ public:
// If any error occurs, this method throws an exception.
virtual void accept(BeamlineVisitor &visitor) const = 0;
/// Return clone.
// Return an identical deep copy of the element.
virtual ElementBase *clone() const = 0;
......@@ -300,7 +298,6 @@ public:
virtual bool hasBoundaryGeometry() const;
/// attach a wake field to the element
virtual void setWake(WakeFunction *wf);
......@@ -374,6 +371,12 @@ public:
virtual int getRequiredNumberOfTimeSteps() const;
/// Set output filename
void setOutputFN(std::string fn);
/// Get output filename
std::string getOutputFN() const;
protected:
bool isInsideTransverse(const Vector_t &r) const;
......@@ -390,8 +393,8 @@ protected:
double rotationZAxis_m;
private:
private:
// Not implemented.
void operator=(const ElementBase &);
......@@ -413,6 +416,8 @@ private:
bool elemedgeSet_m;
///@}
std::queue<std::pair<double, double> > actionRange_m;
std::string outputfn_m; /**< The name of the outputfile*/
};
......@@ -500,20 +505,19 @@ bool ElementBase::hasParticleMatterInteraction() const
{ return parmatint_m != NULL; }
inline
void ElementBase::setCSTrafoGlobal2Local(const CoordinateSystemTrafo &trafo)
{
void ElementBase::setCSTrafoGlobal2Local(const CoordinateSystemTrafo &trafo) {
if (positionIsFixed) return;
csTrafoGlobal2Local_m = trafo;
}
inline
CoordinateSystemTrafo ElementBase::getCSTrafoGlobal2Local() const
{ return csTrafoGlobal2Local_m; }
CoordinateSystemTrafo ElementBase::getCSTrafoGlobal2Local() const {
return csTrafoGlobal2Local_m;
}
inline
CoordinateSystemTrafo ElementBase::getEdgeToBegin() const
{
CoordinateSystemTrafo ElementBase::getEdgeToBegin() const {
CoordinateSystemTrafo ret(Vector_t(0, 0, 0),
Quaternion(1, 0, 0, 0));
......@@ -521,8 +525,7 @@ CoordinateSystemTrafo ElementBase::getEdgeToBegin() const
}
inline
CoordinateSystemTrafo ElementBase::getEdgeToEnd() const
{
CoordinateSystemTrafo ElementBase::getEdgeToEnd() const {
CoordinateSystemTrafo ret(Vector_t(0, 0, getElementLength()),
Quaternion(1, 0, 0, 0));
......@@ -530,21 +533,18 @@ CoordinateSystemTrafo ElementBase::getEdgeToEnd() const
}
inline
void ElementBase::setAperture(const ApertureType& type, const std::vector<double> &args)
{
void ElementBase::setAperture(const ApertureType& type, const std::vector<double> &args) {
aperture_m.first = type;
aperture_m.second = args;
}
inline
std::pair<ElementBase::ApertureType, std::vector<double> > ElementBase::getAperture() const
{
std::pair<ElementBase::ApertureType, std::vector<double> > ElementBase::getAperture() const {
return aperture_m;
}
inline
bool ElementBase::isInside(const Vector_t &r) const
{
bool ElementBase::isInside(const Vector_t &r) const {
const double length = getElementLength();
return r(2) >= 0.0 && r(2) < length && isInsideTransverse(r);
}
......@@ -612,13 +612,27 @@ double ElementBase::getElementPosition() const {
}
inline
bool ElementBase::isElementPositionSet() const
{ return elemedgeSet_m; }
bool ElementBase::isElementPositionSet() const {
return elemedgeSet_m;
}
inline
int ElementBase::getRequiredNumberOfTimeSteps() const
{
int ElementBase::getRequiredNumberOfTimeSteps() const {
return 10;
}
inline
void ElementBase::setOutputFN(const std::string fn) {
outputfn_m = fn;
}
inline
std::string ElementBase::getOutputFN() const {
if (outputfn_m.empty()) {
return getName();
} else {
return outputfn_m.substr(0, outputfn_m.rfind("."));
}
}
#endif // CLASSIC_ElementBase_HH
//
// Class FlexibleCollimator
// Defines the abstract interface for a collimator.
//
// Abstract collimator.
// Class FlexibleCollimator defines the abstract interface for a collimator.
//
// Copyright (c) 200x - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// Copyright (c) 200x - 2021, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved.
//
// This file is part of OPAL.
......@@ -17,16 +15,16 @@
// You should have received a copy of the GNU General Public License
// along with OPAL. If not, see <https://www.gnu.org/licenses/>.
//
#include "AbsBeamline/FlexibleCollimator.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "AbstractObjects/OpalData.h"
#include "Physics/Physics.h"
#include "Algorithms/PartBunchBase.h"
#include "AbsBeamline/BeamlineVisitor.h"
#include "Fields/Fieldmap.h"
#include "Physics/Physics.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Structure/LossDataSink.h"
#include "Utilities/Options.h"
#include "Solvers/ParticleMatterInteractionHandler.h"
#include "Utilities/Util.h"
#include <memory>
......@@ -43,7 +41,6 @@ FlexibleCollimator::FlexibleCollimator(const FlexibleCollimator &right):
description_m(right.description_m),
bb_m(right.bb_m),
tree_m(/*right.tree_m*/),