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

The PythonInitialData class sets the initial data through a python string. More...

#include <alsfvm/init/PythonInitialData.hpp>

Inheritance diagram for alsfvm::init::PythonInitialData:
alsfvm::init::InitialData

Public Member Functions

 PythonInitialData (const std::string &programString, const Parameters &parameters)
 PythonInitialData constructs the object. More...
 
virtual void setInitialData (volume::Volume &conservedVolume, volume::Volume &primitiveVolume, equation::CellComputer &cellComputer, grid::Grid &grid) override
 setInitialData sets the initial data More...
 
virtual void setParameters (const Parameters &parameters) override
 Sets the given parameters. More...
 
virtual boost::property_tree::ptree getDescription () const override
 
- Public Member Functions inherited from alsfvm::init::InitialData
virtual ~InitialData ()
 

Detailed Description

The PythonInitialData class sets the initial data through a python string.

Constructor & Destructor Documentation

◆ PythonInitialData()

alsfvm::init::PythonInitialData::PythonInitialData ( const std::string &  programString,
const Parameters parameters 
)

PythonInitialData constructs the object.

Parameters
programStringthe string containing the full python program.
parametersa list of parameters to give to the python code this could eg be the adiabatic constant (gamma), some uq parameters, etc

The programString should be in the following format:

# coordinates are stored in the variables x, y and z
rho = ...
ux = ...
uy = ...
uz = ...
p = ...

We also accept scripts on the form of a function. This should have form

def init_global(x_midpoints, y_midpoints, z_midpoints, dx, dy, dz, rho, ux, uy, uz, p):
for (n,x) in enumerate(x_midpoints):
for (m,y) in enumerate(y_midpoints):
for (o,z) in enumerate(z_midpoints):
rho[n,m,o] = ...
ux[n,m,o] = ...
uy[n,m,o] = ...
uz[n,m,o] = ...
p[n,m,o] = ...

The momentum (m) and energy will be computed automatically.

Member Function Documentation

◆ getDescription()

boost::property_tree::ptree alsfvm::init::PythonInitialData::getDescription ( ) const
overridevirtual

Should provide a description of the initial data (eg the python script used for the initial data). Does not need to be machine parseable in any way, this is for "human readable reproducability" and extra debugging information.

Implements alsfvm::init::InitialData.

◆ setInitialData()

void alsfvm::init::PythonInitialData::setInitialData ( volume::Volume conservedVolume,
volume::Volume primitiveVolume,
equation::CellComputer cellComputer,
grid::Grid grid 
)
overridevirtual

setInitialData sets the initial data

Parameters
conservedVolumeconserved volume to fill
cellComputeran instance of the cell computer for the equation
primitiveVolumean instance of the primtive volume for the equation
gridunderlying grid.
Note
All volumes need to have the correct size. All volumes will at the end be written to.
This is not an efficient implementation, so it should really only be used for initial data!

Implements alsfvm::init::InitialData.

◆ setParameters()

void alsfvm::init::PythonInitialData::setParameters ( const Parameters parameters)
overridevirtual

Sets the given parameters.

Implements alsfvm::init::InitialData.


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