|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
Alejandro
Join Date: Mar 2025
Posts: 1
Rep Power: 0 ![]() |
Hi,
I'm running pimpleFoam to obtain the flow field, with this I'm attempting to run a simple advection diffusion solver of a scalar. I first tried by setting a fixed inlet condition for the scalar and my model runs just fine. Now, I would like to randomize the scalar input for it to run random values on each cell across the inlet. I tried chatgpt-ing it, but im getting definition errors. The error im getting is: Entry 'minValue' not found in dictionary. I also tried installing groovyBC, but I'm getting issues with the compilation. Showing the AI solution: ''' yourInletPatchName // <<<=== REPLACE THIS WITH YOUR INLET PATCH NAME { type codedFixedValue; value uniform 0; // Initial placeholder value (required) name randomInletSBC; // Optional: Give the BC instance a name // --- These keywords MUST be inside this block --- minValue 0.0; // Minimum random value maxValue 1.0; // Maximum random value // --- Optional: Define rate of change (if needed, otherwise values change every evaluation) --- // rateOfChange 0.0; // Set to > 0 if you want values to persist for rateOfChange seconds // --- Include necessary headers for random number generation --- codeInclude #{ #include <random> #}; // --- The C++ code to execute --- code #{ // Get the boundary field patch data (vector of values for each face) scalarField& field = *this; // Access the dictionary entries for min/max values defined above // Note: Using this->dict().lookup("...") is the standard way const scalar minVal = readScalar(this->dict().lookup("minValue")); const scalar maxVal = readScalar(this->dict().lookup("maxValue")); // --- Set up the random number generator --- // Use 'static' for persistent state across time steps. // Choose seeding method: fixed for reproducibility, random_device otherwise. // Example: Reproducible seeding (use the same seed every run) static std::mt19937 engine(12345); // Example: Non-reproducible seeding (uncomment the two lines below) // static std::random_device rd; // static std::mt19937 engine(rd()); // Define the distribution (uniform between minVal and maxVal) std::uniform_real_distribution<scalar> distribution(minVal, maxVal); // Loop over all faces on this patch forAll(field, facei) { // Assign a random value from the distribution to each face field[facei] = distribution(engine); } #}; } // End of yourInletPatchName definition ''' |
|
![]() |
![]() |
![]() |
Tags |
boundary condition, groovybc, inlet, scalar transport |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Centrifugal fan | j0hnny | CFX | 13 | October 1, 2019 13:55 |
Error - Solar absorber - Solar Thermal Radiation | MichaelK | CFX | 12 | September 1, 2016 05:15 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 17:11 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 17:44 |
inlet velocity boundary condition | murali | CFX | 5 | August 3, 2012 08:56 |