Chombo + EB + MF  3.2
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MeshRefine Class Referenceabstract

Class which manages grid generation. More...

#include <MeshRefine.H>

Inheritance diagram for MeshRefine:
Inheritance graph
[legend]

Public Member Functions

 MeshRefine ()
 default constructor – leaves object in an unusable state More...
 
 MeshRefine (const Box &a_baseDomain, const Vector< int > &a_refRatios, const Real a_fillRatio, const int a_blockFactor, const int a_bufferSize, const int a_maxSize)
 full constructor – leaves object in usable state More...
 
 MeshRefine (const ProblemDomain &a_baseDomain, const Vector< int > &a_refRatios, const Real a_fillRatio, const int a_blockFactor, const int a_bufferSize, const int a_maxSize)
 full constructor – leaves object in usable state More...
 
virtual ~MeshRefine ()
 destructor More...
 
void define (const Box &a_baseDomain, const Vector< int > &a_refRatios, const Real a_fillRatio, const int a_blockFactor, const int a_bufferSize, const int a_maxSize)
 define function – size of RefRatios will define maximum number of levels More...
 
virtual void define (const ProblemDomain &a_baseDomain, const Vector< int > &a_refRatios, const Real a_fillRatio, const int a_blockFactor, const int a_bufferSize, const int a_maxSize)
 define function – size of RefRatios will define maximum number of levels More...
 
virtual int regrid (Vector< Vector< Box > > &a_newmeshes, const IntVectSet &a_tags, const int a_baseLevel, const int a_topLevel, const Vector< Vector< Box > > &a_oldMeshes)
 create hierarchy of grids from a single level of tags More...
 
virtual int regrid (Vector< Vector< Box > > &a_newmeshes, Vector< IntVectSet > &a_tags, const int a_baseLevel, const int a_topLevel, const Vector< Vector< Box > > &a_oldMeshes)
 create hierarchy of grids from tags at all levels More...
 
const Vector< int > & refRatios () const
 returns vector of refinement ratios More...
 
Real fillRatio () const
 returns fillRatio More...
 
int blockFactor () const
 returns blocking factor More...
 
int bufferSize () const
 returns proper nesting buffer size More...
 
int maxSize () const
 returns maximum box size in any dimension – 0 means no limit More...
 
void refRatios (const Vector< int > &a_nRefVect)
 sets vector of refinement ratios More...
 
virtual void fillRatio (const Real a_fill_ratio)
 sets fillRatio More...
 
virtual void blockFactor (const int a_block_factor)
 sets blocking factor More...
 
virtual void bufferSize (const int a_buffer_size)
 sets proper nesting buffer size More...
 
virtual void maxSize (const int a_max_size)
 sets maximum box size in any dimension – 0 means no limit More...
 
bool isDefined () const
 has this object been defined properly? More...
 
void granularity (int a_granularity)
 sets proper nesting region granularity. More...
 
virtual void makeBoxes (Vector< Box > &a_mesh, const IntVectSet &a_tags, const IntVectSet &a_pnd, const ProblemDomain &a_domain, const int a_maxSize, const int a_totalBufferSize) const =0
 constructs a set of boxes which covers a set of tagged cells More...
 
void setPNDMode (int a_mode)
 
void setRefineDirs (const IntVect &a_refineDirs)
 set each component to 1 or 0 according to whether or not we refine in that direction. Default IntVect::Unit. More...
 
IntVect inRefineDirs (int a_val) const
 returns IntVect with component d set to a_val if m_refineDirs[d] == 1; else 1. More...
 
void restrictUnrefined (Box &a_box) const
 
void restrictUnrefined (IntVectSet &a_ivs) const
 

Protected Member Functions

virtual void computeLocalBlockFactors ()
 computes local blockFactors used internally to enforce the BlockFactor More...
 
virtual bool properlyNested (const Box &a_box, const ProblemDomain &a_domain, const IntVectSet &a_pnd, int a_totalBuffer) const
 
