Alsvinn  0.5.3
The fast FVM simulator with UQ support
Public Member Functions | List of all members
alsfvm::volume::Volume Class Reference

The Volume class represents a volume (a collection of cells with values for each cell (eg. pressure, density, etc) More...

#include <alsfvm/volume/Volume.hpp>

Inheritance diagram for alsfvm::volume::Volume:

Public Member Functions

 Volume (const std::vector< std::string > &variableNames, alsfvm::shared_ptr< memory::MemoryFactory > memoryFactory, size_t nx, size_t ny, size_t nz, size_t numberOfGhostCells=0)
 Volume creates a new volume object. More...
 
 Volume (Volume &volume, const std::vector< size_t > &components, const std::vector< std::string > &variableNames)
 
virtual ~Volume ()
 
virtual size_t getNumberOfVariables () const
 getNumberOfVariables gets the number of variables used More...
 
virtual ivec3 getSize () const
 Returns the size in each dimension. More...
 
virtual ivec3 getInnerSize () const
 Gets the size without ghost cells in each dimension. More...
 
virtual ivec3 getNumberOfGhostCells () const
 Returns the number of ghostcells in each dimension. More...
 
virtual alsfvm::shared_ptr< memory::Memory< real > > & getScalarMemoryArea (size_t index)
 getScalarMemoryArea gets the scalar memory area (real) More...
 
virtual alsfvm::shared_ptr< const memory::Memory< real > > getScalarMemoryArea (size_t index) const
 getScalarMemoryArea gets the scalar memory area (real) More...
 
virtual alsfvm::shared_ptr< memory::Memory< real > > & getScalarMemoryArea (const std::string &name)
 getScalarMemoryArea gets the scalar memory area (real) More...
 
virtual alsfvm::shared_ptr< const memory::Memory< real > > getScalarMemoryArea (const std::string &name) const
 getScalarMemoryArea gets the scalar memory area (real) More...
 
virtual alsfvm::shared_ptr< const memory::Memory< real > > operator[] (size_t index) const
 gets the scalar memory area (real) More...
 
virtual alsfvm::shared_ptr< memory::Memory< real > > operator[] (size_t index)
 gets the scalar memory area (real) More...
 
virtual const memory::Memory< real > & operator[] (const std::string &name) const
 gets the scalar memory area (real) More...
 
virtual memory::Memory< real > & operator[] (const std::string &name)
 gets the scalar memory area (real) More...
 
virtual size_t getIndexFromName (const std::string &name) const
 getIndexFromName returns the given index from the name More...
 
virtual std::string getName (size_t index) const
 
virtual Volumeoperator+= (const Volume &other)
 
virtual Volumeoperator*= (real scalar)
 
virtual size_t getNumberOfXCells () const
 
virtual size_t getNumberOfYCells () const
 
virtual size_t getNumberOfZCells () const
 
virtual void makeZero ()
 makeZero sets every element of the volume to zero (0). More...
 
virtual size_t getNumberOfXGhostCells () const
 
virtual size_t getNumberOfYGhostCells () const
 
virtual size_t getNumberOfZGhostCells () const
 
virtual size_t getTotalNumberOfXCells () const
 
virtual size_t getTotalNumberOfYCells () const
 
virtual size_t getTotalNumberOfZCells () const
 
virtual void copyInternalCells (size_t memoryAreaIndex, real *output, size_t outputSize) const
 
virtual void copyTo (volume::Volume &other) const
 
virtual void setVolume (const volume::Volume &other)
 setVolume sets the contents of this volume to the contenst of the other volume More...
 
virtual size_t getDimensions () const
 Gets the number of space dimensions. More...
 
void addLinearCombination (real a1, real a2, const Volume &v2, real a3, const Volume &v3, real a4, const Volume &v4, real a5, const Volume &v5)
 
virtual ivec3 getTotalDimensions () const
 
virtual void addPower (const Volume &other, real power)
 
virtual void addPower (const Volume &other, real power, real factor)
 
virtual void subtractPower (const Volume &other, real power)
 
std::shared_ptr< volume::VolumemakeInstance () const
 Makes a volume with the same memory areas and the same sizes. More...
 
std::shared_ptr< volume::VolumemakeInstance (size_t nx, size_t ny, size_t nz, const std::string &platform="default") const
 
std::shared_ptr< volume::VolumegetCopyOnCPU ()
 
bool hasVariable (const std::string &variableName) const
 Returns true if the volume has the given variable, false otherwise. More...
 

Detailed Description

The Volume class represents a volume (a collection of cells with values for each cell (eg. pressure, density, etc)

Constructor & Destructor Documentation

◆ Volume() [1/2]

alsfvm::volume::Volume::Volume ( const std::vector< std::string > &  variableNames,
alsfvm::shared_ptr< memory::MemoryFactory memoryFactory,
size_t  nx,
size_t  ny,
size_t  nz,
size_t  numberOfGhostCells = 0 
)

Volume creates a new volume object.

Parameters
variableNamesa list of the used variable names. Typically this can be "rho", "m", "u", etc.
memoryFactorythe memory factory to use to create new memory areas.
nxthe number of cells in x diretion
nythe number of cells in y diretion
nzthe number of cells in z diretion
numberOfGhostCellsthe number of ghost cells
Note
we deduce from ny and nz whether or not to added ghostcells in that direction. Ie. if ny==1, then we do not add ghost cells in y direction

◆ Volume() [2/2]

alsfvm::volume::Volume::Volume ( Volume volume,
const std::vector< size_t > &  components,
const std::vector< std::string > &  variableNames 
)

Make a volume as a view of another volume.

Parameters
volumethe volume to make a view of
componentsthe components to use
variableNamesthe variableNames to use

◆ ~Volume()

alsfvm::volume::Volume::~Volume ( )
virtual

Member Function Documentation

◆ addLinearCombination()

void alsfvm::volume::Volume::addLinearCombination ( real  a1,
real  a2,
const Volume v2,
real  a3,
const Volume v3,
real  a4,
const Volume v4,
real  a5,
const Volume v5 
)

Adds the volumes with coefficients to this volume Here we compute the sum

\[ v_1^{\mathrm{new}}=a_1v_1+a_2v_2+a_3v_3+a_4v_4+a_5v_5+a_6v_6\]

where $v_1$ is the volume being operated on.

◆ addPower() [1/2]

void alsfvm::volume::Volume::addPower ( const Volume other,
real  power 
)
virtual

Adds a power of the other volume to this volume, ie

\[this += pow(other, power)\]

Parameters
otherthe other volume to the the power of
powerthe power to use

◆ addPower() [2/2]

void alsfvm::volume::Volume::addPower ( const Volume other,
real  power,
real  factor 
)
virtual

Adds a power of the other volume to this volume, ie

\[this += factor*pow(other, power)\]

Parameters
otherthe other volume to the the power of
powerthe power to use

◆ copyInternalCells()

void alsfvm::volume::Volume::copyInternalCells ( size_t  memoryAreaIndex,
real output,
size_t  outputSize 
) const
virtual

Copies the contents of the given memory area into the buffer output.

This is ideal for removing the ghost cells before output.

Note
Throws an exception if outputSize < number of cells

◆ copyTo()

void alsfvm::volume::Volume::copyTo ( volume::Volume other) const
virtual

Copies the whole volume to the other volume

◆ getCopyOnCPU()

std::shared_ptr< Volume > alsfvm::volume::Volume::getCopyOnCPU ( )

If the volume is on the CPU, returns a pointer to the current volume, otherwise, make a new cpu copy, copy data from gpu, and then return

◆ getDimensions()

size_t alsfvm::volume::Volume::getDimensions ( ) const
virtual

Gets the number of space dimensions.

◆ getIndexFromName()

size_t alsfvm::volume::Volume::getIndexFromName ( const std::string &  name) const
virtual

getIndexFromName returns the given index from the name

Parameters
namethe name of the variable
Returns
the index of the name.

◆ getInnerSize()

ivec3 alsfvm::volume::Volume::getInnerSize ( ) const
virtual

Gets the size without ghost cells in each dimension.

◆ getName()

std::string alsfvm::volume::Volume::getName ( size_t  index) const
virtual

Gets the variable name associated to the given index

Parameters
indexthe index of the variable name
Returns
the variable name
Note
This implicitly uses the std::move-feature of C++11

◆ getNumberOfGhostCells()

ivec3 alsfvm::volume::Volume::getNumberOfGhostCells ( ) const
virtual

Returns the number of ghostcells in each dimension.

◆ getNumberOfVariables()

size_t alsfvm::volume::Volume::getNumberOfVariables ( ) const
virtual

getNumberOfVariables gets the number of variables used

Returns
the number of variables

◆ getNumberOfXCells()

size_t alsfvm::volume::Volume::getNumberOfXCells ( ) const
virtual
Returns
the number of cells in X direction

◆ getNumberOfXGhostCells()

size_t alsfvm::volume::Volume::getNumberOfXGhostCells ( ) const
virtual

Gets the number of ghost cells in x direction

Note
This is the number of ghost cells on one side.

◆ getNumberOfYCells()

size_t alsfvm::volume::Volume::getNumberOfYCells ( ) const
virtual
Returns
the number of cells in Y direction

◆ getNumberOfYGhostCells()

size_t alsfvm::volume::Volume::getNumberOfYGhostCells ( ) const
virtual

Gets the number of ghost cells in y direction

Note
This is the number of ghost cells on one side.

◆ getNumberOfZCells()

size_t alsfvm::volume::Volume::getNumberOfZCells ( ) const
virtual
Returns
the number of cells in Z direction

◆ getNumberOfZGhostCells()

size_t alsfvm::volume::Volume::getNumberOfZGhostCells ( ) const
virtual

Gets the number of ghost cells in z direction

Note
This is the number of ghost cells on one side.

◆ getScalarMemoryArea() [1/4]

alsfvm::shared_ptr< memory::Memory< real > > & alsfvm::volume::Volume::getScalarMemoryArea ( size_t  index)
virtual

getScalarMemoryArea gets the scalar memory area (real)

Parameters
indexthe index of the variable. Use getIndexFromName to get the index.
Returns
the MemoryArea for the given index

◆ getScalarMemoryArea() [2/4]

alsfvm::shared_ptr< const memory::Memory< real > > alsfvm::volume::Volume::getScalarMemoryArea ( size_t  index) const
virtual

getScalarMemoryArea gets the scalar memory area (real)

Parameters
indexthe index of the variable. Use getIndexFromName to get the index.
Returns
the MemoryArea for the given index

◆ getScalarMemoryArea() [3/4]

alsfvm::shared_ptr< memory::Memory< real > > & alsfvm::volume::Volume::getScalarMemoryArea ( const std::string &  name)
virtual

getScalarMemoryArea gets the scalar memory area (real)

Parameters
namethe name of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(getIndexFromName(name))

◆ getScalarMemoryArea() [4/4]

alsfvm::shared_ptr< const memory::Memory< real > > alsfvm::volume::Volume::getScalarMemoryArea ( const std::string &  name) const
virtual

getScalarMemoryArea gets the scalar memory area (real)

Parameters
namethe name of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(getIndexFromName(name))

◆ getSize()

ivec3 alsfvm::volume::Volume::getSize ( ) const
virtual

Returns the size in each dimension.

◆ getTotalDimensions()

ivec3 alsfvm::volume::Volume::getTotalDimensions ( ) const
virtual

Gets the total size in each dimension. Equivalent to calling

ivec3 dimensions{volume.getTotalNumberOfXCells(),
volume.getTotalNumberOfYCells(),
volume.getTotalNumberOfZCells()};

◆ getTotalNumberOfXCells()

size_t alsfvm::volume::Volume::getTotalNumberOfXCells ( ) const
virtual

Returns the total number of cells in x direction, including ghost cells

◆ getTotalNumberOfYCells()

size_t alsfvm::volume::Volume::getTotalNumberOfYCells ( ) const
virtual

Returns the total number of cells in y direction, including ghost cells

◆ getTotalNumberOfZCells()

size_t alsfvm::volume::Volume::getTotalNumberOfZCells ( ) const
virtual

Returns the total number of cells in z direction, including ghost cells

◆ hasVariable()

bool alsfvm::volume::Volume::hasVariable ( const std::string &  variableName) const

Returns true if the volume has the given variable, false otherwise.

◆ makeInstance() [1/2]

std::shared_ptr< Volume > alsfvm::volume::Volume::makeInstance ( ) const

Makes a volume with the same memory areas and the same sizes.

◆ makeInstance() [2/2]

std::shared_ptr< Volume > alsfvm::volume::Volume::makeInstance ( size_t  nx,
size_t  ny,
size_t  nz,
const std::string &  platform = "default" 
) const

Makes a new volume with the same names for the memory areas, but with the newly given sizes.

◆ makeZero()

void alsfvm::volume::Volume::makeZero ( )
virtual

makeZero sets every element of the volume to zero (0).

◆ operator*=()

Volume & alsfvm::volume::Volume::operator*= ( real  scalar)
virtual

Multiplies each component of the volume by the scalar

◆ operator+=()

Volume & alsfvm::volume::Volume::operator+= ( const Volume other)
virtual

Adds each component of the other volume to this volume

◆ operator[]() [1/4]

alsfvm::shared_ptr< const memory::Memory< real > > alsfvm::volume::Volume::operator[] ( size_t  index) const
virtual

gets the scalar memory area (real)

Parameters
indexthe index of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(index)

◆ operator[]() [2/4]

alsfvm::shared_ptr< memory::Memory< real > > alsfvm::volume::Volume::operator[] ( size_t  index)
virtual

gets the scalar memory area (real)

Parameters
indexthe index of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(index)

◆ operator[]() [3/4]

const memory::Memory< real > & alsfvm::volume::Volume::operator[] ( const std::string &  name) const
virtual

gets the scalar memory area (real)

Parameters
namethe name of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(name)

◆ operator[]() [4/4]

memory::Memory< real > & alsfvm::volume::Volume::operator[] ( const std::string &  name)
virtual

gets the scalar memory area (real)

Parameters
namethe name of the variable
Returns
the MemoryArea for the given name
Note
Equivalent to calling getScalarMemoryArea(name)

◆ setVolume()

void alsfvm::volume::Volume::setVolume ( const volume::Volume other)
virtual

setVolume sets the contents of this volume to the contenst of the other volume

Parameters
otherthe other volume to read from
Note
This does interpolation if necessary.

◆ subtractPower()

void alsfvm::volume::Volume::subtractPower ( const Volume other,
real  power 
)
virtual

Subtracts a power of the other volume to this volume, ie

\[this -= pow(other, power)\]

Parameters
otherthe other volume to the the power of
powerthe power to use

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