Version 1 (modified by 12 years ago) ( diff ) | ,
---|
Refinement Objects
Refinement Objects can be created within the ProblemModuleInit routine in problem.f90. To create refinements you first need to add two USE
statements to your problem.f90
USE Refinements USE Fields
Refinement objects can be used to control refinement in 3 different ways
- Refine on gradients (with or without shapes)
- Refine on variable thresholds (with or without shapes)
- Nested refinement around a shape (which can be moving)
- Nested derefinement outside a shape (which can also be moving)
If shapes are not used their are simple interfaces for creating refinement objects based on gradients or thresholds
Gradient based refinement
CALL AddRefinementCriterion(field, [tolerance], [scaleField], [scale])
where
field
is an integer handle corresponding to a various fluid quantity. See ProcessingFields for a list - or look in processing/fields.f90 for the most current list.tolerance
is an optional double (KIND=qPREC) that controls the size of gradient used for triggering refinement. The default is 1.0. Setting the tolerance to 0 is the same as not adding the refinement object at all.scaleField
is an optional integer handle that can be used to scale the fluid quantities - especially those that can be positive or negative (vector components). For example, velocities are often scaled to the sound speed.scale
} is an integer parameter that can either be LOGSCALE or LINEARSCALE which determines whether gradients are done in log space or linear space.
for example - adding density based refinement in log space can be done via
CALL AddRefinementCriterion(Mass_Field)
The tolerance for each refinement object is then adjusted by the value of qTolerance for the grids level
If the scale is LOGSCALE then the condition for refinement is that
Note that if a value like 'vx' goes from positive to negative, the log drops very quickly to -infinity. To prevent low velocities from triggering refinement - either a linear scale should be used - or a positive definite scale field like sound speed should be used to prevent the derivative from blowing up.
If the scale is LINEARSCALE then the condition for refinement is that
If a scalefield is defined, the quantity is divided by the scale field before looking for gradients.
Threshold based refinement
CALL AddRefinementThreshold(field, limit, threshold, [scalefield])
where
field
is an integer handle corresponding to a various fluid quantity. See ProcessingFields for a list - or look in processing/fields.f90 for the most current list.threshold
is an array of n values corresponding to levels 0:n-1 that sets the max or min value for refinement depending on whether the threshold is an upper or lower limit.limit
is a logical equal to LESSTHAN or GREATERTHAN depending on whether the threshold is a max or min value for triggering refinement.
for example - the TrueLove criterion for self-gravity is that refinement should be triggered whenever the Jeans Length is less than 4 cells on a given level. It is implemented in module_control.f90 by
CALL AddRefinementThreshold(JeansLength_Field, LESSTHAN, (/(4d0*levels(i)%dx,i=0,MaxLevel)/))
Geometric Based Refinement
Shapes can be used to modify refinement in 4 ways - but all using ShapeObjects.
Completely Refining within shapes
First to force refinement within a shape just create the refinement object and then create and define its shape.
USE Refinements USE Shapes ... TYPE(RefinementDef), POINTER :: Refinement ... CALL CreateRefinement(Refinement) CALL CreateShape(Refinement%Shape) Refinement%Shape%size_param=(/2d0,2d0,2d0/) Refinement%Shape%vel=(/1d0,0d0,0d0/) CALL SetShapeBounds(Refinement%Shape) Refinement%BufferCells=2
This creates a refinement object with default parameters, then creates a default shape (sphere located at 0,0,0 with radius 1) and then adjusts the radius to be 2 and puts the shape in motion to the right. Then the call to SetShapeBounds is needed after modifying the shapes original position or size or type. Then the number of buffer cells between the nested grids is set to be 2 which helps to ensure proper nesting.
Gradient based refinement within shapes
This is essentially the same as above but in addition a field to refine needs to be specified
So to do gradient based refinement of density within that shape - just add the following line
Refinement%field=Mass_Field Refinement%tolerance=1 ! Default value is 1 so this line is not needed unless a different value is desired Refinement%scale=LOGSCALE ! Default value is LOGSCALE so again this line not needed unless a different scale is desired Refinement%ScaleField=P_Field ! If for some crazy reason you wanted to scale the density by the pressure before looking for gradients you could add this line.
Threshold based refinement within shapes
You could also do density threshold based refinement within that shape by adding instead…
Refinement%field=Mass_Field Refinement%Threshold(0:4)=(/10d0,20d0, 40d0,80d0,160d0/)
Note that if any thresholds are defined for the refinement object, it will ignore any gradient based options.
Completely Derefining outside of a shape
Finally to force nested derefinement outside of a shape, just set the tolerance to be negative (ie add the following…)
Refienment%tolerance = -1d0
If you do this - it should be the last refinement object you add since the refinement objects will trigger refinement in the order they are created.
Default Refinement Objects
There are a set of default refinement objects created that use the array RefineVariableFactors in physics.data that setup refinement in log_density, log_momentum (scaled to rho cs), log_Bx (scaled to Pressure½). If self gravity is turned on then additional there is refinement setup for Phi scaled to cs2 and a refinement threshold
Attachments (5)
- DensityBasedRefinement.png (67.4 KB ) - added by 12 years ago.
- DensityThreshold.png (62.1 KB ) - added by 12 years ago.
- DerefineExample.png (62.0 KB ) - added by 12 years ago.
- SpaceBasedRefinement.png (33.9 KB ) - added by 12 years ago.
- SpaceBasedRefinement.gif (806.6 KB ) - added by 12 years ago.
Download all attachments as: .zip