Commit 60e0befb authored by frey_m's avatar frey_m
Browse files

Merge branch 'master' of gitlab.psi.ch:OPAL/src into 542-saamg-wrong-results-with-elliptic-geometry

parents e2643bd8 3b011614
......@@ -222,19 +222,18 @@ endif ()
option (ENABLE_DOXYDOC "compile Doxygen documentation" OFF)
include (FindGit)
if (GIT_FOUND)
set (OPAL_WC_REVISION 0)
execute_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_OUT OUTPUT_STRIP_TRAILING_WHITESPACE
)
set (OPAL_WC_REVISION \"${GIT_OUT}\")
else ()
message (STATUS "could not find git")
set (OPAL_WC_REVISION \"\")
endif ()
add_custom_target(always_rebuild ALL
DEPENDS
src/OPALrevision.h
)
add_custom_command(
OUTPUT src/OPALrevision.h
COMMAND ./gen_OPALrevision
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
DEPENDS
always_rebuild
)
add_subdirectory (ippl)
add_subdirectory (optimizer)
......
#!/bin/bash
#
# create/rewrite 'src/OPALrevision.h'
#
print () {
echo '#define GIT_VERSION '\"$1\" > src/OPALrevision.h
}
# if git(1) is not in $PATH
if ! which -a git &> /dev/null; then
if [[ -e src/OPALrevision.h ]]; then
# do nothing if file exist
exit 0
else
# otherwise create file
print unknown
exit $?
fi
fi
# if we are in a work-tree
if git rev-parse --is-inside-work-tree &> /dev/null; then
# create/rewrite file
revision=$(git rev-parse HEAD)
print ${revision}
exit $?
fi
# if we are not in a work tree and the file does not exist
if [[ ! -e src/OPALrevision.h ]]; then
# create file
print unknown
exit $?
fi
exit 0
\ No newline at end of file
//
// Class CellParticleCachingPolicy
//
// The Cell caching layout ensures that each node has all ghost particles
// for each external particle that is inside a neighboring cell.
//
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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/>.
//
#ifndef CELL_PARTICLE_CACHING_POLICY
#define CELL_PARTICLE_CACHING_POLICY
/*
*
* The Cell caching layout ensures that each node has all ghost particles
* for each external particle that is inside a neighboring cell.
*
*/
#include <Particle/BoxParticleCachingPolicy.h>
template<class T, unsigned Dim, class Mesh>
......@@ -56,4 +72,12 @@ private:
int cells[Dim];
};
#endif
\ No newline at end of file
#endif
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
\ No newline at end of file
//
// Class NoParticleCachingPolicy
// Empty caching strategy that doesn't cache anything
//
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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/>.
//
#ifndef NO_PARTICLE_CACHING_POLICY
#define NO_PARTICLE_CACHING_POLICY
/*
*
* Empty caching strategy that doesn't cache anything
*
*/
template <class T, unsigned Dim, class Mesh, class CachingPolicy> class ParticleSpatialLayout;
//basic policy that doesn't cache any particles
......@@ -33,3 +48,11 @@ protected:
};
#endif
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
*
* Visit http://people.web.psi.ch/adelmann/ for more details
*
***************************************************************************/
//
// Class ParticleCashedLayout
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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/>.
//
#ifndef PARTICLE_CASHED_LAYOUT_H
#define PARTICLE_CASHED_LAYOUT_H
......@@ -178,10 +187,12 @@ private:
#include "Particle/ParticleCashedLayout.hpp"
#endif // PARTICLE_CASHED_LAYOUT_H
#endif
/***************************************************************************
* $RCSfile: ParticleCashedLayout.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:29 $
* IPPL_VERSION_ID: $Id: ParticleCashedLayout.h,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $
***************************************************************************/
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
\ No newline at end of file
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
***************************************************************************/
//
// Class ParticleCashedLayout
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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 files
#include "Particle/ParticleCashedLayout.h"
#include "Particle/ParticleBConds.h"
#include "Particle/IpplParticleBase.h"
......@@ -896,9 +907,10 @@ void ParticleCashedLayout<T,Dim,Mesh>::Repartition(UserList* userlist) {
}
}
/***************************************************************************
* $RCSfile: ParticleCashedLayout.cpp,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:29 $
* IPPL_VERSION_ID: $Id: ParticleCashedLayout.cpp,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $
***************************************************************************/
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
\ No newline at end of file
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
***************************************************************************/
//
// Class ParticleInteractLayout
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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/>.
//
#ifndef PARTICLE_INTERACT_LAYOUT_H
#define PARTICLE_INTERACT_LAYOUT_H
......@@ -205,10 +217,12 @@ private:
#include "Particle/ParticleInteractLayout.hpp"
#endif // PARTICLE_INTERACT_LAYOUT_H
#endif
/***************************************************************************
* $RCSfile: ParticleInteractLayout.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:29 $
* IPPL_VERSION_ID: $Id: ParticleInteractLayout.h,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $
***************************************************************************/
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
// -*- C++ -*-
/***************************************************************************
*
* The IPPL Framework
*
***************************************************************************/
// include files
//
// Class ParticleInteractLayout
// Please note: for the time being this class is *not* used! But since it
// might be used in future projects, we keep this file.
//
// Copyright (c) 2003 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
//
// 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 "Particle/ParticleInteractLayout.h"
#include "Particle/ParticleBConds.h"
#include "Particle/IpplParticleBase.h"
......@@ -15,7 +26,6 @@
#include "Message/Communicate.h"
#include "Message/Message.h"
#include <algorithm>
/////////////////////////////////////////////////////////////////////
......@@ -978,3 +988,11 @@ void ParticleInteractLayout<T,Dim,Mesh>::Repartition(UserList* userlist) {
NeedGhostSwap = true;
}
}
// vi: set et ts=4 sw=4 sts=4:
// Local Variables:
// mode:c
// c-basic-offset: 4
// indent-tabs-mode: nil
// require-final-newline: nil
// End:
......@@ -674,6 +674,10 @@ std::string OpalData::getTitle() {
return p->itsTitle_m;
}
std::string OpalData::getAuxiliaryOutputDirectory() const {
return "data";
}
std::string OpalData::getInputFn() {
return p->inputFn_m;
}
......
......@@ -182,6 +182,9 @@ public:
/// get the step where to restart
int getRestartStep();
/// get the name of the the additional data directory
std::string getAuxiliaryOutputDirectory() const;
/// get opals input filename
std::string getInputFn();
......
......@@ -9,6 +9,7 @@
#include <fstream>
#include <iostream>
#include <string>
extern Inform *gmsg;
......@@ -124,13 +125,19 @@ double CavityAutophaser::getPhaseAtMaxEnergy(const Vector_t &R,
newPhase = std::fmod(originalPhase + optimizedPhase + Physics::two_pi, Physics::two_pi);
element->setPhasem(newPhase);
element->setAutophaseVeto();
OpalData::getInstance()->setMaxPhase(itsCavity_m->getName(), newPhase);
auto opal = OpalData::getInstance();
opal->setMaxPhase(itsCavity_m->getName(), newPhase);
newPhase = std::fmod(newPhase + basePhase, Physics::two_pi);
auto opal = OpalData::getInstance();
if (!opal->isOptimizerRun()) {
std::ofstream out("data/" + itsCavity_m->getName() + "_AP.dat");
std::string fname = Util::combineFilePath({
opal->getAuxiliaryOutputDirectory(),
itsCavity_m->getName() + "_AP.dat"
});
std::ofstream out(fname);
track(initialR_m, initialP_m, t + tErr, dt, newPhase, &out);
out.close();
} else {
......
......@@ -10,6 +10,7 @@
#include "AbsBeamline/Bend2D.h"
#include "Physics/Physics.h"
#include "Structure/ElementPositionWriter.h"
#include "Utilities/Util.h"
extern Inform *gmsg;
......@@ -275,7 +276,10 @@ void IndexMap::saveSDDS(double initialPathLength) const {
sectors.insert(sectors.end(), tmp.begin(), tmp.end());
}
std::string fileName("data/" + OpalData::getInstance()->getInputBasename() + "_ElementPositions.sdds");
std::string fileName = Util::combineFilePath({
OpalData::getInstance()->getAuxiliaryOutputDirectory(),
OpalData::getInstance()->getInputBasename() + "_ElementPositions.sdds"
});
ElementPositionWriter writer(fileName);
for (auto sector: sectors) {
......
......@@ -48,8 +48,11 @@ OrbitThreader::OrbitThreader(const PartData &ref,
{
auto opal = OpalData::getInstance();
if (Ippl::myNode() == 0 && !opal->isOptimizerRun()) {
std::string fileName = "data/" + OpalData::getInstance()->getInputBasename() + "_DesignPath.dat";
if (OpalData::getInstance()->getOpenMode() == OpalData::OPENMODE::WRITE ||
std::string fileName = Util::combineFilePath({
opal->getAuxiliaryOutputDirectory(),
opal->getInputBasename() + "_DesignPath.dat"
});
if (opal->getOpenMode() == OpalData::OPENMODE::WRITE ||
!boost::filesystem::exists(fileName)) {
logger_m.open(fileName);
logger_m << "#"
......
......@@ -205,15 +205,16 @@ void ParallelCyclotronTracker::bgf_main_collision_test() {
int triId = 0;
for(size_t i = 0; i < itsBunch_m->getLocalNum(); i++) {
int res = bgf_m->partInside(itsBunch_m->R[i], itsBunch_m->P[i], dtime, itsBunch_m->PType[i], itsBunch_m->Q[i], intecoords, triId);
//int res = bgf_m->partInside(itsBunch_m->R[i]*1.0e-3, itsBunch_m->P[i], dtime, itsBunch_m->PType[i], itsBunch_m->Q[i], intecoords, triId);
int res = bgf_m->partInside(itsBunch_m->R[i], itsBunch_m->P[i],
dtime, intecoords, triId);
if(res >= 0) {
lossDs_m->addParticle(itsBunch_m->R[i], itsBunch_m->P[i],
itsBunch_m->ID[i], itsBunch_m->getT()*1e9,
turnnumber_m, itsBunch_m->bunchNum[i]);
itsBunch_m->Bin[i] = -1;
Inform gmsgALL("OPAL", INFORM_ALL_NODES);
gmsgALL << level4 << "* Particle " << itsBunch_m->ID[i] << " lost on boundary geometry" << endl;
gmsgALL << level4 << "* Particle " << itsBunch_m->ID[i]
<< " lost on boundary geometry" << endl;
}
}
}
......
......@@ -71,7 +71,8 @@ AmrYtWriter::AmrYtWriter(int step, int bin)
namespace fs = boost::filesystem;
fs::path dir = OpalData::getInstance()->getInputBasename();
boost::filesystem::path path = dir.parent_path() / "data" / "amr" / "yt";
std::string dataDir = OpalData::getInstance()->getAuxiliaryOutputDirectory();
boost::filesystem::path path = dir.parent_path() / dataDir / "amr" / "yt";
dir_m = amrex::Concatenate((path / "plt").string(), step, 10);
dir_m += "-";
dir_m = amrex::Concatenate(dir_m, bin, 3);
......
......@@ -45,6 +45,38 @@
using namespace Expressions;
namespace {
std::string stringifyVariable(Object *obj) {
ValueDefinition *value = dynamic_cast<ValueDefinition*>(obj);
if (value) {
std::ostringstream valueStream;
try {
double real = value->getReal();
valueStream << real;
return valueStream.str();
} catch (OpalException const& e) {
}
try {
std::string str = value->getString();
valueStream << str;
return valueStream.str();
} catch (OpalException const& e) {
}
try {
bool boolean = value->getBool();
valueStream << std::boolalpha << boolean;
return Util::toUpper(valueStream.str());
} catch (OpalException const&) {
}
}
throw OpalException("Attributes::stringifyVariable",
"The variable '" + obj->getOpalName() + "' isn't of type REAL, STRING or BOOL");
return "";
}
}
// Namespace Attributes.
// ------------------------------------------------------------------------
......@@ -337,13 +369,10 @@ namespace Attributes {
std::string variable = Util::toUpper(std::string(what[1].first, what[1].second));
if (Object *obj = opal->find(variable)) {
std::ostringstream value;
RealVariable *real = static_cast<RealVariable*>(obj);
real->printValue(value);
exprDeref += value.str();
exprDeref += ::stringifyVariable(obj);
} else {
exprDeref += std::string(what[0].first, what[0].second);
throw OpalException("Attributes::getString",
"Can't find variable '" + variable + "' in string \"" + expr + "\"");
}
start = what[0].second;
......
......@@ -30,7 +30,6 @@ else ()
endif ()
configure_file(config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/OPALconfig.h)
configure_file(revision.h.in ${CMAKE_CURRENT_SOURCE_DIR}/OPALrevision.h)
set (OPAL_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set (OPAL_SRCS )
......
......@@ -76,9 +76,6 @@ class VerticalFFAMagnet;
// Integrators.
class Integrator;
class MapIntegrator;
class TrackIntegrator;
// Class BeamlineVisitor
// ------------------------------------------------------------------------
......@@ -252,12 +249,6 @@ public:
/// Apply the algorithm to a generic integrator.
virtual void visitIntegrator(const Integrator &) = 0;
/// Apply the algorithm to an integrator capable of tracking.
virtual void visitTrackIntegrator(const TrackIntegrator &) = 0;
/// Apply the algorithm to an integrator capable of mapping.
virtual void visitMapIntegrator(const MapIntegrator &) = 0;
/// Apply the algorithm to a vertical FFA magnet
virtual void visitVerticalFFAMagnet(const VerticalFFAMagnet &) = 0;
......
This diff is collapsed.
......@@ -33,10 +33,10 @@
#endif
#include <array>
#include <cmath>
#include <string>
#include <vector>
class Fieldmap;
class MeshData;
/*
......@@ -60,7 +60,7 @@ public:
virtual ~Bend2D();
/// Apply visitor to Bend2D.
virtual void accept(BeamlineVisitor &) const = 0;
virtual void accept(BeamlineVisitor &) const override = 0;
/*
* Methods for OPAL-T.
......@@ -71,51 +71,48 @@ public:
virtual bool apply(const size_t &i,
const double &t,
Vector_t &E,
Vector_t &B);
Vector_t &B) override;
/// Apply field to particles in beam frame.
virtual bool apply(const Vector_t &R,
const Vector_t &P,
const double &t,
Vector_t &E,
Vector_t &B);
Vector_t &B) override;
virtual bool applyToReferenceParticle(const Vector_t &R,
const Vector_t &P,
const double &t,
Vector_t &E,
Vector_t &B);
Vector_t &B) override;
virtual void goOnline(const double &kineticEnergy);
virtual void goOnline(const double &kineticEnergy) override;