Definition at line 16 of file hips.h.
|
void | set_tree (int nLevels_, double domainLength_, double tau0_, std::vector< double > &ScHips_) |
| Sets up the HiPS tree using explicitly specified tree parameters.
|
|
void | set_tree (double Re_, double domainLength_, double tau0_, std::vector< double > &ScHips_, std::string approach_="rounding") |
| Dynamically builds the HiPS tree based on Reynolds number and a selected strategy.
|
|
void | set_varData (std::vector< double > &v, std::vector< double > &w, const std::string &varN) |
| Assigns variables, their corresponding weights, and names to the parcels in the HiPS tree.
|
|
void | set_varData (std::vector< double > &v, std::vector< double > &w, const std::string &varN, const std::vector< double > &rho) |
| Assigns variables, weights, names, and densities to the parcels in the HiPS tree.
|
|
std::vector< std::vector< double > > | get_varData () |
| Retrieves the final data from the simulation.
|
|
std::vector< std::pair< std::vector< double >, std::vector< double > > > | get_varData_with_density () |
| Retrieves final simulation data, including both values and densities.
|
|
void | setOutputIntervalTime (double interval) |
| Sets the interval (in simulation time) for writing simulation data.
|
|
void | setOutputIntervalEddy (int interval) |
| Sets the interval (in number of eddy events) for writing simulation data.
|
|
void | calculateSolution (const double tRun, bool shouldWriteData=false) |
| Runs the HiPS simulation, advancing the solution using eddy events.
|
|
| hips (double C_param_, int forceTurb_, int nVar_, bool performReaction, std::shared_ptr< void > vcantSol=nullptr, int seed=10, int realization_=1) |
| Constructor for initializing a HiPS object without building the tree immediately.
|
|
| hips (int nLevels_, double domainLength_, double tau0_, double C_param_, int forceTurb_, int nVar_, std::vector< double > &ScHips_, bool performReaction, std::shared_ptr< void > vcantSol=nullptr, int seed=10, int realization_=1) |
| Constructor for initializing the full HiPS tree at the time of object creation.
|
|
void | resetForNewRealization () |
|
|
std::vector< double > | projection (std::vector< double > &vcfd, std::vector< double > &weight) |
| Projects values from flow particles onto HiPS parcels assuming constant density.
|
|
std::pair< std::vector< double >, std::vector< double > > | projection (std::vector< double > &vcfd, std::vector< double > &weight, const std::vector< double > &density) |
| Projects the values from flow particles onto HiPS parcels, accounting for particle density.
|
|
std::vector< double > | setGridHips (int N) |
| Generates a physical domain for HiPS parcels.
|
|
std::vector< double > | setGridCfd (std::vector< double > &w) |
| Generates a physical domain for flow particles based on their weights.
|
|
std::vector< double > | projection_back (std::vector< double > &vb) |
| Projects HiPS parcel values back onto the flow particles.
|
|
std::pair< std::vector< double >, std::vector< double > > | projection_back_with_density (std::vector< double > &vh, std::vector< double > &rho_h) |
| Projects HiPS parcel values and densities back onto the flow particles.
|
|
void | sample_hips_eddy (double &dt, int &iLevel) |
| Samples stochastic eddy events on the HiPS tree, determining the time increment and tree level.
|
|
void | selectAndSwapTwoSubtrees (const int iLevel, int &iTree) |
| Performs eddy events by swapping parcels within the HiPS tree.
|
|
void | advanceHips (const int iLevel, const int iTree) |
| Advances the HiPS model by simulating micromixing and reactions at a specific tree level.
|
|
int | getVariableIndex (const std::string &varName) const |
| Retrieves the index of a variable by its name in the varName list.
|
|
void | reactParcels_LevelTree (const int iLevel, const int iTree) |
| Simulates chemical reactions for parcels affected by a micromixing event.
|
|
void | mixAcrossLevelTree (int kVar, const int iMixLevel, const int iTree) |
| Uniformly mixes parcels at a specified level and subtree within the HiPS model.
|
|
void | forceProfile () |
| Adjusts the HiPS profile to enforce statistical stationarity.
|
|
void | writeData (int real, const int ifile, const double outputTime) |
| Writes simulation data to a file for a specific realization, time, and file index.
|
|
void | saveAllParameters () |
| Saves all user-defined to a file.
|
|
|
int | currentIndex = 0 |
| member variable to keep track of current index of variables
|
|
int | nLevels |
| number of tree levels
|
|
int | nLevels_ |
| number of tree levels?
|
|
int | forceTurb |
| forcing function for statistically stationary: -1 = none, 1 = source term, 2 = dir
|
|
int | nVar |
| number of parcel variables (e.g., h, ysp)
|
|
int | nsp |
| number of species
|
|
int | Nm1 |
| nLevels - 1
|
|
int | Nm2 |
| nLevels - 2
|
|
int | Nm3 |
| nLevels - 3
|
|
int | iEta |
| Kolmogorov level (needed for variable Sc scalars)
|
|
int | nL |
| adjusted number of levels based on the Reynolds number
|
|
bool | LScHips |
| hips schmidt number
|
|
bool | performReaction |
| flag indicating whether chemical reactions are performed in the simulation
|
|
bool | LrandSet |
| flag indicating new randomGen --> allow deletion
|
|
double | time |
| current simulation time
|
|
double | eddyRate_total |
| total rate of all eddies 0 through nLevels-3
|
|
double | eddyRate_inertial |
| total rate of all eddies 0 through iEta (= eddyRate_total if Sc=1)
|
|
double | Afac = 0.5 |
| level lengthscale reduction factor (0.5)
|
|
double | Re |
| Reynolds number.
|
|
double | dtEE |
| time increment to next eddy event
|
|
double | Prob |
| probability value for probability-based solution
|
|
double | lStar |
| length of the level associated with the Reynolds number
|
|
double | Anew |
| adjusted level lengthscale reduction factor for dynamic adjustment of reduction factor
|
|
randomGenerator | rand |
|
std::vector< int > | i_plus |
| ceil(i_batchelor)
|
|
std::vector< int > | pLoc |
| parcel index array for fast implementation of swaps
|
|
std::vector< double > | varRho |
|
std::vector< double > | ScHips |
| vector containing Schmidt numbers related to each variable
|
|
std::vector< std::string > | varName |
| vector containing the names of parcel variables
|
|
std::vector< double > | parcelTimes |
| current times corresponding to the parcel states
|
|
std::vector< double > | levelRates |
| list of eddy event rates at each level
|
|
std::vector< double > | i_batchelor |
| Batchelor level for variable Sc scalars; NOTE: double, as in, between levels.
|
|
std::vector< double > | xc |
| vector containing physical domain of flow particles
|
|
std::vector< double > | xh |
| vector containing physical domain of HiPS parcels
|
|
std::string | approach |
|
int | outputIntervalEddy = 10 |
| Default: write data every 10 eddy events.
|
|
double | outputIntervalTime = 0.1 |
| Default: write data every 0.1s.
|
|
int | eddyCounter = 0 |
| Counter for eddy events.
|
|
double | lastOutputTime = 0.0 |
| Last time data was written.
|
|
bool | useEddyBasedWriting = false |
| Tracks if eddy writing is set.
|
|
bool | useTimeBasedWriting = false |
| Tracks if time writing is set.
|
|
const int | DEFAULT_EDDY_INTERVAL = 1000 |
| Default: Write every 1000 eddies.
|
|
const double | DEFAULT_TIME_INTERVAL = 0.1 |
| Default: Write every 0.1s.
|
|
void hips::set_tree |
( |
double | Re_, |
|
|
double | domainLength_, |
|
|
double | tau0_, |
|
|
std::vector< double > & | ScHips_, |
|
|
std::string | approach_ = "rounding" ) |
Dynamically builds the HiPS tree based on Reynolds number and a selected strategy.
This method configures the HiPS tree using a continuous Reynolds number and one of several initialization strategies. It is intended for simulations where local turbulence conditions change over time or space, requiring the tree to be updated dynamically.
- Parameters
-
Re_ | Reynolds number used to determine base tree level. |
domainLength_ | Domain length for spatial scaling. |
tau0_ | Base time scale for the largest eddy. |
ScHips_ | Vector of Schmidt numbers (one per variable). |
approach_ | Strategy to convert continuous Re to tree level:
- "rounding" → Round to nearest discrete level
- "probability" → Use probabilistic interpolation between levels
- "micromixing" → Use fixed level with adjusted mixing rate
- "dynamic_A" → Adjust geometric scale factor A to fit Re
|
- Note
- This method is ideal for Lagrangian simulations using grid cells with different Re values. It supports runtime reconfiguration of the tree without reinitializing the hips object.
- Warning
- Ensure consistent
approach_
handling across the simulation to avoid inconsistencies.
- See also
- hips::set_tree(int, ...) for direct-level setup.
Definition at line 209 of file hips.cc.
void hips::set_varData |
( |
std::vector< double > & | v, |
|
|
std::vector< double > & | w, |
|
|
const std::string & | varN ) |
Assigns variables, their corresponding weights, and names to the parcels in the HiPS tree.
This function projects the provided variables onto the parcels within the HiPS tree structure, using their corresponding weights. It ensures that each parcel in the tree is associated with the correct variable and weight, along with a descriptive name for better identification.
- Parameters
-
v | Vector of variables to be assigned to the parcels in the HiPS tree. |
w | Vector of weights corresponding to each variable or parcel. |
varN | String representing the name of the variable being assigned. |
- Note
- The size of
v
and w
must match to ensure a one-to-one correspondence between variables and their weights. The function does not perform size validation internally.
- Warning
- Ensure that the weights in
w
are normalized or appropriately scaled, as they directly influence the projection and subsequent simulations.
Definition at line 337 of file hips.cc.
void hips::set_varData |
( |
std::vector< double > & | v, |
|
|
std::vector< double > & | w, |
|
|
const std::string & | varN, |
|
|
const std::vector< double > & | rho ) |
Assigns variables, weights, names, and densities to the parcels in the HiPS tree.
This overloaded function assigns the specified variables, along with their associated weights, names, and densities, to the parcels within the HiPS tree structure. The function incorporates particle density during the projection process, ensuring a more accurate representation of parcel properties in the simulation.
- Parameters
-
v | Vector of variables to be assigned to the HiPS tree. |
w | Vector of weights corresponding to each variable or parcel. |
varN | String representing the name of the variable being assigned. |
rho | Vector of densities corresponding to each flow particle. |
- Note
- This function is specifically overloaded to account for particle density, which enhances the accuracy of the parcel projection. Ensure that the size of
v
, w
, and rho
are consistent.
- Warning
- The values in
rho
should be physically meaningful and consistent with the simulation's requirements. Improper density values may lead to inaccuracies or instabilities in the simulation.
Definition at line 365 of file hips.cc.
std::vector< std::vector< double > > hips::get_varData |
( |
| ) |
|
Retrieves the final data from the simulation.
This function returns the final state of the simulation, packaged as a vector of vectors. It is particularly useful when integrating HiPS as a subgrid model in CFD simulations, enabling seamless transfer of data for further analysis or post-processing.
- Returns
- A vector of vectors containing the final results, where:
- Each inner vector represents a specific variable or property.
- The outer vector contains all variables across parcels.
- Note
- This function is specifically designed for use when HiPS is employed as a subgrid model in CFD simulations.
- The structure of the returned data ensures compatibility with CFD solvers that require parcel-level data.
- Warning
- Ensure the simulation has reached completion before calling this function to avoid incomplete or inconsistent data.
- The returned data structure should be interpreted according to the simulation setup and variable ordering.
Definition at line 1311 of file hips.cc.
std::vector< std::pair< std::vector< double >, std::vector< double > > > hips::get_varData_with_density |
( |
| ) |
|
Retrieves final simulation data, including both values and densities.
This function processes the HiPS data and projects both the values and densities back onto the flow particles. It returns a vector of pairs, where each pair contains the values and corresponding densities for a specific variable. This function is designed to support HiPS as a subgrid model in CFD simulations, ensuring compatibility with solvers that require both values and density information.
- Returns
- A vector of pairs:
- Each pair consists of two vectors:
- The first vector contains the final results for the values.
- The second vector contains the corresponding density results.
- Note
- This function is tailored for integrating HiPS as a subgrid model in CFD simulations, providing both value and density data for accurate modeling.
- Ensure that all HiPS parcels are properly initialized and contain valid values and densities before invoking this function.
Definition at line 1341 of file hips.cc.
void hips::setOutputIntervalTime |
( |
double | interval | ) |
|
Sets the interval (in simulation time) for writing simulation data.
Calling this function enables time-based writing and disables eddy-based writing. If the user does not call this function or setOutputIntervalEddy()
, the default behavior is eddy-based writing every 1000 eddies.
- Parameters
-
interval | The time interval (in seconds) between data writes (e.g., 0.1 writes data every 0.1s). |
- Note
- Calling this function automatically disables eddy-based writing (
setOutputIntervalEddy()
). To revert to default settings, the user must explicitly set a new interval or avoid calling this function.
< Enables time-based writing
< Disables eddy-based writing
Definition at line 1390 of file hips.cc.
void hips::setOutputIntervalEddy |
( |
int | interval | ) |
|
Sets the interval (in number of eddy events) for writing simulation data.
Calling this function enables eddy-based writing and disables time-based writing. If the user does not call this function or setOutputIntervalTime()
, the default interval is set to 1000 eddy events.
- Parameters
-
interval | The number of eddy events between data writes (e.g., 1000 writes data every 1000 eddies). |
- Note
- Calling this function automatically disables time-based writing (
setOutputIntervalTime()
). To revert to default settings, the user must explicitly set a new interval or avoid calling this function.
< Enables eddy-based writing
< Disables time-based writing
Definition at line 1370 of file hips.cc.
void hips::calculateSolution |
( |
const double | tRun, |
|
|
bool | shouldWriteData = false ) |
Runs the HiPS simulation, advancing the solution using eddy events.
This function performs the core HiPS loop: sampling eddy events, performing subtree swaps, advancing parcels, and optionally triggering reactions. It runs until the specified simulation time (tRun
) is reached and writes data periodically based on either eddy count or elapsed simulation time.
Key operations:
- Samples the next eddy event time (
dtEE
)
- Selects and swaps subtrees at a given level
- Applies micromixing and reactions (if enabled)
- Writes output data either:
- Every
outputIntervalEddy
eddy events (if enabled), or
- Every
outputIntervalTime
seconds (if enabled)
- At the end of the simulation, calls
saveAllParameters()
to store input and configuration data in ../post/parameters.dat
.
- Parameters
-
tRun | Total simulation run time (in seconds). |
shouldWriteData | Flag to enable/disable periodic data writing. |
- Note
- To control output frequency, use:
-
Output files are saved using
writeData(realization, ...)
and include the realization index.
-
At the end of the run,
saveAllParameters()
is automatically called to document simulation settings.
- Warning
- Long simulations may generate many output files. Adjust output intervals or disable writing (
shouldWriteData = false
) to manage storage needs.
- See also
- hips::writeData(), hips::saveAllParameters()
Definition at line 608 of file hips.cc.
std::vector< double > hips::projection |
( |
std::vector< double > & | vcfd, |
|
|
std::vector< double > & | weight ) |
|
private |
Projects values from flow particles onto HiPS parcels assuming constant density.
This function maps the values of flow particles onto HiPS parcels under the assumption of constant density. The projection is performed using the following equation:
\[
\sum_{i=0}^{\text{Number of Flow Particles (FP)}} (\phi_{\text{FP}} \, \mathrm{d}x_{\text{FP}})_{i} =
\sum_{j=0}^{\text{Number of HiPS Parcels (HP)}} (\phi_{\text{HP}} \, \mathrm{d}x_{\text{HP}})_{j}
\]
This ensures conservation of properties such as mass or concentration during the projection.
- Parameters
-
vcfd | Vector of variables from flow particles to be mapped to HiPS parcels. |
weight | Vector of weights, with one weight assigned to each flow particle. |
- Returns
- Vector of projected values for HiPS parcels.
- Note
- The function assumes constant density throughout the domain. For cases with varying density, use an appropriate overloaded function or method.
- Warning
- Ensure that the
vcfd
and weight
vectors have matching sizes, as any discrepancy may result in undefined behavior or incorrect projections.
Definition at line 400 of file hips.cc.
std::pair< std::vector< double >, std::vector< double > > hips::projection |
( |
std::vector< double > & | vcfd, |
|
|
std::vector< double > & | weight, |
|
|
const std::vector< double > & | density ) |
|
private |
Projects the values from flow particles onto HiPS parcels, accounting for particle density.
This function calculates the projection of values from flow particles onto HiPS parcels, incorporating the density of each particle into the computation. The resulting projection ensures conservation of both the property values and the density. The function returns a pair of vectors: one representing the projected values on the HiPS parcels and another for the densities.
- Parameters
-
vcfd | Vector of variables from flow particles to be projected onto HiPS parcels. |
weight | Vector of weights corresponding to each flow particle. |
density | Vector of densities associated with each flow particle. |
- Returns
- A pair of vectors:
- First vector: Projected values on the HiPS parcels.
- Second vector: Densities on the HiPS parcels.
- Note
- This is an overloaded version of the projection function, designed to include particle density in the computation. Ensure that the
vcfd
, weight
, and density
vectors are of equal size for consistency.
- Warning
- Discrepancies in the size of the input vectors (
vcfd
, weight
, and density
) may lead to undefined behavior or inaccurate projections. Verify the inputs before calling this function.
Definition at line 464 of file hips.cc.
std::vector< double > hips::setGridHips |
( |
int | N | ) |
|
|
private |
Generates a physical domain for HiPS parcels.
This function creates a grid of positions for HiPS parcels, where each parcel occupies an equal portion of the physical domain. The total size of the domain corresponds to the size specified in the setGridCfd()
function, ensuring consistency between the HiPS and flow particle domains.
- Parameters
-
N | The number of grid points for the HiPS parcels. |
- Returns
- A vector representing the grid positions for the HiPS parcels.
- Note
- The function assumes that the physical domain is evenly divided among the parcels. Ensure that the number of grid points (
N
) is consistent with the physical domain size defined in the simulation setup.
- Warning
- If
N
is less than or equal to zero, the function may produce an empty or invalid grid. Validate the input to avoid unexpected behavior.
Definition at line 560 of file hips.cc.
std::vector< double > hips::setGridCfd |
( |
std::vector< double > & | w | ) |
|
|
private |
Generates a physical domain for flow particles based on their weights.
This function creates a grid of positions for flow particles, where each particle occupies a portion of the domain proportional to its weight. The total length of the domain is assumed to be 1, and the sum of all portions equals 1. The resulting vector represents the positions of particles along the domain.
- Parameters
-
w | Vector of weights, where each weight determines the portion of the domain occupied by a particle. |
- Returns
- A vector of grid positions for the flow particles.
- Note
- The function assumes that the weights in
w
are normalized or properly scaled such that the total sum matches the domain length of 1. If the weights are not normalized, the resulting grid may not represent a valid physical domain.
- Warning
- Ensure that the input weight vector
w
is non-empty and contains positive values. Zero or negative weights may lead to undefined behavior or invalid domain generation.
Definition at line 526 of file hips.cc.
std::vector< double > hips::projection_back |
( |
std::vector< double > & | vh | ) |
|
|
private |
Projects HiPS parcel values back onto the flow particles.
This function reverses the projection process, redistributing the values stored in the HiPS parcels back to the flow particles. It ensures conservation of properties such as mass or concentration by maintaining consistency between the HiPS parcels and flow particles.
Conservation Principle:
The projection follows the equation:
\[
\sum_{j=0}^{\text{Number of HP}} (\phi_{\text{HP}} \, \mathrm{d}x_{\text{HP}})_{j} =
\sum_{i=0}^{\text{Number of FP}} (\phi_{\text{FP}} \, \mathrm{d}x_{\text{FP}})_{i}
\]
where:
- \(\phi_{\text{HP}}\): Values in HiPS parcels.
- \(\mathrm{d}x_{\text{HP}}\): Differential volume elements for HiPS parcels.
- \(\phi_{\text{FP}}\): Values in flow particles.
- \(\mathrm{d}x_{\text{FP}}\): Differential volume elements for flow particles.
- Parameters
-
vh | Vector of values from HiPS parcels to be projected back. |
- Returns
- Vector of values redistributed onto the flow particles.
- Note
- This function is the reverse of the projection function, ensuring consistency in value transfers between HiPS parcels and flow particles.
- The input vector
vh
should be consistent with the HiPS parcel structure.
- Warning
- Ensure that the HiPS parcels have been properly populated with values before invoking this function.
- Mismatches in data sizes between HiPS parcels and flow particles may lead to unexpected results.
Definition at line 1180 of file hips.cc.
std::pair< std::vector< double >, std::vector< double > > hips::projection_back_with_density |
( |
std::vector< double > & | vh, |
|
|
std::vector< double > & | rho_h ) |
|
private |
Projects HiPS parcel values and densities back onto the flow particles.
This function reverses the projection process, redistributing both the values and densities stored in the HiPS parcels back to the flow particles. It ensures conservation of both the property values and densities, maintaining consistency between the HiPS parcels and flow particles.
Conservation Principle:
The projection follows the equation:
\[
\sum_{j=0}^{\text{Number of HP}} (\phi_{\text{HP}} \, \rho_{\text{HP}} \, \mathrm{d}x_{\text{HP}})_{j} =
\sum_{i=0}^{\text{Number of FP}} (\phi_{\text{FP}} \, \rho_{\text{FP}} \, \mathrm{d}x_{\text{FP}})_{i}
\]
where:
- \(\phi_{\text{HP}}\): Values in HiPS parcels.
- \(\rho_{\text{HP}}\): Densities in HiPS parcels.
- \(\mathrm{d}x_{\text{HP}}\): Differential volume elements for HiPS parcels.
- \(\phi_{\text{FP}}\): Values in flow particles.
- \(\rho_{\text{FP}}\): Densities in flow particles.
- \(\mathrm{d}x_{\text{FP}}\): Differential volume elements for flow particles.
- Parameters
-
vh | Vector of values from HiPS parcels to be projected back. |
rho_h | Vector of density values from HiPS parcels. |
- Returns
- A pair of vectors:
- The first vector contains the values projected back onto the flow particles.
- The second vector contains the densities redistributed to the flow particles.
- Note
- This function is the reverse of the projection function that includes density.
- The input vectors
vh
and rho_h
should be consistent with the HiPS parcel structure and sizes.
- Warning
- Ensure that the HiPS parcels are populated with valid values and densities before invoking this function.
- Mismatches in data sizes between HiPS parcels and flow particles may lead to inaccurate results.
Definition at line 1256 of file hips.cc.
void hips::sample_hips_eddy |
( |
double & | dtEE, |
|
|
int & | iLevel ) |
|
private |
Samples stochastic eddy events on the HiPS tree, determining the time increment and tree level.
This function performs stochastic sampling to determine when ( \(\Delta t_{EE}\)) and at what level ( \(i_{Level}\)) in the HiPS tree the next eddy event will occur. The time to the next eddy event is sampled based on the total eddy rate. The tree level of the event is chosen depending on whether it occurs in the inertial or Batchelor region of turbulence.
- Parameters
-
dtEE | Time increment to the next eddy event ( \(\Delta t_{EE}\)), sampled stochastically. |
iLevel | Tree level ( \(i_{Level}\)) at which the eddy event occurs, determined probabilistically. |
- Note
- The function distinguishes between events in the inertial and Batchelor regions based on turbulence properties. Ensure that the HiPS tree is correctly initialized before calling this function.
- Warning
- The stochastic nature of this function requires a properly seeded random generator to ensure reproducibility in simulations where determinism is necessary.
Definition at line 680 of file hips.cc.
void hips::selectAndSwapTwoSubtrees |
( |
const int | iLevel, |
|
|
int & | iTree ) |
|
private |
Performs eddy events by swapping parcels within the HiPS tree.
This function executes parcel swaps by randomly selecting nodes at the specified level of the HiPS tree. It identifies the starting indices of subtrees to be swapped, calculates the number of parcels to swap, and performs the swap operation efficiently using bitwise operations. The process mimics the hierarchical structure of turbulent mixing.
- Parameters
-
iLevel | Input level of the tree where the base of the swap occurs. |
iTree | Output parameter indicating which subtree at the given level is selected for swapping. |
The process is as follows:
- Randomly select a node on
iLevel
.
- Traverse two levels down to identify subtrees
0q
and 1r
, where q
and r
are random binary values (0 or 1).
- Determine the starting indices of the
Q-tree
and R-tree
for the swap and compute the number of parcels.
- Swap the corresponding parcels between the subtrees.
Example for a 6-level tree:
- Tree levels: 0, 1, 2, 3, 4, 5.
- If
iLevel = 1
:
- Suppose the selected node is
i = 01
.
- Subtrees for swapping are
0q = 00
and 1r = 11
.
- Swapping involves parcels
0100**
with 0111**
, or (01|00|**)
with (01|11|**)
.
- In binary terms, the swap is equivalent to exchanging
i0qs
with i1rs
, where:
i = 01
0q = 00
1r = 11
s = **
(remaining bits).
Implementation:
- Bitwise operations are used for efficient calculations of powers of 2.
- The swap operation is performed by flipping the bits for
0q
and 1r
, which effectively swaps the subtrees.
Visual Representation of Tree:
Level 0 * (root)
/ \
Level 1 * (*)
/ \ / \
Level 2 * * * *
Level 3 * [*] * [*]
Level 4 * * * * * * * *
Level 5 00 01 02 03 ... 30 31
- Subtrees
0q
and 1r
correspond to specific branches of the tree.
- Swapping occurs within highlighted sections of Level 3, identified by bit manipulation.
- Warning
- Ensure that the input
iLevel
is within the valid range of tree levels and that the tree is properly initialized before invoking this function.
Definition at line 762 of file hips.cc.
void hips::advanceHips |
( |
const int | iLevel, |
|
|
const int | iTree ) |
|
private |
Advances the HiPS model by simulating micromixing and reactions at a specific tree level.
This function models the interaction of parcels within the HiPS tree structure at a given level, simulating the effects of micromixing and reactions. The process involves determining whether conditions for micromixing are met and, if so, triggering reactions and mixing for parcels under the specified node. The operation depends on turbulence forcing and micromixing thresholds.
- Parameters
-
iLevel | The level of the HiPS tree at which the eddy event occurs. |
iTree | The root node of the eddy event at the specified level. |
Key Operations:
- Identifies parcels within the specified tree level.
- Checks whether conditions for micromixing are satisfied.
- Applies turbulence forcing if enabled.
- Triggers reactions for the first variable that meets micromixing conditions.
- Applies mixing to subsequent variables without additional reactions.
- Note
- Reactions are only performed for the first variable that satisfies the micromixing conditions. For all subsequent variables, only mixing operations are performed.
- Warning
- Ensure that the HiPS tree structure is properly initialized and that
iLevel
and iTree
correspond to valid levels and nodes within the tree to prevent undefined behavior.
Definition at line 804 of file hips.cc.
int hips::getVariableIndex |
( |
const std::string & | varName | ) |
const |
|
private |
Retrieves the index of a variable by its name in the varName
list.
This function searches the varName
list for the specified variable name and determines its index. It uses std::find
and std::distance
to locate the variable efficiently. If the variable name is not found, the function throws a std::runtime_error
. This functionality is crucial for referencing variables dynamically within the HiPS model.
- Parameters
-
varName | The name of the variable to search for (e.g., "enthalpy"). |
- Returns
- int The index of the variable in the
varName
list.
- Exceptions
-
std::runtime_error | If the variable name is not found in the varName list. |
Usage Example:
int index =
hips.get_varIndex(
"enthalpy");
- Note
- This function is case-sensitive and assumes that the
varName
list has been populated, typically via the set_varData
method. Ensure that the variable names match exactly, including case, to avoid errors.
- Warning
- If the
varName
list is empty or not properly populated, the function may throw unexpected errors. Verify the list contents before invoking this method.
- See also
- set_varData
Definition at line 852 of file hips.cc.
void hips::mixAcrossLevelTree |
( |
int | kVar, |
|
|
const int | iLevel, |
|
|
const int | iTree ) |
|
private |
Uniformly mixes parcels at a specified level and subtree within the HiPS model.
This function performs uniform mixing of parcels based on their average values at a specified level and subtree of the HiPS tree. It is particularly suited for low Schmidt number ( \(Sc\)) variables and supports mixing at levels above the lowest in the tree. Parcels are mixed in pairs or groups depending on the level and subtree index.
- Parameters
-
kVar | Index of the variable to be mixed (typically a transported variable determined by the caller). |
iLevel | The tree level whose grandchildren will be mixed. |
iTree | The subtree at the given level where mixing will occur. |
Process Overview:
- At each level, the function mixes parcels in pairs or larger groups as determined by the tree structure.
- The level (
iLevel
) defines the size of the groups to mix:
- Higher levels mix larger groups (e.g., groups of 4 parcels at Level 1).
- Lower levels mix smaller groups (e.g., pairs of parcels at Level 2).
- Mixing is performed uniformly by averaging the variable values (
kVar
) of parcels.
Example for a 5-Level Tree (Levels: 0 to 4):
iLevel
= 2:
- If
iTree
= 0, parcels (0,1) and (2,3) will be mixed.
- If
iTree
= 1, parcels (4,5) and (6,7) will be mixed.
- If
iTree
= 2, parcels (8,9) and (10,11) will be mixed.
- If
iTree
= 3, parcels (12,13) and (14,15) will be mixed.
iLevel
= 1:
- If
iTree
= 0, parcels (0,1,2,3) and (4,5,6,7) will be mixed.
- If
iTree
= 1, parcels (8,9,10,11) and (12,13,14,15) will be mixed.
Notes:
- Density Assumption: The function assumes all parcels have the same density. Be cautious when mixing scalars like mass fractions, as the current implementation directly mixes \(Y_i\).
- Index Calculation: The function uses bitwise left shift (
<<
) to calculate the starting and ending indices for parcel mixing.
- Warning
- Ensure that
iLevel
and iTree
correspond to valid levels and subtrees in the HiPS structure to prevent undefined behavior.
Definition at line 967 of file hips.cc.
void hips::forceProfile |
( |
| ) |
|
|
private |
Adjusts the HiPS profile to enforce statistical stationarity.
This function modifies the parcel values in the HiPS profile to achieve statistical stationarity. Specifically, it adjusts the average value of parcels in the left half of the profile to 0 and the average value in the right half to 1. This is particularly useful for simple scalar variables, such as a mixture fraction ranging between 0 and 1.
Process Overview:
- For each variable in the HiPS profile:
- Compute the average value of parcels in the left half.
- Compute the average value of parcels in the right half.
- Adjust the parcel values to enforce the desired averages (0 for the left half, 1 for the right half).
- Note
- This function directly modifies the parcel data in the HiPS profile.
- It assumes that variable values are bounded and appropriate for normalization (e.g., scalars between 0 and 1).
- Warning
- Ensure that the HiPS profile is properly initialized and contains valid data before calling this function.
- Unbounded or inappropriate variable values may lead to unexpected results.
Definition at line 1030 of file hips.cc.
void hips::writeData |
( |
int | real, |
|
|
const int | ifile, |
|
|
const double | outputTime ) |
|
private |
Writes simulation data to a file for a specific realization, time, and file index.
This function saves the current state of simulation data to a file, organized by realization and time step. The output is stored in a subdirectory corresponding to the realization index (e.g., rlz_00000
, rlz_00001
), and the file is named sequentially (e.g., Data_00001.dat
, Data_00002.dat
) to maintain an ordered record of outputs. The simulation time is also written into the file for reference.
Key Operations:
- Creates a subdirectory named
rlz_XXXXX
based on the realization index.
- Constructs the output filename using the sequential file index.
- Writes the simulation variables (e.g., temperature, species mass fractions) in scientific format with high precision.
- Parameters
-
real | Realization index used to name the subdirectory (rlz_XXXXX ). |
ifile | Sequential index for naming the output file within the realization. |
outputTime | Simulation time associated with the data, included in the file header. |
- Note
- The function ensures the output directory for the specified realization is created if it does not exist.
- It writes all data with high precision for accurate post-processing.
- Warning
- If the function fails to create the directory or open the output file, it may throw an error or silently fail. Ensure file system permissions and disk space are sufficient.
Definition at line 1086 of file hips.cc.
void hips::saveAllParameters |
( |
| ) |
|
|
private |
Saves all user-defined to a file.
This function writes both input parameters (provided by the user) for post-processing. The file is stored in the post/
directory.
The file includes:
- User-defined input parameters, such as grid levels, domain size, turbulence settings, and variable names.
- Note
- The parameters are saved to
../post/parameters.dat
. Ensure that the post/
directory exists, or the function may fail to write the file.
- Warning
- If the file cannot be openedx, an error message is printed, and no data is saved.
< Output file path for simulation parameters
< Number of hierarchical levels in the HiPS model
< Length of the computational domain
< Reference eddy turnover time
< Model constant controlling turbulence behavior
< Flag for forced turbulence (1 = enabled, 0 = disabled)
< Number of variables tracked in the simulation
< Flag indicating whether chemical reactions are simulated
< Current simulation realization (for multiple runs)
< Separate variable names by spaces
< Print each element separated by space
Definition at line 1411 of file hips.cc.