virtual void makePNDs (Vector< IntVectSet > &a_pnds, Vector< int > &a_totalBufferSize, const int a_baseLevel, const int a_topLevel, const Vector< ProblemDomain > &a_domains, const IntVectSet &a_baseMesh, const Vector< int > &a_bufferSize) const
 Computes proper nesting domains. More...
 
virtual void makePNDs (Vector< IntVectSet > &a_pnds, Vector< int > &a_totalBufferSize, const int a_baseLevel, const int a_topLevel, const Vector< ProblemDomain > &a_domains, const Vector< Box > &a_baseMesh, const Vector< int > &a_bufferSize) const
 
virtual void buildSupport (const ProblemDomain &lvldomain, Vector< Box > &lvlboxes, IntVectSet &modifiedTags)
 
virtual void clipBox (Box &a_box, const ProblemDomain &a_domain) const
 

Protected Attributes

bool m_isDefined
 
Vector< ProblemDomainm_vectDomains
 
Vector< IntVectSetm_pnds
 
int m_lastBase
 
int m_lastTop
 
int m_lastBuffer
 
Vector< int > m_nRefVect
 
Real m_fillRatio
 
int m_blockFactor
 
Vector< int > m_level_blockfactors
 
int m_bufferSize
 
int m_maxSize
 
int m_granularity
 
int m_PNDMode
 
IntVect m_refineDirs
 
int m_lowestRefineDir
 

Detailed Description

Class which manages grid generation.

This class manages grid generation from sets of tagged cells. It is designed to be a pure virtual base class from which another class may be derived with a specific grid-generation algorithm (for example, the BRMeshRefine class).

There are two ways grids can be defined based on tagged cells. one takes a single IntVectSet of tags defined on the BaseLevel mesh and uses that set of tags for every level to be refined; the other takes a Vector<IntVectSet> of tags defined on all the mesh levels to be refined and uses those.

Long Description:

Create new meshes based on tagged cells on a range of levels of a mesh hierarchy. Each level of tagged cells is used to generate a new mesh at the next finer level. The finest level in the output mesh will be one level higher than the top of the range of levels given as input. As a special case, use the same tags (appropriately refined) for all levels.

Usage:

Call the regrid functions after computing error estimates and tagging cells. To add a new mesh level, set TopLevel to the index of the finest level in the existing mesh and define tags on the finest level. To keep the existing number of mesh levels, set TopLevel to one less than the index of the finest level and don't define any tags on the finest level. If a single IntVectSet of tags is passed (instead of a Vector<IntVectSet>) then the same tags (properly refined) will be used for all the new meshes up to level TopLevel+1. In any case, the meshes at levels BaseLevel and below are not modified. The output argument newmeshes will be reallocated to the necessary size before being used. When this function returns, the elements of the newmeshes vector corresponding to the unchanged levels will be filled in with copies of the levels from the old mesh vector. The variable tags is modified in an undefined way, so its contents should not be relied upon. The variable BlockFactor specifies the amount by which each box will be coarsenable. Every grid box will have an integral multiple of BlockFactor cells in each dimension and also lower index values that are integral multiples. As a side effect, the minimum box size will be BlockFactor.

Expensive validations are done only when debugging is enabled (i.e. the DEBUG make variable is "TRUE").

Usage Notes:

All the input vectors should be defined with max index >= TopLevel. They should have values for indices [BaseLevel:TopLevel]. (except for OldMeshes, which must be defined for all indices). The new mesh vector newmeshes will be redefined up to index TopLevel+1. RefRatios should be defined such that RefRatios[L] is the value to use to refine the level L mesh to produce the level L+1 mesh. The tags vector is modified in an undefined manner. The output variable newmeshes may not be completely defined if an exception occurs. The BlockFactor can be used to force a minimum box size.

Constructor & Destructor Documentation

◆ MeshRefine() [1/3]

MeshRefine::MeshRefine ( )

default constructor – leaves object in an unusable state

◆ MeshRefine() [2/3]

MeshRefine::MeshRefine ( const Box a_baseDomain,
const Vector< int > &  a_refRatios,
const Real  a_fillRatio,
const int  a_blockFactor,
const int  a_bufferSize,
const int  a_maxSize 
)

