diff --git a/homework4/CMakeLists.txt b/homework4/CMakeLists.txt index 7995714..556966a 100644 --- a/homework4/CMakeLists.txt +++ b/homework4/CMakeLists.txt @@ -1,112 +1,109 @@ cmake_minimum_required (VERSION 3.1) project (Particles) cmake_policy(VERSION 3.3) set(CMAKE_EXPORT_COMPILE_COMMANDS 1) set(CMAKE_CXX_STANDARD 14) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") ################################################################ # libpart ################################################################ add_library(part SHARED compute_boundary.cc compute_verlet_integration.cc particle.cc planet.cc compute_gravity.cc csv_reader.cc particles_factory_interface.cc planets_factory.cc compute_contact.cc compute_kinetic_energy.cc csv_writer.cc system.cc compute_energy.cc compute_potential_energy.cc ping_pong_ball.cc material_point.cc system_evolution.cc ping_pong_balls_factory.cc compute_interaction.cc compute_temperature.cc material_points_factory.cc) ################################################################ # FFTW ################################################################ #include_directories("/usr/local/Cellar/fftw/3.3.8_1/include") #option(USE_FFTW "Use fftw library" OFF) # #if(USE_FFTW) # add_definitions(-DUSE_FFTW) # find_package(FFTW) # target_link_libraries(part ${FFTW_LIBRARIES}) #endif(USE_FFTW) ################################################################ # Particles executable ################################################################ add_executable(particles main.cc) target_link_libraries(particles part) ################################################################ # Google test ################################################################ #add_subdirectory(googletest) # #add_executable(test_kepler test_kepler.cc) #target_link_libraries(test_kepler part gtest_main gtest pthread) # #if(USE_FFTW) #add_executable(test_fft test_fft.cc) #target_link_libraries(test_fft part gtest_main gtest ${FFTW_LIBRARIES} pthread) #endif(USE_FFTW) ################################################################ # Doxygen ################################################################ #find_package(Doxygen) #if (DOXYGEN_FOUND) # ## to set other options, read: https://cmake.org/cmake/help/v3.9/module/FindDoxygen.html #doxygen_add_docs( # doxygen # ${PROJECT_SOURCE_DIR} # COMMENT "Generate html pages" #) #add_custom_target(doc DEPENDS doxygen) #endif(DOXYGEN_FOUND) ################################################################ # Pybind ################################################################ -include_directories("/usr/local/Cellar/pybind11/2.4.3/include") -#option (USE_PYTHON "Use pybind library" ON) +option (USE_PYTHON "Use pybind library" ON) -##### CLion is not recognizing pypart.cc as linked to a target if we use the if option here below in the CMakeFile - -#if (USE_PYTHON) +if (USE_PYTHON) find_package(pybind11 REQUIRED) # or add_subdirectory(pybind11) -#add_subdirectory(pybind11) + add_library(pypart MODULE pypart.cc) target_link_libraries(pypart PRIVATE pybind11::module part) #set_target_properties(pypart PROPERTIES # PREFIX "${PYTHON_MODULE_PREFIX}" # SUFFIX "${PYTHON_MODULE_EXTENSION}" # ) set_target_properties(pypart PROPERTIES PREFIX "") set_target_properties(pypart PROPERTIES OUTPUT_NAME "pypart") file( COPY ${CMAKE_CURRENT_SOURCE_DIR}/main.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/ ) -#endif(USE_PYTHON) +endif(USE_PYTHON) diff --git a/homework4/README.txt b/homework4/README.txt index bf156fc..2aab3f6 100644 --- a/homework4/README.txt +++ b/homework4/README.txt @@ -1,76 +1,80 @@ EXERCISE 4 Alexis Sáez Uribe Carlo Peruzzo -NOTE: Please, make sure of having a folder called "dumps" in the particle code directory to store the results of the simulations +NOTE(1): Please, make sure of having a folder called "dumps" in the particle code directory to store the results of the simulations +NOTE(2): We intentionally deactivated the following sections of the CMakeLists.txt because they were not used: +- FFTW +- Doxygen +- Google test --- Exercise 1.2: The overloaded method createSimulation (three arguments) is taking as an input the functor/function called "createComputes" that has been defined in the file main.py. This function is specific for the type of particle that the user has chosen, it sets some physical parameters and some methods for the simulation. The function createComputes is stored by createSimulation in a object of type std::function defined in the header " Instances of std::function can store, copy, and invoke any Callable target -- functions, lambda expressions, bind expressions, or other function objects, as well as pointers to member functions and pointers to data members. " Coming back to the method createSimulation, after storing "createCompute", it executes the method createSimulation (the non overloaded one, with two arguments) which is specific of the daughter class related to the selected type of particle and it calls the createComputes stored in the object of type std::function. ---- Exercise 2.2: For the compute objects type we specified that we want to use shared pointers as object holder, because the structure of the particle code involves the use of arrays of shared pointers. Additional Note: For the case of factory objects, we used the return_value_policy::reference in order to reference an existing object and preventing python from taking its ownership. We use return_value_policy::reference for the factory objects when using the Reference an existing object, but do not take ownership. In this way, the C++ side is responsible for managing the object’s lifetime and deallocating it when it is no longer used. ---- Exercise 5: the solution of exercise 5 is contained in the file exercise_5.py in order to run exercise_5.py you need to specify in the order: 1- the name of the planet 2- the name of the folder containing the reference solution for the planet (*) 3- the name of the folder containing the computed solution for the planet (*) (*)= or the path of the folder if it is not in the same folder as the script. For example the parameters required when launching the python script are: mercury Trajectories/ dumps/ The output error will be printed on the screen ---- Exercise 6 The solution of exercise 6 is contained in the file exercise_6.py in order to run exercise_6.py you need to specify in the order: 1- number of time steps 2- time step 3- name of the planet 4- scale factor for the velocity 5- name of the input file containing the initial state of the planet system for the particle code (*) (*)= or the path to the file if it is not in the same folder as the script. For example the parameters required when launching the python script are: 365 1 mercury 2.5 init.csv The output error will be printed on the screen ---- Exercise 7 The solution of exercise 7 is contained in the file exercise_7.py in order to run exercise_7.py you need to specify in the order: 1- number of time steps 2- time step 3- name of the planet 4- name of the input file containing the initial state of the planet system for the particle code (*) (*)= or the path to the file if it is not in the same folder as the script. The parameters required when launching the python script are: 365 1 mercury init.csv The output error will be printed on the screen and the plot will be popped up ----