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

Random field

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

Reply
 
LinkBack Thread Tools Display Modes
Old   February 18, 2008, 12:03
Default Hi, I would like to create
  #1
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
Hi,

I would like to create a random vector field with which I could play with my flow (adding it to velocity components as a white noise, or as a body force in the NS equation,...).

Since I still do not catch well how data is organised within OpenFOAM, could somebody help me ? I know the object for this field would be a volVectorField, but I do not get much...
I would like values to be independent for each positions and components, and spanning between 0 and 1.

Thanks,

JD
johndeas is offline   Reply With Quote

Old   February 18, 2008, 14:52
Default I tried to modify perturbU fro
  #2
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
I tried to modify perturbU from De Villier :

#include "fvCFD.H"
#include "Random.H"
#include "wallDist.H"
#include "wallDistReflection.H"
#include "mathematicalConstants.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{
# include "setRootCase.H"

# include "createTime.H"
# include "createMesh.H"

wallDist yw(mesh);
const scalar h = max(yw.internalField());

wallDistReflection reflexVec(mesh);

const volVectorField yDir = reflexVec.n();

IOobject Uheader
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ
);
Info << "Reading U" << endl;
volVectorField U(Uheader, mesh);

IOdictionary transportProperties
(
IOobject
(
"transportProperties",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

dimensionedVector Ubar
(
transportProperties.lookup("Ubar")
);

vector xDir = Ubar.value()/mag(Ubar.value());

const vectorField& centres(mesh.C());

Random perturbation(1234567); // objet possède la méthode GaussNormal

forAll(centres, celli)
{

scalar devX=1.0 + 0.1*perturbation.GaussNormal();
scalar devY=1.0 + 0.1*perturbation.GaussNormal();
scalar devZ=1.0 + 0.1*perturbation.GaussNormal();

vector zDir = xDir^yDir[celli];
zDir /= mag(zDir);


U[celli] = 3.0*Ubar.value() * (yw[celli]/h - 0.5*sqr(yw[celli]/h));

U[celli] += xDir*devX+yDir*devY+zDir*devZ;

}

U.write();

Info<< endl;

return(0);
}


// ************************************************** *********************** //

But this line

U[celli] += xDir*devX+yDir*devY+zDir*devZ;

is a source of compilation error:

sandFoam.C:69: error: no match for 'operator+=' in 'U.Foam::GeometricField<foam::vector<double>, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam::DimensionedField <foam::vector<double>, Foam::volMesh>::<anonymous>.Foam::Field<foam::vect or<double> >::<anonymous>.Foam::List<foam::vector<double> >::<anonymous>.Foam::UList<t>::operator[] [with T = Foam::Vector<double>](celli) += Foam::operator+(const Foam::tmp<foam::geometricfield<type2,> >&, const Foam::VectorSpace<form,>&) [with Form = Foam::Vector<double>, Cmpt = double, int nCmpt = 3, Type = Foam::Vector<double>, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh](((const Foam::VectorSpace<foam::vector<double>, double, 3>&)((const Foam::VectorSpace<foam::vector<double>, double, 3>*)(& Foam::operator*(const Foam::VectorSpace<form,>&, Foam::scalar) [with Form = Foam::Vector<double>, Cmpt = double, int nCmpt = 3](devZ).Foam::Vector<double>::<anonymous>))))'
/home/vinz/OpenFOAM/OpenFOAM-1.4.1/src/OpenFOAM/lnInclude/VectorSpaceI.H:204: note: candidates are: void Foam::VectorSpace<form,>::operator+=(const Foam::VectorSpace<form,>&) [with Form = Foam::Vector<double>, Cmpt = double, int nCmpt = 3]

However I thought I provided my deviation as a three component vector, so I do not understand where the problem is.
johndeas is offline   Reply With Quote

Old   February 19, 2008, 04:08
Default Hi John, Maybe you can have
  #3
Senior Member
 
Cedric DUPRAT
Join Date: Mar 2009
Location: Belgium
Posts: 179
Rep Power: 8
cedric_duprat is on a distinguished road
Hi John,

Maybe you can have a look there : src/randomProcesses
there is a file noise and an other turbulence.

I think they could be interresting for you.

With perturbU, you can already add a noise near the wall (without adding the laminar velocity profile for U).

Can you precise what you want do to ?

Regards

Cedric
cedric_duprat is offline   Reply With Quote

Old   February 19, 2008, 05:17
Default I am trying to reproduce resul
  #4
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
I am trying to reproduce results we get on another code (DNS), perturbing a Poiseuille profile with white noise at 1/10 the original local field value.

I noted perturbU and will give it a try later.

Since turbgen generates divergence free turbulent field, I may also try to surimpose one it produces with a Poiseuille profile.

Anyway if someone understands why U[celli] += xDir*devX+yDir*devY+zDir*devZ; throw me an error in the modification I did...
johndeas is offline   Reply With Quote

Old   February 25, 2008, 06:53
Default I corrected my error: yDir was
  #5
Senior Member
 
John Deas
Join Date: Mar 2009
Posts: 160
Rep Power: 8
johndeas is on a distinguished road
I corrected my error: yDir was declared of type volVectorField, and, as such, the perturbation had to be written:

U[celli] += devX*xDir+devY*yDir[celli]+devZ*zDir;

instead of:

U[celli] += devX*xDir+devY*yDir+devZ*zDir;
johndeas is offline   Reply With Quote

Reply

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
How to get Pressure field from velocity field qunwuhe@hotmail.com Main CFD Forum 4 October 14, 2007 07:38
Putting submesh field values into field on parent mesh helmut OpenFOAM Running, Solving & CFD 2 June 20, 2006 07:31
UDF and random functions gino briganti FLUENT 2 June 28, 2005 04:55
random posrosity shekhar FLUENT 5 October 13, 2003 23:45
field by field decomposition vs. component-wise zhanglei Main CFD Forum 0 January 5, 2001 10:06


All times are GMT -4. The time now is 18:50.