full constructor – leaves object in usable state

Parameters
a_baseDomainlevel 0 domain
a_refRatiosrefinement ratios – refRatio[0] is btwn levels 0 and 1
a_fillRatiomeasure of how efficiently tagged cells will be covered
a_blockFactoramount by which grids are guaranteed to be coarsenable
a_bufferSizeproper nesting buffer amount
a_maxSizemaximum grid length in any direction – 0 means no limit.

◆ MeshRefine() [3/3]

MeshRefine::MeshRefine ( const ProblemDomain a_baseDomain,
const Vector< int > &  a_refRatios,
const Real  a_fillRatio,
const int  a_blockFactor,
const int  a_bufferSize,
const int  a_maxSize 
)

full constructor – leaves object in usable state

Parameters
a_baseDomainlevel 0 domain
a_refRatiosrefinement ratios – refRatio[0] is btwn levels 0 and 1
a_fillRatiomeasure of how efficiently tagged cells will be covered
a_blockFactoramount by which grids are guaranteed to be coarsenable
a_bufferSizeproper nesting buffer amount
a_maxSizemaximum grid length in any direction – 0 means no limit.

◆ ~MeshRefine()

virtual MeshRefine::~MeshRefine ( )
virtual

destructor

Member Function Documentation

◆ define() [1/2]

void MeshRefine::define ( const Box a_baseDomain,
const Vector< int > &  a_refRatios,
const Real  a_fillRatio,
const int  a_blockFactor,
const int  a_bufferSize,
const int  a_maxSize 
)

define function – size of RefRatios will define maximum number of levels

Parameters
a_baseDomainlevel 0 domain
a_refRatiosrefinement ratios – refRatio[0] is btwn levels 0 and 1
a_fillRatiomeasure of how efficiently tagged cells will be covered
a_blockFactoramount by which grids are guaranteed to be coarsenable
a_bufferSizeproper nesting buffer amount
a_maxSizemaximum grid length in any direction – 0 means no limit

◆ define() [2/2]

virtual void MeshRefine::define ( const ProblemDomain a_baseDomain,
const Vector< int > &  a_refRatios,
const Real  a_fillRatio,
const int  a_blockFactor,
const int  a_bufferSize,
const int  a_maxSize 
)
virtual

define function – size of RefRatios will define maximum number of levels

Parameters
a_baseDomainlevel 0 domain
a_refRatiosrefinement ratios – refRatio[0] is btwn levels 0 and 1
a_fillRatiomeasure of how efficiently tagged cells will be covered
a_blockFactoramount by which grids are guaranteed to be coarsenable
a_bufferSizeproper nesting buffer amount
a_maxSizemaximum grid length in any direction – 0 means no limit

Reimplemented in BRMeshRefine.

◆ regrid() [1/2]

virtual int MeshRefine::regrid ( Vector< Vector< Box > > &  a_newmeshes,
const IntVectSet a_tags,
const int  a_baseLevel,
const int  a_topLevel,
const Vector< Vector< Box > > &  a_oldMeshes 
)
virtual

create hierarchy of grids from a single level of tags

This function creates a hierarchy of grids from a single level of tags on BaseLevel. If tags exist, then all levels will have grids. Returns the new finest level of grids.

If m_refineDirs != IntVect::Unit, then a_tags and a_oldMeshes must have ranges restricted to 0 in all dimensions d with m_refineDirs[d] == 0, and the output a_newmeshes will have this same restriction.

Parameters
a_newmeshesnew set of grids at every level
a_tagstagged cells on baseLevel
a_baseLevelindex of base mesh level (finest unchanged level)
a_topLeveltop level to refine (one less than finest possible level)
a_oldMeshesexisting grids (if no previous grids, set to domains)

◆ regrid() [2/2]

virtual int MeshRefine::regrid ( Vector< Vector< Box > > &  a_newmeshes,
Vector< IntVectSet > &  a_tags,
const int  a_baseLevel,
const int  a_topLevel,
const Vector< Vector< Box > > &  a_oldMeshes 
)
virtual

