
[Sponsors] 
August 27, 2008, 13:25 
Hi again, I am trying to under

#81 
Member
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 72
Rep Power: 15 
Hi again, I am trying to understand how to specify phi, i took the liberty and choosing the structure of phi in Time.Running() catalogue, then changed wherever i found it suited, then it works fine during reading but stops later in,
error message: that "FvMesh" lack initiated phi variable, are the mesh movable?. Now i am confused since the mesh indeed are movable and besides i am using dynamicFvMesh.H, my solver works fine apart the important fact the U field isnt correct with noslip condition. Anyone who have any idea for the reason of this, again, the settings on the patch is movingWallVelocity on the U, fixedValue on the cellDisplacement and calculated on pointDisplacement. The phi have calculated as well ( since the running.catalogue specified so ). Best Regards Johan 

August 28, 2008, 09:10 
Why does FvMesh::phi() complai

#82 
Member
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 72
Rep Power: 15 
Why does FvMesh::phi() complain about that the mesh is not movable, when it actually move the mesh using update()? I am using above settings for U,celldisplacement and p. I have checked other codes, test printed the displacement field, the mesh is moving, however, while trying explicitly print out the U file on boundary it doesnt change at all. Anyone could shed some light into this matter? Thank you.


August 28, 2008, 11:02 
The current score between FOAM

#83 
Member
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 72
Rep Power: 15 
The current score between FOAM::error and me is 3  0, my latest test involves using motionU file with calculated option to trigger the change of the U.boundaryField().
If i am using movingWallVelocity, the solver complains about the Mesh::phi not created ( yes it is using createFields ), then asking wether the grid is movable ( yes it is cuz the points are moving) but the U field arent noslip, instead set to ( 0 0 0) for stationary walls. This gives 10 in score, If i am changing the U in the automesh step which includes U.correctBoundaryConditions() in the update(), ( for this reason, i dont understand why repeat this call in icoDymFoam ), the changes are ignored due to the fixedValue type, despite the use of ==. This gives 20 in score, By porting the code of icoDymFoam into my code section, then the error repeats! This gives 30 in score, and as a coach for this game i am doing Time out, for a tactic discussion, since the last score implicate error in the input files. Anyone who can provide me with a working example? Btw i tried reading shipFoam but the links are broken. Get a *.unk file which i cannot read. Best Regards Johan 

August 28, 2008, 13:02 
Current score is 31, yes, you

#84 
Member
Johan Lorentzon
Join Date: Mar 2009
Location: Lunds University, Sweden
Posts: 72
Rep Power: 15 
Current score is 31, yes, you got it right,


August 29, 2008, 03:10 
Thanks for the response Gavin!

#85 
New Member
Ken Mattsson
Join Date: Mar 2009
Posts: 7
Rep Power: 9 
Thanks for the response Gavin!
Due to my limited knowledge of OpenFOAM I have not been able to resolve my issue with transient boundary conditions. I have analytic functions U(x,y,t), V(x,y,t) (and p(x,y,t)) for the velocity and pressure (although I will not need p if I specify dirichlet BC). I would like to use these functions to generate 1) the initial conditions (data) and 2) to impose the dirichlet boundary data at the boundaries (at runtime). What I'm aiming at is to meassure the accuracy of the incompressible solver (a gridconvergence study), when having transient (nonconstant along the boundary) boundary conditions, using an analytic 2D solution. I should say that I will update the entire boundary (all patches) with the same analytic data (I will treat all 4 boundaries the same way, there is no specific inlet or outlet, as a matter of fact there will be both inflow and outflow on all boundaries). I'm greatful for any comments on this, especially from people who have used this approach of using analytic functions to specify initial and boundary data directly in the code. I'm even more greatful for as much details as possible (due to my limited knowledge at this stage). Best regards Ken 

September 5, 2008, 05:30 
I have checked the forum for s

