|
[Sponsors] |
[swak4Foam] delayed response - on the limit of groovyBC's capabilities? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
July 9, 2012, 05:00 |
delayed response - on the limit of groovyBC's capabilities?
|
#1 |
Member
Roland
Join Date: Mar 2009
Location: Netherlands
Posts: 92
Rep Power: 17 |
Is it possible to have a patch react to the value of another patch, but only after a certain delay?
For example see the geometry depicted in de picture attached. From the bottom of a mixing tank, fluid with a certain amount of contamination is (continuously) taken. This fluid is then processed, such that the contamination level changes. After about 30 seconds the fluid is be fed back into the tank. My first thought was to use groovyBC, as it was helpful so many times in the past. But after having a good look on the wiki and this forum I haven't been able to find a clue on how to do this. So maybe I have to build a custom boundary condition after all. Any suggestion will be much appreciated! Best regards, Sylvester |
|
July 9, 2012, 12:53 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Another possibility would be to use the pythonIntegration-functionObject and implement the delaying yourself (one possibility would be to use rrdtool to do the storage. It is specialized for that kind of thing) I don't think that the coded-functionObject that comes with OF gives you the possibility to store date between calls to the FO and therefor won't work with this. But I could be wrong |
||
July 10, 2012, 03:18 |
|
#3 | |||
Member
Roland
Join Date: Mar 2009
Location: Netherlands
Posts: 92
Rep Power: 17 |
Hi Bernhard,
Thanks for your help. Quote:
Quote:
Quote:
If I get something working, I'll report back here. Regards, Sylvester |
||||
July 10, 2012, 03:35 |
|
#4 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
BTW: swak has a subclass (swakCoded) of it that allows to read and write swak-Variables in global namespaces. But this isn't sufficient for our purposes too I'm afraid OK |
|||
July 11, 2012, 05:55 |
|
#5 |
Member
Roland
Join Date: Mar 2009
Location: Netherlands
Posts: 92
Rep Power: 17 |
Hi Bernhard,
I've got it working now. The input concentration is calculated in a swakCoded/swakFunctionObjects. Using globalScopes this concentration is available to a standard groovyBC for the inlet patch. The time history of the concentration is stored within the swakCoded/swakFunctionObjects using a global (fixed length) scalar. The availability of a labelList for this part would have resulted in prettier code, but this is also working. The examples I used for this construct were 'cylinderWithSwak' for the 'swakCoded/swakFunctionObjects' part and the file 'Examples/tests/pythonIntegration/0/rand' for the 'globalScopes/groovyBC' part. Thanks again for your help! regards, Sylvester |
|
July 11, 2012, 08:29 |
|
#6 | ||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Great. Congratulations. Its always nice when people abuse swak for stuff that I didn't think is possible.
Quote:
- you mean "fixedLength scalarList", right? - why was labelList not possible? Not "known"? Are you aware of codeInclude (see http://www.openfoam.org/docs/user/ba...8-1050004.2.11) or does this not work with the swak-FO? - how did you get the persistence between calls? Is it possible to add member variables to the FO or did you use a static variable in the function? - does your solution assume a fixed time-step? Quote:
Would you like to contribute your example? Bernhard |
|||
July 11, 2012, 09:07 |
|
#7 | |||
Member
Roland
Join Date: Mar 2009
Location: Netherlands
Posts: 92
Rep Power: 17 |
Never heard of them. For my (ugly) solution see the timeList and concentrationList definition in the code below.
Quote:
I was not aware of codeInclude. Quote:
As you'll see in the code, this part is not finished yet. I'm already storing the (average) concentration every time data is written to disk. And I have verified I can access this data at a later iteration. Next I will add a mechanism that will use linear interpolation between stored concentration value, plus some additional processing function. Quote:
Regards, Sylvester from controlDict: Code:
libs ( "libswakFunctionObjects.so" "libsimpleSwakFunctionObjects.so" "libgroovyStandardBCs.so" ); functions { addTimeList { type addGlobalVariable; globalName timeList; globalScope concentrationResults; valueType scalar; value 999999{0}; isSingleValue false; } addTimeListLength { type addGlobalVariable; globalName timeListLength; globalScope concentrationResults; valueType scalar; value 0; isSingleValue true; } addConcentrationList { type addGlobalVariable; globalName concentrationList; globalScope concentrationResults; valueType scalar; value 999999{0}; isSingleValue false; } addInConcentration { type addGlobalVariable; globalName inConcentration; globalScope concentrationResults; valueType scalar; value 0; isSingleValue true; } concentrationFunction { // Load the library containing the 'coded' functionObject functionObjectLibs ("libswakFunctionObjects.so"); type swakCoded; codedToSwakNamespace concentrationResults; codedToSwakVariables ( timeList timeListLength concentrationList inConcentration ); swakToCodedNamespaces (concentrationResults); code #{ const volScalarField& T = mesh().lookupObject<volScalarField>("T"); label outPatch = mesh().boundaryMesh().findPatchID("outlet"); label inPatch = mesh().boundaryMesh().findPatchID("inlet"); scalar delay=30.; dimensionedScalar Concentration ( "Concentration", dimensionSet(0, 0, 0, 1, 0), gSum ( T.boundaryField()[outPatch] * mesh().magSf().boundaryField()[outPatch] ) / gSum ( mesh().magSf().boundaryField()[outPatch] ) ); if (mesh().time().outputTime()) { timeList[++timeListLength] = mesh().time().value(); concentrationList[timeListLength] = Concentration.value(); scalar procesTime = timeList[timeListLength] - delay; if (procesTime < timeList[0]) { // Info << "No data yet" << endl; inConcentration = 1.0; } else { // Info << "Woohoo data!" << endl; inConcentration = 1.0 + max(concentrationList[timeListLength],0); } } #}; } } Code:
inlet { type groovyBC; value uniform 1; globalScopes ( concentrationResults ); valueExpression "inConcentration"; } |
||||
July 11, 2012, 13:43 |
|
#8 | ||||
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Quote:
label as a list type is not supported by swak because there is no such thing as a volLabelField Quote:
Quote:
Don't be offended but your urgency is of little relevance to me if you're not a client |
|||||
Tags |
boundary condition, delayed response, groovybc, mixing tank |
Thread Tools | Search this Thread |
Display Modes | |
|
|