create hierarchy of grids from tags at all levels

This function creates a hierarchy of grids from tags at all refinement levels. It is possible that not all levels will return with grids, since there may not be tags at all levels. Returns the new finest level of grids.

If m_refineDirs != IntVect::Unit, then a_tags and a_oldMeshes must have ranges restricted to 0 in all dimensions d with m_refineDirs[d] == 0, and the output a_newmeshes will have this same restriction.

Parameters
a_newmeshesnew set of grids at every level
a_tagstagged cells on each existing level
a_baseLevelindex of base mesh level (finest unchanged level)
a_topLeveltop level to refine (one less than finest possible level)
a_oldMeshesexisting grids (if no previous grids, set to domains)

◆ refRatios() [1/2]

const Vector<int>& MeshRefine::refRatios ( ) const

returns vector of refinement ratios

◆ fillRatio() [1/2]

Real MeshRefine::fillRatio ( ) const

returns fillRatio

◆ blockFactor() [1/2]

int MeshRefine::blockFactor ( ) const

returns blocking factor

◆ bufferSize() [1/2]

int MeshRefine::bufferSize ( ) const

returns proper nesting buffer size

◆ maxSize() [1/2]

int MeshRefine::maxSize ( ) const

returns maximum box size in any dimension – 0 means no limit

◆ refRatios() [2/2]

void MeshRefine::refRatios ( const Vector< int > &  a_nRefVect)

sets vector of refinement ratios

◆ fillRatio() [2/2]

virtual void MeshRefine::fillRatio ( const Real  a_fill_ratio)
virtual

sets fillRatio

◆ blockFactor() [2/2]

virtual void MeshRefine::blockFactor ( const int  a_block_factor)
virtual

sets blocking factor

◆ bufferSize() [2/2]

virtual void MeshRefine::bufferSize ( const int  a_buffer_size)
virtual

sets proper nesting buffer size

◆ maxSize() [2/2]

virtual void MeshRefine::maxSize ( const int  a_max_size)
virtual

sets maximum box size in any dimension – 0 means no limit

◆ isDefined()

bool MeshRefine::isDefined ( ) const

has this object been defined properly?

◆ granularity()

void MeshRefine::granularity ( int  a_granularity)

sets proper nesting region granularity.

◆ makeBoxes()

virtual void MeshRefine::makeBoxes ( Vector< Box > &  a_mesh,
const IntVectSet a_tags,
const IntVectSet a_pnd,
const ProblemDomain a_domain,
const int  a_maxSize,
const int  a_totalBufferSize 
) const
pure virtual

constructs a set of boxes which covers a set of tagged cells

constructs a set of boxes which covers a set of tagged cells by using the algorithm of choice. Everything should be on the same level, and blocking factor is not applied. Boxes will be on the same refinement level as the tags. This would normally be a protected function, but it can be useful to call it on its own, so it has been left public.

Parameters
a_meshoutput: refined boxes at each new level
a_tagsinput: set of tagged cells to cover
a_pndinput: proper nesting domain in which mesh boxes must live
a_domaininput: physical domain
a_maxSizeinput: largest number of cells in any dimension for any box

Implemented in BRMeshRefine.

◆ setPNDMode()

void MeshRefine::setPNDMode ( int  a_mode)

◆ setRefineDirs()

void MeshRefine::setRefineDirs ( const IntVect a_refineDirs)

set each component to 1 or 0 according to whether or not we refine in that direction. Default IntVect::Unit.

◆ inRefineDirs()

IntVect MeshRefine::inRefineDirs ( int  a_val) const

returns IntVect with component d set to a_val if m_refineDirs[d] == 1; else 1.

◆ restrictUnrefined() [1/2]

void MeshRefine::restrictUnrefined ( Box a_box) const

◆ restrictUnrefined() [2/2]

void MeshRefine::restrictUnrefined ( IntVectSet a_ivs) const

◆ computeLocalBlockFactors()

