|
chombo-discharge
|
Class which maps a multifluid cut-cell AMR hierarchy to PETSc. More...
#include <CD_PetscGrid.H>
Public Member Functions | |
| PetscGrid () noexcept | |
| Default constructor. Must subsequently call define. | |
| virtual | ~PetscGrid () noexcept |
| Destructor. Does nothing. | |
| virtual void | define (const Vector< RefCountedPtr< MFLevelGrid > > &a_levelGrids, const Vector< RefCountedPtr< MFLevelGrid > > &a_levelGridsCoFi, const Vector< RefCountedPtr< MFLevelGrid > > &a_levelGridsFiCo, const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > &a_validCells, const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > &a_coarHaloCF, const Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > &a_fineHaloCF, const Vector< int > &a_refinementRatios, const Vector< Real > &a_dx, const int a_finestLevel, const int a_numGhost) noexcept |
| Main define function. Puts object in usable state. | |
| virtual void | clear () noexcept |
| Clear the object. | |
| virtual bool | isDefined () const noexcept |
| Is defined or not. | |
| virtual int | getNumPhases () const noexcept |
| Get the number of phases. | |
| virtual PetscInt | getNumLocalRows () const noexcept |
| Get the number of PETSc rows owned by this rank. | |
| virtual PetscInt | getNumGlobalRows () const noexcept |
| Get the total number of PETSc rows over all ranks. | |
| virtual const Vector< RefCountedPtr< MFLevelGrid > > & | getMFLevelGrids () const noexcept |
| Get the grids on each level. | |
| virtual const Vector< RefCountedPtr< MFLevelGrid > > & | getMFLevelGridsCoFi () const noexcept |
| Get the coarsened fine grids. | |
| virtual const Vector< RefCountedPtr< MFLevelGrid > > & | getMFLevelGridsFiCo () const noexcept |
| Get the refined coarse grids. | |
| virtual const Vector< int > & | getRefinementRatios () const noexcept |
| Get the refinement ratios. | |
| virtual const Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > & | getAMRToPetsc () const noexcept |
| Get the map from AMR cells to PETSc rows, on the grids of each level. | |
| virtual const Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > & | getAMRToPetscCoFi () const noexcept |
| Get the map from AMR cells to PETSc rows, on the coarsened fine grids. | |
| virtual const Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > & | getAMRToPetscFiCo () const noexcept |
| Get the map from AMR cells to PETSc rows, on the refined coarse grids. | |
| virtual Vector< RefCountedPtr< LayoutData< VoFIterator > > > & | getVoFIterator (const int a_iphase) const noexcept |
| Get iterators over the cut cells that are PETSc rows on a phase. | |
| virtual Vector< PetscInt > | getLocalRows (const int a_iphase) const noexcept |
| Get the global PETSc rows of a phase that this rank owns. | |
| virtual PetscStencil | getPetscStencil (const VoFStencil &a_stencil, const int a_level, const DataIndex &a_din, const int a_phase) const noexcept |
| Rewrite a stencil over cells on one level as a stencil over global PETSc rows. | |
| virtual PetscStencil | getPetscStencilWithFinerLevel (const VoFStencil &a_stencil, const VoFStencil &a_fineStencil, const int a_level, const DataIndex &a_din, const int a_phase) const noexcept |
| Rewrite a two-level stencil, over cells on a level and the next finer level, as a stencil over global PETSc rows. | |
| virtual PetscStencil | getPetscStencilWithCoarserLevel (const VoFStencil &a_stencil, const VoFStencil &a_coarStencil, const int a_level, const DataIndex &a_din, const int a_phase) const noexcept |
| Rewrite a two-level stencil, over cells on a level and the next coarser level, as a stencil over global PETSc rows. | |
| virtual void | replaceGhostCells (VoFStencil &a_stencil, VoFStencil &a_stencilCoar, const RefCountedPtr< EBMultigridInterpolator > &a_interpolator, const int a_level, const DataIndex &a_din) const noexcept |
| Replace the coarse-fine ghost cells in a stencil over level a_level cells by their interpolation stencils. | |
| virtual PetscStencil | getPetscStencilWithGhostCells (const VoFStencil &a_stencilCoar, const VoFStencil &a_stencil, const VoFStencil &a_stencilFine, const RefCountedPtr< EBMultigridInterpolator > &a_interpolator, const int a_level, const DataIndex &a_din, const int a_phase) const noexcept |
| Rewrite a stencil over three levels, whose part on the middle level may contain coarse-fine ghost cells, as a stencil over global PETSc rows. | |
| virtual void | create (Vec &a_x) noexcept |
| Create a PETSc vector. | |
| virtual void | destroy (Vec &a_x) noexcept |
| Destroy a PETSc vector. | |
| virtual void | setValue (Vec &a_x, const PetscScalar a_value) const noexcept |
| Set values in a PETSc vector. | |
| virtual void | putChomboInPetsc (Vec &a_x, const MFAMRCellData &a_y) const noexcept |
| Push data form a chombo-discharge data holder into PETSc. | |
| virtual void | putPetscInChombo (MFAMRCellData &a_y, const Vec &a_x) const noexcept |
| Pull data from a PETSc vector into a chombo-discharge data holder. | |
| virtual void | dumpPetscGrid (const std::string &a_filename) const noexcept |
| Write the PETSc grid to an output HDF5 file. | |
Protected Member Functions | |
| virtual void | defineAMRCells () noexcept |
| Define basic cell information for PetscGrid. | |
| virtual void | definePetscRows () noexcept |
| Build the Chombo <--> Petsc index mapping for the valid cells. | |
| virtual void | addRows (PetscStencil &a_petscStencil, const VoFStencil &a_stencil, const BaseFab< PetscAMRCell > &a_map, const int a_phase, const std::string &a_what) const noexcept |
| Add the rows of a stencil's cells to a PETSc stencil. | |
| virtual void | abortInvalidEntry (const IntVect &a_iv, const BaseFab< PetscAMRCell > &a_map, const int a_phase, const std::string &a_what) const noexcept |
| Abort because a stencil entry lies outside the map or is not a PETSc row, naming the cell and the reason. | |
| virtual void | defineCoFiBuffers () noexcept |
| Define the coarsened/refined views of m_amrToPetsc. | |
Protected Attributes | |
| bool | m_isDefined |
| Is defined or not. | |
| bool | m_verbose |
| Verbose or not. | |
| bool | m_debug |
| Run-time debug or not. | |
| bool | m_profile |
| Run-time profile or not. | |
| int | m_finestLevel |
| Finest grid level. | |
| int | m_numGhost |
| Number of ghost cells. | |
| int | m_numPhases |
| Number of phases. | |
| PetscInt | m_numLocalRows |
| Number of rows owned locally. | |
| PetscInt | m_numGlobalRows |
| Number of global rows. | |
| PetscInt | m_localRowBegin |
| Global row corresponding to the first local row. | |
| ISLocalToGlobalMapping | m_localToGlobalIS |
| Local index to global index mapping for PETSc. | |
| Vector< PetscInt > | m_numRowsPerRank |
| Number of rows per MPI rank. Visible to all ranks. | |
| Vector< RefCountedPtr< MFLevelGrid > > | m_levelGrids |
| Grids on each level. | |
| Vector< RefCountedPtr< MFLevelGrid > > | m_levelGridsCoFi |
| Coarsened grids. | |
| Vector< RefCountedPtr< MFLevelGrid > > | m_levelGridsFiCo |
| Refined grids. | |
| Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > | m_validCells |
| Data holder which is true for cells not covered by a finer grid. | |
| Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > | m_coarHaloCF |
| Coarse-side cells on refinement interface. | |
| Vector< RefCountedPtr< LevelData< BaseFab< bool > > > > | m_fineHaloCF |
| Fine-side cells on refinement interface. | |
| Vector< int > | m_refRat |
| Refinement ratios between levels. | |
| Vector< Real > | m_dx |
| Grid resolutions. | |
| Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > | m_amrToPetsc |
| Mapping structure for moving between AMR cells and PETSc rows. | |
| Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > | m_amrToPetscCoFi |
| Mapping structure for moving between AMR cells and PETSc rows. | |
| Vector< RefCountedPtr< LevelData< BaseFab< PetscAMRCell > > > > | m_amrToPetscFiCo |
| Mapping structure for moving between AMR cells and PETSc rows. | |
| Vector< RefCountedPtr< LayoutData< Vector< PetscDOF > > > > | m_petscToAMR [2] |
| Mapping of PETSc local row index back to AMR. | |
| Vector< RefCountedPtr< LayoutData< VoFIterator > > > | m_vofIterators [2] |
| Iterators over the cut cells that are PETSc rows, per phase and level. | |
Class which maps a multifluid cut-cell AMR hierarchy to PETSc.
This class includes functions for putting chombo-discharge in PETSc and vice versa.
|
protectedvirtualnoexcept |
Abort because a stencil entry lies outside the map or is not a PETSc row, naming the cell and the reason.
| [in] | a_iv | Cell. |
| [in] | a_map | Map from cells to PETSc rows, for one grid patch. |
| [in] | a_phase | Phase. |
| [in] | a_what | Which stencil the entry belongs to. |
|
protectedvirtualnoexcept |
Add the rows of a stencil's cells to a PETSc stencil.
Looks up each entry of a_stencil in a_map. Every entry must lie in a_map's box and be a PETSc row on a_phase. Either failure aborts in every build, through abortInvalidEntry: an entry outside the map would read out of bounds, and PETSc silently ignores negative indices.
| [in,out] | a_petscStencil | PETSc stencil to add to. |
| [in] | a_stencil | Stencil over the cells of a_map. |
| [in] | a_map | Map from cells to PETSc rows, for one grid patch. |
| [in] | a_phase | Phase. |
| [in] | a_what | Which stencil this is, for the abort message. |
|
virtualnoexcept |
Clear the object.
This deallocates all PETSc-relevant allocations and marks the grid as undefined, so calling it twice is safe.
|
virtualnoexcept |
Create a PETSc vector.
This will allocate the PETSc vector. It is up to the user to destroy it when it is no longer needed.
| [in,out] | a_x | PETSc vector |
|
virtualnoexcept |
Main define function. Puts object in usable state.
Note that a_levelGridsCoFi must be coarsened from finer grids. That is, entry lvl in levelGridsCoFi must be a coarsened version of a_levelGrids[lvl+1]. Similarly, a_levelGridsFiCo must be refined from coarser grids, i.e., a_levelGridsFiCo[lvl] must be a refinement of a_levelGrids[lvl-1].
| [in] | a_levelGrids | chombo-discharge AMR grids |
| [in] | a_levelGridsCoFi | Coarsened grids. |
| [in] | a_levelGridsFiCo | Refined grids. |
| [in] | a_validCells | Data holder which is true for cells not covered by a finer grid and false otherwise. |
| [in] | a_coarHaloCF | Data holder which is true on cells that lie on the coarse side of a CF interface |
| [in] | a_fineHaloCF | Data holder which is true on cells that lie on the fine side of a CF interface |
| [in] | a_refinementRatios | Refinement ratios between grid level. |
| [in] | a_dx | Grid resolutions on each level. |
| [in] | a_finestLevel | Finest defined grid level. |
| [in] | a_numGhost | Number of ghost cells described in the grid. |
|
protectedvirtualnoexcept |
Define basic cell information for PetscGrid.
This defines basic cell properties, indicating whether or not a cell is covered by a finer grid, if it abuts the coarse-fine interface, etc.
|
protectedvirtualnoexcept |
Build the Chombo <--> Petsc index mapping for the valid cells.
This defines m_localRows and m_globalRows, m_numRowsPerRank, m_localToGlobalIS, and figures out the number of degrees of freedom on each MPI rank. After this is called, it will be possible to index local grid cells into a PETSc vector row.
|
virtualnoexcept |
Destroy a PETSc vector.
This will deallocate the PETSc vector.
| [in,out] | a_x | PETSc vector |
|
virtualnoexcept |
Write the PETSc grid to an output HDF5 file.
| [in] | a_filename | Output file name |
|
virtualnoexcept |
Get the map from AMR cells to PETSc rows, on the grids of each level.
Valid cells and ghost cells both hold global PETSc rows.
|
virtualnoexcept |
Get the map from AMR cells to PETSc rows, on the coarsened fine grids.
Entry lvl holds the rows of level lvl on the grids of getMFLevelGridsCoFi()[lvl].
|
virtualnoexcept |
Get the map from AMR cells to PETSc rows, on the refined coarse grids.
Entry lvl holds the rows of level lvl on the grids of getMFLevelGridsFiCo()[lvl].
|
virtualnoexcept |
Get the global PETSc rows of a phase that this rank owns.
These are the rows of the cells of the phase on all levels, e.g. for an index set that splits the matrix by phase.
| [in] | a_iphase | Phase index |
|
virtualnoexcept |
Get the grids on each level.
|
virtualnoexcept |
Get the coarsened fine grids.
Entry lvl is level lvl+1 coarsened to the resolution of level lvl, and shares DataIndex with level lvl+1. The finest level has no entry.
|
virtualnoexcept |
Get the refined coarse grids.
Entry lvl is level lvl-1 refined to the resolution of level lvl, and shares DataIndex with level lvl-1. Level 0 has no entry.
|
virtualnoexcept |
Get the total number of PETSc rows over all ranks.
|
virtualnoexcept |
Get the number of PETSc rows owned by this rank.
|
virtualnoexcept |
Get the number of phases.
|
virtualnoexcept |
Rewrite a stencil over cells on one level as a stencil over global PETSc rows.
Each entry of a_stencil is a cell on level a_level, in the index space of grid a_din, possibly in its ghost region. Every entry must be a PETSc row on a_phase, i.e. a valid cell of a_din or of a neighbouring box. Anything else aborts with the reason: a cell covered by a finer level, a coarse-fine ghost cell, a cell covered by the EB, or a cell outside the domain. Ghost cells and boundary conditions are the caller's to resolve first.
| [in] | a_stencil | Stencil over cells on level a_level. |
| [in] | a_level | Grid level. |
| [in] | a_din | Grid index on level a_level. |
| [in] | a_phase | Phase. |
|
virtualnoexcept |
Rewrite a two-level stencil, over cells on a level and the next coarser level, as a stencil over global PETSc rows.
This is the form of the coarse-fine ghost cell stencils of EBMultigridInterpolator::getGhostStencil. a_stencil resolves as in the single-level version. a_coarStencil is over cells on level a_level-1, in the index space of the level a_level grid a_din coarsened to level a_level-1 (getMFLevelGridsCoFi), and each of its entries must be a PETSc row on level a_level-1.
| [in] | a_stencil | Stencil over cells on level a_level. |
| [in] | a_coarStencil | Stencil over cells on level a_level-1. |
| [in] | a_level | Grid level of a_stencil. Must be above level 0. |
| [in] | a_din | Grid index on level a_level. |
| [in] | a_phase | Phase. |
|
virtualnoexcept |
Rewrite a two-level stencil, over cells on a level and the next finer level, as a stencil over global PETSc rows.
This is the form produced by LeastSquares::computeDualLevelStencils for a stencil on level a_level that uses level a_level+1 cells. a_stencil resolves as in the single-level version. a_fineStencil is over cells on level a_level+1, in the index space of grid a_din refined to level a_level+1 (getMFLevelGridsFiCo), and each of its entries must be a PETSc row on level a_level+1.
| [in] | a_stencil | Stencil over cells on level a_level. |
| [in] | a_fineStencil | Stencil over cells on level a_level+1. |
| [in] | a_level | Grid level of a_stencil. Must be below the finest level. |
| [in] | a_din | Grid index on level a_level. |
| [in] | a_phase | Phase. |
|
virtualnoexcept |
Rewrite a stencil over three levels, whose part on the middle level may contain coarse-fine ghost cells, as a stencil over global PETSc rows.
The ghost cells in a_stencil are replaced as in replaceGhostCells. The parts then resolve as in getPetscStencilWithCoarserLevel and getPetscStencilWithFinerLevel: a_stencilCoar is in the index space of grid a_din coarsened, and a_stencilFine in the index space of grid a_din refined. Aborts if the coarse part is not empty on level 0, or the fine part on the finest level.
| [in] | a_stencilCoar | Stencil over cells on level a_level - 1 |
| [in] | a_stencil | Stencil over cells on level a_level, possibly with coarse-fine ghost cells |
| [in] | a_stencilFine | Stencil over cells on level a_level + 1 |
| [in] | a_interpolator | Coarse-fine interpolator of level a_level, for phase a_phase. Null on level 0. |
| [in] | a_level | Grid level of a_stencil |
| [in] | a_din | Grid index on level a_level |
| [in] | a_phase | Phase |
|
virtualnoexcept |
Get the refinement ratios.
Entry lvl is the refinement ratio between level lvl and level lvl+1.
|
virtualnoexcept |
Get iterators over the cut cells that are PETSc rows on a phase.
Non-const because a VoFIterator must be reset to be iterated over.
| [in] | a_iphase | Phase index |
|
virtualnoexcept |
Is defined or not.
|
virtualnoexcept |
Push data form a chombo-discharge data holder into PETSc.
| [out] | a_x | PETSc vector |
| [in] | a_y | chombo-discharge data holder |
|
virtualnoexcept |
Pull data from a PETSc vector into a chombo-discharge data holder.
| [in,out] | a_y | chombo-discharge data holder |
| [in] | a_x | PETSc vector |
|
virtualnoexcept |
Replace the coarse-fine ghost cells in a stencil over level a_level cells by their interpolation stencils.
Each ghost cell entry is removed from a_stencil, and its stencil from EBMultigridInterpolator::getGhostStencil, times the entry's weight, is added to a_stencil (the part on level a_level) and a_stencilCoar (the part on level a_level - 1, in the index space of grid a_din coarsened). Entries that are not ghost cells are kept. Aborts if a_stencil has a ghost cell and a_interpolator is null.
| [in,out] | a_stencil | Stencil over cells on level a_level |
| [in,out] | a_stencilCoar | Stencil over cells on level a_level - 1 |
| [in] | a_interpolator | Coarse-fine interpolator of level a_level, for the phase of the stencil. Null on level 0. |
| [in] | a_level | Grid level |
| [in] | a_din | Grid index on the level |
|
virtualnoexcept |
Set values in a PETSc vector.
a_value Does not need to be the same across all ranks.
| [in,out] | a_x | Global PETSc vector |
| [in] | a_value | Value to set |
|
protected |
Mapping structure for moving between AMR cells and PETSc rows.
PetscAMRCell contains extra information, such as whether or not a cell is a ghost cell, covered by another cell, etc.
|
protected |
Mapping structure for moving between AMR cells and PETSc rows.
This is like m_amrToPetsc, except that it is defined on the coarsened grids. Index i thus contains the coarsening of level i+1.
|
protected |
Mapping structure for moving between AMR cells and PETSc rows.
This is like m_amrToPetsc, except that it is defined on the refined. Index i+1 thus contains the refinement of level i.
|
protected |
Mapping of PETSc local row index back to AMR.
Locally owned. Maps a local row index to a level/grid/cell.
|
mutableprotected |
Iterators over the cut cells that are PETSc rows, per phase and level.
Mutable because iterating over a VoFIterator resets it.