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

codedFixedValue boundary condition

Register Blogs Community New Posts Updated Threads Search

Like Tree7Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 24, 2011, 17:18
Question codedFixedValue boundary condition
  #1
Member
 
Neilson Whit
Join Date: Aug 2011
Posts: 74
Rep Power: 14
wolfindark is on a distinguished road
Dear All;

I am trying to define a moving wall boundary condition, X component velocity will change with a function of sin().

the block below does not take calculated ux value. How can I get calculated value as a boundary condition like (ux 0 0) ?.

movingWall_1
{
type codedFixedValue;
value uniform (0 0 0);
redirectType rampedFixedValue;
code
#{

double ux=(0.5*sin(3.14*this->db().time().value())/2);

#};
}

best regards.
wolfindark is offline   Reply With Quote

Old   August 24, 2011, 21:29
Default
  #2
New Member
 
Aidan
Join Date: Apr 2010
Posts: 18
Rep Power: 16
flowman is on a distinguished road
I think it might be something like

Code:
movingWall_1 
{
type codedFixedValue; 
value uniform (0 0 0); 
redirectType rampedFixedValue; 
code 
#{ 

 vector ((0.5*sin(3.14*this->db().time().value())/2), 0, 0);

#}; 
}
flowman is offline   Reply With Quote

Old   August 25, 2011, 01:16
Default
  #3
Member
 
Lars Kiewidt
Join Date: Sep 2009
Location: Germany
Posts: 54
Rep Power: 16
LarsPT is on a distinguished road
That looks like something oscillating! Do you know the oscillatingFixedValue BC? It comes naturally with OpenFOAM. Check out the article in the Wiki.

http://openfoamwiki.net/index.php/Ma...tingFixedValue
LarsPT is offline   Reply With Quote

Old   August 25, 2011, 03:14
Default
  #4
Member
 
Neilson Whit
Join Date: Aug 2011
Posts: 74
Rep Power: 14
wolfindark is on a distinguished road
flowman: thank you for the reply but it does not work.

LarsPT : thank you too, yes this is oscilating. However, I also need different step or oscilating functions, I should imlement in this way.

any help aprreciated.

thank you.
wolfindark is offline   Reply With Quote

Old   August 25, 2011, 07:13
Default
  #5
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 wolfindark View Post
Dear All;

I am trying to define a moving wall boundary condition, X component velocity will change with a function of sin().

the block below does not take calculated ux value. How can I get calculated value as a boundary condition like (ux 0 0) ?.

movingWall_1
{
type codedFixedValue;
value uniform (0 0 0);
redirectType rampedFixedValue;
code
#{

double ux=(0.5*sin(3.14*this->db().time().value())/2);

#};
}

best regards.
I think the line
Code:
            (*this)==vector(0.5*sin(3.14*this->db().time().value())/2,0,0);
will do what you want to. Have a look in doxygen why it does that (should take you at most an hour).

