Conversation
52e6375 to
7a65f0e
Compare
tests/input_files/particle_sph_2d_pdbody_dbc_per_particle.4C.yaml
Outdated
Show resolved
Hide resolved
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.hpp
Outdated
Show resolved
Hide resolved
slfuchs
left a comment
There was a problem hiding this comment.
I also like this feature a lot! This enables not only simple moving boundaries in SPH but more complex examples
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.cpp
Outdated
Show resolved
Hide resolved
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.hpp
Outdated
Show resolved
Hide resolved
3f9741c to
fa49c46
Compare
fa49c46 to
90d2745
Compare
ppraegla
left a comment
There was a problem hiding this comment.
One question and some nitpicking
| // get reference to function (lazy cache fill handles transferred particles) | ||
| if (!per_particle_function_cache_.contains(funct_id)) | ||
| per_particle_function_cache_[funct_id] = | ||
| &Global::Problem::instance()->function_by_id<Core::Utils::FunctionOfSpaceTime>(funct_id); | ||
| const auto& function = *per_particle_function_cache_.at(funct_id); |
There was a problem hiding this comment.
Out of interest, why do you use the lazy cache instead of filling the map during setup? Do you expect some performance savings in case one processor does not own particles of a type subjected to a dirichlet function?
My understanding of lazy initialization is that it is used when it is expensive to create objects that are rarely used. Though, getting the functions is not that expensive and they will definitely be used at some point during the simulation. But maybe I'm missing something.
There was a problem hiding this comment.
As funct_id is only known on the processor which owns/ghost a particle during setup, I expect the cache to be filled "locally". Assuming a phase with per particle dbc is not present on a processor, I expect that proc not to fill the cache properly.
While writing these lines, I see the solution: A brief MPI communcation is necessary to fill the cache with all possible functs that are present one any proc. Then every proc has a complete cache and if a particle arrives newly on this proc, it immediately uses the proper cache.
My previous concern was that a check is necessary whether the cache does not contain a certain FUNCT on a certain proc and need to be filled in that moment after a partile transfer. This sounds like lazy init which I chose.
Will change to do communication and set it up during setup. Then, no check is necessary on the fly.
@ppraegla Thanks for your question.
There was a problem hiding this comment.
Good catch, I would also do a communication during setup.
There was a problem hiding this comment.
At the point where the setup of the dirichlet_bc is called, there should still be all particles on proc 0. The distributing happens in distribute_load_among_procs. However, it is probably better to include the communication in case the order of the functions is changed.
There was a problem hiding this comment.
Are you sure? When reading particles from the input file this is true. But when generating particles with the particle generator in the code I think every proc generates particles that are to be located within its processor domain.
There was a problem hiding this comment.
@slfuchs you are right. If one implements some particle generation logic in the code, it will generate particles per process. I only considered the reading from the input file.
There was a problem hiding this comment.
setup() is too early (particle container not yet populated). MPI_Comm needs to be availble. I prefer to have no distinction between restart and standard startup. Therefore, starting point is particle_algorithm now. Maybe not overwhelmingly beautiful but definitly obvious and clear what happens.
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.cpp
Outdated
Show resolved
Hide resolved
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.cpp
Outdated
Show resolved
Hide resolved
src/particle/src/algorithm/4C_particle_algorithm_dirichlet_bc.cpp
Outdated
Show resolved
Hide resolved
90d2745 to
e58d26e
Compare
Description and Context
Extracted the per particle Dirichlet boundary condition from #1881 into a separate PR.
The first review comments are already included from the original PR.
DIRICHLET_FUNCTin particle definitions (e.g.,"TYPE pdphase POS ... DIRICHLET_FUNCT 1")DIRICHLET_FUNCT 1are subject to a Dirichlet boundary condition prescribed byFUNCT1Related Issues and Pull Requests
(#1881)
Interested parties
@alhermann