Field Class Reference

AMR-Wind API: amr_wind::Field Class Reference
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches

#include <Field.H>

Collaboration diagram for amr_wind::Field:
[legend]

Public Member Functions

 Field (const Field &)=delete
Fieldoperator= (const Field &)=delete
 ~Field ()
const std::string & name () const
 Name of this field (including state information)
const std::string & base_name () const
 Base name (without state information)
unsigned id () const
 Unique integer identifier for this field.
int num_comp () const
 Number of components for this field.
const amrex::IntVect & num_grow () const
 Ghost cells.
int num_time_states () const
 Number of exact time states available for this field.
int num_states () const
 Number of states available for this field.
FieldLoc field_location () const
 Cell, node, or face centered field.
FieldState field_state () const
 State of this field instance.
FieldReporepo () const
 FieldRepo instance that manages this field.
bool & fillpatch_on_regrid ()
bool fillpatch_on_regrid () const
bool query_state (const FieldState fstate) const
 Return true if the requested state exists for this field.
const amrex::GpuArray< BC, AMREX_SPACEDIM *2 > & bc_type () const
amrex::GpuArray< BC, AMREX_SPACEDIM *2 > & bc_type ()
amrex::Vector< amrex::Vector< amrex::Real > > & bc_values ()
 Return reference to the host view of BC values array.
amrex::Vector< amrex::BCRec > & bcrec () const
 Return reference to host view of BCRec array.
const amrex::GpuArray< const amrex::Real *, AMREX_SPACEDIM *2 > & bc_values_device () const
const amrex::Gpu::DeviceVector< amrex::BCRec > & bcrec_device () const
void copy_bc_to_device ()
 Copy BC data from host to device.
bool bc_initialized () const
 Return flag indicating whether BCs have been initialized.
bool has_fillpatch_op () const
 Return a flag indicating whether a fillpatch Op has been registered.
void set_default_fillpatch_bc (const SimTime &time, amrex::BCType::mathematicalBndryTypes bctype=amrex::BCType::hoextrap)
void to_uniform_space ()
void to_stretched_space ()
Fieldstate (FieldState fstate)
 Return field at a different time state.
const Fieldstate (FieldState fstate) const
amrex::MultiFab & operator() (int lev)
 Return MultiFab instance for a given level.
const amrex::MultiFab & operator() (int lev) const
amrex::Vector< amrex::MultiFab * > vec_ptrs ()
 Return a vector of MultiFab pointers for all levels.
amrex::Vector< const amrex::MultiFab * > vec_const_ptrs () const
 Return vector of const MultiFab* for all levels.
void advance_states ()
 Advance timestep for fields with multiple states.
void copy_state (FieldState to_state, FieldState from_state)
 Copy a user-specified "from_state" to "to_state".
Fieldcreate_state (FieldState fstate)
 Create a new time state after the field has been created.
void setVal (amrex::Real value)
 Set the field to a constant value at all levels.
void setVal (amrex::Real value, int start_comp, int num_comp=1, int nghost=0)
void setVal (const amrex::Vector< amrex::Real > &values, int nghost=0)
ViewField< Fieldsubview (const int scomp=0, const int ncomp=1)
template<typename T, class... Args>
void register_fill_patch_op (Args &&... args)
template<typename T, class... Args>
void register_custom_bc (Args &&... args)
void fillpatch (amrex::Real time)
void fillpatch (amrex::Real time, amrex::IntVect ng)
void fillpatch_sibling_fields (amrex::Real time, amrex::IntVect ng, amrex::Array< Field *, AMREX_SPACEDIM > &fields) const
void fillphysbc (amrex::Real time)
void fillphysbc (amrex::Real time, amrex::IntVect ng)
void apply_bc_funcs (FieldState rho_state)
void fillpatch (int lev, amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost)
void fillpatch_from_coarse (int lev, amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost)
void fillphysbc (int lev, amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost)
void set_inflow (int lev, amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost)
void set_inflow_sibling_fields (int lev, amrex::Real time, amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > mfabs)
void fillpatch (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost)
void fillpatch_from_coarse (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost)
void fillphysbc (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost)
void set_inflow (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost)
bool & in_uniform_space ()
bool in_uniform_space () const
bool has_inout_bndry () const
 Check if any of the boundaries is a mass-inflow-outflow.
void set_inout_bndry ()
 Set the inout_bndry flag.

Protected Member Functions

 Field (FieldRepo &repo, std::string name, std::shared_ptr< FieldInfo > finfo, unsigned fid, FieldState state)

