wiki:LayoutObjects

Version 4 (modified by trac, 12 years ago) ( diff )

BackLinksMenu()

Layout Objects

Layouts can be used to load and unload data from the AMR data set onto distributed fixed grids. Layouts define the partition of the data as well as coordinates the communication required to transfer data between the AMR dataset and layouts as well as between different layouts. To create layouts you first need to add a USE statement to your problem.f90

  USE LayoutDeclarations

Then in ProblemModuleInit declare a variable pointer of type LayoutDef

  TYPE(LayoutDef), POINTER :: layout

Then create the Layout and load data into it

        CALL CreateLayout(GmGlobal, layout)
        layout%level = 0
        mB=layout%mB(MPI_ID,:,:)
        ALLOCATE(data(mB(1,1):mB(1,2), mB(2,1):mB(2,2),mB(3,1):mB(3,2),4))
        ALLOCATE(FieldID(4))
        FieldID=(/(i,i=1,4)/)
        CALL LoadFieldIntoLayout(layout, data, FieldID)

Once the AMR data is loaded into a distributed fixed grid data set, it can be manipulated in various ways - but one option is to modify the layout to be able to map the data back onto a different region of the AMR data set.

For example after loading the data above, we can unload the data onto the level 1 grids offset by 64 level 1 cells in x y and z.

   layout%level = 1
   layout%mB(:,:,:)=layout%mB(:,:,:)+64
   CALL UnloadFieldFromLayout(layout, data, FieldID)
  • We can also store the layout for later use… (iE we could store a 5123 fixed grid run as a layout and then in another simulation load it in to a level 2 region)

For example we could save the level 0 fixed grid 5123 as a layout inside of 1 simulation (during BeforeGlobalStep(0))

 CALL CreateLayout(GmGlobal, layout)
 layout%level = 0
 mB=layout%mB(MPI_ID,:,:)
 ALLOCATE(data(mB(1,1):mB(1,2), mB(2,1):mB(2,2),mB(3,1):mB(3,2),4))
 CALL LoadFieldIntoLayout(layout, data, FieldID)
 CALL StoreLayout(layout, data, 'ISO512')

and then load it into another simulation where the base grid is 128, and the finest level 3 grid is 1024 cells across - and we want to load the data into the middle of the domain on level 3

 CALL CreateLayout(GmGlobal, layout)
 CALL LoadLayout(layout, data, 'ISO512')
 layout%level = 2
 layout%mB(:,1:nDim,:)=layout%mB(:,1:nDim,:)+256 !Shift everything by 256 level 3 cells = 1/4 of the grid
 CALL UnloadFieldFromLayout(layout, data, FieldID, lHydroPeriodic, levels(n)%gmbc(1))
 CALL DestroyLayout(layout)
 DEALLOCATE(data)

The only caveat is that we must use the same number of processors for the saving and the loading. But once we reload and dump a chombo file - we could restart the simulation with a different number of processors.

Note: See TracWiki for help on using the wiki.