Commit f318d68c authored by kraus's avatar kraus
Browse files

Merge branch 'develop' into svn: fix issues with gcc 4.7

parent 182e9140
......@@ -42,6 +42,17 @@ OPTION (BUILD_LIBOPAL "Enable building the OPAL library" OFF)
OPTION (NOCPLUSPLUS11_FOREACH "Disable C++11 foreach support" OFF)
OPTION (NOCPLUSPLUS11_NULLPTR "Disable C++11 nullptr support" OFF)
OPTION (NO_FIELD_ASSIGN_OPTIMIZATION "Disable compiler optimization of IPPL field assignment" OFF)
SET (CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules")
FIND_PACKAGE (IPPL REQUIRED
PATHS /usr/local/include /usr/include $ENV{IPPL_PREFIX})
MESSAGE (STATUS "Found IPPL library dir: ${IPPL_LIBRARY_DIR}")
MESSAGE (STATUS "Found IPPL include dir: ${IPPL_INCLUDE_DIR}")
FIND_PACKAGE (H5Hut REQUIRED)
FIND_PACKAGE (HDF5 REQUIRED)
FIND_PACKAGE (GSL REQUIRED)
IF (DBG_SCALARFIELD)
MESSAGE (STATUS "\nWrite scalar rho_m field is enabled ")
......@@ -71,6 +82,12 @@ IF (NOCPLUSPLUS11_NULLPTR)
)
ENDIF (NOCPLUSPLUS11_NULLPTR)
IF (NO_FIELD_ASSIGN_OPTIMIZATION)
MESSAGE (STATUS "\nCompiler will not try to optimize field assignment")
SET (CMAKE_CXX_FLAGS
"-DdontOPTIMIZE_FIELD_ASSIGNMENT ${CMAKE_CXX_FLAGS}"
)
ENDIF (NO_FIELD_ASSIGN_OPTIMIZATION)
IF (ENABLE_ML_SOLVER)
# Get Trilinos as one entity
......@@ -143,11 +160,18 @@ IF ("${COMPILER_NAME}" STREQUAL "mpicxx")
OUTPUT_VARIABLE GCC_VERSION_OUTPUT
ERROR_VARIABLE GCC_VERSION_ERROR)
STRING (REGEX REPLACE ".*([0-9]\\.[0-9]\\.[0-9]).*" "\\1" GCC_VERSION ${GCC_VERSION_OUTPUT})
IF (${GCC_VERSION} VERSION_LESS "4.6.0" AND ${GCC_VERSION} VERSION_GREATER "4.5.0")
SET (OTHER_CMAKE_CXX_FLAGS
"-DOPAL_NOCPLUSPLUS11_NULLPTR -DOPAL_NOCPLUSPLUS11_FOREACH ${OTHER_CMAKE_CXX_FLAGS}")
MESSAGE (STATUS "YOUR GCC VERSION IS: 4.5")
ENDIF (${GCC_VERSION} VERSION_LESS "4.6.0" AND ${GCC_VERSION} VERSION_GREATER "4.5.0")
MESSAGE (STATUS "Your gcc version is: ${GCC_VERSION}")
IF (${GCC_VERSION} VERSION_LESS "4.5.0")
MESSAGE (FATAL_ERROR "To build OPAL you need gcc version 4.5.0 or greater")
ELSEIF (${GCC_VERSION} VERSION_LESS "4.6.0")
SET (OTHER_CMAKE_CXX_FLAGS
"-DOPAL_NOCPLUSPLUS11_NULLPTR -DOPAL_NOCPLUSPLUS11_FOREACH ${OTHER_CMAKE_CXX_FLAGS}")
ELSEIF (${GCC_VERSION} VERSION_EQUAL "4.7.0")
SET (OTHER_CMAKE_CXX_FLAGS
"-DdontOPTIMIZE_FIELD_ASSIGNMENT ${OTHER_CMAKE_CXX_FLAGS}")
ENDIF (${GCC_VERSION} VERSION_LESS "4.5.0")
ELSE ("${MPI_UNDERLYING_COMPILER_NAME}" STREQUAL "icpc")
# using unknown compiler
MESSAGE (STATUS "${COMPILER_NAME} is using a compiler (${MPI_UNDERLYING_COMPILER}) we were not thinking of!
......
......@@ -11,6 +11,7 @@
#include "Meshes/Centering.h"
#include "FieldLayout/CenteredFieldLayout.h"
#include "Field/Field.h"
#include "FFT/FFT.h"
typedef IntCIC IntrplCIC_t;
typedef IntNGP IntrplNGP_t;
......@@ -35,4 +36,9 @@ typedef CenteredFieldLayout<3, Mesh_t, Center_t> FieldLayout_t;
typedef Field<double, 3, Mesh_t, Center_t> Field_t;
typedef Field<Vector_t, 3, Mesh_t, Center_t> VField_t;
typedef Field<int, 3, Mesh_t, Center_t> IField_t;
typedef Field<dcomplex, 3, Mesh_t, Center_t> CxField_t;
typedef FFT<RCTransform, 3, double> FFT_t;
typedef FFT<SineTransform, 3, double> SINE_t;
#endif
......@@ -218,7 +218,7 @@ void CSRWakeFunction::calculateContributionAfter(size_t sliceNumber, double angl
// prior to the bend.
double Ds_max2 = bendRadius_m * pow(totalBendAngle_m, 2) / 6. * (3. * angleOfSlice - 2. * totalBendAngle_m);
int j = 0;
double frac;
double frac = 0.0;
if(Ds_max2 / meshSpacing < sliceNumber) {
j = sliceNumber - static_cast<int>(floor(Ds_max2 / meshSpacing));
frac = Ds_max2 / meshSpacing - (sliceNumber - j);
......
......@@ -8,6 +8,7 @@
***************************************************************************/
// include files
#include "Algorithms/PartBunch.h"
#include "FFTBoxPoissonSolver.h"
#include "Physics/Physics.h"
#include <fstream>
......
......@@ -22,30 +22,10 @@
#define FFT_BOXPOISSON_SOLVER_H_
//////////////////////////////////////////////////////////////
//#include "Ippl.h"
//class PartBunch;
#include "PoissonSolver.h"
class FFTBoxPoissonSolver;
#include "Algorithms/PartBunch.h"
class PartBunch;
//////////////////////////////////////////////////////////////
// typedef ParticleSpatialLayout<double, 3>::ParticlePos_t Ppos_t;
// typedef ParticleSpatialLayout<double, 3>::ParticleIndex_t PID_t;
// typedef UniformCartesian<3, double> Mesh_t;
// typedef ParticleSpatialLayout<double, 3>::SingleParticlePos_t Vector_t;
// typedef ParticleSpatialLayout< double, 3, Mesh_t > Layout_t;
// typedef Cell Center_t;
// typedef CenteredFieldLayout<3, Mesh_t, Center_t> FieldLayout_t;
// typedef Field<double, 3, Mesh_t, Center_t> Field_t;
typedef Field<int, 3, Mesh_t, Center_t> IField_t;
typedef FFT<SineTransform, 3, double> SINE_t;
class FFTBoxPoissonSolver : public PoissonSolver {
public:
// constructor and destructor
......
......@@ -446,19 +446,7 @@ void FFTPoissonSolver::integratedGreensFunction() {
tmpgreen[I+1][J+1][K+1] - tmpgreen[I][J+1][K+1] - tmpgreen[I+1][J][K+1] + tmpgreen[I][J][K+1] - tmpgreen[I+1][J+1][K] +
tmpgreen[I][J+1][K] + tmpgreen[I+1][J][K] - tmpgreen[I][J][K]);*/
rho2_m[0][0][0] = rho2_m[0][0][1];
Index IE(nr_m[0] + 1, 2 * nr_m[0] - 1);
Index JE(nr_m[1] + 1, 2 * nr_m[1] - 1);
Index KE(nr_m[2] + 1, 2 * nr_m[2] - 1);
rho2_m[IE][JE][KE] = rho2_m[2*nr_m[0] - IE][2*nr_m[1] - JE][2*nr_m[2] - KE];
rho2_m[IE][J ][K ] = rho2_m[2*nr_m[0] - IE][J][K];
rho2_m[I ][JE][K ] = rho2_m[I][2*nr_m[1] - JE][K];
rho2_m[I ][J ][KE] = rho2_m[I][J][2*nr_m[2] - KE];
rho2_m[IE][JE][K ] = rho2_m[2*nr_m[0] - IE][2*nr_m[1] - JE][K];
rho2_m[IE][J ][KE] = rho2_m[2*nr_m[0] - IE][J][2*nr_m[2] - KE];
rho2_m[I ][JE][KE] = rho2_m[I][2*nr_m[1] - JE][2*nr_m[2] - KE];
mirrorRhoField();
IpplTimings::stopTimer(IntGreensFunctionTimer3_m);
IpplTimings::startTimer(IntGreensFunctionTimer4_m);
......@@ -466,7 +454,6 @@ void FFTPoissonSolver::integratedGreensFunction() {
IpplTimings::stopTimer(IntGreensFunctionTimer4_m);
}
void FFTPoissonSolver::shiftedIntGreensFunction(double zshift) {
tmpgreen = 0.0;
......@@ -567,10 +554,6 @@ void FFTPoissonSolver::shiftedIntGreensFunction(double zshift) {
ggrn2[I][J][K] -= grn2[I][J+1][K+1];
ggrn2[I][J][K] -= grn2[I][J][K];
Index IE(nr_m[0] + 1, 2 * nr_m[0] - 1);
Index JE(nr_m[1] + 1, 2 * nr_m[1] - 1);
Index KE(nr_m[2], 2 * nr_m[2] - 1);
/**
** (x[0:nr_m[0]-1]^2 + y[0:nr_m[1]-1]^2 + (z_c + z[0:nr_m[2]-1])^2)^{-0.5}
** (x[nr_m[0]:1]^2 + y[0:nr_m[1]-1]^2 + (z_c + z[0:nr_m[2]-1])^2)^{-0.5}
......@@ -583,14 +566,7 @@ void FFTPoissonSolver::shiftedIntGreensFunction(double zshift) {
** (x[nr_m[0]:1]^2 + y[nr_m[1]:1]^2 + (z_c - z[nr_m[2]:1])^2)^{-0.5}
*/
rho2_m[IE][J ][K ] = rho2_m[2*nr_m[0] - IE][J][K];
rho2_m[I ][JE][K ] = rho2_m[I][2*nr_m[1] - JE][K];
rho2_m[IE][JE][K ] = rho2_m[2*nr_m[0] - IE][2*nr_m[1] - JE][K];
rho2_m[I ][J ][KE] = ggrn2[I][J][KE - nr_m[2]];
rho2_m[IE][J ][KE] = ggrn2[2*nr_m[0] - IE][J][KE - nr_m[2]];
rho2_m[I ][JE][KE] = ggrn2[I][2*nr_m[1] - JE][KE - nr_m[2]];
rho2_m[IE][JE][KE] = ggrn2[2*nr_m[0] - IE][2*nr_m[1] - JE][KE - nr_m[2]];
mirrorRhoField(ggrn2);
//rho2_m[I ][J ][KE] = tmpgreen[I][J][2*nr_m[2] - KE];
//rho2_m[IE][J ][KE] = tmpgreen[2*nr_m[0] - IE][J][2*nr_m[2] - KE];
......@@ -606,6 +582,7 @@ void FFTPoissonSolver::shiftedIntGreensFunction(double zshift) {
for (int k=0;k<32;k++)
fstr << k+1 << " " << j+1 << " " << i+1 << " " << rho2_m[k][j][i] << endl;
fstr.close();*/
IpplTimings::stopTimer(ShIntGreensFunctionTimer3_m);
IpplTimings::startTimer(ShIntGreensFunctionTimer4_m);
......@@ -614,6 +591,55 @@ void FFTPoissonSolver::shiftedIntGreensFunction(double zshift) {
}
void FFTPoissonSolver::mirrorRhoField() {
Index I(0, nr_m[0] + 1);
Index J(0, nr_m[1] + 1);
Index K(0, nr_m[2] + 1);
Index IE(nr_m[0] + 1, 2 * nr_m[0] - 1);
Index JE(nr_m[1] + 1, 2 * nr_m[1] - 1);
Index KE(nr_m[2] + 1, 2 * nr_m[2] - 1);
Index mirroredIE = 2*nr_m[0] - IE;
Index mirroredJE = 2*nr_m[1] - JE;
Index mirroredKE = 2*nr_m[2] - KE;
rho2_m[0][0][0] = rho2_m[0][0][1];
rho2_m[IE][J ][K ] = rho2_m[mirroredIE][J ][K ];
rho2_m[I ][JE][K ] = rho2_m[I ][mirroredJE][K ];
rho2_m[I ][J ][KE] = rho2_m[I ][J ][mirroredKE];
rho2_m[IE][JE][K ] = rho2_m[mirroredIE][mirroredJE][K ];
rho2_m[IE][J ][KE] = rho2_m[mirroredIE][J ][mirroredKE];
rho2_m[I ][JE][KE] = rho2_m[I ][mirroredJE][mirroredKE];
rho2_m[IE][JE][KE] = rho2_m[mirroredIE][mirroredJE][mirroredKE];
}
void FFTPoissonSolver::mirrorRhoField(Field_t & ggrn2) {
Index I = nr_m[0] + 1;
Index J = nr_m[1] + 1;
Index K = nr_m[2] + 1;
Index IE(nr_m[0] + 1, 2 * nr_m[0] - 1);
Index JE(nr_m[1] + 1, 2 * nr_m[1] - 1);
Index KE(nr_m[2], 2 * nr_m[2] - 1);
Index mirroredIE = 2*nr_m[0] - IE;
Index mirroredJE = 2*nr_m[1] - JE;
Index shiftedKE(0, nr_m[2] - 1);
rho2_m[IE][J ][K ] = rho2_m[mirroredIE][J ][K];
rho2_m[I ][JE][K ] = rho2_m[I ][mirroredJE][K];
rho2_m[IE][JE][K ] = rho2_m[mirroredIE][mirroredJE][K];
rho2_m[I ][J ][KE] = ggrn2[I ][J ][shiftedKE];
rho2_m[IE][J ][KE] = ggrn2[mirroredIE][J ][shiftedKE];
rho2_m[I ][JE][KE] = ggrn2[I ][mirroredJE][shiftedKE];
rho2_m[IE][JE][KE] = ggrn2[mirroredIE][mirroredJE][shiftedKE];
}
Inform &FFTPoissonSolver::print(Inform &os) const {
os << "* ************* F F T P o i s s o n S o l v e r ************************************ " << endl;
os << "* h " << hr_m << '\n';
......
......@@ -21,43 +21,19 @@
#ifndef FFT_POISSON_SOLVER_H_
#define FFT_POISSON_SOLVER_H_
#ifdef dontOPTIMIZE_FIELD_ASSIGNMENT
#define FIELDASSIGNOPTIMIZATION __attribute__((optimize(0)))
#else
#define FIELDASSIGNOPTIMIZATION
#endif
#include <memory>
//////////////////////////////////////////////////////////////
//#include "Ippl.h"
#include "FFT/FFT.h"
class PartBunch;
class FFTPoissonSolver;
//#include "Algorithms/PartBunch.h"
#include "PoissonSolver.h"
//////////////////////////////////////////////////////////////
// typedef IntCIC IntrplCIC_t;
// typedef IntNGP IntrplNGP_t;
// typedef IntSUDS IntrplSUDS_t;
// typedef ParticleSpatialLayout<double, 3>::ParticlePos_t Ppos_t;
// typedef ParticleSpatialLayout<double, 3>::ParticleIndex_t PID_t;
// typedef ParticleAttrib<double> Pscalar_t;
// typedef InterpolatorTraits<double, 3, IntrplCIC_t>::Cache_t Pcache_t;
// typedef UniformCartesian<3, double> Mesh_t;
// typedef ParticleSpatialLayout<double, 3>::SingleParticlePos_t Vector_t;
// typedef ParticleSpatialLayout< double, 3, Mesh_t > Layout_t;
// typedef Cell Center_t;
// typedef CenteredFieldLayout<3, Mesh_t, Center_t> FieldLayout_t;
// typedef Field<double, 3, Mesh_t, Center_t> Field_t;
// typedef Field<Vector_t, 3, Mesh_t, Center_t> VField_t;
class PartBunch;
typedef Field<int, 3, Mesh_t, Center_t> IField_t;
typedef Field<dcomplex, 3, Mesh_t, Center_t> CxField_t;
typedef FFT<RCTransform, 3, double> FFT_t;
//////////////////////////////////////////////////////////////
class FFTPoissonSolver : public PoissonSolver {
public:
......@@ -95,6 +71,9 @@ public:
Inform &print(Inform &os) const;
private:
void mirrorRhoField() FIELDASSIGNOPTIMIZATION;
void mirrorRhoField(Field_t & ggrn2) FIELDASSIGNOPTIMIZATION;
// rho2_m is the charge-density field with mesh doubled in each dimension
Field_t rho2_m;
......
......@@ -17,6 +17,11 @@
// ------------------------------------------------------------------------
#include "Structure/FieldSolver.h"
#include "Solvers/FFTPoissonSolver.h"
#include "Solvers/FFTBoxPoissonSolver.h"
#ifdef HAVE_ML_SOLVER
#include "Solvers/MGPoissonSolver.h"
#endif
#include "AbstractObjects/Expressions.h"
#include "AbstractObjects/OpalData.h"
#include "Attributes/Attributes.h"
......@@ -26,6 +31,7 @@
#include "Utilities/OpalException.h"
#include "BoundaryGeometry.h"
#include "AbstractObjects/Element.h"
#include "Algorithms/PartBunch.h"
using namespace Expressions;
using namespace Physics;
......
......@@ -21,16 +21,9 @@
class FieldSolver;
#include "AbstractObjects/Definition.h"
#include "Algorithms/PartData.h"
//class PartBunch;
#include "Algorithms/PartBunch.h"
//#include "Ippl.h"
//class FFTPosissonSolver;
#include "Solvers/PoissonSolver.h"
#include "Solvers/FFTPoissonSolver.h"
#include "Solvers/FFTBoxPoissonSolver.h"
#ifdef HAVE_ML_SOLVER
#include "Solvers/MGPoissonSolver.h"
#endif
class PartBunch;
// Class FieldSolver
......@@ -40,29 +33,6 @@ class FieldSolver;
// particle charge and the reference momentum, together with some other
// data.
// typedef IntCIC IntrplCIC_t;
// typedef IntNGP IntrplNGP_t;
// typedef IntSUDS IntrplSUDS_t;
// typedef ParticleSpatialLayout<double, 3>::ParticlePos_t Ppos_t;
// typedef ParticleSpatialLayout<double, 3>::ParticleIndex_t PID_t;
// typedef ParticleAttrib<double> Pscalar_t;
// typedef InterpolatorTraits<double, 3, IntrplCIC_t>::Cache_t Pcache_t;
// typedef UniformCartesian<3, double> Mesh_t;
// typedef ParticleSpatialLayout<double, 3>::SingleParticlePos_t Vector_t;
// typedef ParticleSpatialLayout< double, 3, Mesh_t > Layout_t;
// typedef Cell Center_t;
// typedef CenteredFieldLayout<3, Mesh_t, Center_t> FieldLayout_t;
// typedef Field<double, 3, Mesh_t, Center_t> Field_t;
// typedef Field<Vector_t, 3, Mesh_t, Center_t> VField_t;
class FieldSolver: public Definition {
public:
......
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