Protected Attributes

FieldRepom_repo
 Reference to the FieldRepository instance.
const std::string m_name
 Name of the field.
std::shared_ptr< FieldInfom_info
 Common data for all field states.
const unsigned m_id
 Unique ID for this field.
const FieldState m_state
 State for this field.
bool m_fillpatch_on_regrid {false}
 Flag indicating whether fill patch operation must be performed for this field during regrid.
bool m_mesh_mapped {false}
 Flag to track mesh mapping (to uniform space) of field.
bool m_inout_bndry {false}
 Flag to indicate whether any of the boundaries is mass-inflow-outflow.

Friends

class FieldRepo

Detailed Description

Computational field

This is an abstraction of a collection of MultiFabs over multiple levels, and allows operations on the field as a whole. The Field cannot be constructed directly but instead must be created using field creation functions in amr_wind::FieldRepo. This indirection is necessary to allow different parts of the code to hold a reference to the Field instance without having to worry about the changes in underlynig MultiFab data during regrid operations.

Field data is split into two groups: information that is unique to a particular field at a given time state, and data that is common to a given field with multiple timestates. The latter is held within amr_wind::FieldInfo object that is common to all time instances of a given Field (which are themselves Field instances). Different time instances of a Field can access other states through this FieldInfo instance, as well as access boundary conditions and fill patch operators applicable to all states.

As Field does not hold any data itself, but instead is just a thin wrapper to data held by amr_wind::FieldRepo, Field instance cannot be created directly. Instead the user must use amr_wind::FieldRepo::declare_field to create and initialize the field. This also ensures that the FieldInfo instance is managed properly during field creation. Once a field is created, the user can customize the behavior (e.g., registering fill patch operator, handling I/O on a per-field basis).

Constructor & Destructor Documentation

◆ Field() [1/2]

amr_wind::Field::Field ( const Field & )
delete

◆ ~Field()

amr_wind::Field::~Field ( )
default

◆ Field() [2/2]

amr_wind::Field::Field ( FieldRepo & repo,
std::string name,
std::shared_ptr< FieldInfo > finfo,
unsigned fid,
FieldState state )
protected

Member Function Documentation

◆ advance_states()

void amr_wind::Field::advance_states ( )

Advance timestep for fields with multiple states.

◆ apply_bc_funcs()

void amr_wind::Field::apply_bc_funcs ( FieldState rho_state)

◆ base_name()

const std::string & amr_wind::Field::base_name ( ) const
inlinenodiscard

Base name (without state information)

◆ bc_initialized()

bool amr_wind::Field::bc_initialized ( ) const
inlinenodiscard

Return flag indicating whether BCs have been initialized.

◆ bc_type() [1/2]

amrex::GpuArray< BC, AMREX_SPACEDIM *2 > & amr_wind::Field::bc_type ( )
inline

◆ bc_type() [2/2]

const amrex::GpuArray< BC, AMREX_SPACEDIM *2 > & amr_wind::Field::bc_type ( ) const
inlinenodiscard

◆ bc_values()

amrex::Vector< amrex::Vector< amrex::Real > > & amr_wind::Field::bc_values ( )
inline

Return reference to the host view of BC values array.

◆ bc_values_device()

const amrex::GpuArray< const amrex::Real *, AMREX_SPACEDIM *2 > & amr_wind::Field::bc_values_device ( ) const
inlinenodiscard

◆ bcrec()

amrex::Vector< amrex::BCRec > & amr_wind::Field::bcrec ( ) const
inlinenodiscard

Return reference to host view of BCRec array.

◆ bcrec_device()

const amrex::Gpu::DeviceVector< amrex::BCRec > & amr_wind::Field::bcrec_device ( ) const
inlinenodiscard

◆ copy_bc_to_device()

void amr_wind::Field::copy_bc_to_device ( )
inline

Copy BC data from host to device.

The data must have been created on host using the host arrays

◆ copy_state()

void amr_wind::Field::copy_state ( FieldState to_state,
FieldState from_state )

Copy a user-specified "from_state" to "to_state".

◆ create_state()

Field & amr_wind::Field::create_state ( FieldState fstate)

Create a new time state after the field has been created.

◆ field_location()

FieldLoc amr_wind::Field::field_location ( ) const
inlinenodiscard

Cell, node, or face centered field.

◆ field_state()

FieldState amr_wind::Field::field_state ( ) const
inlinenodiscard

State of this field instance.

◆ fillpatch() [1/4]

