
[Sponsors] 
June 19, 2012, 14:54 
Oscilating crosswind

#1 
New Member
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 7 
All OFers,
I am having trouble creating an oscillating crosswind velocity over my wing. I used to be able to use 'timeVaryingUniformInletOutlet' but since the update this has changed. I have found this OF site (below) to help guide me but it doesn't quite appear to be working. http://www.openfoam.org/version2.1.0...conditions.php My Case I am trying to keep a constant velocity of 5m/s (through xaxis) through a box shaped domain and with an additional fluctuating crosswind (FCW) in the y direction. With my 'timevelocity.txt' file I have created a fluctuating velocity using a sine wave where only ydirection velocity changes e.g.(5 FCW 0) so OF can model exactly the velocity I require at each time step. Below is the original BC: type timeVaryingUniformInletOutlet; value uniform (5 0 0); outOfBounds warn; fileName "timevelocity.txt" Attempts Using the above web link I can't quite work out how the BC is setup or if there is an alternative method to gain the same crosswind results. type uniformFixedValue; uniformValue tableFile; tableFileCoeffs { outOfBounds warn; fileName "timevelocity.txt"; }; I have also tried 'oscillatingFixedValue' but I get double Scalar errors, also I have tried some of the mapping BCs but again they don't quite work for me. For instance the BC requires additional 'points' in the constant/boundaryData/inlet folder (I am not sure how to do this/what points it requires). I would very much appreciate some advice as I am struggling on this reasonably simple problem. Thank you in advance. 

June 24, 2012, 05:39 

#2 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Greetings Dave,
Navein asked me about this very same question the other day and I said then I would answer here... so here it is:
Bruno
__________________


June 25, 2012, 03:53 

#3 
New Member
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 7 
Excellent, thank you so much for your help.
I just have one minor problem. After running Tjunction and opening paraFoam I get this error. > FOAM FATAL IO ERROR: keyword hasHeaderLine is undefined in dictionary "/home/david/Desktop/TJunctionOsc/0.1/U::boundaryField::inlet::csvFileCoeffs" file: /home/david/Desktop/TJunctionOsc/0.1/U::boundaryField::inlet::csvFileCoeffs from line 3909 to line 3913. From function dictionary::lookupEntry(const word&, bool, bool) const in file db/dictionary/dictionary.C at line 400. FOAM exiting Segmentation fault The error is clearly due to 'hasHeaderLine' line but this is required to identify the header line (as you well know). Any ideas? I am currently running in OF v2.1, hopefully it's not a version problem as it is not practical to upgrade right now. thanks again David 

June 25, 2012, 17:30 

#4 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Hi David,
I saw your bug report: http://www.openfoam.org/mantisbt/view.php?id=564 I've checked and indeed this has already been fixed in OpenFOAM 2.1.x. Attached is a case without the header line in the CSV file. You can always do this the other way around: use a CSV with a header line! Best regards, Bruno
__________________


June 26, 2012, 07:59 

#5 
New Member
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 7 
Hi Bruno,
I'm not sure what's going on, so far I am still coming across errors regarding the 'HeaderLine'. My first issue is the following. I have ran your Tjunction with and without a header but when I move to the next time step in paraFoam the software crashes relaying an error of (after selecting 'U' and 'surface'): > FOAM FATAL IO ERROR: keyword hasHeaderLine is undefined in dictionary "/home/david/Desktop/TJunctionOsc_NoHeader/0.1/U::boundaryField::inlet::csvFileCoeffs" file: /home/david/Desktop/TJunctionOsc_NoHeader/0.1/U::boundaryField::inlet::csvFileCoeffs from line 3909 to line 3913. From function dictionary::lookupEntry(const word&, bool, bool) const in file db/dictionary/dictionary.C at line 400. FOAM exiting Could you confirm that this is the case your end? My second issue is my oscillating case, I have set my case up with your help but again the HeaderLine keeps giving me errors when I decompose (with and without headers). Do you think I have made a BC error or is it a bad installation of OF? Attached is my current case. Constant folder was too big and my timevelocity.txt file also had to be chopped down a lot. Hope this helps identify my annoying problem. Regards Dave 

June 26, 2012, 16:57 

#6 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Hi Dave,
OK, the problem is this: OpenFOAM 2.1.0 has this bug, while the latest 2.1.x (git repository version) does not have this bug. I haven't checked OpenFOAM 2.1.1. You have two possible fixes:
Bruno
__________________


February 18, 2015, 15:24 

