CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Community Contributions

[swak4Foam] change "value" in groovyBC

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 27, 2011, 12:04
Default change "value" in groovyBC
  #1
Member
 
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17
r2d2 is on a distinguished road
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
r2d2 is offline   Reply With Quote

Old   September 27, 2011, 14:29
Default
  #2
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by r2d2 View Post
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
Hi R2D2!

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"
gschaider is offline   Reply With Quote

Old   September 28, 2011, 04:38
Default follow up
  #3
Member
 
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17
r2d2 is on a distinguished road
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
r2d2 is offline   Reply With Quote

Old   September 28, 2011, 12:04
Default
  #4
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by r2d2 View Post
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
Reordering words my habit is. The droid only says "Bip bip. Beeep. Tweeee"

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
gschaider is offline   Reply With Quote

Old   September 29, 2011, 06:03
Default exit
  #5
Member
 
Radu Mustata
Join Date: Mar 2009
Location: Zaragoza, Spain
Posts: 99
Rep Power: 17
r2d2 is on a distinguished road
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
r2d2 is offline   Reply With Quote

Old   September 29, 2011, 13:16
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by r2d2 View Post
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
In groovyBC (without c++) itself this is not possible. Anyway. The interesting question for me is whether if you leave the ref-values like in your example and set "type mixed" the value-field has the same values.

Bernhard
gschaider is offline   Reply With Quote

Reply


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
[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


All times are GMT -4. The time now is 04:42.