Commit 4e784138 authored by Tuelin Kaman's avatar Tuelin Kaman
Browse files

C++11 fixes for MGSolver. OPAL is compiled with -DENABLE_ML_SOLVER=TRUE option now.

parent 1c5f97f7
......@@ -81,8 +81,20 @@ ENDIF (NO_FIELD_ASSIGN_OPTIMIZATION)
IF (ENABLE_ML_SOLVER)
# Get Trilinos as one entity
FIND_PACKAGE (Trilinos PATHS $ENV{TRILINOS_INCLUDE_PATH})
# FIND_PACKAGE(Trilinos PATHS $ENV{TRILINOS_INCLUDE_DIR})
FIND_PACKAGE(Trilinos REQUIRED HINTS $ENV{TRILINOS_INCLUDE_DIR})
SET (Trilinos_INCLUDE_DIRS "$ENV{TRILINOS_INCLUDE_DIR}"
)
SET (Trilinos_LIBRARY_DIRS "$ENV{TRILINOS_LIBRARY_DIR}"
)
SET (Trilinos_LIBRARIES "-lbelosepetra -lbelos -lml -lgaleri -lamesos -lifpack -lepetraext -lepetra -lteuchos -ltriutils -laztecoo -lisorropia -lzoltan $ENV{PARMETIS_LIB_DIR}/libparmetis.a $ENV{METIS_LIB_DIR}/libmetis.a $ENV{BLAS_LIB_DIR}/libblas.a $ENV{LAPACK_LIB_DIR}/liblapacke.a $ENV{LAPACK_LIB_DIR}/liblapack.a -lgfortran "
)
# SET (Trilinos_TPL_LIBRARY_DIRS "$ENV{TRILINOS_TPL_LIBRARY_DIRS}"
# )
# SET (Trilinos_TPL_LIBRARIES "$ENV{PARMETIS_PREFIX}/lib/libparmetis.a $ENV{METIS_PREFIX}/lib/libmetis.a $ENV{BLAS_PREFIX}/lib/blas.a $ENV{LAPACK_PREFIX}/lib/lapacke.a $ENV{LAPACK_PREFIX}/lib/lapack.a -lgfortran"
# )
IF (NOT Trilinos_FOUND)
MESSAGE (FATAL_ERROR "Could not find Trilinos!")
ENDIF (NOT Trilinos_FOUND)
......@@ -175,8 +187,8 @@ ELSE ("${COMPILER_NAME}" STREQUAL "mpicxx")
ENDIF ("${COMPILER_NAME}" STREQUAL "mpicxx")
SET (CMAKE_CXX_FLAGS
"-Wall -Werror -std=c++0x $ENV{CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_CMAKE_CXX_FLAGS}")
"-Wall -Werror -Wno-reorder -std=c++11 $ENV{CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS} ${OTHER_CMAKE_CXX_FLAGS}")
#Make sure the members appear in the initializer list in the same order as they appear in the class or turn -Wno-reorder
MESSAGE (STATUS "Compiling with ${CMAKE_CXX_FLAGS}")
......
#ifdef HAVE_ML_SOLVER
#include <map>
#include <string>
#include <cmath>
#include <iostream>
#include <assert.h>
......@@ -10,7 +11,6 @@
extern Inform *gmsg;
BoxCornerDomain::BoxCornerDomain(Vector_t nr, Vector_t hr) {
setNr(nr);
setHr(hr);
......@@ -36,12 +36,12 @@ BoxCornerDomain::BoxCornerDomain(double A, double B, double C, double Lenght, do
if(Ippl::getNodes() == 1) {
*gmsg << " Write BoxCorner data to file boxcorner.dat" << endl;
string file("boxcorner.dat");
std::string file("boxcorner.dat");
os_m.open(file.c_str());
if(os_m.bad()) {
*gmsg << "Unable to open output file " << file << endl;
}
os_m << "# ...." << endl;
//os_m << "# ...." << endl;
}
}
......@@ -72,7 +72,7 @@ void BoxCornerDomain::Compute(Vector_t hr) {
double bH= getB(getMaxZ());
actBMin_m = -B_m;
actBMax_m = max(bL,bH);
actBMax_m = std::max(bL,bH);
INFOMSG(" BoxCorner L= " << Lenght_m << " L1= " << L1_m << " L2= " << L2_m << " A= " << A_m << " B= " << B_m << " C= " << C_m
<< " bL= " << bL << " bH= " << bH << " actBMin= " << actBMin_m << " actBMax=max(bL,bH)= " << actBMax_m << endl);
......
#ifndef BOXCORNER_DOMAIN_H
#define BOSCORNER_DOMAIN_H
#define BOXCORNER_DOMAIN_H
#ifdef HAVE_ML_SOLVER
//#include <vector>
#include <map>
#include <multimap>
//#include <multimap>
#include <string>
#include <cmath>
#include <iostream> // Neeeded for stream I/O
......
......@@ -92,15 +92,15 @@ void EllipticDomain::Compute(Vector_t hr) {
for(x = 0; x < nr[0]; x++) {
pos = x * hr[0] - mx;
yd = std::abs(sqrt(sminsq - sminsq * pos * pos / smajsq)); // + 0.5*nr[1]*hr[1]);
IntersectYDir.insert(pair<int, double>(x, yd));
IntersectYDir.insert(pair<int, double>(x, -yd));
IntersectYDir.insert(std::pair<int, double>(x, yd));
IntersectYDir.insert(std::pair<int, double>(x, -yd));
}
for(y = 0; y < nr[1]; y++) {
pos = y * hr[1] - my;
xd = std::abs(sqrt(smajsq - smajsq * pos * pos / sminsq)); // + 0.5*nr[0]*hr[0]);
IntersectXDir.insert(pair<int, double>(y, xd));
IntersectXDir.insert(pair<int, double>(y, -xd));
IntersectXDir.insert(std::pair<int, double>(y, xd));
IntersectXDir.insert(std::pair<int, double>(y, -xd));
}
}
}
......
#ifdef HAVE_ML_SOLVER
#define DBG_STENCIL
#include "Algorithms/PartBunch.h"
#include "MGPoissonSolver.h"
#include "Physics/Physics.h"
#include "Attributes/Attributes.h"
......@@ -14,13 +15,20 @@
using Physics::c;
MGPoissonSolver::MGPoissonSolver(PartBunch &beam, Mesh_t *mesh, FieldLayout_t *fl, std::vector<BoundaryGeometry *> geometries, std::string itsolver, std::string interpl, double tol, int maxiters, std::string precmode):
itsBunch_m(&beam), layout_m(fl), mesh_m(mesh), LHS(0), geometries_m(geometries), tol_m(tol), maxiters_m(maxiters), Comm(Ippl::getComm()) {
MGPoissonSolver::MGPoissonSolver(PartBunch &beam,Mesh_t *mesh, FieldLayout_t *fl, std::vector<BoundaryGeometry *> geometries, std::string itsolver, std::string interpl, double tol, int maxiters, std::string precmode):
itsBunch_m(&beam),
mesh_m(mesh),
layout_m(fl),
LHS(0),
geometries_m(geometries),
tol_m(tol),
maxiters_m(maxiters),
Comm(Ippl::getComm()) {
domain_m = layout_m->getDomain();
e_dim_tag decomp[3];
// e_dim_tag decomp[3]; //set but not used FIXME
for(int i = 0; i < 3; i++) {
decomp[i] = layout_m->getRequestedDistribution(i);
// decomp[i] = layout_m->getRequestedDistribution(i); //set but not used FIXME
hr_m[i] = mesh_m->get_meshSpacing(i);
orig_nr_m[i] = domain_m[i].length();
}
......@@ -501,6 +509,7 @@ Inform &MGPoissonSolver::print(Inform &os) const {
os << "* *************** M G P o i s s o n S o l v e r ************************************ " << endl;
os << "* h " << hr_m << '\n';
os << "* ********************************************************************************** " << endl;
return os;
}
#endif /* HAVE_ML_SOLVER */
......@@ -9,9 +9,7 @@
#define MG_POISSON_SOLVER_H_
//////////////////////////////////////////////////////////////
class MGPoissonSolver;
class BoundaryGeometry;
#include "Algorithms/PartBunch.h"
#include "Structure/BoundaryGeometry.h"
#include "PoissonSolver.h"
#include "IrregularDomain.h"
#include "EllipticDomain.h"
......@@ -81,10 +79,13 @@ enum {
* \warning This solver is in an EXPERIMENTAL STAGE. For reliable simulations use the FFTPoissonSolver
*
*/
class PartBunch;
class BoundaryGeometry;
class MGPoissonSolver : public PoissonSolver {
public:
MGPoissonSolver(PartBunch &beam, Mesh_t *mesh, FieldLayout_t *fl, std::vector<BoundaryGeometry *> geometries, std::string itsolver, std::string interpl, double tol, int maxiters, std::string precmode);
MGPoissonSolver(PartBunch &beam,Mesh_t *mesh, FieldLayout_t *fl, std::vector<BoundaryGeometry *> geometries, std::string itsolver, std::string interpl, double tol, int maxiters, std::string precmode);
MGPoissonSolver(PartBunch &bunch);
~MGPoissonSolver();
......@@ -186,6 +187,9 @@ private:
/// parameter list for the iterative solver (Belos)
Teuchos::ParameterList belosList;
/// PartBunch object
PartBunch *itsBunch_m;
// mesh and layout objects for rho_m
Mesh_t *mesh_m;
FieldLayout_t *layout_m;
......@@ -200,9 +204,6 @@ private:
/// global number of mesh points in each direction
Vektor<int, 3> orig_nr_m;
/// PartBunch object
PartBunch *itsBunch_m;
// timers
IpplTimings::TimerRef FunctionTimer1_m;
IpplTimings::TimerRef FunctionTimer2_m;
......
......@@ -3,6 +3,8 @@
#ifdef HAVE_ML_SOLVER
#include <vector>
#include <string>
using namespace std;
#include "IrregularDomain.h"
class RectangularDomain : public IrregularDomain {
......
......@@ -77,21 +77,21 @@ void TaperDomain::Compute(Vector_t hr) {
for(x = 0; x < nr[0]; x++) {
pos = (x - (nr[0] - 1) / 2) * hr[0];
yd = std::abs(sqrt(rb2 - pos * pos));
IntersectYDir.insert(pair<int, double>(x, yd));
IntersectYDir.insert(pair<int, double>(x, -yd));
IntersectYDir.insert(std::pair<int, double>(x, yd));
IntersectYDir.insert(std::pair<int, double>(x, -yd));
yd = std::abs(sqrt(rs2 - pos * pos));
Intersectydir.insert(pair<int, double>(x, yd));
Intersectydir.insert(pair<int, double>(x, -yd));
Intersectydir.insert(std::pair<int, double>(x, yd));
Intersectydir.insert(std::pair<int, double>(x, -yd));
}
for(y = 0; y < nr[1]; y++) {
pos = (y - (nr[1] - 1) / 2) * hr[1];
xd = std::abs(sqrt(rb2 - pos * pos));
IntersectXDir.insert(pair<int, double>(y, xd));
IntersectXDir.insert(pair<int, double>(y, -xd));
IntersectXDir.insert(std::pair<int, double>(y, xd));
IntersectXDir.insert(std::pair<int, double>(y, -xd));
xd = std::abs(sqrt(rs2 - pos * pos));
Intersectxdir.insert(pair<int, double>(y, xd));
Intersectxdir.insert(pair<int, double>(y, -xd));
Intersectxdir.insert(std::pair<int, double>(y, xd));
Intersectxdir.insert(std::pair<int, double>(y, -xd));
}
}
}
......
......@@ -39,7 +39,7 @@ public:
/// returns index of neighbours at 3D index
void getNeighbours(int idx, double &W, double &E, double &S, double &N, double &F, double &B);
/// returns type of boundary condition
string getType() {return "Taper";}
std::string getType() {return "Taper";}
/// queries if a given (x,y,z) coordinate lies inside the domain
inline bool isInside(int x, int y, int z) {
......
......@@ -160,6 +160,14 @@ public:
return (double)Attributes::getReal(itsAttr[A]);
}
inline double getB() {
return (double)Attributes::getReal(itsAttr[B]);
}
inline double getC() {
return (double)Attributes::getReal(itsAttr[C]);
}
inline double getS() {
return (double)Attributes::getReal(itsAttr[S]);
}
......@@ -342,7 +350,8 @@ public:
}
return false;
}
private:
std::string h5FileName_m; // H5hut filename
......@@ -858,14 +867,6 @@ private:
return (double)(Attributes::getReal (itsAttr[XYZSCALE]));
}
inline double getB() {
return (double)Attributes::getReal(itsAttr[B]);
}
inline double getC() {
return (double)Attributes::getReal(itsAttr[C]);
}
enum {
FGEOM, // file holding the geometry
LENGHT, // length of elliptic tube or boxcorner
......
......@@ -235,7 +235,7 @@ void FieldSolver::initSolver(PartBunch &b) {
std::string tmp = "";
//split and add all to list
std::vector<BoundaryGeometry *> geometries;
for(int i = 0; i <= geoms.length(); i++) {
for(unsigned int i = 0; i <= geoms.length(); i++) {
if(geoms[i] == ',' || i == geoms.length()) {
BoundaryGeometry *geom = BoundaryGeometry::find(tmp);
if(geom != 0) {
......
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