diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..895a460 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,151 @@ +#=============================================================================== +# @file CMakeLists.txt +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Jul 28 12:20:03 2014 +# +# @brief This is the main CMake configuration file for LM +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +#=============================================================================== +# Project definition +#=============================================================================== +cmake_minimum_required(VERSION 2.8) +project(LibMultiScale) + +enable_language(CXX) + +#=============================================================================== +# Misc. config for cmake +#=============================================================================== +set(LIBMULTISCALE_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules") +set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.") + +include(LibMultiScaleMacros) + +include(CMakeFlagsHandling) +include(CMakeVersionGenerator) +include(CMakeDebugMessages) +include(CMakePackagesSystem) + +#=============================================================================== +# Version Number +#=============================================================================== +# LIBMULTISCALE version number. An even minor number corresponds to releases. +set(LIBMULTISCALE_MAJOR_VERSION 2) +set(LIBMULTISCALE_MINOR_VERSION 1) +set(LIBMULTISCALE_BUILD_VERSION 0) +define_project_version() + +#=============================================================================== +# Options +#=============================================================================== +option(LIBMULTISCALE_OPTIMIZE "Set this if you want libmultiscale to be fully optimized" OFF) +if(LIBMULTISCALE_OPTIMIZE) + add_definitions(-DLM_OPTIMIZED) +endif(LIBMULTISCALE_OPTIMIZE) + +add_flags(cxx -Wall) +add_flags(cxx -fPIC) +#add_flags(cxx -std=gnu++0x) +#add_flags(cxx -std=c++11) +add_flags(SHARED_LINKER -fPIC) +if (CMAKE_CXX_COMPILER_ID MATCHES "Intel") + add_flags(cxx -vec-report=0) +endif() + +#=============================================================================== +# LibMultiScale library +#=============================================================================== +#cmake_activate_debug_message(TestSystem) +cmake_deactivate_debug_message() + +add_all_packages(${PROJECT_SOURCE_DIR}/packages ${PROJECT_SOURCE_DIR}/src) +add_subdirectory(src) + +set(LIBMULTISCALE_DEPEND_FILES "") + +foreach(_file ${LIBMULTISCALE_SRCS} ${LIBMULTISCALE_HDRS} ${LIBMULTISCALE_INLINE_SRCS}) + list(APPEND LIBMULTISCALE_DEPEND_FILES ${PROJECT_SOURCE_DIR}/src/${_file}) +endforeach() + + +#=============================================================================== +# Release file target +#=============================================================================== +set(GET_RELEASE_INFO ${PROJECT_SOURCE_DIR}/get_release_info.sh) +set(RELEASE_FILE ${PROJECT_BINARY_DIR}/release.cc) + +find_program(uuencode_exec "uuencode") +mark_as_advanced(uuencode_exec) + +if(uuencode_exec) + add_custom_command( + OUTPUT ${RELEASE_FILE} + COMMAND bash ${GET_RELEASE_INFO} ${uuencode_exec} ${PROJECT_BINARY_DIR} > ${RELEASE_FILE} + DEPENDS ${LIBMULTISCALE_DEPEND_FILES} ${GET_RELEASE_INFO} + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} + ) +else() + message("install uuencode on the building machine to have access to release information.") + file(WRITE "${RELEASE_FILE}" + " +#include +std::string lm_release_info = \" install uuencode on the building machine to have access to release information.\"; +") +endif() + +add_custom_target(RELEASE_INFO DEPENDS ${RELEASE_FILE}) + +#=============================================================================== +# LibMultiScale AMEL + LMPOST +#=============================================================================== + +add_subdirectory(clients) + +#=============================================================================== +# Documentation +#=============================================================================== +option(LIBMULTISCALE_DOCUMENTATION "Build documentation." OFF) +if(LIBMULTISCALE_DOCUMENTATION) + add_subdirectory(doc) +endif(LIBMULTISCALE_DOCUMENTATION) + +#=============================================================================== +# Tests +#=============================================================================== +option(LIBMULTISCALE_TESTS "Activate tests" OFF) +if(LIBMULTISCALE_TESTS) + enable_testing() + include(CTest) + add_subdirectory(test) + mark_as_advanced(BUILD_TESTING) +endif() + +#=============================================================================== +# CPack +#=============================================================================== +include(LibMultiScaleCPack) diff --git a/LGPL.txt b/LGPL.txt new file mode 100644 index 0000000..dd4f6ea --- /dev/null +++ b/LGPL.txt @@ -0,0 +1,15 @@ +Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + +LibMultiScale is free software: you can redistribute it and/or modify it under the +terms of the GNU Lesser General Public License as published by the Free +Software Foundation, either version 3 of the License, or (at your option) any +later version. + +LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +details. + +You should have received a copy of the GNU Lesser General Public License +along with LibMultiScale. If not, see . diff --git a/README.compilation b/README.compilation new file mode 100644 index 0000000..1a47e79 --- /dev/null +++ b/README.compilation @@ -0,0 +1,9 @@ +___________ +COMPILATION + +In order to compile LibMultiScale you have to use cmake + + > mkdir build + > cd build + > ccmake .. + > make diff --git a/README.licence b/README.licence new file mode 100644 index 0000000..c7c30bb --- /dev/null +++ b/README.licence @@ -0,0 +1,13 @@ +LibMultiScale was initiated in a collaboration between INRIA Futurs Bordeaux +within ScAlApplix team and CEA/DPTA Ile de France. +The project is now continued at the Ecole Polytechnique Fédérale of Lausanne +within the ENAC/IIC/LSMS laboratory. + +In consequence, the files of the source code are under two distinct Copyrights +and distributed under two distinct licenses: CECILL-C and LGPL. These licenses +are compatible with each other. + +The complete text of the licenses are joined in the files cecill-c.txt and LGPL.txt + + + diff --git a/cecill-c.txt b/cecill-c.txt new file mode 100644 index 0000000..5aab3f0 --- /dev/null +++ b/cecill-c.txt @@ -0,0 +1,37 @@ +Copyright INRIA and CEA + +The LibMultiScale is a C++ parallel framework for the multiscale +coupling methods dedicated to material simulations. This framework +provides an API which makes it possible to program coupled simulations +and integration of already existing codes. + +This Project was initiated in a collaboration between INRIA Futurs Bordeaux +within ScAlApplix team and CEA/DPTA Ile de France. +The project is now continued at the Ecole Polytechnique Fédérale de Lausanne +within the LSMS/ENAC laboratory. + +This software is governed by the CeCILL-C license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-C +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-C license and that you accept its terms. diff --git a/clients/AMEL.cc b/clients/AMEL.cc new file mode 100644 index 0000000..c436b9b --- /dev/null +++ b/clients/AMEL.cc @@ -0,0 +1,341 @@ +/* ./amel/AMEL.cpp +********************************** +author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net) + +The LibMultiScale is a C++ parallel framework for the multiscale +coupling methods dedicated to material simulations. This framework +provides an API which makes it possible to program coupled simulations +and integration of already existing codes. + +This Project is done in a collaboration between +EPFL within ENAC-LSMS (http://lsms.epfl.ch/) and +INRIA Bordeaux, ScAlApplix (http://www.labri.fr/projet/scalapplix/). + +This software is governed by the CeCILL-C license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-C +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-C license and that you accept its terms. +***********************************/ + +/* -------------------------------------------------------------------------- */ +#include "lm_common.hh" +#include "domain_multiscale.hh" +#include "algebraic_parser.hh" +#include "action_manager.hh" + +using namespace libmultiscale; + +/* -------------------------------------------------------------------------- */ +#include +#include +/* -------------------------------------------------------------------------- */ +#ifdef LIBMULTISCALE_USE_QVIEW +#include +#endif +/* -------------------------------------------------------------------------- */ +#ifdef USING_EPSN +#include +#include +#include +#endif +/* -------------------------------------------------------------------------- */ +#include +#include +#include +/* -------------------------------------------------------------------------- */ +#include + +Real lastdump = -1e30; +Real lastStep = 0; + +void printState(){ + if (lm_my_proc_id != 0) return; + + struct timespec gtime; + clock_gettime(CLOCK_PROCESS_CPUTIME_ID,>ime); + + if ( gtime.tv_sec - lastdump < 2) return; + + Real nstep_done = - lastStep+current_step; + + std::stringstream info_steps; + + info_steps << std::setw(3) << std::setfill(' ') + << 100*current_step/nb_step << "% - " +#ifdef USE_COMPACT_STATUS + << "step" +#else + << "passing step " +#endif + << std::setw(5) << std::setfill(' ') << current_step << "/" + << std::setw(5) << std::setfill(' ') << nb_step; + + if(current_step > 0){ + Real step_per_seconds = nstep_done/(gtime.tv_sec - lastdump); + Real remaining_time = 1. * (nb_step-current_step) / step_per_seconds; + UInt remaining_hours = int(remaining_time/60/60); + UInt remaining_minutes = int(remaining_time/60 - remaining_hours*60); + UInt remaining_seconds = int(remaining_time-remaining_minutes*60 - remaining_hours*60*60); + info_steps << " " + << std::setw(5) << std::setfill(' ') << step_per_seconds +#ifdef USE_COMPACT_STATUS + << "/sec. ETA: " +#else + << " steps/seconds " + << "remaining " +#endif + << std::setw(5) << std::setfill(' ') << remaining_hours +#ifdef USE_COMPACT_STATUS + << ":" +#else + << " hours " +#endif +#ifdef USE_COMPACT_STATUS + << std::setw(2) << std::setfill('0') << remaining_minutes + << ":" +#else + << std::setw(2) << std::setfill(' ') << remaining_minutes + << " minutes " +#endif +#ifdef USE_COMPACT_STATUS + << std::setw(2) << std::setfill('0') << remaining_seconds; +#else + << std::setw(2) << std::setfill(' ') << remaining_seconds + << " seconds"; +#endif + } + std::string clown = info_steps.str(); + //std::cerr << "\r" << clown; + std::cerr << info_steps.str() << std::endl; + + lastStep = current_step; + lastdump = gtime.tv_sec; +} +/* -------------------------------------------------------------------------- */ + + + +//void echange_args(const string &* argv,char **my_args); +extern std::string lm_release_info; +/* -------------------------------------------------------------------------- */ + +static void Usage(const std::string & name){ + std::cout << "Usage : " << name << " config_file nb_time_step\n" + << "\t config_file : global config file of the simulation\n" + << "\t nb_time_step : number of time step wanted to be done (>=0)\n"; + + std::cout << "*****************************************" << std::endl; + std::cout << "release info" << std::endl; + std::cout << "*****************************************" << std::endl; + std::cout << lm_release_info << std::endl; + lm_exit(LM_EXIT_FAILURE); +} +/* -------------------------------------------------------------------------- */ + + +int main(int argc, char ** argv) +{ + loadModules(argc,argv); // loading the modules macro + + if (argc != 3){ + if (lm_my_proc_id == 0) + Usage(argv[0]); + lm_exit(LM_EXIT_FAILURE); + } + + nb_step = atoi(argv[2]); + nb_step_next_event = nb_step; + + if (nb_step == UINT_MAX) + Usage(argv[0]); + + MPI_Barrier(MPI_COMM_WORLD); + + DOWAIT_AT_STARTUP; + + STARTTIMER("Init"); + + DomainMultiScale & dom = DomainMultiScale::getManager(); + + dom.build(argv[1]); + + ActionManager & actions = dom.getActionManager(); + + STOPTIMER("Init"); + + nb_step+= current_step; + +#ifdef USING_EPSN + std::ofstream epsn_log; + + struct timeval timer_epsn_start; + struct timeval timer_epsn_stop; + + struct timeval result; + + std::stringstream epsn_log_filename; + + epsn_log_filename << "epsn_log_" << std::setfill('0') << std::setw(5) << lm_my_proc_id << ".log"; + epsn_log.open(epsn_log_filename.str().c_str(), std::ios_base::out); + + if (epsn_itfc->isNodeInitialized()) { + UInt epsn_status = 0; + // EPSN Ready + DUMP("EPSN is going to be READY...", DBG_INFO_STARTUP); + epsn_status = epsn_itfc->ready(); + if (!epsn_status) { + FATAL("error on EPSN Node ready operation\n"); + } + DUMP("EPSN READY",DBG_INFO_STARTUP); + // the main loop + DUMP("EPSN Begin HTG",DBG_INFO_STARTUP); + epsn_itfc->beginHTM(); + epsn_itfc->beginLoop("main"); + DUMP("simulation ready to start for EPSN", DBG_INFO_STARTUP); + } +#endif + + MPI_Barrier(MPI_COMM_WORLD); + + bool shouldPrintState = true; + +#ifdef LIBMULTISCALE_USE_QVIEW + QView qv; + qv.setMode(NET_MODE); + qv.initLibQview(lm_my_proc_id); + qv.beginTask("main",nb_step); + shouldPrintState = false; +#endif //USING_QVIEW + + + char * varenv = getenv("PRINT_STATE"); + if (varenv) shouldPrintState = true; + + STARTTIMER("Main loop"); + + Real min_dt = dom.getTimeStep(); + current_time = current_step*min_dt; + + for (; current_step < nb_step ; ++current_step, current_time += min_dt){ + +#ifdef USING_EPSN + gettimeofday(&timer_epsn_start,NULL); + + if (epsn_itfc->isNodeInitialized()) + epsn_itfc->beginTask("body"); +#endif + +#ifdef LIBMULTISCALE_USE_QVIEW + qv.setCurrentStep(current_step); +#endif //USING_QVIEW + if (shouldPrintState) printState(); + try { + current_stage = PRE_DUMP; + actions.action(); + current_stage = PRE_STEP1; + actions.action(); + + STARTTIMER("performStep1"); + dom.performStep1(); + STOPTIMER("performStep1"); + + dom.coupling(COUPLING_STEP1); + + current_stage = PRE_STEP2; + actions.action(); + + STARTTIMER("performStep2"); + dom.performStep2(); + STOPTIMER("performStep2"); + dom.coupling(COUPLING_STEP2); + + current_stage = PRE_STEP3; + actions.action(); + + STARTTIMER("performStep3"); + dom.performStep3(); + STOPTIMER("performStep3"); + + STARTTIMER("Coupling"); + dom.coupling(COUPLING_STEP3); + STOPTIMER("Coupling"); + + current_stage = PRE_STEP4; + actions.action(); + + dom.coupling(COUPLING_STEP4); + } catch (std::runtime_error & err) { + std::stringstream error_stream; + error_stream << " at stage " << current_stage << ": Caught '" + << err.what() << "'"; + LM_FATAL(error_stream.str()); + } + +#ifdef USING_EPSN + if (epsn_itfc->isNodeInitialized()) + epsn_itfc->endTask("body"); + + gettimeofday(&timer_epsn_stop,NULL); + + result.tv_sec = timer_epsn_stop.tv_sec - timer_epsn_start.tv_sec; + if ( (result.tv_usec = timer_epsn_stop.tv_usec - timer_epsn_start.tv_usec) < 0 ) { + --result.tv_sec; + result.tv_usec += 1000000; + } + + Real time_epsn = result.tv_sec * 1000.0 + result.tv_usec / 1000.0; + epsn_log << lm_my_proc_id << " " << current_step << " " << time_epsn << std::endl; +#endif + + // MPI_Barrier(MPI_COMM_WORLD); + } + +#ifdef LIBMULTISCALE_USE_QVIEW + qv.endTask(); +#endif //USING_QVIEW + +#ifdef USING_EPSN + if (epsn_itfc->isNodeInitialized()) { + epsn_itfc->endLoop("main"); + epsn_itfc->endHTM(); + } +#endif + + + current_stage = PRE_DUMP; + actions.action(); + current_stage = PRE_STEP1; + actions.action(); + + STOPTIMER("Main loop"); + + dom.destroy(); + + closeModules(); // closing the modules macro + + std::cerr << std::endl; + lm_exit(LM_EXIT_SUCCESS); +} +/* -------------------------------------------------------------------------- */ + diff --git a/clients/AMELCG.cc b/clients/AMELCG.cc new file mode 100644 index 0000000..a7413b0 --- /dev/null +++ b/clients/AMELCG.cc @@ -0,0 +1,245 @@ +/* ./amel/AMELCG.cpp +********************************** +Copyright INRIA and CEA + +author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net) + +The LibMultiScale is a C++ parallel framework for the multiscale +coupling methods dedicated to material simulations. This framework +provides an API which makes it possible to program coupled simulations +and integration of already existing codes. + +This Project is done in a collaboration between INRIA Futurs Bordeaux +within ScAlApplix team and CEA/DPTA Ile de France. + +This software is governed by the CeCILL-C license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-C +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-C license and that you accept its terms. +***********************************/ + +#define TIMER +#define MAIN_SOURCE + +#include "lm_common.hh" +#include "domain_multiscale.hh" +#include "algebraic_parser.hh" +#include "action_manager.hh" + +using namespace libmultiscale; +/* -------------------------------------------------------------------------- */ +#include +#include +#include +/* -------------------------------------------------------------------------- */ + + +void Usage(const std::string & name){ + std::cout << "Usage : " << name << " config_file nb_quasi_step nb_convergence_step\n" + << "\t config_file : global config file of the simulation\n" + << "\t nb_time_step : number of quasi step wanted to be done (>=0)\n" + << "\t nb_convergence_step : max number of convergence step to be done\n"; + lm_exit(LM_EXIT_FAILURE); +} + +#define ALPHA_REDUCE 0.5 +#define BACKTRACK_SLOPE 0.5 + +// UInt LineSearchScan(DomainMultiScale & dom,StimulationMultiScale & stimulator,Real dmax,Real & eng, UInt & neval){ +// Real fdotdir = dom.getFdotDir(); +// Real dirmax = dom.getDirMax(); +// //Real dirmax_original = dirmax; +// Real alphamax = dmax/dirmax; + +// Real fnorm2 = dom.getFNorm2(); +// Real fnorm2_original = fnorm2; +// Real alpha = alphamax; +// Real alpha_previous = 0.0; +// Real delta; +// eng = dom.getEpot();; +// Real eoriginal = eng; +// //Real fmax_original = dom.getFMax(); +// //Real fmax = fmax_original; + +// // std::cerr << "eng " << eng << " alpha " << alpha << " fmax " << fmax << " fdotdir " << fdotdir << std::endl; + +// while (1) { +// delta = alpha - alpha_previous; +// // apply displacement constraUInt (pre force disp update) +// stimulator.stimulate(PRE_STEP1); +// // displace along direction +// dom.displaceTowardsDirection(delta); +// // apply displacement constraUInt (pre force compute) +// stimulator.stimulate(PRE_STEP2); +// // recompute forces +// dom.performStep2(); +// // apply post forces stimulations +// stimulator.stimulate(PRE_STEP3); +// // recompute fnorm +// fnorm2 = dom.getFNorm2(); +// // fmax = dom.getFMax(); +// // get potential energy +// eng = dom.getEpot(); +// neval++; + +// // DUMPBYPROC("eng " << eng << " fnorm2 " << fnorm2 << " epsilon " << fnorm2_original << " alpha " << alpha << " fmax " << fmax,DBG_ERROR,0); +// // if (lm_my_proc_id == 0) +// // std::cerr << "eng " << eng << " epsilon " << eoriginal << " alpha " << alpha << " delta " << delta << " dirmax " << dirmax << std::endl; +// if (eng <= eoriginal - BACKTRACK_SLOPE*alpha*fdotdir) return 0; +// if (fnorm2 <= fnorm2_original) return 0; +// //if (fmax <= fmax_original) return 0; + +// alpha_previous = alpha; +// alpha *= ALPHA_REDUCE; +// if (alpha == 0) { +// dom.displaceTowardsDirection(-alpha_previous); +// // recompute forces +// dom.performStep2(); +// // apply post forces stimulations +// stimulator.stimulate(PRE_STEP3); +// return 1; +// } +// } +// } + +int main(int argc, char ** argv) +{ + + if (argc != 4){ + Usage(argv[0]); + } + + loadModules(argc,argv); //loading the modules macro + + UInt nb_step = atoi(argv[2]); + UInt nb_convergence_step = atoi(argv[3]); + + MPI_Barrier(MPI_COMM_WORLD); + + // UInt frequency = 1; + MPI_Barrier(MPI_COMM_WORLD); + + STARTTIMER("Init"); + DomainMultiScale & dom = DomainMultiScale::getManager(); + dom.build(argv[1]); + ActionManager & actions = dom.getActionManager(); + STOPTIMER("Init"); + + nb_step+= current_step; + + // Real norm2 = 0; + + UInt fail = 0; + // Real dmax=0.1; + UInt nforce_compute = 0; + UInt max_eval = 1000000; + Real ftol = 1e-3; + Real gg; + Real fdotOldf; + + for (UInt i = 0 ; i < nb_step ; ++i) { + current_step = i*nb_convergence_step; + + dom.performStep2(); + //initialize the things + // apply displacement constraUInt (pre force disp update) + current_stage = PRE_STEP1; + actions.action(); + // apply displacement constraUInt (pre force compute) + current_stage = PRE_STEP2; + actions.action(); + // recompute forces + dom.performStep2(); + // apply post forces stimulations + current_stage = PRE_STEP3; + actions.action(); + // compute fnorm + + Real fnorm2 = dom.getFNorm2(); + gg = fnorm2; + Real eng = dom.getEpot(); + + // if (lm_my_proc_id == 0) + // std::cerr << "LM SIDE fnorm2_init " << fnorm2 << std::endl; + + // Real einitial = dom.getEpot(); + // if (lm_my_proc_id == 0) + // std::cerr << "LM SIDE einitial " << einitial << std::endl; + + ++current_step; + + for (; current_step < (i+1)*nb_convergence_step ; ++current_step) + { + // search minimum value along line which is stored in velocity field for convenience + // fail = LineSearchScan(dom,actions,dmax,eng,nforce_compute); + + if (fail) { + DUMPBYPROC("linescan FAIL",DBG_MESSAGE,0); + break; + } + if (nforce_compute >= max_eval) LM_FATAL("MAXEVAL " << nforce_compute); + + fnorm2 = dom.getFNorm2(); + Real fmax = dom.getFMax(); + fdotOldf = dom.getFdotOldF(); + + + if (lm_my_proc_id==0) + std::cerr << "converging -> norm force = " << fnorm2 << " fmax " << fmax + << " epot " << eng << " descending step " + << nforce_compute << " nb search = " << current_step << std::endl; + + + + // if (lm_my_proc_id == 0) + // std::cerr << "LM SIDE " << fnorm2 << " " << fdotOldf << std::endl; + + // force tolerance criterion + if (fmax < ftol) { + DUMPBYPROC("FTOL " << fmax,DBG_MESSAGE,0); + break; + } + + // update h from new f = -Grad(x) and old g + //beta = dotall[0]/gg would be Fletcher-Reeves CG + + Real beta = std::max(0.0,(fnorm2 - fdotOldf)/gg); + gg = fnorm2; + + // if (lm_my_proc_id == 0) + // std::cerr << "LM SIDE beta " << beta << std::endl; + + + dom.saveForceVector(); + dom.updateDirection(beta); + + + } + + } + closeModules(); // closing the modules macro + + lm_exit(LM_EXIT_SUCCESS); +} + diff --git a/clients/CMakeLists.txt b/clients/CMakeLists.txt new file mode 100644 index 0000000..98cd550 --- /dev/null +++ b/clients/CMakeLists.txt @@ -0,0 +1,35 @@ +include_directories(${LIBMULTISCALE_INCLUDE_DIRS} ${LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR}) + +foreach(_dep ${LIBMULTISCALE_DEFINITIONS}) + add_definitions(-D${_dep}) +endforeach() + +option(LIBMULTISCALE_COMPACT_STATUS + "Produce more compact and better readable status updates in libmultiscale" OFF) +mark_as_advanced(LIBMULTISCALE_COMPACT_STATUS) +if (LIBMULTISCALE_COMPACT_STATUS) + add_definitions(-DUSE_COMPACT_STATUS) +endif (LIBMULTISCALE_COMPACT_STATUS) + + +set_source_files_properties(${RELEASE_FILE} PROPERTIES GENERATED 1) + +add_executable(AMEL AMEL.cc ${RELEASE_FILE}) +add_executable(AMELCG AMELCG.cc ${RELEASE_FILE}) +add_executable(LMPOST LMPOST.cc ${RELEASE_FILE}) + +add_dependencies(AMEL RELEASE_INFO) +add_dependencies(AMELCG RELEASE_INFO) +add_dependencies(LMPOST RELEASE_INFO) + +target_link_libraries(AMEL multiscale) +target_link_libraries(AMELCG multiscale) +target_link_libraries(LMPOST multiscale) + +install(TARGETS AMEL AMELCG LMPOST + EXPORT LibMultiScaleLibraryDepends + RUNTIME DESTINATION bin COMPONENT client + LIBRARY DESTINATION lib COMPONENT lib + ARCHIVE DESTINATION lib COMPONENT lib + PUBLIC_HEADER DESTINATION include/libmultiscale/ COMPONENT dev + ) diff --git a/clients/LMPOST.cc b/clients/LMPOST.cc new file mode 100644 index 0000000..b07ac4c --- /dev/null +++ b/clients/LMPOST.cc @@ -0,0 +1,182 @@ +/* ./amel/LMPOST.cpp +********************************* +Copyright EPFL and INRIA + +author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net) + +The LibMultiScale is a C++ parallel framework for the multiscale +coupling methods dedicated to material simulations. This framework +provides an API which makes it possible to program coupled simulations +and integration of already existing codes. + +This Project is done in a collaboration between +EPFL within ENAC-LSMS (http://lsms.epfl.ch/) and +INRIA Bordeaux, ScAlApplix (http://www.labri.fr/projet/scalapplix/). + +This software is governed by the CeCILL-C license under French law and +abiding by the rules of distribution of free software. You can use, +modify and/ or redistribute the software under the terms of the CeCILL-C +license as circulated by CEA, CNRS and INRIA at the following URL +"http://www.cecill.info". + +As a counterpart to the access to the source code and rights to copy, +modify and redistribute granted by the license, users are provided only +with a limited warranty and the software's author, the holder of the +economic rights, and the successive licensors have only limited +liability. + +In this respect, the user's attention is drawn to the risks associated +with loading, using, modifying and/or developing or reproducing the +software by the user in light of its specific status of free software, +that may mean that it is complicated to manipulate, and that also +therefore means that it is reserved for developers and experienced +professionals having in-depth computer knowledge. Users are therefore +encouraged to load and test the software's suitability as regards their +requirements in conditions enabling the security of their systems and/or +data to be ensured and, more generally, to use and operate it in the +same conditions as regards security. + +The fact that you are presently reading this means that you have had +knowledge of the CeCILL-C license and that you accept its terms. +***********************************/ + +#define TIMER +#define MAIN_SOURCE + +#include "lm_common.hh" +#include "domain_multiscale.hh" +#include "algebraic_parser.hh" +#include "action_manager.hh" +#include "lm_parser.hh" + +using namespace libmultiscale; +/* -------------------------------------------------------------------------- */ +#include +#include +#include +#include +#include + +#ifdef USING_QVIEW +#include +#endif + +static UInt numLines = UINT_MAX; + +FILE * open_restart(const std::string & fname) +{ + FILE * res = fopen(fname.c_str(),"rb"); + if (res == NULL) LM_FATAL("cannot open multiscale restart file : " << fname); + + char buffer[512]; + char * buf = NULL; + while(!feof(res)){ + buf = fgets(buffer,512,res); + numLines++; + } + fclose(res); + + res = fopen(fname.c_str(),"rb"); + buf = fgets(buffer,512,res); + if (strcmp(buf,"LMRESTART\n")) + LM_FATAL("invalid restart file : " << fname << "first line read : " << buffer); + return res; +} + +UInt parseRestartLine(const std::string & line,DomainMultiScale & dom){ + Real value; + DomainID dom_index; + std::string f; + UInt cpt=0; + std::stringstream sline(line); + Parser::parse(value,sline); + dom_index = (int)value; + sline >> f; + while (sline.good()){ + if (f == "") break; + DUMP("reload file " << f << " dom index = " << dom_index + << " " << line,DBG_MESSAGE); + if (dom.getObject(dom_index)){ + dom.getObject(dom_index)->readXMLFile(f.c_str()); + dom.getObject(dom_index)->performStep2(); + } + ++cpt; + Parser::parse(value,sline); + dom_index = (int)value; + sline >> f; + } + return cpt; +} + +UInt readRestartLine(FILE * frestart,DomainMultiScale & dom){ + char buffer[512]; + char * test = fgets(buffer,512,frestart); + if (!test) return 0; + return parseRestartLine(buffer,dom); +} + +int main(int argc, char ** argv) +{ + loadModules(argc,argv); // loading the modules macro + // int a = 1; + // while (a) {}; + + char restart_file[255]; + strcpy(restart_file,argv[2]); + FILE * frestart = open_restart(restart_file); + + + DomainMultiScale & dom = DomainMultiScale::getManager(); + dom.build(argv[1]); + ActionManager & actions = dom.getActionManager(); + + current_stage = PRE_STEP1; + actions.action(); + + UInt more = readRestartLine(frestart,dom); + UInt current_line = 0; + UInt sav_current_step = current_step; + UInt increment_step = 0; + +#ifdef USING_QVIEW + QView qv; + qv.setMode(NET_MODE); + qv.initLibQview(); + qv.beginTask("main",numLines); +#endif //USING_QVIEW + + while (more) + { +#ifdef USING_QVIEW + qv.setCurrentStep(current_line); +#else + std::cerr << "passing step " << current_line << "/" << numLines << std::endl; +#endif + //make dump + current_stage = PRE_STEP1; + actions.action(); + //reload restart file + more = readRestartLine(frestart,dom); + if (sav_current_step == current_step) { + current_step = ++increment_step; + } + else { + sav_current_step = current_step; + } + + ++current_line; + } + +#ifdef USING_QVIEW + qv.endTask(); +#endif //USING_QVIEW + + closeModules(); // closing the modules macro + + return 0; +} + + + + + diff --git a/cmake/LibMultiScaleCPack.cmake b/cmake/LibMultiScaleCPack.cmake new file mode 100644 index 0000000..1fcb002 --- /dev/null +++ b/cmake/LibMultiScaleCPack.cmake @@ -0,0 +1,77 @@ +#=============================================================================== +# @file LibMultiScaleCPack.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Jul 28 12:20:03 2014 +# +# @brief Configure the packaging system +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(PACKAGE_FILE_NAME "libmultiscale" CACHE STRING "Name of package to be generated") +mark_as_advanced(PACKAGE_FILE_NAME) + +set(CPACK_GENERATOR "DEB;TGZ;TBZ2;STGZ") + +# General configuration +set(CPACK_PACKAGE_VENDOR "LSMS") +set(CPACK_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${LIBMULTISCALE_VERSION}-${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}") +set(CPACK_PACKAGE_VERSION "${LIBMULTISCALE_VERSION}") + +# Debian config package +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "guillaume.anciaux@epfl.ch, nicolas.richart@epfl.ch") +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" CACHE STRING "Architecture of debian package generation") +else() + set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386" CACHE STRING "Architecture of debian package generation") +endif() +mark_as_advanced(CPACK_DEBIAN_PACKAGE_ARCHITECTURE) +set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "LibMultiScale library") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "${PACKAGE_SYSTEM_DEBIAN_PACKAGE_DEPENDS}") + +set(CPACK_DEB_COMPONENT_INSTALL ON) +set(CPACK_TGZ_COMPONENT_INSTALL ON) +set(CPACK_STGZ_COMPONENT_INSTALL ON) +#set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE") +set(CPACK_COMPONENTS_ALL client lib) +set(CPACK_COMPONENT_CLIENT_DISPLAY_NAME "Clients") +set(CPACK_COMPONENT_LIB_DISPLAY_NAME "Libraries") +set(CPACK_COMPONENT_DEV_DISPLAY_NAME "C++ Headers") +set(CPACK_COMPONENT_DEV_DEPENDS lib) +set(CPACK_COMPONENT_LIB_DESCRIPTION "LibMultiScale clients as AMEL/LMPOST") +set(CPACK_COMPONENT_LIB_DESCRIPTION "LibMultiScale libraries") +set(CPACK_COMPONENT_DEV_DESCRIPTION "LibMultiScale C/C++ header files") +set(CPACK_COMPONENT_CLIENT_GROUP "Applications") +set(CPACK_COMPONENT_LIB_GROUP "Applications") +set(CPACK_COMPONENT_DEV_GROUP "Development") + +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PACKAGE_FILE_NAME}-${LIBMULTISCALE_VERSION}-src") +#set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/COPYING") + +list(APPEND CPACK_SOURCE_IGNORE_FILES ${LIBMULTISCALE_EXCLUDE_SOURCE_FILES} ${LIBMULTISCALE_TESTS_EXCLUDE_FILES} ${LIBMULTISCALE_DOC_EXCLUDE_FILES}) +foreach(_pkg ${PACKAGE_SYSTEM_PACKAGES_OFF}) + list(APPEND CPACK_SOURCE_IGNORE_FILES ${CMAKE_SOURCE_DIR}/packages/${_pkg}.cmake) +endforeach() +list(APPEND CPACK_SOURCE_IGNORE_FILES "/doc/manual/;/.*build.*/;/CVS/;/\\\\.svn/;/\\\\.bzr/;/\\\\.hg/;/\\\\.git/;\\\\.swp$;\\\\.#;/#;~" ) + +include(CPack) diff --git a/cmake/LibMultiScaleMacros.cmake b/cmake/LibMultiScaleMacros.cmake new file mode 100644 index 0000000..fa37219 --- /dev/null +++ b/cmake/LibMultiScaleMacros.cmake @@ -0,0 +1,114 @@ +#=============================================================================== +# @file LibMultiScaleMacros.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Sun Jan 06 01:16:34 2013 +# +# @brief General Macros for CMake build system of LM +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +#=============================================================================== +function(compare_lists list1 list2 result) +endfunction() + +#=============================================================================== +include(CMakeDebugMessages) +cmake_register_debug_message_module(ListGenerator) + +function(generate_list type file) + string(TOUPPER ${type} _type) + + foreach(_pkg ${LIBMULTISCALE_PACKAGE_LIST}) + if (LIBMULTISCALE_${_type}_LIST_${_pkg}) + foreach(_line ${LIBMULTISCALE_${_type}_LIST_${_pkg}}) + list(APPEND _list ${_line}) + endforeach() + endif() + endforeach() + + if(NOT "${_list}" STREQUAL "${LIBMULTISCALE_${_type}_LIST}" OR (NOT EXISTS ${file})) + cmake_debug_message(ListGenerator "Generating LIBMULTISCALE_${_type}_LIST in ${file}") + cmake_debug_message(ListGenerator " -- new list: ${_list}") + cmake_debug_message(ListGenerator " -- old list: ${LIBMULTISCALE_${_type}_LIST}") + file(WRITE "${file}" "#define LIST_${_type} \\") + set(LIBMULTISCALE_${_type}_LIST ${_list} CACHE INTERNAL "") + foreach(_line ${LIBMULTISCALE_${_type}_LIST}) + file(APPEND "${file}" " + ${_line} \\") + endforeach() + file(APPEND "${file}" " + + /* File Generated by CMake */") + endif() +endfunction() + +#=============================================================================== +cmake_register_debug_message_module(HeaderListGenerator) + +function(generate_module_header_file module file) + string(TOUPPER ${module} _module) + + cmake_debug_message(HeaderListGenerator "${module} - Package ${LIBMULTISCALE_PACKAGE_LIST}") + foreach(_pkg ${LIBMULTISCALE_PACKAGE_LIST}) + cmake_debug_message(HeaderListGenerator "${module} - Package ${_pkg}") + if (LIBMULTISCALE_${_module}_HDRS_LIST_${_pkg}) + foreach(_line ${LIBMULTISCALE_${_module}_HDRS_LIST_${_pkg}}) + get_filename_component(_hdrs "${_line}" NAME) + cmake_debug_message(HeaderListGenerator "${module} - ${_hdrs}") + list(APPEND _list ${_hdrs}) + endforeach() + endif() + endforeach() + + if(NOT "${_list}" STREQUAL "${LIBMULTISCALE_${_module}_HDR_LIST}" OR (NOT EXISTS ${file})) + cmake_debug_message(HeaderListGenerator "Generating LIBMULTISCALE_${_module}_HDR_LIST in ${file}") + cmake_debug_message(HeaderListGenerator " -- new list: ${_list}") + cmake_debug_message(HeaderListGenerator " -- old list: ${LIBMULTISCALE_${_module}_HDR_LIST}") + set(LIBMULTISCALE_${_module}_HDR_LIST ${_list} CACHE INTERNAL "") + + get_filename_component(_file_we "${file}" NAME_WE) + string(TOUPPER ${_file_we} _file_we) + file(WRITE "${file}" "#ifndef __LIBMULTISCALE_${_file_we}_HH__ +#define __LIBMULTISCALE_${_file_we}_HH__ + +/* -------------------------------------------------------------------------- */") + + foreach(_pkg ${LIBMULTISCALE_PACKAGE_LIST}) + if (LIBMULTISCALE_${_module}_HDRS_LIST_${_pkg}) + file(APPEND "${file}" " + +/* ${_pkg} */") + foreach(_line ${LIBMULTISCALE_${_module}_HDRS_LIST_${_pkg}}) + get_filename_component(_hdrs "${_line}" NAME) + file(APPEND "${file}" " +#include \"${_hdrs}\"") + endforeach() + endif() + endforeach() + file(APPEND "${file}" " +/* -------------------------------------------------------------------------- */ + +#endif // __LIBMULTISCALE_${_file_we}_HH__") + endif() +endfunction() \ No newline at end of file diff --git a/cmake/LibMultiScaleTests.cmake b/cmake/LibMultiScaleTests.cmake new file mode 100644 index 0000000..4a1fd46 --- /dev/null +++ b/cmake/LibMultiScaleTests.cmake @@ -0,0 +1,127 @@ +#=============================================================================== +# @file LibMultiScaleTests.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Feb 04 23:50:04 2013 +# +# @brief Test system for LM +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +include(CMakeDebugMessages) +cmake_register_debug_message_module(TestSystem) + +macro(list_sub_directories list_of_dirs path pattern) + cmake_debug_message(TestSystem "list_sub_directories: Path ${path} - Pattern ${pattern}") + file(GLOB sub-dir RELATIVE ${path} ${path}/${pattern}) + cmake_debug_message(TestSystem "list_sub_directories: ${path}/${pattern} - ${sub-dir}") + set(${list_of_dirs} "") + foreach (dir ${sub-dir}) + if (IS_DIRECTORY ${path}/${dir})# AND NOT ${dir} MATCHES "[.].*") + list(APPEND ${list_of_dirs} ${dir}) + endif() + endforeach() + cmake_debug_message(TestSystem "list_sub_directories: ${${list_of_dirs}}") +endmacro() + +################################################################ +function(create_test path) + cmake_debug_message(TestSystem "create_test: path ${path} - global dependencies: ${ARGN}") + set(list_of_dirs "") + list_sub_directories(list_of_dirs ${CMAKE_CURRENT_SOURCE_DIR}/${path} test_*) + + list(APPEND _dependencies ${ARGN}) + + set(_default_test_enable TRUE) + set(_base_dependencies_str "") + foreach(_dep ${_dependencies}) + set(_base_dependencies_str "${_base_dependencies_str}_${_dep}") + if (NOT LIBMULTISCALE_${_dep}) + set(_default_test_enable FALSE) + cmake_debug_message(TestSystem "create_test: test dependencies ${_dep}: NOT OK") + else() + cmake_debug_message(TestSystem "create_test: test dependencies ${_dep}: OK") + endif() + endforeach() + + set(_tests_dir ${CMAKE_CURRENT_SOURCE_DIR}/${path}) + + if(_default_test_enable) + cmake_debug_message(TestSystem "create_test: list of dirs ${list_of_dirs}") + foreach(dir ${list_of_dirs}) + cmake_debug_message(TestSystem "create_test: registering test ${test_name}") + + set(_test_enable TRUE) + set(_extra_dependencies "") + set(_dependencies_str "${_base_dependencies_str}") + if(EXISTS ${_tests_dir}/${dir}/.depends) + file(STRINGS ${_tests_dir}/${dir}/.depends _extra_dependencies) + foreach(_dep ${_extra_dependencies}) + set(_dependencies_str "${_dependencies_str}_${_dep}") + if (NOT LIBMULTISCALE_${_dep}) + set(_test_enable FALSE) + cmake_debug_message(TestSystem "create_test: test extra dependencies ${_dep}: NOT OK") + else() + cmake_debug_message(TestSystem "create_test: test extra dependencies ${_dep}: OK") + endif() + endforeach() + endif() + if(EXISTS ${_tests_dir}/${dir}/.timesteps) + file(STRINGS ${_tests_dir}/${dir}/.timesteps test_timesteps) + else() + set(test_timesteps 10) + endif() + + cmake_debug_message(TestSystem "create_test: dependency string ${_base_dependencies_str} ${_dependencies_str}") + + set(test_name ${dir}${_dependencies_str}) + if(_test_enable) + SET(${test_name}_timesteps ${test_timesteps} CACHE INTEGER "number of timestep to run for test ${test_name}") + mark_as_advanced(${test_name}_timesteps) + add_test(${test_name} ${CMAKE_BINARY_DIR}/test/run_test.sh ${test_name} ${_tests_dir} ${dir} ${${test_name}_timesteps} ) + cmake_debug_message(TestSystem "create_test: ${test_name} REGISTRED") + set_tests_properties(${test_name} PROPERTIES DEPENDS AMEL) + if(LIBMULTISCALE_TESTS_CHECK_REFERENCE) + add_test(${test_name}_check_reference ${CMAKE_SOURCE_DIR}/test/check_reference.sh output_${test_name} + ${CMAKE_BINARY_DIR}/test/untar_test_reference/output_${test_name}) + set_tests_properties(${test_name}_check_reference PROPERTIES DEPENDS AMEL ${test_name}) + endif() + else() + cmake_debug_message(TestSystem "create_test: ${test_name} NOT REGISTRED") + endif() + endforeach() + endif() +endfunction() + +################################################################ +function(register_tests path) + list_sub_directories(list_of_dirs ${path} *) + cmake_debug_message(TestSystem "register_tests: ${path}") + cmake_debug_message(TestSystem "register_tests: list_of_dirs: ${list_of_dirs}") + foreach(dir ${list_of_dirs}) + string(REPLACE "_" ";" plugins ${dir}) + create_test(${dir} ${plugins}) + endforeach() +endfunction() + +################################################################ diff --git a/cmake/Modules/CMakeDebugMessages.cmake b/cmake/Modules/CMakeDebugMessages.cmake new file mode 100644 index 0000000..b53c13d --- /dev/null +++ b/cmake/Modules/CMakeDebugMessages.cmake @@ -0,0 +1,71 @@ +#=============================================================================== +# @file CMakeDebugMessages.cmake +# +# @author Nicolas Richart +# +# @date creation: Thu Dec 20 2012 +# @date last modification: Fri Jan 04 2013 +# +# @brief Debug message helper +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +if(__CMAKE_DEBUG_MESSAGES) + return() +endif() +set(__CMAKE_DEBUG_MESSAGES TRUE) + +macro(cmake_register_debug_message_module module) + set(_CMAKE_DEBUG_MESSAGE_MODULES ${CMAKE_DEBUG_MESSAGE_MODULES}) + list(APPEND _CMAKE_DEBUG_MESSAGE_MODULES ${module}) + set(CMAKE_DEBUG_MESSAGE_MODULES "${_CMAKE_DEBUG_MESSAGE_MODULES}" + CACHE INTERNAL "List of modules handled by the debug messages system" FORCE) +endmacro() + +macro(cmake_activate_debug_message) + set(_default FALSE) + if(ARGC EQUAL 0) + set(_default TRUE) + endif() + + foreach(_module ${CMAKE_DEBUG_MESSAGE_MODULES}) + set(CMAKE_DEBUG_MESSAGE_${_module} ${_default} CACHE INTERNAL "" FORCE) + endforeach() + + foreach(_module ${ARGN}) + set(CMAKE_DEBUG_MESSAGE_${_module} TRUE CACHE INTERNAL "" FORCE) + endforeach() +endmacro() + + +macro(cmake_deactivate_debug_message) + foreach(_module ${CMAKE_DEBUG_MESSAGE_MODULES}) + if(CMAKE_DEBUG_MESSAGE_${_module}) + set(CMAKE_DEBUG_MESSAGE_${_module} FALSE CACHE INTERNAL "" FORCE) + endif() + endforeach() +endmacro() + +macro(cmake_debug_message module) + if(CMAKE_DEBUG_MESSAGE_${module}) + message("${PROJECT_NAME} - ${module}: ${ARGN}") + endif() +endmacro() \ No newline at end of file diff --git a/cmake/Modules/CMakeDetermineCCompiler.cmake b/cmake/Modules/CMakeDetermineCCompiler.cmake new file mode 100644 index 0000000..1c4fbc8 --- /dev/null +++ b/cmake/Modules/CMakeDetermineCCompiler.cmake @@ -0,0 +1,66 @@ +#=============================================================================== +# @file AkantuDetermineCCompiler.cmake +# +# @author Nicolas Richart +# +# @date Thu Aug 02 10:34:06 2012 +# +# @brief CMake file to determine the compiler +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +macro(determine_compiler_version COMPILER) + exec_program(${CMAKE_CXX_COMPILER} + ARGS --version + OUTPUT_VARIABLE _temp + ) + + set(${COMPILER}_COMPILER_VERSION "" CACHE STRING "Vesion of ${COMPILER} compiler.") + string(REGEX MATCH "([0-9\\.]+)" + ${COMPILER}_COMPILER_VERSION + ${_temp} + ) + + mark_as_advanced(${COMPILER}_COMPILER_VERSION) +endmacro() + +# Code from James Bigler (http://www.cmake.org/pipermail/cmake/2007-June/014460.html) +set(MANTA_COMPILER_NAME_REGEXPR "icc.*$") +if(NOT CMAKE_COMPILER_IS_GNUCC) + # This regular expression also matches things like icc-9.1 + if(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) + set(AKANTU_USING_ICC TRUE) + endif(CMAKE_C_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) +else(NOT CMAKE_COMPILER_IS_GNUCC) + set(AKANTU_USING_GNUCC TRUE) +endif(NOT CMAKE_COMPILER_IS_GNUCC) + +set(MANTA_COMPILER_NAME_REGEXPR "icpc.*$") +if(NOT CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) + set(AKANTU_USING_ICPC TRUE) + determine_compiler_version(INTEL) + #else mvsc/clang/ibm/... ? + endif(CMAKE_CXX_COMPILER MATCHES ${MANTA_COMPILER_NAME_REGEXPR}) +else(NOT CMAKE_COMPILER_IS_GNUCXX) + set(AKANTU_USING_GNUCXX TRUE) + determine_compiler_version(GCC) +endif(NOT CMAKE_COMPILER_IS_GNUCXX) diff --git a/cmake/Modules/CMakeDetermineCompiler.cmake b/cmake/Modules/CMakeDetermineCompiler.cmake new file mode 100644 index 0000000..8bbdbc0 --- /dev/null +++ b/cmake/Modules/CMakeDetermineCompiler.cmake @@ -0,0 +1,87 @@ +# not present in CMake <=2.8.7 so local copy to correct the problem for cpp-array + + +#============================================================================= +# Copyright 2004-2012 Kitware, Inc. +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +macro(_cmake_find_compiler lang) + # Use already-enabled languages for reference. + get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) + list(REMOVE_ITEM _languages "${lang}") + + if(CMAKE_${lang}_COMPILER_INIT) + # Search only for the specified compiler. + set(CMAKE_${lang}_COMPILER_LIST "${CMAKE_${lang}_COMPILER_INIT}") + else() + # Re-order the compiler list with preferred vendors first. + set(_${lang}_COMPILER_LIST "${CMAKE_${lang}_COMPILER_LIST}") + set(CMAKE_${lang}_COMPILER_LIST "") + # Prefer vendors of compilers from reference languages. + foreach(l ${_languages}) + list(APPEND CMAKE_${lang}_COMPILER_LIST + ${_${lang}_COMPILER_NAMES_${CMAKE_${l}_COMPILER_ID}}) + endforeach() + # Prefer vendors based on the platform. + list(APPEND CMAKE_${lang}_COMPILER_LIST ${CMAKE_${lang}_COMPILER_NAMES}) + # Append the rest of the list and remove duplicates. + list(APPEND CMAKE_${lang}_COMPILER_LIST ${_${lang}_COMPILER_LIST}) + unset(_${lang}_COMPILER_LIST) + list(REMOVE_DUPLICATES CMAKE_${lang}_COMPILER_LIST) + if(CMAKE_${lang}_COMPILER_EXCLUDE) + list(REMOVE_ITEM CMAKE_${lang}_COMPILER_LIST + ${CMAKE_${lang}_COMPILER_EXCLUDE}) + endif() + endif() + + # Look for directories containing compilers of reference languages. + set(_${lang}_COMPILER_HINTS) + foreach(l ${_languages}) + if(CMAKE_${l}_COMPILER AND IS_ABSOLUTE "${CMAKE_${l}_COMPILER}") + get_filename_component(_hint "${CMAKE_${l}_COMPILER}" PATH) + if(IS_DIRECTORY "${_hint}") + list(APPEND _${lang}_COMPILER_HINTS "${_hint}") + endif() + unset(_hint) + endif() + endforeach() + + # Find the compiler. + if(_${lang}_COMPILER_HINTS) + # Prefer directories containing compilers of reference languages. + list(REMOVE_DUPLICATES _${lang}_COMPILER_HINTS) + find_program(CMAKE_${lang}_COMPILER + NAMES ${CMAKE_${lang}_COMPILER_LIST} + PATHS ${_${lang}_COMPILER_HINTS} + NO_DEFAULT_PATH + DOC "${lang} compiler") + endif() + find_program(CMAKE_${lang}_COMPILER NAMES ${CMAKE_${lang}_COMPILER_LIST} DOC "${lang} compiler") + if(CMAKE_${lang}_COMPILER_INIT AND NOT CMAKE_${lang}_COMPILER) + set(CMAKE_${lang}_COMPILER "${CMAKE_${lang}_COMPILER_INIT}" CACHE FILEPATH "${lang} compiler" FORCE) + endif() + unset(_${lang}_COMPILER_HINTS) + unset(_languages) + + # Look for a make tool provided by Xcode + if(CMAKE_${lang}_COMPILER STREQUAL "CMAKE_${lang}_COMPILER-NOTFOUND" AND CMAKE_HOST_APPLE) + foreach(comp ${CMAKE_${lang}_COMPILER_LIST}) + execute_process(COMMAND xcrun --find ${comp} + OUTPUT_VARIABLE _xcrun_out OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE _xcrun_err) + if(_xcrun_out) + set_property(CACHE CMAKE_${lang}_COMPILER PROPERTY VALUE "${_xcrun_out}") + break() + endif() + endforeach() + endif() +endmacro() diff --git a/cmake/Modules/CMakeFlagsHandling.cmake b/cmake/Modules/CMakeFlagsHandling.cmake new file mode 100644 index 0000000..508c386 --- /dev/null +++ b/cmake/Modules/CMakeFlagsHandling.cmake @@ -0,0 +1,69 @@ +#=============================================================================== +# @file CMakeFlagsHandling.cmake +# +# @author Nicolas Richart +# +# @date creation: Thu Dec 20 2012 +# @date last modification: Tue Feb 26 2013 +# +# @brief Set of macros used by akantu to handle the package system +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +if(_CMAKE_FLAGS_HANDLING) + return() +endif() +set(_CMAKE_FLAGS_HANDLING TRUE) + + +#=============================================================================== +# Compilation options handling +#=============================================================================== +macro(_get_flags_message type desc) + if(${type} MATCHES "C..") + set(${desc} "Flags used by the compiler during all build types.") + elseif(${type} MATCHES "EXE_LINKER") + set(${desc} "Flags used by the linker.") + elseif(${type} MATCHES "SHARED_LINKER") + set(${desc} "Flags used by the linker during the creation of dll's.") + endif() +endmacro() + +#=============================================================================== +macro(add_flags type flag) + string(TOUPPER ${type} _type) + set(_var CMAKE_${_type}_FLAGS) + _get_flags_message(${_type} _desc) + string(REPLACE "${flag}" "match" _temp_var "${${_var}}") + if(NOT _temp_var MATCHES "match") + set(${_var} "${flag} ${${_var}}" CACHE STRING ${_desc} FORCE) + endif() +endmacro() + +#=============================================================================== +macro(remove_flags type flag) + string(TOUPPER ${type} _type) + set(_var CMAKE_${_type}_FLAGS) + _get_flags_message(${_type} _desc) + string(REPLACE "${flag} " "" ${_var} "${${_var}}") + set(${_var} "${${_var}}" CACHE STRING ${_desc} FORCE) +endmacro() +#=============================================================================== diff --git a/cmake/Modules/CMakePackagesSystem.cmake b/cmake/Modules/CMakePackagesSystem.cmake new file mode 100644 index 0000000..461d036 --- /dev/null +++ b/cmake/Modules/CMakePackagesSystem.cmake @@ -0,0 +1,413 @@ +#=============================================================================== +# @file CMakePackagesSystem.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date creation: Thu Dec 20 2012 +# @date last modification: Wed Sep 10 2014 +# +# @brief Set of macros used by akantu to handle the package system +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +include(CMakeParseArguments) +#=============================================================================== +# Package Management +#=============================================================================== +if(__CMAKE_PACKAGES_SYSTEM) + return() +endif() +set(__CMAKE_PACKAGES_SYSTEM TRUE) + +include(CMakeDebugMessages) +cmake_register_debug_message_module(PackagesSystem) + +macro(package_pkg_name PKG PKG_NAME) + string(TOUPPER ${PROJECT_NAME} _project) + string(TOUPPER ${PKG} _u_package) + set(${PKG_NAME} ${_project}_${_u_package}) +endmacro() + +macro(package_opt_name PKG OPT_NAME) + string(TOUPPER ${PROJECT_NAME} _project) + string(TOUPPER ${PKG} _u_package) + set(${OPT_NAME} ${_project}_USE_${_u_package}) +endmacro() + +macro(package_nature PKG NATURE) + string(TOUPPER ${PROJECT_NAME} _project) + string(TOUPPER ${PKG} _u_package) + set(${NATURE} ${_project}_${_u_package}_NATURE) +endmacro() + +macro(package_desc_name PKG DESC_NAME) + string(TOUPPER ${PROJECT_NAME} _project) + string(TOUPPER ${PKG} _u_package) + set(${DESC_NAME} ${_project}_DESC_${_u_package}) +endmacro() + +#=============================================================================== +option(AUTO_MOVE_OLD_FILES "give cmake permission to move the unregistered files to ${PROJECT_SOURCE_DIR}/tmp directory" FALSE) +mark_as_advanced(AUTO_MOVE_OLD_FILES) + +macro(add_all_packages package_dir src_dir) + string(TOUPPER ${PROJECT_NAME} _project) + cmake_debug_message(PackagesSystem "add_all_packages: PKG DIR : ${package_dir}") + file(GLOB ${_project}_package_list "${package_dir}/*.cmake") + + set(_${_project}_src_dir ${src_dir}) + + set(_package_files) + foreach(_pkg ${${_project}_package_list}) + get_filename_component(_basename ${_pkg} NAME) + list(APPEND _package_files ${_basename}) + endforeach() + + if(_package_files) + list(SORT _package_files) + endif() + + set(${_project}_PACKAGE_SYSTEM_PACKAGES_NAMES_LIST_ALL) + foreach(_pkg ${_package_files}) + string(REGEX REPLACE "[0-9]+_" "" _pkg_name ${_pkg}) + string(REGEX REPLACE "\\.cmake" "" _option_name ${_pkg_name}) + string(TOUPPER "${_option_name}" _option_name) + set(${_project}_${_option_name}_FILE ${_pkg} CACHE INTERNAL "" FORCE) + list(APPEND ${_project}_PACKAGE_SYSTEM_PACKAGES_NAMES_LIST_ALL ${_option_name}) + endforeach() + + cmake_debug_message(PackagesSystem "add_all_packages: PKG LIST : ${${_project}_PACKAGE_SYSTEM_PACKAGES_NAMES_LIST_ALL}") + +# message("Packages: ${${_project}_PACKAGE_SYSTEM_PACKAGES_NAMES_LIST_ALL}") + + foreach(_pkg ${${_project}_PACKAGE_SYSTEM_PACKAGES_NAMES_LIST_ALL}) + cmake_debug_message(PackagesSystem "add_all_packages: including ${_pkg}") + string(TOLOWER "${_pkg}" _l_pkg) + include(${package_dir}/${${_project}_${_pkg}_FILE}) + package_pkg_name(${_l_pkg} _package_name) + if (${_package_name}) + list(APPEND ${_project}_PACKAGE_SYSTEM_PACKAGES_ON ${_l_pkg}) + list(APPEND ${_project}_PACKAGE_LIST ${_pkg}) + else (${_package_name}) + list(APPEND ${_project}_PACKAGE_SYSTEM_PACKAGES_OFF ${_l_pkg}) + endif() + + foreach(_file ${${_package_name}_FILES}) + list(APPEND ${_project}_release_all_files ${_file}) + endforeach() + endforeach() + + cmake_debug_message(PackagesSystem "add_all_packages: ON PKG : ${${_project}_PACKAGE_SYSTEM_PACKAGES_ON}") + cmake_debug_message(PackagesSystem "add_all_packages: ALL RELEASE FILES LIST : ${_project}_release_all_files ${${_project}_release_all_files}") + + #check if there are some file in the release that are not registered in a package + file(GLOB_RECURSE ${_project}_all_files "*.cc" "*.hh" "*.c" "*.h" "*.hpp") + cmake_debug_message(PackagesSystem "add_all_packages: ALL FILES LIST : ${_project}_all_files ${${_project}_all_files}") + + cmake_debug_message(PackagesSystem "add_all_packages: SOURCE DIR : ${_${_project}_src_dir}") + foreach(_file ${${_project}_all_files}) + if("${_file}" MATCHES "${_${_project}_src_dir}") + file(RELATIVE_PATH __file "${_${_project}_src_dir}" ${_file}) + list(APPEND ${_project}_all_files_relatives ${__file}) + endif() + endforeach() + + foreach(_file ${${_project}_all_files_relatives}) + if(NOT ${_file} MATCHES "test.*" AND NOT ${_file} MATCHES "third-party" AND NOT ${_file} MATCHES "doc") + list(FIND ${_project}_release_all_files ${_file} _index) + if (_index EQUAL -1) + list(APPEND ${_project}_missing_files_in_packages ${_file}) + endif() + endif() + endforeach() + if (${_project}_missing_files_in_packages) + message("The files:") + message("*****************") + foreach(_file ${${_project}_missing_files_in_packages}) + message("${_file}") + endforeach() + message("*****************") + message("are not registered in any package.") + if (NOT AUTO_MOVE_OLD_FILES) + message("Please append these files in one of the packages within directory + ${PROJECT_SOURCE_DIR}/packages +or remove the files if useless. +") + message(FATAL_ERROR "abort") + else() + message("These files are getting displaced to directory ${PROJECT_SOURCE_DIR}/tmp/") + message("creating directory ${PROJECT_SOURCE_DIR}/tmp/") + file(MAKE_DIRECTORY ${PROJECT_SOURCE_DIR}/tmp/) + foreach(_file ${${_project}_missing_files_in_packages}) + get_filename_component(fname ${_file} NAME) + message("renaming ${src_dir}/${_file} to ${PROJECT_SOURCE_DIR}/tmp/${fname}") + file(RENAME ${src_dir}/${_file} ${PROJECT_SOURCE_DIR}/tmp/${fname}) + endforeach() + endif() + endif() + + if(${_project}_missing_files_in_packages) + message("A complete list of files missing in the packages description can be found here: ${PROJECT_BINARY_DIR}/missing_files_in_packages") + if(EXISTS ${PROJECT_BINARY_DIR}/missing_files_in_packages) + file(REMOVE ${PROJECT_BINARY_DIR}/missing_files_in_packages) + endif() + foreach(_file ${${_project}_missing_files_in_packages}) + file(APPEND ${PROJECT_BINARY_DIR}/missing_files_in_packages "${_file} +") + endforeach() + endif() + + #check if there are some file in the package list that are not on the current directory + foreach(_file ${${_project}_release_all_files}) + list(FIND ${_project}_all_files_relatives ${_file} _index) + if (_index EQUAL -1) + message("The file ${_file} is registered in packages but is not present in the source directory.") + endif() + endforeach() + + #construct list of files for unactivated packages +# list(APPEND _tmp_${_project}_EXCLUDE_SOURCE_FILES ${${_project}_EXCLUDE_SOURCE_FILES}) + set(_tmp_${_project}_EXCLUDE_SOURCE_FILES "") + foreach(_pkg ${${_project}_PACKAGE_SYSTEM_PACKAGES_OFF}) + package_pkg_name(${_pkg} _pkg_name) + cmake_debug_message(PackagesSystem "add_all_packages: exlude ${_file}") + list(APPEND _tmp_${_project}_EXCLUDE_SOURCE_FILES ${${_pkg_name}_FILES}) + endforeach() + + set(${_project}_EXCLUDE_SOURCE_FILES "${_tmp_${_project}_EXCLUDE_SOURCE_FILES}" CACHE INTERNAL "File to exclude in the project ${_project} package" FORCE) + #check dependencies + foreach(_pkg ${${_project}_PACKAGE_SYSTEM_PACKAGES_OFF}) + # differentiate the file types + cmake_debug_message(PackagesSystem "add_all_packages: DEPENDS PKG : ${_pkg}") + cmake_debug_message(PackagesSystem "add_all_packages: DEPENDS LST : ${${_pkg}_DEPENDS}") + package_pkg_name(${_pkg} _pkg_name) + if (NOT "${${_pkg_name}_DEB_DEPEND}" STREQUAL "") + set(deb_depend "${deb_depend}, ${${_pkg}_DEB_DEPEND}") + endif() + endforeach() + set(${_project}_PACKAGE_SYSTEM_DEBIAN_PACKAGE_DEPENDS "${deb_depend}") +endmacro() + +#=============================================================================== +macro(generate_source_list_from_packages source_dir source_files inline_files headers_files include_dirs) + string(TOUPPER ${PROJECT_NAME} _project) + + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: SRC DIR : ${source_dir}") + foreach(_pkg ${${_project}_PACKAGE_SYSTEM_PACKAGES_ON}) + # differentiate the file types + package_pkg_name(${_pkg} _package_name) + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: PKG ${_package_name} FILES : ${${_package_name}_FILES}") + foreach(_file ${${_package_name}_FILES}) + if(${_file} MATCHES ".*inline.*\\.cc") + list(APPEND ${_package_name}_inlines ${_file}) + elseif(${_file} MATCHES ".*\\.h+") + list(APPEND ${_package_name}_headers ${_file}) + else() + list(APPEND ${_package_name}_srcs ${_file}) + endif() + endforeach() + + # generates the include directory variable + foreach(_file ${${_package_name}_headers}) + get_filename_component(_absolute_name ${_file} ABSOLUTE) + get_filename_component(_include_dir ${_absolute_name} PATH) + list(APPEND ${_package_name}_include_dirs ${_include_dir}) + list(REMOVE_DUPLICATES ${_package_name}_include_dirs) + endforeach() + + # generate global lists for akantu to know what to build + list(APPEND ${source_files} ${${_package_name}_srcs}) + list(APPEND ${inline_files} ${${_package_name}_inlines}) + list(APPEND ${headers_files} ${${_package_name}_headers}) + list(APPEND ${include_dirs} ${${_package_name}_include_dirs}) + + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: PKG ${_package_name} SRCS : ${${_package_name}_srcs}") + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: PKG ${_package_name} INLINES : ${${_package_name}_inlines}") + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: PKG ${_package_name} HRDS : ${${_package_name}_headers}") + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: PKG ${_package_name} INCS : ${${_package_name}_include_dirs}") + endforeach() + + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: SRCS : ${${source_files}}") + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: HRDS : ${${headers_files}}") + cmake_debug_message(PackagesSystem "generate_source_list_from_packages: INCS : ${${include_dirs}}") +endmacro() + +#=============================================================================== +# macro to include optional packages +macro(add_optional_external_package PACKAGE DESC DEFAULT) + package_opt_name (${PACKAGE} _option_name) + package_desc_name(${PACKAGE} _desc_name) + set(${_desc_name} ${DESC}) + package_nature(${PACKAGE} _nature) + set(${_nature} "external_optional") + option(${_option_name} ${DESC} ${DEFAULT}) + _add_external_package(${PACKAGE} ${ARGN}) +endmacro() + +macro(add_external_package PACKAGE) + package_opt_name (${PACKAGE} _option_name) + set(${_option_name} ON) + package_nature(${PACKAGE} _nature) + set(${_nature} "external") + _add_external_package(${PACKAGE} ${ARGN}) +endmacro() + + +macro(_add_external_package PACKAGE) + string(TOUPPER ${PROJECT_NAME} _project) + cmake_parse_arguments(_opt_pkg "" "LANGUAGE" "DEPENDS;PREFIX;FOUND;ARGS" ${ARGN}) + + package_pkg_name (${PACKAGE} _pkg_name) + package_opt_name (${PACKAGE} _option_name) + + cmake_debug_message(PackagesSystem "add_optional_package: Registering ${PACKAGE} ${DESC} -> ${_option_name}") + + if(_opt_pkg_PREFIX) + set(_package_prefix ${_opt_pkg_PREFIX}) + else() + string(TOUPPER ${PACKAGE} _u_package) + set(_package_prefix ${_u_package}) + endif() + + if(${_option_name}) + if(_opt_pkg_LANGUAGE) + foreach(_language ${_opt_pkg_LANGUAGE}) + cmake_debug_message(PackagesSystem "add_optional_package: Package ${PACKAGE} asked for language ${_language}") + enable_language(${_language}) + endforeach() + endif() + + foreach(_dep ${_opt_pkg_DEPENDS}) + add_external_package_dependencies(${PACKAGE} ${_dep}) + endforeach() + + find_package(${PACKAGE} REQUIRED ${_opt_pkg_ARGS}) + + foreach(_prefix ${_package_prefix}) + if(${_prefix}_FOUND OR _opt_pkg_FOUND) + list(APPEND ${_project}_DEFINITIONS ${_option_name}) + if(DEFINED ${_prefix}_INCLUDE_DIRS) + list(APPEND ${_project}_EXTERNAL_LIB_INCLUDE_DIR ${${_prefix}_INCLUDE_DIRS}) + set(${_pkg_name}_INCLUDE_DIR ${${_prefix}_INCLUDE_DIRS}) + elseif(DEFINED ${_prefix}_INCLUDE_DIR) + list(APPEND ${_project}_EXTERNAL_LIB_INCLUDE_DIR ${${_prefix}_INCLUDE_DIR}) + set(${_pkg_name}_INCLUDE_DIR ${${_prefix}_INCLUDE_DIR}) + elseif(DEFINED ${_prefix}_INCLUDE_PATH) + list(APPEND ${_project}_EXTERNAL_LIB_INCLUDE_DIR ${${_prefix}_INCLUDE_PATH}) + set(${_pkg_name}_INCLUDE_DIR ${${_prefix}_INCLUDE_PATH}) + endif() + list(APPEND ${_project}_EXTERNAL_LIBRARIES ${${_prefix}_LIBRARIES}) + set(${_pkg_name}_LIBRARIES ${${_prefix}_LIBRARIES}) + set(${_pkg_name} ON) + string(TOUPPER ${PACKAGE} _u_package) + list(APPEND ${_project}_OPTION_LIST ${_u_package}) + cmake_debug_message(PackagesSystem "add_optional_package: Package ${PACKAGE} found! (PREFIX: ${_prefix})") + cmake_debug_message(PackagesSystem "add_optional_package: Package ${PACKAGE} includes : ${${_pkg_name}_INCLUDE_DIR}") + cmake_debug_message(PackagesSystem "add_optional_package: Package ${PACKAGE} libraries: ${${_pkg_name}_LIBRARIES}") + cmake_debug_message(PackagesSystem "add_optional_package: option list: ${${_project}_OPTION_LIST}") + else(${_prefix}_FOUND) + cmake_debug_message(PackagesSystem "add_optional_package: Package ${PACKAGE} not found! (PREFIX: ${_prefix})") + set(${_pkg_name} OFF) + endif() + endforeach() + endif(${_option_name}) +endmacro() + +#=============================================================================== +# macro to add meta packages +macro(add_meta_package PKG DESC DEFAULT) + cmake_debug_message(PackagesSystem "add_meta_package: register meta option ${PKG} ${DESC} ${DEFAULT}") + package_pkg_name (${PKG} _pkg_name) + package_desc_name(${PKG} _desc_name) + + set(${_desc_name} ${DESC}) + option(${_pkg_name} ${DESC} ${DEFAULT}) + + foreach(_dep ${ARGN}) + package_opt_name (${_dep} _dep_name) + mark_as_advanced(${_dep_name}) + add_external_package_dependencies(${PKG} ${_dep}) + endforeach() +endmacro() + +#=============================================================================== +macro(_add_package_dependencies PKG DEP _dep_name) + package_pkg_name (${PKG} _opt_name) + package_desc_name(${DEP} _var_dep_desc) + package_pkg_name (${DEP} _dep_pkg_name) + + if (NOT ${_opt_name}_dependencies) + set(${_opt_name}_dependencies) + endif() + + list(APPEND ${_opt_name}_dependencies ${_dep_pkg_name}) + list(REMOVE_DUPLICATES ${_opt_name}_dependencies) + + set(${_opt_name}_dependencies ${${_opt_name}_dependencies} CACHE INTERNAL "List of dependencies for package ${_opt_name}" FORCE) + + cmake_debug_message(PackagesSystem "add_package_dependecies: add dependence between ${_opt_name} and ${_dep_name}") + set(_dep_desc ${_var_dep_desc}) + + cmake_debug_message(PackagesSystem "add_package_dependecies: ON dependencies of ${_dep_name} are: ${${_dep_name}_DEPS}") + cmake_debug_message(PackagesSystem "add_package_dependecies: saved value for ${_dep_name} is: ${${_dep_name}_OLD}") + if(${_opt_name}) + if("${${_dep_name}_DEPS}" STREQUAL "") + cmake_debug_message(PackagesSystem "add_package_dependecies: Save dep state ${_dep_name}:${${_dep_name}}") + set(${_dep_name}_OLD ${${_dep_name}} CACHE INTERNAL "${_dep_desc}" FORCE) + endif() + + cmake_debug_message(PackagesSystem "add_package_dependecies: force value to ON ${_dep_name}") + set(${_dep_name} ON CACHE BOOL "${_dep_desc}" FORCE) + + list(FIND ${_dep_name}_DEPS ${_opt_name} pos) + if(pos EQUAL -1) + list(APPEND ${_dep_name}_DEPS ${_opt_name}) + set(${_dep_name}_DEPS ${${_dep_name}_DEPS} CACHE INTERNAL "Dependencies ON with package ${_dep_name}" FORCE) + endif() + else() + list(LENGTH ${_dep_name}_DEPS len) + list(FIND ${_dep_name}_DEPS ${_opt_name} pos) + if((len EQUAL 1) AND (NOT pos EQUAL -1)) + cmake_debug_message(PackagesSystem "add_package_dependecies: Restore state ${_dep_name}:${${_dep_name}} (${pos})") + set(${_dep_name} ${${_dep_name}_OLD} CACHE BOOL "${_dep_desc}" FORCE) + unset(${_dep_name}_OLD CACHE) + endif() + + if(NOT pos EQUAL -1) + list(REMOVE_AT ${_dep_name}_DEPS ${pos}) + set(${_dep_name}_DEPS ${${_dep_name}_DEPS} CACHE INTERNAL "Nb dependencies with package ${_dep_name}" FORCE) + endif() + endif() + +endmacro() + +#=============================================================================== +macro(add_internal_package_dependencies PKG DEP) + package_pkg_name (${DEP} _dep_name) + _add_package_dependencies(${PKG} ${DEP} ${_dep_name}) +endmacro() + +#=============================================================================== +macro(add_external_package_dependencies PKG DEP) + package_opt_name (${DEP} _dep_name) + _add_package_dependencies(${PKG} ${DEP} ${_dep_name}) +endmacro() diff --git a/cmake/Modules/CMakeVersionGenerator.cmake b/cmake/Modules/CMakeVersionGenerator.cmake new file mode 100644 index 0000000..d884b8b --- /dev/null +++ b/cmake/Modules/CMakeVersionGenerator.cmake @@ -0,0 +1,100 @@ +#=============================================================================== +# @file CMakeVersionGenerator.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date creation: Thu Dec 20 2012 +# @date last modification: Fri Jun 13 2014 +# +# @brief Set of macros used by akantu to handle the package system +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +if(__DEFINE_PROJECT_VERSION__) + return() +endif() +set(__DEFINE_PROJECT_VERSION__ TRUE) + +macro(define_project_version) + string(TOUPPER ${PROJECT_NAME} _project) + + if(EXISTS ${PROJECT_SOURCE_DIR}/VERSION) + file(STRINGS ${PROJECT_SOURCE_DIR}/VERSION ${_project}_VERSION) + + if("${${_project}_VERSION}" MATCHES "^([0-9]+)") + string(REGEX REPLACE "^([0-9]+).*" "\\1" _ver_major "${${_project}_VERSION}") + set(${_project}_MAJOR_VERSION ${_ver_major}) + + if("${${_project}_VERSION}" MATCHES "^${_ver_major}\\.([0-9]+)") + string(REGEX REPLACE "^${_ver_major}\\.([0-9]+).*" "\\1" _ver_minor "${${_project}_VERSION}") + set(${_project}_MINOR_VERSION ${_ver_minor}) + if("${${_project}_VERSION}" MATCHES "^${_ver_major}\\.${_ver_minor}\\.([0-9a-zA-Z\\-]+)") + string(REGEX REPLACE "^${_ver_major}\\.${_ver_minor}\\.([0-9a-zA-Z\\-]+).*" "\\1" _ver_build "${${_project}_VERSION}") + set(${_project}_BUILD_VERSION ${_ver_build}) + endif() + endif() + endif() + else() + find_package(Subversion) + if(SUBVERSION_FOUND) + subversion_wc_info(${PROJECT_SOURCE_DIR} ${_project} ERROR_QUIET) + if(${${_project}_WC_FOUND}) + set(${_project}_BUILD_VERSION ${${_project}_WC_REVISION}) + set(${_project}_VERSION + "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}.${${_project}_BUILD_VERSION}" + ) + endif() + endif() + find_package(Git) + if(GIT_FOUND) + execute_process( + COMMAND git rev-parse --verify --short HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_HEAD + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(NOT ${GIT_HEAD} STREQUAL "") + set(${_project}_BUILD_VERSION ${GIT_HEAD}) + set(${_project}_VERSION + "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}.${${_project}_BUILD_VERSION}" + ) + endif() + endif() + + endif() + + if(NOT ${_project}_VERSION) + set(${_project}_VERSION + "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}" + ) + endif() + + # Append the library version information to the library target properties + if(NOT ${_project}_NO_LIBRARY_VERSION) + message(STATUS "${PROJECT_NAME} version: ${${_project}_VERSION}") + + set(${_project}_LIBRARY_PROPERTIES ${${_project}_LIBRARY_PROPERTIES} + VERSION "${${_project}_VERSION}" + SOVERSION "${${_project}_MAJOR_VERSION}.${${_project}_MINOR_VERSION}" + ) + endif() +endmacro() \ No newline at end of file diff --git a/cmake/Modules/CorrectWindowsPaths.cmake b/cmake/Modules/CorrectWindowsPaths.cmake new file mode 100644 index 0000000..09bcdd6 --- /dev/null +++ b/cmake/Modules/CorrectWindowsPaths.cmake @@ -0,0 +1,14 @@ +# CorrectWindowsPaths - this module defines one macro +# +# CONVERT_CYGWIN_PATH( PATH ) +# This uses the command cygpath (provided by cygwin) to convert +# unix-style paths into paths useable by cmake on windows + +macro (CONVERT_CYGWIN_PATH _path) + if (WIN32) + EXECUTE_PROCESS(COMMAND cygpath.exe -m ${${_path}} + OUTPUT_VARIABLE ${_path}) + string (STRIP ${${_path}} ${_path}) + endif (WIN32) +endmacro (CONVERT_CYGWIN_PATH) + diff --git a/cmake/Modules/FindCppArray.cmake b/cmake/Modules/FindCppArray.cmake new file mode 100644 index 0000000..3476849 --- /dev/null +++ b/cmake/Modules/FindCppArray.cmake @@ -0,0 +1,35 @@ +#=============================================================================== +# @file FindCppArray.cmake +# +# @author Alejandro M. Aragón +# +# @date creation: Fri Jan 04 2013 +# @date last modification: Thu Jan 10 2013 +# +# @brief The find_package file for cpp-array library +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_path (CPPARRAY_INCLUDE_DIR expr.hpp PATH_SUFFIXES array) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CppArray DEFAULT_MSG CPPARRAY_INCLUDE_DIR) + diff --git a/cmake/Modules/FindEPSN.cmake b/cmake/Modules/FindEPSN.cmake new file mode 100644 index 0000000..d252334 --- /dev/null +++ b/cmake/Modules/FindEPSN.cmake @@ -0,0 +1,56 @@ +#=============================================================================== +# @file FindEPSN.cmake +# +# @author Nicolas Richart +# +# @date creation: Mon Dec 13 2010 +# @date last modification: Fri Jan 04 2013 +# +# @brief The find_package file for EPSN +# +# @section LICENSE +# +# Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +#=============================================================================== +find_path(EPSN_DIR EPSNConfig.cmake + PATHS $ENV{EPSN_TOP} + ) + + +if(EPSN_DIR) + include(${EPSN_DIR}/EPSNConfig.cmake) + set(EPSN_LIB_PATH ${EPSN_DIR}/lib + ${EPSN_LIBRARIES_DIR} + ) + find_library(EPSN_COMMON_LIBRARY epsn_common + PATHS ${EPSN_LIB_PATH} + ) + find_library(EPSN_SIMULATION_LIBRARY epsn_simulation + PATHS ${EPSN_LIB_PATH} + ) + include(${EPSN_DIR}/EPSNLibraryDepends.cmake) + + set(EPSN_LIBRARIES ${EPSN_SIMULATION_LIBRARY} ${EPSN_COMMON_LIBRARY}) +endif(EPSN_DIR) + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(EPSN DEFAULT_MSG + EPSN_LIBRARIES EPSN_INCLUDE_DIR) diff --git a/cmake/Modules/FindFFTW.cmake b/cmake/Modules/FindFFTW.cmake new file mode 100644 index 0000000..4a86652 --- /dev/null +++ b/cmake/Modules/FindFFTW.cmake @@ -0,0 +1,72 @@ +#=============================================================================== +# @file FindFFTW.cmake +# +# @author Guillaume Anciaux +# +# @date creation: Thu Mar 17 2011 +# @date last modification: Mon Jul 28 2014 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +set(FFTW_VERSION "3" CACHE INTEGER "Version of FFTW required") + +if (FFTW_FIND_VERSION) + set(FFTW_VERSION ${FFTW_FIND_VERSION} CACHE INTEGER "Version of FFTW required") +endif() + +if (FFTW_VERSION EQUAL "2") + find_library(FFTW_LIBRARIES fftw + PATHS ${FFTW_DIR} + PATH_SUFFIXES fftw/.libs/ lib + ) + find_path(FFTW_INCLUDE_PATH fftw.h + PATHS ${FFTW_DIR} $ENV{INCLUDE_PATH} + PATH_SUFFIXES include fftw + ) +else() + + find_library(FFTW_LIBRARIES fftw3 + PATHS ENV LD_LIBRARY_PATH + ) + find_library(FFTW_THREAD_LIBRARY fftw3_threads + PATHS ENV LD_LIBRARY_PATH + ) + find_library(FFTW_OPENMP_LIBRARY fftw3_omp + PATHS ENV LD_LIBRARY_PATH + ) + find_path(FFTW_INCLUDE_PATH fftw3.h + PATHS ENV INCLUDE_PATH + PATH_SUFFIXES include fftw + ) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFTW DEFAULT_MSG + FFTW_LIBRARIES FFTW_INCLUDE_PATH) + + +if(NOT FFTW_FOUND) + set(FFTW_DIR "" CACHE PATH "Location of FFTW library.") +endif(NOT FFTW_FOUND) + +mark_as_advanced(FFTW_LIBRARIES FFTW_OPENMP_LIBRARY FFTW_THREAD_LIBRARY FFTW_INCLUDE_PATH FFTW_VERSION) diff --git a/cmake/Modules/FindGMSH.cmake b/cmake/Modules/FindGMSH.cmake new file mode 100644 index 0000000..0f3722f --- /dev/null +++ b/cmake/Modules/FindGMSH.cmake @@ -0,0 +1,81 @@ +#=============================================================================== +# @file FindGMSH.cmake +# +# @author Nicolas Richart +# +# @date creation: Fri Oct 15 2010 +# @date last modification: Tue Sep 09 2014 +# +# @brief Find gmsh and delacre the add_mesh macro +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_program(GMSH gmsh + DOC "The mesh generetor gmsh") + +mark_as_advanced(GMSH) + +find_package(PackageHandleStandardArgs) +find_package_handle_standard_args(GMSH DEFAULT_MSG GMSH) + +#=============================================================================== +macro(ADD_MESH MESH_TARGET GEO_FILE DIM ORDER) + if(GMSH_FOUND) + set(arguments + ${MESH_TARGET} ${GEO_FILE} ${DIM} ${ORDER} + ${ARGN} + ) + + cmake_parse_arguments(ADD_MESH + "" + "OUTPUT" + "" + ${arguments} + ) + + set(_geo_file ${CMAKE_CURRENT_SOURCE_DIR}/${GEO_FILE}) + + if(ADD_MESH_OUTPUT) + set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${ADD_MESH_OUTPUT}) + else(ADD_MESH_OUTPUT) + get_filename_component(_msh_file "${GEO_FILE}" NAME_WE) + set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${_msh_file}.msh) + endif(ADD_MESH_OUTPUT) + + string(REPLACE "${CMAKE_SOURCE_DIR}/" "" _r_geo_file "${_geo_file}") + string(REPLACE "${CMAKE_BINARY_DIR}/" "" _r_msh_file "${_msh_file}") + + if(EXISTS ${_geo_file}) + add_custom_command( + OUTPUT ${_msh_file} + DEPENDS ${_geo_file} + COMMAND ${GMSH} + ARGS -${DIM} -order ${ORDER} -optimize -o ${_msh_file} ${_geo_file} 2>&1 > /dev/null + COMMENT "Generating the ${DIM}D mesh ${_r_msh_file} (order ${ORDER}) form the geometry ${_r_geo_file}" + ) + add_custom_target(${MESH_TARGET} + DEPENDS ${_msh_file}) + set_target_properties(${MESH_TARGET} PROPERTIES RESSOURCES ${_geo_file}) + #else(EXISTS ${_geo_file}) + # message("File ${_geo_file} not found") + endif(EXISTS ${_geo_file}) + endif(GMSH_FOUND) +endmacro(ADD_MESH) diff --git a/cmake/Modules/FindGSL.cmake b/cmake/Modules/FindGSL.cmake new file mode 100644 index 0000000..a2812c8 --- /dev/null +++ b/cmake/Modules/FindGSL.cmake @@ -0,0 +1,54 @@ +#=============================================================================== +# @file FindGSL.cmake +# +# +# @date creation: Fri Aug 10 2012 +# @date last modification: Fri Jan 04 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_path(GSL_INCLUDE_PATH gsl_math.h + PATHS ${GSL_DIR} ENV C_INCLUDE_PATH + PATH_SUFFIXES gsl + ) + +find_library(GSL_MAIN_LIBRARY NAME gsl + PATHS ${GSL_DIR} ENV LIBRARY_PATH + PATH_SUFFIXES lib + ) + +find_library(GSL_BLAS_LIBRARY NAME gslcblas + PATHS ${GSL_DIR} ENV LIBRARY_PATH + PATH_SUFFIXES lib +) + +mark_as_advanced(GSL_INCLUDE_PATH) +mark_as_advanced(GSL_MAIN_LIBRARY NAME) +mark_as_advanced(GSL_BLAS_LIBRARY NAME) + +set(GSL_LIBRARIES ${GSL_MAIN_LIBRARY} ${GSL_BLAS_LIBRARY}) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(GSL DEFAULT_MSG + GSL_LIBRARIES GSL_INCLUDE_PATH) diff --git a/cmake/Modules/FindIOHelper.cmake b/cmake/Modules/FindIOHelper.cmake new file mode 100644 index 0000000..4eb2cf9 --- /dev/null +++ b/cmake/Modules/FindIOHelper.cmake @@ -0,0 +1,60 @@ +#=============================================================================== +# @file FindIOHelper.cmake +# +# @author Nicolas Richart +# +# @date creation: Wed Aug 04 2010 +# @date last modification: Fri Jan 04 2013 +# +# @brief The find_package file for IOHelper +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +#=============================================================================== +#set(IOHELPER_LIBRARY "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) +find_library(IOHELPER_LIBRARY iohelper + PATHS ${IOHELPER_DIR} + PATH_SUFFIXES lib + ) + +find_path(IOHELPER_INCLUDE_DIR io_helper.hh + PATHS ${IOHELPER_DIR} + PATH_SUFFIXES include include/iohelper + ) + +#=============================================================================== +mark_as_advanced(IOHELPER_LIBRARY) +mark_as_advanced(IOHELPER_INCLUDE_DIR) + +#=============================================================================== +find_package(ZLIB REQUIRED) + +set(IOHELPER_LIBRARIES_ALL ${IOHELPER_LIBRARY} ${ZLIB_LIBRARIES}) +set(IOHELPER_LIBRARIES ${IOHELPER_LIBRARIES_ALL} CACHE INTERNAL "Libraries for IOHelper" FORCE) + +#=============================================================================== +if(NOT IOHELPER_FOUND) + set(IOHELPER_DIR "" CACHE PATH "Location of IOHelper source directory.") +endif() + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(IOHelper DEFAULT_MSG IOHELPER_LIBRARY IOHELPER_INCLUDE_DIR) diff --git a/cmake/Modules/FindInkscape.cmake b/cmake/Modules/FindInkscape.cmake new file mode 100644 index 0000000..eb0d2e6 --- /dev/null +++ b/cmake/Modules/FindInkscape.cmake @@ -0,0 +1,93 @@ +#=============================================================================== +# @file FindInkscape.cmake +# +# +# @date creation: Thu Jan 10 2013 +# @date last modification: Thu Jan 10 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +# Module thaat checks for inkscape +# +# Sets the following variables +# +# INSCAPE: Path to inkscape to generate .png's form .svg's +# +# Provides the following functions: +# +# inkscape_generate_png_from_svg([OUTPUT_DIR ] [ ....]) +# +# Generates pngfile1, ... from svg input files pngfile1.svg, .... +# The output directory can be specified with the option OUTPUT_DIR. If it is omitted +# the files will be generated in CMAKE_CURRENT_BINARY_DIR. + +find_program(INKSCAPE inkscape DOC "Path to inkscape to generate png files from svg files") +find_program(CONVERT convert DOC "Path to convert program") +if(INKSCAPE) + set(INKSCAPE_FOUND True) +endif(INKSCAPE) + +include(CMakeParseArguments) + +function(inkscape_generate_png_from_svg) + if(NOT INKSCAPE) + return() + endif(NOT INKSCAPE) + cmake_parse_arguments(INKSCAPE "" "DPI" "" ${ARGN}) + if(NOT INKSCAPE_DPI) + set(INKSCAPE_DPI 90) + endif(NOT INKSCAPE_DPI) + + foreach(pic ${INKSCAPE_UNPARSED_ARGUMENTS}) + string(REGEX REPLACE "\\.[a-zA-Z]+" ".png" output ${pic}) + add_custom_command(OUTPUT ${output} + COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${output} -f ${pic} + DEPENDS ${pic} + COMMENT "Generating ${output} from ${pic}" + ) + endforeach(pic) +endfunction(inkscape_generate_png_from_svg) + +function(inkscape_generate_eps_from_svg) + cmake_parse_arguments(INKSCAPE "" "INPUT_DIR;OUTPUT_DIR;DPI" "" ${ARGN}) + if(NOT INKSCAPE_INPUT_DIR) + set(INKSCAPE_INPUT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + endif(NOT INKSCAPE_INPUT_DIR) + if(NOT INKSCAPE_INPUT_DIR) + set(INKSCAPE_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) + endif(NOT INKSCAPE_INPUT_DIR) + + foreach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS}) + string(REGEX REPLACE "\\.[a-zA-Z]+" ".png" input "${_pic}") + string(REGEX REPLACE "\\.[a-zA-Z]+" ".svg" svginput "${_pic}") + + add_custom_target(${input} + COMMAND ${INKSCAPE} --export-dpi=${INKSCAPE_DPI} -e ${input} ${CMAKE_CURRENT_SOURCE_DIR}/${svginput} + COMMENT "Generating ${INKSCAPE_OUTPUT_DIR}/${pic} from ${CMAKE_CURRENT_SOURCE_DIR}/${input}") + add_custom_command(OUTPUT ${_pic} + COMMAND ${CONVERT} ${INKSCAPE_INPUT_DIR}/${input} EPS:${_pic} + DEPENDS ${input} + COMMENT "Converting ${INKSCAPE_INPUT_DIR}/${input} to ${INKSCAPE_OUTPUT_DIR}/${_pic}" + WORKING_DIRECTORY ${INKSCAPE_OUTPUT_DIR}) + endforeach(_pic ${INKSCAPE_UNPARSED_ARGUMENTS}) +endfunction(inkscape_generate_eps_from_svg) \ No newline at end of file diff --git a/cmake/Modules/FindLAMMPS.cmake b/cmake/Modules/FindLAMMPS.cmake new file mode 100644 index 0000000..bf16c78 --- /dev/null +++ b/cmake/Modules/FindLAMMPS.cmake @@ -0,0 +1,68 @@ +#=============================================================================== +# @file FindLAMMPS.cmake +# +# +# @date creation: Thu Mar 17 2011 +# @date last modification: Fri Jan 04 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_path(LAMMPS_INCLUDE_PATH lammps.h + PATHS ${LAMMPS_DIR} ENV C_INCLUDE_PATH + PATH_SUFFIXES src + ) + +#if (not ${LAMMPS_ARCH}) + file(GLOB ARCHS "${LAMMPS_INCLUDE_PATH}/liblmp*") + foreach(loop_var IN ITEMS ${ARCHS}) + get_filename_component(loop_var ${loop_var} NAME) + string(REGEX REPLACE ".so" "" loop_var ${loop_var}) + string(REGEX REPLACE "liblmp_" "" loop_var ${loop_var}) +# MESSAGE ("possible archs compiled for lammps : ${loop_var}") + SET(LAMMPS_ARCH ${loop_var} CACHE INTERNAL "internal built version of lammps detection" FORCE) +# MESSAGE ("libname : lmp_${LAMMPS_ARCH}") + endforeach(loop_var) +#endif(not ${LAMMPS_ARCH}) + + +find_library(LAMMPS_MAIN_LIBRARY NAME lmp_${LAMMPS_ARCH} + PATHS ${LAMMPS_DIR} + PATH_SUFFIXES src + ) + +if (NOT LAMMPS_MAIN_LIBRARY) +set(LAMMPS_DIR "" CACHE PATH "Location of LAMMPS library.") +endif (NOT LAMMPS_MAIN_LIBRARY) + +find_library(LAMMPS_MEAM_LIBRARIES NAME meam + PATHS ${LAMMPS_DIR} + PATH_SUFFIXES lib/meam +) + +set(LAMMPS_LIBRARIES ${LAMMPS_MAIN_LIBRARY} ${LAMMPS_MEAM_LIBRARIES}) +SEPARATE_ARGUMENTS(LAMMPS_LIBRARIES) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LAMMPS DEFAULT_MSG + LAMMPS_LIBRARIES LAMMPS_INCLUDE_PATH) \ No newline at end of file diff --git a/cmake/Modules/FindMumps.cmake b/cmake/Modules/FindMumps.cmake new file mode 100644 index 0000000..d5e2293 --- /dev/null +++ b/cmake/Modules/FindMumps.cmake @@ -0,0 +1,112 @@ +#=============================================================================== +# @file FindMumps.cmake +# +# @author Nicolas Richart +# +# @date creation: Mon Dec 13 2010 +# @date last modification: Tue Sep 09 2014 +# +# @brief The find_package file for the Mumps solver +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +#=============================================================================== +if(NOT MUMPS_TYPE) + set(MUMPS_TYPE par) +endif() + +if("${MUMPS_TYPE}" STREQUAL "seq") + set(MUMPS_PREFIX _seq) +else() + unset(MUMPS_PREFIX) +endif() + +find_library(MUMPS_LIBRARY_DMUMPS NAMES dmumps${MUMPS_PREFIX} + HINTS ${MUMPS_DIR} /usr + PATH_SUFFIXES lib + ) + +find_library(MUMPS_LIBRARY_COMMON NAMES mumps_common${MUMPS_PREFIX} + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib + ) + +find_library(MUMPS_LIBRARY_PORD NAMES pord${MUMPS_PREFIX} + HINTS ${MUMPS_DIR} + PATH_SUFFIXES lib + ) + + +find_path(MUMPS_INCLUDE_DIR dmumps_c.h + HINTS ${MUMPS_DIR} + PATH_SUFFIXES include + ) + +mark_as_advanced(MUMPS_LIBRARY_COMMON) +mark_as_advanced(MUMPS_LIBRARY_DMUMPS) +mark_as_advanced(MUMPS_LIBRARY_PORD) +mark_as_advanced(MUMPS_INCLUDE_DIR) +set(MUMPS_LIBRARIES_ALL ${MUMPS_LIBRARY_DMUMPS} ${MUMPS_LIBRARY_COMMON} ${MUMPS_LIBRARY_PORD}) + +if("${MUMPS_TYPE}" STREQUAL "par") + find_library(BLACS_LIBRARY_C NAME blacsC + HINTS ${MUMPS_DIR} PATH_SUFFIXES lib) + find_library(BLACS_LIBRARY_F77 NAME blacsF77 + HINTS ${MUMPS_DIR} PATH_SUFFIXES lib) + find_library(BLACS_LIBRARY NAME blacs + HINTS ${MUMPS_DIR} PATH_SUFFIXES lib) + find_library(SCALAPACK_LIBRARIES NAME scalapack + HINTS ${MUMPS_DIR} PATH_SUFFIXES lib) + + mark_as_advanced(BLACS_LIBRARY_C) + mark_as_advanced(BLACS_LIBRARY_F77) + mark_as_advanced(BLACS_LIBRARY) + mark_as_advanced(SCALAPACK_LIBRARY) + mark_as_advanced(SCALAPACK_LIBRARIES) + if(SCALAPACK_LIBRARY) + set(BLACS_LIBRARIES_ALL ${BLACS_LIBRARIES_ALL} ${SCALAPACK_LIBRARY}) + endif() + if(BLACS_LIBRARY_F77) + set(BLACS_LIBRARIES_ALL ${BLACS_LIBRARIES_ALL} ${BLACS_LIBRARY_F77}) + endif() + if(BLACS_LIBRARY) + set(BLACS_LIBRARIES_ALL ${BLACS_LIBRARIES_ALL} ${BLACS_LIBRARY}) + endif() + if(BLACS_LIBRARY_C) + set(BLACS_LIBRARIES_ALL ${BLACS_LIBRARIES_ALL} ${BLACS_LIBRARY_C}) + endif() + if(BLACS_LIBRARY_F77) + set(BLACS_LIBRARIES_ALL ${BLACS_LIBRARIES_ALL} ${BLACS_LIBRARY_F77}) + endif() +endif() + +set(MUMPS_LIBRARIES ${MUMPS_LIBRARIES_ALL} ${BLACS_LIBRARIES_ALL} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} CACHE INTERNAL "Libraries for MUMPS" FORCE) + + +#=============================================================================== +if(NOT MUMPS_FOUND) + set(MUMPS_DIR "" CACHE PATH "Prefix of MUMPS library.") + mark_as_advanced(MUMPS_DIR) +endif() +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Mumps DEFAULT_MSG + MUMPS_LIBRARIES MUMPS_INCLUDE_DIR) \ No newline at end of file diff --git a/cmake/Modules/FindNLopt.cmake b/cmake/Modules/FindNLopt.cmake new file mode 100644 index 0000000..1855f45 --- /dev/null +++ b/cmake/Modules/FindNLopt.cmake @@ -0,0 +1,54 @@ +#=============================================================================== +# @file FindNLopt.cmake +# +# @author Alejandro M. Aragón +# +# @date creation: Fri Jan 04 2013 +# @date last modification: Thu Jul 24 2014 +# +# @brief The find_package file for NLopt optimization library +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_library(NLOPT_LIBRARIES NAMES nlopt_cxx + PATHS ${NLOPT_DIR} ${NLOPT_INTERNAL_DIR} + PATH_SUFFIXES lib + ) + +find_path(NLOPT_INCLUDE_DIR nlopt.hpp + PATHS ${NLOPT_DIR} ${NLOPT_INTERNAL_DIR} + PATH_SUFFIXES include + ) + + + +#=============================================================================== +mark_as_advanced(NLOPT_LIBRARIES) +mark_as_advanced(NLOPT_INCLUDE_DIR) +#=============================================================================== +if(NOT NLOPT_FOUND) + set(NLOPT_DIR "" CACHE PATH "Location of NLOPT source directory.") +endif() + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(NLopt DEFAULT_MSG NLOPT_LIBRARIES NLOPT_INCLUDE_DIR) + diff --git a/cmake/Modules/FindPETSc.cmake b/cmake/Modules/FindPETSc.cmake new file mode 100644 index 0000000..191a76f --- /dev/null +++ b/cmake/Modules/FindPETSc.cmake @@ -0,0 +1,345 @@ +# - Try to find PETSc +# Once done this will define +# +# PETSC_FOUND - system has PETSc +# PETSC_INCLUDES - the PETSc include directories +# PETSC_LIBRARIES - Link these to use PETSc +# PETSC_COMPILER - Compiler used by PETSc, helpful to find a compatible MPI +# PETSC_DEFINITIONS - Compiler switches for using PETSc +# PETSC_MPIEXEC - Executable for running MPI programs +# PETSC_VERSION - Version string (MAJOR.MINOR.SUBMINOR) +# +# Usage: +# find_package(PETSc COMPONENTS CXX) - required if build --with-clanguage=C++ --with-c-support=0 +# find_package(PETSc COMPONENTS C) - standard behavior of checking build using a C compiler +# find_package(PETSc) - same as above +# +# Setting these changes the behavior of the search +# PETSC_DIR - directory in which PETSc resides +# PETSC_ARCH - build architecture +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + +set(PETSC_VALID_COMPONENTS + C + CXX) + +if(NOT PETSc_FIND_COMPONENTS) + set(PETSC_LANGUAGE_BINDINGS "C") +else() + # Right now, this is designed for compatability with the --with-clanguage option, so + # only allow one item in the components list. + list(LENGTH ${PETSc_FIND_COMPONENTS} components_length) + if(${components_length} GREATER 1) + message(FATAL_ERROR "Only one component for PETSc is allowed to be specified") + endif() + # This is a stub for allowing multiple components should that time ever come. Perhaps + # to also test Fortran bindings? + foreach(component ${PETSc_FIND_COMPONENTS}) + list(FIND PETSC_VALID_COMPONENTS ${component} component_location) + if(${component_location} EQUAL -1) + message(FATAL_ERROR "\"${component}\" is not a valid PETSc component.") + else() + list(APPEND PETSC_LANGUAGE_BINDINGS ${component}) + endif() + endforeach() +endif() + +function (petsc_get_version) + if (EXISTS "${PETSC_DIR}/include/petscversion.h") + file (STRINGS "${PETSC_DIR}/include/petscversion.h" vstrings REGEX "#define PETSC_VERSION_(RELEASE|MAJOR|MINOR|SUBMINOR|PATCH) ") + foreach (line ${vstrings}) + string (REGEX REPLACE " +" ";" fields ${line}) # break line into three fields (the first is always "#define") + list (GET fields 1 var) + list (GET fields 2 val) + set (${var} ${val} PARENT_SCOPE) + set (${var} ${val}) # Also in local scope so we have access below + endforeach () + if (PETSC_VERSION_RELEASE) + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}p${PETSC_VERSION_PATCH}" PARENT_SCOPE) + else () + # make dev version compare higher than any patch level of a released version + set (PETSC_VERSION "${PETSC_VERSION_MAJOR}.${PETSC_VERSION_MINOR}.${PETSC_VERSION_SUBMINOR}.99" PARENT_SCOPE) + endif () + else () + message (SEND_ERROR "PETSC_DIR can not be used, ${PETSC_DIR}/include/petscversion.h does not exist") + endif () +endfunction () + +find_path (PETSC_DIR include/petsc.h + HINTS ENV PETSC_DIR + PATHS + # Debian paths + /usr/lib/petscdir/3.3 /usr/lib/petscdir/3.2 /usr/lib/petscdir/3.1 + /usr/lib/petscdir/3.0.0 /usr/lib/petscdir/2.3.3 /usr/lib/petscdir/2.3.2 + $ENV{HOME}/petsc + DOC "PETSc Directory") + +find_program (MAKE_EXECUTABLE NAMES make gmake) + +if (NOT PETSC_ARCH) + if (NOT ENV{PETSC_ARCH}) + set(_petsc_arches + linux-gnu-c-debug linux-gnu-c-opt # Debian defaults + x86_64-unknown-linux-gnu i386-unknown-linux-gnu) + else() + set(_petsc_arches $ENV{PETSC_ARCH}) # If set, use environment variable first) + endif() +else() + set (_petsc_arches + ${PETSC_ARCH}) +endif() + +if (NOT PETSC_DIR) + if (NOT ENV{PETSC_DIR}) + set(PETSC_DIR /usr/lib/petsc) + else() + set(PETSC_DIR $ENV{PETSC_DIR}) # If set, use environment variable first) + endif() +endif() + +foreach (arch ${_petsc_arches}) + set (petscconf "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) + find_path (petscconf petscconf.h + HINTS ${PETSC_DIR} + PATH_SUFFIXES ${arch}/include bmake/${arch} + NO_DEFAULT_PATH) + + if(petscconf) + set (PETSC_ARCH "${arch}" CACHE STRING "PETSc build architecture") + set(_petsc_dir ${PETSC_DIR}) + set (PETSC_DIR "${_petsc_dir}" CACHE STRING "PETSc build directory") + break() + endif() +endforeach() + +set (petsc_slaves LIBRARIES_SYS LIBRARIES_VEC LIBRARIES_MAT LIBRARIES_DM LIBRARIES_KSP LIBRARIES_SNES LIBRARIES_TS + INCLUDE_DIR INCLUDE_CONF) +include (FindPackageMultipass) +#find_package_multipass (PETSc petsc_config_current +# STATES DIR ARCH +# DEPENDENTS INCLUDES LIBRARIES COMPILER MPIEXEC EXECUTABLE_RUNS ${petsc_slaves}) +# +# Determine whether the PETSc layout is old-style (through 2.3.3) or +# new-style (>= 3.0.0) +if (EXISTS "${PETSC_DIR}/${PETSC_ARCH}/include/petscconf.h") # > 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/conf/rules") + set (petsc_conf_variables "${PETSC_DIR}/conf/variables") +elseif (EXISTS "${PETSC_DIR}/bmake/${PETSC_ARCH}/petscconf.h") # <= 2.3.3 + set (petsc_conf_rules "${PETSC_DIR}/bmake/common/rules") + set (petsc_conf_variables "${PETSC_DIR}/bmake/common/variables") +elseif (PETSC_DIR) + message (SEND_ERROR "The pair PETSC_DIR=${PETSC_DIR} PETSC_ARCH=${PETSC_ARCH} do not specify a valid PETSc installation") +endif () + + +message(petsc_conf_rules ${petsc_conf_rules}) +message(petsc_conf_variables ${petsc_conf_variables}) +message(petsc_config_current ${petsc_config_current}) + + +if (petsc_conf_rules AND petsc_conf_variables AND NOT petsc_config_current) + petsc_get_version() + + # Put variables into environment since they are needed to get + # configuration (petscvariables) in the PETSc makefile + set (ENV{PETSC_DIR} "${PETSC_DIR}") + set (ENV{PETSC_ARCH} "${PETSC_ARCH}") + + # A temporary makefile to probe the PETSc configuration + set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc") + file (WRITE "${petsc_config_makefile}" +"## This file was autogenerated by FindPETSc.cmake +# PETSC_DIR = ${PETSC_DIR} +# PETSC_ARCH = ${PETSC_ARCH} +include ${petsc_conf_rules} +include ${petsc_conf_variables} +show : + -@echo -n \${\${VARIABLE}} +") + + macro (PETSC_GET_VARIABLE name var) + set (${var} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + execute_process (COMMAND ${MAKE_EXECUTABLE} --no-print-directory -f ${petsc_config_makefile} show VARIABLE=${name} + OUTPUT_VARIABLE ${var} + RESULT_VARIABLE petsc_return) + endmacro (PETSC_GET_VARIABLE) + petsc_get_variable (PETSC_LIB_DIR petsc_lib_dir) + petsc_get_variable (PETSC_EXTERNAL_LIB_BASIC petsc_libs_external) + petsc_get_variable (PETSC_CCPPFLAGS petsc_cpp_line) + petsc_get_variable (PETSC_INCLUDE petsc_include) + petsc_get_variable (PCC petsc_cc) + petsc_get_variable (PCC_FLAGS petsc_cc_flags) + petsc_get_variable (MPIEXEC petsc_mpiexec) + # We are done with the temporary Makefile, calling PETSC_GET_VARIABLE after this point is invalid! + file (REMOVE ${petsc_config_makefile}) + + include (ResolveCompilerPaths) + # Extract include paths and libraries from compile command line + resolve_includes (petsc_includes_all "${petsc_cpp_line}") + + #on windows we need to make sure we're linking against the right + #runtime library + if (WIN32) + if (petsc_cc_flags MATCHES "-MT") + set(using_md False) + foreach(flag_var + CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE + CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO + CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE + CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) + if(${flag_var} MATCHES "/MD") + set(using_md True) + endif(${flag_var} MATCHES "/MD") + endforeach(flag_var) + if(${using_md} MATCHES "True") + message(WARNING "PETSc was built with /MT, but /MD is currently set. + See http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F") + endif(${using_md} MATCHES "True") + endif (petsc_cc_flags MATCHES "-MT") + endif (WIN32) + + include (CorrectWindowsPaths) + convert_cygwin_path(petsc_lib_dir) + message (STATUS "petsc_lib_dir ${petsc_lib_dir}") + + macro (PETSC_FIND_LIBRARY suffix name) + set (PETSC_LIBRARY_${suffix} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # Clear any stale value, if we got here, we need to find it again + if (WIN32) + set (libname lib${name}) #windows expects "libfoo", linux expects "foo" + else (WIN32) + set (libname ${name}) + endif (WIN32) + find_library (PETSC_LIBRARY_${suffix} NAMES ${libname} HINTS ${petsc_lib_dir} NO_DEFAULT_PATH) + set (PETSC_LIBRARIES_${suffix} "${PETSC_LIBRARY_${suffix}}") + mark_as_advanced (PETSC_LIBRARY_${suffix}) + endmacro (PETSC_FIND_LIBRARY suffix name) + + # Look for petscvec first, if it doesn't exist, we must be using single-library + petsc_find_library (VEC petscvec) + if (PETSC_LIBRARY_VEC) + petsc_find_library (SYS "petscsys;petsc") # libpetscsys is called libpetsc prior to 3.1 (when single-library was introduced) + petsc_find_library (MAT petscmat) + petsc_find_library (DM petscdm) + petsc_find_library (KSP petscksp) + petsc_find_library (SNES petscsnes) + petsc_find_library (TS petscts) + macro (PETSC_JOIN libs deps) + list (APPEND PETSC_LIBRARIES_${libs} ${PETSC_LIBRARIES_${deps}}) + endmacro (PETSC_JOIN libs deps) + petsc_join (VEC SYS) + petsc_join (MAT VEC) + petsc_join (DM MAT) + petsc_join (KSP DM) + petsc_join (SNES KSP) + petsc_join (TS SNES) + petsc_join (ALL TS) + else () + set (PETSC_LIBRARY_VEC "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) # There is no libpetscvec + petsc_find_library (SINGLE petsc) + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + set (PETSC_LIBRARIES_${pkg} "${PETSC_LIBRARY_SINGLE}") + endforeach () + endif () + if (PETSC_LIBRARY_TS) + message (STATUS "Recognized PETSc install with separate libraries for each package") + else () + message (STATUS "Recognized PETSc install with single library for all packages") + endif () + + include(Check${PETSC_LANGUAGE_BINDINGS}SourceRuns) + macro (PETSC_TEST_RUNS includes libraries runs) + if(${PETSC_LANGUAGE_BINDINGS} STREQUAL "C") + set(_PETSC_ERR_FUNC "CHKERRQ(ierr)") + elseif(${PETSC_LANGUAGE_BINDINGS} STREQUAL "CXX") + set(_PETSC_ERR_FUNC "CHKERRXX(ierr)") + endif() + if (PETSC_VERSION VERSION_GREATER 3.1) + set (_PETSC_TSDestroy "TSDestroy(&ts)") + else () + set (_PETSC_TSDestroy "TSDestroy(ts)") + endif () + + set(_PETSC_TEST_SOURCE " +static const char help[] = \"PETSc test program.\"; +#include +int main(int argc,char *argv[]) { + PetscErrorCode ierr; + TS ts; + + ierr = PetscInitialize(&argc,&argv,0,help);${_PETSC_ERR_FUNC}; + ierr = TSCreate(PETSC_COMM_WORLD,&ts);${_PETSC_ERR_FUNC}; + ierr = TSSetFromOptions(ts);${_PETSC_ERR_FUNC}; + ierr = ${_PETSC_TSDestroy};${_PETSC_ERR_FUNC}; + ierr = PetscFinalize();${_PETSC_ERR_FUNC}; + return 0; +} +") + multipass_source_runs ("${includes}" "${libraries}" "${_PETSC_TEST_SOURCE}" ${runs} "${PETSC_LANGUAGE_BINDINGS}") + + if (${${runs}}) + set (PETSC_EXECUTABLE_RUNS "YES" CACHE BOOL + "Can the system successfully run a PETSc executable? This variable can be manually set to \"YES\" to force CMake to accept a given PETSc configuration, but this will almost always result in a broken build. If you change PETSC_DIR, PETSC_ARCH, or PETSC_CURRENT you would have to reset this variable." FORCE) + endif (${${runs}}) + endmacro (PETSC_TEST_RUNS) + + + find_path (PETSC_INCLUDE_DIR petscts.h HINTS "${PETSC_DIR}" PATH_SUFFIXES include NO_DEFAULT_PATH) + find_path (PETSC_INCLUDE_CONF petscconf.h HINTS "${PETSC_DIR}" PATH_SUFFIXES "${PETSC_ARCH}/include" "bmake/${PETSC_ARCH}" NO_DEFAULT_PATH) + mark_as_advanced (PETSC_INCLUDE_DIR PETSC_INCLUDE_CONF) + set (petsc_includes_minimal ${PETSC_INCLUDE_CONF} ${PETSC_INCLUDE_DIR}) + + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_minimal) + if (petsc_works_minimal) + message (STATUS "Minimal PETSc includes and libraries work. This probably means we are building with shared libs.") + set (petsc_includes_needed "${petsc_includes_minimal}") + else (petsc_works_minimal) # Minimal includes fail, see if just adding full includes fixes it + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_allincludes) + if (petsc_works_allincludes) # It does, we just need all the includes ( + message (STATUS "PETSc requires extra include paths, but links correctly with only interface libraries. This is an unexpected configuration (but it seems to work fine).") + set (petsc_includes_needed ${petsc_includes_all}) + else (petsc_works_allincludes) # We are going to need to link the external libs explicitly + resolve_libraries (petsc_libraries_external "${petsc_libs_external}") + foreach (pkg SYS VEC MAT DM KSP SNES TS ALL) + list (APPEND PETSC_LIBRARIES_${pkg} ${petsc_libraries_external}) + endforeach (pkg) + petsc_test_runs ("${petsc_includes_minimal}" "${PETSC_LIBRARIES_TS}" petsc_works_alllibraries) + if (petsc_works_alllibraries) + message (STATUS "PETSc only need minimal includes, but requires explicit linking to all dependencies. This is expected when PETSc is built with static libraries.") + set (petsc_includes_needed ${petsc_includes_minimal}) + else (petsc_works_alllibraries) + # It looks like we really need everything, should have listened to Matt + set (petsc_includes_needed ${petsc_includes_all}) + petsc_test_runs ("${petsc_includes_all}" "${PETSC_LIBRARIES_TS}" petsc_works_all) + if (petsc_works_all) # We fail anyways + message (STATUS "PETSc requires extra include paths and explicit linking to all dependencies. This probably means you have static libraries and something unexpected in PETSc headers.") + else (petsc_works_all) # We fail anyways + message (STATUS "PETSc could not be used, maybe the install is broken.") + endif (petsc_works_all) + endif (petsc_works_alllibraries) + endif (petsc_works_allincludes) + endif (petsc_works_minimal) + + # We do an out-of-source build so __FILE__ will be an absolute path, hence __INSDIR__ is superfluous + if (${PETSC_VERSION} VERSION_LESS 3.1) + set (PETSC_DEFINITIONS "-D__SDIR__=\"\"" CACHE STRING "PETSc definitions" FORCE) + else () + set (PETSC_DEFINITIONS "-D__INSDIR__=" CACHE STRING "PETSc definitions" FORCE) + endif () + # Sometimes this can be used to assist FindMPI.cmake + set (PETSC_MPIEXEC ${petsc_mpiexec} CACHE FILEPATH "Executable for running PETSc MPI programs" FORCE) + set (PETSC_INCLUDES ${petsc_includes_needed} CACHE STRING "PETSc include path" FORCE) + set (PETSC_LIBRARIES ${PETSC_LIBRARIES_ALL} CACHE STRING "PETSc libraries" FORCE) + set (PETSC_COMPILER ${petsc_cc} CACHE FILEPATH "PETSc compiler" FORCE) + # Note that we have forced values for all these choices. If you + # change these, you are telling the system to trust you that they + # work. It is likely that you will end up with a broken build. + mark_as_advanced (PETSC_INCLUDES PETSC_LIBRARIES PETSC_COMPILER PETSC_DEFINITIONS PETSC_MPIEXEC PETSC_EXECUTABLE_RUNS) +endif () + +include (FindPackageHandleStandardArgs) +find_package_handle_standard_args (PETSc + "PETSc could not be found. Be sure to set PETSC_DIR and PETSC_ARCH." + PETSC_INCLUDES PETSC_LIBRARIES PETSC_EXECUTABLE_RUNS) diff --git a/cmake/Modules/FindPQXX.cmake b/cmake/Modules/FindPQXX.cmake new file mode 100644 index 0000000..f5817f4 --- /dev/null +++ b/cmake/Modules/FindPQXX.cmake @@ -0,0 +1,61 @@ +#=============================================================================== +# @file FindPQXX.cmake +# +# @author Nicolas Richart +# +# @date creation: Fri Jan 13 2012 +# @date last modification: Tue Sep 09 2014 +# +# @brief The find_package file for PostgreSQL C++ library +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_package(PostgreSQL REQUIRED) +if(POSTGRESQL_FOUND) + find_library(PQXX_LIBRARY NAMES pqxx + HINTS ${PQXX_DIR} ENV PQXX_DIR + DOC "Location of libpqxx library" + ) + + find_path(PQXX_HEADER_DIR NAMES pqxx/pqxx + HINTS ${PQXX_DIR} ENV PQXX_DIR + DOC "Path to pqxx/pqxx header file. Do not include the 'pqxx' directory in this value." + ) + + set(PQXX_INCLUDE_DIR "${PQXX_HEADER_DIR};${POSTGRESQL_INCLUDE_DIR}" CACHE STRING "Include directories for PostgreSQL C++ library" FORCE) + set(PQXX_LIBRARIES "${PQXX_LIBRARY};${POSTGRESQL_LIBRARIES}" CACHE STRING "Link libraries for PostgreSQL C++ interface" FORCE) + + mark_as_advanced(PQXX_HEADER_DIR) + mark_as_advanced(PQXX_INCLUDE_DIR) + mark_as_advanced(PQXX_LIBRARY) + mark_as_advanced(PQXX_LIBRARIES) +endif() + +#=============================================================================== +if(NOT PQXX_FOUND) + set(PQXX_DIR "" CACHE PATH "Help to find the location of pqxx library.") + mark_as_advanced(PQXX_FOUND) +endif() + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PQXX DEFAULT_MSG PQXX_LIBRARY PQXX_HEADER_DIR) + diff --git a/cmake/Modules/FindPTScotch.cmake b/cmake/Modules/FindPTScotch.cmake new file mode 100644 index 0000000..0daeffc --- /dev/null +++ b/cmake/Modules/FindPTScotch.cmake @@ -0,0 +1,87 @@ +#=============================================================================== +# @file FindPTScotch.cmake +# +# @author Nicolas Richart +# +# @date creation: Tue Apr 05 2011 +# @date last modification: Fri Jan 04 2013 +# +# @brief The find_package file for PT-Scotch +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +#=============================================================================== +#if(PTSCOTCH_DIR) +# set(PTSCOTCH_LIBRARY "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) +#endif(PTSCOTCH_DIR) + +find_library(PTSCOTCH_LIBRARY ptscotch + PATHS ${PTSCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_library(PTSCOTCH_LIBRARY_ERR ptscotcherr + PATHS ${PTSCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_library(PTSCOTCH_LIBRARY_ESMUMPS ptesmumps + PATHS ${PTSCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_path(PTSCOTCH_INCLUDE_PATH ptscotch.h + PATHS ${PTSCOTCH_DIR} + PATH_SUFFIXES include scotch src/libscotch include/scotch + ) + +#=============================================================================== +mark_as_advanced(PTSCOTCH_LIBRARY) +mark_as_advanced(PTSCOTCH_LIBRARY_ERR) +mark_as_advanced(PTSCOTCH_LIBRARY_ESMUMPS) +mark_as_advanced(PTSCOTCH_INCLUDE_PATH) + +set(PTSCOTCH_LIBRARIES_ALL ${PTSCOTCH_LIBRARY} ${PTSCOTCH_LIBRARY_ERR}) + +if(PTSCOTCH_LIBRARY_ESMUMPS) + set(PTSCOTCH_LIBRARIES_ALL ${PTSCOTCH_LIBRARY_ESMUMPS} ${PTSCOTCH_LIBRARIES_ALL}) +endif() + +set(PTSCOTCH_LIBRARIES ${PTSCOTCH_LIBRARIES_ALL} CACHE INTERNAL "Libraries for PT-Scotch" FORCE) + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PTSCOTCH DEFAULT_MSG + PTSCOTCH_LIBRARY PTSCOTCH_LIBRARY_ERR PTSCOTCH_INCLUDE_PATH) + + +if(PTSCOTCH_INCLUDE_PATH) + file(STRINGS ${PTSCOTCH_INCLUDE_PATH}/scotch.h PTSCOTCH_INCLUDE_CONTENT) + string(REGEX MATCH "_cplusplus" _match ${PTSCOTCH_INCLUDE_CONTENT}) + if(_match) + add_definitions(-DAKANTU_PTSCOTCH_NO_EXTERN) + endif() +endif() + +#=============================================================================== +if(NOT PTSCOTCH_FOUND) + set(PTSCOTCH_DIR "" CACHE PATH "Location of PT-Scotch library.") +endif(NOT PTSCOTCH_FOUND) diff --git a/cmake/Modules/FindPackageMultipass.cmake b/cmake/Modules/FindPackageMultipass.cmake new file mode 100644 index 0000000..fa350a9 --- /dev/null +++ b/cmake/Modules/FindPackageMultipass.cmake @@ -0,0 +1,106 @@ +# PackageMultipass - this module defines two macros +# +# FIND_PACKAGE_MULTIPASS (Name CURRENT +# STATES VAR0 VAR1 ... +# DEPENDENTS DEP0 DEP1 ...) +# +# This function creates a cache entry _CURRENT which +# the user can set to "NO" to trigger a reconfiguration of the package. +# The first time this function is called, the values of +# _VAR0, ... are saved. If _CURRENT +# is false or if any STATE has changed since the last time +# FIND_PACKAGE_MULTIPASS() was called, then CURRENT will be set to "NO", +# otherwise CURRENT will be "YES". IF not CURRENT, then +# _DEP0, ... will be FORCED to NOTFOUND. +# Example: +# find_path (FOO_DIR include/foo.h) +# FIND_PACKAGE_MULTIPASS (Foo foo_current +# STATES DIR +# DEPENDENTS INCLUDES LIBRARIES) +# if (NOT foo_current) +# # Make temporary files, run programs, etc, to determine FOO_INCLUDES and FOO_LIBRARIES +# endif (NOT foo_current) +# +# MULTIPASS_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS LANGUAGE) +# Always runs the given test, use this when you need to re-run tests +# because parent variables have made old cache entries stale. The LANGUAGE +# variable is either C or CXX indicating which compiler the test should +# use. +# MULTIPASS_C_SOURCE_RUNS (Name INCLUDES LIBRARIES SOURCE RUNS) +# DEPRECATED! This is only included for backwards compatability. Use +# the more general MULTIPASS_SOURCE_RUNS instead. +# Always runs the given test, use this when you need to re-run tests +# because parent variables have made old cache entries stale. + +macro (FIND_PACKAGE_MULTIPASS _name _current) + string (TOUPPER ${_name} _NAME) + set (_args ${ARGV}) + list (REMOVE_AT _args 0 1) + + set (_states_current "YES") + list (GET _args 0 _cmd) + if (_cmd STREQUAL "STATES") + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + while (_state AND NOT _state STREQUAL "DEPENDENTS") + # The name of the stored value for the given state + set (_stored_var PACKAGE_MULTIPASS_${_NAME}_${_state}) + if (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (_states_current "NO") + endif (NOT "${${_stored_var}}" STREQUAL "${${_NAME}_${_state}}") + set (${_stored_var} "${${_NAME}_${_state}}" CACHE INTERNAL "Stored state for ${_name}." FORCE) + list (REMOVE_AT _args 0) + list (GET _args 0 _state) + endwhile (_state AND NOT _state STREQUAL "DEPENDENTS") + endif (_cmd STREQUAL "STATES") + + set (_stored ${_NAME}_CURRENT) + if (NOT ${_stored}) + set (${_stored} "YES" CACHE BOOL "Is the configuration for ${_name} current? Set to \"NO\" to reconfigure." FORCE) + set (_states_current "NO") + endif (NOT ${_stored}) + + set (${_current} ${_states_current}) + if (NOT ${_current} AND PACKAGE_MULTIPASS_${_name}_CALLED) + message (STATUS "Clearing ${_name} dependent variables") + # Clear all the dependent variables so that the module can reset them + list (GET _args 0 _cmd) + if (_cmd STREQUAL "DEPENDENTS") + list (REMOVE_AT _args 0) + foreach (dep ${_args}) + set (${_NAME}_${dep} "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endforeach (dep) + endif (_cmd STREQUAL "DEPENDENTS") + set (${_NAME}_FOUND "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) + endif () + set (PACKAGE_MULTIPASS_${name}_CALLED YES CACHE INTERNAL "Private" FORCE) +endmacro (FIND_PACKAGE_MULTIPASS) + + +macro (MULTIPASS_SOURCE_RUNS includes libraries source runs language) + include (Check${language}SourceRuns) + # This is a ridiculous hack. CHECK_${language}_SOURCE_* thinks that if the + # *name* of the return variable doesn't change, then the test does + # not need to be re-run. We keep an internal count which we + # increment to guarantee that every test name is unique. If we've + # gotten here, then the configuration has changed enough that the + # test *needs* to be rerun. + if (NOT MULTIPASS_TEST_COUNT) + set (MULTIPASS_TEST_COUNT 00) + endif (NOT MULTIPASS_TEST_COUNT) + math (EXPR _tmp "${MULTIPASS_TEST_COUNT} + 1") # Why can't I add to a cache variable? + set (MULTIPASS_TEST_COUNT ${_tmp} CACHE INTERNAL "Unique test ID") + set (testname MULTIPASS_TEST_${MULTIPASS_TEST_COUNT}_${runs}) + set (CMAKE_REQUIRED_INCLUDES ${includes}) + set (CMAKE_REQUIRED_LIBRARIES ${libraries}) + if(${language} STREQUAL "C") + check_c_source_runs ("${source}" ${testname}) + elseif(${language} STREQUAL "CXX") + check_cxx_source_runs ("${source}" ${testname}) + endif() + set (${runs} "${${testname}}") +endmacro (MULTIPASS_SOURCE_RUNS) + +macro (MULTIPASS_C_SOURCE_RUNS includes libraries source runs) + multipass_source_runs("${includes}" "${libraries}" "${source}" ${runs} "C") +endmacro (MULTIPASS_C_SOURCE_RUNS) diff --git a/cmake/Modules/FindParaDiS.cmake b/cmake/Modules/FindParaDiS.cmake new file mode 100644 index 0000000..4ffeb0a --- /dev/null +++ b/cmake/Modules/FindParaDiS.cmake @@ -0,0 +1,45 @@ +#=============================================================================== +# @file FindParaDiS.cmake +# +# +# @date creation: Tue Mar 29 2011 +# @date last modification: Fri Jan 04 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_library(PARADIS_LIBRARIES paradis + PATHS ${PARADIS_DIR} + PATH_SUFFIXES bin) + +find_path(PARADIS_INCLUDE_PATH ParadisGen.h + PATHS ${PARADIS_DIR} + PATH_SUFFIXES include +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PARADIS DEFAULT_MSG + PARADIS_LIBRARIES PARADIS_INCLUDE_PATH) + +if (NOT PARADIS_FOUND) + set(PARADIS_DIR "" CACHE PATH "Location of PARADIS library") +endif(NOT PARADIS_FOUND) \ No newline at end of file diff --git a/cmake/Modules/FindPostgreSQL.cmake b/cmake/Modules/FindPostgreSQL.cmake new file mode 100644 index 0000000..7821f67 --- /dev/null +++ b/cmake/Modules/FindPostgreSQL.cmake @@ -0,0 +1,46 @@ +#=============================================================================== +# @file FindPostgreSQL.cmake +# +# @author Nicolas Richart +# +# @date creation: Fri Jan 13 2012 +# @date last modification: Thu Nov 14 2013 +# +# @brief The find_package file for PostgreSQL C library +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_library(POSTGRESQL_LIBRARIES NAMES pq + PATH_SUFFIXES pgsql postgresql + PATH ENV POSTGRESQL_DIR + ) + +find_path(POSTGRESQL_INCLUDE_DIR NAMES libpq-fe.h + PATH_SUFFIXES pgsql postgresql + PATHS ENV POSTGRESQL_DIR + ) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(POSTGRESQL DEFAULT_MSG + POSTGRESQL_LIBRARIES POSTGRESQL_INCLUDE_DIR) + +mark_as_advanced(POSTGRESQL_INCLUDE_DIR) +mark_as_advanced(POSTGRESQL_LIBRARIES) diff --git a/cmake/Modules/FindQVIEW.cmake b/cmake/Modules/FindQVIEW.cmake new file mode 100644 index 0000000..461bd7d --- /dev/null +++ b/cmake/Modules/FindQVIEW.cmake @@ -0,0 +1,50 @@ +#=============================================================================== +# @file FindQVIEW.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date creation: Thu Mar 17 2011 +# @date last modification: Sun Jan 06 2013 +# +# @brief The find_package file for libQVIEW +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_library(QVIEW_LIBRARIES NAME qview + PATHS ${QVIEW_DIR} + PATH_SUFFIXES lib + ) +#=============================================================================== +find_path(QVIEW_INCLUDE_DIR libqview.h + PATHS ${QVIEW_DIR} + PATH_SUFFIXES include src + ) +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(QVIEW DEFAULT_MSG + QVIEW_LIBRARIES QVIEW_INCLUDE_DIR) + +#=============================================================================== +if(NOT QVIEW_FOUND) + set(QVIEW_DIR "" CACHE PATH "Location of QVIEW library.") +endif(NOT QVIEW_FOUND) + diff --git a/cmake/Modules/FindSIMULPACK.cmake b/cmake/Modules/FindSIMULPACK.cmake new file mode 100644 index 0000000..c28e68b --- /dev/null +++ b/cmake/Modules/FindSIMULPACK.cmake @@ -0,0 +1,118 @@ +#=============================================================================== +# @file FindSIMULPACK.cmake +# +# +# @date creation: Thu Mar 17 2011 +# @date last modification: Fri Jan 04 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +find_path(SIMULPACK_INCLUDE_PATH adlib.h + PATHS ${SIMULPACK_DIR} ENV C_INCLUDE_PATH + PATH_SUFFIXES include src adlib adlib-cmake + ) + +SET(USING_SIMULPACK_TEMPERATURE OFF CACHE BOOL "Activation of temperature within SIMULPACK plugin" ) + +SET(SIMULPACK_MATERIALS "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_MECHANICS "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_MESHER3D "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_UTILS "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_FEM "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_LIBMYUTILS "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_SUBDI_COLLAPSE3D "-NOTFOUND" CACHE LIBRARY "" FORCE) +SET(SIMULPACK_MESH_IO "-NOTFOUND" CACHE LIBRARY "" FORCE) + + +FIND_LIBRARY(SIMULPACK_PMECHANICS NAME pmechanics + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_MESHER3D NAME mesher3d + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_MATERIALS NAME materials + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_MECHANICS NAME mechanics + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_FEM NAME fem + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_MYUTILS NAME myutils + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_UTILS NAME utils + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_SUBDI_COLLAPSE3D NAME subdi_collapse3d + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +FIND_LIBRARY(SIMULPACK_MESH_IO NAME mesh_io + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) + +IF (USING_SIMULPACK_TEMPERATURE) +ADD_DEFINITIONS(-DUSING_SIMULPACK_TEMPERATURE) + +FIND_LIBRARY(SIMULPACK_MULTIPHYSICS NAME multiphysics + PATHS ${SIMULPACK_DIR} + PATHS ${SIMULPACK_LIB_PATH} + PATH_SUFFIXES lib + ) +ENDIF (USING_SIMULPACK_TEMPERATURE) + + +set(SIMULPACK_LIBRARIES ${SIMULPACK_MULTIPHYSICS} ${SIMULPACK_MECHANICS} ${SIMULPACK_MESHER3D} ${SIMULPACK_UTILS} ${SIMULPACK_FEM} ${SIMULPACK_MATERIALS} ${SIMULPACK_MYUTILS} ${SIMULPACK_SUBDI_COLLAPSE3D} ${SIMULPACK_PMECHANICS} ${SIMULPACK_MESH_IO}) +SEPARATE_ARGUMENTS(SIMULPACK_LIBRARIES) +#SET(SIMULPACK_INCLUDE_DIR "${SIMULPACK_SRC} ${SIMULPACK_SRC}/utils/include" CACHE STRING "simulpack includes" FORCE) +#SEPARATE_ARGUMENTS(SIMULPACK_INCLUDE_DIR) + +if (NOT SIMULPACK_MECHANICS) + set(SIMULPACK_DIR "" CACHE PATH "Location of SIMULPACK main tree.") + set(SIMULPACK_LIB_PATH "" CACHE PATH "Additional path to search SimulPack libraries" ) +endif(NOT SIMULPACK_MECHANICS) + + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(SIMULPACK DEFAULT_MSG + SIMULPACK_MECHANICS SIMULPACK_MESHER3D SIMULPACK_UTILS SIMULPACK_FEM SIMULPACK_MATERIALS SIMULPACK_MYUTILS SIMULPACK_SUBDI_COLLAPSE3D SIMULPACK_PMECHANICS SIMULPACK_MESH_IO SIMULPACK_INCLUDE_PATH) + diff --git a/cmake/Modules/FindScotch.cmake b/cmake/Modules/FindScotch.cmake new file mode 100644 index 0000000..88a733c --- /dev/null +++ b/cmake/Modules/FindScotch.cmake @@ -0,0 +1,87 @@ +#=============================================================================== +# @file FindScotch.cmake +# +# @author Nicolas Richart +# +# @date creation: Wed Sep 01 2010 +# @date last modification: Tue Sep 09 2014 +# +# @brief The find_package file for Scotch +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +#=============================================================================== +#if(SCOTCH_DIR) +# set(SCOTCH_LIBRARY "NOTFOUND" CACHE INTERNAL "Cleared" FORCE) +#endif(SCOTCH_DIR) + +find_library(SCOTCH_LIBRARY scotch + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_library(SCOTCH_LIBRARY_ERR scotcherr + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_library(SCOTCH_LIBRARY_ERREXIT scotcherrexit + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_library(SCOTCH_LIBRARY_ESMUMPS esmumps + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES src/libscotch lib + ) + +find_path(SCOTCH_INCLUDE_DIR scotch.h + HINTS ${SCOTCH_DIR} + PATH_SUFFIXES include scotch src/libscotch include/scotch + ) + +#=============================================================================== +mark_as_advanced(SCOTCH_LIBRARY) +mark_as_advanced(SCOTCH_LIBRARY_ERR) +mark_as_advanced(SCOTCH_LIBRARY_ERREXIT) +mark_as_advanced(SCOTCH_LIBRARY_ESMUMPS) +mark_as_advanced(SCOTCH_INCLUDE_DIR) + +set(SCOTCH_LIBRARIES_ALL ${SCOTCH_LIBRARY} ${SCOTCH_LIBRARY_ERR}) + +if(SCOTCH_LIBRARY_ESMUMPS) + set(SCOTCH_LIBRARIES_ALL ${SCOTCH_LIBRARY_ESMUMPS} ${SCOTCH_LIBRARIES_ALL}) +endif() + +set(SCOTCH_LIBRARIES ${SCOTCH_LIBRARIES_ALL} CACHE INTERNAL "Libraries for scotch" FORCE) + +#=============================================================================== +if(NOT SCOTCH_FOUND) + set(SCOTCH_DIR "" CACHE PATH "Location of Scotch library.") + mark_as_advanced(SCOTCH_DIR) +endif() + +#=============================================================================== +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Scotch DEFAULT_MSG + SCOTCH_LIBRARY SCOTCH_LIBRARY_ERR SCOTCH_INCLUDE_DIR) + + diff --git a/cmake/Modules/FindSubversion.cmake b/cmake/Modules/FindSubversion.cmake new file mode 100644 index 0000000..39a7ca2 --- /dev/null +++ b/cmake/Modules/FindSubversion.cmake @@ -0,0 +1,89 @@ +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +find_program(Subversion_SVN_EXECUTABLE svn + DOC "subversion command line client") +mark_as_advanced(Subversion_SVN_EXECUTABLE) + +if(Subversion_SVN_EXECUTABLE) + # the subversion commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated, Alex + set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + set(ENV{LC_ALL} C) + + execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} --version + OUTPUT_VARIABLE Subversion_VERSION_SVN + OUTPUT_STRIP_TRAILING_WHITESPACE) + + # restore the previous LC_ALL + set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + + string(REGEX REPLACE "^(.*\n)?svn, version ([.0-9]+).*" + "\\2" Subversion_VERSION_SVN "${Subversion_VERSION_SVN}") + + macro(Subversion_WC_INFO dir prefix) + # the subversion commands should be executed with the C locale, otherwise + # the message (which are parsed) may be translated, Alex + set(_Subversion_SAVED_LC_ALL "$ENV{LC_ALL}") + set(ENV{LC_ALL} C) + + execute_process(COMMAND ${Subversion_SVN_EXECUTABLE} info ${dir} + OUTPUT_VARIABLE ${prefix}_WC_INFO + ERROR_VARIABLE Subversion_svn_info_error + RESULT_VARIABLE Subversion_svn_info_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT ${Subversion_svn_info_result} EQUAL 0) + set(${prefix}_WC_FOUND FALSE) + if(NOT "${ARGV2}" STREQUAL "ERROR_QUIET") + message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} info ${dir}\" failed with output:\n${Subversion_svn_info_error}") + endif(NOT "${ARGV2}" STREQUAL "ERROR_QUIET") + else(NOT ${Subversion_svn_info_result} EQUAL 0) + set(${prefix}_WC_FOUND TRUE) + + string(REGEX REPLACE "^(.*\n)?URL: ([^\n]+).*" + "\\2" ${prefix}_WC_URL "${${prefix}_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Repository Root: ([^\n]+).*" + "\\2" ${prefix}_WC_ROOT "${${prefix}_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Revision: ([^\n]+).*" + "\\2" ${prefix}_WC_REVISION "${${prefix}_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Author: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_AUTHOR "${${prefix}_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Rev: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_REV "${${prefix}_WC_INFO}") + string(REGEX REPLACE "^(.*\n)?Last Changed Date: ([^\n]+).*" + "\\2" ${prefix}_WC_LAST_CHANGED_DATE "${${prefix}_WC_INFO}") + + endif() + + # restore the previous LC_ALL + set(ENV{LC_ALL} ${_Subversion_SAVED_LC_ALL}) + + endmacro() + + macro(Subversion_WC_LOG dir prefix) + # This macro can block if the certificate is not signed: + # svn ask you to accept the certificate and wait for your answer + # This macro requires a svn server network access (Internet most of the time) + # and can also be slow since it access the svn server + execute_process(COMMAND + ${Subversion_SVN_EXECUTABLE} --non-interactive log -r BASE ${dir} + OUTPUT_VARIABLE ${prefix}_LAST_CHANGED_LOG + ERROR_VARIABLE Subversion_svn_log_error + RESULT_VARIABLE Subversion_svn_log_result + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(NOT ${Subversion_svn_log_result} EQUAL 0) + message(SEND_ERROR "Command \"${Subversion_SVN_EXECUTABLE} log -r BASE ${dir}\" failed with output:\n${Subversion_svn_log_error}") + endif() + endmacro() + +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Subversion REQUIRED_VARS Subversion_SVN_EXECUTABLE + VERSION_VAR Subversion_VERSION_SVN ) + +# for compatibility +set(Subversion_FOUND ${SUBVERSION_FOUND}) +set(Subversion_SVN_FOUND ${SUBVERSION_FOUND}) diff --git a/cmake/Modules/PCHgcc.cmake b/cmake/Modules/PCHgcc.cmake new file mode 100644 index 0000000..cc3ccf1 --- /dev/null +++ b/cmake/Modules/PCHgcc.cmake @@ -0,0 +1,84 @@ +#=============================================================================== +# @file PCHgcc.cmake +# +# @author Nicolas Richart +# +# @date creation: Wed Aug 31 2011 +# @date last modification: Sun Jan 06 2013 +# +# @brief +# +# @section LICENSE +# +# Copyright (©) 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# Akantu is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with Akantu. If not, see . +# +#=============================================================================== + +# (ADD_PCH_RULE _header_filename _src_list) +# Version 7/26/2010 4:55pm +# +# use this macro before "add_executable" +# +# _header_filename +# header to make a .gch +# +# _src_list +# the variable name (do not use ${..}) which contains a +# a list of sources (a.cpp b.cpp c.cpp ...) +# This macro will append a header file to it, then this src_list can be used in +# "add_executable..." +# +# +# Now a .gch file should be generated and gcc should use it. +# (add -Winvalid-pch to the cpp flags to verify) +# +# make clean should delete the pch file +# +# example : ADD_PCH_RULE(headers.h myprog_SRCS) + + +function(ADD_PCH_RULE _header_filename _src_list) + set(_gch_filename "${CMAKE_CURRENT_BINARY_DIR}/${_header_filename}.gch") + + list(APPEND ${_src_list} ${_gch_filename}) + + set(_args ${CMAKE_CXX_FLAGS} -D__aka_inline__=inline) + + get_filename_component(_gch_filename_path ${_gch_filename} PATH) + file(MAKE_DIRECTORY ${_gch_filename_path}) + + # list(APPEND _args -c ${CMAKE_CURRENT_SOURCE_DIR}/${_header_filename}) + list(APPEND _args -c ${CMAKE_CURRENT_SOURCE_DIR}/${_header_filename} -o ${_gch_filename} -Winvalid-pch) + + get_directory_property(DIRINC INCLUDE_DIRECTORIES) + foreach (_inc ${DIRINC}) + list(APPEND _args "-I" ${_inc}) + endforeach(_inc ${DIRINC}) + separate_arguments(_args) + + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${_header_filename} PROPERTIES GENERATED 1) + set_source_files_properties(${_gch_filename} PROPERTIES GENERATED 1) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_header_filename} + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${_header_filename} ${CMAKE_CURRENT_BINARY_DIR}/${_header_filename} # ensure same directory! Required by gcc + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_header_filename} + ) + + add_custom_command(OUTPUT ${_gch_filename} + COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} ${_args} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_header_filename} + ) +endfunction(ADD_PCH_RULE _header_filename _src_list) diff --git a/cmake/Modules/ResolveCompilerPaths.cmake b/cmake/Modules/ResolveCompilerPaths.cmake new file mode 100644 index 0000000..644a738 --- /dev/null +++ b/cmake/Modules/ResolveCompilerPaths.cmake @@ -0,0 +1,105 @@ +# ResolveCompilerPaths - this module defines two macros +# +# RESOLVE_LIBRARIES (XXX_LIBRARIES LINK_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compiler link line and resolves all libraries +# (-lfoo) using the library path contexts (-L/path) in scope. +# The result in XXX_LIBRARIES is the list of fully resolved libs. +# Example: +# +# RESOLVE_LIBRARIES (FOO_LIBRARIES "-L/A -la -L/B -lb -lc -ld") +# +# will be resolved to +# +# FOO_LIBRARIES:STRING="/A/liba.so;/B/libb.so;/A/libc.so;/usr/lib/libd.so" +# +# if the filesystem looks like +# +# /A: liba.so libc.so +# /B: liba.so libb.so +# /usr/lib: liba.so libb.so libc.so libd.so +# +# and /usr/lib is a system directory. +# +# Note: If RESOLVE_LIBRARIES() resolves a link line differently from +# the native linker, there is a bug in this macro (please report it). +# +# RESOLVE_INCLUDES (XXX_INCLUDES INCLUDE_LINE) +# This macro is intended to be used by FindXXX.cmake modules. +# It parses a compile line and resolves all includes +# (-I/path/to/include) to a list of directories. Other flags are ignored. +# Example: +# +# RESOLVE_INCLUDES (FOO_INCLUDES "-I/A -DBAR='\"irrelevant -I/string here\"' -I/B") +# +# will be resolved to +# +# FOO_INCLUDES:STRING="/A;/B" +# +# assuming both directories exist. +# Note: as currently implemented, the -I/string will be picked up mistakenly (cry, cry) +include (CorrectWindowsPaths) + +macro (RESOLVE_LIBRARIES LIBS LINK_LINE) + string (REGEX MATCHALL "((-L|-l|-Wl)([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))" _all_tokens "${LINK_LINE}") + set (_libs_found) + set (_directory_list) + foreach (token ${_all_tokens}) + if (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + # If it's a library path, add it to the list + string (REGEX REPLACE "^-L" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + convert_cygwin_path(token) + list (APPEND _directory_list ${token}) + elseif (token MATCHES "^(-l([^\" ]+|\"[^\"]+\")|[^\" ]+\\.(a|so|dll|lib))") + # It's a library, resolve the path by looking in the list and then (by default) in system directories + if (WIN32) #windows expects "libfoo", linux expects "foo" + string (REGEX REPLACE "^-l" "lib" token ${token}) + else (WIN32) + string (REGEX REPLACE "^-l" "" token ${token}) + endif (WIN32) + set (_root) + if (token MATCHES "^/") # We have an absolute path + #separate into a path and a library name: + string (REGEX MATCH "[^/]*\\.(a|so|dll|lib)$" libname ${token}) + string (REGEX MATCH ".*[^${libname}$]" libpath ${token}) + convert_cygwin_path(libpath) + set (_directory_list ${_directory_list} ${libpath}) + set (token ${libname}) + endif (token MATCHES "^/") + set (_lib "NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library (_lib ${token} HINTS ${_directory_list} ${_root}) + if (_lib) + string (REPLACE "//" "/" _lib ${_lib}) + list (APPEND _libs_found ${_lib}) + else (_lib) + message (STATUS "Unable to find library ${token}") + endif (_lib) + endif (token MATCHES "-L([^\" ]+|\"[^\"]+\")") + endforeach (token) + set (_lib "NOTFOUND" CACHE INTERNAL "Scratch variable" FORCE) + # only the LAST occurence of each library is required since there should be no circular dependencies + if (_libs_found) + list (REVERSE _libs_found) + list (REMOVE_DUPLICATES _libs_found) + list (REVERSE _libs_found) + endif (_libs_found) + set (${LIBS} "${_libs_found}") +endmacro (RESOLVE_LIBRARIES) + +macro (RESOLVE_INCLUDES INCS COMPILE_LINE) + string (REGEX MATCHALL "-I([^\" ]+|\"[^\"]+\")" _all_tokens "${COMPILE_LINE}") + set (_incs_found) + foreach (token ${_all_tokens}) + string (REGEX REPLACE "^-I" "" token ${token}) + string (REGEX REPLACE "//" "/" token ${token}) + convert_cygwin_path(token) + if (EXISTS ${token}) + list (APPEND _incs_found ${token}) + else (EXISTS ${token}) + message (STATUS "Include directory ${token} does not exist") + endif (EXISTS ${token}) + endforeach (token) + list (REMOVE_DUPLICATES _incs_found) + set (${INCS} "${_incs_found}") +endmacro (RESOLVE_INCLUDES) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt new file mode 100644 index 0000000..5511895 --- /dev/null +++ b/doc/CMakeLists.txt @@ -0,0 +1,47 @@ +#=============================================================================== +# @file CMakeLists.txt +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Jul 28 12:20:03 2014 +# +# @brief Principal CMamke for the documentation +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +find_package(Doxygen REQUIRED) + +SET(LIBMULTISCALE_BUILD_DOXYGEN FALSE CACHE BOOL "Request build of doxygen of LibMultiScale sources" ) + +if(DOXYGEN_FOUND AND LIBMULTISCALE_BUILD_DOXYGEN) + set(DOXYGEN_WARNINGS NO) + set(DOXYGEN_QUIET "YES" CACHE STRING "switch to make doxygen quiet or not") + mark_as_advanced(DOXYGEN_QUIET) + if(CMAKE_VERBOSE_MAKEFILE) + set(DOXYGEN_WARNINGS YES) + set(DOXYGEN_QUIET "NO" CACHE STRING "switch to make doxygen quiet or not" FORCE) + endif(CMAKE_VERBOSE_MAKEFILE) + add_subdirectory(doxygen) +endif() + +add_subdirectory(manual) + diff --git a/doc/doxygen/CMakeLists.txt b/doc/doxygen/CMakeLists.txt new file mode 100644 index 0000000..6339a14 --- /dev/null +++ b/doc/doxygen/CMakeLists.txt @@ -0,0 +1,73 @@ +#Copyright EPFL +# +#author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net) +# +#The LibMultiScale is a C++ parallel framework for the multiscale +#coupling methods dedicated to material simulations. This framework +#provides an API which makes it possible to program coupled simulations +#and integration of already existing codes. +# +#This Project is done in a collaboration between +#EPFL within ENAC-LSMS (http://lsms.epfl.ch/) and +#INRIA Bordeaux, ScAlApplix (http://www.labri.fr/projet/scalapplix/). +# +#This software is governed by the CeCILL-C license under French law and +#abiding by the rules of distribution of free software. You can use, +#modify and/ or redistribute the software under the terms of the CeCILL-C +#license as circulated by CEA, CNRS and INRIA at the following URL +#"http://www.cecill.info". +# +#As a counterpart to the access to the source code and rights to copy, +#modify and redistribute granted by the license, users are provided only +#with a limited warranty and the software's author, the holder of the +#economic rights, and the successive licensors have only limited +#liability. +# +#In this respect, the user's attention is drawn to the risks associated +#with loading, using, modifying and/or developing or reproducing the +#software by the user in light of its specific status of free software, +#that may mean that it is complicated to manipulate, and that also +#therefore means that it is reserved for developers and experienced +#professionals having in-depth computer knowledge. Users are therefore +#encouraged to load and test the software's suitability as regards their +#requirements in conditions enabling the security of their systems and/or +#data to be ensured and, more generally, to use and operate it in the +#same conditions as regards security. +# +#The fact that you are presently reading this means that you have had +#knowledge of the CeCILL-C license and that you accept its terms. + + +set(DOXYGEN_INPUT ${CMAKE_CURRENT_BINARY_DIR}/libmultiscale.dox) +set(DOXYGEN_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/html) +set(DOXYGEN_OUTPUT ${DOXYGEN_OUTPUT_DIR}/index.html) + +foreach(_file ${LIBMULTISCALE_DEPEND_FILES}) + list(APPEND LIBMULTISCALE_DOXYGEN_SOURCE_DIRS ${_file}) +endforeach() + +list(APPEND LIBMULTISCALE_DOXYGEN_SOURCE_DIRS ${PROJECT_BINARY_DIR}/src/) +string(REGEX REPLACE ";" " " LIBMULTISCALE_DOXYGEN_SOURCE_DIRS "${LIBMULTISCALE_DOXYGEN_SOURCE_DIRS}") +string(REGEX REPLACE ":" " " LIBMULTISCALE_DOXYGEN_DEFINTIONS "${LIBMULTISCALE_DEFINITIONS}") + +make_directory(${DOXYGEN_OUTPUT_DIR}) +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libmultiscale.dox.cmake + ${CMAKE_CURRENT_BINARY_DIR}/libmultiscale.dox) + +add_custom_command( + OUTPUT ${DOXYGEN_OUTPUT} + COMMAND ${CMAKE_COMMAND} -E echo "${DOXYGEN_EXECUTABLE} ${DOXYGEN_INPUT}" + COMMAND ${CMAKE_COMMAND} -E echo_append "Building libmultiscale Documentation..." + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_INPUT} + COMMAND ${CMAKE_COMMAND} -E echo "Done." + DEPENDS ${DOXYGEN_INPUT} + ) + +add_custom_target(libmultiscale-doc-doxygen ALL DEPENDS ${DOXYGEN_OUTPUT}) + +add_custom_target(libmultiscale-doc-doxygen-forced + COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_INPUT} + ) + +install(DIRECTORY ${DOXYGEN_OUTPUT_DIR} + DESTINATION share/libmultiscale-${libmultiscale_VERSION}/doc) diff --git a/doc/doxygen/libmultiscale.dox.cmake b/doc/doxygen/libmultiscale.dox.cmake new file mode 100644 index 0000000..32a276c --- /dev/null +++ b/doc/doxygen/libmultiscale.dox.cmake @@ -0,0 +1,94 @@ +#=============================================================================== +# @file libmultiscale.dox.cmake +# +# @author Guillaume Anciaux +# +# @date Tue Apr 23 11:03:14 2013 +# +# @brief Doxygen file for LibMultiScale +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +DOXYFILE_ENCODING = UTF-8 +PROJECT_NAME = @CMAKE_PROJECT_NAME@ +PROJECT_NUMBER = @LIBMULTISCALE_VERSION@ +OUTPUT_DIRECTORY = . +OUTPUT_LANGUAGE = English +RECURSIVE = NO +FULL_PATH_NAMES = YES +STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@ +STRIP_FROM_INC_PATH = @CMAKE_SOURCE_DIR@ +TAB_SIZE = 4 +BUILTIN_STL_SUPPORT = NO +EXTRACT_ALL = YES +EXTRACT_PRIVATE = YES + +#--------------------------------------------------------------------------- +# configuration options related to warning and progress messages +#--------------------------------------------------------------------------- + +QUIET = @DOXYGEN_QUIET@ +WARNINGS = @DOXYGEN_WARNINGS@ +WARN_IF_UNDOCUMENTED = @DOXYGEN_WARNINGS@ +WARN_IF_DOC_ERROR = @DOXYGEN_WARNINGS@ + +#--------------------------------------------------------------------------- +# configuration options related to the input files +#--------------------------------------------------------------------------- + +INPUT = @LIBMULTISCALE_DOXYGEN_SOURCE_DIRS@ + +#--------------------------------------------------------------------------- +# configuration options related to source browsing +#--------------------------------------------------------------------------- + +SOURCE_BROWSER = YES +INLINE_SOURCES = NO + +#--------------------------------------------------------------------------- +# Configuration options related to the preprocessor +#--------------------------------------------------------------------------- + +ENABLE_PREPROCESSING = YES +MACRO_EXPANSION = YES +EXPAND_ONLY_PREDEF = NO +SEARCH_INCLUDES = YES +INCLUDE_FILE_PATTERNS = *.hh +PREDEFINED = @LIBMULTISCALE_DOXYGEN_DEFINTIONS@ +SKIP_FUNCTION_MACROS = YES + +#--------------------------------------------------------------------------- +# Configuration options related to the dot tool +#--------------------------------------------------------------------------- + +CLASS_DIAGRAMS = YES +HAVE_DOT = YES +CLASS_GRAPH = YES +COLLABORATION_GRAPH = YES +TEMPLATE_RELATIONS = YES +CALL_GRAPH = YES +CALLER_GRAPH = YES +INCLUDE_GRAPH = YES +DOT_PATH = @DOXYGEN_DOT_PATH@ diff --git a/doc/manual/CMakeLists.txt b/doc/manual/CMakeLists.txt new file mode 100644 index 0000000..1b8534a --- /dev/null +++ b/doc/manual/CMakeLists.txt @@ -0,0 +1,156 @@ +#Copyright EPFL +# +#author : Guillaume ANCIAUX (guillaume.anciaux@epfl.ch, g.anciaux@laposte.net) +# +#The LibMultiScale is a C++ parallel framework for the multiscale +#coupling methods dedicated to material simulations. This framework +#provides an API which makes it possible to program coupled simulations +#and integration of already existing codes. +# +#This Project is done in a collaboration between +#EPFL within ENAC-LSMS (http://lsms.epfl.ch/) and +#INRIA Bordeaux, ScAlApplix (http://www.labri.fr/projet/scalapplix/). +# +#This software is governed by the CeCILL-C license under French law and +#abiding by the rules of distribution of free software. You can use, +#modify and/ or redistribute the software under the terms of the CeCILL-C +#license as circulated by CEA, CNRS and INRIA at the following URL +#"http://www.cecill.info". +# +#As a counterpart to the access to the source code and rights to copy, +#modify and redistribute granted by the license, users are provided only +#with a limited warranty and the software's author, the holder of the +#economic rights, and the successive licensors have only limited +#liability. +# +#In this respect, the user's attention is drawn to the risks associated +#with loading, using, modifying and/or developing or reproducing the +#software by the user in light of its specific status of free software, +#that may mean that it is complicated to manipulate, and that also +#therefore means that it is reserved for developers and experienced +#professionals having in-depth computer knowledge. Users are therefore +#encouraged to load and test the software's suitability as regards their +#requirements in conditions enabling the security of their systems and/or +#data to be ensured and, more generally, to use and operate it in the +#same conditions as regards security. +# +#The fact that you are presently reading this means that you have had +#knowledge of the CeCILL-C license and that you accept its terms. + +set(Boost_USE_MULTITHREADED OFF) +find_package(Boost COMPONENTS filesystem system regex REQUIRED) + +SET(parser_doc_SRC +libmultiscale_doc_parser.cc +generate_latex.cc +main.cc +) + +if(Boost_FOUND) + include_directories(${Boost_INCLUDE_DIRS}) + ADD_EXECUTABLE(parser_doc ${parser_doc_SRC}) + TARGET_LINK_LIBRARIES(parser_doc ${Boost_LIBRARIES}) +endif() + +find_package(Inkscape REQUIRED) +if (NOT INKSCAPE_FOUND) + message(FATAL_ERROR "Documentation cannot be built without Inkscape installed") +endif() +mark_as_advanced(INKSCAPE CONVERT) + + +find_program(rubber "rubber") +mark_as_advanced(rubber) + +if(NOT rubber) + message(FATAL_ERROR "Documentation cannot be built without rubber installed") +endif() + +find_program(latex2html "latex2html") +mark_as_advanced(latex2html) +if(NOT latex2html) + message(FATAL_ERROR "Documentation cannot be built without latex2html installed") +endif() + + +set(file_list_source_files "${CMAKE_CURRENT_BINARY_DIR}/list_source_files") +file(WRITE "${file_list_source_files}" "") + +foreach(_file ${LIBMULTISCALE_DEPEND_FILES}) + file(APPEND "${file_list_source_files}" + "${_file} +") +endforeach() + +include_directories(${PROJECT_BINARY_DIR}/src/) + +set(MANUAL_HTML_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/manual_html) +set(MANUAL_HTML_OUTPUT ${MANUAL_HTML_OUTPUT_DIR}/manual_html.html) +set(MANUAL_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/manual.pdf) +set(GENERATED_TEX ${CMAKE_CURRENT_BINARY_DIR}/manual-generated.tex) + +set(LATEX_SOURCE ${CMAKE_CURRENT_BINARY_DIR}/latex) + +file(GLOB list_images + "${CMAKE_CURRENT_SOURCE_DIR}/images/*.svg" + "${CMAKE_CURRENT_SOURCE_DIR}/images/*.png" + "${CMAKE_CURRENT_SOURCE_DIR}/images/*.jpg" +) + +file(GLOB list_tex + "${CMAKE_CURRENT_SOURCE_DIR}/*.tex" + "${CMAKE_CURRENT_SOURCE_DIR}/*.cls" + "${CMAKE_CURRENT_SOURCE_DIR}/*.sty" +) + +file(COPY + ${list_tex} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR} +) +file(COPY + ${list_images} + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/images/ +) + +file(GLOB list_svgs "${CMAKE_CURRENT_BINARY_DIR}/images/*.svg") +foreach(pic ${list_svgs}) + get_filename_component(path ${pic} PATH) + get_filename_component(name ${pic} NAME_WE) + list(APPEND list_pngs ${path}/${name}.png) +endforeach() + +inkscape_generate_png_from_svg(${list_svgs}) + +add_custom_command( + OUTPUT ${GENERATED_TEX} + COMMAND ./parser_doc ${file_list_source_files} + DEPENDS parser_doc ${LIBMULTISCALE_DEPEND_FILES} ${list_pngs} + ) + +add_custom_target(libmultiscale-doc-tex DEPENDS ${GENERATED_TEX}) + +add_custom_command( + OUTPUT ${MANUAL_OUTPUT} + COMMAND cp ${list_tex} ${CMAKE_CURRENT_BINARY_DIR}/ + COMMAND rm -f manual.out + COMMAND rm -f manual.aux + COMMAND ${rubber} -d manual + DEPENDS libmultiscale-doc-tex ${GENERATED_TEX} ${LIBMULTISCALE_DEPEND_FILES} ${list_images} manual.tex syntax.tex chapters.tex + ) + +add_custom_command( + OUTPUT ${MANUAL_HTML_OUTPUT} + COMMAND cp ${list_tex} ${CMAKE_CURRENT_BINARY_DIR}/ + COMMAND rm -fr manual_html + COMMAND ${rubber} -d manual_html.tex + COMMAND ${latex2html} manual_html.tex 2>&1 > /dev/null | grep -v "No implementation found for" + COMMAND rm manual_html.pdf + DEPENDS libmultiscale-doc-tex ${GENERATED_TEX} ${list_images} ${LIBMULTISCALE_DEPEND_FILES} manual_html.tex syntax.tex chapters.tex + ) + +add_custom_target(libmultiscale-doc-pdf ALL DEPENDS ${MANUAL_OUTPUT}) +add_custom_target(libmultiscale-doc-html ALL DEPENDS ${MANUAL_HTML_OUTPUT}) + + +install(DIRECTORY ${MANUAL_OUTPUT_DIR} + DESTINATION share/libmultiscale-${libmultiscale_VERSION}/doc) diff --git a/doc/manual/chapters.tex b/doc/manual/chapters.tex new file mode 100644 index 0000000..f899ea7 --- /dev/null +++ b/doc/manual/chapters.tex @@ -0,0 +1,190 @@ +\chapter{Getting started} +\section{Getting \libmultiscale} + +The \libmultiscale source code can be requested using the form accessible at the URL +\url{http://lsms.epfl.ch/libmultiscale}. There, you will be asked to accept the +CECILL-C license terms (\url{http://www.cecill.info/licences/Licence_CeCILL-C_V1-en.html}) + +\section{Compiling \libmultiscale} + +\libmultiscale is a \code{cmake} project, so to configure it you can either follow the usual way: +\begin{command} + > cd libmultiscale + > mkdir build + > cd build + > ccmake + [ Set the options that you need ] + > make + > make install +\end{command} + +\chapter{Configuration files} +\section{Parser syntax} + +\subsection{Sections} +Configuration files are divided in sections which admit the syntax +\begin{lmconfig} +Section NAME UNITS + ... +endSection +\end{lmconfig} +The user can place commands in the section with the simple structure +\begin{lmconfig} +Section NAME UNITS + ... + KEYWORD arg1 arg2 ... + ... +endSection +\end{lmconfig} +where units can be +\begin{itemize} +\item RealUnits: SI units \\ \\ + length = meters \\ + mass = kilograms \\ + energy = Joule \\ + time = seconds \\ + temperature = Kelvins +\item AtomsUnits \\ \\ + length = angstroms \\ + mass = grams per mol \\ + energy = kilo calory per mol \\ + time = femto seconds \\ + temperature = Kelvins +\item MetalUnits \\ \\ + length = angstroms \\ + mass = grams per mol \\ + energy = eV \\ + time = pico seconds \\ + temperature = Kelvins +\end{itemize} +The unit system specify, for all values in the described section, +in what units are expressed the numerical values. + + +The parser allows multiline arguments or block reported arguments such as +the examples below +\begin{lmconfig} +Section NAME UNITS + ... + KEYWORD arg1 \ + arg2 \ + arg3 + ... + KEYWORD arg1 BLOCK_PARAMS section2 + +endSection + +#second section called by the BLOCK_PARAM +Section section2 UNITS + arg1 arg2 + arg3 + arg4 +endSection +\end{lmconfig} + +\subsection{Variables} +Variables can be defined using the LET command +\begin{lmconfig} +LET varname = cos(pi/2) +\end{lmconfig} +As you can see an algebraic parser is included and allows to +compute values within scripts and benefit from common unary functions. +all variable names can be recalled within arguments like +\begin{lmconfig} +Section NAME UNITS + ... + LET varname = cos(pi/2) + KEYWORD varname + ... +endSection +\end{lmconfig} +The user can also construct variable names with other variables using +the \verb&${}& dereferencing operator +\begin{lmconfig} +Section NAME UNITS + ... + LET ANGLE = pi/2 + LET cos\${ANGLE} = cos(ANGLE) + KEYWORD cos\${ANGLE} arg2 arg3 + PRINT cos\${ANGLE} + ... +endSection +\end{lmconfig} +Environment variables can also be defined and used using \verb&$()& operator +\begin{lmconfig} +Section NAME UNITS + ... + LET ANGLE = \$(myangle) + LET cos\${ANGLE} = cos(ANGLE) + KEYWORD cos\${ANGLE} arg2 arg3 + PRINT cos\${ANGLE} + ... +endSection +In the example, \verb&myangle& must be defined in the environment context. +\end{lmconfig} + +\subsection{Control blocks} +It is possible to use loops within the configuration files. +The iteration is done following the syntax +\begin{lmconfig} +FOR k in a b c + LET name = k +endFOR +\end{lmconfig} +or to explore a range of numerical values +\begin{lmconfig} +LET index = 0 +FOR k in range start end increment + LET index = index + k +endFOR +\end{lmconfig} + +\section{General keywords} + +A \libmultiscale configuration file needs a \verb$MultiScale$ section. It is the entry +point for all configuration files. + +\begin{lmconfig} +Section MultiScale Units + ... +endSection +\end{lmconfig} + +First of all, the \verb$MultiScale$ section should start by defining what +is the unit system used {\bf internally} by the code. It can differ +from the unit system of the section since the \libmultiscale parser +will handle the conversion for the user. +Secondly, the dimension of the space that is going to be simulated +needs to be given. For instance, these two things can be provided like + +\begin{lmconfig} +Section MultiScale RealUnits + ... + UNITCODE AtomsUnits + DIMENSION 3 + ... +endSection +\end{lmconfig} + +Then you can construct some objects between three kinds + +\begin{itemize} +\item MODELS: It is the storage of degrees of freedom and can be of nature: + \hyperref[section:md]{Molecular Dynamics}, + \hyperref[section:continuum]{Continuum Mechanics-Finite Element} or + \hyperref[section:dd]{Dislocation dynamics}. +\item \hyperref[section:dumper]{DUMPER}: action that generate output files of various forms. +\item \hyperref[section:stimulator]{STIMULATOR}: action that alter a set of degrees of freedom, for instance to impose thermostats or initial conditions. +\item \hyperref[section:filter]{FILTER}: special container which select a subset of another container based on varisous criteria +\item \hyperref[section:filter]{COMPUTE}: special container which contains real value from dedicated + operations. +\item \hyperref[section:coupler]{COUPLER}: request creation of a coupler +\end{itemize} + +In general these object are created following the syntax +\begin{lmconfig} + FAMILY nameID TYPE INPUT input KEY1 param1 KEY2 +\end{lmconfig} +And a full description is provided in the lexicon presented in chapter \ref{chapter:lexicon}. + + diff --git a/doc/manual/generate_latex.cc b/doc/manual/generate_latex.cc new file mode 100644 index 0000000..97adae3 --- /dev/null +++ b/doc/manual/generate_latex.cc @@ -0,0 +1,402 @@ +/** + * @file generate_latex.cc + * + * @author Guillaume Anciaux + * + * @date Thu Oct 24 12:01:19 2013 + * + * @brief Manual generator + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +/* -------------------------------------------------------------------------- */ +#include +#include +#include +#include +#include "generate_latex.hh" +#include +/* -------------------------------------------------------------------------- */ + +GenerateLatex::GenerateLatex(){} +/* -------------------------------------------------------------------------- */ + + +GenerateLatex::~GenerateLatex(){} +/* -------------------------------------------------------------------------- */ + +std::string makeTypeString(const LMDocData & doc){ + + // std::cerr << "doing " << doc.c_type << std::endl; + boost::smatch what; + + const boost::regex my_filter_quantity_plus_brackets("Quantity<([^,]+),?(.*)>\\[(.*)\\]"); + bool res = boost::regex_match(doc.c_type,what,my_filter_quantity_plus_brackets); + + if (res){ + std::cerr << doc.filename.native() << ":0:Error the type " + << doc.c_type << " is invalid" << std::endl; + exit(EXIT_FAILURE); + } + + const boost::regex my_filter_quantity("Quantity<([^,]+),([^,]+)>"); + res = boost::regex_match(doc.c_type,what,my_filter_quantity); + + if (res) { + // std::cerr << "AAAAAAA"; + const boost::regex my_filter2("Keyword\\s\\[(.*)\\]"); + boost::smatch what2; + res = boost::regex_match(doc.type,what2,my_filter2); + if (!res) return doc.c_type; + + // std::cerr << "AAAAAAA " + doc.type << std::endl; + std::string ret = what2.str(1); + if (what.str(2) != "") ret += " x "; + ret += what.str(1); + return ret; + } + + const boost::regex my_filter_single_quantity("Quantity<(.*)>"); + res = boost::regex_match(doc.c_type,what,my_filter_single_quantity); + if (res) { + // std::cerr << "BBBBBBBBB"; + return what.str(1); + } + + const boost::regex my_filter_brackets("(.*)\\[(.*)\\]"); + res = boost::regex_match(doc.c_type,what,my_filter_brackets); + if (res) { + // std::cerr << "CCCCCCCC"; + const boost::regex my_filter2("Keyword\\s\\[(.*)\\]"); + boost::smatch what2; + res = boost::regex_match(doc.type,what2,my_filter2); + if (!res) return doc.c_type; + + std::string ret = what2.str(1); + if (what.str(2) != "") ret += " x "; + ret += what.str(1); + return ret; + } + + return doc.c_type; +} + +/* -------------------------------------------------------------------------- */ + +std::string removeUnderscore(const std::string & str){ + + const boost::regex my_filter("\\\\_"); + + std::string copy_str = + boost::regex_replace(str,my_filter,"", + boost::match_default | boost::format_all); + + return copy_str; +} + +/* -------------------------------------------------------------------------- */ + + +std::string getSubPath(const boost::filesystem::path & file){ + + boost::filesystem::path::iterator end = file.end(); + boost::filesystem::path::iterator begin = file.begin(); + + for (; end != begin ; --end) { + if (end->native() == "src"){ + break; + } + } + if (end == file.end()){ + std::cerr << "problem in the file structure" << std::endl; + exit(EXIT_FAILURE); + } + + begin = end; + end = file.end(); + + boost::filesystem::path p; + + for (; begin != end ; ++begin) { + p /= *begin; + } + return protectString(p.native()); +} +/* -------------------------------------------------------------------------- */ + +std::string getMainSection(const boost::filesystem::path & file){ + + boost::filesystem::path::iterator end = file.end(); + boost::filesystem::path::iterator begin = file.begin(); + + for (; end != begin ; --end) { + if (end->native() == "src"){ + break; + } + } + if (end == file.end()){ + std::cerr << "problem in the file structure" << std::endl; + exit(EXIT_FAILURE); + } + ++end; + return end->native(); +} +/* -------------------------------------------------------------------------- */ +void makeLatexFunction(std::ofstream & fout,const std::string & func_name, + const std::vector & params){ + + fout << "\\" << func_name; + for (UInt i = 0; i < params.size(); ++i) { + fout << "{" << params[i] << "}"; + } + fout << std::endl << std::endl; +} +/* -------------------------------------------------------------------------- */ +void generateSyntax(std::ofstream & fout,const LMDocData & doc){ + std::string func_name = removeUnderscore(std::string("syntax") + getMainSection(doc.filename)); + + std::vector params; + params.push_back(doc.name); + makeLatexFunction(fout,func_name,params); +} +/* -------------------------------------------------------------------------- */ +void GenerateLatex::generateLatexCall(std::ofstream & fout, + const std::string & func) { + + std::vector params; + makeLatexFunction(fout,func,params); +} + +/* -------------------------------------------------------------------------- */ +void GenerateLatex::generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1) { + + std::vector params; + params.push_back(arg1); + makeLatexFunction(fout,func,params); +} + +/* -------------------------------------------------------------------------- */ + +void GenerateLatex::generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1, + const std::string & arg2) { + + std::vector params; + params.push_back(arg1); + params.push_back(arg2); + makeLatexFunction(fout,func,params); +} + +/* -------------------------------------------------------------------------- */ + +void GenerateLatex::generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1, + const std::string & arg2, + const std::string & arg3) { + + std::vector params; + params.push_back(arg1); + params.push_back(arg2); + params.push_back(arg3); + makeLatexFunction(fout,func,params); +} + +/* -------------------------------------------------------------------------- */ + + +void GenerateLatex::generateLatexSection(std::ofstream & fout, + const std::string & title, + const std::string & label, + const std::string level){ + + std::vector params; + params.push_back(removeUnderscore(label)); + params.push_back(title); + params.push_back(label); + + makeLatexFunction(fout,"my"+level,params); +} + +/* -------------------------------------------------------------------------- */ + +void GenerateLatex::generateKeywordsLatexBloc(std::ofstream & fout, + std::vector & keywords){ + + if (keywords.size() == 0) return; + + std::string key_list = keywords[0].name; + for(UInt i = 1 ; i < keywords.size(); ++i) + key_list += ", " + keywords[i].name; + + generateLatexCall(fout,"keywordlist",key_list); + + for (UInt i = 0 ; i < keywords.size() ; ++i){ + LMDocData & keyword = keywords[i]; + + std::vector params; + params.push_back(keyword.name); + params.push_back(makeTypeString(keyword)); + params.push_back(keyword.c_type); + // std::cerr << keyword.name << " " << keyword.c_type << std::endl; + params.push_back(keyword.var_name); + params.push_back(keyword.description); + if (keyword.defaults == "") + params.push_back("\\textbf{MANDATORY}"); + else + params.push_back("Default: " + keyword.defaults); + makeLatexFunction(fout,"keyword",params); + } +} + +/* -------------------------------------------------------------------------- */ + +void +GenerateLatex::generateHeritanceList(LMDocData & doc, + std::map & hlist){ + + std::vector & heritance = doc.heritance; + for (UInt i = 0; i < heritance.size(); ++i) { + std::string class_name = heritance[i]; + if (sorted_by_name.count(class_name) == 0){ + std::cout << doc.filename.native() << ":0:" + << "Unknown heritance " << class_name << std::endl; + exit(EXIT_FAILURE); + } + hlist[class_name] += 1; + // std::cerr << "hlist[" << class_name << "] = " << hlist[class_name] << std::endl; + LMDocData & herit = sorted_by_name[class_name]; + std::stringstream sstr; + generateHeritanceList(herit,hlist); + } +} + +/* -------------------------------------------------------------------------- */ + + +void GenerateLatex::generateHeritance(std::ofstream & fout, + LMDocData & doc, + std::map & hlist){ + + std::vector & heritance = doc.heritance; + for (UInt i = 0; i < heritance.size(); ++i) { + std::string class_name = heritance[i]; + if (sorted_by_name.count(class_name) == 0){ + std::cout << doc.filename.native() << ":0:" + << "Unknown heritance " << class_name << std::endl; + exit(EXIT_FAILURE); + } + if (!hlist.count(class_name)) { + std::cerr << "internal error" << std::endl; + exit(EXIT_FAILURE); + } + if (hlist[class_name] > 1){ + hlist[class_name] -=1; + // std::cerr << "not outputing " << class_name + // << " since hlist[" << class_name << "] = " << hlist[class_name] << std::endl; + continue; + } + // std::cerr << "outputing " << class_name + // << " since hlist[" << class_name << "] = " << hlist[class_name] << std::endl; + + LMDocData & herit = sorted_by_name[class_name]; + std::stringstream sstr; + sstr << class_name << "[\\ref{" << + removeUnderscore(class_name) << "}]"; + generateLatexCall(fout,"heritance",sstr.str()); + generateKeywordsLatexBloc(fout,herit.children); + generateHeritance(fout,herit,hlist); + } +} + +/* -------------------------------------------------------------------------- */ + +void GenerateLatex::generateClassInfo(std::ofstream & fout, + LMDocData & doc){ + + + //get heritance info + std::map hlist; + generateHeritanceList(doc,hlist); + // std::map::iterator it = hlist.begin(); + // std::map::iterator end = hlist.end(); + + // std::cerr << "4 " << doc.name << " heritance is " << std::endl; + // while(it != end){ + // std::cerr << it->first << ": " << it->second << std::endl; + // ++it; + // } + std::string & description = doc.description; + + if (description != "") generateLatexCall(fout,"description",description); + generateSyntax(fout,doc); + if (doc.example != "" && doc.example.find("NONE") == std::string::npos) + generateLatexCall(fout,"example",doc.example); + generateLatexCall(fout,"file",getSubPath(doc.filename)); + + generateKeywordsLatexBloc(fout,doc.children); + generateHeritance(fout,doc,hlist); +} + +/* -------------------------------------------------------------------------- */ +void GenerateLatex::generateLatex(std::ofstream & fout, + LMDataNode & sorted_by_section, + std::map & sorted_by_name, + std::string level){ + + this -> sorted_by_name = sorted_by_name; + + if (sorted_by_section.children.size()){ + if (level != "root") { + generateLatexSection(fout,sorted_by_section.name, + sorted_by_section.name,level); + level = "sub" + level; + } + else level = "section"; + + std::map::iterator it = sorted_by_section.children.begin(); + std::map::iterator end = sorted_by_section.children.end(); + + while(it != end){ + + generateLatex(fout,it->second,sorted_by_name,level); + + ++it; + } + } + else { + + std::vector::iterator it = sorted_by_section.data.begin(); + std::vector::iterator end = sorted_by_section.data.end(); + + while (it != end){ + + std::string title = it->name; + generateLatexSection(fout,title,protectString(it->filename.stem().native()),level); + generateClassInfo(fout,*it); + ++it; + } + } +} +/* -------------------------------------------------------------------------- */ diff --git a/doc/manual/generate_latex.hh b/doc/manual/generate_latex.hh new file mode 100644 index 0000000..acbf89e --- /dev/null +++ b/doc/manual/generate_latex.hh @@ -0,0 +1,133 @@ +/** + * @file generate_latex.hh + * + * @author Guillaume Anciaux + * + * @date Wed Oct 23 16:09:08 2013 + * + * @brief Manual generator + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_GENERATE_LATEX_HH__ +#define __LIBMULTISCALE_GENERATE_LATEX_HH__ +/* -------------------------------------------------------------------------- */ +#include "lm_doc_data.hh" +#include +#include +/* -------------------------------------------------------------------------- */ +typedef unsigned int UInt; +/* -------------------------------------------------------------------------- */ + + +inline std::string protectString(const std::string & str){ + + + const boost::regex my_filter("_"); + + std::string copy_str = + boost::regex_replace(str,my_filter,"\\\\_", + boost::match_default | boost::format_all); + + const boost::regex my_filter2("\\\\\\\\_"); + + copy_str = + boost::regex_replace(copy_str,my_filter2,"\\\\_", + boost::match_default | boost::format_all); + + + const boost::regex my_filter3("#"); + + copy_str = + boost::regex_replace(copy_str,my_filter3,"diese", + boost::match_default | boost::format_all); + + return copy_str; +} + +/* -------------------------------------------------------------------------- */ + + + +class GenerateLatex { + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ +public: + + GenerateLatex(); + virtual ~GenerateLatex(); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ +public: + + void generateLatexCall(std::ofstream & fout, + const std::string & func); + void generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1); + void generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1, + const std::string & arg2); + void generateLatexCall(std::ofstream & fout, + const std::string & func, + const std::string & arg1, + const std::string & arg2, + const std::string & arg3); + + void generateLatexSection(std::ofstream & fout, + const std::string & title, + const std::string & label, + const std::string level = "root"); + void generateKeywordsLatexBloc(std::ofstream & fout, + std::vector & keywords); + void generateClassInfo(std::ofstream & fout, + LMDocData & doc); + void generateLatex(std::ofstream & fout, + LMDataNode & sorted_by_section, + std::map & sorted_by_name, + std::string level = "root"); + + void generateHeritance(std::ofstream & fout, + LMDocData & doc, + std::map & hlist); + void generateHeritanceList(LMDocData & doc, + std::map & hlist); + + + /* ------------------------------------------------------------------------ */ + /* Accessors */ + /* ------------------------------------------------------------------------ */ +public: + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ +private: + + std::map sorted_by_name; + +}; + +#endif /* __LIBMULTISCALE_GENERATE_LATEX_HH__ */ diff --git a/doc/manual/images/bridging-zone-BM.svg b/doc/manual/images/bridging-zone-BM.svg new file mode 100644 index 0000000..251be4f --- /dev/null +++ b/doc/manual/images/bridging-zone-BM.svg @@ -0,0 +1,11663 @@ + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Atomic Zone + Bridging Zone + Continuum Mechanics Zone + + + + + + R + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/doc/manual/images/geom-circle-hole1d.svg b/doc/manual/images/geom-circle-hole1d.svg new file mode 100644 index 0000000..25692e8 --- /dev/null +++ b/doc/manual/images/geom-circle-hole1d.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/doc/manual/images/geom-circle-hole2d.svg b/doc/manual/images/geom-circle-hole2d.svg new file mode 100644 index 0000000..480a0d3 --- /dev/null +++ b/doc/manual/images/geom-circle-hole2d.svg @@ -0,0 +1,61 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/doc/manual/images/geom-circle.svg b/doc/manual/images/geom-circle.svg new file mode 100644 index 0000000..6ee7e0f --- /dev/null +++ b/doc/manual/images/geom-circle.svg @@ -0,0 +1,69 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/doc/manual/images/geom-cube-hole1d.svg b/doc/manual/images/geom-cube-hole1d.svg new file mode 100644 index 0000000..72b7755 --- /dev/null +++ b/doc/manual/images/geom-cube-hole1d.svg @@ -0,0 +1,74 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/doc/manual/images/geom-cube-hole2d.svg b/doc/manual/images/geom-cube-hole2d.svg new file mode 100644 index 0000000..82f3190 --- /dev/null +++ b/doc/manual/images/geom-cube-hole2d.svg @@ -0,0 +1,88 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/doc/manual/images/geom-cube.svg b/doc/manual/images/geom-cube.svg new file mode 100644 index 0000000..4cd8736 --- /dev/null +++ b/doc/manual/images/geom-cube.svg @@ -0,0 +1,63 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/doc/manual/images/planar-impulse.png b/doc/manual/images/planar-impulse.png new file mode 100644 index 0000000..1e0fb2f Binary files /dev/null and b/doc/manual/images/planar-impulse.png differ diff --git a/doc/manual/images/radial-impulse.png b/doc/manual/images/radial-impulse.png new file mode 100644 index 0000000..57e901f Binary files /dev/null and b/doc/manual/images/radial-impulse.png differ diff --git a/doc/manual/introduction.tex b/doc/manual/introduction.tex new file mode 100644 index 0000000..13ec5bf --- /dev/null +++ b/doc/manual/introduction.tex @@ -0,0 +1,11 @@ +\chapter{Introduction} + +The LibMultiScale Library has been designed to be a high performance tool to study +the mutiscale methods currently employed in material simulations. The component +design of the project distinct the base code components (Continuum mechanics code +implemented through finite element, meshless, XFEM or molecular dynamics codes) from +the coupling components. Other services like dumpers (logging the state of the +simulated system to files or memory), +stimulators (initial conditions, thermostats) or computes (general computation) +are provided. + diff --git a/doc/manual/libmultiscale_doc_parser.cc b/doc/manual/libmultiscale_doc_parser.cc new file mode 100644 index 0000000..dfa8a1a --- /dev/null +++ b/doc/manual/libmultiscale_doc_parser.cc @@ -0,0 +1,357 @@ +/** + * @file libmultiscale_doc_parser.cc + * + * @author Guillaume Anciaux + * + * @date Fri Oct 10 16:40:09 2014 + * + * @brief Manual parser + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +/* -------------------------------------------------------------------------- */ +#include "libmultiscale_doc_parser.hh" +/* -------------------------------------------------------------------------- */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +using namespace boost::filesystem; + +/* -------------------------------------------------------------------------- */ +using namespace boost::spirit; +/* -------------------------------------------------------------------------- */ +typedef unsigned int UInt; +/* -------------------------------------------------------------------------- */ +#define _call(x) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this) +#define _call1(x,p1) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1) +#define _call2(x,p1,p2) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2) +#define _call3(x,p1,p2,p3) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2,p3) +#define _call4(x,p1,p2,p3,p4) boost::phoenix::bind(&LibMultiScaleDocParser::x,*this,p1,p2,p3,p4) +/* -------------------------------------------------------------------------- */ +std::string debug(const std::string & v){ + std::cerr << "AAAAAAAAAA " << v << " AAAAAAAAAAAAA" << std::endl; + return v; +} +#define _dbg(x,p1) boost::phoenix::bind(&debug,p1) +/* -------------------------------------------------------------------------- */ +template +LibMultiScaleDocParser::LibMultiScaleDocParser() : + LibMultiScaleDocParser::base_type(start,"start") { + + std::string stag_desc = "/* LMDESC"; + std::string etag_desc = "*/"; + + std::string stag_keyword = "/* LMKEYWORD"; + std::string etag_keyword = "*/"; + + std::string stag_heritance = "/* LMHERITANCE"; + std::string etag_heritance = "*/"; + + std::string stag_example = "/* LMEXAMPLE"; + std::string etag_example = "*/"; + + using qi::char_; + using qi::print; + using qi::space; + using qi::alnum; + using qi::alpha; + using qi::string; + using qi::lexeme; + using qi::on_error; + using qi::fail; + using boost::phoenix::ref; + using boost::phoenix::val; + using boost::phoenix::construct; + using boost::phoenix::at_c; + using boost::phoenix::push_back; + + + start = text(stag_desc) + > description[_val = _1] + >> *(*(char_ - string(stag_keyword) - string(stag_heritance) - string(stag_example)) + >> (heritance[at_c<7>(_val) = _1] | + keyword[push_back(at_c<3>(_val),_1)] | + example[at_c<8>(_val) = _1] + ) + ); + + lookup_todo = *(char_ - string("TODO")) > eoi; + + lookup_type = *(string("return") | (char_ - declaration(_r1))) + > declaration(_r1)[_val = _1]; + + lookup_syntax = *(char_ - string("LMSYNTAX")) > eoi; + + quantity_type = string("Quantity<") > name > string(">"); + + vec_quantity_type = string("Quantity<") >> name + >> string(",") >> *(char_ - '>') >> string(">"); + + c_type = + +(char_ - "return" - eol - space - "{" - "}" + - "<<" - ">>" ); + + declaration = ( vec_quantity_type | quantity_type | c_type)[_val = _1] + >> +space >> string(_r1) + >> brackets[_val += _1] >> ';'; + + brackets = -(string("[") > *(char_ -string("]")) > string("]")); + + description = lit(stag_desc) + > (*space) > name[at_c<0>(_val) = _1] + > *(space-eol) > eol[at_c<1>(_val) = val("class")] + > innertext(etag_desc)[at_c<2>(_val) = _1] + > lit(etag_desc); + + defaults = *(char_-')'); + + keyword = lit(stag_keyword) + > name[at_c<0>(_val) = _1] > eol + > innertext(etag_desc)[at_c<2>(_val) = _1] + > lit(etag_keyword) > *eol + > ((( + string("this->parseTag")[at_c<1>(_val) = "Tag"] + |string("this->parseKeyword")[at_c<1>(_val) = "Keyword"] + ) > "(\"" > string(at_c<0>(_val)) > "\"," + > *string("this->") > name[at_c<4>(_val) = _1] > *(char_-")"-",") + > -(string(",") > defaults[at_c<9>(_val) = _1])) + |(string("this->parseVectorKeyword")[at_c<1>(_val) = "Keyword ["] + > "(\"" > string(at_c<0>(_val)) > "\"," + > expr[at_c<1>(_val) += _1 + val(std::string("]"))] + > "," > *string("this->") > name[at_c<4>(_val) = _1] + > -( + string(",") > string("VEC_DEFAULTS(") + > defaults[at_c<9>(_val) = _1] > string(")"))) + ) > string(");"); + + expr = *(char_ - string(",") - space); + + heritance = lit(stag_heritance) + > (*space) > + *(name[push_back(_val,_1)] > *(space-eol)) + > lit(etag_heritance) > eol; + + example = lit(stag_example) + > (*space) > + *(char_ - string(etag_example)) + > lit(etag_example) > eol; + + // parse everything but a starting tag + text = *(char_ - string(_r1)); + // // parse a single name + name = +(alnum|string("_")); + // // parse everything but the end tag + innertext = *(char_ - string(_r1)); + + description.name("description"); + lookup_type.name("lookup_type"); + lookup_todo.name("lookup_todo"); + heritance.name("heritance"); + start.name("start"); + c_type.name("c_type"); + declaration.name("declaration"); + name.name("name"); + text.name("text"); + innertext.name("innertext"); + keyword.name("keyword"); + expr.name("expr"); + example.name("example"); + + on_error(start,_call4(errorHandlerMain,_1,_2,_3,_4)); + on_error(lookup_type,_call4(errorHandlerMain,_1,_2,_3,_4)); + on_error(lookup_todo,_call4(errorHandlerTodo,_1,_2,_3,_4)); + on_error(lookup_syntax,_call4(errorHandlerSyntax,_1,_2,_3,_4)); +} + + +/* -------------------------------------------------------------------------- */ + +template +bool LibMultiScaleDocParser::parse(LMDocData & result, + std::set & internal_key_list){ + + fname = result.filename.native(); + std::ifstream file(result.filename.c_str()); + if (!file.good()) std::cerr << "could not open file: " << result.filename << std::endl; + std::string str((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); + + iter = str.begin(); + end = str.end(); + bool parsed = qi::phrase_parse(iter, end, start, + boost::spirit::ascii::blank,result); + result.filename = fname; + + if (result.example == "" && internal_key_list.count(result.name) == 0){ + std::cerr << fname << ":0:Warning: no LMEXAMPLE found in that class" << std::endl; + } + else if (result.example != "" && internal_key_list.count(result.name) != 0){ + std::cerr << fname << ":0:Warning: an example was provided for an internal class" << std::endl; + } + + if (!parsed) return parsed; + + iter = str.begin(); + std::string todo; + qi::parse(iter, end, lookup_todo,todo); + + if (!parsed) return parsed; + iter = str.begin(); + std::string syntax; + qi::parse(iter, end, lookup_syntax,syntax); + + for (UInt i = 0; i < result.children.size(); ++i) { + LMDocData & child = result.children[i]; + // if (child.type == "Tag" || + // child.type == "Keyword" || + // child.type == "Keyword []"){ + + path cc_file = result.filename; + path hh_file = cc_file.replace_extension(path(".hh")); + std::string h_fname = hh_file.native(); + + std::ifstream hfile(h_fname.c_str()); + if (hfile.is_open() == false){ + std::cerr << "fname:0:Error: cannot find header file " << h_fname << std::endl; + return false; + } + std::string hstr((std::istreambuf_iterator(hfile)), + std::istreambuf_iterator()); + + iter = hstr.begin(); + end = hstr.end(); + std::string c_type; + // std::cerr << "look for parameter " << child.name << " " << child.var_name << " " << child.type << std::endl; + parsed &= qi::parse(iter, end, lookup_type(child.var_name),c_type); + if (!parsed){ + std::cerr << h_fname << ":" << 0 << ":Error could not parse variable " + << child.name << " " << child.var_name << " " << child.type << std::endl; + return parsed; + } + // std::cerr << "found parameter " << child.name << " " << child.var_name << " " << c_type << std::endl; + child.c_type = c_type; + + // } + + + iter = hstr.begin(); + std::string todo; + qi::parse(iter, end, lookup_todo,todo); + + if (!parsed) return parsed; + iter = hstr.begin(); + std::string syntax; + qi::parse(iter, end, lookup_syntax,syntax); + + } + + return parsed; + +} +/* -------------------------------------------------------------------------- */ + +template +int LibMultiScaleDocParser::getLineNumber(const std::string & text, + std::string & now_parsing){ + + + int last_index = 0; + UInt count_lines = 0; + size_t index = text.find_first_of("\n", 0); + + while (index != text.npos){ + count_lines++; + last_index = index; + index = text.find_first_of("\n", last_index + 1); + // std::cerr << last_index << " " << index << std::endl; + } + // std::cerr << last_index << " " << index << std::endl; + now_parsing = text.substr(last_index+1,index); + + return count_lines; +} + +/* -------------------------------------------------------------------------- */ + + +template +void LibMultiScaleDocParser::errorHandlerMain(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const info & what){ + + std::string already_parsed(a,c); + std::string now_parsing; + UInt count_lines = getLineNumber(already_parsed,now_parsing); + + std::string not_parsed = std::string(c,b); + int index = not_parsed.find_first_of("\n",0); + std::string mess = now_parsing + " ^^^^ " + not_parsed.substr(0,index); + + std::cerr << fname << ":" << count_lines+1 << ":Error Expecting " << what << " here: \"" << + mess << "\"" << std::endl; +} + +/* -------------------------------------------------------------------------- */ + + +template +void LibMultiScaleDocParser::errorHandlerTodo(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const info & what){ + + std::string already_parsed(a,c); + // std::cerr << "already parsed " << already_parsed << std::endl; + std::string now_parsing; + UInt count_lines = getLineNumber(already_parsed,now_parsing); + std::cerr << fname << ":" << count_lines+1 << ":Warning TODO remaining: " + << what << ": " << now_parsing < +void LibMultiScaleDocParser::errorHandlerSyntax(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const info & what){ + + std::string already_parsed(a,c); + // std::cerr << "already parsed " << already_parsed << std::endl; + std::string now_parsing; + UInt count_lines = getLineNumber(already_parsed,now_parsing); + std::cerr << fname << ":" << count_lines+1 << ":Warning old Syntax remaining: " + << what << ": " << now_parsing <; diff --git a/doc/manual/libmultiscale_doc_parser.hh b/doc/manual/libmultiscale_doc_parser.hh new file mode 100644 index 0000000..329c22c --- /dev/null +++ b/doc/manual/libmultiscale_doc_parser.hh @@ -0,0 +1,126 @@ +/** + * @file libmultiscale_doc_parser.hh + * + * @author Guillaume Anciaux + * + * @date Mon Oct 28 19:23:14 2013 + * + * @brief Manual doc parser + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LIBMULTISCALE_DOC_PARSER_HH__ +#define __LIBMULTISCALE_LIBMULTISCALE_DOC_PARSER_HH__ +/* -------------------------------------------------------------------------- */ +#include +#include +#include "lm_doc_data.hh" +#include +/* -------------------------------------------------------------------------- */ + +template +struct LibMultiScaleDocParser : + boost::spirit::qi::grammar{ + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ + +public: + + LibMultiScaleDocParser(); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ + +public: + + + //! parse a single file (filename is stored in the structure) + bool parse(LMDocData & result,std::set & internal_key_list); + //! call back function for error handling + void errorHandlerMain(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const boost::spirit::info & what); + + //! call back function for error handling + void errorHandlerType(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const boost::spirit::info & what); + + //! call back function for error handling + void errorHandlerTodo(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const boost::spirit::info & what); + + //! call back function for error handling + void errorHandlerSyntax(const std::string::const_iterator & a, + const std::string::const_iterator& b, + const std::string::const_iterator & c, + const boost::spirit::info & what); + + + //! get the line number and last extract last line + int getLineNumber(const std::string & text, + std::string & now_parsing); + + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + +private: + + //! grammar rules + boost::spirit::qi::rule start; + boost::spirit::qi::rule name; + boost::spirit::qi::rule text; + boost::spirit::qi::rule c_type; + boost::spirit::qi::rule brackets; + boost::spirit::qi::rule innertext; + boost::spirit::qi::rule description; + boost::spirit::qi::rule keyword; + boost::spirit::qi::rule() > heritance; + boost::spirit::qi::rule lookup_type; + boost::spirit::qi::rule lookup_todo; + boost::spirit::qi::rule example; + boost::spirit::qi::rule declaration; + boost::spirit::qi::rule lookup_syntax; + boost::spirit::qi::rule expr; + boost::spirit::qi::rule defaults; + boost::spirit::qi::rule quantity_type; + boost::spirit::qi::rule vec_quantity_type; + + std::string fname; + + std::string::const_iterator iter; + std::string::const_iterator end; + +}; + +/* -------------------------------------------------------------------------- */ +typedef LibMultiScaleDocParser LibMultiScaleParser; +/* -------------------------------------------------------------------------- */ + +#endif /* __LIBMULTISCALE_LIBMULTISCALE_DOC_PARSER_HH__ */ diff --git a/doc/manual/lm_doc_data.hh b/doc/manual/lm_doc_data.hh new file mode 100644 index 0000000..8f25d9d --- /dev/null +++ b/doc/manual/lm_doc_data.hh @@ -0,0 +1,77 @@ +/** + * @file lm_doc_data.hh + * + * @author Guillaume Anciaux + * + * @date Wed Oct 23 16:09:08 2013 + * + * @brief Manual parser data + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LM_DOC_DATA_HH__ +#define __LIBMULTISCALE_LM_DOC_DATA_HH__ +/* -------------------------------------------------------------------------- */ +#include +#include +#include +#include +#include +/* -------------------------------------------------------------------------- */ + +struct LMDocData { + std::string name; // item name + std::string type; // item type + std::string description; // description + std::vector children; // sub items + std::string var_name; // code variable name + std::string c_type; // item type from the code + boost::filesystem::path filename; // filename where the thing is stored + std::vector heritance; // list of heritance + std::string example; // list of examples + std::string defaults; // default values +}; + +BOOST_FUSION_ADAPT_STRUCT( + LMDocData, + (std::string, name) + (std::string, type) + (std::string, description) + (std::vector, children) + (std::string, var_name) + (std::string, c_type) + (boost::filesystem::path, filename) + (std::vector, heritance) + (std::string, example) + (std::string, defaults) + ) + +/* -------------------------------------------------------------------------- */ +struct LMDataNode { + std::string name; + std::map children; + std::vector data; +}; + +/* -------------------------------------------------------------------------- */ + + +#endif /* __LIBMULTISCALE_LM_DOC_DATA_HH__ */ diff --git a/doc/manual/main.cc b/doc/manual/main.cc new file mode 100644 index 0000000..bf9bfe4 --- /dev/null +++ b/doc/manual/main.cc @@ -0,0 +1,345 @@ +/** + * @file main.cc + * + * @author Guillaume Anciaux + * + * @date Fri Oct 10 16:40:09 2014 + * + * @brief Manual parser + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +/* -------------------------------------------------------------------------- */ +#include "libmultiscale_doc_parser.hh" +#include "generate_latex.hh" +#include +/* -------------------------------------------------------------------------- */ +#include +#include +#include +using namespace std; +using namespace boost::filesystem; +/* -------------------------------------------------------------------------- */ +typedef unsigned int UInt; +/* -------------------------------------------------------------------------- */ +bool searchDeclareParamInFile(const std::string & filename){ + std::ifstream file(filename.c_str()); + std::string str((std::istreambuf_iterator(file)), + std::istreambuf_iterator()); + + const boost::regex my_filter( ".*(declareParams\\(\\)\\s*\\{).*" ); + + boost::smatch what; + bool res = boost::regex_match(str, what, my_filter ); + + if (res){ + const boost::regex filter_header_files( ".*\\.hh" ); + + boost::smatch what; + bool res = boost::regex_match(filename, what, filter_header_files); + if (res) std::cerr << filename << ":0:Warning: please move declaration of parameters to .cc file" << std::endl; + } + // std::cout << "test file " << filename << " : " << res<< std::endl; + return res; +} + + +/* -------------------------------------------------------------------------- */ + + + +std::vector recursiveSearchForSourceFiles(path p){ + + const boost::regex my_filter( ".*\\.(cc|hh)" ); + std::vector list_source_files; + + boost::filesystem::recursive_directory_iterator end; + boost::filesystem::recursive_directory_iterator dir(p); + while (dir != end){ + path f = dir->path(); + if (is_regular_file(f)){ + + boost::smatch what; + if (boost::regex_match(f.leaf().native(), what, my_filter )) + if (searchDeclareParamInFile(f.native())) + list_source_files.push_back(f); + } + ++dir; + } + return list_source_files; +} +/* -------------------------------------------------------------------------- */ + +std::vector readListOfSourceFiles(path p){ + + + std::string fname = p.native(); + std::ifstream f(fname.c_str()); + + std::vector list_files; + + + if (!f.is_open()) { + std::cerr << "could not open config file " << fname << std::endl; + exit(EXIT_FAILURE); + } + + while (f.good()){ + std::string line; + getline(f,line); + if (line == "") continue; + if (!searchDeclareParamInFile(line)) continue; + path source_file = line; + // std::cout << "I will parse file " << source_file << std::endl; + list_files.push_back(source_file); + } + + return list_files; + +} +/* -------------------------------------------------------------------------- */ + + + +void addDoc(LMDataNode & root,LMDocData & doc, path file){ + + path::iterator end = file.end(); + path::iterator begin = file.begin(); + + --end; + + for (; end != begin ; --end) { + if (end->native() == "src"){ + ++end; + break; + } + } + if (end == file.end()){ + std::cerr << "problem in the file structure" << std::endl; + exit(EXIT_FAILURE); + } + + begin = end; + end = file.end(); + LMDataNode * it = &root; + for (; begin != end ; ++begin) { + std::string sublevel = begin->native(); + it = &(it->children[sublevel]); + it->name = sublevel; + } + it->data.push_back(doc); + +} +/* -------------------------------------------------------------------------- */ + +void addDocByName( std::map & sorted_by_name, + LMDocData & doc, path file){ + + std::string short_name = file.stem().native(); + // std::cerr << "record heritance " << short_name << std::endl; + sorted_by_name[protectString(short_name)] = doc; + +} +/* -------------------------------------------------------------------------- */ + +void protectUnderscoreInDoc(LMDocData & doc){ + + + doc.name = protectString(doc.name); + doc.type = protectString(doc.type); + doc.var_name = protectString(doc.var_name); + doc.defaults = protectString(doc.defaults); + doc.c_type = protectString(doc.c_type); + doc.example = protectString(doc.example); + for (UInt i = 0; i < doc.heritance.size(); ++i) { + doc.heritance[i] = protectString(doc.heritance[i]); + } + for (UInt i = 0; i < doc.children.size(); ++i) + protectUnderscoreInDoc(doc.children[i]); +} +/* -------------------------------------------------------------------------- */ + +#include "atom_model_list.hh" +#include "compute_real_input_list.hh" +#include "compute_ref_input_list.hh" +#include "continuum_model_list.hh" +#include "coupler_list.hh" +#include "dd_model_list.hh" +#include "dumper_real_input_list.hh" +#include "dumper_ref_input_list.hh" +#include "filter_list.hh" +#include "stimulation_real_input_list.hh" +#include "stimulation_ref_input_list.hh" +#include "geometry_list.hh" +/* -------------------------------------------------------------------------- */ +#include +#define stringify_macro(s) stringify_macro_1(s) +#define stringify_macro_1(s) #s +/* -------------------------------------------------------------------------- */ +#define APPEND_MODEL_KEY_TO_LIST(r,data,x) \ + data[stringify_macro(BOOST_PP_TUPLE_ELEM(3,2,x))].resize(1); \ + data[stringify_macro(BOOST_PP_TUPLE_ELEM(3,2,x))][0] = \ + stringify_macro(BOOST_PP_TUPLE_ELEM(3,0,x)); + + +#define APPEND_COUPLER_KEY_TO_LIST(r,data,x) \ + data[stringify_macro(BOOST_PP_TUPLE_ELEM(4,1,x))]. \ + push_back( \ + stringify_macro(BOOST_PP_TUPLE_ELEM(4,0,x))); + + +#define APPEND_NORMAL_KEY_TO_LIST(r,data,x) \ + data[stringify_macro(BOOST_PP_TUPLE_ELEM(2,1,x))]. \ + push_back( \ + stringify_macro(BOOST_PP_TUPLE_ELEM(2,0,x))); + + +/* -------------------------------------------------------------------------- */ +std::map > generatorKeyWordList(){ + std::map > key_list; + BOOST_PP_SEQ_FOR_EACH(APPEND_MODEL_KEY_TO_LIST,key_list,LIST_ATOM_MODEL); + BOOST_PP_SEQ_FOR_EACH(APPEND_MODEL_KEY_TO_LIST,key_list,LIST_DD_MODEL); + BOOST_PP_SEQ_FOR_EACH(APPEND_MODEL_KEY_TO_LIST,key_list,LIST_CONTINUUM_MODEL); + + BOOST_PP_SEQ_FOR_EACH(APPEND_COUPLER_KEY_TO_LIST,key_list,LIST_COUPLER); + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_GEOMETRY); + + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_STIMULATION_REF_INPUT); + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_STIMULATION_REAL_INPUT); + + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_DUMPER_REF_INPUT); + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_DUMPER_REAL_INPUT); + + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_COMPUTE_REF_INPUT); + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_COMPUTE_REAL_INPUT); + BOOST_PP_SEQ_FOR_EACH(APPEND_NORMAL_KEY_TO_LIST,key_list,LIST_FILTER); + + return key_list; +} +/* -------------------------------------------------------------------------- */ +#include +/* -------------------------------------------------------------------------- */ +std::set generatorInternalKeyWordList(){ + std::set key_list; + + key_list.insert("DomainDD"); + key_list.insert("DomainAtomic"); + key_list.insert("DomainContinuum"); + key_list.insert("ActionInterface"); + key_list.insert("DomainInterface"); + key_list.insert("Dumper"); + key_list.insert("ComposedGeom"); + key_list.insert("CouplerManager"); + key_list.insert("DofAssociation"); + key_list.insert("Bridging"); + key_list.insert("Geometry"); + key_list.insert("ArlequinTemplate"); + key_list.insert("PointAssociation"); + key_list.insert("LAMMPS_BASE"); + key_list.insert("AKANTU_BASE"); + key_list.insert("AKANTU_DYNAMIC"); + key_list.insert("AKANTU_STATIC"); + key_list.insert("FILTER"); + return key_list; +} +/* -------------------------------------------------------------------------- */ + + + +void checkKeywordExistance(const std::string key, + std::map > & key_list, + std::set & internal_key_list){ + + if (key_list.count(key) == 0 && internal_key_list.count(key) == 0){ + std::cerr << "Error: Undeclared keyword " << key << std::endl; + std::map >::iterator it = key_list.begin(); + std::map >::iterator end = key_list.end(); + std::cerr << "declared keywords are "; + while (it!= end){ + std::cerr << it->first << " "; + ++it; + } + std::cerr << std::endl; + exit(EXIT_FAILURE); + } + else if(key_list.count(key)) { + // std::cerr << "treating key " << key << " " << key_list[key].size(); + key_list[key].pop_back(); + //std::cerr << " " << key_list[key].size() << std::endl; + if (key_list[key].size() == 0){ + key_list.erase(key); + // std::cerr << "removing key"; + } + // std::cerr << std::endl; + } +} + +/* -------------------------------------------------------------------------- */ + + + +int main(int argc, char ** argv){ + path p = argv[1]; + + // std::vector files = recursiveSearchForSourceFiles(p); + std::vector files = readListOfSourceFiles(p); + + std::map > key_list = generatorKeyWordList(); + std::set internal_key_list = generatorInternalKeyWordList(); + + LibMultiScaleParser parser; + + LMDataNode root; + std::map sorted_by_name; + + for (UInt i = 0; i < files.size(); ++i) { + LMDocData res; + res.filename = files[i].native(); + // std::cout << "parsing " << res.filename << std::endl; + bool r = parser.parse(res,internal_key_list); + if (r) { + checkKeywordExistance(res.name,key_list,internal_key_list); + protectUnderscoreInDoc(res); + for (UInt k = 0; k < res.children.size(); ++k) { + res.children[k].filename = res.filename; + } + protectUnderscoreInDoc(res); + addDoc(root,res,files[i]); + addDocByName(sorted_by_name,res,files[i]); + } + else std::cout << "parsing of " << res.filename << " failed" << std::endl; + } + + std::map >::iterator it = key_list.begin(); + std::map >::iterator end = key_list.end(); + + if (it != end){ + std::cerr << "Error: keyword " << it->first << " was not documented " << std::endl; + exit(EXIT_FAILURE); + } + + std::string fname = "manual-generated.tex"; + std::ofstream fout(fname.c_str()); + GenerateLatex ltx; + + ltx.generateLatex(fout,root,sorted_by_name); + +} diff --git a/doc/manual/manual-macros.sty b/doc/manual/manual-macros.sty new file mode 100644 index 0000000..d118541 --- /dev/null +++ b/doc/manual/manual-macros.sty @@ -0,0 +1,30 @@ +% Some new commands +\newcommand{\akantu}{{\texttt{\textbf{Akantu}}}\xspace} + +\newcommand{\examplesdir}{\texttt{examples}} + +\newcommand{\code}[1]{\texttt{#1}} +\newcommand{\note}[2][]{\textbf{Note#1: }\textit{#2}} +\newcommand{\todo}[1]{~({\small\color{red}\textbf{TODO: }\textbf{#1}})} + +\renewcommand{\vec}[1]{\ensuremath{\boldsymbol{#1}}} +\newcommand{\mat}[1]{\ensuremath{\boldsymbol{#1}}} +\newcommand{\st}[1]{{\mathrm{#1}}} + +\newcommand{\eg}{\emph{e.g.},\xspace} +\newcommand{\ie}{\emph{i.e.},\xspace} + +\newcommand{\realnum}{\mathbb{R}} % +\newcommand{\intnum}{\mathbb{Z}} % Requires: +\newcommand{\natnum}{\mathbb{N}} % \usepackage{pxfonts} +\newcommand{\compnum}{\mathbb{C}} % +\newcommand{\ratnum}{\mathbb{Q}} % + +\newcommand{\half}{\ensuremath{\tfrac{1}{2}}\xspace} +\newcommand{\quart}{\ensuremath{\tfrac{1}{4}}\xspace} +\newcommand{\third}{\ensuremath{\tfrac{1}{3}}\xspace} +\newcommand{\twothird}{\ensuremath{\tfrac{2}{3}}\xspace} +\newcommand{\sixth}{\ensuremath{\tfrac{1}{6}}\xspace} +\newcommand{\eighth}{\ensuremath{\tfrac{1}{8}}\xspace} +\newcommand{\invsqrtthree}{\ensuremath{\tfrac{1}{\sqrt{3}}}\xspace} + diff --git a/doc/manual/manual.cls b/doc/manual/manual.cls new file mode 100644 index 0000000..7b94545 --- /dev/null +++ b/doc/manual/manual.cls @@ -0,0 +1,754 @@ +%% +%% This is file `book.cls', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% classes.dtx (with options: `book') +%% +%% This is a generated file. +%% +%% Copyright 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 +%% The LaTeX3 Project and any individual authors listed elsewhere +%% in this file. +%% +%% This file was generated from file(s) of the LaTeX base system. +%% -------------------------------------------------------------- +%% +%% It may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either version 1.3c +%% of this license or (at your option) any later version. +%% The latest version of this license is in +%% http://www.latex-project.org/lppl.txt +%% and version 1.3c or later is part of all distributions of LaTeX +%% version 2005/12/01 or later. +%% +%% This file has the LPPL maintenance status "maintained". +%% +%% This file may only be distributed together with a copy of the LaTeX +%% base system. You may however distribute the LaTeX base system without +%% such generated files. +%% +%% The list of all files belonging to the LaTeX base distribution is +%% given in the file `manifest.txt'. See also `legal.txt' for additional +%% information. +%% +%% The list of derived (unpacked) files belonging to the distribution +%% and covered by LPPL is defined by the unpacking scripts (with +%% extension .ins) which are part of the distribution. +%% \CharacterTable +%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z +%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z +%% Digits \0\1\2\3\4\5\6\7\8\9 +%% Exclamation \! Double quote \" Hash (number) \# +%% Dollar \$ Percent \% Ampersand \& +%% Acute accent \' Left paren \( Right paren \) +%% Asterisk \* Plus \+ Comma \, +%% Minus \- Point \. Solidus \/ +%% Colon \: Semicolon \; Less than \< +%% Equals \= Greater than \> Question mark \? +%% Commercial at \@ Left bracket \[ Backslash \\ +%% Right bracket \] Circumflex \^ Underscore \_ +%% Grave accent \` Left brace \{ Vertical bar \| +%% Right brace \} Tilde \~} +\NeedsTeXFormat{LaTeX2e}[1995/12/01] +\ProvidesClass{manual} + [2012/04/23 v1.0 Akantu Manual LaTeX class (based on book.cls)] +\newcommand\@ptsize{} +\newif\if@restonecol +\newif\if@titlepage +\@titlepagetrue +\newif\if@openright +\newif\if@mainmatter \@mainmattertrue +\if@compatibility\else +\DeclareOption{a4paper} + {\setlength\paperheight {297mm}% + \setlength\paperwidth {210mm}} +\DeclareOption{a5paper} + {\setlength\paperheight {210mm}% + \setlength\paperwidth {148mm}} +\DeclareOption{b5paper} + {\setlength\paperheight {250mm}% + \setlength\paperwidth {176mm}} +\DeclareOption{letterpaper} + {\setlength\paperheight {11in}% + \setlength\paperwidth {8.5in}} +\DeclareOption{legalpaper} + {\setlength\paperheight {14in}% + \setlength\paperwidth {8.5in}} +\DeclareOption{executivepaper} + {\setlength\paperheight {10.5in}% + \setlength\paperwidth {7.25in}} +\DeclareOption{landscape} + {\setlength\@tempdima {\paperheight}% + \setlength\paperheight {\paperwidth}% + \setlength\paperwidth {\@tempdima}} +\fi +\if@compatibility + \renewcommand\@ptsize{0} +\else +\DeclareOption{10pt}{\renewcommand\@ptsize{0}} +\fi +\DeclareOption{11pt}{\renewcommand\@ptsize{1}} +\DeclareOption{12pt}{\renewcommand\@ptsize{2}} +\if@compatibility\else +\DeclareOption{oneside}{\@twosidefalse \@mparswitchfalse} +\fi +\DeclareOption{twoside}{\@twosidetrue \@mparswitchtrue} +\DeclareOption{draft}{\setlength\overfullrule{5pt}} +\if@compatibility\else +\DeclareOption{final}{\setlength\overfullrule{0pt}} +\fi +\DeclareOption{titlepage}{\@titlepagetrue} +\if@compatibility\else +\DeclareOption{notitlepage}{\@titlepagefalse} +\fi +\if@compatibility +\@openrighttrue +\else +\DeclareOption{openright}{\@openrighttrue} +\DeclareOption{openany}{\@openrightfalse} +\fi +\if@compatibility\else +\DeclareOption{onecolumn}{\@twocolumnfalse} +\fi +\DeclareOption{twocolumn}{\@twocolumntrue} +\DeclareOption{leqno}{\input{leqno.clo}} +\DeclareOption{fleqn}{\input{fleqn.clo}} +\DeclareOption{openbib}{% + \AtEndOfPackage{% + \renewcommand\@openbib@code{% + \advance\leftmargin\bibindent + \itemindent -\bibindent + \listparindent \itemindent + \parsep \z@ + }% + \renewcommand\newblock{\par}}% +} +\ExecuteOptions{a4paper,11pt,twoside,onecolumn,final,openright} +\ProcessOptions +\input{bk1\@ptsize.clo} +\setlength\lineskip{1\p@} +\setlength\normallineskip{1\p@} +\renewcommand\baselinestretch{} +\setlength\parskip{0\p@ \@plus \p@} +\@lowpenalty 51 +\@medpenalty 151 +\@highpenalty 301 +\setcounter{topnumber}{2} +\renewcommand\topfraction{.7} +\setcounter{bottomnumber}{1} +\renewcommand\bottomfraction{.3} +\setcounter{totalnumber}{3} +\renewcommand\textfraction{.2} +\renewcommand\floatpagefraction{.5} +\setcounter{dbltopnumber}{2} +\renewcommand\dbltopfraction{.7} +\renewcommand\dblfloatpagefraction{.5} +\if@twoside + \def\ps@headings{% + \let\@oddfoot\@empty\let\@evenfoot\@empty + \def\@evenhead{\thepage\hfil\slshape\leftmark}% + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\markboth + \def\chaptermark##1{% + \markboth {\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne + \if@mainmatter + \@chapapp\ \thechapter. \ % + \fi + \fi + ##1}}{}}% + \def\sectionmark##1{% + \markright {\MakeUppercase{% + \ifnum \c@secnumdepth >\z@ + \thesection. \ % + \fi + ##1}}}} +\else + \def\ps@headings{% + \let\@oddfoot\@empty + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\markboth + \def\chaptermark##1{% + \markright {\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne + \if@mainmatter + \@chapapp\ \thechapter. \ % + \fi + \fi + ##1}}}} +\fi +\def\ps@myheadings{% + \let\@oddfoot\@empty\let\@evenfoot\@empty + \def\@evenhead{\thepage\hfil\slshape\leftmark}% + \def\@oddhead{{\slshape\rightmark}\hfil\thepage}% + \let\@mkboth\@gobbletwo + \let\chaptermark\@gobble + \let\sectionmark\@gobble + } + \if@titlepage + \newcommand\maketitle{\begin{titlepage}% + \let\footnotesize\small + \let\footnoterule\relax + \let \footnote \thanks + \null\vfil + \vskip 60\p@ + \begin{center}% + {\LARGE \@title \par}% + \vskip 3em% + {\large + \lineskip .75em% + \begin{tabular}[t]{c}% + \@author + \end{tabular}\par}% + \vskip 1.5em% + {\large \@date \par}% % Set date in \large size. + \end{center}\par + \@thanks + \vfil\null + \end{titlepage}% + \setcounter{footnote}{0}% + \global\let\thanks\relax + \global\let\maketitle\relax + \global\let\@thanks\@empty + \global\let\@author\@empty + \global\let\@date\@empty + \global\let\@title\@empty + \global\let\title\relax + \global\let\author\relax + \global\let\date\relax + \global\let\and\relax +} +\else +\newcommand\maketitle{\par + \begingroup + \renewcommand\thefootnote{\@fnsymbol\c@footnote}% + \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}% + \long\def\@makefntext##1{\parindent 1em\noindent + \hb@xt@1.8em{% + \hss\@textsuperscript{\normalfont\@thefnmark}}##1}% + \if@twocolumn + \ifnum \col@number=\@ne + \@maketitle + \else + \twocolumn[\@maketitle]% + \fi + \else + \newpage + \global\@topnum\z@ % Prevents figures from going at top of page. + \@maketitle + \fi + \thispagestyle{plain}\@thanks + \endgroup + \setcounter{footnote}{0}% + \global\let\thanks\relax + \global\let\maketitle\relax + \global\let\@maketitle\relax + \global\let\@thanks\@empty + \global\let\@author\@empty + \global\let\@date\@empty + \global\let\@title\@empty + \global\let\title\relax + \global\let\author\relax + \global\let\date\relax + \global\let\and\relax +} +\def\@maketitle{% + \newpage + \null + \vskip 2em% + \begin{center}% + \let \footnote \thanks + {\LARGE \@title \par}% + \vskip 1.5em% + {\large + \lineskip .5em% + \begin{tabular}[t]{c}% + \@author + \end{tabular}\par}% + \vskip 1em% + {\large \@date}% + \end{center}% + \par + \vskip 1.5em} +\fi +\newcommand*\chaptermark[1]{} +\setcounter{secnumdepth}{2} +\newcounter {part} +\newcounter {chapter} +\newcounter {section}[chapter] +\newcounter {subsection}[section] +\newcounter {subsubsection}[subsection] +\newcounter {paragraph}[subsubsection] +\newcounter {subparagraph}[paragraph] +\renewcommand \thepart {\@Roman\c@part} +\renewcommand \thechapter {\@arabic\c@chapter} +\renewcommand \thesection {\thechapter.\@arabic\c@section} +\renewcommand\thesubsection {\thesection.\@arabic\c@subsection} +\renewcommand\thesubsubsection{\thesubsection.\@arabic\c@subsubsection} +\renewcommand\theparagraph {\thesubsubsection.\@arabic\c@paragraph} +\renewcommand\thesubparagraph {\theparagraph.\@arabic\c@subparagraph} +\newcommand\@chapapp{\chaptername} +\newcommand\frontmatter{% + \cleardoublepage + \@mainmatterfalse + \pagenumbering{roman}} +\newcommand\mainmatter{% + \cleardoublepage + \@mainmattertrue + \pagenumbering{arabic}} +\newcommand\backmatter{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi + \@mainmatterfalse} +\newcommand\part{% + \if@openright + \cleardoublepage + \else + \clearpage + \fi + \thispagestyle{plain}% + \if@twocolumn + \onecolumn + \@tempswatrue + \else + \@tempswafalse + \fi + \null\vfil + \secdef\@part\@spart} + +\def\@part[#1]#2{% + \ifnum \c@secnumdepth >-2\relax + \refstepcounter{part}% + \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}% + \else + \addcontentsline{toc}{part}{#1}% + \fi + \markboth{}{}% + {\centering + \interlinepenalty \@M + \normalfont + \ifnum \c@secnumdepth >-2\relax + \huge\bfseries \partname\nobreakspace\thepart + \par + \vskip 20\p@ + \fi + \Huge \bfseries #2\par}% + \@endpart} +\def\@spart#1{% + {\centering + \interlinepenalty \@M + \normalfont + \Huge \bfseries #1\par}% + \@endpart} +\def\@endpart{\vfil\newpage + \if@twoside + \if@openright + \null + \thispagestyle{empty}% + \newpage + \fi + \fi + \if@tempswa + \twocolumn + \fi} +\newcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{plain}% + \global\@topnum\z@ + \@afterindentfalse + \secdef\@chapter\@schapter} +\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne + \if@mainmatter + \refstepcounter{chapter}% + \typeout{\@chapapp\space\thechapter.}% + \addcontentsline{toc}{chapter}% + {\protect\numberline{\thechapter}#1}% + \else + \addcontentsline{toc}{chapter}{#1}% + \fi + \else + \addcontentsline{toc}{chapter}{#1}% + \fi + \chaptermark{#1}% + \addtocontents{lof}{\protect\addvspace{10\p@}}% + \addtocontents{lot}{\protect\addvspace{10\p@}}% + \if@twocolumn + \@topnewpage[\@makechapterhead{#2}]% + \else + \@makechapterhead{#2}% + \@afterheading + \fi} +\def\@makechapterhead#1{% + \vspace*{50\p@}% + {\parindent \z@ \raggedright \normalfont + \ifnum \c@secnumdepth >\m@ne + \if@mainmatter + \huge\bfseries \@chapapp\space \thechapter + \par\nobreak + \vskip 20\p@ + \fi + \fi + \interlinepenalty\@M + \Huge \bfseries #1\par\nobreak + \vskip 40\p@ + }} +\def\@schapter#1{\if@twocolumn + \@topnewpage[\@makeschapterhead{#1}]% + \else + \@makeschapterhead{#1}% + \@afterheading + \fi} +\def\@makeschapterhead#1{% + \vspace*{50\p@}% + {\parindent \z@ \raggedright + \normalfont + \interlinepenalty\@M + \Huge \bfseries #1\par\nobreak + \vskip 40\p@ + }} +\newcommand\section{\@startsection {section}{1}{\z@}% + {-3.5ex \@plus -1ex \@minus -.2ex}% + {2.3ex \@plus.2ex}% + {\normalfont\Large\bfseries}} +\newcommand\subsection{\@startsection{subsection}{2}{\z@}% + {-3.25ex\@plus -1ex \@minus -.2ex}% + {1.5ex \@plus .2ex}% + {\normalfont\large\bfseries}} +\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}% + {-3.25ex\@plus -1ex \@minus -.2ex}% + {1.5ex \@plus .2ex}% + {\normalfont\normalsize\bfseries}} +\newcommand\paragraph{\@startsection{paragraph}{4}{\z@}% + {3.25ex \@plus1ex \@minus.2ex}% + {-1em}% + {\normalfont\normalsize\bfseries}} +\newcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}% + {3.25ex \@plus1ex \@minus .2ex}% + {-1em}% + {\normalfont\normalsize\bfseries}} +\if@twocolumn + \setlength\leftmargini {2em} +\else + \setlength\leftmargini {2.5em} +\fi +\leftmargin \leftmargini +\setlength\leftmarginii {2.2em} +\setlength\leftmarginiii {1.87em} +\setlength\leftmarginiv {1.7em} +\if@twocolumn + \setlength\leftmarginv {.5em} + \setlength\leftmarginvi {.5em} +\else + \setlength\leftmarginv {1em} + \setlength\leftmarginvi {1em} +\fi +\setlength \labelsep {.5em} +\setlength \labelwidth{\leftmargini} +\addtolength\labelwidth{-\labelsep} +\@beginparpenalty -\@lowpenalty +\@endparpenalty -\@lowpenalty +\@itempenalty -\@lowpenalty +\renewcommand\theenumi{\@arabic\c@enumi} +\renewcommand\theenumii{\@alph\c@enumii} +\renewcommand\theenumiii{\@roman\c@enumiii} +\renewcommand\theenumiv{\@Alph\c@enumiv} +\newcommand\labelenumi{\theenumi.} +\newcommand\labelenumii{(\theenumii)} +\newcommand\labelenumiii{\theenumiii.} +\newcommand\labelenumiv{\theenumiv.} +\renewcommand\p@enumii{\theenumi} +\renewcommand\p@enumiii{\theenumi(\theenumii)} +\renewcommand\p@enumiv{\p@enumiii\theenumiii} +\newcommand\labelitemi{\textbullet} +\newcommand\labelitemii{\normalfont\bfseries \textendash} +\newcommand\labelitemiii{\textasteriskcentered} +\newcommand\labelitemiv{\textperiodcentered} +\newenvironment{description} + {\list{}{\labelwidth\z@ \itemindent-\leftmargin + \let\makelabel\descriptionlabel}} + {\endlist} +\newcommand*\descriptionlabel[1]{\hspace\labelsep + \normalfont\bfseries #1} +\newenvironment{verse} + {\let\\\@centercr + \list{}{\itemsep \z@ + \itemindent -1.5em% + \listparindent\itemindent + \rightmargin \leftmargin + \advance\leftmargin 1.5em}% + \item\relax} + {\endlist} +\newenvironment{quotation} + {\list{}{\listparindent 1.5em% + \itemindent \listparindent + \rightmargin \leftmargin + \parsep \z@ \@plus\p@}% + \item\relax} + {\endlist} +\newenvironment{quote} + {\list{}{\rightmargin\leftmargin}% + \item\relax} + {\endlist} +\if@compatibility +\newenvironment{titlepage} + {% + \cleardoublepage + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse\newpage + \fi + \thispagestyle{empty}% + \setcounter{page}\z@ + }% + {\if@restonecol\twocolumn \else \newpage \fi + } +\else +\newenvironment{titlepage} + {% + \cleardoublepage + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse\newpage + \fi + \thispagestyle{empty}% + \setcounter{page}\@ne + }% + {\if@restonecol\twocolumn \else \newpage \fi + \if@twoside\else + \setcounter{page}\@ne + \fi + } +\fi +\newcommand\appendix{\par + \setcounter{chapter}{0}% + \setcounter{section}{0}% + \gdef\@chapapp{\appendixname}% + \gdef\thechapter{\@Alph\c@chapter}} +\setlength\arraycolsep{5\p@} +\setlength\tabcolsep{6\p@} +\setlength\arrayrulewidth{.4\p@} +\setlength\doublerulesep{2\p@} +\setlength\tabbingsep{\labelsep} +\skip\@mpfootins = \skip\footins +\setlength\fboxsep{3\p@} +\setlength\fboxrule{.4\p@} +\@addtoreset {equation}{chapter} +\renewcommand\theequation + {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@equation} +\newcounter{figure}[chapter] +\renewcommand \thefigure + {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@figure} +\def\fps@figure{tbp} +\def\ftype@figure{1} +\def\ext@figure{lof} +\def\fnum@figure{\figurename\nobreakspace\thefigure} +\newenvironment{figure} + {\@float{figure}} + {\end@float} +\newenvironment{figure*} + {\@dblfloat{figure}} + {\end@dblfloat} +\newcounter{table}[chapter] +\renewcommand \thetable + {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@table} +\def\fps@table{tbp} +\def\ftype@table{2} +\def\ext@table{lot} +\def\fnum@table{\tablename\nobreakspace\thetable} +\newenvironment{table} + {\@float{table}} + {\end@float} +\newenvironment{table*} + {\@dblfloat{table}} + {\end@dblfloat} +\newlength\abovecaptionskip +\newlength\belowcaptionskip +\setlength\abovecaptionskip{10\p@} +\setlength\belowcaptionskip{0\p@} +\long\def\@makecaption#1#2{% + \vskip\abovecaptionskip + \sbox\@tempboxa{#1: #2}% + \ifdim \wd\@tempboxa >\hsize + #1: #2\par + \else + \global \@minipagefalse + \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}% + \fi + \vskip\belowcaptionskip} +\DeclareOldFontCommand{\rm}{\normalfont\rmfamily}{\mathrm} +\DeclareOldFontCommand{\sf}{\normalfont\sffamily}{\mathsf} +\DeclareOldFontCommand{\tt}{\normalfont\ttfamily}{\mathtt} +\DeclareOldFontCommand{\bf}{\normalfont\bfseries}{\mathbf} +\DeclareOldFontCommand{\it}{\normalfont\itshape}{\mathit} +\DeclareOldFontCommand{\sl}{\normalfont\slshape}{\@nomath\sl} +\DeclareOldFontCommand{\sc}{\normalfont\scshape}{\@nomath\sc} +\DeclareRobustCommand*\cal{\@fontswitch\relax\mathcal} +\DeclareRobustCommand*\mit{\@fontswitch\relax\mathnormal} +\newcommand\@pnumwidth{1.55em} +\newcommand\@tocrmarg{2.55em} +\newcommand\@dotsep{4.5} +\setcounter{tocdepth}{2} +\newcommand\tableofcontents{% + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\contentsname + \@mkboth{% + \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}% + \pdfbookmark[0]{\contentsname}{} + \@starttoc{toc}% + \if@restonecol\twocolumn\fi + } +\newcommand*\l@part[2]{% + \ifnum \c@tocdepth >-2\relax + \addpenalty{-\@highpenalty}% + \addvspace{2.25em \@plus\p@}% + \setlength\@tempdima{3em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + {\leavevmode + \large \bfseries #1\hfil \hb@xt@\@pnumwidth{\hss #2}}\par + \nobreak + \global\@nobreaktrue + \everypar{\global\@nobreakfalse\everypar{}}% + \endgroup + \fi} +\newcommand*\l@chapter[2]{% + \ifnum \c@tocdepth >\m@ne + \addpenalty{-\@highpenalty}% + \vskip 1.0em \@plus\p@ + \setlength\@tempdima{1.5em}% + \begingroup + \parindent \z@ \rightskip \@pnumwidth + \parfillskip -\@pnumwidth + \leavevmode \bfseries + \advance\leftskip\@tempdima + \hskip -\leftskip + #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par + \penalty\@highpenalty + \endgroup + \fi} +\newcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}} +\newcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}} +\newcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}} +\newcommand*\l@paragraph{\@dottedtocline{4}{10em}{5em}} +\newcommand*\l@subparagraph{\@dottedtocline{5}{12em}{6em}} +\newcommand\listoffigures{% + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\listfigurename}% + \@mkboth{\MakeUppercase\listfigurename}% + {\MakeUppercase\listfigurename}% + \@starttoc{lof}% + \if@restonecol\twocolumn\fi + } +\newcommand*\l@figure{\@dottedtocline{1}{1.5em}{2.3em}} +\newcommand\listoftables{% + \if@twocolumn + \@restonecoltrue\onecolumn + \else + \@restonecolfalse + \fi + \chapter*{\listtablename}% + \@mkboth{% + \MakeUppercase\listtablename}% + {\MakeUppercase\listtablename}% + \@starttoc{lot}% + \if@restonecol\twocolumn\fi + } +\let\l@table\l@figure +\newdimen\bibindent +\setlength\bibindent{1.5em} +\newenvironment{thebibliography}[1] + {\chapter*{\bibname}% + \@mkboth{\MakeUppercase\bibname}{\MakeUppercase\bibname}% + \list{\@biblabel{\@arabic\c@enumiv}}% + {\settowidth\labelwidth{\@biblabel{#1}}% + \leftmargin\labelwidth + \advance\leftmargin\labelsep + \@openbib@code + \usecounter{enumiv}% + \let\p@enumiv\@empty + \renewcommand\theenumiv{\@arabic\c@enumiv}}% + \sloppy + \clubpenalty4000 + \@clubpenalty \clubpenalty + \widowpenalty4000% + \sfcode`\.\@m} + {\def\@noitemerr + {\@latex@warning{Empty `thebibliography' environment}}% + \endlist} +\newcommand\newblock{\hskip .11em\@plus.33em\@minus.07em} +\let\@openbib@code\@empty +\newenvironment{theindex} + {\if@twocolumn + \@restonecolfalse + \else + \@restonecoltrue + \fi + \twocolumn[\@makeschapterhead{\indexname}]% + \@mkboth{\MakeUppercase\indexname}% + {\MakeUppercase\indexname}% + \thispagestyle{plain}\parindent\z@ + \parskip\z@ \@plus .3\p@\relax + \columnseprule \z@ + \columnsep 35\p@ + \let\item\@idxitem} + {\if@restonecol\onecolumn\else\clearpage\fi} +\newcommand\@idxitem{\par\hangindent 40\p@} +\newcommand\subitem{\@idxitem \hspace*{20\p@}} +\newcommand\subsubitem{\@idxitem \hspace*{30\p@}} +\newcommand\indexspace{\par \vskip 10\p@ \@plus5\p@ \@minus3\p@\relax} +\renewcommand\footnoterule{% + \kern-3\p@ + \hrule\@width.4\columnwidth + \kern2.6\p@} +\@addtoreset{footnote}{chapter} +\newcommand\@makefntext[1]{% + \parindent 1em% + \noindent + \hb@xt@1.8em{\hss\@makefnmark}#1} +\newcommand\contentsname{Contents} +\newcommand\listfigurename{List of Figures} +\newcommand\listtablename{List of Tables} +\newcommand\bibname{Bibliography} +\newcommand\indexname{Index} +\newcommand\figurename{Figure} +\newcommand\tablename{Table} +\newcommand\partname{Part} +\newcommand\chaptername{Chapter} +\newcommand\appendixname{Appendix} +\def\today{\ifcase\month\or + January\or February\or March\or April\or May\or June\or + July\or August\or September\or October\or November\or December\fi + \space\number\day, \number\year} +\setlength\columnsep{10\p@} +\setlength\columnseprule{0\p@} +\pagestyle{headings} +\pagenumbering{arabic} +\if@twoside +\else + \raggedbottom +\fi +\if@twocolumn + \twocolumn + \sloppy + \flushbottom +\else + \onecolumn +\fi +\endinput +%% +%% End of file `manual.cls'. diff --git a/doc/manual/manual.sty b/doc/manual/manual.sty new file mode 100644 index 0000000..419b030 --- /dev/null +++ b/doc/manual/manual.sty @@ -0,0 +1,307 @@ +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% %% +%% LaTeX STYLE SHEET for LibMultiScale DOCUMENTATION %% +%% %% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +% Geometry +\usepackage{a4wide} +\usepackage{geometry} +\geometry{ + pdftex=true, + twoside=true, + margin=20mm, + bottom=20mm, + top=20mm, + bindingoffset=5.5mm +} + +% Font encoding +\usepackage[T1]{fontenc} +\usepackage{palatino} +\usepackage{xspace} +% Line spacing +\linespread{1.05}\selectfont + +% Allow spaces to be added at the end of macro +\usepackage{xspace} + +% Mathematics (including correct font encoding, after amsmath) +\usepackage{amsmath} +\usepackage{amssymb} +\usepackage{pxfonts} +%\setlength\mathindent{2em} + +% Some unit stuff +\usepackage[squaren]{SIunits} + +% Easy tables +\usepackage{booktabs} +\usepackage{longtable} +\usepackage{rotating} % For sideways tables +\usepackage{multirow} % For larger cells + +% A special environment for element tables +\newcommand\elemline{\hline}%{\noalign{\smallskip}\hline\noalign{\smallskip}} +\newcommand\elemcooroned{\ensuremath{\left(\xi\right)}} +\newcommand\elemcoortwod{\ensuremath{\left(\xi\;,\;\eta\right)}} +\newcommand\elemcoorthreed{\ensuremath{\left(\xi\;,\;\eta\;,\;\zeta\right)}} +\newcommand\elemdshapeoned{\ensuremath{\left(\partial N_i/\partial\xi\right)}} +\newcommand\elemdshapetwod{\ensuremath{\left(\partial N_i/\partial\xi\;,\;\partial N_i/\partial\eta\right)}} +\newcommand\elemdshapethreed{\ensuremath{\left(\partial N_i/\partial\xi\;,\;\partial N_i/\partial\eta\;,\;\partial N_i/\partial\zeta\right)}} +\newcommand\inelemone[1]{\ensuremath{#1}} +%\newcommand\inelemtwo[2]{\ensuremath{\begin{pmatrix} {\; #1} & \!,\! & {#2 \;} \end{pmatrix}}} +%\newcommand\inelemthree[3]{\ensuremath{\begin{pmatrix} {\; #1} & \!,\! & {#2} & \!,\! & {#3 \;} \end{pmatrix}}} +\newcommand\inelemtwo[2]{\ensuremath{\left( {\; #1} \; , \; {#2 \;} \right)}} +\newcommand\inelemthree[3]{\ensuremath{\left( {\; #1} \; , \; {#2} \; , \; {#3 \;} \right)}} +\newcommand\inquadone[1]{\ensuremath{#1}} +\newcommand\inquadtwo[2]{\ensuremath{\left(\, #1 \, , \, #2 \,\right)}} +\newcommand\inquadthree[3]{\ensuremath{\left(\, #1 \, , \, #2 \, , \, #3 \,\right)}} +%\newcommand\quada{\tfrac{1}{20}\left(5-\sqrt{5}\right)} +%\newcommand\quadb{\tfrac{1}{20}\left(5+3\sqrt{5}\right)} +\newcommand\quada{\tfrac{\left(5-\sqrt{5}\right)}{20}} +\newcommand\quadb{\tfrac{\left(5+3\sqrt{5}\right)}{20}} +\newenvironment{Element}[1] + {\begin{table*}[!htbp]\footnotesize + \ifthenelse{\equal{#1}{1D}}{\renewcommand{\arraystretch}{1.50}}{} + \ifthenelse{\equal{#1}{2D}}{\renewcommand{\arraystretch}{1.60}}{} + \ifthenelse{\equal{#1}{3D}}{\renewcommand{\arraystretch}{1.70}}{} + \textbf{{\normalsize Element properties}}\newline\vspace*{0.5\baselineskip} + \begin{tabular}{c|c|c|c} + %\multicolumn{4}{l}{\textbf{{\normalsize Element properties}}} \\ + Node ($i$) & Coord. + \ifthenelse{\equal{#1}{1D}}{\elemcooroned}{} + \ifthenelse{\equal{#1}{2D}}{\elemcoortwod}{} + \ifthenelse{\equal{#1}{3D}}{\elemcoorthreed}{} + & Shape function ($N_{i}$) + & {Derivative + \ifthenelse{\equal{#1}{1D}}{\elemdshapeoned}{} + \ifthenelse{\equal{#1}{2D}}{\elemdshapetwod}{} + \ifthenelse{\equal{#1}{3D}}{\elemdshapethreed}{} + }\\ + \elemline + } + {\end{tabular}\end{table*}} +\newenvironment{QuadPoints}%[1] + {\vspace*{-\baselineskip} + \begin{table*}[!htbp]\footnotesize + \renewcommand{\arraystretch}{1.50} + \textbf{{\normalsize Gaussian quadrature points}}\newline\vspace*{0.5\baselineskip} + } + {\end{table*}} + +% Nice coloring +%\usepackage[dvipsnames,usenames,table]{xcolor} +\usepackage[dvipsnames]{xcolor} +\definecolor{RED}{rgb}{1,0,0} +\definecolor{cppbg}{HTML}{EBF2F2} +\definecolor{shellbg}{HTML}{F5EDE4} +\definecolor{commentcolor}{HTML}{101280} + +% Allow for the use of listings +\usepackage{listings} + +% Create an index +\usepackage{makeidx} + +% Figure handling +\usepackage{graphics} +\usepackage{epsfig} +\usepackage[lofdepth,lotdepth]{subfig} +\usepackage{tikz} +\usetikzlibrary{decorations} +\renewcommand{\floatpagefraction}{.6} % default: .5 +\renewcommand\topfraction{0.9} % 90% of page top can be a float (Standard 0.7) +\renewcommand\bottomfraction{0.1} % 10% of page bottom can be a float (Standard 0.3) +\renewcommand\textfraction{0.1} % only 10% of page must to be text (Standard 0.2) + +% Removes parenthese around subfig number +\renewcommand*{\thesubfigure}{\alph{subfigure}} + +% Create a new list style for C++ +\lstdefinestyle{C++}{ + language=C++, % the language of the code + basicstyle=\small\ttfamily, % Without beramono, we'd get cmtt, the teletype font. + commentstyle=\color{commentcolor}\itshape, + keywordstyle=\color{DarkOrchid}\bfseries, + % fontadjust, + % numbers=left, % where to put the line-numbers + % numberstyle=\tiny, % the size of the fonts that are used for the line-numbers + % stepnumber=2, % the step between two line-numbers. If it's 1, each line will + % be numbered + % numbersep=5pt, % how far the line-numbers are from the code + % showspaces=false, % show spaces adding particular underscores + showstringspaces=false, % underline spaces within strings + % showtabs=false, % show tabs within strings adding particular underscores + % frame=llines, % adds a frame around the code + % frame=tb, + tabsize=2, % sets default tabsize to 2 spaces + captionpos=b, % sets the caption-position to bottom + breaklines=true, % sets automatic line breaking + breakatwhitespace=false, % sets if automatic breaks should only happen at + % whitespace + % title=\lstname, % show the filename of files included with \lstinputlisting; + % also try caption instead of title + % escapeinside={\%*}{*)}, % if you want to add a comment within your code + xleftmargin=1cm, + xrightmargin=1cm, + mathescape=true, + escapechar=\%, + morekeywords={Real, UInt, Int}, + columns=flexible, + keepspaces=true, + backgroundcolor=\color{cppbg} +} + +% Create new list style for the shell +\lstdefinestyle{shell}{ + language=bash, % the language of the code + basicstyle=\scriptsize\ttfamily, % Without beramono, we'd get cmtt, the teletype font. + showstringspaces=false, % underline spaces within strings + tabsize=2, % sets default tabsize to 2 spaces + captionpos=b, % sets the caption-position to bottom + breaklines=true, % sets automatic line breaking + breakatwhitespace=false, + xleftmargin=1cm, + xrightmargin=1cm, + escapechar=\%, + morekeywords={mkdir, make, ccmake, cmake}, + columns=flexible, + keepspaces=true, + backgroundcolor=\color{shellbg} +} + +\lstdefinelanguage{lmconfig} + {morekeywords={Section,endSection,LET,GEOMETRY,FILTER,KEYWORD,PRINT,FOR,endFOR,range, in}, + sensitive=true, + morecomment=[l]{\#}, + } + +\lstdefinestyle{config}{ + language=lmconfig, % the language of the code + basicstyle=\small\ttfamily, % Without beramono, we'd get cmtt, the teletype font. + commentstyle=\color{commentcolor}\itshape, + keywordstyle=\color{DarkOrchid}\bfseries, + showstringspaces=false, % underline spaces within strings + tabsize=2, % sets default tabsize to 2 spaces + captionpos=b, % sets the caption-position to bottom + breaklines=true, % sets automatic line breaking + breakatwhitespace=false, + xleftmargin=1cm, + xrightmargin=1cm, + escapechar=\%, + morekeywords={mkdir, make, ccmake, cmake}, + columns=flexible, + keepspaces=true, + backgroundcolor=\color{cppbg} +} + +% Set some derived listing environments +\lstnewenvironment{cpp}{\lstset{style=C++}}{} +\lstnewenvironment{lmconfig}{\lstset{style=config}}{} +\lstnewenvironment{command}{\lstset{style=shell}}{} + +% Make sure outputspace is white +\makeatletter +\def\lst@outputspace{{\ifx\lst@bkgcolor\empty\color{white}\else\lst@bkgcolor\fi\lst@visiblespace}} +\makeatother + +% Renow a label in the itemized lists +\renewcommand{\labelitemi}{$\mathbf{\circ}$} + +% Don't care so much about overfull h-boxes +\sloppy + +% Penalty adjusments +%\widowpenalty=10000 % Single lines/word on beginning of page +%\clubpenalty=10000 % Single lines/word at end of page +%\hyphenpenalty=2000 % Hyphenate words +%\tolerance=250 % To adjust the hyphenation of words, increase the tolerance to discourage hyphenation + % the higher the value, the more ugly the gaps between words + % default \tolerance=200 +%\hfuzz=10000pt % threshold when an overfull hbox is reported, default \hfuzz=0.1pt +%\vfuzz=10000pt % threshold to report an overfull vbox, default \vfuzz=0.1pt +%\hbadness=10000 % threshold to report an underfull \hbox +%\vbadness=10000 % threshold to report an underfull \vbox protokolliert wird. +\emergencystretch=0pt % causes a third attempt to fix bad paragraphs and defines a maximum limit to stretch them + +% Insert an empty or a blank page +\newcommand{\insertemptypage}{\newpage\hbox{}\newpage} +\newcommand{\insertblankpage}{\newpage\thispagestyle{empty}\hbox{}\newpage} + +% No page number on an empty page +\let\origdoublepage\cleardoublepage +\newcommand{\clearemptydoublepage}{% + \clearpage + {\thispagestyle{empty}\origdoublepage}% +} +\let\cleardoublepage\clearemptydoublepage + +% A new ruler for in chapters +\newcommand\InChapterRule{\addvspace{\baselineskip}\rule{0.3\linewidth}{0.25pt}} + +% New footnote style +%\def\@fnsymbol#1{\ifcase#1\or *\or \dagger\or \ddagger\or \mathchar "278\or \mathchar "27B\or \|\or **\or \dagger\dagger \or \ddagger\ddagger \else\@ctrerr\fi\relax} +\def\@fnsymbol#1{*\xspace\relax} +\renewcommand{\thefootnote}{\fnsymbol{footnote}} % Symbols rather than numbers +\def\footnoterule{\vspace*{0.5\baselineskip}\InChapterRule\vspace*{0.25\baselineskip}} + +% Improved look of the Table of Contents +\usepackage[nottoc,notbib]{tocbibind} +\usepackage[dotinlabels]{titletoc} +\titlecontents{chapter}[1.4pc] + {\addvspace{0.6pc}\large\bfseries\filright} + {\contentslabel[\thecontentslabel.]{1.4pc}} + {\hspace{-1.4pc}} + {\hfill\contentspage} + [\addvspace{2pt}] +\titlecontents{section}[3.4pc] + {\filright} + {\contentslabel[\thecontentslabel]{2pc}} + {\hspace{-2pc}} + {\titlerule*[6pt]{.}\contentspage} + [] +\titlecontents{subsection}[5.0pc] + {\filright} + {\contentslabel[\thecontentslabel]{2.4pc}} + {} + {\titlerule*[6pt]{.}\contentspage} + [] +\setcounter{tocdepth}{2} +\newcommand\addspaceintoc{\addtocontents{toc}{\protect\addvspace{20pt}}} + +% Change the appearance of the bibliography +%\bibliographystyle{manual-bibliographystyle} +\renewcommand\bibname{References} +\usepackage{cite} % To sort citations: [2,10-14] +\let\oldthebibliography=\thebibliography +\let\endoldthebibliography=\endthebibliography +\renewenvironment{thebibliography}[1] +{ \begin{oldthebibliography}{#1} +% \small + \addcontentsline{toc}{chapter}{\bibname} + \setlength{\labelsep}{2mm} + \setlength{\parskip}{0\baselineskip} + \setlength{\itemsep}{0.24\baselineskip} +} +{ \end{oldthebibliography} } + + +\newcommand{\libmultiscale}{\textit{LibMultiScale}\xspace} + +% Hyperref +\usepackage{url} +\usepackage[pdftex, + bookmarks=true, + bookmarksnumbered=true, + linkbordercolor={1 1 1}, + pdfborder={0 0 0}, + pdfpagemode=UseOutlines +]{hyperref} +\hypersetup{ + pdfauthor={Computational Solid Mechanics Laboratory - EPFL}, + pdftitle={LibMultiScale User's Guide}, + pdfsubject={Open Source Coupling framewwork - \libmultiscale} +} + + diff --git a/doc/manual/manual.tex b/doc/manual/manual.tex new file mode 100644 index 0000000..088d380 --- /dev/null +++ b/doc/manual/manual.tex @@ -0,0 +1,123 @@ +\documentclass[openright,a4paper,9pt,fleqn]{manual} +\usepackage{manual} +\usepackage{manual-macros} + +\setlength{\oddsidemargin}{-1cm} % Marge gauche sur pages impaires +\setlength{\evensidemargin}{-1cm} % Marge gauche sur pages paires +\setlength{\marginparwidth}{0cm} % Largeur de note dans la marge +\setlength{\textwidth}{18cm} % Largeur de la zone de texte (17cm) +\setlength{\marginparsep}{0pt} % Separation de la marge + \setlength\parindent{0pt} + + + + +\newcommand{\keyword}[6]{ + {\bf #1 \index{#1}} #2 (variable: {\it #3} #4,#6) \\ + #5 + \vspace{.2cm} +} + + + +\newcommand{\bloc}[2]{ + \hrule + \vspace{.2cm} + \noindent{\bf #1 }\\ + {#2} + \vspace{.4cm} +} + +%\renewcommand{\section}[1]{ +%\newpage +%\begin{center} +%{\Huge \bf #1} +%\end{center} +%} + +\newcommand{\file}[1]{ + \bloc{File}{#1} +} + +\renewcommand{\description}[1]{ + \bloc{Description}{#1} +} + +\newcommand{\keywordlist}[1]{ + \hrule + \vspace{.2cm} + \noindent{\bf Keywords : } \\ + {#1} + \vspace{.2cm} + \hrule + \vspace{.4cm} +} + +\newcommand{\example}[1]{ + \bloc{Example}{#1} +} + +\newcommand{\heritance}[1]{ + \hrule + \vspace{.2cm} + \noindent{\bf Inherit from} #1 + \vspace{.4cm} +} + +\newcommand{\syntax}[1]{ + \bloc{Syntax}{#1} +} + +\newcommand{\mysection}[3]{ + \section{\index{#2} \label{section:#1} Module \it #2} +} + +\newcommand{\mysubsection}[3]{ + \subsection{\index{#2} \label{#1} #2 (#3)} +} + +\newcommand{\mysubsubsection}[3]{ + \subsubsection{\index{#2} \label{#1} #2 (#3)} +} + + +\input{syntax} + +\author{} +\date{} +\newcommand{\version}{1.2} + +\title{\textbf{\Huge \libmultiscale}\\ + \vspace{0.5cm} + \textbf{\huge User's Guide}\\ + \vspace{1cm} + {\small \today{} --- Version \version} +} + +\makeindex + + + +\begin{document} + +\setcounter{page}{1} +\renewcommand{\thepage}{\roman{page}} + +\pdfbookmark[0]{Titlepage}{maintitlepage} +\label{maintitlepage} +\maketitle +\tableofcontents +\ifodd\value{page} \insertblankpage +\else \insertblankpage\insertblankpage \fi + +\setcounter{page}{1} +\renewcommand\thepage{\arabic{page}} + + +\include{introduction} +\include{chapters} +\chapter{Keywords lexicon \label{chapter:lexicon}} +\input{manual-generated} + +\printindex +\end{document} diff --git a/doc/manual/manual_html.tex b/doc/manual/manual_html.tex new file mode 100644 index 0000000..e868eaf --- /dev/null +++ b/doc/manual/manual_html.tex @@ -0,0 +1,89 @@ +\documentclass{manual} + +\usepackage{manual} +\usepackage{manual-macros} +\usepackage{graphics} +\usepackage{hyperref} +\usepackage{xspace} + +\renewcommand{\libmultiscale}{\textit{LibMultiScale}\xspace} + +\setlength{\oddsidemargin}{-1cm} % Marge gauche sur pages impaires +\setlength{\evensidemargin}{-1cm} % Marge gauche sur pages paires +\setlength{\marginparwidth}{0cm} % Largeur de note dans la marge +\setlength{\textwidth}{18cm} % Largeur de la zone de texte (17cm) +\setlength{\marginparsep}{0pt} % Separation de la marge +\setlength\parindent{0pt} + +\newcommand{\keyword}[6]{ + {\bf #1} #2 (variable: {\it #3} #4,#6)\\ + Description: #5 + \vspace{.2cm} +} + +\newcommand{\bloc}[2]{ + \hrule + \noindent{\bf #1 }\\ + {#2} +} + +\newcommand{\file}[1]{ + \bloc{File}{#1} +} + +\renewcommand{\description}[1]{ + \bloc{Description}{#1} +} + +\newcommand{\keywordlist}[1]{ + \bloc{Keywords}{#1} + \hrule +} + +\newcommand{\example}[1]{ + \bloc{Example}{#1} +} + +\newcommand{\heritance}[1]{ + \hrule + \noindent{\bf Inherit from} #1 +} + +\newcommand{\syntax}[1]{ + \bloc{Syntax}{#1} +} + +\input{syntax} + +\newcommand{\mysection}[3]{ + \section{\label{section:#1} Module \it #2} +} + +\newcommand{\mysubsection}[3]{ + \subsection{\label{#1} #2 (#3)} +} + +\newcommand{\mysubsubsection}[3]{ + \subsubsection{\label{#1} #2 (#3)} +} + +\author{} +\date{} +\newcommand{\version}{1.2} + +\title{\textbf{\huge \it LibMultiScale}\\ + \textbf{User's Guide}\\ + {\small \today{} --- Version \version} +} + + +\makeindex + +\begin{document} + +\maketitle +\include{introduction} +\include{chapters} +\chapter{Keywords lexicon \label{chapter:lexicon}} +\include{manual-generated} +\end{document} diff --git a/doc/manual/syntax.tex b/doc/manual/syntax.tex new file mode 100644 index 0000000..9367612 --- /dev/null +++ b/doc/manual/syntax.tex @@ -0,0 +1,45 @@ +\newcommand{\syntaxamel}[1]{} +\newcommand{\syntaxcommon}[1]{} + +\newcommand{\syntaxgeometry}[1]{ + \syntax{GEOMETRY ID #1 KEYWORD1 key1 KEYWORD2 key2} +} + +\newcommand{\syntaxdumper}[1]{ + \syntax{DUMPER ID #1 INPUT input KEYWORD1 key1 KEYWORD2 key2} +} + +\newcommand{\syntaxstimulation}[1]{ + \syntax{STIMULATION ID #1 INPUT input KEYWORD1 key1 KEYWORD2 key2} +} + + +\newcommand{\syntaxfilter}[1]{ + \syntax{FILTER/COMPUTE ID #1 INPUT input KEYWORD1 key1 KEYWORD2 key2} +} + +\newcommand{\syntaxcoupling}[1]{ + \syntax{COUPLING\_CODE ID CODE1 CODE2 #1 KEYWORD1 key1 KEYWORD2 key22 ... } +} + +\newcommand{\syntaxmodel}[1]{ + \syntax{ + Section MultiScale Units \\ + ... \\ + MODEL #1 ID \\ + ... \\ + endSection + + + Section #1:ID Units \\ + KEYWORD1 .. \\ + KEYWORD2 .. \\ + endSection + } +} + +\newcommand{\syntaxcontinuum}[1]{\syntaxmodel{#1}} +\newcommand{\syntaxmd}[1]{\syntaxmodel{#1}} +\newcommand{\syntaxdd}[1]{\syntaxmodel{#1}} +\newcommand{\syntaxcadd}[1]{} +\newcommand{\syntaxthermalcoupling}[1]{} diff --git a/doc/table-units/Makefile b/doc/table-units/Makefile new file mode 100644 index 0000000..714f1fd --- /dev/null +++ b/doc/table-units/Makefile @@ -0,0 +1,9 @@ +manual: + latex units.tex + dvips -Ppdf -G0 units.dvi -o units.ps +# latex2html -local_icons manual.tex + ps2pdf -dPDFsettings=/prepress units.ps units.pdf + + +clean: + rm -f *.aux *.log *.pdf *.ps *.dvi *.bbl *.blg *.toc *.out* *~ diff --git a/doc/table-units/units.tex b/doc/table-units/units.tex new file mode 100644 index 0000000..f0d1301 --- /dev/null +++ b/doc/table-units/units.tex @@ -0,0 +1,104 @@ +\documentclass[10pt]{article} +\usepackage{graphicx} +\usepackage{graphics} +\usepackage{amsmath} +\usepackage[french]{babel} +\usepackage[latin1]{inputenc} +\title{Unit conversion table for molecular dynamics codes} + +\author{Guillaume ANCIAUX} + +\usepackage{fancyhdr} +\setlength{\hoffset}{-18pt} +\setlength{\oddsidemargin}{0pt} % Marge gauche sur pages impaires +\setlength{\evensidemargin}{9pt} % Marge gauche sur pages paires +\setlength{\marginparwidth}{54pt} % Largeur de note dans la marge +\setlength{\textwidth}{481pt} % Largeur de la zone de texte (17cm) +\setlength{\voffset}{-18pt} % Bon pour DOS +\setlength{\marginparsep}{7pt} % Séparation de la marge +\setlength{\topmargin}{0cm} % Pas de marge en haut +\setlength{\headheight}{0cm} % Haut de page +\setlength{\headsep}{0cm} % Entre le haut de page et le texte +\setlength{\footskip}{1cm} % Bas de page + séparation +\setlength{\textheight}{25cm} % Hauteur de la zone de texte (25cm) +%\pagestyle{fancy} +\fancyhf{} + +\begin{document} +\maketitle +\begin{align*} +1 calorie &= 4.184 Joule\\ +\end{align*} +\begin{align*} +1 Newton &= 1 \frac{Joule}{meter} = 10^{-10} \frac{Joule}{\AA} \\ +&= \frac{10^{-13}}{4.185} \frac{Kcalorie}{\AA}\\ +&= \frac{6.0228}{4.184} 10^{10} \frac{Kcalorie}{mol\cdot\AA}\\ +&= 1.439483747609942639 \cdot 10^{10} \frac{Kcalorie}{mol\cdot\AA}\\ +\end{align*} + +Velocity, mass, time and mass are related through the newton expression: +\begin{align*} +m \dot{v} &= f \\ +1 Kg \cdot 1 meter\cdot second^{-2} &= 1 Newton +\end{align*} +In lammps, the real units are grams/mol for mass, angstroems for distance, femtosecond for time and +Kcalorie/mol-\AA{} for force (unit style : real). Then we can change the relation with: +\begin{align*} +1 Kg \cdot 1 meter\cdot second^{-2} &= 1 Newton \\ +10^3 g \cdot 10^{10} \AA \cdot 10^{-30} fs^{-2} &= 1 Newton \\ +6.0228 \cdot 10^{26} \frac{g}{mol} \cdot 10^{10} \AA \cdot 10^{-30} fs^{-2} &= 1 Newton \\ +6.0228 \cdot 10^{-4} \frac{g}{mol} \cdot 1 \AA \cdot fs^{-2} &= \frac{6.0228}{4.184} 10^{10} \frac{Kcalorie}{mol\cdot\AA}\\ +10^{-4} \frac{g}{mol} \cdot 1 \AA \cdot fs^{-2} &= \frac{10^{10}}{4.184} \frac{Kcalorie}{mol\cdot\AA}\\ +4.184 \cdot 10^{-14} \frac{g}{mol} \cdot 1 \AA \cdot fs^{-2} &= 1 \frac{Kcalorie}{mol\cdot\AA}\\ +\end{align*} +In the context of a velocity update we have: +\begin{align*} +v &= f \cdot m \cdot t \\ +1 meter\cdot second^{-1} &= 1 \frac{Newton}{Kg} \cdot 1 second +\end{align*} +By the same procedure we have: +\begin{align*} +1 meter\cdot second^{-1} &= 1 \frac{Newton}{Kg} \cdot 1 second \\ +10^{10} \AA \cdot 10^{-15} fs^{-1} &= \frac{6.0228}{4.184} 10^{10} \frac{Kcalorie}{mol\cdot\AA } \cdot \frac{1}{Kg} \cdot 1 second \\ +10^{-5} \AA \cdot fs^{-1} &= \frac{6.0228}{4.184} 10^{10} +\frac{Kcalorie}{mol\cdot\AA} \cdot \frac{1}{6.0228 \cdot 10^{26}} \frac{1}{g/mol} \cdot 10^{15} fs \\ +10^{-5} \AA \cdot fs^{-1} &= \frac{1}{4.184} 10^{10} +\frac{Kcalorie}{mol\cdot\AA} \cdot 10^{-26} \frac{1}{g/mol} \cdot 10^{15} fs \\ +10^{-5} \AA \cdot fs^{-1} &= \frac{10^{-1}}{4.184} +\frac{Kcalorie}{mol\cdot\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\underbrace{\frac{4.184}{10^{4}}}_{fmt2v} \AA \cdot fs^{-1} &= \frac{Kcalorie}{mol\cdot\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\end{align*} +Here, $fmt2v$ is a coefficient that is used in lammps and the numercal value is $1/2390.05736137667304$. Exactly the +squared root of this value is used: $\sqrt{fmt2v} = 1/48.88821290839616117$. +If now we might need to convert forces between eV and Kcal/mol/\AA{}. We remind that +\begin{align*} +1 eV &= 1.60218 \cdot 10^{-19} Joule\\ +&= 1.60218 \cdot 10^{-19} \frac{10^{-3}}{4.184} Kcalories \\ +&= \frac{1.60218 \cdot 10^{-22}}{4.184} Kcalories +\end{align*} +Then we have: +\begin{align*} +1 \frac{Kcalorie}{mol\cdot\AA } &= \frac{1}{6.0228 \cdot 10^{23}} \frac{Kcalorie}{\AA} \\ +1 \frac{Kcalorie}{mol\cdot\AA } &= \frac{1}{6.0228 \cdot 10^{23}} \frac{4.184}{1.60218 \cdot 10^{-22}} \frac{eV}{\AA} \\ +1 \frac{Kcalorie}{mol\cdot\AA } &= \underbrace{\frac{4.184}{6.0228 \cdot 16.0218}}_{ev2Kcal/mol/\AA} \frac{eV}{\AA} \\ +\end{align*} +The numerical value for $ev2Kcal/mol/\AA$ is: +$$ev2Kcal/mol/\AA = 0.04335926662676967479$$ +Then the previous relation can be changed as: +\begin{align*} +\AA \cdot fs^{-1} &= \frac{10^{4}}{4.184} \frac{Kcalorie}{mol\cdot\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\AA \cdot fs^{-1} &= \frac{10^{4}}{4.184} \frac{4.184}{6.0228 \cdot 16.0218} \frac{eV}{\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\AA \cdot fs^{-1} &= \frac{10^{4}}{6.0228 \cdot 16.0218} \frac{eV}{\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\AA \cdot fs^{-1} &= 103.6311343852047677 \frac{eV}{\AA} \cdot \frac{1}{g/mol} \cdot fs \\ +\end{align*} + +Now if we consider Kg, \AA{}, and eV as the units: +\begin{align*} +1 meter\cdot second^{-1} &= 1 \frac{Newton}{Kg} \cdot 1 second \\ +10^{-5} \AA \cdot fs^{-1} &= 1 \frac{Joule}{Kg \cdot metre} \cdot 10^{15} fs \\ +10^{-5} \AA \cdot fs^{-1} &= 10^{15} \cdot 10^{-10} \frac{Joule}{Kg \cdot \AA} \cdot fs \\ +10^{-10} \AA \cdot fs^{-1} &= \frac{1}{1.60218 \cdot 10^{-19}} \frac{eV}{Kg \cdot \AA} \cdot fs \\ +1.60218 \cdot 10^{-29} \AA \cdot fs^{-1} &= 1 \frac{eV}{Kg \cdot \AA} \cdot fs \\ +\end{align*} + +\end{document} diff --git a/get_release_info.sh b/get_release_info.sh new file mode 100644 index 0000000..ec1d4ed --- /dev/null +++ b/get_release_info.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +uuencode=$1 +if [ -d ".svn" ] ; +then + svn diff > $2/release.patch + svn --verbose status > $2/full-revision-detail.txt + echo "#include " + echo "std::string lm_release_info = \" \\n \\" + svn info | sed s/\"/\\\\\"/g | sed s/\\\*/\\\\\*/g | sed 's/$/ \\n\\/' + #svn diff | sed "s/\\\\/\\\\\\\\/" | sed s/\"/\\\\\"/g | sed 's/$/ \\n \\/' | sed "s/\\\\\*/\\\\\\\\*/g" | sed "s/\\\\\//\\\\\\\\\//g" + $uuencode -m $2/release.patch release.patch | sed 's/$/ \\n\\/' + echo "\\" + $uuencode -m $2/full-revision-detail.txt full-revision-detail.txt | sed 's/$/ \\n\\/' + echo "\\" + $uuencode -m $2/CMakeCache.txt CMakeCache.txt | sed 's/$/ \\n\\/' + echo "\";" +fi +if [ -d ".git" ] ; +then + git diff > $2/release.patch + echo "#include " + echo "std::string lm_release_info = \"\\n\\" +# hostname | sed 's/$/ \\n\\/' +# git rev-parse --show-toplevel | sed 's/$/\\n\\/' + branch=$(git rev-parse --abbrev-ref --verify origin) + echo "$branch \\n\\" + git rev-parse --verify $branch | sed 's/$/\\n\\/' + git remote -v | sed 's/$/ \\n\\/' + echo "\\n\\" + $uuencode -m $2/release.patch release.patch | sed 's/$/\\n\\/' + echo "\\" + $uuencode -m $2/CMakeCache.txt CMakeCache.txt | sed 's/$/\\n\\/' + echo "\";" +fi + diff --git a/packages/akantu.cmake b/packages/akantu.cmake new file mode 100644 index 0000000..e8922d9 --- /dev/null +++ b/packages/akantu.cmake @@ -0,0 +1,123 @@ +#=============================================================================== +# @file akantu.cmake +# +# @author Guillaume Anciaux +# @author Till Junge +# @author Nicolas Richart +# +# @date Tue Jul 22 14:47:56 2014 +# +# @brief Akantu package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +if(EXISTS ${PROJECT_SOURCE_DIR}/third-party/akantu) + option(LIBMULTISCALE_USE_AKANTU "Plugin Akantu for continuum" FALSE) + if(LIBMULTISCALE_USE_AKANTU) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_AKANTU ${AKANTU_DEFINITIONS}) + set(AKANTU_TARGETS_EXPORT LibMultiScaleLibraryDepends) + + set(AKANTU_DISABLE_CPACK ON) + set(AKANTU_USE_IOHELPER OFF CACHE BOOL "iohelper option in Akantu" FORCE) + set(AKANTU_PARALLEL ON CACHE BOOL "Add parallel support in Akantu" FORCE) + + set(AKANTU_CORE_CXX11 OFF CACHE BOOL "core package for Akantu" FORCE) + + # set the needed option to ON. Anciaux, do NOT comment this again + set(AKANTU_IMPLICIT ON CACHE BOOL "Add the implicit support for Akantu" FORCE) + + add_subdirectory(third-party/akantu) + + get_cmake_property(_cache_variables CACHE_VARIABLES) + + # Set all akantu options as off and mark them as advanced + mark_as_advanced(Akantu_DIR) + foreach(_var ${_cache_variables}) + if(_var MATCHES "^AKANTU_") + mark_as_advanced(${_var}) + get_property(_variable_type CACHE ${_var} PROPERTY TYPE) + if("${_variable_type}" STREQUAL "BOOL") + get_property(_variable_desc CACHE ${_var} PROPERTY HELPSTRING) +# set(${_var} OFF CACHE BOOL ${_variable_desc} FORCE) + endif() + endif() + endforeach() + + + + list(APPEND LIBMULTISCALE_EXTERNAL_LIBRARIES akantu) + list(APPEND LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR ${AKANTU_INCLUDE_DIRS}) + set(LIBMULTISCALE_AKANTU_INCLUDE_DIR ${AKANTU_INCLUDE_DIRS}) + + list(APPEND LIBMULTISCALE_EXPORT_LIST akantu) + #list(APPEND LIBMULTISCALE_EXPORT_LIST iohelper) + list(APPEND LIBMULTISCALE_OPTION_LIST AKANTU) + + if(AKANTU_EXCLUDE_SOURCE_FILES) + set(_tmp "third-party/akantu/src/${AKANTU_EXCLUDE_SOURCE_FILES}") + string(REPLACE ";" ";third-party/akantu/src/" _tmp "${_tmp}") + list(APPEND _tmp ${LIBMULTISCALE_EXCLUDE_SOURCE_FILES}) + set(LIBMULTISCALE_EXCLUDE_SOURCE_FILES ${_tmp} CACHE INTERNAL "") + endif() + + list(APPEND LIBMULTISCALE_TESTS_EXCLUDE_FILES ${AKANTU_TESTS_EXCLUDE_FILES}) + list(APPEND LIBMULTISCALE_DOC_EXCLUDE_FILES ${AKANTU_DOC_EXCLUDE_FILES}) + + set(LIBMULTISCALE_AKANTU ON) + else() + set(LIBMULTISCALE_AKANTU OFF) + endif() +else() + add_optional_external_package(Akantu "Plugin Akantu for continuum" TRUE FOUND Akantu) +endif() + +set(LIBMULTISCALE_CONTINUUM_HDRS_LIST_AKANTU + continuum/akantu/domain_akantu.hh + continuum/akantu/domain_akantu_dynamic.hh + continuum/akantu/domain_akantu_static.hh + continuum/akantu/domain_akantu_compound.hh + ) + +set(LIBMULTISCALE_AKANTU_FILES + ${LIBMULTISCALE_CONTINUUM_HDRS_LIST_AKANTU} + continuum/akantu/domain_akantu.cc + continuum/akantu/domain_akantu_dynamic.cc + continuum/akantu/domain_akantu_static.cc + continuum/akantu/domain_akantu_compound.cc + continuum/akantu/iterator_akantu.cc + continuum/akantu/akantu_dof_wrapper.hh + continuum/akantu/akantu_dof_wrapper.cc + continuum/akantu/ref_elem_akantu.hh + continuum/akantu/ref_elem_akantu.cc + continuum/akantu/vec_akantu.hh + continuum/akantu/ref_node_akantu.hh + continuum/akantu/ref_node_akantu.cc + continuum/akantu/container_akantu.hh + continuum/akantu/container_akantu.cc + continuum/akantu/iterator_akantu.hh + ) + +set(LIBMULTISCALE_CONTINUUM_MODEL_LIST_AKANTU + "((DomainAkantuCompound<1>,1,AKANTU))" + "((DomainAkantuCompound<2>,2,AKANTU))" + "((DomainAkantuCompound<3>,3,AKANTU))" + ) + diff --git a/packages/blackdynamite.cmake b/packages/blackdynamite.cmake new file mode 100644 index 0000000..9c3ba55 --- /dev/null +++ b/packages/blackdynamite.cmake @@ -0,0 +1,44 @@ +#=============================================================================== +# @file blackdynamite.cmake +# +# @author Guillaume Anciaux +# +# @date Fri Nov 08 11:28:32 2013 +# +# @brief Blackdynamite parametric studies packages +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +add_optional_external_package(BlackDynamite "Plugin Akantu for continuum" FALSE FOUND BlackDynamite_FOUND) + +set(LIBMULTISCALE_DUMPER_HDRS_LIST_BLACKDYNAMITE + dumper/dumper_blackdynamite.hh + ) + +set(LIBMULTISCALE_BLACKDYNAMITE_FILES + ${LIBMULTISCALE_DUMPER_HDRS_LIST_BLACKDYNAMITE} + dumper/dumper_blackdynamite.cc + ) + +set(LIBMULTISCALE_DUMPER_REAL_INPUT_LIST_BLACKDYNAMITE + "((DumperBlackDynamite,BLACKDYNAMITE))" + ) +mark_as_advanced(LIBMULTISCALE_USE_BLACKDYNAMITE) \ No newline at end of file diff --git a/packages/boost.cmake b/packages/boost.cmake new file mode 100644 index 0000000..5531401 --- /dev/null +++ b/packages/boost.cmake @@ -0,0 +1,29 @@ +#=============================================================================== +# @file boost.cmake +# +# @author Nicolas Richart +# +# @date Thu Dec 20 17:16:00 2012 +# +# @brief Boost library package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + diff --git a/packages/core.cmake b/packages/core.cmake new file mode 100644 index 0000000..5e431a0 --- /dev/null +++ b/packages/core.cmake @@ -0,0 +1,223 @@ +#=============================================================================== +# @file core.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Oct 13 10:50:54 2014 +# +# @brief Core package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_CORE TRUE) + +set(LIBMULTISCALE_CONTINUUM_HDRS_LIST_CORE + common/container_mesh.hh +) + +set(LIBMULTISCALE_GEOMETRY_HDRS_LIST_CORE + geometry/geom_inter.hh + geometry/cylinder.hh + geometry/geometry.hh + geometry/geom_sub.hh + geometry/geom_composed.hh + geometry/chaudron.hh + geometry/ellipsoid.hh + geometry/cube.hh + geometry/geom_union.hh + geometry/ball.hh + geometry/cube_surface.hh + ) + +set(LIBMULTISCALE_CORE_FILES + ${LIBMULTISCALE_DD_HDRS_LIST_CORE} + + common/lm_file.hh + common/lm_file.cc + common/lm_fwd.hh + common/lm_libc.cc + common/action_interface.cc + common/action_interface.hh + common/visitor_libmultiscale.hh + common/model_list.hh + common/id_manager.hh + common/lm_log.hh + common/lm_log.cc + common/lm_ostream_types.hh + common/lm_macros.hh + common/lm_types.hh + common/lm_globals.hh + common/lm_globals.cc + common/lm_common.hh + common/domain_interface.hh + common/domain_interface.cc + common/ref_subset.cc + common/ref_subset.hh + common/ref_set.cc + common/ref_set.hh + common/reference_manager.cc + common/reference_manager.hh + common/reference_manager_interface.hh + common/attached_object.hh + common/ref_point.hh + common/ref_point_data.hh + common/component_libmultiscale.hh + common/lm_functions.cc + common/lm_functions.hh + common/lm_timer.cc + common/lm_timer.hh + + parser/lm_parser.cc + parser/lm_parser_inline_impl.hh + parser/parse_result.hh + parser/xml_parser_restart.cc + parser/algebraic_parser.cc + parser/lm_parsable.cc + parser/xml_parser_restart.hh + parser/lm_parsable.hh + parser/lm_parsable_inline_impl.hh + parser/algebraic_parser.hh + parser/xml_parser.hh + parser/lm_parser.hh + parser/lm_parameter.hh + parser/lm_defaults.hh + + ${LIBMULTISCALE_MD_HDRS_LIST_CORE} + md/domain_md_interface.hh + md/spatial_filter_atomic.cc + md/domain_md.cc + md/trace_atom.cc + md/domain_md_interface.cc + md/container_neighbor_atoms.hh + md/trace_atom.hh + md/domain_md.hh + md/spatial_filter_atomic.hh + md/ref_atom.hh + md/container_neighbor_atoms_interface.hh + md/domain_md_interface.hh + + ${LIBMULTISCALE_GEOMETRY_HDRS_LIST_CORE} + geometry/geometry_manager.cc + geometry/spatial_grid_libmultiscale.hh + geometry/geometry_manager.hh + geometry/spatial_grid.hh + geometry/spatial_grid.cc + geometry/geometry.cc + geometry/cube.cc + geometry/ball.cc + geometry/cylinder.cc + geometry/geom_inter.cc + geometry/geom_sub.cc + geometry/geom_union.cc + geometry/geom_composed.cc + geometry/surface.hh + geometry/surface.cc + geometry/cube_surface.cc + + ${LIBMULTISCALE_CONTINUUM_HDRS_LIST_CORE} + continuum/domain_continuum.cc + continuum/domain_continuum_interface.cc + continuum/ref_node_continuum.hh + continuum/domain_continuum.hh + continuum/ref_element.hh + continuum/domain_continuum_interface.hh + + ${LIBMULTISCALE_DD_HDRS_LIST_CORE} + dd/domain_dd_interface.hh + dd/domain_dd.hh + dd/domain_dd.cc + dd/domain_dd_interface.cc + dd/container_dd.hh + dd/ref_node_dd.hh + + factory/domain_multiscale.cc + factory/factory_multiscale_inline_impl.hh + factory/factory_multiscale.cc + factory/factory_multiscale.hh + factory/domain_multiscale.hh + factory/action_manager.hh + factory/filter_manager.hh + factory/action_manager.cc + factory/filter_manager.cc + + units/units.hh + units/units.cc + units/units_converter.hh + units/units_converter.cc + units/quantity.hh + + communicator/comm_buffer.hh + communicator/communicator_distributed.hh + communicator/communicator_unity.hh + communicator/communicator.hh + communicator/communicator.cc + communicator/pack_buffer.hh + communicator/communicator_mpi_linear.hh + communicator/communicator_mpi_linear.cc + communicator/communicator_world.hh + + container/container_array.hh + container/iterator_array_base_type.hh + container/container.hh + container/iterator_array.hh + + fmm/fmm_multigrid.hh + fmm/fmm_interface.hh + fmm/moments.hh + fmm/fmm.hh + fmm/radial_function.hh + + math/low_pass_filter.hh + math/cubic_spline.hh + math/full_matrix.hh + math/full_matrix_inline_impl.hh + math/function_interface.hh + math/band_matrix.hh + math/hanning_window.hh + math/constant_function.hh + math/gaussian_function.hh + math/array.hh + math/array.cc + math/product_function.hh + math/dispersion_relation.hh + math/spline_function.hh + math/diag_matrix.hh + math/tensor.hh + math/hamming_window.hh + math/math_tools.hh + math/math_tools.cc + math/matrix.c + math/matrix.hh + math/matrix_blaswrapper.h + + boost/for_each2.hpp +) + +set(LIBMULTISCALE_GEOMETRY_LIST_CORE + "((Cylinder,CYLINDER))" + "((Cube,CUBE))" + "((Ball,BALL))" + "((GeomSub,SUB))" + "((GeomInter,INTER))" + "((GeomUnion,UNION))" + "((CubeSurface,CUBE_SURFACE))" + ) diff --git a/packages/coupling.cmake b/packages/coupling.cmake new file mode 100644 index 0000000..6681ee1 --- /dev/null +++ b/packages/coupling.cmake @@ -0,0 +1,72 @@ +#=============================================================================== +# @file coupling.cmake +# +# @author Guillaume Anciaux +# +# @date Tue Feb 05 10:37:52 2013 +# +# @brief Coupling package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_COUPLING TRUE) + +set(LIBMULTISCALE_COUPLER_HDRS_LIST_COUPLING + coupling/xiao.hh + coupling/kobayashi.hh + ) + + +set(LIBMULTISCALE_COUPLING_FILES + ${LIBMULTISCALE_COUPLER_HDRS_LIST_COUPLING} + coupling/dof_association.cc + coupling/kobayashi.cc + coupling/xiao.cc + coupling/bridging_atomic_continuum.cc + coupling/duo_distributed_vector.cc + coupling/coupler_manager.cc + coupling/arlequin_template.cc + coupling/bridging.cc + coupling/coupler_manager.hh + coupling/arlequin_template.hh + coupling/shape_matrix.hh + coupling/coupling.hh + coupling/lib_bridging.hh + coupling/bridging_atomic_continuum.hh + coupling/weighting.hh + coupling/dof_association.hh + coupling/bridging.hh + coupling/coupling_interface.hh + coupling/bridging_par.hh + coupling/coupling_atomic_continuum.hh + coupling/coupling_dd_continuum.hh + coupling/coupling_dd_md.hh + coupling/duo_distributed_vector.hh +) + +set(LIBMULTISCALE_COUPLER_LIST_COUPLING + "((Xiao,XIAO,ATOMTYPE,CONTINUUMTYPE))" + "((Kobayashi,KOBAYASHI,ATOMTYPE,CONTINUUMTYPE))" + ) + +# "((Thermal,THERMAL,ATOMTYPE,CONTINUUMTYPE))" +# "((ThermalPar,THERMALPAR,ATOMTYPE,CONTINUUMTYPE))" +# "((Adaptive,ADAPTIVE,ATOMTYPE,CONTINUUMTYPE))" \ No newline at end of file diff --git a/packages/dumpers.cmake b/packages/dumpers.cmake new file mode 100644 index 0000000..a80f69e --- /dev/null +++ b/packages/dumpers.cmake @@ -0,0 +1,95 @@ +#=============================================================================== +# @file dumpers.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Thu Sep 18 16:13:26 2014 +# +# @brief Dumper package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_DUMPERS TRUE) + +set(LIBMULTISCALE_DUMPER_HDRS_LIST_DUMPERS + dumper/dumper.hh + dumper/dumper_1d.hh + dumper/dumper_ekin.hh + dumper/dumper_epot.hh + dumper/dumper_grid.hh + dumper/dumper_lammps.hh + dumper/dumper_paraview.hh + dumper/dumper_restart.hh + dumper/dumper_text.hh + ) + +set(LIBMULTISCALE_DUMPERS_FILES + ${LIBMULTISCALE_DUMPER_HDRS_LIST_DUMPERS} + + dumper/dumper_interface.hh + + dumper/dumper.cc + dumper/dumper_dd_paraview.cc + dumper/dumper_paraview_atom.cc + dumper/dumper_paraview_mesh.cc + dumper/dumper_paraview.cc + + dumper/dumper_1d.cc + dumper/dumper_ekin.cc + dumper/dumper_epot.cc + dumper/dumper_grid.cc + dumper/dumper_lammps.cc + dumper/dumper_restart.cc + dumper/dumper_text.cc + + dumper/paraview_helper.hh + dumper/base64_reader.hh + dumper/base64_writer.hh + +# dumper/dumper_call_accept.hh +) + +set(LIBMULTISCALE_DUMPER_REF_INPUT_LIST_DUMPERS + "((DumperParaview,PARAVIEW))" + "((Dumper1D,DUMPER1D))" + "((DumperEKin,EKIN))" + "((DumperEPot,EPOT))" + "((DumperGrid,GRID))" + "((DumperLammps,LAMMPS))" + "((DumperRestart,RESTART))" + ) + +set(LIBMULTISCALE_DUMPER_REAL_INPUT_LIST_DUMPERS + "((DumperText,TEXT))" + ) + +# ((DumperXYZ,XYZ)) +# ((DumperVGroup,VGROUPE)) +# ((DumperReduce,REDUCE)) +# ((DumperReduce,REDUCE)) +# ((DumperUser,USER)) +# ((DumperGlobalStat,GLOBALSTAT)) +# ((DumperContact,CONTACT)) +# ((DumperNeighbor,NEIGHBOR)) +# ((DumperCountPoints,COUNTPOINTS)) +#LIBMULTISCALE_USE_FIG -> DumperFig,DUMPERFIG +#LIBMULTISCALE_USE_EPSN -> DumperEpsn,EPSN diff --git a/packages/filters.cmake b/packages/filters.cmake new file mode 100644 index 0000000..e1a1d0e --- /dev/null +++ b/packages/filters.cmake @@ -0,0 +1,134 @@ +#=============================================================================== +# @file filters.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Thu Sep 18 16:13:26 2014 +# +# @brief Filter package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_FILTERS TRUE) + +set(LIBMULTISCALE_FILTER_HDRS_LIST_FILTERS + filter/compute_centro_symmetry.hh + filter/compute_ekin.hh + filter/compute_energydensity.hh + filter/compute_epot.hh + filter/compute_extract.hh + filter/compute_python.hh + filter/compute_reduce.hh + filter/compute_impulse.hh + filter/compute_combine.hh + filter/compute_concat.hh + filter/compute_true_displacement.hh + filter/compute_point_set.hh + filter/compute_mesh.hh + filter/compute_time_average.hh + filter/compute_time_delta.hh + filter/filter.hh + filter/filter_dislo.hh + filter/filter_geometry.hh + filter/compute_periodic_position.hh + filter/filter_threshold.hh + filter/compute_addpoints.hh + filter/compute_add_ddloop.hh + ) + +set(LIBMULTISCALE_FILTERS_FILES + ${LIBMULTISCALE_FILTER_HDRS_LIST_FILTERS} + filter/accept_compute_include.hh + filter/accept_filter_include.hh + filter/accept_real_compute.hh + filter/accept_ref_compute.hh + filter/accept_ref_filter.hh + filter/compute.cc + filter/compute_interface.hh + filter/compute.hh + filter/compute_centro_symmetry.cc + filter/compute_ekin.cc + filter/compute_ekin_mesh.cc + filter/compute_ekin_point.cc + filter/compute_energydensity.cc + filter/compute_epot.cc + filter/compute_epot_point.cc + filter/compute_epot_mesh.cc + filter/compute_extract.cc + filter/compute_extract_point.cc + filter/compute_extract_mesh.cc + filter/compute_python.cc + filter/compute_reduce.cc + filter/compute_impulse.cc + filter/compute_combine.cc + filter/compute_concat.cc + filter/compute_true_displacement.cc + filter/compute_point_set.cc + filter/compute_mesh.cc + filter/filter.cc + filter/filter_compatibility.hh + filter/filter_dislo.cc + filter/filter_geometry.cc + filter/filter_geometry_mesh.cc + filter/filter_geometry_points.cc + filter/filter_interface.hh + filter/null_compute.hh + filter/compute_compatibility.hh + filter/compute_compatibility.hh + filter/compute_time_average.cc + filter/compute_time_delta.cc + filter/compute_periodic_position.cc + filter/filter_threshold.cc + filter/compute_addpoints.cc + filter/compute_add_ddloop.cc + ) + +set(LIBMULTISCALE_FILTER_LIST_FILTERS + "((FilterGeometry,GEOM))" + "((FilterDislo,DISLO))" + "((FilterThreshold, THRESHOLD))" + ) + +set(LIBMULTISCALE_COMPUTE_REF_INPUT_LIST_FILTERS + "((ComputeCentroSymmetry,CENTRO))" + "((ComputeEKin,EKIN))" + "((ComputeEnergyDensity,ENERGY_DENSITY))" + "((ComputeExtract,EXTRACT))" + "((ComputeEPot,EPOT))" + "((ComputeImpulse,IMPULSE))" + "((ComputeTrueDisplacement,TRUEDISP))" + "((ComputePeriodicPosition,PERIODICPOSITION))" + "((ComputeMesh,MESH))" + ) + +set(LIBMULTISCALE_COMPUTE_REAL_INPUT_LIST_FILTERS + "((ComputeReduce,REDUCE))" + "((ComputePython,PYTHON))" + "((ComputeCombine,COMBINE))" + "((ComputeConcat,CONCAT))" + "((ComputePointSet,POINTSET))" + "((ComputeTimeAverage,TIMEAVG))" + "((ComputeTimeDelta,TIMEDELTA))" + "((ComputeAddPoints,ADDPOINTS))" + "((ComputeAddDDLoop,ADD_DDLOOP))" + ) + diff --git a/packages/lammps.cmake b/packages/lammps.cmake new file mode 100644 index 0000000..93cec3e --- /dev/null +++ b/packages/lammps.cmake @@ -0,0 +1,115 @@ +#=============================================================================== +# @file lammps.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Oct 28 19:23:14 2013 +# +# @brief LAMMPS package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +if(EXISTS ${PROJECT_SOURCE_DIR}/third-party/lammps) + option(LIBMULTISCALE_USE_LAMMPS "Plugin LAMMPS for MD" FALSE) + + + if(LIBMULTISCALE_USE_LAMMPS) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_LAMMPS) + set(LAMMPS_TARGETS_EXPORT LibMultiScaleLibraryDepends) + + if (LIBMULTISCALE_USE_ZLIB) + option(LAMMPS_ZLIB "Activate the ZLIB compression feature" ON) + endif() + add_subdirectory(third-party/lammps) + + set_target_properties(lmp_${LAMMPS_ARCH} + PROPERTIES COMPILE_FLAGS "-w") + + foreach(_var ${_cache_variables}) + if(_var MATCHES "^LAMMPS_") + mark_as_advanced(${_var}) + endif() + endforeach() + + list(APPEND LIBMULTISCALE_EXTERNAL_LIBRARIES lmp_${LAMMPS_ARCH}) + list(APPEND LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR ${LAMMPS_INCLUDE_DIRS}) + set(LIBMULTISCALE_LAMMPS_INCLUDE_DIR ${LAMMPS_INCLUDE_DIRS}) + + list(APPEND LIBMULTISCALE_EXPORT_LIST lmp_${LAMMPS_ARCH} meam) + list(APPEND LIBMULTISCALE_OPTION_LIST LAMMPS) + + set(LIBMULTISCALE_LAMMPS ON) + else() + set(LIBMULTISCALE_LAMMPS OFF) + endif() +else() + add_optional_external_package(LAMMPS "Plugin LAMMPS for MD" FALSE FOUND LAMMPS) +endif() + +set(LIBMULTISCALE_MD_HDRS_LIST_LAMMPS + md/lammps/domain_lammps_compound.hh + ) + +#set(LIBMULTISCALE_FILTER_HDRS_LIST_LAMMPS +#md/lammps/compute_lammps.hh +#) + +set(LIBMULTISCALE_LAMMPS_FILES + ${LIBMULTISCALE_MD_HDRS_LIST_LAMMPS} + ${LIBMULTISCALE_FILTER_HDRS_LIST_LAMMPS} + md/lammps/domain_lammps_dynamic.hh + md/lammps/domain_lammps_minimize.hh + md/lammps/container_lammps.hh + md/lammps/domain_lammps.cc + md/lammps/domain_lammps.hh + md/lammps/domain_lammps_dynamic.cc + md/lammps/domain_lammps_minimize.cc + md/lammps/domain_lammps_compound.cc + md/lammps/epot_hook.hh + md/lammps/epot_hook.cc + md/lammps/import_lammps.cc + md/lammps/import_lammps.hh + md/lammps/iterator_lammps.cc + md/lammps/iterator_lammps.hh + md/lammps/lammps_common.hh + md/lammps/ref_atom_lammps.hh + md/lammps/reference_manager_lammps.cc + md/lammps/reference_manager_lammps.hh + md/lammps/stress_hook.hh + md/lammps/stress_hook.cc + md/lammps/compute_lammps.cc + md/lammps/compute_lammps.hh +) + + +set(LIBMULTISCALE_ATOM_MODEL_LIST_LAMMPS + "((DomainLammpsCompound<2>,2,LAMMPS))" + "((DomainLammpsCompound<3>,3,LAMMPS))" + ) + +#set(LIBMULTISCALE_COMPUTE_REF_INPUT_LIST_LAMMPS +# "((ComputeLammps,LAMMPS))" +# ) + + +#(DomainLammpsMinimize<2>,2,LAMMPSMIN) +#(DomainLammpsMinimize<3>,3,LAMMPSMIN) diff --git a/packages/mandatory_packages.cmake b/packages/mandatory_packages.cmake new file mode 100644 index 0000000..412d135 --- /dev/null +++ b/packages/mandatory_packages.cmake @@ -0,0 +1,69 @@ +#=============================================================================== +# @file mandatory_packages.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Wed Mar 06 12:17:42 2013 +# +# @brief All mandatory packages +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_MANDATORY_PACKAGES TRUE) + +add_external_package(MPI) + +add_external_package(Boost PREFIX Boost) +list(APPEND LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src) +list(APPEND LIBMULTISCALE_BOOST_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/boost) + +#Not using the macro because the python module is shity +find_package(PythonLibs REQUIRED 2.7) +if(PYTHONLIBS_FOUND) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_PYTHON) + list(APPEND LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) + list(APPEND LIBMULTISCALE_EXTERNAL_LIBRARIES ${PYTHON_LIBRARIES}) + + set(LIBMULTISCALE_PYTHON_INCLUDE_DIR ${PYTHON_INCLUDE_DIR}) + set(LIBMULTISCALE_PYTHON_LIBRARIES ${PYTHON_LIBRARIES}) + set(LIBMULTISCALE_PYTHON ON) + + list(APPEND LIBMULTISCALE_OPTION_LIST PYTHON) +endif() + +add_external_package(FFTW) +add_external_package(GSL) +add_external_package(LAPACK) +add_external_package(EXPAT) +add_optional_external_package(QVIEW "Activate the QView monitoring feature" OFF) +if (LIBMULTISCALE_USE_QVIEW) + add_definitions(-DUSING_QVIEW) +endif(LIBMULTISCALE_USE_QVIEW) +mark_as_advanced(LIBMULTISCALE_USE_QVIEW) + +add_optional_external_package(ZLIB "Activate the ZLIB compression feature" OFF) +if (LIBMULTISCALE_USE_ZLIB) + add_definitions(-DLIBMULTISCALE_USE_ZLIB) +endif(LIBMULTISCALE_USE_ZLIB) + +mark_as_advanced(MPI_EXTRA_LIBRARY) +mark_as_advanced(MPI_LIBRARY) diff --git a/packages/md1d.cmake b/packages/md1d.cmake new file mode 100644 index 0000000..a85a1e2 --- /dev/null +++ b/packages/md1d.cmake @@ -0,0 +1,55 @@ +#=============================================================================== +# @file md1d.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Sun Jan 06 01:16:34 2013 +# +# @brief 1D moleculardynamics package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +option(LIBMULTISCALE_MD1D "Plugin for MD 1D code" OFF) + +if(LIBMULTISCALE_MD1D) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_MD1D) +endif() + +set(LIBMULTISCALE_MD_HDRS_LIST_MD1D + md/1d/domain_md1d.hh + ) + +set(LIBMULTISCALE_MD1D_FILES + ${LIBMULTISCALE_MD_HDRS_LIST_MD1D} + md/1d/container_md1d.hh + md/1d/domain_md1d.cc + md/1d/iterator_md1d.cc + md/1d/iterator_md1d.hh + md/1d/md_builder.cc + md/1d/md_builder.hh + md/1d/ref_atom_md1d.hh + md/1d/reference_manager_md1d.hh + ) + +set(LIBMULTISCALE_ATOM_MODEL_LIST_MD1D + "((DomainMD1D,1,MD1D))" + ) diff --git a/packages/meca1d.cmake b/packages/meca1d.cmake new file mode 100644 index 0000000..12249d1 --- /dev/null +++ b/packages/meca1d.cmake @@ -0,0 +1,55 @@ +#=============================================================================== +# @file meca1d.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Mon Oct 28 19:23:14 2013 +# +# @brief FE1D package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +option(LIBMULTISCALE_MECA1D "Plugin using internal continuum 1D code for continuum simulations" OFF) + +if(LIBMULTISCALE_MECA1D) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_MECA1D) +endif() + +set(LIBMULTISCALE_CONTINUUM_HDRS_LIST_MECA1D + continuum/1d/domain_meca1d.hh + ) + +set(LIBMULTISCALE_MECA1D_FILES + ${LIBMULTISCALE_CONTINUUM_HDRS_LIST_MECA1D} + continuum/1d/domain_meca1d.cc + continuum/1d/iterator_meca1d.cc + continuum/1d/ref_node_meca1d.hh + continuum/1d/mesh_meca1d.hh + continuum/1d/mesh_meca1d.cc + continuum/1d/container_meca1d.hh + continuum/1d/iterator_meca1d.hh + continuum/1d/ref_elem_meca1d.hh + ) + +set(LIBMULTISCALE_CONTINUUM_MODEL_LIST_MECA1D + "((DomainMeca1D,1,MECA1D))" + ) diff --git a/packages/paradis.cmake b/packages/paradis.cmake new file mode 100644 index 0000000..4db4c89 --- /dev/null +++ b/packages/paradis.cmake @@ -0,0 +1,81 @@ +#=============================================================================== +# @file paradis.cmake +# +# @author Guillaume Anciaux +# @author Till Junge +# @author Nicolas Richart +# @author Moseley Philip Arthur +# +# @date Fri Jul 11 15:47:44 2014 +# +# @brief ParaDiS package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +if(EXISTS ${PROJECT_SOURCE_DIR}/third-party/paradis) + option(LIBMULTISCALE_USE_PARADIS "Plugin ParaDiS as DD code" FALSE) + + if(LIBMULTISCALE_USE_PARADIS) + list(APPEND LIBMULTISCALE_DEFINITIONS LIBMULTISCALE_USE_PARADIS PARADIS_IN_LIBMULTISCALE PARADIS_DISPLACEMENTS) + set(PARADIS_TARGETS_EXPORT LibMultiScaleLibraryDepends) + set(PARADIS_IN_LIBMULTISCALE ON CACHE BOOL "Specify paradis that he is used inside of libmultiscale" FORCE) + set(PARADIS_DISPLACEMENTS ON CACHE BOOL "Enable calculation of displacements in paradis" FORCE) + add_subdirectory(third-party/paradis) + + set_target_properties(ParaDiS + PROPERTIES COMPILE_FLAGS "-w") + + foreach(_var ${_cache_variables}) + if(_var MATCHES "^PARADIS_") + mark_as_advanced(${_var}) + endif() + endforeach() + + list(APPEND LIBMULTISCALE_EXTERNAL_LIBRARIES ParaDiS) + list(APPEND LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR ${PARADIS_INCLUDE_DIRS}) + set(LIBMULTISCALE_PARADIS_INCLUDE_DIR ${PARADIS_INCLUDE_DIRS}) + + list(APPEND LIBMULTISCALE_EXPORT_LIST ParaDiS) + list(APPEND LIBMULTISCALE_OPTION_LIST PARADIS) + + set(LIBMULTISCALE_PARADIS ON) + else() + set(LIBMULTISCALE_PARADIS OFF) + endif() +else() + add_optional_external_package(ParaDiS "Plugin for PARADIS as DD code" OFF) +endif() + +set(LIBMULTISCALE_DD_HDRS_LIST_PARADIS + dd/paradis/domain_paradis.hh + ) + +set(LIBMULTISCALE_PARADIS_FILES + ${LIBMULTISCALE_DD_HDRS_LIST_PARADIS} + dd/paradis/domain_paradis.cc + dd/paradis/iterator_paradis.hh + dd/paradis/container_paradis.hh + dd/paradis/ref_node_paradis.hh + ) + +set(LIBMULTISCALE_DD_MODEL_LIST_PARADIS + "((DomainPARADIS,3,PARADIS))" + ) diff --git a/packages/python.cmake b/packages/python.cmake new file mode 100644 index 0000000..37c3759 --- /dev/null +++ b/packages/python.cmake @@ -0,0 +1,29 @@ +#=============================================================================== +# @file python.cmake +# +# @author Nicolas Richart +# +# @date Thu Dec 20 17:16:00 2012 +# +# @brief Python package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + diff --git a/packages/stimulations.cmake b/packages/stimulations.cmake new file mode 100644 index 0000000..704b50e --- /dev/null +++ b/packages/stimulations.cmake @@ -0,0 +1,100 @@ +#=============================================================================== +# @file stimulations.cmake +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Thu Sep 18 16:13:26 2014 +# +# @brief Stimulations package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +set(LIBMULTISCALE_STIMULATIONS TRUE) + +set(LIBMULTISCALE_STIMULATION_HDRS_LIST_STIMULATIONS + stimulation/stimulation.hh + stimulation/stimulation_addforce.hh + stimulation/stimulation_berendsen.hh + stimulation/stimulation_dislo.hh + stimulation/stimulation_field.hh + stimulation/stimulation_global_timestep.hh + stimulation/stimulation_next_event.hh + stimulation/stimulation_next_event.cc + + stimulation/stimulation_impulse.hh + stimulation/stimulation_langevin.hh + stimulation/stimulation_linearmomentum.hh + stimulation/stimulation_raz.hh + stimulation/stimulation_rigidify.hh + stimulation/stimulation_temperature.hh + stimulation/stimulation_veluni.hh + stimulation/stimulation_block.hh + ) + +set(LIBMULTISCALE_STIMULATIONS_FILES + ${LIBMULTISCALE_STIMULATION_HDRS_LIST_STIMULATIONS} + stimulation/accept_ref_stimulation.hh + stimulation/accept_real_stimulation.hh + stimulation/accept_stimulation_include.hh + + stimulation/stimulation_interface.hh + + stimulation/stimulation.cc + stimulation/stimulation_global_timestep.cc + stimulation/stimulation_berendsen.cc + stimulation/stimulation_dislo.cc + stimulation/stimulation_field.cc + stimulation/stimulation_field_point.cc + stimulation/stimulation_field_mesh.cc + stimulation/stimulation_impulse.cc + stimulation/stimulation_langevin.cc + stimulation/stimulation_linearmomentum.cc + stimulation/stimulation_raz.cc + stimulation/stimulation_rigidify.cc + stimulation/stimulation_temperature.cc + stimulation/stimulation_temperature_point.cc + stimulation/stimulation_temperature_mesh.cc + stimulation/stimulation_veluni.cc + stimulation/stimulation_addforce.cc + + stimulation/stimulation_block.cc + ) + +set(LIBMULTISCALE_STIMULATION_REF_INPUT_LIST_STIMULATIONS + "((StimulationBerendsen,BERENDSEN))" + "((StimulationDislo,DISLO))" + "((StimulationImpulse,IMPULSE))" + "((StimulationRAZ,RAZ))" + "((StimulationTemperature,TEMPERATURE))" + "((StimulationField,FIELD))" + "((StimulationLangevin,LANGEVIN))" + "((StimulationLinearMomentum, LINEAR_MOMENTUM))" + "((StimulationAddForce,ADDFORCE))" + "((StimulationVelUni,VELUNI))" + "((StimulationGlobalTimeStep,GLOBAL_TIMESTEP))" + "((StimulationRigidify,RIGIDIFY))" + "((StimulationBlock, BLOCK))" + ) + +set(LIBMULTISCALE_STIMULATION_REAL_INPUT_LIST_STIMULATIONS + "((StimulationNextEvent,NEXT_EVENT))" +) diff --git a/packages/timer.cmake b/packages/timer.cmake new file mode 100644 index 0000000..222b08e --- /dev/null +++ b/packages/timer.cmake @@ -0,0 +1,36 @@ +#=============================================================================== +# @file timer.cmake +# +# @author Guillaume Anciaux +# +# @date Mon Jul 28 12:20:03 2014 +# +# @brief Timer package +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +option(LIBMULTISCALE_TIMER "Enable timing of functions" OFF) + +if (LIBMULTISCALE_TIMER) + add_definitions(-DLIBMULTISCALE_TIMER) +endif(LIBMULTISCALE_TIMER) + +mark_as_advanced(LIBMULTISCALE_TIMER) \ No newline at end of file diff --git a/packages/trace_atom.cmake b/packages/trace_atom.cmake new file mode 100644 index 0000000..4ebf8ff --- /dev/null +++ b/packages/trace_atom.cmake @@ -0,0 +1,36 @@ +#=============================================================================== +# @file trace_atom.cmake +# +# @author Guillaume Anciaux +# +# @date Mon Jul 28 12:20:03 2014 +# +# @brief Debugging tool for tracing packages +# +# @section LICENSE +# +# Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) +# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) +# +# LibMultiScale is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. +# +# LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with LibMultiScale. If not, see . +# +#=============================================================================== + +option(LIBMULTISCALE_TRACE_ATOM "Enable system for tracing of atoms" OFF) + +if (LIBMULTISCALE_TRACE_ATOM) + add_definitions(-DTRACE_ATOM) +endif(LIBMULTISCALE_TRACE_ATOM) + +mark_as_advanced(LIBMULTISCALE_TRACE_ATOM) \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..bb5bbf8 --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,134 @@ +#=============================================================================== +# @file CMakeLists.txt +# +# @author Guillaume Anciaux +# @author Nicolas Richart +# +# @date Wed Apr 03 23:50:25 2013 +# +# @brief This is the main CMake configuration file for LM library +# +# @section LICENSE +# +# Copyright INRIA and CEA +# +# The LibMultiScale is a C++ parallel framework for the multiscale +# coupling methods dedicated to material simulations. This framework +# provides an API which makes it possible to program coupled simulations +# and integration of already existing codes. +# +# This Project was initiated in a collaboration between INRIA Futurs Bordeaux +# within ScAlApplix team and CEA/DPTA Ile de France. +# The project is now continued at the Ecole Polytechnique Fédérale de Lausanne +# within the LSMS/ENAC laboratory. +# +# This software is governed by the CeCILL-C license under French law and +# abiding by the rules of distribution of free software. You can use, +# modify and/ or redistribute the software under the terms of the CeCILL-C +# license as circulated by CEA, CNRS and INRIA at the following URL +# "http://www.cecill.info". +# +# As a counterpart to the access to the source code and rights to copy, +# modify and redistribute granted by the license, users are provided only +# with a limited warranty and the software's author, the holder of the +# economic rights, and the successive licensors have only limited +# liability. +# +# In this respect, the user's attention is drawn to the risks associated +# with loading, using, modifying and/or developing or reproducing the +# software by the user in light of its specific status of free software, +# that may mean that it is complicated to manipulate, and that also +# therefore means that it is reserved for developers and experienced +# professionals having in-depth computer knowledge. Users are therefore +# encouraged to load and test the software's suitability as regards their +# requirements in conditions enabling the security of their systems and/or +# data to be ensured and, more generally, to use and operate it in the +# same conditions as regards security. +# +# The fact that you are presently reading this means that you have had +# knowledge of the CeCILL-C license and that you accept its terms. +# +#=============================================================================== + +generate_source_list_from_packages(${CMAKE_CURRENT_SOURCE_DIR} + LIBMULTISCALE_SRCS + LIBMULTISCALE_INLINE_SRCS + LIBMULTISCALE_HDRS + LIBMULTISCALE_INCLUDE_DIRS) + +list(APPEND LIBMULTISCALE_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}) + +set(_lists_list + atom_model + compute_real_input + compute_ref_input + compute_ref_output + continuum_model + coupler + dd_model + dumper_real_input + dumper_ref_input + filter + stimulation_ref_input + stimulation_real_input + geometry + ) + +foreach(__list ${_lists_list}) + generate_list(${__list} ${CMAKE_CURRENT_BINARY_DIR}/${__list}_list.hh) + list(APPEND LIBMULTISCALE_LIST_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${__list}_list.hh) +endforeach() + +set(_hdrs_lists_list + continuum + dd + dumper + filter + md + stimulation + geometry + coupler + ) + +foreach(_hdrs_list ${_hdrs_lists_list}) + generate_module_header_file(${_hdrs_list} ${CMAKE_CURRENT_BINARY_DIR}/lib_${_hdrs_list}.hh) + list(APPEND LIBMULTISCALE_LIST_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/lib_${_hdrs_list}.hh) +endforeach() + +set(LIBMULTISCALE_INCLUDE_DIRS ${LIBMULTISCALE_INCLUDE_DIRS} PARENT_SCOPE) +set(LIBMULTISCALE_SRCS ${LIBMULTISCALE_SRCS} PARENT_SCOPE) +set(LIBMULTISCALE_HDRS ${LIBMULTISCALE_HDRS} PARENT_SCOPE) +set(LIBMULTISCALE_INLINE_SRCS ${LIBMULTISCALE_INLINE_SRCS} PARENT_SCOPE) + +include_directories(${LIBMULTISCALE_INCLUDE_DIRS} ${LIBMULTISCALE_EXTERNAL_LIB_INCLUDE_DIR}) + +foreach(_dep ${LIBMULTISCALE_DEFINITIONS}) + add_definitions(-D${_dep}) +endforeach() + +add_library(multiscale ${LIBMULTISCALE_SRCS} ${LIBMULTISCALE_INLINE_SRCS}) +target_link_libraries(multiscale ${LIBMULTISCALE_EXTERNAL_LIBRARIES} rt) + +if(LIBMULTISCALE_LIBRARY_PROPERTIE) + set_target_properties(multiscale PROPERTIES ${LIBMULTISCALE_LIBRARY_PROPERTIES}) +endif() + +set(LIBMULTISCALE_PUBLIC_HEADERS ${LIBMULTISCALE_HDRS} ${LIBMULTISCALE_LIST_HEADERS}) +set_target_properties(multiscale PROPERTIES PUBLIC_HEADER "${LIBMULTISCALE_PUBLIC_HEADERS}") + +list(APPEND LIBMULTISCALE_EXPORT_LIST multiscale) + +install(TARGETS multiscale + EXPORT LibMultiScaleLibraryDepends + LIBRARY DESTINATION lib COMPONENT lib + ARCHIVE DESTINATION lib COMPONENT lib + PUBLIC_HEADER DESTINATION include/libmultiscale/ COMPONENT dev + ) + +install(EXPORT LibMultiScaleLibraryDepends DESTINATION lib/libmultiscale + COMPONENT dev) + +#Export for build tree +export(TARGETS ${LIBMULTISCALE_EXPORT_LIST} + FILE "${CMAKE_BINARY_DIR}/LibMultiScaleLibraryDepends.cmake") +export(PACKAGE LibMultiScale) diff --git a/src/boost/for_each2.hpp b/src/boost/for_each2.hpp new file mode 100644 index 0000000..b34eb94 --- /dev/null +++ b/src/boost/for_each2.hpp @@ -0,0 +1,55 @@ +# /* ************************************************************************** +# * * +# * (C) Copyright Paul Mensonides 2002. +# * Modified by Guillaume Anciaux +# * Distributed under the Boost Software License, Version 1.0. (See +# * accompanying file LICENSE_1_0.txt or copy at +# * http://www.boost.org/LICENSE_1_0.txt) +# * * +# ************************************************************************** */ +# +# /* See http://www.boost.org for most recent version. */ +# +# ifndef BOOST_PREPROCESSOR_SEQ_FOR_EACH2_HPP +# define BOOST_PREPROCESSOR_SEQ_FOR_EACH2_HPP +# +# include +# +# /* BOOST_PP_SEQ_FOR_EACH2 */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FOR_EACH2(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil)), BOOST_PP_SEQ_FOR_EACH2_P, BOOST_PP_SEQ_FOR_EACH2_O, BOOST_PP_SEQ_FOR_EACH2_M) +# else +# define BOOST_PP_SEQ_FOR_EACH2(macro, data, seq) BOOST_PP_SEQ_FOR_EACH2_D(macro, data, seq) +# define BOOST_PP_SEQ_FOR_EACH2_D(macro, data, seq) BOOST_PP_FOR((macro, data, seq (nil)), BOOST_PP_SEQ_FOR_EACH2_P, BOOST_PP_SEQ_FOR_EACH2_O, BOOST_PP_SEQ_FOR_EACH2_M) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH2_P(r, x) BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(BOOST_PP_TUPLE_ELEM(3, 2, x))) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_SEQ_FOR_EACH2_O(r, x) BOOST_PP_SEQ_FOR_EACH2_O_I x +# else +# define BOOST_PP_SEQ_FOR_EACH2_O(r, x) BOOST_PP_SEQ_FOR_EACH2_O_I(BOOST_PP_TUPLE_ELEM(3, 0, x), BOOST_PP_TUPLE_ELEM(3, 1, x), BOOST_PP_TUPLE_ELEM(3, 2, x)) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH2_O_I(macro, data, seq) (macro, data, BOOST_PP_SEQ_TAIL(seq)) +# +# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT() +# define BOOST_PP_SEQ_FOR_EACH2_M(r, x) BOOST_PP_SEQ_FOR_EACH2_M_IM(r, BOOST_PP_TUPLE_REM_3 x) +# define BOOST_PP_SEQ_FOR_EACH2_M_IM(r, im) BOOST_PP_SEQ_FOR_EACH2_M_I(r, im) +# else +# define BOOST_PP_SEQ_FOR_EACH2_M(r, x) BOOST_PP_SEQ_FOR_EACH2_M_I(r, BOOST_PP_TUPLE_ELEM(3, 0, x), BOOST_PP_TUPLE_ELEM(3, 1, x), BOOST_PP_TUPLE_ELEM(3, 2, x)) +# endif +# +# define BOOST_PP_SEQ_FOR_EACH2_M_I(r, macro, data, seq) macro(r, data, BOOST_PP_SEQ_HEAD(seq)) +# +# /* BOOST_PP_SEQ_FOR_EACH2_R */ +# +# if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG() +# define BOOST_PP_SEQ_FOR_EACH2_R(r, macro, data, seq) BOOST_PP_FOR_ ## r((macro, data, seq (nil)), BOOST_PP_SEQ_FOR_EACH2_P, BOOST_PP_SEQ_FOR_EACH2_O, BOOST_PP_SEQ_FOR_EACH2_M) +# else +# define BOOST_PP_SEQ_FOR_EACH2_R(r, macro, data, seq) BOOST_PP_SEQ_FOR_EACH2_R_I(r, macro, data, seq) +# define BOOST_PP_SEQ_FOR_EACH2_R_I(r, macro, data, seq) BOOST_PP_FOR_ ## r((macro, data, seq (nil)), BOOST_PP_SEQ_FOR_EACH2_P, BOOST_PP_SEQ_FOR_EACH2_O, BOOST_PP_SEQ_FOR_EACH2_M) +# endif +# +# endif diff --git a/src/common/action_interface.cc b/src/common/action_interface.cc new file mode 100644 index 0000000..3732145 --- /dev/null +++ b/src/common/action_interface.cc @@ -0,0 +1,198 @@ +/** + * @file action_interface.cc + * + * @author Guillaume Anciaux + * @author Till Junge + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the interface to all action objects + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include "action_interface.hh" +#include "filter_interface.hh" +#include "factory_multiscale.hh" + +__BEGIN_LIBMULTISCALE__ + +/* -------------------------------------------------------------------------- */ +ActionInterface::ActionInterface(const std::string & name){ + setDefaults(); + this->ID = name; +} +/* -------------------------------------------------------------------------- */ + +void ActionInterface::printself(std::ostream & stream, int indent) const{ + stream << "Action " << ID << " " + << "action_step " << action_step << " " + << "start_step " << start_step << " " + << "end_step " << end_step << " " + << "frequency " << frequency << " " + << "name " << ID << std::endl; +} + +/* -------------------------------------------------------------------------- */ + +void ActionInterface::setDefaults(){ + action_step = 0; + frequency = 1; + start_step = 0; + end_step = UINT_MAX; + one_shot = UINT_MAX; +} +/* -------------------------------------------------------------------------- */ + +bool ActionInterface::shouldMakeAction(){ + if ((current_stage == PRE_FATAL) && (stage_mask & PRE_FATAL) ) + return true; + bool sM = doesStageMaskMatch(); + if (!sM) return false; + + setOneStep(); + + DUMP("for action " << ID << " freq " << frequency << " step " + << action_step,DBG_INFO); + if (end_step >= current_step && start_step <= current_step) + if (frequency != UINT_MAX && current_step%frequency == 0){ + DUMP("should proceed action " << ID + << " current_step = " << current_step + << " start " << start_step + << " end " << end_step,DBG_INFO); + return true; + } + return false; +} + +/* -------------------------------------------------------------------------- */ + +void ActionInterface::setOneStep(){ + +if (one_shot != UINT_MAX) + end_step = start_step = one_shot; + +} + +/* -------------------------------------------------------------------------- */ + + +bool ActionInterface::doesStageMaskMatch(){ + if (stage_mask.isNone()) stage_mask = PRE_STEP1; + if (!(stage_mask & current_stage)) return false; + return true; +} + +/* -------------------------------------------------------------------------- */ + +void ActionInterface::action(){ + ++action_step; +} +/* -------------------------------------------------------------------------- */ + +/* LMDESC ActionInterface + This describe the generic keywords which all actions + inheritate from. +*/ + +void ActionInterface::declareParams(){ + + /* LMKEYWORD FREQ + Fix the frequency at which action should be called + */ + this->parseKeyword("FREQ",frequency,1u); + + /* LMKEYWORD START + Fix the first step at which action should start + */ + this->parseKeyword("START",start_step,0u); + /* LMKEYWORD END + Fix the last step at which action should be performed + */ + this->parseKeyword("END",end_step,lm_uint_max); + /* LMKEYWORD ONESHOT + Set the action to be called only at a given step. + */ + this->parseKeyword("ONESHOT",one_shot,lm_uint_max); + + /* LMKEYWORD STAGE + Set the stage within generic explicit integration scheme at + which the action should be called. The possible values are: + \begin{itemize} + \item PRE\_DUMP + \item PRE\_STEP1 + \item PRE\_STEP2 + \item PRE\_STEP3 + \item PRE\_STEP4 + \item PRE\_STEP5 + \item PRE\_STEP6 + \item PRE\_STEP7 + \end{itemize} + + The keyword STAGE can be called more than once and the result will be a bit-mask value + so that an action can be called at several stages within a given timestep.\\ + + These stages are identified depending on the implemented integration scheme. + For instance the classical Verlet integration scheme is coded in a loop in the + AMEL executable as follows: + + \textit{ + for (current\_step = 0; current\_step < nb\_step ; ++current\_step, current\_time += dt) \\ + \{ \\ + ~~... \\ + \\ + ~~stimulator.stimulate(PRE\_DUMP);\\ + \\ + ~~dumper.dump();\\ + \\ + ~~stimulator.stimulate(PRE\_STEP1);\\ + \\ + ~~dom.performStep1();\\ + ~~dom.coupling(COUPLING\_STEP1);\\ + \\ + ~~stimulator.stimulate(PRE\_STEP2);\\ + \\ + ~~dom.performStep2();\\ + ~~dom.coupling(COUPLING\_STEP2);\\ + \\ + ~~stimulator.stimulate(PRE\_STEP3);\\ + ~~dom.performStep3();\\ + \\ + ~~dom.coupling(COUPLING\_STEP3);\\ + ~~stimulator.stimulate(PRE\_STEP4);\\ + ~~dom.coupling(COUPLING\_STEP4);\\ + \\ + ~~...\\ + \}\\ + } + + For a classical Verlet integration scheme performStep1() is the initial velocity and + position update, performStep2() is the force computation, and performStep3() is the + velocity correction. + */ + + this->parseKeyword("STAGE",stage_mask,NONE_STEP); + +} +/* -------------------------------------------------------------------------- */ + + +__END_LIBMULTISCALE__ diff --git a/src/common/action_interface.hh b/src/common/action_interface.hh new file mode 100644 index 0000000..ce5efe2 --- /dev/null +++ b/src/common/action_interface.hh @@ -0,0 +1,126 @@ +/** + * @file action_interface.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the interface to all action objects + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_ACTION_INTERFACE_HH__ +#define __LIBMULTISCALE_ACTION_INTERFACE_HH__ +/* -------------------------------------------------------------------------- */ +#include "lm_parsable.hh" +#include "component_libmultiscale.hh" +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +class ActionInterface : + public Parsable { + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ +public: + + ActionInterface(const std::string & name); + virtual ~ActionInterface(){}; + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ +public: + + //! this function holds to possible restriction to action calls + virtual bool shouldMakeAction(); + //! do the action effectively + virtual void action(); + //! initialisation of the action internal data + virtual void init(){}; + //! set parameters + virtual void declareParams(); + +protected: + + //! this function check for the stage mask + bool doesStageMaskMatch(); + //! set start and end step when onestep is declared + void setOneStep(); + + /* ------------------------------------------------------------------------ */ + /* Accessors */ + /* ------------------------------------------------------------------------ */ +public: + + //! set default values + void setDefaults(); + ///! set the mask + // void setStageMask(UInt mask){stage_mask = mask;}; + ///! get the mask + //IntegrationSchemeMask & getStageMask(){return stage_mask;}; + + //! function to print the contain of the class + virtual void printself(std::ostream & stream, int indent = 0) const; + + //! return the name of the action + const std::string & getID(){return ID;}; + //! set the name of the action + void setID(const std::string & n){ID = n;}; + + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + +protected: + //! actual dump step + UInt action_step; + //! start step + UInt start_step; + //! end step + UInt end_step; + //! one shot + UInt one_shot; + //! frequency of the dump + UInt frequency; + +private: + + //! ID of the action + std::string ID; + //! stage mask to explicitly specify at what place in the scheme to do the action + IntegrationSchemeMask stage_mask; + +}; + +/* -------------------------------------------------------------------------- */ + +inline std::ostream& operator << (std::ostream& os,ActionInterface &obj){ + obj.printself(os); + return os; +} +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_ACTION_INTERFACE_HH__ */ diff --git a/src/common/attached_object.hh b/src/common/attached_object.hh new file mode 100644 index 0000000..21ca68f --- /dev/null +++ b/src/common/attached_object.hh @@ -0,0 +1,100 @@ +/** + * @file attached_object.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This object is used to describe objects attached to containers of references + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_ATTCHED_OBJECT_HH__ +#define __LIBMULTISCALE_ATTCHED_OBJECT_HH__ +/* -------------------------------------------------------------------------- */ +#include "pack_buffer.hh" +/* -------------------------------------------------------------------------- */ + + +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + + +class AttachedObject { + +public: + + virtual ~AttachedObject(){}; + + virtual void packData(UInt index,PackBuffer & buffer,UInt toproc)=0; + virtual void unpackData(UInt index,PackBuffer & buffer,UInt fromproc)=0; + virtual void moveAttachedValues(UInt i_src,UInt i_dest)=0; + virtual void resize(UInt sz) {LM_TOIMPLEMENT;}; +}; + +/* -------------------------------------------------------------------------- */ +template +class AttachedVector : public AttachedObject { + +public: + + AttachedVector(std::vector & vector, UInt nb_components): + AttachedObject(),v(vector),stride(nb_components){}; + + virtual ~AttachedVector(){}; + + void packData(UInt index,PackBuffer & buffer,UInt proc){ + for (UInt i = 0 ; i < stride ; ++i){ + buffer << v[stride*index+i]; + } + } + void unpackData(UInt index,PackBuffer & buffer,UInt proc){ + if (index*stride >= v.size()) v.resize(stride*(index+1)); + for (UInt i = 0 ; i < stride ; ++i){ + buffer >> v[stride*index+i]; + } + } + void moveAttachedValues(UInt i_src,UInt i_dest){ + for (UInt i = 0 ; i < stride ; ++i){ + v[stride*i_dest+i] = v[stride*i_src+i]; + } + } + + void resize(UInt sz){ + DUMP(&v << " resizes from " << v.size() + << " to " << sz*stride,DBG_DETAIL); + + v.resize(sz*stride); + } + + std::vector & getV(){return v;}; + +private : + std::vector & v; + UInt stride; +}; +/* -------------------------------------------------------------------------- */ + + + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_ATTCHED_OBJECT_HH__ */ diff --git a/src/common/component_libmultiscale.hh b/src/common/component_libmultiscale.hh new file mode 100644 index 0000000..c3c321c --- /dev/null +++ b/src/common/component_libmultiscale.hh @@ -0,0 +1,270 @@ +/** + * @file component_libmultiscale.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This describe the root objects to be combined into valid LM components + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_COMPONENT_LIBMULTISCALE_HH__ +#define __LIBMULTISCALE_COMPONENT_LIBMULTISCALE_HH__ + +__BEGIN_LIBMULTISCALE__ + +struct ComponentNull{}; + +class ComponentLMInterface{ + +public: + + ComponentLMInterface():input(NULL){}; + + ComponentLMInterface(ComponentLMInterface & input):input(&input),dim(input.getDim()){}; + ComponentLMInterface(UInt dim):input(NULL),dim(dim){}; + + UInt getDim(){LM_ASSERT(dim,"dimension was not set by the visitable object");return dim;}; + void setDim(UInt d){dim = d;}; + + virtual void accept(ComponentLMInterface & visitor){LM_TOIMPLEMENT;}; + + ComponentLMInterface * getInput(){return input;}; + +protected: + + ComponentLMInterface * input; + + UInt dim; + +}; + +/* -------------------------------------------------------------------------- */ +template class ComponentLMOut; + +template +class ComponentLMIn: + public virtual ComponentLMInterface { + +public: + + ComponentLMIn(UInt dim){this->dim = dim;}; + ComponentLMIn(ComponentLMInterface & input){ + this->input = &input; + this->dim = input.getDim(); + }; + ComponentLMIn(ComponentLMInterface & input, UInt dim){ + this->input = &input; + this->dim = dim; + }; + + virtual void visit(ComponentLMOut<_Input> & obj) = 0; + + typedef _Input Input; + + +}; + +/* -------------------------------------------------------------------------- */ + +template +class ComponentLMOut : + public virtual ComponentLMInterface { + +public: + + ComponentLMOut(UInt dim){this->dim = dim;}; + ComponentLMOut(ComponentLMInterface & input){this->input = &input;}; + ComponentLMOut(ComponentLMInterface & input, UInt dim){ + this->input = &input; + this->dim = dim; + }; + + virtual void accept(ComponentLMInterface & visitor){ + //test the input of the visitor + if (ComponentLMIn<_Output> * ptr + = dynamic_cast *>(&visitor)){ + //if good, first build myself + this->build(); + //then allow the visitor to visit me + ptr->visit(*this); + } + }; + + typedef _Output Output; + + virtual void build() = 0; + + virtual _Output & getOutput(){return *output;}; + + operator _Output & (){return getOutput();}; + + void setOutput(_Output & _output){ + output = &_output; + }; + +private: + + _Output * output; + +}; + +/* -------------------------------------------------------------------------- */ + +template +class ComponentLMOutTyped : + public ComponentLMOut<_Output> { + +public: + + ComponentLMOutTyped(UInt dim) + :ComponentLMOut<_Output>(dim){}; + + ComponentLMOutTyped(ComponentLMInterface & input) + :ComponentLMOut<_Output>(input){}; + + ComponentLMOutTyped(ComponentLMInterface & input, UInt dim) + :ComponentLMOut<_Output>(input,dim){}; + + static const COutputType output_type = _type; + +}; + +/* -------------------------------------------------------------------------- */ + +template +class ComponentLMOutContainer : + public ComponentLMOutTyped<_Output,type>, + public _Output +{ + +public: + + ComponentLMOutContainer(UInt dim) + :ComponentLMOutTyped<_Output,type>(dim){}; + + ComponentLMOutContainer(ComponentLMInterface & input) + :ComponentLMOutTyped<_Output,type>(input){}; + + ComponentLMOutContainer(ComponentLMInterface & input, UInt dim) + :ComponentLMOutTyped<_Output,type>(input,dim){}; + + virtual _Output & getOutput(){return *this;}; + +}; +/* -------------------------------------------------------------------------- */ + + + +template +class ComponentLMTemplate : + public Comp_Input, + public Comp_Output +{ + +public: + + ComponentLMTemplate(UInt dim): + ComponentLMInterface(dim), + Comp_Input(dim), + Comp_Output(dim) + {}; + + ComponentLMTemplate(ComponentLMInterface & input): + ComponentLMInterface(input), + Comp_Input(input), + Comp_Output(input) + {}; + + ComponentLMTemplate(ComponentLMInterface & input,UInt dim): + ComponentLMInterface(input), + Comp_Input(input,dim), + Comp_Output(input,dim) + {}; + + virtual ~ComponentLMTemplate(){}; + +}; + +/* -------------------------------------------------------------------------- */ + +template +class ComponentLM : + public ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutTyped<_Output,type> > { + +public: + + ComponentLM(ComponentLMInterface & input):ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutTyped<_Output,type> >(input){}; + + ComponentLM(ComponentLMInterface & input, UInt dim):ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutTyped<_Output,type> >(input,dim){}; + + ComponentLM(UInt dim):ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutTyped<_Output,type> >(dim){}; + + + virtual ~ComponentLM(){}; + +}; + +/* -------------------------------------------------------------------------- */ + + +template +class ComponentLMContainer : + public ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutContainer<_Output,type> > { + +public: + + ComponentLMContainer(ComponentLMInterface & input): + ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutContainer<_Output,type> >(input){}; + + ComponentLMContainer(ComponentLMInterface & input, UInt dim): + ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutContainer<_Output,type> >(input,dim){}; + + ComponentLMContainer(UInt dim): + ComponentLMTemplate< + ComponentLMIn<_Input>, + ComponentLMOutContainer<_Output,type> >(dim){}; + + virtual ~ComponentLMContainer(){}; + +}; + + +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_COMPONENT_LIBMULTISCALE_HH__ */ diff --git a/src/common/container_mesh.hh b/src/common/container_mesh.hh new file mode 100644 index 0000000..0218005 --- /dev/null +++ b/src/common/container_mesh.hh @@ -0,0 +1,252 @@ +/** + * @file container_mesh.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the abstract container for mesh data + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_CONTAINER_MESH_HH__ +#define __LIBMULTISCALE_CONTAINER_MESH_HH__ +/* -------------------------------------------------------------------------- */ +#include "container.hh" +#include "container_array.hh" +#include "ref_point_data.hh" +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +template +class ContainerMesh : public Container_base { + /* ------------------------------------------------------------------------ */ + /* Typedefs */ + /* ------------------------------------------------------------------------ */ + +public: + + typedef ContNodes ContainerNodes; + typedef ContElems ContainerElems; + + typedef typename ContNodes::iterator iterator; + typedef typename ContNodes::Ref Ref; + + typedef typename ContElems::Ref RefElem; + + typedef ContainerMesh, ContainerArray > ContainerSubset; + + static const UInt Dim = ContainerNodes::Dim; + + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ +public: + + ContainerMesh(ContNodes & cN, ContElems & cEl); + ContainerMesh(); + virtual ~ContainerMesh(); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ +public: + + void incRelease(){ + Container_base::incRelease(); + container_nodes->incRelease(); + container_elems->incRelease(); + }; + + void setRelease(UInt rel){ + Container_base::setRelease(rel); + container_nodes->setRelease(rel); + container_elems->setRelease(rel); + }; + + operator ContainerNodes & (){ + LM_FATAL("silent conversion from ContainerMesh to ContainerNode is not allowed"); + return *container_nodes; + } + + iterator getIterator(DOFType dt = dt_local){return container_nodes->getIterator(dt);}; + + void add(Ref & node) { + container_nodes->add(node); + } + + Ref & get(UInt index) { + return container_nodes->get(index); + } + + void empty(){ + container_nodes->empty(); + container_elems->empty(); + } + + UInt nbElem(DOFType dt = dt_local){ + return container_nodes->nbElem(dt); + }; + + template + void computeAlteredConnectivity(ContNodesPristine & contNodes); + + /* ------------------------------------------------------------------------ */ + /* Accessors */ + /* ------------------------------------------------------------------------ */ +public: + + ContNodes & getArray(){return this->getContainerNodes();}; + + ContNodes & getContainerNodes(){return *container_nodes;}; + ContElems & getContainerElems(){return *container_elems;}; + + UInt subIndex2Index(UInt index){ + LM_ASSERT(nodeIndexList.nbElem() > 0, + "nodeIndexList was not initialized: did you call " + << "computeAlteredConnectivity method ?"); + + return nodeIndexList.searchInSorted(index); + }; + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ +private: + + ContNodes * container_nodes; + ContElems * container_elems; + + ContainerArray nodeIndexList; + + bool self_allocated; +}; + +/* -------------------------------------------------------------------------- */ + +template +ContainerMesh::ContainerMesh(ContNodes & cN, ContElems & cEl): + container_nodes(&cN),container_elems(&cEl){ + self_allocated = false; +} +/* -------------------------------------------------------------------------- */ + +template +ContainerMesh::ContainerMesh(): + container_nodes(new ContNodes()),container_elems(new ContElems()){ + self_allocated = true; +} +/* -------------------------------------------------------------------------- */ + +template +ContainerMesh::~ContainerMesh(){ + if (self_allocated){ + delete (container_nodes); + delete (container_elems); + } +} +/* -------------------------------------------------------------------------- */ + +template +template +void ContainerMesh:: +computeAlteredConnectivity(ContNodesPristine & contNodes){ + + std::vector connectivity; + typename ContElems::iterator itElem = container_elems->getIterator(); + + for(typename ContElems::Ref el = itElem.getFirst() ; + !itElem.end() ; el = itElem.getNext()) { + + el.globalIndexes(connectivity); + for(UInt n = 0; n < connectivity.size() ; ++n) + nodeIndexList.addInSorted(connectivity[n]); + } + + ContainerArray::iterator itNdIndex = nodeIndexList.getIterator(); + + for (UInt n_index = itNdIndex.getFirst(); + !itNdIndex.end() ; + n_index = itNdIndex.getNext()){ + + container_nodes->add(contNodes.get(n_index)); + } + + //recompute the connectivity + std::vector altered_connectivity; + + for (UInt i = 0; i < container_elems->nbElem(); ++i) { + typename ContainerElems::Ref & el = container_elems->get(i); + el.globalIndexes(connectivity); + altered_connectivity.resize(connectivity.size()); + for(UInt n = 0; n < connectivity.size() ; ++n) + altered_connectivity[n] = nodeIndexList.searchInSorted(connectivity[n]); + + el.setAlteredConnectivity(altered_connectivity); + } +} +/* -------------------------------------------------------------------------- */ + +class RefGenericElem { + + /* ------------------------------------------------------------------------ */ + /* Typedefs */ + /* ------------------------------------------------------------------------ */ + +public: + + static const UInt Dim = 3; + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + +public: + + void setConnectivity(Real * conn, UInt nb_nodes_per_element){ + this->conn.resize(nb_nodes_per_element); + for (UInt i = 0; i < nb_nodes_per_element; ++i) { + this->conn[i] = conn[i]; + } + + } + + bool operator == (RefGenericElem & e){LM_TOIMPLEMENT;return true;}; + + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + + //private: + + std::vector conn; +}; + +typedef ContainerMesh, + ContainerArray > ContainerGenericMesh; + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_CONTAINER_MESH_HH__ */ + + diff --git a/src/common/domain_interface.cc b/src/common/domain_interface.cc new file mode 100644 index 0000000..1f16b57 --- /dev/null +++ b/src/common/domain_interface.cc @@ -0,0 +1,181 @@ +/** + * @file domain_interface.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:45:56 2014 + * + * @brief This is the interface to all domain (model/plugins) + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include "domain_interface.hh" +#include "cube.hh" +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + + +DomainInterface::DomainInterface(DomainID id,CommGroup gid){ + this->id = id; + group_id = gid; + restartfile = ""; +} +/* -------------------------------------------------------------------------- */ +DomainInterface::DomainInterface(UInt Dim){ + this->id = "MULTISCALE"; + group_id = group_all; + restartfile = ""; +} +/* -------------------------------------------------------------------------- */ +DomainInterface::DomainInterface(){ + this->id = "MULTISCALE"; + group_id = group_all; + restartfile = ""; +} +/* -------------------------------------------------------------------------- */ + +DomainInterface::~DomainInterface(){ + +} + +/* -------------------------------------------------------------------------- */ + +Real DomainInterface::getEpot(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ +void DomainInterface::performStep1(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ + +void DomainInterface::performStep2(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ + +void DomainInterface::performStep3(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ +void DomainInterface::performStep4(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ +void DomainInterface::performStep5(){ + LM_TOIMPLEMENT; +} +/* -------------------------------------------------------------------------- */ + +UInt DomainInterface::getType(){ + return type; +} +/* -------------------------------------------------------------------------- */ + +CommGroup DomainInterface::getGroupID(){ + return group_id; +} +/* -------------------------------------------------------------------------- */ + +DomainID DomainInterface::getID(){ + return id; +} +/* -------------------------------------------------------------------------- */ + +void DomainInterface::setID(const DomainID & name){ + id = name; +} +/* -------------------------------------------------------------------------- */ + +void DomainInterface::getDomainDimensions(Cube & bbox){ + Real xmin[3]; + Real xmax[3]; + getDomainDimensions(xmin,xmax); + bbox.setDimensions(xmin,xmax); + } +/* -------------------------------------------------------------------------- */ + +void DomainInterface::getSubDomainDimensions(Cube & bbox){ + Real xmin[3]; + Real xmax[3]; + getSubDomainDimensions(xmin,xmax); + bbox.setDimensions(xmin,xmax); +} + +/* -------------------------------------------------------------------------- */ + + +bool DomainInterface::shouldRestart(){ + return restartfile.size(); +} +/* -------------------------------------------------------------------------- */ + +const std::string & DomainInterface::getRestartFile(){ + return restartfile; +} + +/* -------------------------------------------------------------------------- */ + +void DomainInterface::printself(std::ostream & stream, int indent) const{ + +} + +/* -------------------------------------------------------------------------- */ + +void DomainInterface::connect(FilterManager & f){ + LM_TOIMPLEMENT; +} + +/* -------------------------------------------------------------------------- */ + +void DomainInterface::connect(ActionManager & f){ + LM_TOIMPLEMENT; +} + +/* -------------------------------------------------------------------------- */ + +/* LMDESC DomainInterface + This section describe the section that is associated + with every model. +*/ + +void DomainInterface::declareParams(){ + + /* LMKEYWORD RESTART_FILE + Specifies a filename to perform a restart just after initialization. + */ + this->parseKeyword("RESTART_FILE",restartfile,""); + /* LMKEYWORD RESTART_CONTINUE_IF_NOTFOUND + Set a flag that allow RESTART routine to ignore the absence of a file + while restarting. If the restart file is not existing no restart + procedure is launched at and a warning message is outputed. + */ + this->parseTag("RESTART_CONTINUE_IF_NOTFOUND",restart_continue_if_notfound,false); +} +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + + + + diff --git a/src/common/domain_interface.hh b/src/common/domain_interface.hh new file mode 100644 index 0000000..dd47fb9 --- /dev/null +++ b/src/common/domain_interface.hh @@ -0,0 +1,228 @@ +/** + * @file domain_interface.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the interface to all domain (model/plugins) + * + * @section LICENSE + * + * Copyright INRIA and CEA + * + * The LibMultiScale is a C++ parallel framework for the multiscale + * coupling methods dedicated to material simulations. This framework + * provides an API which makes it possible to program coupled simulations + * and integration of already existing codes. + * + * This Project was initiated in a collaboration between INRIA Futurs Bordeaux + * within ScAlApplix team and CEA/DPTA Ile de France. + * The project is now continued at the Ecole Polytechnique Fédérale de Lausanne + * within the LSMS/ENAC laboratory. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. + * + */ + +/* -------------------------------------------------------------------------- */ +#ifndef DOMAIN_INTERFACE_H +#define DOMAIN_INTERFACE_H +/* -------------------------------------------------------------------------- */ +#include "lm_parsable.hh" +#include "component_libmultiscale.hh" +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ +class FilterManager; +class ActionManager; +class Cube; +/* -------------------------------------------------------------------------- */ + +/** + * Class DomainInterface + * is the most generic interface to domains + */ + +class DomainInterface : + public Parsable, + public virtual ComponentLMInterface { + +public: + + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ + + DomainInterface(DomainID id,CommGroup gid); + DomainInterface(UInt Dim); + DomainInterface(); + + virtual ~DomainInterface(); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ + + //! initialization method + virtual void init()=0; + + //! generic access to potential energy + virtual Real getEpot(); + //! virtual first step of a domain + virtual void performStep1(); + //! virtual second step of a domain + virtual void performStep2(); + //! virtual third step of a domain + virtual void performStep3(); + //! virtual fourth step of a domain + virtual void performStep4(); + //! virtual fifth step of a domain + virtual void performStep5(); + + //! set internal timestep to a given value + virtual void setTimeStep(Real ts)=0; + //! set current timestep to a given value + virtual void setCurrentStep(UInt ts)=0; + //! get internal timestep to a given value + virtual Real getTimeStep()=0; + //! get current timestep to a given value + virtual UInt getCurrentStep()=0; + //! restart from xml file function + virtual void readXMLFile(const std::string & filename)=0; + + /** the type of code used. Currently could be only of two kinds + Atomic or Continu, for MD and continuum simulations */ + //! type of simulation + UInt getType(); + /** return a group id referencing a subset of processor + where a domain is ran on */ + //! group of processor ID + CommGroup getGroupID(); + //! domain ID + DomainID getID(); + //! set the domain ID + void setID(const DomainID & name); + + + //! return the size of the domain ususefull to deal with pbc + virtual void getDomainDimensions(Real * xmin, + Real * xmax)=0; + //! return the size of the box associated to current processor + virtual void getSubDomainDimensions(Real * xmin, + Real * xmax)=0; + + //! return the size of the domain ususefull to deal with pbc + void getDomainDimensions(Cube & bbox); + //! return the size of the box associated to current processor + void getSubDomainDimensions(Cube & bbox); + + //! set the parameters common to all domains + virtual void declareParams(); + + //! add points for vector of reals + virtual void addPoints(const std::vector & allPositions){LM_TOIMPLEMENT;}; + + /* -------------------------------------------------------------------------- */ + //old material part + /* ------------------------------------------------------------------------ */ + + bool shouldRestart(); + //!function that return the restart file name + const std::string & getRestartFile(); + + + /* -------------------------------------------------------------------------- */ + //functions for AMELCG + /* ------------------------------------------------------------------------ */ + + //! return product of force by descent direction (for AMELCG) */ + virtual Real getFdotDir()=0; + //! return max of forces (for AMELCG) + virtual Real getFMax()=0; + //! return max of direction vector (for AMELCG) + virtual Real getDirMax()=0; + //! return norm 2 of forces (for AMELCG) + virtual Real getFNorm2()=0; + //! return stuff for AMELCG + virtual Real getFdotOldF()=0; + //! update direction AMELCG + virtual void updateDirection(Real beta)=0; + //! return stuff for AMELCG + virtual void saveForceVector()=0; + //! displace in descent direction with given magnitude + virtual void displaceTowardsDirection(Real alpha)=0; + //! get amount of work done by external forces + /* virtual double getExternalWork()=0; */ + /* //! set amount of work done by external forces */ + /* virtual void setExternalWork(double work)=0; */ + + //! function to print the contain of the class + virtual void printself(std::ostream & stream, int indent = 0) const; + + //! connect and build the adapted object + virtual void connect(FilterManager & f); + //! connect and build the adapted object + virtual void connect(ActionManager & f); + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + +protected: + + //! type identifier + UInt type; // type fe, md meshless, xfem + + /* -------------------------------------------------------------------------- */ + //old material part + /* ------------------------------------------------------------------------ */ + + //! restartfile name + std::string restartfile; + //! restart if exists flag + bool restart_continue_if_notfound; + +private: + + //! general id + DomainID id; + //! number for private group of communication + CommGroup group_id; +}; +/* -------------------------------------------------------------------------- */ + +inline std::ostream& operator << (std::ostream& os,DomainInterface &obj){ + obj.printself(os); + return os; +} +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + +#endif //DOMAIN_INTERFACE_H + diff --git a/src/common/id_manager.hh b/src/common/id_manager.hh new file mode 100644 index 0000000..c5670bd --- /dev/null +++ b/src/common/id_manager.hh @@ -0,0 +1,250 @@ +/** + * @file id_manager.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the generic manager of objects from their IDs (string) + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_ID_MANAGER_HH__ +#define __LIBMULTISCALE_ID_MANAGER_HH__ +/* -------------------------------------------------------------------------- */ +#include +#include +#include +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +template +class IDManager { + + /* ------------------------------------------------------------------------ */ + /* Typedefs */ + /* ------------------------------------------------------------------------ */ +public: + + typedef std::string typeID; + typedef std::map Cont; + + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ + +protected: + + IDManager(const std::string & obj_name); + virtual ~IDManager(){ + freeMemory(); + }; + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ +public: + + static IT & getManager(); + static void destroy(); + + //! add a geometry to the manager list with a given ID + // typeID addObject(T * g,const typeID & ID=""); + typeID addObject(T * g, bool nf=true); + //! generate a new id automatically + typeID generateNewID(); + //! remove a managed object + void removeObject(const typeID & ID, bool free=true); + //! remove a managed object + void removeObject(T* ID, bool free=true); + //! reserve an ID without specifying the pointer (that needs to be specified later) + // void reserveID(const typeID & ID); + //! free all the memory attributed to geometries + void freeMemory(); + + + /* ------------------------------------------------------------------------ */ + /* Accessors */ + /* ------------------------------------------------------------------------ */ +public: + + //! return a pointer to a geometry from its ID + T * getObject(const typeID & ID); + //! search id of a given geometry + typeID getID(T * obj); + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ +protected: + + //! mapping between IDs and geometry pointers + std::map objects; + //! vector of names to know registering order + std::vector object_list; + //! object name + std::string object_name; + //! file to which output the object infos + std::ofstream fout; + + static IT * static_pointer; + + //! map to now if object should be freed or not + std::map need_free; +}; + +/* -------------------------------------------------------------------------- */ + +template +inline IT & IDManager::getManager(){ + if (!static_pointer) + static_pointer = new IT(); + + return *static_pointer; +} +/* -------------------------------------------------------------------------- */ + + +template +inline IDManager::IDManager(const std::string & obj_name): + object_name(obj_name){ + std::string filename = "log."; + filename += obj_name; + fout.open(filename.c_str(),std::ios_base::out); +} +/* -------------------------------------------------------------------------- */ +template +inline typename IDManager::typeID IDManager::generateNewID(){ + UInt i = objects.size(); + std::stringstream str; + str << "geom" << i; + return str.str(); +} +/* -------------------------------------------------------------------------- */ + + +template +inline typename IDManager::typeID IDManager::addObject(T * obj, bool nf){ + if (obj == NULL) LM_FATAL("attempt to register a null pointer as " << object_name); + + + typeID id = obj->getID(); + if (id == "") { + id = generateNewID(); + obj->setID(id); + } + else if (objects.count(id) > 0 && objects[id]) + LM_FATAL("ID " << id << " has already been used for " << *objects[id]); + + object_list.push_back(id); + objects[id] = obj; + need_free[id] = nf; + + DUMPFILE(fout,object_name << " added to manager with ID " + << id << " " << *obj); + return id; +} +/* -------------------------------------------------------------------------- */ + +template +inline void IDManager::removeObject(T * obj, bool free){ + + const std::string ID = obj->getID(); + removeObject(ID,free); +} +/* -------------------------------------------------------------------------- */ + +template +inline void IDManager::removeObject(const typeID & ID, bool free){ + + if (objects.count(ID) == 0) + LM_FATAL("impossible to delete entry -> unknown " + << object_name << " from ID " << ID); + + if (free) delete(objects[ID]); + objects.erase(ID); + std::string tmp = ID; + std::vector::iterator it = find(object_list.begin(),object_list.end(),ID); + if (it == object_list.end()) LM_FATAL("object_list is inconsistent: do not contain " + << ID); + object_list.erase(it); + +} +/* -------------------------------------------------------------------------- */ +template +inline T * IDManager::getObject(const typeID & ID){ + if (objects.count(ID) == 0){ + LM_THROW("unknown " << object_name << " from ID " << ID); + } + + return objects[ID]; +} +/* -------------------------------------------------------------------------- */ +template +inline typename IDManager::typeID IDManager::getID(T * obj){ + + typename Cont::iterator it = objects.begin(); + typename Cont::iterator last = objects.end(); + + for (it = objects.begin(); it != last ; ++it){ + if ((*it).second == obj) + return (*it).first; + } + + DUMPFILE(fout,"Warning : auto registering of " + << object_name << " {\n" << *obj << "\n}"); + return (addObject(obj)); +} +/* -------------------------------------------------------------------------- */ +// template +// inline void IDManager::reserveID(const typeID & ID){ +// if (objects.count(ID) == 0) +// objects[ID]=NULL; +// } +/* -------------------------------------------------------------------------- */ +template +inline void IDManager::freeMemory(){ + + while (object_list.size()){ + const std::string & ID = this->object_list[0]; + DUMP("delete " << ID,DBG_INFO); + removeObject(ID,need_free[ID]); + } + + objects.clear(); + need_free.clear(); + object_list.clear(); + + DUMPFILE(fout,"all " << object_name << " cleaned..."); + fout.close(); +} +/* -------------------------------------------------------------------------- */ +template +inline void IDManager::destroy(){ + delete (static_pointer); +} +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + + +#endif /* __LIBMULTISCALE_ID_MANAGER_HH__ */ diff --git a/src/common/lm_common.hh b/src/common/lm_common.hh new file mode 100644 index 0000000..a72c84b --- /dev/null +++ b/src/common/lm_common.hh @@ -0,0 +1,67 @@ +/** + * @file lm_common.hh + * + * @author Guillaume Anciaux + * @author Jaehyun Cho + * @author Srinivasa Babu Ramisetti + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the file to be included by anyfile of the project + * + * @section LICENSE + * + * Copyright INRIA and CEA + * + * The LibMultiScale is a C++ parallel framework for the multiscale + * coupling methods dedicated to material simulations. This framework + * provides an API which makes it possible to program coupled simulations + * and integration of already existing codes. + * + * This Project was initiated in a collaboration between INRIA Futurs Bordeaux + * within ScAlApplix team and CEA/DPTA Ile de France. + * The project is now continued at the Ecole Polytechnique Fédérale de Lausanne + * within the LSMS/ENAC laboratory. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. + * + */ + +#ifndef __LIBMULTISCALE_LM_COMMON_HH__ +#define __LIBMULTISCALE_LM_COMMON_HH__ +/* -------------------------------------------------------------------------- */ +#include "lm_macros.hh" +#include "lm_types.hh" +#include "lm_globals.hh" +#include "lm_log.hh" +#include "lm_functions.hh" +#include "lm_timer.hh" +#include "lm_ostream_types.hh" +#include "model_list.hh" +/* -------------------------------------------------------------------------- */ +#endif /* __LIBMULTISCALE_LM_COMMON_HH__ */ + diff --git a/src/common/lm_file.cc b/src/common/lm_file.cc new file mode 100644 index 0000000..4231f70 --- /dev/null +++ b/src/common/lm_file.cc @@ -0,0 +1,307 @@ +/** + * @file lm_file.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief File object useful to open/close read/write files in plain/compressed mode + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include "lm_file.hh" +#include +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + + +void LMFile::printf(const char * formated, ...){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + + // if (!opened) return; + + if (_file == NULL) LM_FATAL("file not opened"); + + char buf[512]; + + va_list list; + va_start(list,formated); + UInt len = vsprintf(buf,formated,list); + va_end(list); + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + gzwrite(gzfile,buf,len); + return; + } + else +#endif + fwrite(buf,len,1,_file); + +} +/* -------------------------------------------------------------------------- */ + + +char * LMFile::gets(char * buf, UInt len){ + char * ret; + + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + if (_file == NULL) LM_FATAL("file not opened"); + + DUMP("read to buf (" << buf << ") at most " << len << " characters",DBG_DETAIL); +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + ret = gzgets(gzfile,buf,len); + } + else +#endif + ret = fgets(buf,len,_file); + + DUMP("read to buf (" << buf << ") at most " << len << " characters",DBG_DETAIL); + return ret; + +} + +/* -------------------------------------------------------------------------- */ + + + +void LMFile::close(){ + // if (!opened) FATAL("file not opened"); + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + gzclose(gzfile); + gzfile = NULL; + } + else +#endif + fclose(_file); + + _file = NULL; + fd = UINT_MAX; + opened = false; + + DUMP("file " << name << " closed",DBG_DETAIL); +} +/* -------------------------------------------------------------------------- */ + + +void LMFile::open(const std::string & fname ,const std::string & mode,UInt compr){ + std::string _mode="wb"; + + if (mode != "") + _mode = mode; + + if (opened) { + close(); + } + + compressed = compr; + if (compressed){ +#ifdef LIBMULTISCALE_USE_ZLIB + char buffer[256]; + sprintf(buffer,"%s.gz",fname.c_str()); + _file = fopen(buffer,_mode.c_str()); + if (_file == NULL) LM_THROW("Could not open file " << buffer); + name = buffer; +#else + LM_FATAL("cannot open a compressed file without ZLIB support: activate in CMake menu"); +#endif + //DUMP("file opened in compressed form " << name); + } + else{ + _file = fopen(fname.c_str(),_mode.c_str()); + if (_file == NULL) LM_THROW("Could not open file "<< fname); + name = fname; + } + + opened = true; + fd = fileno(_file); + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + char temp[10]; + sprintf(temp,"%s%d",_mode.c_str(),9); + gzfile = gzdopen(fd,temp); + if (gzfile == NULL) LM_FATAL("Could not open file descriptor using gzdopen(" + << fd << "," << temp << ")"); + } +#endif + + DUMP("file " << name << " opened , compressed = " << compressed, DBG_INFO); + +} +/* -------------------------------------------------------------------------- */ + + +int LMFile::dumpchar(int c){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + // if (!opened) return EOF; + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + int res = gzputc(gzfile,c); + //DUMP("file opened in compressed form " << name); + if (c != res) + LM_FATAL("I did not write what I wanted (compressed) " << res); + return res; + } + else +#endif + if (c != putc(c,_file)) + LM_FATAL("I did not write what I wanted"); + return c; +} + +/* -------------------------------------------------------------------------- */ + + +UInt LMFile::seek(UInt offset,UInt set){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + return gzseek(gzfile, offset,set); + } + else +#endif + return fseek(_file,offset,set); +} + +/* -------------------------------------------------------------------------- */ + + +UInt LMFile::tell(){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + return gztell(gzfile); + } + else +#endif + + return ftell(_file); +} +/* -------------------------------------------------------------------------- */ + + +UInt LMFile::read(void * buffer,UInt size,UInt number){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + return gzread(gzfile,buffer,size*number); + } + else +#endif + return fread(buffer,size,number,_file); +} + +/* -------------------------------------------------------------------------- */ + + +UInt LMFile::write(void * buffer,UInt size,UInt number){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + return gzwrite(gzfile,buffer,size*number); + } + else +#endif + return fwrite(buffer,size,number,_file); +} + +/* -------------------------------------------------------------------------- */ + + +void LMFile::flush(){ + if (!opened) { + LM_FATAL("Warning : file not opened " << name); + } + + +#ifdef LIBMULTISCALE_USE_ZLIB + if (compressed){ + gzflush(gzfile,Z_SYNC_FLUSH); + } + else +#endif + fflush(_file); +} + +/* -------------------------------------------------------------------------- */ + + +LMFile::LMFile(){ + compressed = 0; + _file = NULL; + fd = UINT_MAX; +#ifdef LIBMULTISCALE_USE_ZLIB + gzfile = NULL; +#endif + opened = false; +} +/* -------------------------------------------------------------------------- */ + + +LMFile::LMFile(const std::string & fname,const std::string & mode,UInt compr){ + compressed = compr; + _file = NULL; + fd = UINT_MAX; +#ifdef LIBMULTISCALE_USE_ZLIB + gzfile = NULL; +#endif + opened = false; + open(fname,mode,compressed); +} + +/* -------------------------------------------------------------------------- */ + + +__END_LIBMULTISCALE__ diff --git a/src/common/lm_file.hh b/src/common/lm_file.hh new file mode 100644 index 0000000..946ff33 --- /dev/null +++ b/src/common/lm_file.hh @@ -0,0 +1,113 @@ +/** + * @file lm_file.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief File object useful to open/close read/write files in plain/compressed mode + * + * @section LICENSE + * + * Copyright INRIA and CEA + * + * The LibMultiScale is a C++ parallel framework for the multiscale + * coupling methods dedicated to material simulations. This framework + * provides an API which makes it possible to program coupled simulations + * and integration of already existing codes. + * + * This Project was initiated in a collaboration between INRIA Futurs Bordeaux + * within ScAlApplix team and CEA/DPTA Ile de France. + * The project is now continued at the Ecole Polytechnique Fédérale de Lausanne + * within the LSMS/ENAC laboratory. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. + * + */ + +#ifndef __LIBMULTISCALE_LM_FILE_HH__ +#define __LIBMULTISCALE_LM_FILE_HH__ +/* -------------------------------------------------------------------------- */ +#include +#include +#include +#include +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +class LMFile { + + /* ------------------------------------------------------------------------ */ + /* Constructors/Destructors */ + /* ------------------------------------------------------------------------ */ + + public: + + LMFile(); + LMFile(const std::string & fname,const std::string & mode="", UInt compr=false); + + /* ------------------------------------------------------------------------ */ + /* Methods */ + /* ------------------------------------------------------------------------ */ + + + void printf(const char * ,...); + void close(); + void open(const std::string & fname,const std::string & mode="",UInt compr= false); + void flush(); + + UInt tell(); + UInt seek(UInt offset,UInt set); + int dumpchar(int c); + UInt read(void * buffer,UInt size,UInt number); + UInt write(void * buffer,UInt size,UInt number); + char * gets(char * buf, UInt len); + + /* ------------------------------------------------------------------------ */ + /* Class Members */ + /* ------------------------------------------------------------------------ */ + +private: + + FILE * _file; + UInt fd; +#ifdef LIBMULTISCALE_USE_ZLIB + gzFile gzfile; +#endif + + UInt opened; + UInt compressed; + + std::string name; +}; +/* -------------------------------------------------------------------------- */ +__END_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + + +#endif /* __LIBMULTISCALE_LM_FILE_HH__ */ diff --git a/src/common/lm_functions.cc b/src/common/lm_functions.cc new file mode 100644 index 0000000..032c7d3 --- /dev/null +++ b/src/common/lm_functions.cc @@ -0,0 +1,147 @@ +/** + * @file lm_functions.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This file contains the global scope functions + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include "geometry.hh" +#include "lm_parser.hh" +#include +#include "geometry_manager.hh" + +__BEGIN_LIBMULTISCALE__ + +/* -------------------------------------------------------------------------- */ +// MPI macros +/* -------------------------------------------------------------------------- */ +void loadMPI(int argc, char ** argv) { + int myrank, world; + MPI_Init (&argc,&argv); + MPI_Comm_rank (MPI_COMM_WORLD, &myrank); + lm_my_proc_id = (UInt)myrank; + MPI_Comm_size (MPI_COMM_WORLD, &world); + lm_world_size = (UInt) world; +} + +void closeMPI(){ + MPI_Barrier(MPI_COMM_WORLD); + MPI_Finalize(); +} + +/* -------------------------------------------------------------------------- */ +//environment macro +/* -------------------------------------------------------------------------- */ + +void loadENV() { + char * varenv = lm_getenv("DEBUG_LEVEL"); + if (varenv) global_level = lm_atoi(varenv); + else global_level = DBG_WARNING; + varenv = lm_getenv("DEBUG_PROC"); + if (varenv) global_proc = lm_atoi(varenv); + else global_proc = UINT_MAX; + varenv = lm_getenv("DEBUG_PROC1"); + if (varenv) global_proc1 = lm_atoi(varenv); + else global_proc1 = UINT_MAX; + varenv = lm_getenv("DEBUG_PROC2"); + if (varenv) global_proc2 = lm_atoi(varenv); + else global_proc2 = UINT_MAX; + varenv = lm_getenv("DEBUG_START"); + if (varenv) start_dump = lm_atoi(varenv); + else start_dump = 0; + varenv = lm_getenv("DEBUG_END"); + if (varenv) end_dump = lm_atoi(varenv); + else end_dump = UINT_MAX; + varenv = lm_getenv("HOSTNAME"); + if (varenv) my_hostname = varenv; + else my_hostname = ""; + varenv = lm_getenv("JOB_ID"); + if (varenv) lm_job_id = lm_atoi(varenv); + else lm_job_id = lm_world_size; + varenv = lm_getenv("PRINT_CRAP_TO_FILE"); + if (varenv) print_crap_to_file = true; + else print_crap_to_file = false; + varenv = lm_getenv("CREATE_SEG_FAULT"); + if (varenv) create_seg_fault = true; + else create_seg_fault = false; + varenv = lm_getenv("WAIT_ON_FATAL"); + if (varenv) wait_on_fatal = true; + else wait_on_fatal = false; + varenv = lm_getenv("WAIT_AT_STARTUP"); + if (varenv) wait_at_startup = lm_atoi(varenv); + else wait_at_startup = UINT_MAX; + openGlobal(); +} + +/* -------------------------------------------------------------------------- */ +/// EPSN init macro +/* -------------------------------------------------------------------------- */ +#ifdef LIBMULTISCALE_USE_EPSN +#include "RedSYM..hh" +#include "Epsn..hh" +EXTERN char xmlepsnfile[255]; +EXTERN EPSN::Simulation::Interface * epsn_itfc; + +inline void loadEPSN() { + epsn_itfc = NULL; + epsn_itfc = new EPSN::Simulation::Interface; + epsn_itfc->initORB(argc,argv); +} + +inline closeEPSN(){ + epsn_itfc->finalize(); + epsn_itfc->killORB(); + delete epsn_itfc; +} +#else +void loadEPSN(){} +void closeEPSN(){} +#endif + +/* -------------------------------------------------------------------------- */ +//init functions +/* -------------------------------------------------------------------------- */ +void loadModules(int argc, char ** argv){ + loadMPI(argc,argv); + loadEPSN(); + loadENV(); +} + +void closeModules(){ + GeometryManager::destroy(); + Parser::freeMemory(); + closeEPSN(); +#ifdef LIBMULTISCALE_TIMER + dumpTimes(lm_my_proc_id); +#endif + closeMPI(); + (*global_out).flush(); +} + + + + +__END_LIBMULTISCALE__ diff --git a/src/common/lm_functions.hh b/src/common/lm_functions.hh new file mode 100644 index 0000000..e3fb4d1 --- /dev/null +++ b/src/common/lm_functions.hh @@ -0,0 +1,45 @@ +/** + * @file lm_functions.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This file contains the global scope functions + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +__BEGIN_LIBMULTISCALE__ + +// LM libc functions wrappers +extern void lm_exit (int __status) __THROW __attribute__ ((__noreturn__)); +extern char * lm_getenv (const char *); +extern int lm_getpid(); +extern int lm_atoi(const std::string & n); + +//init functions +extern void loadModules(int argc, char ** argv); +extern void closeModules(); + + + + +__END_LIBMULTISCALE__ diff --git a/src/common/lm_fwd.hh b/src/common/lm_fwd.hh new file mode 100644 index 0000000..31c14db --- /dev/null +++ b/src/common/lm_fwd.hh @@ -0,0 +1,42 @@ +/** + * @file lm_fwd.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is where forward declaration of global objects should be defined + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +/* forward declaration */ + +#ifndef __LIBMULTISCALE_LM_FWD_HH__ +#define __LIBMULTISCALE_LM_FWD_HH__ + +__BEGIN_LIBMULTISCALE__ + +template class ReferenceManager; +template class ContainerArray; + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_LM_FWD_HH__ */ diff --git a/src/common/lm_globals.cc b/src/common/lm_globals.cc new file mode 100644 index 0000000..2d05ad9 --- /dev/null +++ b/src/common/lm_globals.cc @@ -0,0 +1,104 @@ +/** + * @file lm_globals.cc + * + * @author Guillaume Anciaux + * @author Jaehyun Cho + * @author Till Junge + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This file contains all the global variables of LM + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include +#include +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +/* -------------------------------------------------------------------------- */ +//global variables +UInt current_step; +IntegrationSchemeStage current_stage; +Real current_time; +UInt nb_step; +UInt nb_step_next_event; +UInt global_level; +UInt global_mod; +UInt global_proc; +UInt global_proc1; +UInt global_proc2; +UInt start_dump; +UInt end_dump; +std::string my_hostname; +UInt print_crap_to_file; +std::ostream * global_out; +std::ofstream file_out; +UInt wait_on_fatal; +UInt wait_at_startup; +UInt create_seg_fault; +UInt lm_my_proc_id; +UInt lm_world_size; +UInt lm_job_id; +UInt spatial_dimension; +UInt lm_uint_max = std::numeric_limits::max(); +Real lm_real_max = std::numeric_limits::max(); +/// used to avoid infinite FATAL recursion in stage PRE_FATAL +bool fatal_loop = false; + +#if defined(LIBMULTISCALE_USE_TIMER) +std::map mesT; +std::map nmes; +std::map tstart; +std::map tstop; +#endif +/* -------------------------------------------------------------------------- */ + +UInt getGlobalCurrentRelease(){ + UInt k = 0; + switch (current_stage){ + case PRE_DUMP : k = 0; break; + case PRE_STEP1 : k = 1; break; + case PRE_STEP2 : k = 2; break; + case PRE_STEP3 : k = 3; break; + case PRE_STEP4 : k = 4; break; + case PRE_STEP5 : k = 5; break; + case PRE_STEP6 : k = 6; break; + case PRE_STEP7 : k = 7; break; + case PRE_FATAL : k = 8; break; + default: LM_FATAL("error: unknown stage " << current_stage); + } + return (8*current_step + k + INITIAL_MODEL_RELEASE); +} + +/* -------------------------------------------------------------------------- */ +const int CommGroup::id_all = std::numeric_limits::max(); +const int CommGroup::id_none = id_all-1; +const int CommGroup::id_invalid = id_all-2; +CommGroup group_all(CommGroup::id_all); +CommGroup group_none(CommGroup::id_none); +CommGroup group_invalid(CommGroup::id_invalid); +/* -------------------------------------------------------------------------- */ + + +__END_LIBMULTISCALE__ diff --git a/src/common/lm_globals.hh b/src/common/lm_globals.hh new file mode 100644 index 0000000..a9ba64d --- /dev/null +++ b/src/common/lm_globals.hh @@ -0,0 +1,93 @@ +/** + * @file lm_globals.hh + * + * @author Guillaume Anciaux + * @author Jaehyun Cho + * @author Till Junge + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This file contains all the global variables of LM + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LM_GLOBALS_HH__ +#define __LIBMULTISCALE_LM_GLOBALS_HH__ +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ + +static const std::string invalidFilter = "invalid filter"; +static const std::string invalidGeom = "invalid geometry"; +static const std::string invalidDomain = "invalid domain"; +static const std::string invalidDumper = "invalid dumper"; +static const std::string invalidStimulator = "invalid stimulator"; + +typedef std::string GeomID; +typedef std::string FilterID; +typedef std::string DomainID; +typedef std::string ActionID; +typedef std::string DumperID; +typedef std::string StimulatorID; +/* -------------------------------------------------------------------------- */ +//global variables +EXTERN UInt current_step; +EXTERN IntegrationSchemeStage current_stage; +EXTERN Real current_time; +EXTERN UInt nb_step; +EXTERN UInt nb_step_next_event; +EXTERN UInt global_level; +EXTERN UInt global_mod; +EXTERN UInt global_proc; +EXTERN UInt global_proc1; +EXTERN UInt global_proc2; +EXTERN UInt start_dump; +EXTERN UInt end_dump; +EXTERN std::string my_hostname; +EXTERN UInt print_crap_to_file; +EXTERN std::ostream * global_out; +EXTERN std::ofstream file_out; +EXTERN UInt wait_on_fatal; +EXTERN UInt wait_at_startup; +EXTERN UInt create_seg_fault; +EXTERN UInt lm_my_proc_id; +EXTERN UInt lm_world_size; +EXTERN UInt lm_job_id; +EXTERN UInt spatial_dimension; +EXTERN UInt lm_uint_max; +EXTERN Real lm_real_max; +/// used to avoid infinite FATAL recursion in stage PRE_FATAL +EXTERN bool fatal_loop; + +/* -------------------------------------------------------------------------- */ +EXTERN UInt getGlobalCurrentRelease(); +/* -------------------------------------------------------------------------- */ +EXTERN CommGroup group_all; +EXTERN CommGroup group_none; +EXTERN CommGroup group_invalid; +/* -------------------------------------------------------------------------- */ +static const UInt INITIAL_MODEL_RELEASE = 100; +/* -------------------------------------------------------------------------- */ + + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_LM_GLOBALS_HH__ */ diff --git a/src/common/lm_libc.cc b/src/common/lm_libc.cc new file mode 100644 index 0000000..a0897dd --- /dev/null +++ b/src/common/lm_libc.cc @@ -0,0 +1,70 @@ +/** + * @file lm_libc.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief Wrapper of libc functions + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include +#include +#include +#include "lm_common.hh" +#include +#include +/* -------------------------------------------------------------------------- */ + +void ::libmultiscale::lm_exit (int __status) __THROW { + switch (__status){ + case LM_EXIT_FAILURE: + MPI_Abort(MPI_COMM_WORLD, EXIT_FAILURE); + exit(EXIT_FAILURE);break; + + case LM_EXIT_SUCCESS: + exit(EXIT_SUCCESS);break; + default: exit(__status); + } +} + +/* -------------------------------------------------------------------------- */ + + +char * ::libmultiscale::lm_getenv(const char * vname) { + return getenv(vname); +} + +/* -------------------------------------------------------------------------- */ + +int ::libmultiscale::lm_getpid() { + return getpid(); +} + +/* -------------------------------------------------------------------------- */ + +int ::libmultiscale::lm_atoi(const std::string & n){ + int res; + std::stringstream sstr(n); + sstr >> res; + return res; +} diff --git a/src/common/lm_log.cc b/src/common/lm_log.cc new file mode 100644 index 0000000..992e703 --- /dev/null +++ b/src/common/lm_log.cc @@ -0,0 +1,182 @@ +/** + * @file lm_log.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief Log/Debug system of LibMultiScale + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include +#include +#include "action_manager.hh" +#include "lm_globals.hh" + + +/* -------------------------------------------------------------------------- */ + + +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ +#define CREATE_SEGFAULT if (create_seg_fault) {UInt * a = NULL; *a = 1;} +/* -------------------------------------------------------------------------- */ + +void doWait(bool condition) { + if(!condition) return; + + UInt pid = lm_getpid(); + std::cerr << "Proc " << lm_my_proc_id + << " Waiting for gdb to attach: pid is " << pid + << std::endl; + UInt a = 1; + while(a) {}; +} + +/* -------------------------------------------------------------------------- */ +void doWaitOnFatal(){ + doWait(wait_on_fatal); +} +/* -------------------------------------------------------------------------- */ +void doWaitAtStartup(){ + doWait((wait_at_startup != UINT_MAX) + && + (lm_my_proc_id == wait_at_startup)); +} +/* -------------------------------------------------------------------------- */ + + +void lmFatal(std::stringstream & x, + UInt line, + const std::string & file, + const std::string & function, + const std::string & pretty_function) { + if (!fatal_loop) { + fatal_loop = true; + try { + ActionManager & actions = ActionManager::getManager(); + current_stage = PRE_FATAL; + actions.action(); + } + catch (...){ + } + } + (*global_out) << "(" << current_step << ")" + << "[" << lm_my_proc_id << "]<" << file + << ":" << line << "> FATAL : " + << x.str() << std::endl; + (*global_out).flush(); + DOWAIT_ON_FATAL; + CREATE_SEGFAULT; + ::libmultiscale::lm_exit(LM_EXIT_FAILURE); +} + +/* -------------------------------------------------------------------------- */ +void openGlobal(){ + if (print_crap_to_file){ + std::stringstream sstr; + sstr << my_hostname << "-" << lm_my_proc_id << ".log"; + file_out.open(sstr.str().c_str(),std::ios_base::out); + global_out = &file_out; + } + else{ + global_out = &std::cerr; + } +} + +/* -------------------------------------------------------------------------- */ + +inline std::ostream & operator <<(std::ostream & stream, const dbgLevel & _this) +{ + switch (_this){ + case dbg_message : ; break; + case dbg_warning : stream << "WARNING:" ; break; + case dbg_info_startup : stream << "INFO_STARTUP:"; break; + case dbg_info : stream << "INFO:" ; break; + case dbg_detail : stream << "DETAIL:" ; break; + case dbg_all : stream << "ALL:" ; break; + } + return stream; +} + + +/* -------------------------------------------------------------------------- */ + + +#define INFO_PROCESS \ + "(" << current_step << ":" << current_stage \ + << ")[" << lm_my_proc_id << "," + +#define INFO_PROCESS_FULL \ + "(" << current_step << ")[" \ + << lm_my_proc_id << "," \ + << my_hostname << "," << getpid() + +#define INFO_SOURCE \ + function << ":" << line << "] " + +#define INFO_SOURCE_FULL \ + pretty_function << ":" << line << "] " + + + + +/* ----------------- */ +//no info +//#define APPEND_FILE "" +/* ------------------*/ +//small info +#define APPEND_FILE INFO_PROCESS << INFO_SOURCE +/* ------------------*/ +//full info +//#define APPEND_FILE INFO_PROCESS_FULL << INFO_SOURCE_FULL + +/* -------------------------------------------------------------------------- */ + + +void lmPrintOut(std::stringstream & x, + dbgLevel level, + UInt line, + const std::string & file, + const std::string & function, + const std::string & pretty_function){ + + if(global_level >= level) + if((global_proc == lm_uint_max + || global_proc == lm_my_proc_id + || global_proc1 == lm_my_proc_id + || global_proc2 == lm_my_proc_id) + && (current_step >= start_dump && + (end_dump == lm_uint_max + || current_step <= end_dump))){ + (*global_out) << APPEND_FILE << + x.str() << std::endl << std::flush; + } +} + +/* -------------------------------------------------------------------------- */ + + + + +__END_LIBMULTISCALE__ diff --git a/src/common/lm_log.hh b/src/common/lm_log.hh new file mode 100644 index 0000000..45e1e01 --- /dev/null +++ b/src/common/lm_log.hh @@ -0,0 +1,222 @@ +/** + * @file lm_log.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the file containing all the macros for the log/debug system + * + * @section LICENSE + * + * Copyright INRIA and CEA + * + * The LibMultiScale is a C++ parallel framework for the multiscale + * coupling methods dedicated to material simulations. This framework + * provides an API which makes it possible to program coupled simulations + * and integration of already existing codes. + * + * This Project was initiated in a collaboration between INRIA Futurs Bordeaux + * within ScAlApplix team and CEA/DPTA Ile de France. + * The project is now continued at the Ecole Polytechnique Fédérale de Lausanne + * within the LSMS/ENAC laboratory. + * + * This software is governed by the CeCILL-C license under French law and + * abiding by the rules of distribution of free software. You can use, + * modify and/ or redistribute the software under the terms of the CeCILL-C + * license as circulated by CEA, CNRS and INRIA at the following URL + * "http://www.cecill.info". + * + * As a counterpart to the access to the source code and rights to copy, + * modify and redistribute granted by the license, users are provided only + * with a limited warranty and the software's author, the holder of the + * economic rights, and the successive licensors have only limited + * liability. + * + * In this respect, the user's attention is drawn to the risks associated + * with loading, using, modifying and/or developing or reproducing the + * software by the user in light of its specific status of free software, + * that may mean that it is complicated to manipulate, and that also + * therefore means that it is reserved for developers and experienced + * professionals having in-depth computer knowledge. Users are therefore + * encouraged to load and test the software's suitability as regards their + * requirements in conditions enabling the security of their systems and/or + * data to be ensured and, more generally, to use and operate it in the + * same conditions as regards security. + * + * The fact that you are presently reading this means that you have had + * knowledge of the CeCILL-C license and that you accept its terms. + * + */ + +#ifndef __LIBMULTISCALE_LOG_HH__ +#define __LIBMULTISCALE_LOG_HH__ +/* -------------------------------------------------------------------------- */ +#include +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ +#define DBG_MESSAGE 0 +#define DBG_WARNING 1 +#define DBG_INFO_STARTUP 2 +#define DBG_INFO 3 +#define DBG_DETAIL 4 +#define DBG_ALL 5 +/* -------------------------------------------------------------------------- */ +void openGlobal(); +/* -------------------------------------------------------------------------- */ +void doWait(bool condition); +void doWaitOnFatal(); +void doWaitAtStartup(); +/* -------------------------------------------------------------------------- */ +#define DOWAIT_ON_FATAL doWaitOnFatal(); +#define DOWAIT_AT_STARTUP doWaitAtStartup(); +/* -------------------------------------------------------------------------- */ +enum dbgLevel { + dbg_message = 0, + dbg_warning = 1, + dbg_info_startup = 2, + dbg_info = 3, + dbg_detail = 4, + dbg_all = 5 +}; +/* -------------------------------------------------------------------------- */ + +#define DUMP(x,level) DUMP##level(x) +#define DUMPBYPROC(x,level,p) \ + if (lm_my_proc_id == p \ + || global_proc == lm_my_proc_id \ + || global_proc1 == lm_my_proc_id \ + || global_proc2 == lm_my_proc_id) \ + DUMP##level(x) +#define DUMPFILE(f,x) if (lm_my_proc_id == 0) { \ + f << __FILE__ << "," << __LINE__ << ">" << x << std::endl; \ + } + + +/* -------------------------------------------------------------------------- */ +#define PRINTOUT(x,level) { \ + if(global_level >= level) { \ + std::stringstream sstr; \ + sstr << x; \ + lmPrintOut(sstr,level,__LINE__,__FILE__,__func__,__PRETTY_FUNCTION__); \ + } \ +} +void lmPrintOut(std::stringstream & x, + dbgLevel level, + UInt line, + const std::string & file, + const std::string & function, + const std::string & pretty_function); +/* -------------------------------------------------------------------------- */ + +#ifdef LM_OPTIMIZED +#define LEVEL_MAX 1 +#else +#define LEVEL_MAX 10 +#endif + +#if LEVEL_MAX > 0 +#define DUMPDBG_MESSAGE(x) {PRINTOUT(x,dbg_message);} +#else +#define DUMPDBG_MESSAGE(x) {} +#endif + +#if LEVEL_MAX > 1 +#define DUMPDBG_WARNING(x) {PRINTOUT(x,dbg_warning);} +#else +#define DUMPDBG_WARNING(x) {} +#endif + +#if LEVEL_MAX > 2 +#define DUMPDBG_INFO_STARTUP(x) {PRINTOUT(x,dbg_info_startup);} +#else +#define DUMPDBG_INFO_STARTUP(x) {} +#endif + +#if LEVEL_MAX > 3 +#define DUMPDBG_INFO(x) {PRINTOUT(x,dbg_info);} +#else +#define DUMPDBG_INFO(x) {} +#endif + +#if LEVEL_MAX > 4 +#define DUMPDBG_DETAIL(x) {PRINTOUT(x,dbg_detail);} +#else +#define DUMPDBG_DETAIL(x) {} +#endif + +#if LEVEL_MAX > 5 +#define DUMPDBG_ALL(x) {PRINTOUT(x,dbg_all);} +#else +#define DUMPDBG_ALL(x) {} +#endif + +/* -------------------------------------------------------------------------- */ + + +#ifndef LM_OPTIMIZED +#define LM_ASSERT(cond,message) if (!(cond)){ \ + LM_FATAL(message); \ + } +#else +#define LM_ASSERT(cond,message) {} +#endif + +void lmFatal(std::stringstream & x, + UInt line, + const std::string & file, + const std::string & function, + const std::string & pretty_function); +#define LM_FATAL(x) { \ + std::stringstream sstr; \ + sstr << x; \ + lmFatal(sstr,__LINE__,__FILE__,__func__,__PRETTY_FUNCTION__); \ + ::libmultiscale::lm_exit(LM_EXIT_FAILURE); \ +} + + +/* -------------------------------------------------------------------------- */ + + +class LibMultiScaleException : public std::exception { +public: + + LibMultiScaleException(const std::string & mess) throw() { + message = mess; + }; + + ~LibMultiScaleException() throw(){}; + + virtual const char* what() const throw(){ + return message.c_str(); + }; + +private: + + std::string message; +}; + +/* -------------------------------------------------------------------------- */ + +#define LM_THROW(x) { \ + std::stringstream sstr; \ + sstr << x; \ + throw LibMultiScaleException(sstr.str()); \ + } + +/* -------------------------------------------------------------------------- */ + + +#define LM_TOIMPLEMENT { \ + LM_FATAL("Function " << __PRETTY_FUNCTION__ \ + << " not implemented "); \ + } + + +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ + + +#endif /* __LIBMULTISCALE_LOG_HH__ */ diff --git a/src/common/lm_macros.hh b/src/common/lm_macros.hh new file mode 100644 index 0000000..f113a7c --- /dev/null +++ b/src/common/lm_macros.hh @@ -0,0 +1,58 @@ +/** + * @file lm_macros.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is where global macros are defined + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LM_MACROS_HH__ +#define __LIBMULTISCALE_LM_MACROS_HH__ + +/* -------------------------------------------------------------------------- */ +// MACRO DEFINITIONS +/* -------------------------------------------------------------------------- */ +#ifndef LIBMULTISCALE_USE_MPI +#error "LibMultiScale current version cannot be compiled without MPI support" +#endif + +#define EXTERN extern +/* -------------------------------------------------------------------------- */ +#ifndef UINT_MAX +#define UINT_MAX lm_uint_max +#endif + +#define __BEGIN_LIBMULTISCALE__ namespace libmultiscale { + +#define __END_LIBMULTISCALE__ } +/* -------------------------------------------------------------------------- */ +#define CONTINUUMTYPE 0 +#define ATOMTYPE 1 +#define DDTYPE 2 +/* -------------------------------------------------------------------------- */ +//stuff to stringify a macro after expansion +#define stringify_macro(s) stringify_macro_1(s) +#define stringify_macro_1(s) #s + +#endif /* __LIBMULTISCALE_LM_MACROS_HH__ */ diff --git a/src/common/lm_ostream_types.hh b/src/common/lm_ostream_types.hh new file mode 100644 index 0000000..34eb5ee --- /dev/null +++ b/src/common/lm_ostream_types.hh @@ -0,0 +1,86 @@ +/** + * @file lm_ostream_types.hh + * + * @author Guillaume Anciaux + * @author Till Junge + * @author Jaehyun Cho + * @author Moseley Philip Arthur + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief Definition of the printing features of the principal enums of LibMultiScale + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LM_OSTREAM_TYPES_HH__ +#define __LIBMULTISCALE_LM_OSTREAM_TYPES_HH__ + +__BEGIN_LIBMULTISCALE__ + +/* -------------------------------------------------------------------------- */ + +inline std::ostream& operator << (std::ostream& os,FieldType q){ + switch(q){ + case _position0: os << "position0"; break; + case _position: os << "position"; break; + case _displacement: os << "displacement"; break; + case _velocity: os << "velocity"; break; + case _force: os << "force"; break; + case _temperature: os << "temperature"; break; + case _grouprank: os << "grouprank"; break; + case _stress: os << "stress"; break; + case _strain: os << "strain"; break; + case _epot : os << "pe/atom"; break; + case _mass : os << "mass"; break; + default: LM_FATAL("unknown field type"); + } + return os; +} + +/* -------------------------------------------------------------------------- */ + +inline std::ostream& operator << (std::ostream& os,Operator op){ + switch(op){ + case OP_NONE : os << "NONE"; break; + case OP_AVERAGE : os << "AVERAGE"; break; + case OP_DENSITY : os << "DENSITY"; break; + case OP_DEVIATION : os << "DEVIATION"; break; + case OP_MAX : os << "MAX"; break; + case OP_MIN : os << "MIN"; break; + case OP_SUM : os << "SUM"; break; + default: LM_FATAL("unknown operator"); + } + return os; +} + +/* -------------------------------------------------------------------------- */ + +inline std::ostream& operator << (std::ostream& os, CommGroup group){ + os << "Communication Group #" << group.getID(); + return os; +} + +/* -------------------------------------------------------------------------- */ + + +__END_LIBMULTISCALE__ + +#endif /* __LIBMULTISCALE_LM_OSTREAM_TYPES_HH__ */ diff --git a/src/common/lm_timer.cc b/src/common/lm_timer.cc new file mode 100644 index 0000000..fef6d8c --- /dev/null +++ b/src/common/lm_timer.cc @@ -0,0 +1,81 @@ +/** + * @file lm_timer.cc + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief Timer system for LibMultiScale + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#include "lm_common.hh" +#include +#include +#include +#include +/* -------------------------------------------------------------------------- */ + +__BEGIN_LIBMULTISCALE__ +#ifdef LIBMULTISCALE_TIMER +/* -------------------------------------------------------------------------- */ +std::map mesT; +std::map nmes; +std::map tstart; +std::map tstop; +/* -------------------------------------------------------------------------- */ +void dumpTimes(UInt proc_number) { + std::stringstream fname; + fname << "perf-" << proc_number; + std::ofstream out(fname.str().c_str()); + out << std::setw(30) << "Operation" << std::setw(5) << " " + << std::setw(20) << "Mean time(s)" << std::setw(5) << " " + << std::setw(20) << "Total time(s)" << std::setw(5) << " " + << std::setw(20) << "Call number" << std::endl; + std::multimap inv; + { + std::map::iterator it = mesT.begin(); + std::map::iterator end = mesT.end(); + for( ; it != end ; ++it){ + Real t = (*it).second.tv_sec + (*it).second.tv_nsec*1e-9; + inv.insert(std::pair(t,(*it).first)); + } + } + std::multimap::reverse_iterator it = inv.rbegin(); + std::multimap::reverse_iterator end = inv.rend(); + for( ; it != end ; ++it){ + std::string & key = (*it).second; + Real t = (*it).first; + UInt n = nmes[key]; + Real t_moy = t/n; + out << std::scientific << std::setprecision(10) + << std::setw(30) << key << std::setw(5) << " " + << std::setw(20) << t_moy << std::setw(5) << " " + << std::setw(20) << t << std::setw(5) << " " + << std::setw(20) << n << std::endl; + } +} +#else +void dumpTimes(UInt proc_number) {} +#endif +/* -------------------------------------------------------------------------- */ +__END_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ diff --git a/src/common/lm_timer.hh b/src/common/lm_timer.hh new file mode 100644 index 0000000..0ac4404 --- /dev/null +++ b/src/common/lm_timer.hh @@ -0,0 +1,79 @@ +/** + * @file lm_timer.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief Timer system for LibMultiScale + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +/* -------------------------------------------------------------------------- */ +#if defined(TIMER) && defined(LIBMULTISCALE_TIMER) +/* -------------------------------------------------------------------------- */ +#include +#include +#include +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ +extern std::map mesT; +extern std::map nmes; +extern std::map tstart; +extern std::map tstop; +/* -------------------------------------------------------------------------- */ +#define SEC_IN_NANOSEC 1000000000 +/* -------------------------------------------------------------------------- */ + +inline void STARTTIMER(const std::string & x) { + if (!mesT.count(x)) { + mesT[x].tv_sec = 0; + mesT[x].tv_nsec = 0; + } + clock_gettime(CLOCK_REALTIME,&(tstart[x])); +} +/* -------------------------------------------------------------------------- */ + +inline void STOPTIMER(const std::string & x) { + clock_gettime(CLOCK_REALTIME,&(tstop[x])); + mesT[x].tv_sec += (tstop[x].tv_sec - tstart[x].tv_sec); + mesT[x].tv_nsec += (tstop[x].tv_nsec - tstart[x].tv_nsec); + if (mesT[x].tv_nsec < 0) { + --mesT[x].tv_sec; + mesT[x].tv_nsec += SEC_IN_NANOSEC; + } + if (mesT[x].tv_nsec >= SEC_IN_NANOSEC){ + ++mesT[x].tv_sec; + mesT[x].tv_nsec -= SEC_IN_NANOSEC; + } + ++nmes[x]; +} +/* -------------------------------------------------------------------------- */ +__END_LIBMULTISCALE__ +#else +#define STARTTIMER(x) +#define STOPTIMER(x) +#endif + +__BEGIN_LIBMULTISCALE__ +void dumpTimes(UInt proc_number = 0); +__END_LIBMULTISCALE__ diff --git a/src/common/lm_types.hh b/src/common/lm_types.hh new file mode 100644 index 0000000..1c2ae2b --- /dev/null +++ b/src/common/lm_types.hh @@ -0,0 +1,316 @@ +/** + * @file lm_types.hh + * + * @author Guillaume Anciaux + * @author Jaehyun Cho + * @author Till Junge + * @author Moseley Philip Arthur + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This where the global types and enums of LibMultiScale are defined + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_LM_TYPES_HH__ +#define __LIBMULTISCALE_LM_TYPES_HH__ +/* -------------------------------------------------------------------------- */ +#include +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ + +/* -------------------------------------------------------------------------- */ +// error management +/* -------------------------------------------------------------------------- */ +#define LM_EXIT_FAILURE 1 +#define LM_EXIT_SUCCESS 0 + +/* -------------------------------------------------------------------------- */ +// TYPEDEFS +/* -------------------------------------------------------------------------- */ +typedef unsigned int UInt; +typedef double Real; +typedef Real REAL; + +/* -------------------------------------------------------------------------- */ +// ENUMS +/* -------------------------------------------------------------------------- */ + +enum DOFType { + dt_local_master = 1, + dt_local_slave = 2, + dt_local = 3, + dt_ghost = 4, + dt_all = 255 +}; + +/* -------------------------------------------------------------------------- */ + +enum GeomType { + BALL = 1, + CUBE = 2, + INTER = 3, + SUB = 4, + ELLIPSOID = 5, + UNION = 6, + CYLINDER = 7, + CHAUDRON = 8, + CUBE_SURFACE = 9 +}; +/* -------------------------------------------------------------------------- */ + + +enum COutputType { + OUTPUT_REF = 1 , + OUTPUT_REAL = 2 , + OUTPUT_NULL = 32767 +}; +/* -------------------------------------------------------------------------- */ + +enum CouplingStage { + COUPLING_STEP1 = 1 , + COUPLING_STEP2 = 2 , + COUPLING_STEP3 = 4 , + COUPLING_STEP4 = 8 , + COUPLING_STEP5 = 16 , + COUPLING_STEP6 = 32 , + COUPLING_STEP7 = 64 +}; +/* -------------------------------------------------------------------------- */ + +enum Operator { + OP_NONE = 0, + OP_AVERAGE = 1 , + OP_DENSITY = 2 , + OP_DEVIATION = 4 , + OP_MAX = 8 , + OP_MIN = 16, + OP_SUM = 64 +}; + +/* -------------------------------------------------------------------------- */ +enum FieldType { + _position0 = 0, + _position = 1, + _displacement = 2, + _velocity = 3, + _force = 4, + _stress = 5, + _temperature = 6, + _grouprank = 7, + _strain = 8, + _epot = 9, + _applied_force = 10, + _mass = 11, + ft_uninitialised = 32767 +}; +/* -------------------------------------------------------------------------- */ +enum ActionType { + at_stimulator = 0, + at_dumper = 1, + at_filter = 2, + at_compute = 4, + at_uninitialised = 32767 +}; +/* -------------------------------------------------------------------------- */ +enum LatticeType { + _not_defined, + mono_atom_1d, + hex_2d, + hex_2d_radial, + fcc_3d +}; + +template struct LatticeDim { + static const UInt value; +}; +template <> struct LatticeDim {static const UInt value = 1;}; +template <> struct LatticeDim {static const UInt value = 2;}; +template <> struct LatticeDim {static const UInt value = 2;}; +template <> struct LatticeDim {static const UInt value = 3;}; + +/* -------------------------------------------------------------------------- */ +enum IntegrationSchemeStage { + NONE_STEP = 0 , + PRE_DUMP = 1 , + PRE_STEP1 = 2 , + PRE_STEP2 = 4 , + PRE_STEP3 = 8 , + PRE_STEP4 = 16 , + PRE_STEP5 = 32 , + PRE_STEP6 = 64 , + PRE_STEP7 = 128 , + PRE_FATAL = 256 , //This stage only exists if a FATAL is triggered + ALL_STEP = 65536 +}; + +/* -------------------------------------------------------------------------- */ + +class IntegrationSchemeMask { +public: + + IntegrationSchemeMask(UInt mask){ + stage = mask; + } + + IntegrationSchemeMask(){ + stage = NONE_STEP; + }; + + bool operator & (const IntegrationSchemeStage & s) const{ + return (stage&s); + }; + + IntegrationSchemeMask & operator= (const IntegrationSchemeStage & s){ + stage = s; + return (*this); + }; + + IntegrationSchemeMask operator|= (const IntegrationSchemeStage & s){ + stage |= s; + return (*this); + }; + + IntegrationSchemeMask operator|= (const IntegrationSchemeMask & m){ + stage |= m.stage; + return (*this); + }; + + bool isNone(){ + return (stage == NONE_STEP); + } + + virtual void printself(std::ostream & stream, int indent = 0) const{ + + stream << "NONE_STEP"; + if ((*this) & PRE_DUMP) stream << "|PREDUMP"; + if ((*this) & PRE_STEP1) stream << "|PRE_STEP1"; + if ((*this) & PRE_STEP2) stream << "|PRE_STEP2"; + if ((*this) & PRE_STEP3) stream << "|PRE_STEP3"; + if ((*this) & PRE_STEP4) stream << "|PRE_STEP4"; + if ((*this) & PRE_STEP5) stream << "|PRE_STEP5"; + if ((*this) & PRE_STEP6) stream << "|PRE_STEP6"; + if ((*this) & PRE_STEP7) stream << "|PRE_STEP7"; + if ((*this) & PRE_FATAL) stream << "|PRE_FATAL"; + if ((*this) & ALL_STEP) stream << "|ALL_STEP"; + }; + + + +private: + + UInt stage; +}; + + +inline std::ostream & operator <<(std::ostream & stream, const IntegrationSchemeMask & _this) +{ + _this.printself(stream); + return stream; +} + +inline std::ostream & operator <<(std::ostream & stream, const IntegrationSchemeStage & _this) +{ + switch(_this){ + case NONE_STEP: stream << "NONESTEP"; break; + case PRE_DUMP : stream << "PREDUMP"; break; + case PRE_STEP1: stream << "PRE_STEP1"; break; + case PRE_STEP2: stream << "PRE_STEP2"; break; + case PRE_STEP3: stream << "PRE_STEP3"; break; + case PRE_STEP4: stream << "PRE_STEP4"; break; + case PRE_STEP5: stream << "PRE_STEP5"; break; + case PRE_STEP6: stream << "PRE_STEP6"; break; + case PRE_STEP7: stream << "PRE_STEP7"; break; + case PRE_FATAL: stream << "PRE_FATAL"; break; + case ALL_STEP : stream << "ALL_STEP"; break; + } + return stream; +} +/* -------------------------------------------------------------------------- */ + +class CommGroup { + +public: + + static const int id_all; + static const int id_none; + static const int id_invalid; + + CommGroup(){ + group_id = id_invalid; + } + + CommGroup(int id){ + this->setID(id); + } + + bool operator == (CommGroup & grp){ + return (grp.group_id == group_id); + } + + bool operator != (CommGroup & grp){ + return (grp.group_id != group_id); + } + + void setID(int id){group_id = id;}; + int getID(){return group_id;}; + +private: + + int group_id; +}; +/* -------------------------------------------------------------------------- */ + +enum PhysicalQuantity { + //physical quantities + Length, + Mass, + Energy, + Time, + MassDensity, + Force, + Pressure, + Temperature +}; +/* -------------------------------------------------------------------------- */ +// enum DDModelType { +// _DD2D, +// _PARADIS, +// }; + +/* -------------------------------------------------------------------------- */ +/* describes the orientation of the edge dislo by indication which + * quadrant is shifted towards x=0*/ +enum dislo_orientation { + TOP_RIGHT = 0 , + TOP_LEFT = 1, + BOTTOM_RIGHT = 2, + BOTTOM_LEFT = 3 +}; + + +/* -------------------------------------------------------------------------- */ + +__END_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + +#endif /* __LIBMULTISCALE_LM_TYPES_HH__ */ + diff --git a/src/common/model_list.hh b/src/common/model_list.hh new file mode 100644 index 0000000..a02415a --- /dev/null +++ b/src/common/model_list.hh @@ -0,0 +1,39 @@ +/** + * @file model_list.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This file simply includes the atomic, continnum and dislocation models .hh files + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_MODEL_LIST_HH__ +#define __LIBMULTISCALE_MODEL_LIST_HH__ +/* -------------------------------------------------------------------------- */ +//files generated by CMake +#include "atom_model_list.hh" +#include "continuum_model_list.hh" +#include "dd_model_list.hh" +/* -------------------------------------------------------------------------- */ + +#endif /* __LIBMULTISCALE_MODEL_LIST_HH__ */ diff --git a/src/common/ref_point.hh b/src/common/ref_point.hh new file mode 100644 index 0000000..22089a2 --- /dev/null +++ b/src/common/ref_point.hh @@ -0,0 +1,163 @@ +/** + * @file ref_point.hh + * + * @author Guillaume Anciaux + * + * @date Mon Sep 08 23:40:22 2014 + * + * @brief This is the class for reference that are any reference using a point-like description should inheritate from + * + * @section LICENSE + * + * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne) + * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides) + * + * LibMultiScale is free software: you can redistribute it and/or modify it under the + * terms of the GNU Lesser General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) any + * later version. + * + * LibMultiScale is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR + * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with LibMultiScale. If not, see . + * + */ + +#ifndef __LIBMULTISCALE_REF_POINT_HH__ +#define __LIBMULTISCALE_REF_POINT_HH__ +/* -------------------------------------------------------------------------- */ +__BEGIN_LIBMULTISCALE__ +/* -------------------------------------------------------------------------- */ + +template