Commit 918997da authored by incardon's avatar incardon
Browse files

Patching Parmetis on cygwin

parent 7d21307a
......@@ -111,25 +111,25 @@ constexpr int y = 1;
constexpr int z = 2;
// The type of the grids
typedef grid_dist_id<3,float,aggregate<float[3]>> grid_type;
typedef grid_dist_id<3,double,aggregate<double[3]>> grid_type;
// The type of the particles
typedef vector_dist<3,float,aggregate<float[3],float[3],float[3],float[3],float[3]>> particles_type;
typedef vector_dist<3,double,aggregate<double[3],double[3],double[3],double[3],double[3]>> particles_type;
// radius of the torus
float ringr1 = 1.0;
double ringr1 = 1.0;
// radius of the core of the torus
float sigma = 1.0/3.523;
double sigma = 1.0/3.523;
// Reynold number
float tgtre = 7500.0;
double tgtre = 7500.0;
// Noise factor for the ring vorticity on z
float ringnz = 0.01;
double ringnz = 0.01;
// Kinematic viscosity
float nu = 1.0/tgtre;
double nu = 1.0/tgtre;
// Time step
float dt = 0.025;
double dt = 0.025;
// All the properties by index
constexpr unsigned int vorticity = 0;
......@@ -215,14 +215,14 @@ template<typename grid> void calc_and_print_max_div_and_int(grid & g_vort)
* domain is the simulation domain
*
*/
void init_ring(grid_type & gr, const Box<3,float> & domain)
void init_ring(grid_type & gr, const Box<3,double> & domain)
{
// To add some noise to the vortex ring we create two random
// vector
constexpr int nk = 32;
float ak[nk];
float bk[nk];
double ak[nk];
double bk[nk];
for (size_t i = 0 ; i < nk ; i++)
{
......@@ -231,9 +231,9 @@ void init_ring(grid_type & gr, const Box<3,float> & domain)
}
// We calculate the circuitation gamma
float gamma = nu * tgtre;
float rinv2 = 1.0f/(sigma*sigma);
float max_vorticity = gamma*rinv2/M_PI;
double gamma = nu * tgtre;
double rinv2 = 1.0f/(sigma*sigma);
double max_vorticity = gamma*rinv2/M_PI;
// We go through the grid to initialize the vortex
auto it = gr.getDomainIterator();
......@@ -243,21 +243,21 @@ void init_ring(grid_type & gr, const Box<3,float> & domain)
auto key_d = it.get();
auto key = it.getGKey(key_d);
float tx = (key.get(x)-2)*gr.spacing(x) + domain.getLow(x);
float ty = (key.get(y)-2)*gr.spacing(y) + domain.getLow(y);
float tz = (key.get(z)-2)*gr.spacing(z) + domain.getLow(z);
float theta1 = atan2((ty-2.5f),(tz-2.5f));
double tx = (key.get(x)-2)*gr.spacing(x) + domain.getLow(x);
double ty = (key.get(y)-2)*gr.spacing(y) + domain.getLow(y);
double tz = (key.get(z)-2)*gr.spacing(z) + domain.getLow(z);
double theta1 = atan2((ty-2.5f),(tz-2.5f));
float noise = 0.0f;
double noise = 0.0f;
// for (int kk=1 ; kk < nk; kk++)
// noise = noise + sin(kk*(theta1+2.0f*M_PI*ak[kk])) + cos(kk*(theta1+2.0f*M_PI*bk[kk]));
float rad1r = sqrt((ty-2.5f)*(ty-2.5f) + (tz-2.5f)*(tz-2.5f)) - ringr1*(1.0f + ringnz * noise);
float rad1t = tx - 1.0f;
float rad1sq = rad1r*rad1r + rad1t*rad1t;
float radstr = -exp(-rad1sq*rinv2)*rinv2*gamma/M_PI;
double rad1r = sqrt((ty-2.5f)*(ty-2.5f) + (tz-2.5f)*(tz-2.5f)) - ringr1*(1.0f + ringnz * noise);
double rad1t = tx - 1.0f;
double rad1sq = rad1r*rad1r + rad1t*rad1t;
double radstr = -exp(-rad1sq*rinv2)*rinv2*gamma/M_PI;
gr.template get<vorticity>(key_d)[x] = 0.0f;
gr.template get<vorticity>(key_d)[y] = -radstr * cos(theta1);
gr.template get<vorticity>(key_d)[z] = radstr * sin(theta1);
......@@ -273,7 +273,7 @@ void init_ring(grid_type & gr, const Box<3,float> & domain)
// Specification of the poisson equation for the helmotz-hodge projection
// 3D (dims = 3). The field is a scalar value (nvar = 1), bournary are periodic
// type of the the space is float. Final grid that will store \phi, the result (grid_dist_id<.....>)
// type of the the space is double. Final grid that will store \phi, the result (grid_dist_id<.....>)
// The other indicate which kind of Matrix to use to construct the linear system and
// which kind of vector to construct for the right hand side. Here we use a PETSC Sparse Matrix
// and PETSC vector. NORMAL_GRID indicate that is a standard grid (non-staggered)
......@@ -282,8 +282,8 @@ struct poisson_nn_helm
static const unsigned int dims = 3;
static const unsigned int nvar = 1;
static const bool boundary[];
typedef float stype;
typedef grid_dist_id<3,float,aggregate<float>> b_grid;
typedef double stype;
typedef grid_dist_id<3,double,aggregate<double>> b_grid;
typedef SparseMatrix<double,int,PETSC_BASE> SparseMatrix_type;
typedef Vector<double,PETSC_BASE> Vector_type;
static const int grid_type = NORMAL_GRID;
......@@ -407,7 +407,7 @@ const bool poisson_nn_helm::boundary[] = {PERIODIC,PERIODIC,PERIODIC};
* domain simulation domain
*
*/
void helmotz_hodge_projection(grid_type & gr, const Box<3,float> & domain, petsc_solver<double> & solver, petsc_solver<double>::return_type & x_ , bool init)
void helmotz_hodge_projection(grid_type & gr, const Box<3,double> & domain, petsc_solver<double> & solver, petsc_solver<double>::return_type & x_ , bool init)
{
///////////////////////////////////////////////////////////////
......@@ -436,7 +436,7 @@ void helmotz_hodge_projection(grid_type & gr, const Box<3,float> & domain, petsc
Ghost<3,long int> g(2);
// Here we create a distributed grid to store the result of the helmotz projection
grid_dist_id<3,float,aggregate<float>> psi(gr.getDecomposition(),gr.getGridInfo().getSize(),g);
grid_dist_id<3,double,aggregate<double>> psi(gr.getDecomposition(),gr.getGridInfo().getSize(),g);
// Calculate the divergence of the vortex field
auto it = gr.getDomainIterator();
......@@ -558,7 +558,7 @@ void helmotz_hodge_projection(grid_type & gr, const Box<3,float> & domain, petsc
//! \cond [remesh_part] \endcond
void remesh(particles_type & vd, grid_type & gr,Box<3,float> & domain)
void remesh(particles_type & vd, grid_type & gr,Box<3,double> & domain)
{
// Remove all particles because we reinitialize in a grid like position
vd.clear();
......@@ -649,7 +649,7 @@ void remesh(particles_type & vd, grid_type & gr,Box<3,float> & domain)
*
*/
void comp_vel(Box<3,float> & domain, grid_type & g_vort,grid_type & g_vel, petsc_solver<double>::return_type (& phi_s)[3],petsc_solver<double> & solver)
void comp_vel(Box<3,double> & domain, grid_type & g_vort,grid_type & g_vel, petsc_solver<double>::return_type (& phi_s)[3],petsc_solver<double> & solver)
{
//! \cond [poisson_obj_eq] \endcond
......@@ -671,8 +671,8 @@ void comp_vel(Box<3,float> & domain, grid_type & g_vort,grid_type & g_vel, petsc
Ghost<3,long int> g(2);
// Here we create a distributed grid to store the result
grid_dist_id<3,float,aggregate<float>> gr_ps(g_vort.getDecomposition(),g_vort.getGridInfo().getSize(),g);
grid_dist_id<3,float,aggregate<float[3]>> phi_v(g_vort.getDecomposition(),g_vort.getGridInfo().getSize(),g);
grid_dist_id<3,double,aggregate<double>> gr_ps(g_vort.getDecomposition(),g_vort.getGridInfo().getSize(),g);
grid_dist_id<3,double,aggregate<double[3]>> phi_v(g_vort.getDecomposition(),g_vort.getGridInfo().getSize(),g);
// We calculate and print the maximum divergence of the vorticity
// and the integral of it
......@@ -756,9 +756,9 @@ void comp_vel(Box<3,float> & domain, grid_type & g_vort,grid_type & g_vel, petsc
phi_v.ghost_get<phi>();
float inv_dx = 0.5f / g_vort.spacing(0);
float inv_dy = 0.5f / g_vort.spacing(1);
float inv_dz = 0.5f / g_vort.spacing(2);
double inv_dx = 0.5f / g_vort.spacing(0);
double inv_dy = 0.5f / g_vort.spacing(1);
double inv_dz = 0.5f / g_vort.spacing(2);
auto it3 = phi_v.getDomainIterator();
......@@ -767,12 +767,12 @@ void comp_vel(Box<3,float> & domain, grid_type & g_vort,grid_type & g_vel, petsc
{
auto key = it3.get();
float phi_xy = (phi_v.get<phi>(key.move(y,1))[x] - phi_v.get<phi>(key.move(y,-1))[x])*inv_dy;
float phi_xz = (phi_v.get<phi>(key.move(z,1))[x] - phi_v.get<phi>(key.move(z,-1))[x])*inv_dz;
float phi_yx = (phi_v.get<phi>(key.move(x,1))[y] - phi_v.get<phi>(key.move(x,-1))[y])*inv_dx;
float phi_yz = (phi_v.get<phi>(key.move(z,1))[y] - phi_v.get<phi>(key.move(z,-1))[y])*inv_dz;
float phi_zx = (phi_v.get<phi>(key.move(x,1))[z] - phi_v.get<phi>(key.move(x,-1))[z])*inv_dx;
float phi_zy = (phi_v.get<phi>(key.move(y,1))[z] - phi_v.get<phi>(key.move(y,-1))[z])*inv_dy;
double phi_xy = (phi_v.get<phi>(key.move(y,1))[x] - phi_v.get<phi>(key.move(y,-1))[x])*inv_dy;
double phi_xz = (phi_v.get<phi>(key.move(z,1))[x] - phi_v.get<phi>(key.move(z,-1))[x])*inv_dz;
double phi_yx = (phi_v.get<phi>(key.move(x,1))[y] - phi_v.get<phi>(key.move(x,-1))[y])*inv_dx;
double phi_yz = (phi_v.get<phi>(key.move(z,1))[y] - phi_v.get<phi>(key.move(z,-1))[y])*inv_dz;
double phi_zx = (phi_v.get<phi>(key.move(x,1))[z] - phi_v.get<phi>(key.move(x,-1))[z])*inv_dx;
double phi_zy = (phi_v.get<phi>(key.move(y,1))[z] - phi_v.get<phi>(key.move(y,-1))[z])*inv_dy;
g_vel.template get<velocity>(key)[x] = phi_zy - phi_yz;
g_vel.template get<velocity>(key)[y] = phi_xz - phi_zx;
......@@ -843,13 +843,13 @@ template<typename grid> void calc_rhs(grid & g_vort, grid & g_vel, grid & g_dwp)
// calculate several pre-factors for the stencil finite
// difference
float fac1 = 2.0f*nu/(g_vort.spacing(0));
float fac2 = 2.0f*nu/(g_vort.spacing(1));
float fac3 = 2.0f*nu/(g_vort.spacing(2));
double fac1 = 2.0f*nu/(g_vort.spacing(0));
double fac2 = 2.0f*nu/(g_vort.spacing(1));
double fac3 = 2.0f*nu/(g_vort.spacing(2));
float fac4 = 0.5f/(g_vort.spacing(0));
float fac5 = 0.5f/(g_vort.spacing(1));
float fac6 = 0.5f/(g_vort.spacing(2));
double fac4 = 0.5f/(g_vort.spacing(0));
double fac5 = 0.5f/(g_vort.spacing(1));
double fac6 = 0.5f/(g_vort.spacing(2));
auto it = g_dwp.getDomainIterator();
......@@ -1041,8 +1041,8 @@ template<typename grid, typename vector> void do_step(vector & particles,
grid & g_vort,
grid & g_vel,
grid & g_dvort,
Box<3,float> & domain,
interpolate<particles_type,grid_type,mp4_kernel<float>> & inte,
Box<3,double> & domain,
interpolate<particles_type,grid_type,mp4_kernel<double>> & inte,
petsc_solver<double>::return_type (& phi_s)[3],
petsc_solver<double> & solver)
{
......@@ -1096,7 +1096,7 @@ template<typename vector, typename grid> void check_point_and_save(vector & part
// In order to reduce the size of the saved data we apply a threshold.
// We only save particles with vorticity higher than 0.1
vector_dist<3,float,aggregate<float>> part_save(particles.getDecomposition(),0);
vector_dist<3,double,aggregate<double>> part_save(particles.getDecomposition(),0);
auto it_s = particles.getDomainIterator();
......@@ -1104,7 +1104,7 @@ template<typename vector, typename grid> void check_point_and_save(vector & part
{
auto p = it_s.get();
float vort_magn = sqrt(particles.template getProp<vorticity>(p)[0] * particles.template getProp<vorticity>(p)[0] +
double vort_magn = sqrt(particles.template getProp<vorticity>(p)[0] * particles.template getProp<vorticity>(p)[0] +
particles.template getProp<vorticity>(p)[1] * particles.template getProp<vorticity>(p)[1] +
particles.template getProp<vorticity>(p)[2] * particles.template getProp<vorticity>(p)[2]);
......@@ -1155,7 +1155,7 @@ int main(int argc, char* argv[])
openfpm_init(&argc,&argv);
{
// Domain, a rectangle
Box<3,float> domain({0.0,0.0,0.0},{22.0,5.57,5.57});
Box<3,double> domain({0.0,0.0,0.0},{22.0,5.57,5.57});
// Ghost (Not important in this case but required)
Ghost<3,long int> g(2);
......@@ -1218,7 +1218,7 @@ int main(int argc, char* argv[])
// create some data-structure to optimize the conversion particle
// position to sub-domain. If there are no re-balancing it is safe
// to reuse-it
interpolate<particles_type,grid_type,mp4_kernel<float>> inte(particles,g_vort);
interpolate<particles_type,grid_type,mp4_kernel<double>> inte(particles,g_vort);
// With more than 24 core we rely on the HDF5 checkpoint restart file
if (v_cl.getProcessingUnits() < 24)
......
......@@ -15,6 +15,7 @@ platform=unknown
platform=osx
elif [[ "$OSTYPE" == "cygwin" ]]; then
echo -e "We are on\033[1;34m CYGWIN \033[0m"
platform=cygwin
elif [[ "$OSTYPE" == "msys" ]]; then
echo -e "We are on\033[1;34m Microsoft Window \033[0m"
echo "This platform is not supported"
......
......@@ -8,14 +8,14 @@ if [ -d "$1/HDF5" ]; then
fi
if [ ! -d "$1/ZLIB" ]; then
rm zlib1211.zip
rm zlib1211.tar.gz
rm -rf zlib-1.2.11
wget https://zlib.net/zlib1211.zip
wget https://zlib.net/zlib-1.2.11.tar.gz
if [ $? -ne 0 ]; then
echo -e "\033[91;5;1m FAILED! Installation requires an Internet connection \033[0m"
exit 1
fi
unzip zlib1211.zip
tar -xf zlib1211.tar.gz
cd zlib-1.2.11
CC=mpicc ./configure --prefix=$1/ZLIB
......
......@@ -263,38 +263,19 @@ if [ ! -d "$1/SUPERLU_DIST" ]; then
mkdir build
cd build
cmake .. -DCMAKE_C_FLAGS="-fPIC -std=c99 " -DTPL_BLAS_LIBRARIES="$1/OPENBLAS/lib/libopenblas.a" -DCMAKE_INSTALL_PREFIX="$1/SUPERLU_DIST" -DTPL_PARMETIS_INCLUDE_DIRS="$1/PARMETIS/include/;$1/METIS/include/" -DTPL_PARMETIS_LIBRARIES="$1/PARMETIS/lib/libparmetis.a;$1/METIS/lib/libmetis.so"
if [ x"$platform" == x"cygwin" ]; then
cmake .. -DCMAKE_C_FLAGS="-fPIC -std=c99 " -DTPL_BLAS_LIBRARIES="$1/OPENBLAS/lib/libopenblas.a" -DCMAKE_INSTALL_PREFIX="$1/SUPERLU_DIST" -DTPL_PARMETIS_INCLUDE_DIRS="$1/PARMETIS/include/;$1/METIS/include/" -DTPL_PARMETIS_LIBRARIES="$1/PARMETIS/lib/libparmetis.a;$1/METIS/lib/libmetis.dll.a;-lmpi;-lopen-rte;-lopen-pal"
else
cmake .. -DCMAKE_C_FLAGS="-fPIC -std=c99 " -DTPL_BLAS_LIBRARIES="$1/OPENBLAS/lib/libopenblas.a" -DCMAKE_INSTALL_PREFIX="$1/SUPERLU_DIST" -DTPL_PARMETIS_INCLUDE_DIRS="$1/PARMETIS/include/;$1/METIS/include/" -DTPL_PARMETIS_LIBRARIES="$1/PARMETIS/lib/libparmetis.a;$1/METIS/lib/libmetis.so"
fi
# Installation for linux
# $sed_command -i "/DSuperLUroot\s\+=\s\${HOME}\/Release_Codes\/SuperLU_DIST_4.3/c\DSuperLUroot = ../" make.inc
# $sed_command -i "/BLASLIB\s\+=/c\BLASLIB = $1/OPENBLAS/lib/libopenblas.a" make.inc
# $sed_command -i "/LOADOPTS\s\+=\s-openmp/c\LOADOPTS = -fopenmp" make.inc
# $sed_command -i "/PARMETIS_DIR\s\+=\/project\/projectdirs\/mp127\/parmetis-4.0.3-g/c\PARMETIS_DIR := $1/PARMETIS" make.inc
# $sed_command -i "/METISLIB\s:=\s-L\${PARMETIS_DIR}\/build\/Linux-x86_64\/libmetis\s-lmetis/c\METISLIB := -L$1/METIS/lib -lmetis" make.inc
# $sed_command -i "/PARMETISLIB\s:=\s-L\${PARMETIS_DIR}\/build\/Linux-x86_64\/libparmetis\s-lparmetis/c\PARMETISLIB := -L$1/PARMETIS/lib -lparmetis" make.inc
# $sed_command -i "/I_PARMETIS\s:=\s-I\${PARMETIS_DIR}\/include\s-I\${PARMETIS_DIR}\/metis\/include/c\I_PARMETIS := -I$1/PARMETIS/include -I$1/METIS/include" make.inc
# $sed_command -i "/CC\s\+=\scc/c\CC = mpicc" make.inc
# $sed_command -i "/FORTRAN\s\+=\sftn/c\FORTRAN = mpif90" make.inc
# if [ x"$CXX" == x"clang++" ]; then
# $sed_command -i "/CFLAGS\s\+=\s-fast\s-m64\s-std=c99\s-Wall\s-openmp\s\\\/c\CFLAGS =-fpic -O3 -m64 -std=c99 -Wall \$(I_PARMETIS) -DDEBUGlevel=0 -DPRNTlevel=0 -DPROFlevel=0" make.inc
# else
# $sed_command -i "/CFLAGS\s\+=\s-fast\s-m64\s-std=c99\s-Wall\s-openmp\s\\\/c\CFLAGS =-fpic -O3 -m64 -std=c99 -Wall -fopenmp \$(I_PARMETIS) -DDEBUGlevel=0 -DPRNTlevel=0 -DPROFlevel=0" make.inc
# fi
# $sed_command -i "/\s\$(I_PARMETIS)\s-DDEBUGlevel=0\s-DPRNTlevel=0\s-DPROFlevel=0\s\\\/c\ " make.inc
make
if [ $? -eq 0 ]; then
make install
echo 1 > $1/SUPERLU_DIST/version
# mkdir $1/SUPERLU_DIST
# mkdir $1/SUPERLU_DIST/include
# cp -r lib $1/SUPERLU_DIST
# cp SRC/*.h $1/SUPERLU_DIST/include
if [ x"$CXX" == x"icpc" ]; then
configure_options="$configure_options"
else
......
......@@ -35,6 +35,14 @@ fi
mkdir $1/PARMETIS
make install
#### Apply patch if we are on cygwin
if [ x"$platform" == x"cygwin" ]; then
cd $1/PARMETIS/include
wget http://openfpm.mpi-cbg.de/upload/parmetis_patch
patch < parmetis_patch
fi
# Mark the installation
echo 1 > $1/PARMETIS/version
......@@ -21,39 +21,18 @@ if [ $? != 0 ]; then
fi
cd SuiteSparse
# configuration
#if [ x"$platform" = x"osx" ]; then
# # installation for OSX
# sed -i "" -e "s| LAPACK = -llapack|LAPACK = |" SuiteSparse_config/SuiteSparse_config_Mac.mk
# sed -i "" -e "s| BLAS = -lopenblas|BLAS = -L"$1"/OPENBLAS/lib -lopenblas|" SuiteSparse_config/SuiteSparse_config_Mac.mk
### Overwrite SuiteSparse_config.mk
# rm SuiteSparse_config/SuiteSparse_config.mk
# mv SuiteSparse_config/SuiteSparse_config_Mac.mk SuiteSparse_config/SuiteSparse_config.mk
#else
# Installation for linux
if [ x"$CXX" == x"icpc" ]; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/$1/OPENBLAS/lib"
STS_LIB="-shared-intel -lrt -lifcore"
fi
# sed -i "/\sLIB\s=\s-lm\s-lrt/c\LIB = -shared-intel -lm -lrt -lifcore" SuiteSparse_config/SuiteSparse_config.mk
# sed -i "/\sLAPACK\s=\s-llapack/c\LAPACK = " SuiteSparse_config/SuiteSparse_config.mk
# sed -i "/\sBLAS\s=\s\-lopenblas/c\BLAS = -L$1/OPENBLAS/lib -lopenblas -lpthread" SuiteSparse_config/SuiteSparse_config.mk
# else
# sed -i "/\sLAPACK\s=\s-llapack/c\LAPACK = " SuiteSparse_config/SuiteSparse_config.mk
# sed -i "/\sBLAS\s=\s\-lopenblas/c\BLAS = -L$1/OPENBLAS/lib -lopenblas -lpthread" SuiteSparse_config/SuiteSparse_config.mk
# fi
#fi
if [ x"$CXX" == x"icpc" ]; then
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/$1/OPENBLAS/lib"
STS_LIB="-shared-intel -lrt -lifcore"
fi
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$1/OPENBLAS/lib"
if [ x"$platform" == x"cygwin" ]; then
export PATH="$PATH:$(pwd)/lib"
echo "$PATH"
fi
echo "Compiling SuiteSparse without CUDA (old variable $CUDA)"
make "CUDA=no" "BLAS=-L$1/OPENBLAS/lib -lopenblas" "LAPACK="
if [ $? != 0 ]; then
......
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