I personally still prefer to write such simple boundary conditions as
Code:
type groovyBC;
valueExpression "vector(0.5*sin(3.1414*time())/2,0,0)";
but then machines get polluted with groovyBC/swak4Foam as soon as I touch them (and I prefer not to do C++ if I don't have to)

Bernhard
PonchO, JR22, Tellur and 2 others like this.
gschaider is offline   Reply With Quote

Old   August 25, 2011, 08:40
Default
  #6
Member
 
Neilson Whit
Join Date: Aug 2011
Posts: 74
Rep Power: 14
wolfindark is on a distinguished road
gschaider thank you! it works.
wolfindark is offline   Reply With Quote

Old   October 9, 2011, 16:51
Default
  #7
New Member
 
Anders
Join Date: Nov 2010
Posts: 10
Rep Power: 15
anlj is on a distinguished road
Dear all,
I can not get this boundary condition to work (see below), has anyone else gotten this error and have a solution?

Many thanks, Anders

Create time
Create mesh for time = 0
Selecting dynamicFvMesh dynamicMotionSolverFvMesh
Selecting motion solver: displacementLaplacian
[0] [2] [1]
[1]
[1] --> FOAM FATAL IO ERROR:
[1] Unknown patchField type codedFixedValue for patch type wall
Valid patchField types are :
25
(
angularOscillatingDisplacement
angularOscillatingVelocity
calculated
cyclic
cyclicSlip
empty
fixedNormalSlip
fixedValue
mixed
nonuniformTransformCyclic
oscillatingDisplacement
oscillatingVelocity
processor
processorCyclic
sixDoFRigidBodyDisplacement
slip
surfaceDisplacement
surfaceSlipDisplacement
symmetryPlane
timeVaryingUniformFixedValue
uncoupledSixDoFRigidBodyDisplacement
uniformFixedValue
value
wedge
zeroGradient
)
[1] [3]
[0] --------------------------------------------------------------------------
anlj is offline   Reply With Quote

Old   October 10, 2011, 04:30
Default
  #8
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 anlj View Post
Dear all,
I can not get this boundary condition to work (see below), has anyone else gotten this error and have a solution?

Many thanks, Anders

Create time
Create mesh for time = 0
Selecting dynamicFvMesh dynamicMotionSolverFvMesh
Selecting motion solver: displacementLaplacian
[0] [2] [1]
[1]
[1] --> FOAM FATAL IO ERROR:
[1] Unknown patchField type codedFixedValue for patch type wall
Valid patchField types are :
25
(
angularOscillatingDisplacement
angularOscillatingVelocity
calculated
cyclic
cyclicSlip
empty
fixedNormalSlip
fixedValue
mixed
nonuniformTransformCyclic
oscillatingDisplacement
oscillatingVelocity
processor
processorCyclic
sixDoFRigidBodyDisplacement
slip
surfaceDisplacement
surfaceSlipDisplacement
symmetryPlane
timeVaryingUniformFixedValue
uncoupledSixDoFRigidBodyDisplacement
uniformFixedValue
value
wedge
zeroGradient
)
[1] [3]
[0] --------------------------------------------------------------------------
Should be there .... if you're using OF 2.0
gschaider is offline   Reply With Quote

Old   October 10, 2011, 05:39
Default
  #9
New Member
 
Anders
Join Date: Nov 2010
Posts: 10
Rep Power: 15
anlj is on a distinguished road
Hello Bernhard,

Yes it is OF 2.0, and I have allowed the use of dynamic code in the "global" controlDict.
anlj is offline   Reply With Quote

Old   October 11, 2011, 04:55
Default
  #10
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 anlj View Post
Hello Bernhard,

Yes it is OF 2.0, and I have allowed the use of dynamic code in the "global" controlDict.
It is compiled into finiteVolume, so it should be in that list. Maybe the problem is that your patch is a wall (not a patch). But I'm not an expert on the codedBC (only used it once out of curiosity)
gschaider is offline   Reply With Quote

Old   October 11, 2011, 15:37
Default
  #11
New Member
 
Anders
Join Date: Nov 2010
Posts: 10
Rep Power: 15
anlj is on a distinguished road
Ok, I tried codedFixedValue on the inlet (which is a patch and not a wall) in the wingMotion tutorial and it works! But if it does not work for walls, why is there an example of a codedFixedValue boundary condition for a movingWall in the C++ documentation of the codedFixedValue?

Still speaking of the wingMotion tutorial; if I want the wing (patch type wall) to move according to user supplied code, I have to find some other way than the codedFixedValue BC? I am confused :S

Inlet BC (U file):

inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
(*this)==vector(min(100, 0.1*this->db().time().value()),0,0);
#};
}

Output:

