|
[Sponsors] |
Dynamic BCs Based on Probes/Properties at a Specific Point |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 1, 2021, 21:58 |
Dynamic BCs Based on Probes/Properties at a Specific Point
|
#1 |
New Member
Alexander Symeonidis
Join Date: Nov 2021
Posts: 2
Rep Power: 0 |
Hello,
Context: I am trying to set up a model with dynamic boundary conditions. The model is a carpark with a fire, where I want inlet and outlet fans (BCs) to dynamically turn on/off when a certain measured property is reached in a specific location (Probe/Detector). For example when a temperature of 68*C is reached in a specific location, I want the inlet and outlet fans (BCs) to turn off. I know I could run an initial model to figure out when certain events occur, then reset the model with the BC modified to turn off at the specified time. However, i would rather run the model once to save time and computer recourses. Note this is intended to emulate heat/smoke/CO detectors controlling controlling active systems such as fans/dampers, as they would in real life. My question: Is it possible to dynamically modify a BC based on the properties in a specific location of the model? Additional: I believe it may be possible using the codedFixedValue BC, however I am new to C++ coding and could not find any examples. Because of this I am not sure it is possible using the codedFixedValue BC. If there are any other ways, that are known or could be developed, to dynamically modify a BCs, any information would be greatly appreciated. |
|
November 11, 2021, 16:26 |
|
#2 |
New Member
Alexander Symeonidis
Join Date: Nov 2021
Posts: 2
Rep Power: 0 |
I figures out how to do this using functions in the controlDict to stop the model and an All_run bash script to restart and modify the boundary condition.
control dict functions: Code:
functions { temp_0 { type volFieldValue; libs ( "libfieldFunctionObjects.so" ); fields ( T ); operation max; writeFields false; writeInterval 1; log true; regionType cellZone; name cz0; } runTimeControl1 { type runTimeControl; libs ( "libutilityFunctionObjects.so" ); conditions { condition0 { type minMax; functionObject temp_0; mode minimum; value 293; fields ( max(cz0,T) ); } } } } Code:
actions ( { name c0; type cellSet; action new; source nearestToCell; points ( (0 0 1) ); } { name cz0; type cellZoneSet; action new; source setToCellZone; set c0; } ); # Application name Code:
application=$(getApplication) processes=4 detThresh=295 detInit=293 endTime=20 timeStepBA=1 timeStepAA=10 foamDictionary system/decomposeParDict -entry numberOfSubdomains -set "$processes" foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.value -set "$detThresh" foamDictionary system/controlDict -entry endTime -set "$endTime" foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.mode -set "maximum" foamDictionary system/controlDict -entry writeInterval -set "$timeStepBA" runApplication topoSet runApplication decomposePar runParallel $(getApplication) foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.mode -set "minimum" latestFolder=$(ls processor0/ -t | head -1) rm -r processor*/$latestFolder unset latestFolder latestFolder=$(ls processor0/ -t | head -1) latestFolder=$((latestFolder + timeStepBA)) foamDictionary system/controlDict -entry endTime -set "$latestFolder" foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.value -set "$detInit" unset latestFolder rm log.fireFoam runParallel $(getApplication) x=0 processes=$((processes-1)) while [ $x -le $processes ] do processor=processor$x latestFolder=$(ls $processor/ -t | head -1) var_0=$(foamDictionary $processor/$latestFolder/U -entry boundaryField.outlet_1.refValue -value) x=$(( $x + 1 )) var_1="nonuniform List<scalar> 0()" if [ "$var_0" != "$var_1" ] then foamDictionary $processor/$latestFolder/U -entry boundaryField.outlet_1.refValue -set "uniform 0" fi done unset latestFolder unset x unset var_0 unset var_1 unset processes unset processor latestFolder=$(ls processor0/ -t | head -1) stepTime=$latestFolder x=$((stepTime%timeStepAA)) while [ $x -ne 0 ] do stepTime=$((stepTime+timeStepBA)) x=$((stepTime%timeStepAA)) done foamDictionary system/controlDict -entry endTime -set "$stepTime" rm log.fireFoam runParallel $(getApplication) foamDictionary system/controlDict -entry endTime -set "$endTime" foamDictionary system/controlDict -entry writeInterval -set "$timeStepAA" rm log.fireFoam runParallel $(getApplication) runApplication reconstructPar foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.value -set "$detThresh" #rm -r processor* #rm -r postProcessing rm log.decomposePar rm log.fireFoam rm log.toposet rm log.reconstructPar foamDictionary system/controlDict -entry functions.runTimeControl1.conditions.condition0.mode -set "maximum" |
|
November 14, 2021, 07:27 |
|
#3 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14 |
Nice work Alex, and thanks for posting your solution - it's always good to see other's solutions, and to swap ideas. By the way, for getting the name of the latest time folder
Code:
latestFolder=$(ls processor0/ -t | head -1) Code:
time=$(foamListTimes -latestTime) |
|
Tags |
codedfixedvalue, dynamic boundary, firefoam, probes, reactingfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Continuity Equation for multicomponent simulation | lordluan | CFX | 15 | May 19, 2020 19:36 |
Injection initialization generate a segmentation fault!! | zahrae | Fluent UDF and Scheme Programming | 11 | July 9, 2019 20:00 |
[OpenFOAM] Annotate velocity of specific cell or point | jwstolk | ParaView | 4 | August 5, 2016 06:50 |
Compression stoke is giving higher pressure than calculated | nickjuana | CFX | 62 | May 19, 2015 14:32 |
How to get cell labels for all the points within specific distance from a given point | gxy200992243 | OpenFOAM Programming & Development | 7 | October 11, 2014 16:17 |