CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Dynamic BCs Based on Probes/Properties at a Specific Point

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By alexsym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 1, 2021, 21:58
Default Dynamic BCs Based on Probes/Properties at a Specific Point
  #1
New Member
 
Alexander Symeonidis
Join Date: Nov 2021
Posts: 2
Rep Power: 0
alexsym is on a distinguished road
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.
alexsym is offline   Reply With Quote

Old   November 11, 2021, 16:26
Default
  #2
New Member
 
Alexander Symeonidis
Join Date: Nov 2021
Posts: 2
Rep Power: 0
alexsym is on a distinguished road
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) );
            }
        }
    }
}
topoSetDict for the above function in control dict:

Code:
actions
(

	{
		name    c0;
		type    cellSet;
		action  new;
		source  nearestToCell;
        points
        (
            (0 0 1)
        );

	}
	
    {
        name    cz0;
        type    cellZoneSet;
        action  new;
        source  setToCellZone;
        set     c0;
    }

);
All_run bash script for a parallel run

# 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"
Tobi and s1291 like this.
alexsym is offline   Reply With Quote

Old   November 14, 2021, 07:27
Default
  #3
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14
Tobermory will become famous soon enough
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)
note that you can also just use the foamListTimes utility, eg
Code:
time=$(foamListTimes -latestTime)
Tobermory is offline   Reply With Quote

Reply

Tags
codedfixedvalue, dynamic boundary, firefoam, probes, reactingfoam


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


All times are GMT -4. The time now is 11:16.