
[Sponsors] 
January 18, 2012, 05:47 
funkySetBoundaryFields  Manipulation of existing field

#1 
New Member
Julian Hertel
Join Date: Dec 2011
Posts: 4
Rep Power: 6 
Hi everybody,
I would like to set a complex boundary condition at my Inlet (simple rectangular patch) with the funkySetBoundaryField utility. Instead of implementing an analytical expression depending on the spacial parameters pos().x and pos().y, I would like to manipulate an existing field. Actually, the implemented velocity field at the Inlet should represent a complex flow field of a fan. I therefore interpolated experimental data over the whole inlet. There are, however, additional effects on the flow field caused by the fan blades I cant display by a simple interpolation. Thats why I wanted to run the funkySetBoundaryField utility over the interpolated velocity field at the inlet. According to the contrib description of the funkySetField utility on the wiki page it should be possible to manipulate existing fields: "All the fields in the current timestep can be used. If the field is also the target field the old value is used. Then the field is written using the new value." So, does anybody know how to call by an "OldField value" within an expression? Such as pos().x is the syntax for the x position of the cell center. Thanks! 

January 23, 2012, 12:29 

#2  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:


February 12, 2012, 08:39 

#3 
New Member
Julian Hertel
Join Date: Dec 2011
Posts: 4
Rep Power: 6 
Thank you very much for your reply gschaider. Using the variable p in an expression works fine but unfortunately it doesnīt work with the variable U. The error message is that I use a non scalar value when I use e.g. the following expressions: "mag(U)" or "2*U". Isnīt the mag() function supposed to work for vector values as well as scalar values? And anyway there shouldnīt be any problem with the expression "2*U", which is just a scalar multiplication. Any ideas?


February 13, 2012, 06:58 

#4  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:
"mag(U)" should evaluate to a scalar. "2*U" to a vector. Could you please post the funkySetBoundaryFieldDict (or whatever is the exact name)? 

February 14, 2012, 14:00 

#5  
New Member
Julian Hertel
Join Date: Dec 2011
Posts: 4
Rep Power: 6 
Quote:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 1.7.1   \\ / A nd  Web: www.OpenFOAM.com   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // velocities { field U; expressions ( //NOT working { target value; patchName INLET; expression "2*U"; } //Working // { // target value; // patchName INLET; // expression "pos().x>0.11 && pos().x<0.1583 ? vector(0.0,0.0,1.0) : vector(0.0,0.0,0.0)"; // } ); } ERROR MESSAGE: > FOAM FATAL ERROR: No field of type scalar with the name "U" found 

February 14, 2012, 19:25 

#6  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:


February 26, 2012, 14:44 
Problem using funky . . .

#7  
Member

Dear Bernard
Hi I edit the funkysetboundaryfield to implement a simple velocity profile whatever I write it faces a parser error. could you please tell me what to do? Here is its dictionary: PHP Code:
Quote:


February 26, 2012, 18:24 

#8  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:


February 28, 2012, 10:19 

#9 
New Member
Julian Hertel
Join Date: Dec 2011
Posts: 4
Rep Power: 6 
After the fix the expressions work totally fine now. Thanks a lot!!!


September 24, 2012, 10:58 

#10 
Member

