Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

time interpolate levelGhostParticles in IonUpdater #102

Closed
nicolasaunai opened this issue Jan 23, 2020 · 0 comments
Closed

time interpolate levelGhostParticles in IonUpdater #102

nicolasaunai opened this issue Jan 23, 2020 · 0 comments
Assignees
Labels
core feature WIP work in progress
Milestone

Comments

@nicolasaunai
Copy link
Member

Context

Level ghost particles contributing to the moments have two origins:

  • those refined from the next coarser at its former time step : LevelGhostParticlesOld
  • those refined from the next coarser at its current time step : LevelGhostParticlesNew

when calculating the moments on a given level at an arbitrary time, let alpha be the ratio of the current time since the last level synchronisation time (next coarser former time step) and the total duration of the next coarser time step, then the contribution of the level ghost particles is :

alpha * levelGhostParticlesNew + (1-alpha) * levelGhostParticlesOld.

alpha being 0 before the first time step of the sub cycle, and 1 at the end of the sub cycle

image

In ion_updater.h we have :

double alpha = 0.5;
interpolator_(std::begin(pop.levelGhostParticlesNew()),
                      std::end(pop.levelGhostParticlesNew()), pop.density(), pop.flux(), layout,
                      /*coef = */ alpha);


interpolator_(std::begin(pop.levelGhostParticlesOld()),
                       std::end(pop.levelGhostParticlesOld()), pop.density(), pop.flux(), layout,
                       /*coef = */ (1. - alpha));

This means that for now, alpha is hard-coded to be 0.5.

Objective

This issue aims at getting alpha defined correctly, i.e. to be the current time elapsed since last sync point. divided by the total duration of the next coarser time step.

hint:

this is done in hybrid_hybrid_messenger_strategy.h

        double timeInterpCoef_(double const beforePushTime, double const afterPushTime)
        {
            return (afterPushTime - beforePushTime)
                   / (afterPushCoarseTime_ - beforePushCoarseTime_);
        }

and used in the same file:

        virtual void fillIonMomentGhosts(IonsT& ions, SAMRAI::hier::PatchLevel& level,
                                         double const beforePushTime,
                                         double const afterPushTime) override
        {
            auto alpha = timeInterpCoef_(beforePushTime, afterPushTime);


            for (auto patch : level)
            {
                auto dataOnPatch = resourcesManager_->setOnPatch(*patch, ions);
                auto layout      = layoutFromPatch<GridLayoutT>(*patch);

                for (auto& pop : ions)
                {
                    // first thing to do is to project patchGhostParitcles moments
                    auto& patchGhosts = pop.patchGhostParticles();
                    auto& density     = pop.density();
                    auto& flux        = pop.flux();

                    interpolate_(std::begin(patchGhosts), std::end(patchGhosts), density, flux,
                                 layout);


                    // then grab levelGhostParticlesOld and levelGhostParticlesNew
                    // and project them with alpha and (1-alpha) coefs, respectively
                    auto& levelGhostOld = pop.levelGhostParticlesOld();
                    interpolate_(std::begin(levelGhostOld), std::end(levelGhostOld), density, flux,
                                 layout, 1. - alpha);

                    auto& levelGhostNew = pop.levelGhostParticlesNew();
                    interpolate_(std::begin(levelGhostNew), std::end(levelGhostNew), density, flux,
                                 layout, alpha);
                }
            }
        }
@nicolasaunai nicolasaunai added feature core WIP work in progress labels Jan 23, 2020
@nicolasaunai nicolasaunai added this to the PHARE 1.0 milestone Jan 23, 2020
@nicolasaunai nicolasaunai self-assigned this Jan 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature WIP work in progress
Projects
None yet
Development

No branches or pull requests

1 participant