void amr_wind::Field::fillpatch ( amrex::Real time)

◆ fillpatch() [2/4]

void amr_wind::Field::fillpatch ( amrex::Real time,
amrex::IntVect ng )

◆ fillpatch() [3/4]

void amr_wind::Field::fillpatch ( const int lev,
const amrex::Real time,
amrex::MultiFab & mfab,
const int nghost )
inline

◆ fillpatch() [4/4]

void amr_wind::Field::fillpatch ( int lev,
amrex::Real time,
amrex::MultiFab & mfab,
const amrex::IntVect & nghost )

◆ fillpatch_from_coarse() [1/2]

void amr_wind::Field::fillpatch_from_coarse ( const int lev,
const amrex::Real time,
amrex::MultiFab & mfab,
const int nghost )
inline

◆ fillpatch_from_coarse() [2/2]

void amr_wind::Field::fillpatch_from_coarse ( int lev,
amrex::Real time,
amrex::MultiFab & mfab,
const amrex::IntVect & nghost )

◆ fillpatch_on_regrid() [1/2]

bool & amr_wind::Field::fillpatch_on_regrid ( )
inline

◆ fillpatch_on_regrid() [2/2]

bool amr_wind::Field::fillpatch_on_regrid ( ) const
inlinenodiscard

◆ fillpatch_sibling_fields()

void amr_wind::Field::fillpatch_sibling_fields ( amrex::Real time,
amrex::IntVect ng,
amrex::Array< Field *, AMREX_SPACEDIM > & fields ) const

◆ fillphysbc() [1/4]

void amr_wind::Field::fillphysbc ( amrex::Real time)

◆ fillphysbc() [2/4]

void amr_wind::Field::fillphysbc ( amrex::Real time,
amrex::IntVect ng )

◆ fillphysbc() [3/4]

void amr_wind::Field::fillphysbc ( const int lev,
const amrex::Real time,
amrex::MultiFab & mfab,
const int nghost )
inline

◆ fillphysbc() [4/4]

void amr_wind::Field::fillphysbc ( int lev,
amrex::Real time,
amrex::MultiFab & mfab,
const amrex::IntVect & nghost )

◆ has_fillpatch_op()

bool amr_wind::Field::has_fillpatch_op ( ) const
inlinenodiscard

Return a flag indicating whether a fillpatch Op has been registered.

◆ has_inout_bndry()

bool amr_wind::Field::has_inout_bndry ( ) const
inlinenodiscard

Check if any of the boundaries is a mass-inflow-outflow.

◆ id()

unsigned amr_wind::Field::id ( ) const
inlinenodiscard

Unique integer identifier for this field.

◆ in_uniform_space() [1/2]

bool & amr_wind::Field::in_uniform_space ( )
inline

◆ in_uniform_space() [2/2]

bool amr_wind::Field::in_uniform_space ( ) const
inlinenodiscard

◆ name()

const std::string & amr_wind::Field::name ( ) const
inlinenodiscard

Name of this field (including state information)

◆ num_comp()

int amr_wind::Field::num_comp ( ) const
inlinenodiscard

Number of components for this field.

◆ num_grow()

const amrex::IntVect & amr_wind::Field::num_grow ( ) const
inlinenodiscard

Ghost cells.

◆ num_states()

int amr_wind::Field::num_states ( ) const
inlinenodiscard

Number of states available for this field.

◆ num_time_states()

int amr_wind::Field::num_time_states ( ) const
inlinenodiscard

Number of exact time states available for this field.

◆ operator()() [1/2]

amrex::MultiFab & amr_wind::Field::operator() ( int lev)

Return MultiFab instance for a given level.

◆ operator()() [2/2]

const amrex::MultiFab & amr_wind::Field::operator() ( int lev) const

◆ operator=()

Field & amr_wind::Field::operator= ( const Field & )
delete

◆ query_state()

bool amr_wind::Field::query_state ( const FieldState fstate) const
inlinenodiscard

Return true if the requested state exists for this field.

◆ register_custom_bc()

template<typename T, class... Args>
void amr_wind::Field::register_custom_bc ( Args &&... args)
inline

Register a custom boundary conditions class

◆ register_fill_patch_op()

template<typename T, class... Args>
void amr_wind::Field::register_fill_patch_op ( Args &&... args)
inline

Register a custom fillpatch class instance for this field

The class must be a subclass of amr_wind::FieldFillPatchOpsBase

◆ repo()

FieldRepo & amr_wind::Field::repo ( ) const
inlinenodiscard

