Definition at line 16 of file hips.h.
|
| void | set_tree (int nLevels_, double domainLength_, double tau0_) |
| | Sets up the HiPS tree using explicitly specified tree parameters.
|
| |
| void | set_tree (double Re_, double domainLength_, double tau0_, std::string ReApproach_="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::pair< std::vector< 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.
|
| |
| void | writeData (int real, const int ifile, const double outputTime) |
| | Writes simulation data to a file for a specific realization, time, and file index.
|
| |
| int | get_nparcels () const |
| |
| const std::vector< int > & | get_pLoc () const |
| |
| const std::vector< std::shared_ptr< std::vector< double > > > & | get_HipsVarData_ptr () const |
| |
| | hips (double C_param_, bool forceTurb_, int nVar_, std::vector< double > &ScHips_, 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_, bool 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.
|
| |
|
| 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) |
| | Project values from CFD cells onto HiPS parcels, accounting for cell 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::vector< double > | projection_back_with_density (std::vector< double > &vh, std::vector< double > &rho_h, std::vector< double > &rho_c) |
| | Projects HiPS parcel values and densities back onto the flow particles (CFD cells).
|
| |
| 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 | saveAllParameters () |
| | Saves all user-defined to a file.
|
| |
|
| int | nparcels |
| | number of parcels
|
| |
| 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 | 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 | forceTurb |
| | forcing function for statistically stationary: -1 = none, 1 = source term, 2 = dir
|
| |
| bool | LScHips |
| | hips schmidt number
|
| |
| bool | performReaction |
| | flag indicating whether chemical reactions are performed in the simulation
|
| |
| 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< 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 | ReApproach |
| |
| 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_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 343 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 371 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.
Projects data from HiPS varData (size nparcels) to number of CFD particles corresponding to initial set_varData call
- 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 1420 of file hips.cc.
| std::pair< std::vector< 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 1459 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 1518 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 1498 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 649 of file hips.cc.
| void hips::writeData |
( |
int | real, |
|
|
const int | ifile, |
|
|
const double | outputTime ) |
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 1170 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 404 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 |
Project values from CFD cells onto HiPS parcels, accounting for cell density.
Projects a CFD field onto HiPS parcels using density weighting so that both the property (mass-weighted) and the density are conserved.
- Parameters
-
| vcfd | CFD cell values to project (aligned with CFD cells). |
| weight | CFD cell weights (e.g., widths) used to build the CFD grid. |
| density | CFD cell densities aligned with vcfd. |
- Returns
- A pair {vh, rho_h} where:
vh : parcel-averaged values on the HiPS parcels
rho_h : parcel-averaged densities on the HiPS parcels
Parcel averages are formed via geometric overlaps between CFD cells and HiPS parcels:
\[
\phi_h(i) =
\frac{\sum_j \rho_c(j)\,\phi_c(j)\,\Delta x_{ij}}
{\sum_j \rho_c(j)\,\Delta x_{ij}},\qquad
\rho_h(i) =
\frac{\sum_j \rho_c(j)\,\Delta x_{ij}}
{\sum_j \Delta x_{ij}},
\]
where \(\Delta x_{ij}\) is the overlap length between CFD cell \(j\) and parcel \(i\).
- Consistency with parcel weights
- The overlap is scaled by \(w_{\mathrm{par}}(i)/\ell_i\) so forward/backward projection remain consistent when
wPar changes during chemistry. This preserves the mass-weighted integrals:
\[
\sum_i \rho_h(i)\, w_{\mathrm{par}}(i) \approx \sum_j \rho_c(j)\, w_c(j), \qquad
\sum_i \rho_h(i)\,\phi_h(i)\, w_{\mathrm{par}}(i) \approx
\sum_j \rho_c(j)\,\phi_c(j)\, w_c(j).
\]
- Note
- This overload includes density in the computation. Ensure that
vcfd, weight, and density have identical sizes. Weights are typically normalized ( \(\sum_j w_c(j)=1\)), but only their relative magnitudes matter.
- Warning
- Size mismatches among
vcfd, weight, and density will lead to incorrect projections. Verify inputs before calling. Non-positive parcel lengths or negative weights are invalid.
- See also
- set_varData, get_varData_with_density, projection_back_with_density
Definition at line 489 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 601 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 563 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 1281 of file hips.cc.
| std::vector< double > hips::projection_back_with_density |
( |
std::vector< double > & | vh, |
|
|
std::vector< double > & | rho_h, |
|
|
std::vector< double > & | rho_c ) |
|
private |
Projects HiPS parcel values and densities back onto the flow particles (CFD cells).
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.
- Note
- In the new implementation, geometric overlaps are scaled by \(w_{\text{Par}}/\mathrm{d}x_{\text{HP}}\) so that mass is preserved when parcel volumes change during chemistry.
- Parameters
-
| vh | Vector of values from HiPS parcels to be projected back. |
| rho_h | Vector of density values from HiPS parcels. |
| rho_c | (output) Vector to receive the densities redistributed to the flow particles. |
- Returns
- A vector containing the values projected back onto 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 1355 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 721 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 803 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 845 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 1114 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 1539 of file hips.cc.