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 ()
 
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, const amrex::BCType::mathematicalBndryTypes bctype=amrex::BCType::hoextrap) noexcept
 
void to_uniform_space () noexcept
 
void to_stretched_space () noexcept
 
Fieldstate (const FieldState fstate)
 Return field at a different time state.
 
const Fieldstate (const FieldState fstate) const
 
amrex::MultiFab & operator() (int lev) noexcept
 Return MultiFab instance for a given level.
 
const amrex::MultiFab & operator() (int lev) const noexcept
 
amrex::Vector< amrex::MultiFab * > vec_ptrs () noexcept
 Return a vector of MultiFab pointers for all levels.
 
amrex::Vector< const amrex::MultiFab * > vec_const_ptrs () const noexcept
 Return vector of const MultiFab* for all levels.
 
void advance_states () noexcept
 Advance timestep for fields with multiple states.
 
void copy_state (FieldState to_state, FieldState from_state) noexcept
 Copy a user-specified "from_state" to "to_state".
 
Fieldcreate_state (const FieldState fstate) noexcept
 Create a new time state after the field has been created.
 
void setVal (amrex::Real value) noexcept
 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) noexcept
 
void setVal (const amrex::Vector< amrex::Real > &values, int nghost=0) noexcept
 
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 (const amrex::Real time) noexcept
 
void fillpatch (const amrex::Real time, amrex::IntVect ng) noexcept
 
void fillpatch_sibling_fields (const amrex::Real time, const amrex::IntVect ng, amrex::Array< Field *, AMREX_SPACEDIM > &fields) const noexcept
 
void fillphysbc (const amrex::Real time) noexcept
 
void fillphysbc (const amrex::Real time, const amrex::IntVect ng) noexcept
 
void apply_bc_funcs (const FieldState rho_state) noexcept
 
void fillpatch (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost) noexcept
 
void fillpatch_from_coarse (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost) noexcept
 
void fillphysbc (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost) noexcept
 
void set_inflow (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const amrex::IntVect &nghost) noexcept
 
void set_inflow_sibling_fields (const int lev, const amrex::Real time, const amrex::Array< amrex::MultiFab *, AMREX_SPACEDIM > mfabs) noexcept
 
void fillpatch (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost) noexcept
 
void fillpatch_from_coarse (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost) noexcept
 
void fillphysbc (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost) noexcept
 
void set_inflow (const int lev, const amrex::Real time, amrex::MultiFab &mfab, const int nghost) noexcept
 
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, const 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}
 
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,
const unsigned fid,
FieldState state )
protected

Member Function Documentation

◆ advance_states()

void amr_wind::Field::advance_states ( )
noexcept

Advance timestep for fields with multiple states.

◆ apply_bc_funcs()

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

◆ base_name()

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

Base name (without state information)

◆ bc_initialized()

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

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
inline

◆ 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
inline

◆ bcrec()

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

Return reference to host view of BCRec array.

◆ bcrec_device()

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

◆ 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 )
noexcept

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

◆ create_state()

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

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

◆ field_location()

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

Cell, node, or face centered field.

◆ field_state()

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

State of this field instance.

◆ fillpatch() [1/4]

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

◆ fillpatch() [2/4]

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

◆ fillpatch() [3/4]

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

◆ fillpatch() [4/4]

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

◆ fillpatch_from_coarse() [1/2]

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

◆ fillpatch_from_coarse() [2/2]

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

◆ 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
inline

◆ fillpatch_sibling_fields()

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

◆ fillphysbc() [1/4]

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

◆ fillphysbc() [2/4]

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

◆ fillphysbc() [3/4]

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

◆ fillphysbc() [4/4]

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

◆ has_fillpatch_op()

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

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

◆ has_inout_bndry()

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

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

◆ id()

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

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
inline

◆ name()

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

Name of this field (including state information)

◆ num_comp()

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

Number of components for this field.

◆ num_grow()

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

Ghost cells.

◆ num_states()

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

Number of states available for this field.

◆ num_time_states()

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

Number of exact time states available for this field.

◆ operator()() [1/2]

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

◆ operator()() [2/2]

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

Return MultiFab instance for a given level.

◆ operator=()

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

◆ query_state()

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

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
inline

FieldRepo instance that manages this field.

◆ set_default_fillpatch_bc()

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

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 amrex::IntVect & nghost )
noexcept

◆ set_inflow() [2/2]

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

◆ set_inflow_sibling_fields()

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

◆ 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)
noexcept

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 )
noexcept

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 )
noexcept

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

◆ state() [1/2]

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

Return field at a different time state.

◆ state() [2/2]

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

◆ 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 ( )
noexcept

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 ( )
noexcept

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
noexcept

Return vector of const MultiFab* for all levels.

◆ vec_ptrs()

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

Return a vector of MultiFab pointers for all levels.

Friends And Related Symbol Documentation

◆ 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