/*---------------------------------------------------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.0.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
Build : 2.0.1-51f1de99a4bc
Exec : pimpleDyMFoam
Date : Oct 11 2011
Time : 20:56:33
Host : anlj-laptop
PID : 3089
Case : /home/anlj/OpenFOAM/anlj-2.0.1/run/tutorials/wingMotion/wingMotion2D_pimpleDyMFoam
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Selecting dynamicFvMesh dynamicMotionSolverFvMesh
Selecting motion solver: displacementLaplacian
Selecting motion diffusion: inverseDistance
Reading field p

Reading field U

Using dynamicCode for patch inlet on field U
at line 12593 in "/home/anlj/OpenFOAM/anlj-2.0.1/run/tutorials/wingMotion/wingMotion2D_pimpleDyMFoam/0/U::boundaryField::inlet"
Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting turbulence model type RASModel
Selecting RAS turbulence model kOmegaSST
kOmegaSSTCoeffs
{
alphaK1 0.85034;
alphaK2 1;
alphaOmega1 0.5;
alphaOmega2 0.85616;
gamma1 0.5532;
gamma2 0.4403;
beta1 0.075;
beta2 0.0828;
betaStar 0.09;
a1 0.31;
c1 10;
}

Reading field rAU if present


PIMPLE: no residual control data found.
Calculations will employ 2 corrector loops


Starting time loop
....

Best regards, Anders
anlj is offline   Reply With Quote

Old   October 11, 2011, 17:05
Default
  #12
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 anlj View Post
Ok, I tried codedFixedValue on the inlet (which is a patch and not a wall) in the wingMotion tutorial and it works! But if it does not work for walls, why is there an example of a codedFixedValue boundary condition for a movingWall in the C++ documentation of the codedFixedValue?
I don't know. The guys from OpenCFD don't answer on the message board any more, so if you really want an answer you'll have to make a bug-report.

Quote:
Originally Posted by anlj View Post
Still speaking of the wingMotion tutorial; if I want the wing (patch type wall) to move according to user supplied code, I have to find some other way than the codedFixedValue BC? I am confused :S
I personally (but I'm biased) use groovyBC for that kind of stuff. There are cases whee groovyBC has its limits, but not in this case (and it doesn't care whether the patch is a wall)

Quote:
Originally Posted by anlj View Post
Inlet BC (U file):

inlet
{
type codedFixedValue;
value $internalField;
redirectType ramp;
code
#{
(*this)==vector(min(100, 0.1*this->db().time().value()),0,0);
#};
}
That would be the same BC in groovyBC:
Code:
inlet {
    type groovyBC;
    value           $internalField;
    valueExpression "vector(min(100,time()),0,0)";
}
Quote:
Originally Posted by anlj View Post
Output:

Starting time loop
That looks alright, doesn't it?
gschaider is offline   Reply With Quote

Old   October 11, 2011, 19:51
Default
  #13
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

Quote:
Originally Posted by anlj View Post
But if it does not work for walls, why is there an example of a codedFixedValue boundary condition for a movingWall in the C++ documentation of the codedFixedValue?
Just my 2 cents here (since I don't much experience on this particular subject), but my guess is that:
  • a wall BC is like a house;
  • a movingWall BC is like a trailer;
  • but a trailer is not a house both can be homes, but only one is a true house
In other words, they probably designate the movingWall BC to be a special type of patch, similarly to a wedge or a symmetryPlane (if I'm not mistaken).

As for the moving wing, shouldn't it be a mesh motion, not a field motion!?
But if it is meant to be a field motion, then why not set it as a movingWall instead of just wall?

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   October 12, 2011, 08:28
Default
  #14
New Member
 
Anders
Join Date: Nov 2010
Posts: 10
Rep Power: 15
anlj is on a distinguished road
Gents,
Thanks for your replies.

My goal here is to implement a quite advanced control algorithm for the movement of a wall in my simulation (which is not the wingMotion tutorial, I just use that one as a test case) so groovyBC is not an option.

Previously (OF 1.7) I used the timeVaryingUniformFixedValue BC on my moving wall (in the pointDisplacment file) and had the wall moving in a prescribed matter, i.e. a passiv solution. Now I want to switch to the codedFixedValue and have the wall move according to instructions from a control algorithm, i.e. an active solution.

The patch type in the constant/polyMesh/boundary file must be set to WALL, otherwise I can not use turbulnce wall functions on my moving wall since wall functions are made for patch type wall only, and not for patch type patch as well?

When a wall moves, the movingWall BC must be applied on that wall in the U-file as I understand it?

Then in the pointDisplacment file, instead of the sixDOF BC (as in wingMotion tutorial) I want to write my own C++ code. I thought codedFixedValue would let me do that.....

Bruno; did you mean that that codedFixedValue BC is only for fields and can not be used for mesh motion? Is that why it does not work?

Best regards, Anders
anlj is offline   Reply With Quote

Old   October 12, 2011, 16:17
Default
  #15
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Anders,

Quote:
Originally Posted by anlj View Post
Bruno; did you mean that that codedFixedValue BC is only for fields and can not be used for mesh motion? Is that why it does not work?
According to the error message, that's exactly it! codedFixedValue hasn't been implemented on the point displacement solver. It's even a bit ironic, trying to define a dynamic fixed value...

OK, basically said motion solver is explicitly specified in the file "constant/dynamicMeshDict" which states the following interesting code:
Code:
dynamicFvMesh      dynamicMotionSolverFvMesh;

motionSolverLibs ("libfvMotionSolvers.so");

solver            displacementLaplacian;

diffusivity       inverseDistance (wing);
The output you showed us before indicates the same:
Code:
Selecting dynamicFvMesh dynamicMotionSolverFvMesh
Selecting motion solver: displacementLaplacian
If you check the folder "OpenFOAM-2.0.x/src/fvMotionSolver/fvMotionSolvers/displacement", you'll find these:
Code:
componentLaplacian
displacementFvMotionSolver
interpolation
laplacian
layeredSolver
SBRStress
Sooo... this pretty much reinforces the idea that the codedFixedValue doesn't exist yet for point displacement.

Now you have (at least) two options:
  1. Try to (re)make the library yourself, using copy-paste-change/adapt .
  2. Or innocently report this as a bug here: http://www.openfoam.com/mantisbt/my_view_page.php

edit: here's another possibility, shown in the folder "tutorials/basic/potentialFoam/cylinder/constant/polyMesh/blockMeshDict", where it shows how to code the desired text on-the-fly... but I don't know its limitations.
All I know is that OpenFOAM 2.0 keeps blowing my mind... this "#codeStream" business seems pretty powerful!


Best regards,
Bruno
__________________

Last edited by wyldckat; October 12, 2011 at 17:09. Reason: see "edit:"
wyldckat is offline   Reply With Quote

Old   October 17, 2011, 19:49
Default
  #16
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Dear all,

Thanks a lot for the rich info.

I would like to do something similar. I guess from what I've read, and for my case, I will base a point (motionSolver) BC on the timeVaryingUniformFixedValue. Apart from that comes my ignorance-rich question:

In both fvPatch and pointPatch, what is the difference between a fixedValue and a uniformFixedValue BC?

Best regards
Hisham
Hisham is offline   Reply With Quote

Old   March 20, 2012, 09:38
Default
  #17
Senior Member
 
Goutam Saha
Join Date: Dec 2011
Location: UK
Posts: 131
Rep Power: 14
Goutam is on a distinguished road
Dear Hisham

How can I write the codedFixedValue boundary condition for

U(x) = 2 U_0 (1 - x^2 / r^2 ) where U_0 and r are known.

Thanks
Goutam is offline   Reply With Quote

Old   March 20, 2012, 10:39
Default
  #18
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by Goutam View Post
Dear Hisham

How can I write the codedFixedValue boundary condition for

U(x) = 2 U_0 (1 - x^2 / r^2 ) where U_0 and r are known.

Thanks
I guess you should use the groovyBC .... There are many posts about it and a nice Wiki

Nevertheless, it should go something like:

Code:
inlet
{
    type            codedFixedValue;
    value           $internalField;
    redirectType    ramp;
    code
    #{
       scalar U_0 = 5, r = 10; // Values you need
   fixedValueFvPatchField<vector> myPatch(this->Cf().size());
       forAll(this->Cf(), i) { myPatch[i] = vector( 2*U_0*(1 - Foam::pow(this->Cf()[i].x(), 2) / r / r )),0,0); }
      (*this)== myPatch;
   #};         
}
I would appreciate it if anyone can confirm/edit this code

Last edited by Hisham; March 20, 2012 at 11:05.
Hisham is offline   Reply With Quote

Old   March 20, 2012, 12:06
Default
  #19
Senior Member
 
Goutam Saha
Join Date: Dec 2011
Location: UK
Posts: 131
Rep Power: 14
Goutam is on a distinguished road
Dear Hisham,

Thanks for your quick reply. I am using of-2.1.0. Is it possible to use groovyBC in this version? I have checked this but i am confused.

I will try to implement your suggession about the codedFixedValue.

Thanks for your help.
Goutam is offline   Reply With Quote

Old   March 20, 2012, 12:17
Default
  #20
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 Goutam View Post
Dear Hisham,

Thanks for your quick reply. I am using of-2.1.0. Is it possible to use groovyBC in this version? I have checked this but i am confused.

I will try to implement your suggession about the codedFixedValue.

Thanks for your help.
Not the "standalone/oldSchool" groovyBC but the groovyBC that comes with swak4Foam (the 2.x-variant): http://openfoamwiki.net/index.php/Co...am#Downloading
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
Domain Imbalance HMR CFX 5 October 10, 2016 05:57
Can anyone give me some hint on how to make traction free boundary condition? poplar OpenFOAM 3 January 14, 2015 02:37
Boundary Conditions Thomas P. Abraham Main CFD Forum 20 July 7, 2013 05:05
Setting outlet Pressure boundary condition using CAFFA code Mukund Pondkule Main CFD Forum 0 March 16, 2011 03:23
How to set boundary condition in Fluent for the fo Peiyong FLUENT 1 November 10, 2006 11:44


All times are GMT -4. The time now is 12:30.