virtual void MeshRefine::computeLocalBlockFactors ( )
protectedvirtual

computes local blockFactors used internally to enforce the BlockFactor

This function computes values for m_local_blockfactors array, which is the amount that tags on a level are coarsened in order to guarantee that the grids on the next finer level are coarsenable by the BlockFactor.

◆ properlyNested()

virtual bool MeshRefine::properlyNested ( const Box a_box,
const ProblemDomain a_domain,
const IntVectSet a_pnd,
int  a_totalBuffer 
) const
protectedvirtual

Reimplemented in MultiBlockMeshRefine.

◆ makePNDs() [1/2]

virtual void MeshRefine::makePNDs ( Vector< IntVectSet > &  a_pnds,
Vector< int > &  a_totalBufferSize,
const int  a_baseLevel,
const int  a_topLevel,
const Vector< ProblemDomain > &  a_domains,
const IntVectSet a_baseMesh,
const Vector< int > &  a_bufferSize 
) const
protectedvirtual

Computes proper nesting domains.

This should only be called by refine. it assumes that everything has already been coarsened by the local blocking factor

Parameters
a_pndsoutput: proper nesting domains at each level
a_baseLevelinput: index of highest AMR level not to be refined
a_topLevelinput: index of highest AMR level in output
a_domainsinput: (same as in meshRefine)
a_baseMeshinput: boxes at mesh level BaseLevel
a_bufferSizeinput: (similar to meshRefine; but with level-dependent coarsening factors)

◆ makePNDs() [2/2]

virtual void MeshRefine::makePNDs ( Vector< IntVectSet > &  a_pnds,
Vector< int > &  a_totalBufferSize,
const int  a_baseLevel,
const int  a_topLevel,
const Vector< ProblemDomain > &  a_domains,
const Vector< Box > &  a_baseMesh,
const Vector< int > &  a_bufferSize 
) const
protectedvirtual
Parameters
a_pndsoutput: proper nesting domains at each level
a_baseLevelinput: index of highest AMR level not to be refined
a_topLevelinput: index of highest AMR level in output
a_domainsinput: (same as in meshRefine)
a_baseMeshinput: boxes at mesh level BaseLevel
a_bufferSizeinput: (similar to meshRefine; but with level-dependent coarsening factors)

◆ buildSupport()

virtual void MeshRefine::buildSupport ( const ProblemDomain lvldomain,
Vector< Box > &  lvlboxes,
IntVectSet modifiedTags 
)
protectedvirtual

Reimplemented in MultiBlockMeshRefine.

◆ clipBox()

virtual void MeshRefine::clipBox ( Box a_box,
const ProblemDomain a_domain 
) const
protectedvirtual

Reimplemented in MultiBlockMeshRefine.

Member Data Documentation

◆ m_isDefined

bool MeshRefine::m_isDefined
protected

◆ m_vectDomains

Vector<ProblemDomain> MeshRefine::m_vectDomains
protected

◆ m_pnds

Vector<IntVectSet> MeshRefine::m_pnds
protected

◆ m_lastBase

int MeshRefine::m_lastBase
protected

◆ m_lastTop

int MeshRefine::m_lastTop
protected

◆ m_lastBuffer

int MeshRefine::m_lastBuffer
protected

◆ m_nRefVect

Vector<int> MeshRefine::m_nRefVect
protected

◆ m_fillRatio

Real MeshRefine::m_fillRatio
protected

◆ m_blockFactor

int MeshRefine::m_blockFactor
protected

◆ m_level_blockfactors

Vector<int> MeshRefine::m_level_blockfactors
protected

◆ m_bufferSize

int MeshRefine::m_bufferSize
protected

◆ m_maxSize

int MeshRefine::m_maxSize
protected

◆ m_granularity

int MeshRefine::m_granularity
protected

◆ m_PNDMode

int MeshRefine::m_PNDMode
protected

◆ m_refineDirs

IntVect MeshRefine::m_refineDirs
protected

◆ m_lowestRefineDir

int MeshRefine::m_lowestRefineDir
protected

The documentation for this class was generated from the following file: