ABLATE Source Documentation  0.12.33
ablate::boundarySolver::BoundarySolver Class Reference
+ Inheritance diagram for ablate::boundarySolver::BoundarySolver:

Classes

struct  BoundaryFVFaceGeom
 
struct  BoundaryPreRHSPointFunctionDefinition
 

Public Types

enum class  BoundarySourceType { Point , Distributed , Flux , Face }
 
using BoundarySourceFunction = PetscErrorCode(*)(PetscInt dim, const BoundaryFVFaceGeom *fg, const PetscFVCellGeom *boundaryCell, const PetscInt uOff[], const PetscScalar *boundaryValues, const PetscScalar *stencilValues[], const PetscInt aOff[], const PetscScalar *auxValues, const PetscScalar *stencilAuxValues[], PetscInt stencilSize, const PetscInt stencil[], const PetscScalar stencilWeights[], const PetscInt sOff[], PetscScalar source[], void *ctx)
 
using BoundaryUpdateFunction = PetscErrorCode(*)(PetscInt dim, const BoundaryFVFaceGeom *fg, const PetscFVCellGeom *boundaryCell, const PetscInt uOff[], PetscScalar *boundaryValues, const PetscScalar *stencilValues, const PetscInt aOff[], PetscScalar *auxValues, const PetscScalar *stencilAuxValues, void *ctx)
 
using BoundaryPreRHSFunctionDefinition = PetscErrorCode(*)(BoundarySolver &, TS ts, PetscReal time, bool initialStage, Vec locX, void *ctx)
 
using BoundaryPreRHSPointFunction = PetscErrorCode(*)(PetscReal time, PetscReal dt, PetscInt dim, const BoundaryFVFaceGeom *fg, const PetscFVCellGeom *boundaryCell, const PetscInt uOff[], PetscScalar *boundaryValues, const PetscScalar *stencilValues[], const PetscInt aOff[], PetscScalar *auxValues, const PetscScalar *stencilAuxValues[], PetscInt stencilSize, const PetscInt stencil[], const PetscScalar stencilWeights[], void *ctx)
 
- Public Types inherited from ablate::solver::CellSolver
using AuxFieldUpdateFunction = PetscErrorCode(*)(PetscReal time, PetscInt dim, const PetscFVCellGeom *cellGeom, const PetscInt uOff[], const PetscScalar *u, const PetscInt aOff[], PetscScalar *auxField, void *ctx)
 function template for updating the aux field
 
using SolutionFieldUpdateFunction = PetscErrorCode(*)(PetscReal time, PetscInt dim, const PetscFVCellGeom *cellGeom, const PetscInt uOff[], PetscScalar *u, void *ctx)
 function template for updating the solution field
 
- Public Types inherited from ablate::io::Serializable
enum class  SerializerType { none , collective , serial }
 

Public Member Functions

PetscErrorCode ComputeBoundaryPreRHSPointFunction (PetscReal time, PetscReal dt, Vec locXVec, const BoundaryPreRHSPointFunctionDefinition &boundaryPreRhsPointFunction)
 
 BoundarySolver (std::string solverId, std::shared_ptr< domain::Region > region, std::shared_ptr< domain::Region > fieldBoundary, std::vector< std::shared_ptr< BoundaryProcess >> boundaryProcesses, std::shared_ptr< parameters::Parameters > options, bool mergeFaces=false)
 
void Setup () override
 
void Initialize () override
 
void RegisterFunction (BoundarySourceFunction function, void *context, const std::vector< std::string > &sourceFields, const std::vector< std::string > &inputFields, const std::vector< std::string > &auxFields, BoundarySourceType type=BoundarySourceType::Point)
 
void RegisterFunction (BoundaryUpdateFunction function, void *context, const std::vector< std::string > &inputFields, const std::vector< std::string > &auxFields)
 
void RegisterPreRHSFunction (BoundaryPreRHSFunctionDefinition function, void *context)
 
PetscErrorCode ComputeRHSFunction (PetscReal time, Vec locXVec, Vec locFVec) override
 
PetscErrorCode ComputeRHSFunction (PetscReal time, Vec locXVec, Vec locFVec, const std::vector< BoundarySourceFunctionDescription > &boundarySourceFunctions)
 
void InsertFieldFunctions (const std::vector< std::shared_ptr< mathFunctions::FieldFunction >> &initialization, PetscReal time=0.0)
 
std::vector< GradientStencil > GetBoundaryGeometry (PetscInt cell) const
 
const std::vector< GradientStencil > & GetBoundaryGeometry () const
 
const std::vector< std::string > & GetOutputComponents ()
 
const std::vector< BoundarySourceFunctionDescription > & GetOutputFunctions ()
 
PetscErrorCode PreRHSFunction (TS ts, PetscReal time, bool initialStage, Vec locX) override
 
SerializerType Serialize () const override
 
const std::string & GetId () const override
 
PetscErrorCode Save (PetscViewer viewer, PetscInt sequenceNumber, PetscReal time) override
 
PetscErrorCode Restore (PetscViewer viewer, PetscInt sequenceNumber, PetscReal time) override
 
- Public Member Functions inherited from ablate::solver::CellSolver
 CellSolver (std::string solverId, std::shared_ptr< domain::Region >={}, std::shared_ptr< parameters::Parameters > options=nullptr)
 
void RegisterAuxFieldUpdate (AuxFieldUpdateFunction function, void *context, const std::vector< std::string > &auxField, const std::vector< std::string > &inputFields)
 
void RegisterSolutionFieldUpdate (SolutionFieldUpdateFunction function, void *context, const std::vector< std::string > &inputFields)
 
void UpdateAuxFields (PetscReal time, Vec locXVec, Vec locAuxField)
 
void UpdateSolutionFields (PetscReal time, Vec globXVec)
 
void Setup () override
 
void Initialize () override
 
- Public Member Functions inherited from ablate::solver::Solver
virtual void Register (std::shared_ptr< ablate::domain::SubDomain > subDomain)
 
const std::string & GetSolverId () const
 
ablate::domain::SubDomainGetSubDomain () noexcept
 
const ablate::domain::SubDomainGetSubDomain () const noexcept
 
std::shared_ptr< domain::RegionGetRegion () const noexcept
 
void PreStage (TS ts, PetscReal stagetime)
 
void PreStep (TS ts)
 
void PostStep (TS ts)
 
void PostEvaluate (TS ts)
 
void RegisterPreStep (const std::function< void(TS ts, Solver &)> &preStep)
 
void RegisterPreStage (const std::function< void(TS ts, Solver &, PetscReal)> &preStage)
 
void RegisterPostStep (const std::function< void(TS ts, Solver &)> &postStep)
 
void RegisterPostEvaluate (const std::function< void(TS ts, Solver &)> &postEval)
 
void GetCellRange (ablate::domain::Range &cellRange) const
 
void GetFaceRange (ablate::domain::Range &faceRange) const
 
void GetRange (PetscInt depth, ablate::domain::Range &range) const
 
void RestoreRange (ablate::domain::Range &range) const
 

Static Public Member Functions

static void ComputeGradient (PetscInt dim, PetscScalar boundaryValue, PetscInt stencilSize, const PetscScalar *stencilValues, const PetscScalar *stencilWeights, PetscScalar *grad)
 
static void ComputeGradientAlongNormal (PetscInt dim, const BoundaryFVFaceGeom *fg, PetscScalar boundaryValue, PetscInt stencilSize, const PetscScalar *stencilValues, const PetscScalar *stencilWeights, PetscScalar &dPhiDNorm)
 

Protected Attributes

std::vector< GradientStencil > gradientStencils
 
- Protected Attributes inherited from ablate::solver::CellSolver
Vec cellGeomVec = nullptr
 Vector used to describe the entire cell geom of the dm. This is constant and does not depend upon region.
 
Vec faceGeomVec = nullptr
 Vector used to describe the entire face geom of the dm. This is constant and does not depend upon region.
 
- Protected Attributes inherited from ablate::solver::Solver
PetscOptions petscOptions
 
std::shared_ptr< ablate::domain::SubDomainsubDomain
 

Additional Inherited Members

- Protected Member Functions inherited from ablate::solver::Solver
 Solver (std::string solverId, std::shared_ptr< domain::Region >={}, std::shared_ptr< parameters::Parameters > options=nullptr)
 
- Static Protected Member Functions inherited from ablate::solver::Solver
static PetscErrorCode DMPlexInsertBoundaryValues_Plex (DM dm, PetscDS ds, PetscBool insertEssential, Vec locX, PetscReal time, Vec faceGeomFVM, Vec cellGeomFVM, Vec gradFVM)
 
static PetscErrorCode DMPlexInsertTimeDerivativeBoundaryValues_Plex (DM dm, PetscDS ds, PetscBool insertEssential, Vec locX, PetscReal time, Vec faceGeomFVM, Vec cellGeomFVM, Vec gradFVM)
 
- Static Protected Member Functions inherited from ablate::io::Serializable
static PetscErrorCode SaveKeyValue (PetscViewer viewer, const char *name, PetscScalar value)
 
static PetscErrorCode RestoreKeyValue (PetscViewer viewer, const char *name, PetscScalar &value)
 
template<class T >
static PetscErrorCode SaveKeyValue (PetscViewer viewer, const char *name, T value)
 
template<class T >
static PetscErrorCode RestoreKeyValue (PetscViewer viewer, const char *name, T &value)
 
template<class T >
static SerializerType DetermineSerializerType (const T &types)
 

Member Typedef Documentation

◆ BoundaryPreRHSFunctionDefinition

using ablate::boundarySolver::BoundarySolver::BoundaryPreRHSFunctionDefinition = PetscErrorCode (*)(BoundarySolver&, TS ts, PetscReal time, bool initialStage, Vec locX, void* ctx)

Called before any of the rhs functions of the solver

◆ BoundaryPreRHSPointFunction

using ablate::boundarySolver::BoundarySolver::BoundaryPreRHSPointFunction = PetscErrorCode (*)(PetscReal time, PetscReal dt, PetscInt dim, const BoundaryFVFaceGeom* fg, const PetscFVCellGeom* boundaryCell, const PetscInt uOff[], PetscScalar* boundaryValues, const PetscScalar* stencilValues[], const PetscInt aOff[], PetscScalar* auxValues, const PetscScalar* stencilAuxValues[], PetscInt stencilSize, const PetscInt stencil[], const PetscScalar stencilWeights[], void* ctx)

Simple function definition used to iterate over all boundary cells before the time step

◆ BoundaryUpdateFunction

using ablate::boundarySolver::BoundarySolver::BoundaryUpdateFunction = PetscErrorCode (*)(PetscInt dim, const BoundaryFVFaceGeom* fg, const PetscFVCellGeom* boundaryCell, const PetscInt uOff[], PetscScalar* boundaryValues, const PetscScalar* stencilValues, const PetscInt aOff[], PetscScalar* auxValues, const PetscScalar* stencilAuxValues, void* ctx)

Update the solution or aux field before each time step

Member Enumeration Documentation

◆ BoundarySourceType

Boundaries can be treated in two different ways, point source on the boundary or distributed in the other phase. For the Distributed model, the source is divided by volume in each case

Enumerator
Distributed 

the source terms are added to boundary cell

Flux 

the source terms are distributed to neighbor cells based upon the stencil (divided by cell volume)

Face 

the source term are added to only one neighbor cell. (divided by cell volume) the face location of the rhs array is directly passed to the function, this is only useful/called for io

Constructor & Destructor Documentation

◆ BoundarySolver()

ablate::boundarySolver::BoundarySolver::BoundarySolver ( std::string  solverId,
std::shared_ptr< domain::Region region,
std::shared_ptr< domain::Region fieldBoundary,
std::vector< std::shared_ptr< BoundaryProcess >>  boundaryProcesses,
std::shared_ptr< parameters::Parameters options,
bool  mergeFaces = false 
)
Parameters
solverIdthe id for this solver
regionthe boundary cell region
fieldBoundarythe region describing the faces between the boundary and field
boundaryProcessesa list of boundary processes
optionsother options

Member Function Documentation

◆ ComputeBoundaryPreRHSPointFunction()

PetscErrorCode ablate::boundarySolver::BoundarySolver::ComputeBoundaryPreRHSPointFunction ( PetscReal  time,
PetscReal  dt,
Vec  locXVec,
const BoundaryPreRHSPointFunctionDefinition boundaryPreRhsPointFunction 
)

Helper function that can be called from other locations to to iterate over each boundary cell

Parameters
time
dt
locXVec
boundaryPreRhsPointFunction
Returns

◆ ComputeGradient()

void ablate::boundarySolver::BoundarySolver::ComputeGradient ( PetscInt  dim,
PetscScalar  boundaryValue,
PetscInt  stencilSize,
const PetscScalar *  stencilValues,
const PetscScalar *  stencilWeights,
PetscScalar *  grad 
)
static

public helper function to compute the gradient

Parameters
dim
boundaryValue
stencilValues
stencilWeights
grad

◆ ComputeGradientAlongNormal()

void ablate::boundarySolver::BoundarySolver::ComputeGradientAlongNormal ( PetscInt  dim,
const BoundaryFVFaceGeom fg,
PetscScalar  boundaryValue,
PetscInt  stencilSize,
const PetscScalar *  stencilValues,
const PetscScalar *  stencilWeights,
PetscScalar &  dPhiDNorm 
)
static

public helper function to compute dPhiDNorm

Parameters
dim
boundaryValue
stencilValues
stencilWeights
grad

◆ ComputeRHSFunction() [1/2]

PetscErrorCode ablate::boundarySolver::BoundarySolver::ComputeRHSFunction ( PetscReal  time,
Vec  locXVec,
Vec  locFVec 
)
overridevirtual

Function passed into PETSc to compute the FV RHS with all boundarySourceFunctions

Parameters
time
locXVec
locFVec
Returns

Implements ablate::solver::RHSFunction.

Reimplemented in ablate::boundarySolver::DebugBoundarySolver.

◆ ComputeRHSFunction() [2/2]

PetscErrorCode ablate::boundarySolver::BoundarySolver::ComputeRHSFunction ( PetscReal  time,
Vec  locXVec,
Vec  locFVec,
const std::vector< BoundarySourceFunctionDescription > &  boundarySourceFunctions 
)

Public function to allow arbitrary boundarySourceFunctions to be used for computation

Parameters
time
locXVec
locFVec
boundarySourceFunctions
Returns

◆ GetBoundaryGeometry() [1/2]

const std::vector<GradientStencil>& ablate::boundarySolver::BoundarySolver::GetBoundaryGeometry ( ) const
inline

Return a copy of all GradientStencil

◆ GetBoundaryGeometry() [2/2]

std::vector< ablate::boundarySolver::BoundarySolver::GradientStencil > ablate::boundarySolver::BoundarySolver::GetBoundaryGeometry ( PetscInt  cell) const

Return a reference to the boundary geometry. This is a slow call and should only be done for init/debugging/testing

◆ GetId()

const std::string& ablate::boundarySolver::BoundarySolver::GetId ( ) const
inlineoverridevirtual

only required function, returns the id of the object. Should be unique for the simulation

Returns

Implements ablate::io::Serializable.

◆ GetOutputComponents()

const std::vector<std::string>& ablate::boundarySolver::BoundarySolver::GetOutputComponents ( )
inline

Get access to the output fields

◆ GetOutputFunctions()

const std::vector<BoundarySourceFunctionDescription>& ablate::boundarySolver::BoundarySolver::GetOutputFunctions ( )
inline

Get access to the output functions

◆ InsertFieldFunctions()

void ablate::boundarySolver::BoundarySolver::InsertFieldFunctions ( const std::vector< std::shared_ptr< mathFunctions::FieldFunction >> &  initialization,
PetscReal  time = 0.0 
)

Helper function to project values to a cell boundary instead of the cell centroid

◆ PreRHSFunction()

PetscErrorCode ablate::boundarySolver::BoundarySolver::PreRHSFunction ( TS  ts,
PetscReal  time,
bool  initialStage,
Vec  locX 
)
overridevirtual

Called to update the aux variables

Parameters
time
locX
Returns

Reimplemented from ablate::solver::RHSFunction.

◆ RegisterFunction() [1/2]

void ablate::boundarySolver::BoundarySolver::RegisterFunction ( BoundarySourceFunction  function,
void *  context,
const std::vector< std::string > &  sourceFields,
const std::vector< std::string > &  inputFields,
const std::vector< std::string > &  auxFields,
BoundarySourceType  type = BoundarySourceType::Point 
)

Register an arbitrary function. The user is responsible for all work. When registering face based functions the each sourceField is assumed to be a separate components in a single field

Parameters
function
context

◆ RegisterFunction() [2/2]

void ablate::boundarySolver::BoundarySolver::RegisterFunction ( BoundaryUpdateFunction  function,
void *  context,
const std::vector< std::string > &  inputFields,
const std::vector< std::string > &  auxFields 
)

Register an update function.

Parameters
function
context

◆ RegisterPreRHSFunction()

void ablate::boundarySolver::BoundarySolver::RegisterPreRHSFunction ( BoundaryPreRHSFunctionDefinition  function,
void *  context 
)

Register an pre function that is called before any RHS function

Parameters
function
context

◆ Restore()

PetscErrorCode ablate::boundarySolver::BoundarySolver::Restore ( PetscViewer  viewer,
PetscInt  sequenceNumber,
PetscReal  time 
)
overridevirtual

Restore each of the processes

Parameters
viewer
sequenceNumber
time

Implements ablate::io::Serializable.

◆ Save()

PetscErrorCode ablate::boundarySolver::BoundarySolver::Save ( PetscViewer  viewer,
PetscInt  sequenceNumber,
PetscReal  time 
)
overridevirtual

Call each of the processes to be saved

Parameters
viewer
sequenceNumber
time

Implements ablate::io::Serializable.

◆ Serialize()

ablate::io::Serializable::SerializerType ablate::boundarySolver::BoundarySolver::Serialize ( ) const
overridevirtual

Check to see if any of the processes should be serialized

Returns

Reimplemented from ablate::io::Serializable.

◆ Setup()

void ablate::boundarySolver::BoundarySolver::Setup ( )
overridevirtual

SubDomain Register and Setup

Implements ablate::solver::Solver.

Reimplemented in ablate::boundarySolver::DebugBoundarySolver.


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