#7 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Hi Guys,
I know this is an old thread, but I am looking at implementing: timeVaryingMappedFixedValue in OF2.3.0 for incoming turbulent wakes (ux,uy,k,omega profiles required) being translated vertically. (I have the profiles I want.) I have used timeVaryingMappedFixedValue to provide a spatial profile, i.e. by just specifying the profile in 0. My question is regarding how I could loop through time directories 0, 1, ..., T then return to 0 and loop back through (i.e. the uniformFixedValue behaviour for the out of bounds repeat). (Whilst the profiles are linearly interpolated between 0 and 1 when 0<t<1 etc. Is there a way to do this? Any help towards the correct BC would be great. Thanks Jack 

February 18, 2015, 15:40 

#8 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Greetings Jack,
Sorry, but I read your post twice, but I still can't figure out what exactly what you're trying to do, where and why From your description, my guess is that without an image explaining what you're trying to do, I won't be able to figure it out Or at least a practical example. Best regards, Bruno
__________________


February 18, 2015, 15:58 

#9 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Hi, thanks for the response,
I think the answer I am looking for is quite simple, I just wanted to know if there was a neat way of doing it... I have a profile which I want to prescribe at the inlet and then translate it vertically. However after a given time it resets to its initial position. (The actual profile is coming from moving bars in a linear turbine cascade and is serving as an inlet to my simulation  I have attached an image to the kind of geometry I am imitating  the bars are outside of my domain and the inflow of my simulation is the moving wakes from these. Playing with the timeVaryingMappedFixedValue I see that it linearly(?) interpolates the values between two time directories, but I would like a reset option (without having to write out every timestep, as the speed of the bars (and hence the time directories of any reset) depend on the inflow velocity which I will have to find by running the case iteratively. Thanks a lot Jack 

February 18, 2015, 17:02 

#10 
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Hi Jack,
OK, the few neurons that are still working properly in my head at this time of the night, have finally managed to figure it out what you mean and want to do! If the interpolation was done with the "uniformFixed" boundary condition, I think it already has this feature. Problem is that this boundary condition "timeVaryingMappedFixedValue" doesn't have this feature. You'll need to create a new boundary condition (or modify the current one, if you feel lucky ) based on the source code folder indicated by this command: Code:
echo $FOAM_SRC/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/ The relevant parts of the source code should be as follows:
In addition, you might want to suggest this as a feature here: http://www.openfoam.org/bugs/ Best regards, Bruno 

February 18, 2015, 17:42 

#11 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Thats brilliant, thanks a lot. I ll post here tomorrow with completed bc hopefully as a useful solution!
Jack 

February 18, 2015, 20:20 

#12 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Hi,
So I have made the modification to the three occurrences: Code:
this>db().time().value() Code:
fmod(this>db().time().value(),sampleTimes_[endSampleTime_].value()) I now think this boundary condition will do what I want it to do, so thank's a lot! (It will break if 0 is not the start of the modulo period, but defining carefully the boundary data should clear it up. There is now however a problem at runtime  but for just the last time step: *** Error in `simpleFoam': corrupted doublelinked list: 0x0000000001b16200 *** [1] 20669 abort (core dumped) simpleFoam I have attached both the BC (should anyone want it) and the pitzdaily case (only modified bc for U) > I added AverageIO to the Make folder, largely just because it was there  but on removal of AverageIO the error went away. Bit confused by that, but hey. Thanks Jack Ps. CFDonline is not allowing me to attach stuff. So will do so when I have further tested it in the situation that I want to apply it in 

February 19, 2015, 09:51 

#13 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Dear Bruno,
Sorry for the pestering. I think I have a better solution now, I would just like to confirm! I will before hand run Fourier decomposition of my inlet profile and then try to use codedMixedValue: e.g. Code:
code #{ scalar a_i = x_1; // known from a priori fourier decomp. ... scalar a_n = x_n; scalar c = cons; // speed of wave scalar L = cons; // length of domain {NOT SURE 1 (U)} = a_i * cos(constant::mathematical::twoPi * {NOT SURE 2 (y)}  c * db().time().value())/L) + (similar sin term); operator==({NOT SURE 3}) {NOT SURE 1 (U)} is the velocity for the patch, which is a function of y and t. {NOT SURE 2} is the y coordinate of the patch and {NOT SURE 3} is how to update it. Also the a_i coefficients will be different for u,v & w, so if I specify e.g. Code:
vector a_i(v1,v2,v3); Thank you very much, your help is greatly appreciated Jack 

February 22, 2015, 10:02 

#14  
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Hi Jack,
Quote:
But my guess is that you didn't follow "protocol" (which honestly, I do have plans to write about, but simply haven't managed to get to it):
Quote:
I believe that if you formulate at least the full mathematical concept of what you're trying to implement, both of us (you and me) would very likely have an easier task on translating it to source code. Best regards, Bruno 

February 23, 2015, 17:37 

#15 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Dear Bruno,
After a little bit of work and useful direction, I think I am almost there... In terms of the maths I am all set, the basic idea is to take a points profile for U,k,omega & p and write them all as sums of cosines and sines by using python before hand: Code:
code #{ //This file was writing by setupInletBoundary.py //Save on fileIO later fixedValueFvPatchField<scalar> myPatch(*this); scalar L = 0.799000; scalar vbar = 0.422; int numModes = 20; double a[20] = { 0.018350, 0.000013, ...., // not sure if I can post these online (the original profiles are a companies property) 0.000032 }; double b[20] = { 1.000000, 0.000784, ..., // Not sure if I can post these online 0.000002 }; forAll(this>patch().Cf(),i) { myPatch[i] = 0; for(int iter=0;iter<numModes;iter++){ myPatch[i] += scalar ( a[iter]*cos( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) + b[iter]*sin( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) ); } }; Info << "IN K\n\n\n\n" << endl; operator==(myPatch); #}; Code:
Info << "IN K\n\n\n\n" << endl; A BIGGER problem at the moment is that k and omega are IDENTICAL, despite using two different pieces of code: Code:
code #{ //This file was writing by setupInletBoundary.py //Save on fileIO later fixedValueFvPatchField<scalar> myPatchO(*this); scalar L = 0.799000; scalar vbar = 0.422; int numModes = 20; double ae[20] = { ... }; double be[20] = { ... }; double ak[20] = { ... }; double bk[20] = { ... }; forAll(this>patch().Cf(),i) { scalar k = scalar(0); scalar eps = scalar(0); for(int iter=0;iter<numModes;iter++){ k += scalar ( ak[iter]*cos( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) + bk[iter]*sin( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) ); eps += scalar ( ae[iter]*cos( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) + be[iter]*sin( iter * constant::mathematical::twoPi * (this>patch().Cf()[i].y()  vbar*db().time().value() )/L ) ); } Info << "\n\n\n\n" << eps << " " << k << endl; // NOT WRITTEN myPatchO[i] = eps / (0.09 * k); }; operator==(myPatchO); #}; Code:
*** Error in `reconstructPar': double free or corruption (fasttop): 0x00000000012d15a0 *** Will it matter that in the 0/ folder I am doing (including it): Code:
inflow { type codedFixedValue; redirectType ramp; // what are the point of these options!? #include "../constant/boundarySetup/codedU.bc" value uniform (0.745 0.708 0); } Thanks for any help! This is a really powerful BC, but I am not quite using it right yet! Best regards Jack 

February 23, 2015, 19:26 

#16 
Member
Jack
Join Date: Aug 2012
Posts: 44
Rep Power: 6 
Scratch everything I just said! I realised the redirectType needs to be unique!
Jack 

August 3, 2015, 23:58 

#17 
New Member
ravi
Join Date: Nov 2013
Posts: 10
Rep Power: 4 
Hi Guys,
My question is similar to the one asked here. At different % of radius, I want to hook radial, tangential, axial velocities and turbulent kinetic energy and turbulent eddy dissipation values. Somebody pls help me in making use of "myDataFile" approach as my data contains 50 rows. Encountered an error even after trying as suggested by "wyldckat" in this link: http://www.cfdonline.com/Forums/ope...rosswind.html [^]. I am using openfoam 2.4.0  > FOAM FATAL IO ERROR: keyword uniformValueCoeffs is undefined in dictionary "/home/cfd11/TJunctionOsc/0/U.boundaryField.inlet" file: /home/cfd11/TJunctionOsc/0/U.boundaryField.inlet from line 25 to line 34. From function dictionary::subDict(const word& keyword) const in file db/dictionary/dictionary.C at line 648. FOAM exiting  [ Moderator note: moved from how to define velocity for a circular inlet from a file ] Last edited by wyldckat; August 16, 2015 at 14:31. Reason: see "Moderator note" 

August 16, 2015, 14:29 

#18  
Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,651
Blog Entries: 39
Rep Power: 99 
Attached is the file "TJunctionOsc24.tar.gz" which has the case updated for OpenFOAM 2.4, in reference to the following quoted post:
Quote:


Tags 
crosswind, mappedfixedvalue, oscillation, timevarying 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
simulating wind shear profile for a wind turbine> How???  mohammad  CFX  14  August 25, 2014 09:09 
FSI  Wind Turbine  AUN  CFX  13  August 29, 2012 16:44 
simulating wind shear profile for a wind turbine> How???  mohammad  FLUENT  0  April 14, 2012 23:54 
Simulate the wind profile on a wind turbine> HOW ????  mohammad  Main CFD Forum  0  April 13, 2012 08:07 
Macro fan modeling considering cross wind effect  microfin  FLUENT  0  January 1, 2012 04:07 