Gowdy solver
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
UniformGrid Class Reference

Uniform grid of grid functions. More...

#include <gridDriver.h>

Inheritance diagram for UniformGrid:
Collaboration diagram for UniformGrid:

Public Member Functions

GridPoint ** get_grid ()
Int get_nLen () const
Int get_nGhost () const
Int get_mLen () const
Real get_delta_r () const
Int mpiSize () const
Int mpiRank () const
 UniformGrid (Parameters &params)
 Constructs the uniform grid as specified in the parameter file.
void exchangeBoundaries (Int m)
 Exchange the boundaries at the given time slice.

Protected Attributes

GridPoint ** grid
 The grid storage.
Int nLen
 Number of cells in r-direction.
Int nGhost
 Number of virtual (ghost) cells on the r-boundary.
Real delta_r
 The grid spacing accross r
Int mLen
 Number of cached cells in t-direction.
Int mExtra
 Number of extra cells (for integration substeps)

Private Member Functions

void createGrid ()
 Allocates memory for the numerical grid.
void deleteGrid ()
 Releases memory allocated for the numerical grid.

Detailed Description

Uniform grid of grid functions.

Definition at line 72 of file gridDriver.h.


Constructor & Destructor Documentation

UniformGrid::UniformGrid ( Parameters params) [inline]

Constructs the uniform grid as specified in the parameter file.

Definition at line 137 of file gridDriver.h.

References createGrid(), delta_r, Parameters::get(), mExtra, mLen, nGhost, nLen, MPIWorld::size(), and slog.

    {
        params.get( "grid.nLen",    nLen,     10  );
        params.get( "grid.nGhost",  nGhost,   10  );
        params.get( "grid.delta_r", delta_r,  0.1 );
        params.get( "grid.mLen",    mLen,     5   );
        params.get( "grid.mExtra",  mExtra,   9   );

        // Split the data equally among all the ranks in the MPI world
        nLen = nLen / size();

        slog << "Uniform Grid Driver:" << std::endl << std::endl
             << "    nLen = " << nLen << ",  nGhost = " << nGhost
             << ",  delta_r = " << delta_r
             << ",  mLen = " << mLen << ",  mExtra = " << mExtra << std::endl
             << "    Compile-time: CFDS_ORDER = " << CFDS_ORDER << std::endl;

        #if _OPENMP
             slog << "    Using OpenMP: #procs = "
                  << omp_get_num_procs() << ", max #threads = "
                  << omp_get_max_threads() << std::endl;
        #endif

        // Sanity check that nGhost > CFDS_ORDER/2
        //
        if( nGhost < CFDS_ORDER/2 ) {
            slog << "Error: Ghost region does not fit the FD order." << std::endl;
            exit( -1 );
        }

        createGrid ();
    }

Member Function Documentation

void UniformGrid::createGrid ( ) [inline, private]

Allocates memory for the numerical grid.

We allocate mExtra extra m grid rows for the intermediate steps. We also allocate 2*nGhost n-cells as the L/R spatial boundary.

Definition at line 80 of file gridDriver.h.

References GFCNT, grid, mExtra, mLen, nGhost, nLen, and slog.

Referenced by UniformGrid().

    {
        size_t mDim = mLen + mExtra;
        size_t nDim = nLen + 2 * nGhost;

        grid = new GridPoint* [ mDim ];
        grid[0] = new GridPoint[ mDim * nDim ];

        for( size_t m = 0; m < mDim - 1; ++m ) {
            grid[m+1] = grid[m] + nDim;
        }

        slog << "    Allocated " << mDim << " * " << nDim
             << " * " << sizeof(GridPoint) / sizeof(Real)
             << " * Real" << 8 * sizeof(Real)
             << " = " << mDim * nDim * sizeof(GridPoint)
             << " bytes" << std::endl
             << "    Tracking " << GFCNT << " grid functions at a point"
             << std::endl << std::endl;
    }
void UniformGrid::deleteGrid ( ) [inline, private]

Releases memory allocated for the numerical grid.

Definition at line 103 of file gridDriver.h.

References grid.

    {
        if ( ! grid ) return;

        delete[] grid[0];
        delete[] grid;
        grid = NULL;
    }
void UniformGrid::exchangeBoundaries ( Int  m) [inline]

Exchange the boundaries at the given time slice.

Definition at line 172 of file gridDriver.h.

References GFCNT, grid, nGhost, and nLen.

Referenced by MoLIntegrator::integStep_Begin().

    {
        MPIWorld::exchangeBoundaries(
            &grid[m][ 0                      ],  // Left ghost (received)
            &grid[m][ nGhost                 ],  // Left edge (sent)
            &grid[m][ nGhost + nLen - nGhost ],  // Right_edge (sent)
            &grid[m][ nGhost + nLen          ],  // Right ghost (received)
            nGhost * GFCNT                       // Exchanged size of Reals
        );
    }
Real UniformGrid::get_delta_r ( ) const [inline]

Definition at line 130 of file gridDriver.h.

References delta_r.

{ return delta_r; }

Definition at line 125 of file gridDriver.h.

References grid.

Referenced by GridInitialData::load(), GridOutputWriter::open(), and GridOutputWriter::write().

{ return grid; }
Int UniformGrid::get_mLen ( ) const [inline]

Definition at line 129 of file gridDriver.h.

References mLen.

{ return mLen;    }
Int UniformGrid::get_nGhost ( ) const [inline]

Definition at line 128 of file gridDriver.h.

References nGhost.

Referenced by GridInitialData::load(), GridOutputWriter::open(), and GridOutputWriter::write().

{ return nGhost;  }
Int UniformGrid::get_nLen ( ) const [inline]

Definition at line 127 of file gridDriver.h.

References nLen.

Referenced by GridInitialData::load(), and GridOutputWriter::write().

{ return nLen;    }
Int UniformGrid::mpiRank ( ) const [inline]

Definition at line 133 of file gridDriver.h.

References MPIWorld::rank().

Referenced by GridInitialData::load(), and GridOutputWriter::open().

{ return rank (); }
Int UniformGrid::mpiSize ( ) const [inline]

Definition at line 132 of file gridDriver.h.

References MPIWorld::size().

Referenced by GridInitialData::load(), and GridOutputWriter::open().

{ return size (); }

Field Documentation

The grid spacing accross r

Definition at line 118 of file gridDriver.h.

Referenced by get_delta_r(), and UniformGrid().

The grid storage.

Definition at line 114 of file gridDriver.h.

Referenced by createGrid(), deleteGrid(), exchangeBoundaries(), and get_grid().

Int UniformGrid::mExtra [protected]

Number of extra cells (for integration substeps)

Definition at line 121 of file gridDriver.h.

Referenced by createGrid(), and UniformGrid().

Int UniformGrid::mLen [protected]

Number of cached cells in t-direction.

Definition at line 120 of file gridDriver.h.

Referenced by createGrid(), get_mLen(), and UniformGrid().

Int UniformGrid::nGhost [protected]

Number of virtual (ghost) cells on the r-boundary.

Definition at line 117 of file gridDriver.h.

Referenced by createGrid(), exchangeBoundaries(), get_nGhost(), and UniformGrid().

Int UniformGrid::nLen [protected]

Number of cells in r-direction.

Definition at line 116 of file gridDriver.h.

Referenced by createGrid(), exchangeBoundaries(), get_nLen(), and UniformGrid().


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