FieldRepo Class Reference
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
|
#include <FieldRepo.H>
Public Member Functions | |
FieldRepo (const amrex::AmrCore &mesh) | |
FieldRepo (const FieldRepo &)=delete | |
FieldRepo & | operator= (const FieldRepo &)=delete |
~FieldRepo ()=default | |
void | make_new_level_from_scratch (int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) |
void | make_new_level_from_coarse (int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) |
void | remake_level (int lev, amrex::Real time, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm) |
void | clear_level (int lev) |
Remove a level during regrid. | |
Field & | declare_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1, const FieldLoc floc=FieldLoc::CELL) |
Field & | declare_cc_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1) |
Field & | declare_nd_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1) |
Field & | declare_xf_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1) |
Field & | declare_yf_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1) |
Field & | declare_zf_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1) |
amrex::Vector< Field * > | declare_face_normal_field (const amrex::Vector< std::string > &names, const int ncomp=1, const int ngrow=0, const int nstates=1) |
Field & | get_field (const std::string &name, const FieldState fstate=FieldState::New) const |
Field & | get_field (const int field_id) const |
Field & | get_mesh_mapping_field (FieldLoc floc) const |
Field & | get_mesh_mapping_det_j (FieldLoc floc) const |
bool | field_exists (const std::string &name, const FieldState fstate=FieldState::New) const |
IntField & | declare_int_field (const std::string &name, const int ncomp=1, const int ngrow=0, const int nstates=1, const FieldLoc floc=FieldLoc::CELL) |
IntField & | get_int_field (const std::string &name, const FieldState fstate=FieldState::New) const |
Return a reference to an integer field. | |
IntField & | get_int_field (const int field_id) const |
bool | int_field_exists (const std::string &name, const FieldState fstate=FieldState::New) const |
Query if an integer field exists. | |
std::unique_ptr< ScratchField > | create_scratch_field (const std::string &name, const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
std::unique_ptr< ScratchField > | create_scratch_field (const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
std::unique_ptr< ScratchField > | create_scratch_field_on_host (const std::string &name, const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
std::unique_ptr< ScratchField > | create_scratch_field_on_host (const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
std::unique_ptr< IntScratchField > | create_int_scratch_field_on_host (const std::string &name, const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
std::unique_ptr< IntScratchField > | create_int_scratch_field_on_host (const int ncomp=1, const int nghost=0, const FieldLoc floc=FieldLoc::CELL) const |
void | advance_states () noexcept |
Advance all fields with more than one timestate to the new timestep. | |
const amrex::AmrCore & | mesh () const |
Return a reference to the underlying AMR mesh instance. | |
int | num_active_levels () const noexcept |
Total number of levels currently active in the AMR mesh. | |
int | num_fields () const noexcept |
Number of fields registered in the database. | |
const amrex::Vector< std::unique_ptr< Field > > & | fields () const |
Return list of fields registered (for unit-test purposes only) | |
const amrex::FabFactory< amrex::FArrayBox > & | factory (int lev) const noexcept |
Return factory instance at a given level. | |
Protected Member Functions | |
amrex::MultiFab & | get_multifab (const unsigned fid, const int lev) noexcept |
amrex::iMultiFab & | get_int_fab (const unsigned fid, const int lev) noexcept |
Field & | create_state (Field &field, const FieldState fstate) |
Create a new state for a field. | |
void | allocate_field_data (int lev, const Field &field, LevelDataHolder &level_data, const amrex::FabFactory< amrex::FArrayBox > &factory) |
Allocate field data for a single level outside of regrid. | |
void | allocate_field_data (Field &field) |
Allocate field data at all levels. | |
void | allocate_field_data (const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, LevelDataHolder &level_data, const amrex::FabFactory< amrex::FArrayBox > &factory) |
Allocate data at a level during regrid. | |
void | allocate_field_data (int lev, const IntField &field, LevelDataHolder &level_data) |
void | allocate_field_data (const IntField &field) |
void | allocate_field_data (const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, LevelDataHolder &level_data, const amrex::FabFactory< amrex::IArrayBox > &factory) |
Protected Attributes | |
const amrex::AmrCore & | m_mesh |
Reference to the mesh instance. | |
amrex::Vector< std::unique_ptr< LevelDataHolder > > | m_leveldata |
amrex::Vector< std::unique_ptr< Field > > | m_field_vec |
References to field instances identified by unique integer. | |
amrex::Vector< std::unique_ptr< IntField > > | m_int_field_vec |
Reference to integer field instances identified by unique integer. | |
std::unordered_map< std::string, size_t > | m_fid_map |
Map of field name to unique integer ID for lookups. | |
std::unordered_map< std::string, size_t > | m_int_fid_map |
Map of integer field name to unique integer ID for lookups. | |
bool | m_is_initialized {false} |
Flag indicating if mesh is available to allocate field data. | |
Friends | |
class | Field |
class | IntField |
Detailed Description
Field Repository
FieldRepo is a database that manages handling of fields used during a simulation. It provides an interface to automatically handle the creation/destruction of lower-level data structures (amrex::MultiFab) during regrids and handles the interface between the actual data and the amr_wind::Field interface which doesn't hold any actual data.
FieldRepo allows the user to declare instances of fields and their types (e.g., cell or node cenrered), and allows querying and accessing these fields at different places in the code and ensures the same data is accessed everywhere.
Fields can be declared at any time, even before the actual mesh instance is created, and it is recommended that they be created before mesh is initialized so that initialization happens automatically. When fields are declared before a mesh is available, data allocation is deferred until the mesh is generated (MakeNewLevelFromScratch
). However, if a mesh is available, data is allocated and ready for use immediately upon declaration.
Field declarations use a unique string name to differentiate different fields. If amr_wind::FieldRepo::declare_field is called multiple times with the same field name, the previously created instance is returned on subsequent calls. However, an error is raised if the subsequent calls do not have the same field parameters (e.g., number of components, states, or ghost cells).
Fields can be accessed using amr_wind::FieldRepo::get_field method. Unlike the declaration method, this method will raise an error if no field exists. amr_wind::FieldRepo::field_exists can be used to determine if a field exists in the repository.
FieldRepo also manages integer fields (IntField) as well as creation of ScratchField instances.
Constructor & Destructor Documentation
◆ FieldRepo() [1/2]
|
inlineexplicit |
◆ FieldRepo() [2/2]
|
delete |
◆ ~FieldRepo()
|
default |
Member Function Documentation
◆ advance_states()
|
noexcept |
Advance all fields with more than one timestate to the new timestep.
◆ allocate_field_data() [1/6]
|
protected |
Allocate data at a level during regrid.
◆ allocate_field_data() [2/6]
|
protected |
◆ allocate_field_data() [3/6]
|
protected |
◆ allocate_field_data() [4/6]
|
protected |
Allocate field data at all levels.
◆ allocate_field_data() [5/6]
|
protected |
Allocate field data for a single level outside of regrid.
◆ allocate_field_data() [6/6]
|
protected |
◆ clear_level()
void amr_wind::FieldRepo::clear_level | ( | int | lev | ) |
Remove a level during regrid.
◆ create_int_scratch_field_on_host() [1/2]
std::unique_ptr< IntScratchField > amr_wind::FieldRepo::create_int_scratch_field_on_host | ( | const int | ncomp = 1, |
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
◆ create_int_scratch_field_on_host() [2/2]
std::unique_ptr< IntScratchField > amr_wind::FieldRepo::create_int_scratch_field_on_host | ( | const std::string & | name, |
const int | ncomp = 1, | ||
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
◆ create_scratch_field() [1/2]
std::unique_ptr< ScratchField > amr_wind::FieldRepo::create_scratch_field | ( | const int | ncomp = 1, |
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
Create a scratch field
ScratchField is a temporary field used to compute and store intermediate quantities that are needed within a timestep. Scratch fields provide an API similar to Field, but do not contain multiple states. The underlying MultiFab data is not managed by FieldRepo and, therefore, ScratchField do not survive a regrid. This method returns a unique_ptr instance that is only valid within a timestep. It is not safe to hold a reference to the ScratchField object across timesteps.
◆ create_scratch_field() [2/2]
std::unique_ptr< ScratchField > amr_wind::FieldRepo::create_scratch_field | ( | const std::string & | name, |
const int | ncomp = 1, | ||
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
Create a scratch field
ScratchField is a temporary field used to compute and store intermediate quantities that are needed within a timestep. Scratch fields provide an API similar to Field, but do not contain multiple states. The underlying MultiFab data is not managed by FieldRepo and, therefore, ScratchField do not survive a regrid. This method returns a unique_ptr instance that is only valid within a timestep. It is not safe to hold a reference to the ScratchField object across timesteps.
◆ create_scratch_field_on_host() [1/2]
std::unique_ptr< ScratchField > amr_wind::FieldRepo::create_scratch_field_on_host | ( | const int | ncomp = 1, |
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
◆ create_scratch_field_on_host() [2/2]
std::unique_ptr< ScratchField > amr_wind::FieldRepo::create_scratch_field_on_host | ( | const std::string & | name, |
const int | ncomp = 1, | ||
const int | nghost = 0, | ||
const FieldLoc | floc = FieldLoc::CELL ) const |
◆ create_state()
|
protected |
Create a new state for a field.
◆ declare_cc_field()
|
inline |
Declare a cell-centered field
This is a convenience wrapper around declare_field
◆ declare_face_normal_field()
|
inline |
Declare a vector field with components in the x,y,z faces
This is a convenience function around declare_field
◆ declare_field()
Field & amr_wind::FieldRepo::declare_field | ( | const std::string & | name, |
const int | ncomp = 1, | ||
const int | ngrow = 0, | ||
const int | nstates = 1, | ||
const FieldLoc | floc = FieldLoc::CELL ) |
Create a new field instance
- Parameters
-
name Unique identifier for this field ncomp Number of components in this field (default: 1) ngrow Number of ghost cells/nodes for this field (default: 1) nstates Number of time states for this field (default: 1) floc Field location (default: cell-centered)
◆ declare_int_field()
IntField & amr_wind::FieldRepo::declare_int_field | ( | const std::string & | name, |
const int | ncomp = 1, | ||
const int | ngrow = 0, | ||
const int | nstates = 1, | ||
const FieldLoc | floc = FieldLoc::CELL ) |
Declare an integer field
Integer fields are used for masks and iblanking with overset meshes
- Parameters
-
name [in] Unique identifier for the field ncomp Number of components in this field (default: 1) ngrow Number of ghost cells/nodes for this field (default: 1) nstates Number of time states for this field (default: 1) floc Field location (default: cell-centered)
◆ declare_nd_field()
|
inline |
Declare a node-centered field
This is a convenience wrapper around declare_field
◆ declare_xf_field()
|
inline |
Declare a face field on the faces with normal in x-direction
This is a convenience wrapper around declare_field
◆ declare_yf_field()
|
inline |
Declare a face field on the faces with normal in y-direction
This is a convenience wrapper around declare_field
◆ declare_zf_field()
|
inline |
Declare a face field on the faces with normal in z-direction
This is a convenience wrapper around declare_field
◆ factory()
|
inlinenoexcept |
Return factory instance at a given level.
◆ field_exists()
bool amr_wind::FieldRepo::field_exists | ( | const std::string & | name, |
const FieldState | fstate = FieldState::New ) const |
Query if field uniquely identified by name and time state exists in repository
◆ fields()
|
inline |
Return list of fields registered (for unit-test purposes only)
◆ get_field() [1/2]
|
inline |
Return a previously created field using a unique identifier
◆ get_field() [2/2]
Field & amr_wind::FieldRepo::get_field | ( | const std::string & | name, |
const FieldState | fstate = FieldState::New ) const |
Return a previously created field identified by name and time state
◆ get_int_fab()
|
inlineprotectednoexcept |
Return the integer fab instance for a field at a given level
- Parameters
-
fid Unique integer field identifier for this field lev AMR level
◆ get_int_field() [1/2]
|
inline |
Return a reference to a previously created integer field using unique identifier
◆ get_int_field() [2/2]
IntField & amr_wind::FieldRepo::get_int_field | ( | const std::string & | name, |
const FieldState | fstate = FieldState::New ) const |
Return a reference to an integer field.
◆ get_mesh_mapping_det_j()
Return a previously created mesh mapping detJ using field location
◆ get_mesh_mapping_field()
Return a previously created mesh mapping field using field location
◆ get_multifab()
|
inlineprotectednoexcept |
Return the amrex::MultiFab instance for a field at a given level
- Parameters
-
fid Unique integer field identifier for this field lev AMR level
◆ int_field_exists()
bool amr_wind::FieldRepo::int_field_exists | ( | const std::string & | name, |
const FieldState | fstate = FieldState::New ) const |
Query if an integer field exists.
◆ make_new_level_from_coarse()
void amr_wind::FieldRepo::make_new_level_from_coarse | ( | int | lev, |
amrex::Real | time, | ||
const amrex::BoxArray & | ba, | ||
const amrex::DistributionMapping & | dm ) |
Allocate and initialize data on a finer level from the next coarser level
This is called by the AmrCore automatically during regrid process
◆ make_new_level_from_scratch()
void amr_wind::FieldRepo::make_new_level_from_scratch | ( | int | lev, |
amrex::Real | time, | ||
const amrex::BoxArray & | ba, | ||
const amrex::DistributionMapping & | dm ) |
Perform field data management tasks when amrex::AmrCore::MakeNewLevelFromScratch is called
◆ mesh()
|
inline |
Return a reference to the underlying AMR mesh instance.
◆ num_active_levels()
|
inlinenoexcept |
Total number of levels currently active in the AMR mesh.
◆ num_fields()
|
inlinenoexcept |
Number of fields registered in the database.
◆ operator=()
◆ remake_level()
void amr_wind::FieldRepo::remake_level | ( | int | lev, |
amrex::Real | time, | ||
const amrex::BoxArray & | ba, | ||
const amrex::DistributionMapping & | dm ) |
Allocate and initialize data on an existing level during regrid
This is called by the AmrCore automatically during regrid process
Friends And Related Symbol Documentation
◆ Field
|
friend |
◆ IntField
|
friend |
Member Data Documentation
◆ m_fid_map
|
protected |
Map of field name to unique integer ID for lookups.
◆ m_field_vec
|
mutableprotected |
References to field instances identified by unique integer.
◆ m_int_fid_map
|
protected |
Map of integer field name to unique integer ID for lookups.
◆ m_int_field_vec
|
mutableprotected |
Reference to integer field instances identified by unique integer.
◆ m_is_initialized
|
protected |
Flag indicating if mesh is available to allocate field data.
◆ m_leveldata
|
protected |
Array (size: nlevels) of data holder that contains another array of MultiFabs for all fields at that level.
◆ m_mesh
|
protected |
Reference to the mesh instance.
The documentation for this class was generated from the following files:
- /home/runner/work/amr-wind/amr-wind/amr-wind/core/FieldRepo.H
- /home/runner/work/amr-wind/amr-wind/amr-wind/core/FieldRepo.cpp
Generated by 1.12.0