WIP: Logger: scheme dependent output
In this merge request, I am implementing the possibility to have different scheme with the logger and also the different type of particle in the loader (but currently they cannot change during the simulation, it will be done in a next merge request).
If you wish to take a look at the API for the schemes, you can go to src/hydro/Gadget2/hydro_io.h
(last function), logger/hydro/Gadget2/logger_hydro.h
. Due to the new particle types in the loader, the python API has been changed a bit, you can take a look in logger/examples/reader_example.py
.
I will need a few days to clean it and then I will assign the merge request to Pedro.
Merge request reports
Activity
- Resolved by Loic Hausammann
assigned to @nnrw56
Lot of stuff in this merge request. I stopped my work before dealing with the star formation and the particle deletion in order to keep small. We will need to deal with !1019 (merged) before merging this one (and I will need to update this branch after the merge too).
mentioned in merge request !904 (closed)
643 struct gpart gpart; 644 645 const int with_hydro = e->policy & engine_policy_hydro; 646 const int with_grav = (e->policy & engine_policy_self_gravity) || 647 (e->policy & engine_policy_external_gravity); 648 const int with_stars = e->policy & engine_policy_stars; 649 650 struct mask_data list[100]; 651 652 // TODO do only the required particles (with_hydro) 653 // TODO add chemistry, cooling, ... + xpart + spart 654 655 /* Get all the fields that need to be written for the hydro. */ 656 int num_fields = 0; 657 if (with_hydro) { 658 num_fields = hydro_logger_write_particles(&part, list); changed this line in version 3 of the diff
A possibility would be to give the writing function to the user. I will only need to provide a function that decides if a field should be written and a way to initialize the fields. This is a quick and dirty code, but I hope it will be clear enough.
/** @brief Structure that deals with the decision of writing a field. This will be stored in the logger_writer. */ struct logger_struct { int mask; int frequency; int field_size; } /** @brief Decide if a field should be written */ int logger_should_write_field(struct logger_struct *logger, int mask) { if (!(mask & logger->mask)) { return 0; } /* We can use the frequency to decide for each field */ return 1; } /** @brief This function is implemented in hydro/scheme/hydro_io.h and initialize the logger_struct. */ void hydro_logger_init(struct logger_struct *logger) { logger_add_field_to_logger(logger, "InternalEnergy", sizeof(float)); // All the other fields } /** @brief This function is implemented in hydro/scheme/hydro_io.h and directly writes to the buffer */ void hydro_logger_write_particle(struct part *p, struct logger_struct *logger, int mask, char *buff) { if (logger_should_write_field(&logger[0], mask)) { memcpy(buff, p->u, sizeof(float)); } /* Now all the other fields */ } /** @brief This is the function that we call in the runner */ void logger_log_particle(struct part *p, struct logger_writer *log, int mask) { char *buff = malloc(logger_get_buffer_size(p, log, mask)); hydro_logger_write_particle(p, log->logger_struct, mask, buff); chemistry_logger_write_particle(p, log->logger_struct, mask, buff); // All the other type of scheme free(buff); }
- Resolved by Loic Hausammann
added 1 commit
- 3b6da3b0 - Logger: Implement logging multiple particles at the same time with different mask
630 549 } 631 550 632 551 /** 552 * @brief Initialize the variable logger_mask_data. 553 * 554 * @param log The #logger_writer. 555 * @param e The #engine. 556 */ 557 void logger_init_masks(struct logger_writer *log, const struct engine *e) { 558 559 /* Get the policies */ 560 const int with_hydro = e->policy & engine_policy_hydro; added 2 commits
added 187 commits
-
687225dd...e978eec6 - 161 commits from branch
master
- a1740345 - Logger: API implemented for the hydro
- 20c070b8 - Logger: testlogger.c is working
- 0ca53034 - Logger: hydro implemented
- d3c4110c - Logger: API is working for the hydro
- 79a36140 - Logger: Implement python for gpart and spart
- 5c22ba30 - Logger: implement particle_read for gravity + stars
- f698204d - Logger: test are working again
- 4c27798f - Logger: basename should contain the mpi basename
- ffd5b154 - Logger: implement read_all for the different type of particles
- 2f59a9f4 - Format
- f2076698 - Format
- 3eafce93 - Logger: add todo
- ea87b671 - Logger: remove global variable + update API loader
- 48d52194 - Logger: implement restart for masks
- 6d4de5c9 - Logger: update API
- dee277a2 - Logger: small changes to the reader
- 38d04a9b - Logger: Implement logging multiple particles at the same time with different mask
- f822b546 - Logger: use log_parts in log_all
- 84dbbf82 - Logger: remove offset_new from the copy functions
- 5bc98cac - Logger: implement dynamic array + hydro part deletion
- d9521788 - Logger: fix tests
- cb7d2c29 - Logger: log particle leaving the box
- 978a884d - Logger: implement delete particles
- 2943da2b - Logger: merge the two types of array
- 3e395b95 - Logger: move forward fully implemented
- f14a8805 - Logger: add hermite interpolation
Toggle commit list-
687225dd...e978eec6 - 161 commits from branch