Commit 5a80e451 authored by BRAMAS Berenger's avatar BRAMAS Berenger

add a few words about the P2P

parent 44fea386
/*! \page p2p P2P
* In this section, we briefly discuss the 3 P2P functions that the kernels have to implement.
* <pre class='brush: cpp'>
* virtual void P2P(const FTreeCoordinate& inLeafPosition,
* ContainerClass* const FRestrict targets, const ContainerClass* const FRestrict sources,
* ContainerClass* const directNeighborsParticles[], const int neighborPositions[],
* const int size) = 0;
*
* virtual void P2POuter(const FTreeCoordinate& /*inLeafPosition*/,
* ContainerClass* const FRestrict /*targets*/,
* ContainerClass* const /*directNeighborsParticles*/[], const int /*neighborPositions*/[],
* const int /*size*/) = 0;
*
* virtual void P2PRemote(const FTreeCoordinate& /*inLeafPosition*/,
* ContainerClass* const FRestrict /*targets*/, const ContainerClass* const FRestrict /*sources*/,
* const ContainerClass* const /*directNeighborsParticles*/[],
* const int /*neighborPositions*/[], const int /*size*/) {
* }
* </pre>
* These functions are not necessary called at all times, it depends on the target=source or target!=source (TSM) configuration.
* The maximum number of neighbors (size) is 26 (+/-1 in each dimension) and the relative positions each neighbors is given in directNeighborsParticles.
* The relative position is filled by the formula: (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1
* This formula is given in the FOctree class, and getLeafsNeighbors method.
* \section P2P
* The P2P is always called (only once!) for each leaf and it provides the target leaf ptr,
* the source ptr and maybe some neighbors.
* If the source ptr is equal to the target ptr it means that we are in a NO-tsm and that the same particles exist in both leaves.
* It also means that the neighbors are both sources and targets too.
* Such that a usual implementation is given by (see FRotationKernel):
* <pre class='brush: cpp'>
* void P2P(const FTreeCoordinate& inPosition,
* ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources,
* ContainerClass* const inNeighbors[], const int neighborPositions[],
* const int inSize) override {
* if(inTargets == inSources){
* FP2PRT<FReal>::template Inner<ContainerClass>(inTargets);
* P2POuter(inPosition, inTargets, inNeighbors, neighborPositions, inSize);
* }
* else{
* const ContainerClass* const srcPtr[1] = {inSources};
* FP2PRT<FReal>::template FullRemote<ContainerClass>(inTargets,srcPtr,1);
* FP2PRT<FReal>::template FullRemote<ContainerClass>(inTargets,inNeighbors,inSize);
* }
* }
* </pre>
* In this code we check if we are in TSM or not by comparing the pointers.
* If we are in source=target then we carefully compute the P2P inside the leaf (Inner) and
* then call the P2POuter for the neighbors.
* Otherwise we use the P2PRemote.
* \section P2POuter
* The P2P is use when some contribution should be added in NO TSM (so with target=source).
* This is why the source leaf is not provided because the it should be taken into account in the P2P function.
* We usually deal with symmetric (or anti-symmetric) functions and so a classic implementation is given by:
* <pre class='brush: cpp'>
* void P2POuter(const FTreeCoordinate& /*inLeafPosition*/,
* ContainerClass* const FRestrict inTargets,
* ContainerClass* const inNeighbors[], const int neighborPositions[],
* const int inSize) override {
* int nbNeighborsToCompute = 0;
* while(nbNeighborsToCompute < inSize
* && neighborPositions[nbNeighborsToCompute] < 14){
* nbNeighborsToCompute += 1;
* }
* FP2PRT<FReal>::template FullMutual<ContainerClass>(inTargets,inNeighbors,nbNeighborsToCompute);
* }
* </pre>
* Here we proceed only the neighbors with a relative position < 14 because we compute in both ways (Fij=-Fji).
* So the neighbors > 14 are going to be computed when the current cell will be in their neighbor data.
* \section P2PRemote
* The P2PRemote is used to add contributions in the TSM configuration or from remote leaves (when using MPI).
* This is why the neighbors are const.
* Remember that in ScalFMM a const is maybe a way to ensure that you are not modifying data share between several threads.
*/
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment