Commit 6e239e5b authored by tonynsyde's avatar tonynsyde

Fixes in CartDecomposition and latest changes

parents 235e442a 5bdc0356
......@@ -38,7 +38,7 @@ m4_ifdef([AX_BLAS],,[m4_include([m4/ax_blas.m4])])
m4_ifdef([AX_LAPACK],,[m4_include([m4/ax_lapack.m4])])
m4_ifdef([AX_SUITESPARSE],,[m4_include([m4/ax_suitesparse.m4])])
m4_ifdef([AX_EIGEN],,[m4_include([m4/ax_eigen.m4])])
m4_ifdef([AX_LIB_HDF5],,[m4_include([m4/ax_lib_hdf5.m4])]])
case $host_os in
*cygwin*)
......@@ -111,6 +111,17 @@ fi
IMMDX_LIB_METIS([],[echo "Cannot detect metis, use the --with-metis option if it is not installed in the default location"
exit 201])
#########
## Check for HDF5
AX_LIB_HDF5([parallel])
if test x"$with_hdf5" = x"no"; then
echo "Cannot detect hdf5, use the --with-hdf5 option if it is not installed in the default location"
exit 207
fi
########
## Enable scan coverty
......@@ -134,7 +145,7 @@ fi
## Check for parMetis
IMMDX_LIB_PARMETIS([],[echo "Cannot detect parmetis, use the --with-parmetis option if it is not installed in the default location"
exit 203])
exit 208])
####### include OpenFPM_devices include path
......
......@@ -204,7 +204,7 @@ int main(int argc, char* argv[])
}
//
// ### WIKI 6 ###
// ### WIKI 7 ###
//
// We create a CellList with cell spacing 12 sigma
//
......@@ -218,14 +218,13 @@ int main(int argc, char* argv[])
double linf = 0.0;
//
// ### WIKI 6 ###
// ### WIKI 8 ###
//
// For each particle get the neighborhood of each particle
//
// This cycle is literally the formula from PSE operator approximation
//
//
//
// \$ \frac{1}{\epsilon^{2}} h (u_{q} - u_{p}) \eta_{\epsilon}(x_q - x_p) \$
//
auto it_p = vd.getDomainIterator();
......@@ -288,7 +287,7 @@ int main(int argc, char* argv[])
}
//
// ### WIKI 7 ###
// ### WIKI 9 ###
//
// Calculate the maximum infinity norm across processors and
// print it
......@@ -301,7 +300,7 @@ int main(int argc, char* argv[])
std::cout << "Norm infinity: " << linf << "\n";
//
// ### WIKI 8 ###
// ### WIKI 10 ###
//
// Deinitialize the library
//
......
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
cell: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: cell
.PHONY: clean all
clean:
rm -f *.o *~ core cell
include ../../example.mk
CC=mpic++
LDIR =
OBJ = main.o
%.o: %.cpp
$(CC) -O3 -c --std=c++11 -o $@ $< $(INCLUDE_PATH)
verlet: $(OBJ)
$(CC) -o $@ $^ $(CFLAGS) $(LIBS_PATH) $(LIBS)
all: vect
.PHONY: clean all
clean:
rm -f *.o *~ core verlet
#! /bin/bash
source script/help
source script/discover_os
source script/show_solutions
source script/pre_req
source script/remove_old
##
install_req=1
i_dir=" "
sq=0
while getopts :di:shc: FLAG; do
case $FLAG in
d)
echo "Disable depencencies installation"
install_req=0
;;
i)
echo "Setting dependencies installation dir: $OPTARG"
i_dir=$OPTARG
;;
s)
echo "Skipping user cin"
sq=1
;;
c)
echo "Fowarding options $OPTARG to configure script"
configure_options=$OPTARG
;;
h) #show help
#! /bin/bash
source script/help
source script/discover_os
source script/show_solutions
source script/pre_req
source script/remove_old
##
install_req=1
i_dir=" "
sq=0
while getopts :di:shc: FLAG; do
case $FLAG in
d)
echo "Disable depencencies installation"
install_req=0
;;
i)
echo "Setting dependencies installation dir: $OPTARG"
i_dir=$OPTARG
;;
s)
echo "Skipping user cin"
sq=1
;;
c)
echo "Fowarding options $OPTARG to configure script"
configure_options=$OPTARG
;;
h) #show help
HELP
;;
\?) #unrecognized option - are fowarded to configure
......@@ -143,6 +143,8 @@ BOOST_installed=0
LAPACK_installed=0
SUITESPARSE_installed=0
EIGEN_installed=0
HDF5_installed=0
H5PART_installed=0
blas_options=""
conf_err=1
......@@ -219,15 +221,24 @@ else
./script/install_EIGEN.sh $i_dir $compiler_opt
configure_options=" $configure_options --with-eigen=$i_dir/EIGEN "
EIGEN_installed=1
elif [ $conf_err -ne 207 ]; then
elif [ $conf_err -eq 208 ]; then
echo "ParMetis not found try to install"
if [ $PARMETIS_installed -eq 1 ]; then
echo "Error the installation of ParMETIS failed"
exit 1
fi
./script/install_ParMetis.sh $i_dir $compiler_gcc $compiler_gpp
./script/install_Parmetis.sh $i_dir $compiler_gcc $compiler_gpp
PARMETIS_installed=1
configure_options=" $configure_options --with-parmetis=$i_dir/PARMETIS "
elif [ $conf_err -eq 207 ]; then
echo "HDF5 not found try to install"
if [ $HDF5_installed -eq 1 ]; then
echo "Error the installation of HDF5 failed"
exit 1
fi
./script/install_HDF5.sh $i_dir $compiler_opt
configure_options=" $configure_options --with-hdf5=$i_dir/HDF5/bin/h5pcc "
HDF5_installed=1
elif [ $conf_err -ne 0 ]; then
echo "I do not know how to recover from this error"
exit 1
......@@ -326,6 +337,20 @@ if [ $SUITESPARSE_installed -eq 1 ]; then
echo -e "\033[1m export DYLD_LIBRARY_PATH=\"\$DYLD_LIBRARY_PATH:$i_dir/SUITESPARSE/lib\" \033[0m"
fi
fi
if [ $EIGEN_installed -eq 1 ]; then
echo ""
echo -e "\033[1;34;5m --------------------------------------- \033[0m"
echo -e "\033[1;34;5m --------------- EIGEN ----------------- \033[0m"
echo -e " EIGEN has been installed into: \033[1m $i_dir/EIGEN \033[0m"
echo ""
fi
if [ $HDF5_installed -eq 1 ]; then
echo ""
echo -e "\033[1;34;5m --------------------------------------- \033[0m"
echo -e "\033[1;34;5m ---------------- HDF5 ----------------- \033[0m"
echo -e " HDF5 has been installed into: \033[1m $i_dir/HDF5 \033[0m"
echo ""
fi
echo ""
echo ""
if [ $conf_err -ne 0 ]; then
......
This diff is collapsed.
openfpm_data @ 2fe8dee2
Subproject commit a0c140b7772c3b39a817f03d3da76b7a60a9c074
Subproject commit 2fe8dee2be9e818c1ff8d876bf99a6ce8f591d17
openfpm_io @ 59f5019f
Subproject commit d5d691407e392ca64094d1b2a6008b5ca33eefe9
Subproject commit 59f5019f8f3acc6401af7422f19d61dd225e1a21
......@@ -8,8 +8,6 @@ function detect_fortran()
return
fi
echo -e "$1 \033[92;1m SUCCESS \033[0m"
dgc_ret=1
}
......
#! /bin/bash
# check if the directory $1/HDF5 exist
if [ -d "$1/HDF5" ]; then
echo "HDF5 already installed"
exit 0
fi
wget http://ppmcore.mpi-cbg.de/upload/hdf5-1.8.16.tar.bz2
tar -xf hdf5-1.8.16.tar.bz2
cd hdf5-1.8.16
CC=mpicc ./configure --enable-parallel --prefix=$1/HDF5
make -j 4
mkdir $1/HDF5
make install
......@@ -7,7 +7,7 @@ if [ -d "$1/MPI" ]; then
exit 0
fi
wget http://www.open-mpi.de/software/ompi/v1.8/downloads/openmpi-1.8.7.tar.bz2
wget http://ppmcore.mpi-cbg.de/upload/openmpi-1.8.7.tar.bz2
tar -xvf openmpi-1.8.7.tar.bz2
cd openmpi-1.8.7
......
......@@ -10,8 +10,9 @@ fi
wget http://ppmcore.mpi-cbg.de/upload/parmetis-4.0.3.tar.gz
tar -xf parmetis-4.0.3.tar.gz
cd parmetis-4.0.3
make config prefix=$1/PARMETIS
make -j 4
if [ $? -eq 0 ]; then
if [ $? -ne 0 ]; then
echo "PARMETIS error installing"
exit 0
fi
......
/*
* CartDecomposition_ext.hpp
*
* Created on: Mar 6, 2016
* Author: i-bird
*/
#ifndef SRC_DECOMPOSITION_CARTDECOMPOSITION_EXT_HPP_
#define SRC_DECOMPOSITION_CARTDECOMPOSITION_EXT_HPP_
template<unsigned int dim, typename T, typename Memory = HeapMemory, typename Distribution = ParMetisDistribution<dim, T>>
class CartDecomposition;
/**
* \brief This class decompose a space into sub-sub-domains and distribute them across processors
*
* \tparam dim is the dimensionality of the physical domain we are going to decompose.
* \tparam T type of the space we decompose, Real, Integer, Complex ...
* \tparam Memory Memory factory used to allocate memory
* \tparam Distribution type of distribution, can be ParMetisDistribution or MetisDistribution
*
* Most of the functionality is the same as CartDecomposition so refer to that class for more information
*
* The additional functionality is the possibility to produce an extended decomposition, in figure is
* show what we mean with extended
*
* \see CartDecomposition
*
*
*
* ### Create a Cartesian decomposition object on a Box space, distribute, calculate internal and external ghost boxes
* \snippet CartDecomposition_unit_test.hpp Create CartDecomposition
*
*/
template<unsigned int dim, typename T, typename Memory = HeapMemory, typename Distribution = ParMetisDistribution<dim, T>>
class CartDecomposition_ext: public CartDecomposition<dim,T,Memory,Distribution>
{
private:
/*! \brief It copy the sub-domains into another CartesianDecomposition object extending them
*
* \see duplicate (in case of extended domain)
*
* \param cart Cartesian decomposition object
* \param box Extended domain
*
*/
void extend_subdomains(const CartDecomposition<dim,T,Memory,Distribution> & dec, const ::Box<dim,T> & ext_dom)
{
// Box
typedef ::Box<dim,T> b;
this->bbox.zero();
for (size_t i = 0 ; i < dim ; i++)
{
this->ss_box.setLow(i,0.0);
this->ss_box.setHigh(i,ext_dom.getHigh(i) - ext_dom.getLow(i));
}
// Extend sub-domains
for (size_t i = 0 ; i < dec.sub_domains.size() ; i++)
{
::Box<dim,T> box;
// Calculate the extended box
for (size_t j = 0 ; j < dim ; j++)
{
if (dec.sub_domains.template get<b::p1>(i)[j] == dec.domain.getLow(j))
box.setLow(j,ext_dom.getLow(j));
else
box.setLow(j,dec.sub_domains.template get<b::p1>(i)[j]);
if (dec.sub_domains.template get<b::p2>(i)[j] == dec.domain.getHigh(j))
box.setHigh(j,ext_dom.getHigh(j));
else
box.setHigh(j,dec.sub_domains.template get<b::p2>(i)[j]);
}
// add the subdomain
this->sub_domains.add(box);
// Calculate the bound box
this->bbox.enclose(box);
// Create the smallest box contained in all sub-domain
this->ss_box.contained(box);
}
}
/*! \brief Extend the fines for the new Cartesian decomposition
*
* \param new_fines extended fine_s
* \param old_fines old fine_s
*
*/
void extend_fines(const CartDecomposition<dim,T> & dec)
{
// Extension, first we calculate the extensions of the new domain compared
// to the old one in cell units (each cell unit is a sub-sub-domain)
::Box<dim,size_t> ext;
// Extension of the new fines structure
::Box<dim,size_t> n_fines_ext;
// Extension of the old fines structure
::Box<dim,size_t> o_fines_ext;
size_t sz_new[dim];
size_t sz_old[dim];
for (size_t i = 0; i < dim ; i++)
{
size_t p1 = (dec.domain.getLow(i) - dec.domain.getLow(i)) / dec.cd.getCellBox().getHigh(i) + 1;
size_t p2 = (dec.domain.getLow(i) - dec.domain.getLow(i)) / dec.cd.getCellBox().getHigh(i) + 1;
ext.setLow(i,p1);
ext.setHigh(i,p2);
sz_new[i] = p1+p2+dec.cd.getGrid().size(i);
sz_old[i] = dec.cd.getGrid().size(i);
}
grid_sm<dim,void> info_new(sz_new);
grid_sm<dim,void> info_old(sz_old);
// resize the new fines
this->fine_s.resize(info_new.size());
// we create an iterator that iterate across the full new fines
grid_key_dx_iterator<dim> fines_t(info_new);
while (fines_t.isNext())
{
auto key = fines_t.get();
// new_fines is bigger than old_fines structure
// out of bound key must be adjusted
// The adjustment produce a natural extension
// a representation can be seen in the figure of
// CartDecomposition duplicate function with extended domains
grid_key_dx<dim> key_old;
for (size_t i = 0 ; i < dim ; i++)
{
key_old.set_d(i,(long int)key.get(i) - ext.getLow(i));
if (key_old.get(i) < 0)
key_old.set_d(i,0);
else if(key_old.get(i) >= (long int)info_old.size(i) )
key_old.set_d(i,info_old.size(i)-1);
}
this->fine_s.get(info_new.LinId(key)) = dec.fine_s.get(info_old.LinId(key_old));
++fines_t;
}
this->gr.setDimensions(sz_new);
// the new extended CellDecomposer must be consistent with the old cellDecomposer.
this->cd.setDimensions(dec.cd,ext);
}
public:
/*! \brief Cartesian decomposition constructor
*
* \param v_cl VCluster
*
*/
CartDecomposition_ext(Vcluster & v_cl)
:CartDecomposition<dim,T,Memory,Distribution>(v_cl)
{
}
typedef CartDecomposition<dim,T,Memory,Distribution> base_type;
/*! \brief It create another object that contain the same decomposition information but with different ghost boxes and an extended domain
*
* The domain extension is produced extending the boxes at the border like in figure
*
* \verbatim
*
+--------------^--------^----------^----------+
| | | | |
| A | E | F | N |
| +-----------------------------------+---->
| | | | | | |
| A | A | | F | | |
| | | | | | |
| | | E +----------+ N | N |
<--------------+ | | | |
| | | | | | |
| | | | G | | |
| | | | +---------->
| B | B | +----------+ | |
| | +--------+ | M | M |
| | | | H | | |
| | | +-----+----+---------->
<--------------+ D | | | |
| | | | I | L | L |
| C | C | | | | |
| | | | | | |
| +-----------------------------------+ |
| | | | |
| C | D | I | L |
+--------------v--------v-----v---------------+
*
* \endverbatim
*
* \param g ghost
* \param domain extended domain (MUST be extended)
*
* \return a duplicated decomposition with different ghost boxes and an extended domain
*
*/
void setParameters(const CartDecomposition<dim,T,Memory,Distribution> & dec, const Ghost<dim,T> & g, const ::Box<dim,T> & ext_domain)
{
this->box_nn_processor = dec.box_nn_processor;
// Calculate new sub-domains for extended domain
extend_subdomains(dec,ext_domain);
// Calculate fine_s structure for the extended domain
// update the cell decomposer and gr
extend_fines(dec);
// Get the old sub-sub-domain grid extension
this->domain = ext_domain;
// spacing does not change
std::copy(dec.spacing,dec.spacing+3,this->spacing);
//! Runtime virtual cluster
this->v_cl = dec.v_cl;
this->ghost = g;
this->dist = dec.dist;
for (size_t i = 0 ; i < dim ; i++)
this->bc[i] = dec.bc[i];
(static_cast<nn_prcs<dim,T> &>(*this)).create(this->box_nn_processor, this->sub_domains);
(static_cast<nn_prcs<dim,T> &>(*this)).applyBC(ext_domain,g,this->bc);
this->Initialize_geo_cell_lists();
this->calculateGhostBoxes();
}
};
#endif /* SRC_DECOMPOSITION_CARTDECOMPOSITION_EXT_HPP_ */
......@@ -51,6 +51,83 @@ template<unsigned int dim, typename Distribution> void setSphereComputationCosts
}
}
struct animal
{
typedef boost::fusion::vector<float[2], size_t, size_t, size_t> type;
//! Attributes name
struct attributes
{
static const std::string name[];
};
//! type of the positional field
typedef float s_type;
//! The data
type data;
//! position property id in boost::fusion::vector
static const unsigned int pos = 0;
//! genre of animal property id in boost::fusion::vector
static const unsigned int genre = 1;
//! state property id in boost::fusion::vector
static const unsigned int status = 2;
//! alive time property id in boost::fusion::vector
static const unsigned int time_a = 3;
//! total number of properties boost::fusion::vector
static const unsigned int max_prop = 4;
animal()
{
}
inline animal(const animal & p)
{
boost::fusion::at_c<0>(data)[0] = boost::fusion::at_c<0>(p.data)[0];
boost::fusion::at_c<0>(data)[1] = boost::fusion::at_c<0>(p.data)[1];
//boost::fusion::at_c<0>(data)[2] = boost::fusion::at_c<0>(p.data)[2];
boost::fusion::at_c<1>(data) = boost::fusion::at_c<1>(p.data);
boost::fusion::at_c<2>(data) = boost::fusion::at_c<2>(p.data);
boost::fusion::at_c<3>(data) = boost::fusion::at_c<3>(p.data);
}
template<unsigned int id> inline auto get() -> decltype(boost::fusion::at_c < id > (data))
{
return boost::fusion::at_c<id>(data);
}
template<unsigned int id> inline auto get() const -> const decltype(boost::fusion::at_c < id > (data))
{
return boost::fusion::at_c<id>(data);
}
template<unsigned int dim, typename Mem> inline animal(const encapc<dim, animal, Mem> & p)
{
this->operator=(p);
}
template<unsigned int dim, typename Mem> inline animal & operator=(const encapc<dim, animal, Mem> & p)
{
boost::fusion::at_c<0>(data)[0] = p.template get<0>()[0];
boost::fusion::at_c<0>(data)[1] = p.template get<0>()[1];
//boost::fusion::at_c<0>(data)[2] = p.template get<0>()[2];
boost::fusion::at_c<1>(data) = p.template get<1>();
boost::fusion::at_c<2>(data) = p.template get<2>();
boost::fusion::at_c<3>(data) = p.template get<3>();
return *this;
}
static bool noPointers()
{
return true;
}
};
const std::string animal::attributes::name[] = { "pos"