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

Oscilating cross-wind

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   June 19, 2012, 14:54
Unhappy Oscilating cross-wind
  #1
New Member
 
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 6
crossley90 is on a distinguished road
All OFers,

I am having trouble creating an oscillating cross-wind 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 x-axis) through a box shaped domain and with an additional fluctuating cross-wind (FCW) in the y direction. With my 'time-velocity.txt' file I have created a fluctuating velocity using a sine wave where only y-direction 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 "time-velocity.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 cross-wind results.

type uniformFixedValue;
uniformValue tableFile;
tableFileCoeffs
{
outOfBounds warn;
fileName "time-velocity.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.
crossley90 is offline   Reply With Quote

Old   June 24, 2012, 05:39
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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:
  • The attached case is based on the tutorial "incompressible/pimpleFoam/TJunction".
  • I had to change the pressure boundary conditions, given that I wanted to impose an inlet with velocity.
  • For using, it's the same as usual for OpenFOAM tutorials:
    • ./Allrun for running.
    • ./Allclean for cleaning.
Best regards,
Bruno
Attached Files
File Type: gz TJunctionOsc.tar.gz (3.5 KB, 71 views)
wyldckat is offline   Reply With Quote

Old   June 25, 2012, 03:53
Default
  #3
New Member
 
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 6
crossley90 is on a distinguished road
Excellent, thank you so much for your help.
I just have one minor problem. After running T-junction 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
crossley90 is offline   Reply With Quote

Old   June 25, 2012, 17:30
Default
  #4
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
Attached Files
File Type: gz TJunctionOsc_NoHeader.tar.gz (3.5 KB, 59 views)
wyldckat is offline   Reply With Quote

Old   June 26, 2012, 07:59
Default
  #5
New Member
 
Dave Crossley
Join Date: Oct 2010
Posts: 18
Rep Power: 6
crossley90 is on a distinguished road
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 T-junction 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 time-velocity.txt file also had to be chopped down a lot. Hope this helps identify my annoying problem.

Regards

Dave
Attached Files
File Type: gz 0.tar.gz (852 Bytes, 12 views)
File Type: gz system.tar.gz (4.9 KB, 5 views)
File Type: gz time-velocity.txt.tar.gz (87.7 KB, 16 views)
crossley90 is offline   Reply With Quote

Old   June 26, 2012, 16:57
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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:
  • Install OpenFOAM 2.1.x.
  • Or whenever you want to post-process results, run the following command before (or before you skip to the next time step in) paraFoam:
    Code:
    sed -i -e 's=headerLine=hasHeaderLine=' [0-9]*.*/U
    This way you fix the error in the mentioned files.
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   February 18, 2015, 15:24
Default
  #7
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
Hi Guys,

I know this is an old thread, but I am looking at implementing:

timeVaryingMappedFixedValue in OF-2.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
JackW is offline   Reply With Quote

Old   February 18, 2015, 15:40
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
wyldckat is offline   Reply With Quote

Old   February 18, 2015, 15:58
Default
  #9
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
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
Attached Images
File Type: gif cascade.gif (6.6 KB, 7 views)
JackW is offline   Reply With Quote

Old   February 18, 2015, 17:02
Default
  #10
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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 following you probably already figured out, but since you didn't detail this much, here goes...
The relevant parts of the source code should be as follows:
  1. This method:
    Code:
    void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
    is the one that calculates the 2 time folders to be used for the interpolation.
  2. This method:
    Code:
    void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
    is where it will use the variables "startSampleTime_" and "endSampleTime_" that were calculated in "checkTable()", along with the (linear) time ratio that relates the current time iteration with the other two variables.
  3. If I'm not mistaken, you need to replace the occurrences of this piece of code:
    Code:
    this->db().time().value()
    for something that is in reference to the existing limits. Something like:
    Code:
    scalar limitedTime = this->db().time().value();
    if(limitedTime > sampleTimes_.end())
    {
      limitedTime = limitedTime%sampleTimes_.end();
    }
    where "limitedTime" will now replace the occurrences of the original time value.
Sorry, but today I don't have enough time to test this and to go into more detail. But the idea is that the "%" is the modulo: http://en.wikipedia.org/wiki/Modulo_operation

In addition, you might want to suggest this as a feature here: http://www.openfoam.org/bugs/

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   February 18, 2015, 17:42
Default
  #11
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
Thats brilliant, thanks a lot. I ll post here tomorrow with completed bc hopefully as a useful solution!

Jack
JackW is offline   Reply With Quote

Old   February 18, 2015, 20:20
Default
  #12
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
Hi,

So I have made the modification to the three occurrences:

Code:
this->db().time().value()
to:

Code:
fmod(this->db().time().value(),sampleTimes_[endSampleTime_].value())
(fmod to account for non-integer timesteps, also sampleTimes_.end() returns an iterator object and I wasn't sure on how to get the value.. so went with the above)

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 double-linked 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. CFD-online 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
JackW is offline   Reply With Quote

Old   February 19, 2015, 09:51
Default
  #13
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
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})
Hope the above makes sense, I am not good at explaining myself! I have run through the pipe cyclic tutorial, which seems almost what I want. Basically the not sure bits are where I am now stuck.

