Giter Club home page Giter Club logo

Comments (14)

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

Are you talking about the error estimate is done on the finest level first and then down to the base level? Could you explain why you want the other way?

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

Yes, exactly.

As far as I see, the regrid process is always called within a loop from the base level up to the current top level. So, one regrids some levels multiple time. I don't know the reason why it's done like this ... but I think there is one for sure.
However, in my application I will regrid always from the coarsest level up to the finest, thus, it would be faster just to regrid every level once.

from amrex.

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

So I think what's need to be changed is not MakeNewGrids but how regrid, which calls NakeNewGrids, is called. Could you show us the code how regrid is called inside time stepping loops?

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

In case of my application is just call regrid(0, time) assuming all levels are initialized. In case of AMReX it's called in AMReX_Amr.cpp in a loop.
The for-loop downwards is implemented in MakeNewGrids, thus, I'm not sure if one can change the behaviour if one calls regrid differently.

from amrex.

drummerdoc avatar drummerdoc commented on August 19, 2024

The regrid downwards ensures that each levels ends up properly nested. How would you propose to guarantee that otherwise?

from amrex.

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

I thought you are not using Amr and AmrLevel and instead you have own class derived from AmrCore. Have you switched?

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

@WeiqunZhang I'm using my own class, you're right. But it's now derived from AmrMesh instead of AmrCore.

@drummerdoc In order to set up the grids of level l+1 the grids of level l need to be set up first. Therefore, going "upwards" shouldn't give bad results, since level l+1 grids can't exist without level l grids.
In the loops of AMReX the base level is increased in every iteration, thus, all grids from the finest to the base level are rebuilt. One actually performs a double loop, where the outer loop goes upwards and inner loop downwards.

from amrex.

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

Are you sure your class is derived from AmrMesh, not AmrCore? Note that regrid function does not even exist in AmrMesh. Do you have your own version? Also Particle class depends on AmrCore, not AmrMesh.

Again, #70 (comment)

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

Yes, I'm sure that it's AmrMesh. Since we use the OPAL particle class I thought it's better to inherit from AmrMesh. I then copied the regrid function into my Amr class.

from amrex.

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

Here is my guess of what you need and why. All your particles are on the finest level. Other than particles, there are no other data that cannot be generated from particles. You want to call error estimate function on the finest level and only on the finest level, because error estimate is expensive. Then coarse level grids are generated based on the finest level grids. Is that correct? If that's the case, I think all you need is for virtual void ErrorEst (int lev, TagBoxArray& tags, Real time, int ngrow) to return immediately if lev is not max_level-1.

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

Depending on the tagging strategy the particles do not necessarily live on the finest level.
Since the finest levels are tagged first, I basically agree with you on the fact that coarse level grids are generated based on the finest level grids -- but couldn't it done the other way around?
However, I'll try your approach and will let you know.

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

I ran two short tests on 4 cores each, where I perform 2000 steps (overall CPU total time around 1000s). After each step I perform a regrid. I had following regrid strategies:

1st approach (as done in AMReX)

for (int i = 0; i <= lev_top; ++i)
    amrobj_mp->regrid(i, time);

Total regrid time: 137s

2nd approach

for (int i = lev_start; i <= lev_top; ++i)
    amrobj_mp->regrid(i, time);

where lev_start is the first level with particles.

Total regrid time: 100s

from amrex.

WeiqunZhang avatar WeiqunZhang commented on August 19, 2024

The loop in AMReX is not like what's in your comment. If that's the real code in your application without any simplification, you are indeed calling regrid too many times and that's why we wanted to see your code in #70 (comment) and #70 (comment).

But I believe Andrew has already suggested in his correspondence with you you can just do amrobj_mpi->regrid(0,time) (except during initialization)?

And as suggested in #70 (comment), your virtual void EstError can be like,

if (lev < std:min(finest_level,max_level-1)) return;

from amrex.

matt-frey avatar matt-frey commented on August 19, 2024

Except to the call to okToRegrid(i) you also perform a loop in Amr::timeStep over the levels incrementing the base level ...

How it's currently implemented:

int lev_top = std::min(amrobj_mp->finestLevel(), maxLevel - 1);
                
*gmsg << "* Start regriding:" << endl
           << "*     Old finest level: "
           << amrobj_mp->finestLevel() << endl;
                
for (int i = 0; i <= lev_top; ++i)
    amrobj_mp->regrid(i, lev_top, t_m * 1.0e9 /*time [ns] */);
            
*gmsg << "*     New finest level: "
           << amrobj_mp->finestLevel() << endl
           << "* Finished regriding" << endl;

I initialize all levels at the beginning, thus, the call amrobj_mp->regrid(0, time) should be fine.

from amrex.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.