diff --git a/homework4/README.txt b/homework4/README.txt index 032cfcc..ef68051 100644 --- a/homework4/README.txt +++ b/homework4/README.txt @@ -1,70 +1,72 @@ EXERCISE 4 Alexis Sáez Uribe Carlo Peruzzo --- Exercise 1.2: -The overloaded method createSimulation (three arguments) is taking as an input the 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 initializes +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 (non overloaded, two arguments) that is specific of the daughter class related to the selected type of particle and +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: -< 1st part of the answer > -return_value_policy::reference -Reference an existing object, but do not take ownership. -The C++ side is responsible for managing the object’s lifetime and deallocating it when it is no longer used. -Warning: undefined behavior will ensue when the C++ side deletes an object that is still referenced and used by Python. +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. -< 2nd part of the answer > -For the compute classes we need to specify that we want to use shared pointers as object holder. ---- 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- the name of the planet -2- the scale factor for the velocity -3- the name of the input file containing the initial state of the planet system for the particle code (*) -4- the name of the output file containing the initial state of the planet system for the particle code scaled according to the scale factor (*) +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: -mercury 2.6 init.csv init_scaled.csv - +365 1 mercury 2.5 init.csv The output error will be printed on the screen ---- Exercise 7 (TO COMPLETE) 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- ... 2- ... For example the parameters required when launching the python script are: ... The output ... ----