FieldRepo instance that manages this field.

◆ set_default_fillpatch_bc()

void amr_wind::Field::set_default_fillpatch_bc ( const SimTime & time,
amrex::BCType::mathematicalBndryTypes bctype = amrex::BCType::hoextrap )

Setup default BC conditions for fillpatch operations

This method initializes the necessary BC data on the field so that a fillpatch call will interpolations on periodic faces and extrapolation on all the other boundaries. This method is useful for use with derived quantities where we still require some fill patch operations.

◆ set_inflow() [1/2]

void amr_wind::Field::set_inflow ( const int lev,
const amrex::Real time,
amrex::MultiFab & mfab,
const int nghost )
inline

◆ set_inflow() [2/2]

void amr_wind::Field::set_inflow ( int lev,
amrex::Real time,
amrex::MultiFab & mfab,
const amrex::IntVect & nghost )

◆ set_inflow_sibling_fields()

void amr_wind::Field::set_inflow_sibling_fields ( int lev,
amrex::Real time,
amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > mfabs )

◆ set_inout_bndry()

void amr_wind::Field::set_inout_bndry ( )
inline

Set the inout_bndry flag.

◆ setVal() [1/3]

void amr_wind::Field::setVal ( amrex::Real value)

Set the field to a constant value at all levels.

◆ setVal() [2/3]

void amr_wind::Field::setVal ( amrex::Real value,
int start_comp,
int num_comp = 1,
int nghost = 0 )

Set specific components of a multi-component field to a given value

Parameters
valueConstant value for initialization
start_compStarting component index (0-based)
num_compNumber of components from starting component to initialize
nghostNumber of ghost cells to include

◆ setVal() [3/3]

void amr_wind::Field::setVal ( const amrex::Vector< amrex::Real > & values,
int nghost = 0 )

Set components to those in the vector for a multi-component field

◆ state() [1/2]

Field & amr_wind::Field::state ( FieldState fstate)

Return field at a different time state.

◆ state() [2/2]

const Field & amr_wind::Field::state ( FieldState fstate) const
nodiscard

◆ subview()

ViewField< Field > amr_wind::Field::subview ( const int scomp = 0,
const int ncomp = 1 )
inline

Return a sub-view of the Field instance

◆ to_stretched_space()

void amr_wind::Field::to_stretched_space ( )

Map field to the stretched mesh

This method transforms the field to the stretched mesh based on the fields mesh_scaling_factor_cc or mesh_scaling_factor_nd depending on whether the field is cell-centered or node-centered, respectively.

◆ to_uniform_space()

void amr_wind::Field::to_uniform_space ( )

Map field to the uniform mesh

This method transforms the field to the uniform mesh based on the fields mesh_scaling_factor_cc or mesh_scaling_factor_nd depending on whether the field is cell-centered or node-centered, respectively.

◆ vec_const_ptrs()

amrex::Vector< const amrex::MultiFab * > amr_wind::Field::vec_const_ptrs ( ) const
nodiscard

Return vector of const MultiFab* for all levels.

◆ vec_ptrs()

amrex::Vector< amrex::MultiFab * > amr_wind::Field::vec_ptrs ( )

Return a vector of MultiFab pointers for all levels.

◆ FieldRepo

friend class FieldRepo
friend

Member Data Documentation

◆ m_fillpatch_on_regrid

bool amr_wind::Field::m_fillpatch_on_regrid {false}
protected

Flag indicating whether fill patch operation must be performed for this field during regrid.

◆ m_id

const unsigned amr_wind::Field::m_id
protected

Unique ID for this field.

◆ m_info

std::shared_ptr<FieldInfo> amr_wind::Field::m_info
protected

Common data for all field states.

◆ m_inout_bndry

bool amr_wind::Field::m_inout_bndry {false}
protected

Flag to indicate whether any of the boundaries is mass-inflow-outflow.

◆ m_mesh_mapped

bool amr_wind::Field::m_mesh_mapped {false}
protected

Flag to track mesh mapping (to uniform space) of field.

◆ m_name

const std::string amr_wind::Field::m_name
protected

Name of the field.

◆ m_repo

FieldRepo& amr_wind::Field::m_repo
protected

Reference to the FieldRepository instance.

◆ m_state

const FieldState amr_wind::Field::m_state
protected

State for this field.


The documentation for this class was generated from the following files:
  • /home/runner/work/amr-wind/amr-wind/amr-wind/core/Field.H
  • /home/runner/work/amr-wind/amr-wind/amr-wind/core/Field.cpp