Core Utilities¶
CFDMesh¶
-
class
CFDMesh
¶ STK Mesh interface.
This class provides a thin wrapper around the STK mesh objects (MetaData, BulkData, and StkMeshIoBroker) for use with various preprocessing utilities.
Public Functions
-
CFDMesh
(stk::ParallelMachine &comm, const std::string filename)¶ Create a CFD mesh instance from an existing mesh database.
- Parameters
comm
: MPI Communicator objectfilename
: Exodus database filename
-
CFDMesh
(stk::ParallelMachine &comm, const int ndim)¶ Create a CFD mesh instance from scratch.
- Parameters
comm
: MPI Communicator objectndim
: Dimensionality of mesh
-
~CFDMesh
()¶
-
void
init
(stk::io::DatabasePurpose db_purpose = stk::io::READ_MESH)¶ Initialize the mesh database.
If an input DB is provided, the mesh is read from the file. The MetaData is committed and the BulkData is ready for use/manipulation.
-
stk::ParallelMachine &
comm
()¶ Reference to the MPI communicator object.
-
stk::mesh::MetaData &
meta
()¶ Reference to the stk::mesh::MetaData instance.
-
stk::mesh::BulkData &
bulk
()¶ Reference to the stk::mesh::BulkData instance.
-
stk::io::StkMeshIoBroker &
stkio
()¶ Reference to the STK mesh I/O instance.
-
void
add_output_field
(const std::string field)¶ Register a field for output during write.
- Parameters
field
: Name of the field to be output
-
size_t
open_database
(std::string output_db)¶ Open a database for writing time series data.
- Return
A valid file handle for use with write_database
- See
- Parameters
output_db
: Pathname to the output ExodusII database
-
void
write_database
(size_t fh, double time)¶ Write time series data to an open database.
- See
- Parameters
fh
: Valid file handletime
: Time to write
-
void
write_database
(std::string output_db, double time = 0.0)¶ Write the Exodus results database with modifications.
- See
- Parameters
output_db
: Pathname to the output ExodusII databasetime
: Timestep to write
- Parameters
output_db
: Filename for the output Exodus databasetime
: (Optional) time to write (default = 0.0)
-
void
write_database_with_fields
(std::string output_db)¶ Write database with restart fields.
Copies the restart data fields from the input Exodus database to the output database.
- Parameters
output_db
: Pathname to the output ExodusII database
-
template<typename
Functor
>
voidwrite_timesteps
(std::string output_db, int num_steps, Functor lambdaFunc)¶ Write time-history to database.
This method accepts a functor that takes one integer argument (timestep) and returns the time (double) that must be written to the database. The functor should update the fields that are being written to the database. An example would be to simulate mesh motion by updating the mesh_displacement field at every timestep.
The following example shows the use with a C++ lambda function:
double deltaT = 0.01; // Timestep size write_timesteps("inflow_history.exo", 100, [&](int tstep) { double time = tstep * deltaT; // Update velocity and coordinates return time; });
-
BoxType
calc_bounding_box
(const stk::mesh::Selector selector, bool verbose = true)¶ Calculate the bounding box of the mesh.
The selector can pick parts that are not contiguous. However, the bounding box returned will be the biggest box that encloses all parts selected.
- Return
An stk::search::Box instance containing the min and max points (3-D).
- Parameters
selector
: An instance of stk::mesh::Selector to filter parts of the mesh where bounding box is calculated.verbose
: If true, then print out the bounding box to standard output.
-
void
set_decomposition_type
(std::string decompType)¶ Set automatic mesh decomposition property.
Valid decomposition types are: rcb, rib, block, linear
- Parameters
decompType
: The decomposition type
-
void
set_64bit_flags
()¶ Force output database to use 8-bit integers.
-
bool
db_modified
()¶ Flag indicating whether the DB has been modified.
-
void
set_write_flag
(bool flag = true)¶ Force output of the results DB.
-
const std::unordered_set<std::string> &
output_fields
()¶ Return a reference to the registered output fields.
-
Interpolation utilities¶
-
struct
OutOfBounds
¶ Flags and actions for out-of-bounds operation.
-
template<typename
T
>
InterpTraits<T>::index_typesierra::nalu::utils
::
check_bounds
(const Array1D<T> &xinp, const T &x)¶ Determine whether the given value is within the limits of the interpolation table.
- Return
A std::pair containing the OutOfBounds flag and the index (0 or MAX)
- Parameters
xinp
: 1-D array of monotonically increasing valuesx
: The value to check for
-
template<typename
T
>
InterpTraits<T>::index_typesierra::nalu::utils
::
find_index
(const Array1D<T> &xinp, const T &x)¶ Return an index object corresponding to the x-value based on interpolation table.
- Return
The
std::pair
returned contains two values: the bounds indicator and the index of the element in the interpolation table such thatxarray[i] <= x < xarray[i+1]
- Parameters
xinp
: 1-D array of monotonically increasing valuesx
: The value to check for
-
template<typename
T
>
voidsierra::nalu::utils
::
linear_interp
(const Array1D<T> &xinp, const Array1D<T> &yinp, const T &xout, T &yout, OutOfBounds::OobAction oob = OutOfBounds::CLAMP)¶ Perform a 1-D linear interpolation.
- Parameters
xinp
: A 1-d vector of monotonically increasing x-valuesyinp
: Corresponding 1-d vector of y-valuesxout
: Target x-value for interpolationyout
: Interpolated value atxout
oob
: (Optional) Out-of-bounds handling (default: CLAMP)
YAML utilities¶
Miscellaneous utilities for working with YAML C++ library.
-
namespace
sierra
¶ -
namespace
nalu
¶ -
namespace
wind_utils
¶ Functions
-
template<typename
T
>
boolget_optional
(const YAML::Node &node, const std::string &key, T &result)¶ Fetch an optional entry from the YAML dictionary if it exists.
The result parameter is unchanged if the entry is not found in the YAML dictionary.
- Parameters
node
: The YAML::Node instance to be examinedkey
: The name of the variable to be extractedresult
: The variable that is updated with the value if it exists
-
template<typename
T
>
boolget_optional
(const YAML::Node &node, const std::string &key, T &result, const T &default_value)¶ Fetch an optional entry from the YAML dictionary if it exists.
The result parameter is updated with the value from the dictionary if it exists, otherwise it is initialized with the default value provided.
- Parameters
node
: The YAML::Node instance to be examinedkey
: The name of the variable to be extractedresult
: The variable that is updated with the value if it existsdefault_value
: The default value to be used if the parameter is not found in the dictionary.
-
template<typename
-
namespace
-
namespace
Performance Monitoring Utilities¶
-
namespace
sierra
-
namespace
nalu
Functions
-
Teuchos::RCP<Teuchos::Time>
get_timer
(const std::string &name)¶ Return a timer identified by name.
If an existing timer is found, then the timer is returned. Otherwise a new timer is created. The user will have to manually start/stop the timer. For most use cases, it might be preferable to use
get_stopwatch
function instead.
-
Teuchos::TimeMonitor
get_stopwatch
(const std::string &name)¶ Return a stopwatch identified by name.
The clock starts automatically upon invocation and will be stopped once the
Teuchos::Timemonitor
instance returned by this function goes out of scope.
-
Teuchos::RCP<Teuchos::Time>
-
namespace