diff --git a/HySoP/CMake/InstallPackage.cmake b/HySoP/CMake/InstallPackage.cmake index 11a46f8b35389705c9eb2338c69517d14e22f4c3..a594a0b3d22f7b0c1440f065dbfcdc3f6c574012 100644 --- a/HySoP/CMake/InstallPackage.cmake +++ b/HySoP/CMake/InstallPackage.cmake @@ -5,10 +5,12 @@ # #=========================================================== -macro(install_package _PACK _LIB_NAME _HEADERSLIST) - - set(_HEADERS ${${_HEADERSLIST}}) +macro(install_package) + if(ARGV2) + set(_HEADERS ${ARGV2}) + endif() + # Offer the user the choice of overriding the installation directories set(INSTALL_LIB_DIR lib CACHE PATH "Installation directory for libraries") set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables") @@ -24,34 +26,37 @@ macro(install_package _PACK _LIB_NAME _HEADERSLIST) endforeach() # The library - install(TARGETS ${_LIB_NAME} - EXPORT ${_PACK}LibraryDepends + install(TARGETS ${ARGV1} + EXPORT ${ARGV0}LibraryDepends ARCHIVE DESTINATION "${INSTALL_LIB_DIR}" # static libs LIBRARY DESTINATION "${INSTALL_LIB_DIR}" COMPONENT shlib # shared libs PUBLIC_HEADER DESTINATION "${INSTALL_INCLUDE_DIR}" COMPONENT dev ) # The headers and modules - install(FILES ${_HEADERS} DESTINATION "${INSTALL_INCLUDE_DIR}") - + if(_HEADERS) + install(FILES ${_HEADERS} DESTINATION "${INSTALL_INCLUDE_DIR}") + endif() install(DIRECTORY ${CMAKE_BINARY_DIR}/Modules DESTINATION "${INSTALL_INCLUDE_DIR}") - export(TARGETS ${_LIB_NAME} FILE "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}LibraryDepends.cmake") + export(TARGETS ${ARGV1} FILE "${PROJECT_BINARY_DIR}/InstallFiles/${ARGV0}LibraryDepends.cmake") # Install the export set for use with the install-tree - install(EXPORT ${_PACK}LibraryDepends DESTINATION + install(EXPORT ${ARGV0}LibraryDepends DESTINATION "${INSTALL_DATA_DIR}/CMake" COMPONENT dev) - set(${_PACK}_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}") - set(${_PACK}_LIB_DIR "${INSTALL_LIB_DIR}") - set(${_PACK}_CMAKE_DIR "${INSTALL_DATA_DIR}/CMake") - configure_file(${CMAKE_SOURCE_DIR}/${_PACK}Config.cmake.in - "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}Config.cmake") - configure_file(${CMAKE_SOURCE_DIR}/${_PACK}ConfigVersion.cmake.in - "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}ConfigVersion.cmake" @ONLY) + set(${ARGV0}_INCLUDE_DIRS "${INSTALL_INCLUDE_DIR}") + set(${ARGV0}_LIB_DIR "${INSTALL_LIB_DIR}") + set(${ARGV0}_CMAKE_DIR "${INSTALL_DATA_DIR}/CMake") + + display(${ARGV0}_CMAKE_DIR) + configure_file(${CMAKE_SOURCE_DIR}/${ARGV0}Config.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/${ARGV0}Config.cmake") + configure_file(${CMAKE_SOURCE_DIR}/${ARGV0}ConfigVersion.cmake.in + "${PROJECT_BINARY_DIR}/InstallFiles/${ARGV0}ConfigVersion.cmake" @ONLY) install(FILES - "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}Config.cmake" - "${PROJECT_BINARY_DIR}/InstallFiles/${_PACK}ConfigVersion.cmake" - DESTINATION "${${_PACK}_CMAKE_DIR}" COMPONENT dev) + "${PROJECT_BINARY_DIR}/InstallFiles/${ARGV0}Config.cmake" + "${PROJECT_BINARY_DIR}/InstallFiles/${ARGV0}ConfigVersion.cmake" + DESTINATION "${${ARGV0}_CMAKE_DIR}" COMPONENT dev) endmacro() diff --git a/HySoP/CMakeLists.txt b/HySoP/CMakeLists.txt index e5371c46016a6e5eb54599c078803009325381db..3d36c521f9087b3072f4360156c088670cfb44c0 100644 --- a/HySoP/CMakeLists.txt +++ b/HySoP/CMakeLists.txt @@ -87,6 +87,7 @@ if(USE_MPI) #set(${PARMES_LIBRARY_NAME}_LINK_FLAGS ${${PARMES_LIBRARY_NAME}_LINK_FLAGS} ${MPI_Fortran_LINK_FLAGS}) set(LIBS ${LIBS} ${MPI_Fortran_LIBRARIES} ) endif(USE_MPI) + add_subdirectory(src) # ============= Generates setup.py ============= diff --git a/HySoP/hysop/fftw2py/fftw2py.f90 b/HySoP/hysop/fftw2py/fftw2py.f90 new file mode 100755 index 0000000000000000000000000000000000000000..5d1c1b7b54cb1460e2a9bec0de6e4aa86740099a --- /dev/null +++ b/HySoP/hysop/fftw2py/fftw2py.f90 @@ -0,0 +1,39 @@ +!> Interface to mpi-fftw utilities +module fftw2py + +use parmepyparameters +!use poisson, only : testpoisson +use poisson + +implicit none + +contains + + subroutine initFFTW(resolution,lengths) + + !> GLOBAL resolution + integer, dimension(3), intent(in) :: resolution + !> Length of the domain + real(kind=8),dimension(3),intent(in) :: lengths + print *, "ahahaha" + + call initFFTW2D(resolution,lengths) + + print *, "ahahaha" + + end subroutine initFFTW + +!!$ subroutine initFFTW(resolution,lengths) +!!$ +!!$ !> GLOBAL resolution +!!$ integer, dimension(:), intent(in) :: resolution +!!$ !> Length of the domain +!!$ real(kind=8),dimension(:),intent(in) :: lengths +!!$ +!!$ print *, "this is a call to fftw-mpi ..." +!!$ +!!$ call initfftw2d(resolution,lengths) +!!$ +!!$ end subroutine initFFTW + +end module fftw2py diff --git a/HySoP/setup.py.in b/HySoP/setup.py.in index dcd31e5a4bdf7a1f1eb847baa68dc40015199460..225d2665e333ad378c7f52d48ee4ea06210d682d 100644 --- a/HySoP/setup.py.in +++ b/HySoP/setup.py.in @@ -55,7 +55,6 @@ testf2pyModule = Extension(name='parmepy.testf2py', ext_modules.append(testf2pyModule) withfftw = "@WITH_FFTW@" - if(withfftw is "ON"): fortran_src = glob.glob('@CMAKE_SOURCE_DIR@/parmepy/fftw2py/*.f90') fftwdir = '@FFTWLIB@' diff --git a/HySoP/src/CMakeLists.txt b/HySoP/src/CMakeLists.txt index 1d9ccf943a8f50226f41e349e1b2dfd037eccd01..53beaa4519f6e29639ff3faaac81961d0c23e3a2 100644 --- a/HySoP/src/CMakeLists.txt +++ b/HySoP/src/CMakeLists.txt @@ -153,11 +153,12 @@ include_directories(${CMAKE_Fortran_MODULE_DIRECTORY}) #if(BUILD_SHARED_LIBS) # shared library # add_library(${PARMES_LIBRARY_NAME} SHARED ${${PARMES_LIBRARY_NAME}_SRC}) #else() # static library - add_library(${PARMES_LIBRARY_NAME} STATIC ${${PARMES_LIBRARY_NAME}_SRC}) +add_library(${PARMES_LIBRARY_NAME} STATIC ${${PARMES_LIBRARY_NAME}_SRC}) #endif() # Libs to link with PARMES__LIBRARY_NAME target_link_libraries(${PARMES_LIBRARY_NAME} ${LIBS}) +### set(PARMES_LINKED_LIBRARIES ${LIBS} ${PARMES_LIBRARY_NAME} PARENT_SCOPE) # ============= Creates the executable ============= add_executable(${EXE_NAME} ${${EXE_NAME}_SRC}) add_dependencies(${EXE_NAME} ${PARMES_LIBRARY_NAME}) @@ -185,8 +186,11 @@ endif(WITH_TESTS) # The library, the headers and mod files, the cmake generated files # will be install in CMAKE_INSTALL_PREFIX/lib include and share include(InstallPackage) -install_package(${PACKAGE_NAME} ${PARMES_LIBRARY_NAME} ${${PARMES_LIBRARY_NAME}_HDRS}) - +if(${PARMES_LIBRARY_NAME}_HDRS}) + install_package(${PACKAGE_NAME} ${PARMES_LIBRARY_NAME} ${${PARMES_LIBRARY_NAME}_HDRS}) +else() + install_package(${PACKAGE_NAME} ${PARMES_LIBRARY_NAME}) +endif() #install(TARGETS ${EXE_NAME} #RUNTIME DESTINATION bin # executables # ) diff --git a/HySoP/src/Domain.hpp b/HySoP/src/Domain.hpp deleted file mode 100644 index 4385ddb7d2d99fb4ed374593568244c787f468b2..0000000000000000000000000000000000000000 --- a/HySoP/src/Domain.hpp +++ /dev/null @@ -1,104 +0,0 @@ -/** \file Domain.hpp Physical domain definition - */ -#ifndef DOMAIN_HPP -#define DOMAIN_HPP -#include <boost/array.hpp> -#include "ParmesDef.hpp" -#include "Tools.hpp" - -namespace Parmes { - /** Namespace for all objects related to the continuous model description - */ - namespace Model { - - - /** This class defines the physical domain (sets dimensions, boundary conditions and so on) - It is templated by the dimension of the problem (default : 1D). - - */ - template <size_t dim = 1> class Domain - { - - private : - - // Local typedef - typedef Parmes::Def::real_t real_t; - typedef boost::array<real_t, dim> localRealVector; - - // Size of the domain - localRealVector _length; - // Position : min values (in each direction) - localRealVector _minPos; - // Position : max values (in each direction) - localRealVector _maxPos; - // Boundary conditions types - - private: - - // Default constructor : size one domain, starting from (0,0,0) point. - Domain() - { - for(size_t i=0; i<dim; ++i) - { - _length[i] = 1.0; - _minPos[i] = 0.0; - _maxPos[i] = 1.0; - } - } - - public: - - // Copy constructor - Domain(const Domain<dim>& copiedD) : _length(copiedD._length), _minPos(copiedD._minPos), _maxPos(copiedD._maxPos) - {} - - /* Gets the length of the domain in one direction */ - inline real_t length(size_t index) const - { - assert(index<dim); - return _length[index]; - } - - /* Returns the min value for coordinate index */ - inline real_t minPos(size_t index) const - { - assert(index<dim); - return _minPos[index]; - } - - /* Returns the max value for coordinate index */ - inline real_t maxPos(size_t index) const - { - assert(index<dim); - return _maxPos[index]; - } - - /** Basic constructor, from the size of the domain and the starting point coordinates - \param - */ - Domain(const localRealVector& dims, const localRealVector& startPos) : _length(dims), _minPos(startPos) - { - for(size_t i=0; i<dim;++i) - _maxPos[i] = _minPos[i] + dims[i]; - } - - /** Display main information about the domain - */ - friend std::ostream& operator<<(std::ostream& output, const Domain<dim>& myDom) - { - output << " ================================================== " << std::endl; - output << dim <<"D physical domain : " << std::endl; - print(myDom._length.begin(), myDom._length.end(), "dimensions ", " ", output); - print(myDom._minPos.begin(), myDom._minPos.end(), "Starting point ", " ", output); - print(myDom._maxPos.begin(), myDom._maxPos.end(), "Top point ", " ", output); - - return output << " ================================================== "; - } - - - }; - - } -} - -#endif diff --git a/HySoP/src/Grid.hpp b/HySoP/src/Grid.hpp deleted file mode 100644 index 7d45cf61a93a24d09ee40234ec5f104ee7fc1ccf..0000000000000000000000000000000000000000 --- a/HySoP/src/Grid.hpp +++ /dev/null @@ -1,123 +0,0 @@ -/** \file Grid.hpp cartesian grid definition - */ -#ifndef GRID_HPP -#define GRID_HPP -#include <boost/array.hpp> -#include "ParmesDef.hpp" -#include "Tools.hpp" -#include "Domain.hpp" - - -namespace Parmes { - /** Namespace for all Parmes objects related to discretization */ - namespace Discr { - - - /** This class defines a cartesian grid, with constant step size in each direction. - It is templated by the dimension of the grid (default : 1D grid). - - */ - template <size_t dim = 1> class Grid - { - - private : - - typedef Parmes::Def::real_t real_t; - typedef boost::array<real_t, dim> localRealVector; - typedef boost::array<size_t,dim> localIntVector; - - // dimension of each side of the grid - localRealVector _length; - // number of points in each direction - localIntVector _nbPoints; - // Step size in each direction - localRealVector _stepSize; - // Reference point, i.e. "lowest" point of the grid. - localRealVector _startPoint; - - private: - - /** Default constructor - */ - Grid() - { - for(size_t i=0; i<dim; ++i) - { - _length[i] = 1.0; - _nbPoints[i] = 2; - _stepSize[i] = 1.0; - _startPoint[i] = 0.0; - } - } - - public: - - // Copy constructor - Grid(const Grid<dim>& copiedG) : _length(copiedG._length), _nbPoints(copiedG._nbPoints), _stepSize(copiedG._stepSize), _startPoint(copiedG._startPoint) - {} - - /** Basic constructor, from the size of the domain and the number of points - \param - */ - Grid(const localRealVector& dims, const localIntVector& nbSteps) : _length(dims), _nbPoints(nbSteps) - { - for(size_t i=0; i<dim; ++i) - { - _stepSize[i] = _length[i]/_nbPoints[i]; - _startPoint[i] = 0.0; - } - } - - /** Constructor from a domain and a number of steps in each dir - */ - Grid(const Parmes::Model::Domain<dim>& domain, const localIntVector& nbSteps) : _nbPoints(nbSteps) - { - for(size_t i=0; i<dim; ++i) - { - _length[i] = domain.length(i); - _startPoint[i] = domain.minPos(i); - _stepSize[i] = _length[i]/(_nbPoints[i]-1); - } - } - - /* Gets the length of the grid in one direction */ - inline size_t length(size_t index) const - { - assert(index<dim); - return _length[index]; - } - - /* Returns the number of points in direction index*/ - inline size_t nbPoints(size_t index) const - { - assert(index<dim); - return _nbPoints[index]; - } - - /* Returns the step size in direction index*/ - inline real_t stepSize(size_t index) const - { - assert(index<dim); - return _stepSize[index]; - } - - /** Display main information about the current grid - */ - friend std::ostream& operator<<(std::ostream& output, const Grid<dim>& myGrid) - { - output << " ================================================== " << std::endl; - output << dim <<"D cartesian grid : " << std::endl; - print(myGrid._length.begin(), myGrid._length.end(), "dimensions ", " ", output); - print(myGrid._nbPoints.begin(), myGrid._nbPoints.end(), "number of points (per dim.) ", " ", output); - print(myGrid._stepSize.begin(), myGrid._stepSize.end(), "step size (per dim.) ", " ", output); - - return output << " ================================================== "; - } - - - }; - - } -} - -#endif diff --git a/HySoP/src/ParmesDef.hpp b/HySoP/src/ParmesDef.hpp deleted file mode 100644 index a54f4aaa5ad81dd938d8a812eb290cda7e0de41e..0000000000000000000000000000000000000000 --- a/HySoP/src/ParmesDef.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/** \file ParmesDef.hpp typedef and other usefull definitions for parmes - */ -#ifndef PARMES_DEF_HPP -#define PARMES_DEF_HPP -#include <boost/array.hpp> - -/** Global namespace for Parmes tools and functions*/ -namespace Parmes { - /** Namespace for basic definitions in Parmes : typedef, enum ... */ - namespace Def { - -#include "parmes_defines.hpp" - - /** enumerated type used to describe in a more readible way the access to some components. - For example, myGrid being a cartesian grid, you can call myGrid.length[X] rather than myGrid.length[0]. - */ - enum Coords {X=0, Y,Z}; - - /** Set the default precision for real number. It depends on the option "DOUBLEPREC" of ParmesConfig.hpp. */ -#ifdef DOUBLEPREC - typedef double real_t; -#else - typedef float real_t; -#endif - /** Fixed size vectors (3D) */ - typedef boost::array<Parmes::Def::real_t,3> vector3D; - /** Fixed size vectors (2D) */ - typedef boost::array<Parmes::Def::real_t,2> vector2D; - - } -} - -#endif // PARMESDEF_HPP diff --git a/HySoP/src/Tools.hpp b/HySoP/src/Tools.hpp deleted file mode 100644 index 535b6178d42faf7399d238ec7383868552ae80be..0000000000000000000000000000000000000000 --- a/HySoP/src/Tools.hpp +++ /dev/null @@ -1,113 +0,0 @@ -/** \file Tools.hpp - Some useful functions ... . -*/ - -#ifndef TOOLS_H -#define TOOLS_H - -#include<string> -#include <sstream> -#include <vector> -#include<algorithm> -#include<iostream> -#include<iterator> - -/** A function to convert any type to string*/ -template <class T> std::string toString(const T& obj) -{ - static std::ostringstream o; - o.str(""); - o << obj ; - return o.str(); -} - -// Next two functions: from Thinking in C++ vol2, p 536. -/** to purge a STL container of pointers, assuming it owns all its pointers. - \param a STL sequence container -*/ -template<class Seq> void purge(Seq& c) -{ - typename Seq::iterator i; - for(i=c.begin(); i!= c.end(); ++i) - { - delete *i; - *i = NULL; - } -} - -/** to purge a STL container of pointers, assuming it owns all its pointers. - \param iterator equal to a container.begin() - \param iterator equal to a container.end() -*/ -template<class InpIt> void purge(InpIt begin, InpIt end) -{ - while (begin!=end) - { - delete *begin; - *begin = NULL; - ++begin; - } -} - -/** to purge a STL container of pointers; only pointers owned by the container, ie for which second arg - corresponding value is true, are deleted. - \param a STL sequence container - \param a std::vector<bool> -*/ -template<class Seq> void purge(Seq& c, const std::vector<bool>& isAllocatedIn ) -{ - typename Seq::iterator i; - std::vector<bool>::const_iterator it = isAllocatedIn.begin(); - for(i=c.begin(); i!= c.end(); ++i) - { - if( *it ++ ) delete *i; - *i = NULL; - } -} - -/** to purge a STL container of pointers, assuming it owns all its pointers. - \param iterator equal to a container.begin() - \param iterator equal to a container.end() -*/ -template<class InpIt> void purge(InpIt begin, InpIt end, const std::vector<bool>& isAllocatedIn ) -{ - std::vector<bool>::const_iterator it = isAllocatedIn.begin(); - while (begin!=end) - { - if( *it ++ ) delete *begin; - *begin = NULL; - ++begin; - } -} - -/** To copy a value into an object ( created if required) - \param a smart pointer to T (SPT): the object to be filled - Must have op= and copy constructor from U. - \param type U param, the value to be assigned. -*/ -template <class T, class SPT, class U> void setObject(SPT& obj, const U& val) -{ - if(!obj) - obj.reset(new T(val)); - else - *obj = val; -} - -/** Print the contents of any sequence - From Thinking in C++, vol 2 p365. - \param first, any iterator, beginning of the sequence - \param last, any iterator, end of the sequence - \param char*, optional message on top of output, default "" - \param char*, separator between sequence elements, default new line - \param ostream, output destination, default cout -*/ -template<typename Iter> -void print(Iter first, Iter last, const char* nm ="", const char * sep = "\n", std::ostream& os = std::cout) -{ - if(nm!= 0 && *nm != '\0') - os << nm << ": " << sep; - typedef typename std::iterator_traits<Iter>::value_type T; - std::copy(first, last, std::ostream_iterator<T>(os, sep)); - os << std::endl; -} - -#endif -