Hello Bernard
I'm using funkysetfields to initialize a field with 4 different conditional statements, imagine a cylinder with four quadrants: Code:
magnetic_1o_quadrant { field B; expression "vector(1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*sin(atan(pos().y/pos().x)),1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*cos(atan(pos().y/pos().x)),0)"; condition "pos().z <= 0.12 && pos().x > 0 && pos().y >=0"; } magnetic_2o_quadrant { field B; expression "vector(1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*sin(atan(pos().y/pos().x)+pi),1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*cos(atan(pos().y/pos().x)+pi),0)"; condition "pos().z <= 0.12 && pos().x <= 0 && pos().y >0"; } magnetic_3o_quadrant { field B; expression "vector(1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*sin(atan(pos().y/pos().x)pi),1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*cos(atan(pos().y/pos().x)pi),0)"; condition "pos().z <= 0.12 && pos().x < 0 && pos().y <0"; } magnetic_4o_quadrant { field B; expression "vector(1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*sin(atan(pos().y/pos().x)+2*pi),1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*cos(atan(pos().y/pos().x)+2*pi),0)"; condition "pos().z <= 0.12 && pos().x > 0 && pos().y < 0"; } Code:
{ target value; patchName inlet; expression "(pos().z <= 0.12 && pos().x > 0 && pos().y >=0) ? vector(1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*sin(atan(pos().y/pos().x)),1.069/sqrt(pos().x*pos().x+pos().y*pos().y)*cos(atan(pos().y/pos().x)),0): vector (0,0,0)";//1st quadrant } Thanks, Carlos 

September 24, 2012, 13:19 

#11  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:
Your problem is that there is no conditionsentry. I didn't add this as it would add some subtle problems if the entry is not currently present. There are two solutions I could think of. One would be a monster expression for all four quadrants. This is a sketch: "pos().x>0 ? (pos().y>0 ? v1 :v2) : (pos().y>0 ? v3 : v4)" (maybe variables can ease the pain here) The other possibility would be a sequence of expressions where you use the value of the field (but this would only work for the valueentry): "pos().x>0 && pos().y>0 ? v1 : vector(0,0,0)" "pos().x>0 && pos().y<=0 ? v2 : U" "pos().x<0 && pos().y>0 ? v3 : U" "pos().x<0 && pos().y<=0 ? v4 : U" But I'm not sure whether the field would have to be written to disc for this to work (or whether the cachecommandlineoption is needed)
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

September 24, 2012, 14:42 

#12 
Member

Sorry Bernard, yes the second one is for funkysetboudary.
Thank you very much for your help. Carlos 

July 25, 2013, 07:47 
Hello,

#13 
New Member
Federica Farisco
Join Date: Jul 2013
Posts: 2
Rep Power: 0 
Code:
/** C++ **\  =========    \\ / F ield  OpenFOAM: The Open Source CFD Toolbox   \\ / O peration  Version: 1.7.1   \\ / A nd  Web: www.OpenFOAM.com   \\/ M anipulation   \**/ FoamFile { version 2.0; format ascii; class dictionary; location "system"; object controlDict; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // velocityswirl { field U; expressions ( { target value; patchName inlet; variables "rpm=1000.0;Un=10;c=sum(pos()*mag(Sf()))/sum(mag(Sf()));n=sum(normal())/mag(sum(normal()));n=sum(normal())/mag(sum(normal()));p=pos()c;r=mag(pos()vector(0,0,1))+1.0e10;R=max(r);xt=vector(0,n.z,n.y);xT=xt/mag(xt);yt=vector(n.y*n.y+n.z*n.z,n.x*n.y,n.x*n.z);yT=yt/mag(yt);"; expression "Un*normal() + (rpm*pi/30)*(((pos()c) & yT)*xT((pos()c) & xT)*yT)"; } ); } //!!! in "variables" do not leave any space between the definitions of two variables and in "espression" try to replace the name of few variables with their definitions !!! //!!! c=sum(pos()*mag(Sf()))/sum(mag(Sf())) works just for full patches; for other cases you have to set it manually !!! Last edited by FedericaF; July 25, 2013 at 08:03. Reason: I used funkySetBoundary to generate a swirl flow in the inlet patch of a cylinder sector and it works. 

July 25, 2013, 08:33 

#14  
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,915
Rep Power: 40 
Quote:
__________________
Note: I don't use "Friend"feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request 

March 18, 2015, 08:58 
setup funkySetBoundaryDict

#15 
New Member
sammasum
Join Date: May 2014
Posts: 5
Rep Power: 3 
Hi,
I have modified the funkySetBoundaryDict for my problem and it is in the 'system' folder. but my program is not reading it. I have groovyBC installed and that works fine. I wonder if I have to add something like 'libsgroovyBC.so' in the controlDict file for the funkySetBoundary. Please suggest. Many thanks 

March 19, 2015, 09:42 
define Neumann boundary in funkySetBoundaryFiled

#16 
New Member
sammasum
Join Date: May 2014
Posts: 5
Rep Power: 3 
Hi,
How should I set up Neumann boundary condition using funkySetBounaryField? It seems like taking only Dirichlet boundary. Thanks 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
problems after decomposing for running  alessio.nz  OpenFOAM  6  December 23, 2015 15:27 
Phase Field modeling in OpenFOAM  adona058  OpenFOAM Running, Solving & CFD  25  November 22, 2015 16:50 
Moving mesh  Niklas Wikstrom (Wikstrom)  OpenFOAM Running, Solving & CFD  122  June 15, 2014 06:20 
Internal field manipulation on runtime  Martin123  OpenFOAM Running, Solving & CFD  2  June 3, 2009 18:11 
Problem with rhoSimpleFoam  matteo_gautero  OpenFOAM Running, Solving & CFD  0  February 28, 2008 07:51 