What is the format of the file
What is the format of the file in which I can specify nonuniform boundary conditions? can any body give a sample?
Thanks, Maka |
// Get index of patch
lab
// 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; } |
Hi Chen Jun
I am interest
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 |
This thread actually belongs i
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. |
Thanks all. Many thanks Hakan
Thanks all. Many thanks Hakan for the detailed steps. It is very helpful.
Regards, Maka |
Thanks Hakan for the detailed
Thanks Hakan for the detailed explications.
|
Francois
I'll have a go at
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 |
Tanks Hilary for your help wit
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 |
Hello!
I'm trying to implemen
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 |
In the statements:
// calcu
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 |
Can we get a tutorial out of t
Can we get a tutorial out of this? I'm also new to both Foam and C++ and interested in learning...
|
Hi,
I tried to implement th
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 |
Some time ago already, however
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 |
Ok, I finally get it working.
Ok, I finally get it working. A small utility that is able to set nonuniform boundary conditions. For my case it is programmed to set gamma at 1 if Z coordinate is <0>0. However, users will be able to modify themselve.
The code is based on snippets found on this forum and very much resembles snippets in this thread. however 1 to 1 copying failed in my case. So here the full directory. hope it is useful for others. attach{setBoundarygamma} Brgds, Mark |
Lets try WITH attachment this
Lets try WITH attachment this time
http://www.cfd-online.com/OpenFOAM_D...hment_icon.gif setBoundarygamma.zip |
Hi guys,
I'm trying to crea
Hi guys,
I'm trying to create a custom bc as told here, but I'm stuck. I want to set the values of U, k and epsilon at the inlet, but when I try to compile, it throws the folowing errors: Quote:
Ravi |
Hi,
The kEpsilon.H has the
Hi,
The kEpsilon.H has the following declarations: //- Return the turbulence kinetic energy tmp<volscalarfield> k() const //- Return the turbulence kinetic energy dissipation rate tmp<volscalarfield> epsilon() const But it seems that refers to cell volume values. I need the face values. Searching in the files (solvers) I found something like that: fvVectorMatrix divR = turbulence->divDevReff(U); and I think that what I'm looking for is something like this. Ravi |
Hi Ravi,
If you'll attach the
Hi Ravi,
If you'll attach the sources to your post, maybe someone will have a look at it, otherwise we can at most speculate the source of your error. Dragos |
dear all,
I have a simple g
dear all,
I have a simple geometry, which I model as a 2-phase liquid flow with interFoam solver. So far I have set boundary conditions manually using a text editor but it's just easier to have a function via command line at hand in order to do so. Thus I followed the thread by on setBoundaryGamma and worked myself through it: 1. Using the instructions by Håkan Nilsson I copied the interFoam directory, renamed the files and applied my changes 2. Everything compiles with wmake 3. While executing setBoundaryGamma <patchname> from the project directory I receive the following error: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #0 Foam::error::printStack(Foam:http://www.cfd-online.com/OpenFOAM_D...part/proud.gifstream&) in "/home/schoeller/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #1 Foam::sigSegv::sigSegvHandler(int) in "/home/schoeller/OpenFOAM/OpenFOAM-1.5/lib/linuxGccDPOpt/libOpenFOAM.so" #2 Uninterpreted: [0xb809b400] #3 std::basic_string<char,>, std::allocator<char> >::basic_string(std::string const&) in "/home/schoeller/OpenFOAM/ThirdParty/gcc-4.3.1/platforms/linux/lib/libstdc++.so. 6" #4 main in "/home/schoeller/OpenFOAM/OpenFOAM-1.5/applications/bin/linuxGccDPOpt/setBoundar yGamma" #5 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6" #6 _start in "/home/schoeller/OpenFOAM/OpenFOAM-1.5/applications/bin/linuxGccDPOpt/setBoundar yGamma" Segmentation fault Does anybody have an idea why this could be? * interFoam as a solver works fine with the case * 'which gcc' tells me that it is using the compiler version from ThirdParty directory The source code I used is as follows: \*---------------------------------------------------------------------------*/ #include "fvCFD.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { argList::validArgs.append("patchName"); # include "setRootCase.H" word patchName(args.args()[3]); # include "createTime.H" # include "createMesh.H" # include "createFields.H" # include "initContinuityErrs.H" Info<< "This utility initializes gamma values for boundary patches based on" <<endl; Info<<>=0 ==>gamma=0, z<o>gamma=1." <<endl; Info<< "These settings are presently only changeable by modifying the source code." <<endl; Info<< "Source code to be found in: OF/user/applications." <<endl; Info<< "Change code (.C file) according your needs and in that directory run wmake." <<endl; Info<< "\nStarting time loop\n" << endl; // Get index of patch label inletPatchID = mesh.boundaryMesh().findPatchID(patchName); // Get reference to boundary value //const fvPatchVectorField& centre = mesh.C().boundaryField()[inletPatchID]; const fvPatchVectorField& faceCentreshub = mesh.C().boundaryField()[inletPatchID]; //const fvPatchVectorField& faceCentreshub = mesh.Cf().boundaryField()[inletPatchID]; //Uncomment the line for your case: U for velocity cases, gamma for gamma cases //fvPatchVectorField& Inlet = U.boundaryField()[inletPatchID]; fvPatchScalarField& targetPatch = gamma.boundaryField()[inletPatchID]; // loop over all hub faces forAll(targetPatch, faceI) { // get coordinate for face centre //const vector& c = centre[faceI]; const vector& c = faceCentreshub[faceI]; //vector p(0.5*(1+Foam::sin(40*M_PI*c[0]-M_PI/2)), 0, 0); // c[0] is X coordinate, c[1] is Y coordinate, c[2] is Z coordinate // Apply boundary condition based in one coordinate (X, Y, or Z). if (c[1] < 0.3) //if true: below watersurface // loop over all hub faces forAll(targetPatch, faceI) { // get coordinate for face centre //const vector& c = centre[faceI]; const vector& c = faceCentreshub[faceI]; //vector p(0.5*(1+Foam::sin(40*M_PI*c[0]-M_PI/2)), 0, 0); // c[0] is X coordinate, c[1] is Y coordinate, c[2] is Z coordinate // Apply boundary condition based in one coordinate (X, Y, or Z). if (c[1] < 0.3) //if true: below watersurface { targetPatch[faceI] = scalar (1); //Inlet[faceI] = vector (1, 0, 0); } //if false: at or above watersurface else { targetPatch[faceI] = scalar (0); //Inlet[faceI] = vector (10 ,0 ,0); } } // Force the write gamma.write(); //U.write(); Info<< "\n ExecutionTime = " << runTime.elapsedCpuTime() << " s\n" << endl; Info<< "End" << endl; return(0); } \*---------------------------------------------------------------------------*/ I would be very happy for any input. Best wishes Sebastian |
Hi Sebastian,
I have the ex
Hi Sebastian,
I have the experience that similar error messages can be due to very stupid small writing errors, either in filenames or e.g. patch names, or files being in the wrong place. Maybe it's something like this... Though it can be something completly else as well. Brgds, Mark |
All times are GMT -4. The time now is 10:50. |