{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);
is * overloaded to simulataneously update all components of U?

Thank you very much, your help is greatly appreciated

Jack
JackW is offline   Reply With Quote

Old   February 22, 2015, 10:02
Default
  #14
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,178
Blog Entries: 34
Rep Power: 83
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Jack,

Quote:
Originally Posted by JackW View Post
Ps. CFD-online 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
When in doubt, use DropBox or some other file sharing website
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):
  1. If you created a separate library, then clean up the build you did, by running:
    Code:
    wclean all
    from within your source code folder where you have your custom library. It will delete only the intermediate files needed for generating the final binary.
  2. Then package the source code for the library folder, for example:
    Code:
    tar -czf mycustom_sourcecode.tar.gz mycustomLibrary
  3. Then attach the file "mycustom_sourcecode.tar.gz".
On the other hand, you could have only attached the ".C" and the ".H" files.


Quote:
Originally Posted by JackW View Post
I will before hand run Fourier decomposition of my inlet profile and then try to use codedMixedValue:
I looked at your example/question yesterday and didn't manage to have enough brain power to figure it out. Unfortunately, apparently I didn't get enough rest yet to manage to get my head working with so many abstract notions
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
wyldckat is offline   Reply With Quote

Old   February 23, 2015, 17:37
Default
  #15
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
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);
        #};
Now, I do this for all the variables for say the k omega SST, so Specify U,p,k,omega. Except that the line,
Code:
 Info << "IN K\n\n\n\n" << endl;
is never written to screen, but the value seems to be update ok!? However the same line in the p boundary condition IS written to screen.

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);
        #};
I assume this is a namespace problem, i.e k and omega belonging to turbmodel?? Also, I get errors like:
Code:
*** Error in `reconstructPar': double free or corruption (fasttop): 0x00000000012d15a0 ***
with every app (pimpleFoam, decomposePar,foamToVTK. I think this is a black flag! -- although all apps seem to run but I think there is a problem finding the right bit for k and omega.


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);
    }
Please let me know if I haven't made any sense!? But I am struggling to see my mistake - something odd is going on with the turbulent variables, but p and U seem OK.

Thanks for any help! This is a really powerful BC, but I am not quite using it right yet!

Best regards

Jack
JackW is offline   Reply With Quote

Old   February 23, 2015, 19:26
Default
  #16
Member
 
Jack
Join Date: Aug 2012
Posts: 42
Rep Power: 4
JackW is on a distinguished road
Scratch everything I just said! I realised the redirectType needs to be unique!

Jack
JackW is offline   Reply With Quote

Reply

Tags
crosswind, mappedfixedvalue, oscillation, timevarying

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


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


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