|
[Sponsors] |
|
September 14, 2005, 11:22 |
What is the format of the file
|
#1 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
What is the format of the file in which I can specify nonuniform boundary conditions? can any body give a sample?
Thanks, Maka |
|
September 14, 2005, 11:26 |
// Get index of patch
lab
|
#2 |
Guest
Posts: n/a
|
// Get index of patch
label inletPatchID = mesh.boundaryMesh().findPatchID("topMovingWall"); // Get reference to boundary value const fvPatchVectorField& faceCentreshub = mesh.Cf().boundaryField()[inletPatchID]; fvPatchVectorField& movingWallU = U.boundaryField()[inletPatchID]; // loop over all hub faces forAll(movingWallU, faceI) { // get coordinate for face centre const vector& c = faceCentreshub[faceI]; vector p(0.5*(1+Foam::sin(40*M_PI*c[0]-M_PI/2)), 0, 0); if (c[0]>0.025 &c[0]<0.075) p = vector(1, 0, 0); movingWallU[faceI] = p; } |
|
September 14, 2005, 12:01 |
Hi Chen Jun
I am interest
|
#3 |
Guest
Posts: n/a
|
Hi Chen Jun
I am interested in considering nonuniform boundary conditions in my computations (e.g., a laminar Blasius boundary layer inflow condition along the free stream flow condition). Please can you specify the file name you described and how to use it? thanks |
|
November 5, 2012, 06:01 |
|
#4 |
New Member
Qiong
Join Date: Oct 2012
Posts: 3
Rep Power: 13 |
hi,
I am sorry if I disturb you. do you solve the blasuis boundary condition in OpenFoam? now I am crazy for this problem. Taylor |
|
September 15, 2005, 03:07 |
This thread actually belongs i
|
#5 |
Senior Member
Håkan Nilsson
Join Date: Mar 2009
Location: Gothenburg, Sweden
Posts: 204
Rep Power: 18 |
This thread actually belongs in preprocessing. Anyway, Chen actually describes the basics of how to set your boundary conditions. It is however a bit difficult to understand for a beginner. Let me, as a slightly more than beginner try to help you in a more detailed way (there might be other solutions also):
It is unlikely that there is such a boundary condition already implemented and distributed in OpenFoam. You will have to implement it yourself. This goes at least for less common bc's. A suggestion on how to implement the steady bc (reads 0 and overwrites 0): Step 1: Copy the source directory of the particular solver that you want to use to your personal applications directory. For instance: mkdir ~/OpenFOAM/hani-1.2/applications (if you don't have it) cp -r OpenFOAM/OpenFOAM-1.2/applications/solvers/incompressible/simpleFoam ~/OpenFOAM/hani-1.2/applications/ Step 2: Rename your copied directory to something that makes sence, for instance: mv ~/OpenFOAM/hani-1.2/applications/simpleFoam ~/OpenFOAM/hani-1.2/applications/blasiusBC Rename the .C-file in your blasiusBC directory to blasiusBC.C Edit blasiusBC.C: Insert correct descriptions for Application and Description in the header of the file, for clarity. Remove everything in the main function except the include statements in the beginning. You may later on check which ones you actually need by commenting them and try to compile. The compiler error messages will guide you. Step 3: Implement your bc's using the directives that Chen gave you. This should be located after the include statements in the main function. Write out the variables you have changed at the end of the main function: // Force the write U.write(); k.write(); epsilon.write(); phi.write(); Info<< "\n ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << endl; Info<< "End" << endl; return(0); Step 4: Edit blasiusBC/Make/files to make sure that the filenames blasiusBC is used instead of the name of the original application. Step 5: Compile. Move to your blasiusBC directory and type wmake Step 6: type: rehash to make the executable available. Step 7: Set your bc's by typing: blasiusBC <root> <case> which will change the files in your <root>/<case>/0 directory to include the bc's you defined in blasiusBC. Step 8: Run your case using the solver you need for the application. It will read the 0 directory and get the correct bc's. Good luck! Håkan. |
|
November 6, 2012, 07:47 |
|
#6 | |
New Member
Qiong
Join Date: Oct 2012
Posts: 3
Rep Power: 13 |
Quote:
thank you very much, I use it and works fine, really thank you |
||
September 13, 2013, 12:20 |
|
#7 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
Dear everybody,
In this forum you explain how to implement a non-uniform value as boundary condition. For instance, U=whatever. I need to implement a non uniform temperature gradient as boundary condition. How can I do it? Regards |
|
September 16, 2013, 15:20 |
|
#8 |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
From me you're going to hear "groovyBC". Others will tell you "coded". Second is with C++-programming, first without
__________________
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 19, 2013, 05:45 |
|
#9 |
Member
Zacarias Carral
Join Date: Sep 2012
Posts: 35
Rep Power: 13 |
Dear Bernard,
I agree that "groovyBC" is an option but perhaps there is a way to program a non uniform temperature gradient. Does anybody know how to program it? |
|
February 12, 2014, 06:04 |
|
#10 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
Dear everybody,
I am using groovyBC to set the boundary condition gradT=2*x I have written this code: top { type groovyBC; gradientExpression "gradT"; fractionExpression "0"; variables "gradT=2*mesh.C().component(vector::X);"; timelines ( ); } And I have the following error: --> FOAM FATAL ERROR: Parser Error at "1.3-6" :"field mesh not existing or of wrong type" "2*mesh.C().component(vector::X)" " ^^^^ " From function parsingValue in file lnInclude/CommonValueExpressionDriverI.H at line 802. FOAM exiting How can I call x coordinate using groovyBC? |
|
February 13, 2014, 07:08 |
|
#11 |
Senior Member
isabel
Join Date: Apr 2009
Location: Spain
Posts: 171
Rep Power: 17 |
Problem solved. This is the correct code:
top { type groovyBC; gradientExpression "gradT"; fractionExpression "0"; variables "gradT=2*pos().x;"; timelines ( ); } |
|
September 16, 2005, 07:37 |
Thanks all. Many thanks Hakan
|
#12 |
Senior Member
Maka Mohu
Join Date: Mar 2009
Posts: 305
Rep Power: 18 |
Thanks all. Many thanks Hakan for the detailed steps. It is very helpful.
Regards, Maka |
|
September 16, 2005, 10:08 |
Thanks Hakan for the detailed
|
#13 |
Guest
Posts: n/a
|
Thanks Hakan for the detailed explications.
|
|
October 13, 2005, 11:44 |
Francois
I'll have a go at
|
#14 |
New Member
Hilary Spencer
Join Date: Mar 2009
Location: Reading, Berkshire, UK
Posts: 1
Rep Power: 0 |
Francois
I'll have a go at answering _some_ of your questions. > Here are my questions: > > * is c[1] is the second component of the vector c on faceI ? Yes! C and C++ arrays start at zero and (in OpenFOAM) go to size()-1 > * What are the differences between those two objects and two methods > (C() and Cf()) of the mesh class: In fvMesh.H it says: //- Return cell centres as volVectorField const volVectorField& C() const; //- Return face centres as surfaceVectorField const surfaceVectorField& Cf() const; > * Finaly if I want to read an experimental profile of the x component > of the velocity Ux=f(y) which is in a file and interpolate those > values on the mesh to apply them on the x component of my inlet > boundary velocity field. Is it easy or not ? This may not be the easiest or most accurate solution - you could create a 1d mesh with cell centres at the locations of your experimental profile. The Ux data could then be the experimental data you could then create another case with a 1d mesh the same as your boundary of your (2d?) case you could then use mapFields to interpolate from the first mesh to the second then copy the interpolated data to the boundary condition of your 2d case (assuming the mesh is numbered in the same way for both - you'll have to make sure of this when you generate the 1d mesh) > PS: more a C++ question, please don't laugh !!! > Why is there sometimes an & (like after VectorField) and sometimes > not (like scalarField) Now this is a REALLY good question. One it took me AGES to understand when there is an & after a name of a class it means that you are not creating a new one, you are just referring to one that all ready exists. It is therefore a reference Example int i = 0; int& j = i; // j refers to i. No new data is created j = 2; // actually sets i = 2 also |
|
October 13, 2005, 11:58 |
Tanks Hilary for your help wit
|
#15 |
Senior Member
Francois Beaubert
Join Date: Mar 2009
Location: Lille, France
Posts: 147
Rep Power: 17 |
Tanks Hilary for your help with OpenFOAM and C++ !
I will study this problem carefully ... it's like an adventure for me ... Have a nice day. Francois |
|
December 13, 2005, 14:28 |
Hello!
I'm trying to implemen
|
#16 |
New Member
Aurelia Cure
Join Date: Mar 2009
Location: Lund, Sweden
Posts: 18
Rep Power: 17 |
Hello!
I'm trying to implement non uniform bc at the inlet, following the step by step method of Håkan (thank you, by the way ) i compile with wmake, it seems to work then the command rehash doesn't exist and finaly, when i do step7, it doesn't change the values in the 0 directory i suppose it's due to many mistake in c++ so i will be happy if one of you could take time to help me and check it here is what i wrote in the main of the .c file, after all the include / Get index of patch label inletPatchID = mesh.boundaryMesh().findPatchID("inlet"); // Get reference to boundary value fvPatchVectorField& inletU = U.boundaryField()[inletPatchID]; // get coordinate for cell centre const fvPatchVectorField& centre = mesh.C().boundaryField()[inletPatchID]; scalarField y = centre.component(vector::Y); scalarField x = centre.component(vector::X); // calculate inlet velocity inletU = y*0.75/0.0051*vector (1,0,0)+x*0.75/0.0051*vector(0,1,0)+7.5*vector(0,0,1); U.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s\n\n" << endl; Info<< "End\n" << endl; return(0); } thanks aurelia |
|
December 14, 2005, 04:22 |
In the statements:
// calcu
|
#17 |
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33 |
In the statements:
// calculate inlet velocity inletU = y*0.75/0.0051*vector (1,0,0)+x*0.75/0.0051*vector(0,1,0)+7.5*vector(0,0,1); try doing inletU == ...; (the rest is the same). I suspect your boundary condition for this patch is fixedValue. Hrv
__________________
Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk |
|
December 17, 2005, 13:59 |
Can we get a tutorial out of t
|
#18 |
Guest
Posts: n/a
|
Can we get a tutorial out of this? I'm also new to both Foam and C++ and interested in learning...
|
|
January 4, 2006, 09:52 |
Hi,
I tried to implement th
|
#19 |
Senior Member
Fabian Braennstroem
Join Date: Mar 2009
Posts: 407
Rep Power: 19 |
Hi,
I tried to implement the version from aurelia. The compilation went fine, but applying the profile to an existing case in turbFoam I get: ... Reading field U --> FOAM FATAL IO ERROR : size 3 is not equal to the given value of 2438 file: turbFoam/smc/0/U::INLET from line 36 to line 42. From function Field<type>::Field(const word& keyword, const dictionary& dict , const label s) in file /home/fab/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/Field.C at li ne 225. FOAM exiting I adjusted 'inletPatchID' to the existing 'INLET' in my case. Would be nice, if anybody has an idea! Greetings! Fabian |
|
May 3, 2008, 10:31 |
Some time ago already, however
|
#20 |
Senior Member
Mark Couwenberg
Join Date: Mar 2009
Location: Netherlands
Posts: 130
Rep Power: 17 |
Some time ago already, however I am experiencing the same problem. The error from Fabian is however caused by the fact that (probably) the 0/U file has non-uniform and three lines of vectors in it already, while the field is supposed to have 2438 faces and thus 2438 entries.
I think you have to include initContinuityErrs.H However, even after this I am still not able to get things work. Changes are made to the internalFieldValues but not to boundary patches. Any comments? Once I succeed I will return with results. Brgds, Mark |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Specifying nonuniform initial condition | msyaml | OpenFOAM Running, Solving & CFD | 65 | April 25, 2016 04:23 |
Nonuniform initial condition using cellSetDict | rinao | OpenFOAM Running, Solving & CFD | 6 | January 9, 2013 00:42 |
Nonuniform boundary syntax | juho | OpenFOAM Running, Solving & CFD | 1 | December 11, 2008 16:13 |
Set nonuniform boundary values | nikwin | OpenFOAM Running, Solving & CFD | 1 | November 30, 2008 07:12 |
Nonuniform gradient boundary condition | ankgupta8um | OpenFOAM Running, Solving & CFD | 1 | March 14, 2006 01:34 |