|
[Sponsors] |
September 27, 2011, 12:04 |
change "value" in groovyBC
|
#1 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17 |
Hi All, a question, maybe someone can help...
I use groovyBC for some scalar, say X, and I want to change the "value" field at runtime (actually I want to eliminate some negative values out of this value nonuniform List<scalar> etcetc... I used to do it for members of mixedFvPatchField<vector> &U1Patch = refCast<mixedFvPatchVectorField>(U1.boundaryField( )[labelH2out]); ..e.g. U1Patch.refValue()[iFaceLocal] = SomeVector (0,0,umag_new); U1Patch.valueFraction()[iFaceLocal] = 1; (from zero gradient to dirichelt) Is this possible? Or cause groovy itīs loaded only at runtime it is not... many thanks, radu |
|
September 27, 2011, 14:29 |
|
#2 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
To quote another StarWars-Character "Not clear your question is, young Yedi. Changing field at run-time purpose of boundary condition is" Where do you run the code-snipplet that you show? - in a special BC - in the solver - in a special postprocessing-utility? In groovyBC what you're trying to do can be written like this (I hope the names of the parameters are right. Just because I wrote that stuff doesn't mean that I know how to use it): type groovyBC; valueExpression "vector(0,0,umag_new)"; gradientExpression "vector(0,0,0)"; fractionExpression " (scalar<0) ? 1 : 0"; If you want to do this after the simulation you can use funkySetBoundaryField (part of swak4Foam) to manipulate the boundary fields (but I havn't tried this as a postprocessor for large cases. Might take a while) To end: "If answer you not like question reformulate you must. Clear asking of question most noble power of the Yedi is" |
||
September 28, 2011, 04:38 |
follow up
|
#3 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17 |
Oh groovyBC Master,
Let me explain myself... Me have a scalarField with a groovyBC patch and during runtime some members in "value" go negative..and I want to cut that off (make them zero). E.g. variable "X" with myPatch { type groovyBC; refValue uniform 0; refGradient uniform 0; valueFraction uniform 1; value nonuniform List<scalar> 10 ( 0.0985793 0.0985383 0.0985488 0.0985484 0.0985443 0.09854 0.0985374 -0.00001 -0.0001 -0.001234 ) ; valueExpression "Ccref"; gradientExpression "0"; fractionExpression "f"; variables "vel=mag(U);A=-nuCceff;B=vel;C=vel;f=1.0/(1.0+A/(B*mag(delta())));Ccref=C/B;"; timelines (); } ...and...if I do (in the code) label Mylabel = mesh.boundaryMesh().findPatchID("myPatch"); scalarField &Xfldlabel=X.boundaryField()[Mylabel]; forAll(Xfldlabel,fI) { if (Xfldlabel[fI]<0.0) Xfldlabel[fI]=0.0 } X.correctBoundaryConditions(); runtime.writeNow(); return(0); ...my "value" field in the X for the groovy BC stays the same...as in like it did not do what I asked it to do in the forAll loop... Thatīs the "problem" this young Jedi is facing...any help appreciated... Regards, r2d2 |
|
September 28, 2011, 12:04 |
|
#4 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Anyway. That is a bit strange. BTW: my suspicion is that you're on a wall with a zero-velocity. That's why the values of the super-class (refValue, refGradient and valueFraction evaluate to the values you have) As they stay constant: could you try to set the type from groovyBC to mixed (with the above ref-values) and see if the resulting values are the same. If yes: then it is a problem with the superclass (mixed) Bernhard |
||
September 29, 2011, 06:03 |
exit
|
#5 |
Member
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17 |
Hi again,
Thing is that this is an exit and for my "X" I wanted to set up a bc of type A*dX/dn+B*X=C with A,B, C functions of the velocity (sort of convective-diffusive flux bc)..the trouble that I ran into at runtime was that X on this patch went negative-when it is a mass fraction(!?) (my posted example was a bit "forced", the values were low ..of order -1e-5) and I wanted to shave them off ...hence my question whether I could access this "value" member at and play with it with correctBoundaryConditions and so on much as I was doing the trick with a mixedFvPatch ... My guess now is that as I load groovy via controlDict as a .so the code will understand it at runtime, but in the code itself I wonīt be able to use/access members of the class...have to find a way round it. Many thanks for your hep anyways. r2d2 |
|
September 29, 2011, 13:16 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
Bernhard |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[swak4Foam] groovyBC issue - k and epsilon | sagnikmazumdar | OpenFOAM Community Contributions | 24 | March 1, 2015 08:16 |
Radiation interface | hinca | CFX | 15 | January 26, 2014 18:11 |
[swak4Foam] switch between existing BCs with groovyBC?! | michielm | OpenFOAM Community Contributions | 3 | September 4, 2013 09:01 |
[swak4Foam] groovyBC and Eqn.setReference() | benk | OpenFOAM Community Contributions | 3 | June 2, 2011 09:49 |
Multicomponent fluid | Andrea | CFX | 2 | October 11, 2004 06:12 |