#86 
New Member
Ken Mattsson
Join Date: Mar 2009
Posts: 7
Rep Power: 9 
I have checked the forum for some insight on how to set time and space dependent boundaryconditions using a function (i.e., not a list). Gavin sent me this reply:
I often think the easiest (although not the most elegant) way of doing this is just to set the boundary to be fixedValue and then grab the data and modify it inside the code. Thus, you can get the patch face centre points thus: vectorField inletFaceCentres(mesh.C().boundaryField()[patchNo]); and the X, Y and Z components of the velocity as scalarField UInletX(U.boundaryField()[patchNo].component(vector::X)); scalarField UInletY(U.boundaryField()[patchNo].component(vector::Y)); scalarField UInletZ(U.boundaryField()[patchNo].component(vector::Z)); You can then manipulate the values in these scalarFields (the ordering is the same), and then replace them U.boundaryField()[patchNo].replace(vector::X,UInletX);  This seems to be a nice solution. But can someone tell me how to set the values of UInletX and UInletY. I know the velocity field as a function (x,y,t). I have checked the funkySetFields approach, but that is only for timeindependent data (unfortunately). I assume that yopu have to loop over all boundary points and set them pointwise using my function expression (and then I need to find the corresponding x,y values at the bounadry, and I'm not sure how to do that). You have to excuse me for my limited knowledge! Best regards Ken 

September 9, 2008, 11:13 
Hello to everybody,
I'm a new

#87 
New Member
Veronica Ricciardi
Join Date: Mar 2009
Posts: 1
Rep Power: 0 
Hello to everybody,
I'm a new user of OpenFOAM 1.4.1. I'm trying to simulate a compressible flow in a chocked nozzle with sonicFoam. In order to simulate a fluctuation over the mean flow, I'm using the timeVaryingUniformFixedValue for the p, U, T fields. But when I run the simulation the solver gives me this error: Exec : sonicFoam . case1Bis Date : Sep 09 2008 Time : 15:21:31 Host : vega PID : 1174 Root : /home/cluster/OpenFOAM/cluster1.4.1/run/tutorials/sonicFoam Case : case1Bis Nprocs : 1 Create time Create mesh for time = 0 Reading thermodynamicProperties Reading transportProperties Reading field p Reading field T Calculating field e from T Reading field U Reading/calculating face flux field phi Starting time loop Time = 0.0001 Courant Number mean: 0 max: 0.686527 diagonal: Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0 DILUPBiCG: Solving for Ux, Initial residual = 1, Final residual = 6.92725e17, No Iterations 1 DILUPBiCG: Solving for Uy, Initial residual = 1, Final residual = 3.97853e17, No Iterations 1 DILUPBiCG: Solving for Uz, Initial residual = 1, Final residual = 1.77402e16, No Iterations 1 > FOAM FATAL IO ERROR : file "" does not exist file: at line 1. From function IFstream::operator() in file db/IOstreams/Fstreams/IFstream.C at line 171. FOAM exiting I'm quite sure that the solver is correctly reading the input files for the b.c., and the error seems to be confined to the T field, as if I change the T b.c to fixedValue and the other fields to timeVarying everything works fine. Could anyone explain me what's happening? Thank you in advance. 

September 10, 2008, 10:32 
Hi,
I have got exactly the

#88 
New Member
Soeren Brot
Join Date: Mar 2009
Posts: 3
Rep Power: 9 
Hi,
I have got exactly the same problem as many others here, for example as Ken. I just want to implement a BC which I would like to specify as U=(u,v)=f(x,y,t) (it is 2dimensional). I am able to set the f(x,y) (not timevarying) BC and I am able to use the timeVaryingUniformFixedValue BC to set it as an f(t) BC (but only one value on the complete patch). Is there an easy way to do this (f(x,y,t)) or should I derive my own BC for this case? If there is no other way than deriving a new BC, is there anywhere a detailed Wiki or a tutorial how to do that? I did not find anything like that anywhere in the web, and I have been looking for it for at least two weeks... Thanks a lot in advance Sören 

September 11, 2008, 04:54 
Ken, Soeren,
I've dug out s

#89 
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 9 
Ken, Soeren,
I've dug out some more of the code I use to do this; // get hold of the inlet face centre vectors vectorField inletFaceCentres(mesh.C().boundaryField()[patchNo]); // and the y and z coordinates (the inlet plane here is a yz plane) scalarField inletY(inletFaceCentres.component(vector::Y)); scalarField inletZ(inletFaceCentres.component(vector::Z)); for (int i=0; i<inletFieldSize; i++) { scalar Ypos(inletY[i]1.0); scalar Ymag(inletY[i]); //double Zmag(inletZ[i]); if (Ymag>LY) Ymag = 2.0*LYYmag; scalar shape = Foam::pow((Ymag/LY),(1.0/7.0));//shape of the mean profile UInletX[i] = maxSpeedX*(shape + uxSeries.uprime(Ypos)); UInletY[i] = maxSpeedY*(uySeries.uprime(Ypos)); UInletZ[i] = maxSpeedZ*(uzSeries.uprime(Ypos)); } U.boundaryField()[patchNo].replace(vector::X,UInletX); U.boundaryField()[patchNo].replace(vector::Y,UInletY); U.boundaryField()[patchNo].replace(vector::Z,UInletZ); The bit inside the loop sets the values of the X, Y and Z components of the velocity for each cell. If you have a timedependent function you could implement it here (runTime.time() should get you this). The .replace() function reinserts the field into the boundaryField. Please note I wrote this bit of code a while back  the exact syntax might have changed, but the general idea is OK I think  and easier than writing a fresh bc (which would be based on this anyway). Gavin 

September 24, 2008, 05:56 
Thanks Gavin,
I have tried

#90 
New Member
Ken Mattsson
Join Date: Mar 2009
Posts: 7
Rep Power: 9 
Thanks Gavin,
I have tried to follow your suggestion. I have made a copy of icoFoam.C and put it into custom_utils directory. I have renamed it (to icoTaylorFoam.C)and made corrections to the Make directory. This is what I add (in the timeloop): for (runTime++; !runTime.end(); runTime++) { Info<< "Time = " << runTime.timeName() << nl << endl; # include "readPISOControls.H" # include "CourantNo.H" double pi=3.14; label patchID = mesh.boundaryMesh().findPatchID("Taylor"); const polyPatch& cPatch = mesh.boundaryMesh()[patchID]; vectorField inletFaceCentres(mesh.C().boundaryField()[patchID]); scalarField inletY(inletFaceCentres.component(vector::Y)); scalarField inletX(inletFaceCentres.component(vector::X)); forAll(cPatch, faceI) { vector faceU(vector::zero); scalar Ypos(inletY[faceI]); scalar Xpos(inletX[faceI]); faceU.x() = sqrt(Ypos*pi); U.boundaryField()[patchID][faceI] = faceU; } However, I get an error message when I type wmake (concerning the usage of various standardfunctions, such as: cos, sqrt, ...) (there are a few characters that does not come out correct below): Making dependency list for source file icoTaylorFoam.C SOURCE=icoTaylorFoam.C ; g++ m64 Dlinux64 DDP Wall Wnostrictaliasing Wextra Wnounusedparameter Woldstylecast march=opteron O3 DNoRepository ftemplatedepth40 I/home/kmn/OpenFOAM/OpenFOAM1.5/src/finiteVolume/lnInclude IlnInclude I. I/home/kmn/OpenFOAM/OpenFOAM1.5/src/OpenFOAM/lnInclude I/home/kmn/OpenFOAM/OpenFOAM1.5/src/OSspecific/Unix/lnInclude fPIC c $SOURCE o Make/linux64GccDPOpt/icoTaylorFoam.o icoTaylorFoam.C: In function â€˜int main(int, char**)â€™: icoTaylorFoam.C:74: error: call of overloaded â€˜sqrt(Foam::scalar)â€™ is ambiguous /usr/include/bits/mathcalls.h:157: note: candidates are: double sqrt(double) /home/kmn/OpenFOAM/OpenFOAM1.5/src/OpenFOAM/lnInclude/dimensionedScalar.H:65: note: Foam::dimensionedScalar Foam::sqrt(const Foam::dimensionedScalar&) /home/kmn/OpenFOAM/OpenFOAM1.5/src/OpenFOAM/lnInclude/Scalar.H:217: note: Foam::doubleScalar Foam::sqrt(Foam::doubleScalar) /home/kmn/OpenFOAM/OpenFOAM1.5/src/OpenFOAM/lnInclude/Scalar.H:217: note: Foam::floatScalar Foam::sqrt(Foam::floatScalar) icoTaylorFoam.C:72: warning: unused variable â€˜Xposâ€™ make: *** [Make/linux64GccDPOpt/icoTaylorFoam.o] Error 1 I can not understand the cause of this. What am I missing here? cos and sqrt are after all defined for scalars!? Best regards Ken 

September 24, 2008, 06:30 
Hi Ken.
OF reimplements cer

#91 
Senior Member
Gavin Tabor
Join Date: Mar 2009
Posts: 181
Rep Power: 9 
Hi Ken.
OF reimplements certain functions such as sqrt which are already available from the standard C++ libraries. It also allows conversion from OF classes such as Scalar to standard types such as double. Thus when you ask for sqrt(q) where q is a scalar, the compiler has two possible options: 1. use the OF sqrt operator on this scalar, or 2. convert q to a double, then use the usual sqrt operator The compiler can't make this decision for you, so it yelps! What you need to do is something like Foam::sqrt(q) which specifies the use of the sqrt function from the Foam namespace. Gavin 

September 24, 2008, 07:24 
Thanks Gavin, that solved it!

#92 
New Member
Ken Mattsson
Join Date: Mar 2009
Posts: 7
Rep Power: 9 
Thanks Gavin, that solved it!
What I really would like to implement is a time and spacedependent boundary condition using the analytic Tylorvortex problem. In order to do this numerically correct i need to specify velocity (U) when there is inflow and use zero gradient on pressure (p) when there is outflow (there will be both inflow and outflow along the boundary). For that I would like to 'simulate' the inletOutlet boundary condition. (By using FunkySetFields and the inletOulet boundary condition I have manage to run the Taylorvortex case, and chosing a parameter setting yielding a steadystate solution. But now I would like to do the timedependent setting and then FunkySetFields does not work) I specify p to have a zeroGradient in the startup file for p (in the 0 directory), for U I will use fixedValue. I'm doing a longshoot here where my first attempt will be to just set the velocity components (like I currently do in the timeloop), but only when there is inflow. But I guess that will not inforce zero pressure gradient for the cases when there is outflow!? If you know how to do this properly within this setting I will be very greatful. I'm going to take a 2day course in OpenFoam (in October), hopefully I will be better equiped after that. My C++ is not up to date. Best regards Ken 

October 14, 2008, 09:30 
Gavin or anybody,
How do I

#93 
New Member
Ken Mattsson
Join Date: Mar 2009
Posts: 7
Rep Power: 9 
Gavin or anybody,
How do I get hold of the actual value of time inside the code, and use that value in a mathematical expression like cos(t), where t is time. If you print out runTime.timeName() it will print the actual value. Gavin, you said that runTime.time() would get you that, but that is not true. Say I would like to compute cos(t). How would I do that? Best regards Ken 

October 14, 2008, 10:23 
Using the value of the dimensi

#94 
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 779
Rep Power: 19 
Using the value of the dimensioned scalar should work  ie, runTime.value()
If you are using engineTime, you might look at using runTime.theta() 

October 22, 2008, 11:08 
Hi,
I'd like to know how to

#95 
New Member
Jordi Fradera
Join Date: Mar 2009
Posts: 1
Rep Power: 0 
Hi,
I'd like to know how to convert a Foam::GeometricField<double> to just a simple double in order to use it in fuctions like modf(). I'm trying to use the c++ modf(), but there is a type error when I try to compile. double modf(double,&double) but the arguments I'm calculating are dimensioned scalar fields, so ::modf() gives a type error. As far as I know functions like sqrt() have already implemented in OF, but what about ceil,floor,trunc and modf? Thanks in advance. 

January 16, 2009, 17:44 
Hi All,
I am using coupled

#96 
Senior Member
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 10 
Hi All,
I am using coupled Transport equations... I would like to add flux boundary condition at the walls of my geometry (which is square channel). This is the equation i would like to add... D1*grad(C1)  K1*C1*grad(Phi) = 0 D1*grad(C2)  K1*C2*grad(Phi) = 0 where C1 C2 and Phi are concentrations and potential respectively which I have obtained from solving my transport equation and poison equation (for Phi)...These equations are coupled... I solved them using simple boundary conditions but I would like to solve them using the above mentioned flux boundary condition.. can anyone help me out with regard to this... Thanks Regards Vishal 

January 21, 2009, 22:39 
Hello,
I am interested in a

#97 
New Member
Peter Johnston
Join Date: Mar 2009
Location: Brisbane, Queensland, Australia
Posts: 23
Rep Power: 9 
Hello,
I am interested in applying a transient velocity boundary condition of the form w(x,y,t) = f(x,y)*g(t) in the z=0 plane. In my example f(x,y) is a paraboloidal velocity field for which I wrote the following piece of code: void paraboloidalVelocityFvPatchVectorField::updateCoef fs() { // Get range and orientation boundBox bb(patch().patch().localPoints(), false); vector ctr = 0.5*(bb.max() + bb.min()); const vectorField& c = patch().Cf(); // Calculate local 2D coordinate for the paraboloidal profile scalarField coordx = 2*((c  ctr) & x_)/((bb.max()  bb.min()) & x_); scalarField coordy = 2*((c  ctr) & y_)/((bb.max()  bb.min()) & y_); vectorField::operator=(n_*maxValue_*(1.0  sqr(coordx)  sqr(coordy))); } (based heavily on the setParabolicInlet code previously mentioned). For my application g(t) is based on data from an input file which I have used successfully with timeVaryingUniformFixedValue, from which the updateCoeffs() code is: template<class> void Foam::timeVaryingUniformFixedValueFvPatchField<typ e>::updateCoeffs() { if (this>updated()) { return; } fvPatchField<type>::operator== ( timeSeries_(this>db().time().timeOutputValue()) ); fixedValueFvPatchField<type>::updateCoeffs(); } My question is: is there some neat way to merge these two ideas together to create a new boundary condition type? Thank you, any insights would be much appreciated. Peter. 

February 9, 2009, 13:55 
Hello All,
I am new to Open

#98 
Member
Gautami Erukulla
Join Date: Mar 2009
Posts: 43
Rep Power: 9 
Hello All,
I am new to OpenFOAM software.I have installed OpenFOAM1.5 on suse linux 10.3. I am trying to implement velocity transient boundary condition at the inlet using interFoam solver. The initial field is defined as (/0/U): inlet { type timeVaryingUniformFixedValue; timeDataFileName "inlet.dat"; value uniform 1e5; } When I run interFoam I get the following error. Reading environmentalProperties Reading field pd Reading field gamma Reading field U keyword outOfBounds is undefined in dictionary "/home/gali/OpenFOAM/gali1.5/run/tutorials/interFoam/transientsb/0/U::inlet" file: /home/gali/OpenFOAM/gali1.5/run/tutorials/interFoam/transientsb/0/U::inlet from line 26 to line 28. From function dictionary::lookupEntry(const word& keyword) const in file db/dictionary/dictionary.C at line 213. FOAM exiting Can someone please help me out. Thank You, Gautami. 

March 4, 2009, 19:33 
Hi All,
I have a simple re

#99 
Senior Member
Vishal Nandigana
Join Date: Mar 2009
Location: Champaign, Illinois, U.S.A
Posts: 208
Rep Power: 10 
Hi All,
I have a simple rectangular geometry and I would like to incorporate boundary conditions at the outlet for one of the variables as Phi = A *sin(wt) where w = 2*pi*f A  Amplitude f  frequency of the AC electric field and t  time Can anyone give some insight on how to incorporate such a boundary condition.. Thanks Regards Vishal 

March 5, 2009, 04:39 
Hi Vishal
Search the forum

#100 
Senior Member
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Deltares, Delft, The Netherlands
Posts: 1,698
Rep Power: 27 
Hi Vishal
Search the forum for groovyBC. It will definitely do the trick (though I haven't used it before myself). Best regards, Niels
__________________
Please note that I do not use the Friendfeature, so do not be offended, if I do not accept a request. 

Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Transient boundary conditions  Dave  FLUENT  5  October 30, 2011 09:58 
Transient boundary conditions in CFX  Sohail Ahmed  CFX  2  December 11, 2007 14:01 
Transient boundary conditions  Yannick  FLUENT  6  November 6, 2007 08:47 
Transient Boundary Conditions  James Date  CFX  5  September 13, 2004 11:34 