wiki:ControllingRefinement

Version 30 (modified by Jonathan, 12 years ago) ( diff )

Controlling Refinement in AstroBEAR 2.0

Overview

Refinement of grids is controlled by RefinementObjects or by setting Info%ErrFlag(i,j,k)=1 in the Problem modules subroutine ProblemSetErrFlag(Info). If a cell is marked for refinement by more then one routine there is no problem since it will still be refined. Setting Info%ErrFlag(i,j,k)=0 however, is generally not a good idea since another flagging routine may have previously marked the cell for refinement with good reason.

After all of the cells in a given parent info have been potentially marked for refinement, the subroutine NewSubGrids in data_info_ops.f90 groups the flagged cells into rectangular patches so that every cell is within a patch.

  • The previous version of the code (which is also used if lUseOriginalNewSubGrids = .true. in global.data) then split and shrunk grids so that no patch had a filling ratio less then the DesiredFillRatio for that level set in global.data. Having a DesiredFillRatio of 1.0 will effectively limit refinement to only cells marked for refinement however the MinimumGridSize also set in global.data may limit the actual desired fill ratios. Having many small grids is generally not as efficient as having a few larger grids even if they comprise more cells and so a desired fill ratio of 1.0 does not usually give the best performance. Values of .7 to .9 are recommended for optimal performance.
Fill Ratio = .7 Fill Ratio = .9 Fill Ratio = 1.0

Additionally one can increase the minimum grid size to reduce the prevalence of long slender grids. Below we increased the minimum refined patch to be 4 parent cells. (This results in actual child grids that are at least 8x8)

  • The newer default version (lUseOriginalNewSubGrids = .false.) uses an improved algorithm that takes into consideration the additional cost of smaller grids. It splits and shrinks but stops when doing so will create more overall work. The DesiredFillRatio and MinimumGridSize are ignored.

After the new patches are determined, the distribution algorithm may split these patches to accommodate load balancing. For example running on 3 processors we get

Fill Ratio = .7 Fill Ratio = .9 Fill Ratio = 1.0

Changing qTolerance and DesiredFillRatios

The most direct and quickest way to change refinement is to change the qTolerance and DesiredFillRatios arrays which are both located in the global.data file. Each element of these arrays is specific to that level. For example, the first element is for the root level, the next element is for the 1st level of refinement, and so on. qTolerance effectively sets how large a gradient must be in order for those two cells to be refined. Higher qTolerance —> less refinement. DesiredFillRatios affects the way astrobear lays down grids or patches for refinement. For example, if the DesiredFillRatio is 0.7, then the AMR will lay down patches so that at least 70% of each patch contains cells marked for refinement. As a result of this process, you will often get cells being refined which were not initially marked for refinement. In general, lower DesiredFillRatios —> more refinement. Note that changing these arrays is very problem specific.

Below are snapshots of the mesh for a simulation of the Rayleigh-Taylor Instability. You are looking at the peak of the interface at t = 4.0 with 2 levels of AMR. In the first snapshot there is improper nesting. More refinement at the root level and/or less at the 1st level would fix this. Note that in this problem the density gradient is very abrupt, and thus it is possible that while some frames have proper nesting, others may not.

qTolerance = (0.2, 0.2) DesiredFillRatios = (0.7, 0.7) qTolerance = (0.005, 0.3) DesiredFillRatios = (0.7, 0.7)
qTolerance = (0.2, 0.2) DesiredFillRatios = (0.25, 0.7) qTolerance = (0.005, 0.3) DesiredFillRatios = (0.25, 0.7)

Jeans Criteria

When Self Gravity is turned on, refinement is flagged based on the Jeans criterion

ProblemSetErrFlag

Users can manually set error flags based on any other criteria (position, etc…) in their problem module. As an example, the Rayleigh-Taylor Instability has an analytic solution. Therefore, one can get a good estimate of where the mesh should be refining at any given time. In this simulation, the mesh started refining in the middle region where the initial interface is located, and the refinement region expanded upwards and downwards as the instability grew: RT Expanding Refinement Region. This is not the most efficient way to refine for this problem, but it gives an idea of how one can refine based on position and time. Here is the code so you can see precisely how this is done in a problem module: RT problem.f90

Particles

Sink Particles have a buffer array that triggers refinement within a certain distance of a particle.

Visualizing Error Flags

You can plot the value of Info%ErrFlag by turning on lOutputErrFlag in process.data

Attachments (13)

Note: See TracWiki for help on using the wiki.