CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Tensor mathematics forAll macro combination tensors with vectors (http://www.cfd-online.com/Forums/openfoam-solving/57900-tensor-mathematics-forall-macro-combination-tensors-vectors.html)

 olesen February 13, 2009 12:23

The forAll(..) macro has reall

The forAll(..) macro has really nothing to do with any mathematics (tensor or otherwise). Take a look in the src/OpenFOAM/containers/Lists/UList.H and you'll see that it is simply a loop across a list.

Actually, strictly speaking, it is a loop from zero to the value returned by the object's size() method.

 sponiar February 13, 2009 13:48

Hi Mark, thank you for your r

Hi Mark,
thank you for your reply. You are right with forAll(...) and connection with tensors mathematics.

I thought about this thread, like little manual to tensors mathematics, which is very often use with forAll(...) macro, when you want to do some postprocessing at boudaries or over the whole domain.

I can see in OF forum lot of threads, where is forAll(...) macro use right in postprocessing and OF users sometime are using other steps, than other users - after that, I am loosing one's grip how to call this field and combine with other fields.

For example (sumation):
- someone is using sumation like this:
sumation = sum(
(U.boundaryField()[patchID]);

- and other ones call index [faceI] or [patchI]
forAll(profilePatch, faceI)
{
sumation[patchID][faceI] += (U.boundaryField()[faceI]);
}

------------------------------------------------

Other example with to calling boundary fields:
const fvPatchVectorField& Uin = U.boundaryField()[patchID]

or

label patchID = mesh.boundaryMesh().findPatchID("w_body");
const polyPatch& profilePatch = mesh.boundaryMesh()[patchID];
forAll(profilePatch, faceI)
{
vectorField = U.boundaryField()[faceI];
}

------------------------------------------------

This is, what I would like to refer.
Could you tell me, when I can combine tensors with vectors. When have to be dimensioned. What is difference between fvPatch<type>Field, vol<type>Field, <type>Field and how use them and work with them in mathematics connection.

This is, what I would like to refer - forAll(...) macro, which is often use in postprocessing, where is necessary knowledge in <type>Fields
Thanks
David

 sponiar February 25, 2009 05:04

Hello All, I was trying other

Hello All,
I was trying other combination, but when I am try more and deeper understand to threads of the boundary face and neighbour cell, I am confused of those things.

May I ask you to sort out my thoughts
I attach picture with typical boudanry prismatic cell with faceCentroid, cellCentroid wich is neighbour to the faceCentroid.

-----

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

-----

cellCentroid holds data like volVectorFiled of the velocity magnitude, volScalarField like pressuer ...
I can get this vector field:
label patchID = mesh.boundaryMesh().findPatchID("w_body");
vectorField Ub = U.boundaryField()[patchID]

Q1) How Can I get U.boudaryField()[patchID] to the boudary faceCentroids? I do that way. Is it right?
volVectorrField Ub
(
IOobject
(
"Ub",
runTime.timeName(),
mesh,
IOobject::NO_WRITE
),
U
);

Q2) How can I operate with scalar field like volume of prismatic cells at the boudary, normals of the boundaries elements and scalar product of two vectors.

I do it this way:
//get patch ID
label patchID = mesh.boundaryMesh().findPatchID("w_body");
//exist patch?
if(patchID != -1)
{

Info << " patch ID:" << patchID << exists << endl;

//get indexes of the patch nieghbour cells
labelList patchCells = mesh.boundary()[patchID].faceCells();

//get normals of boudary elements
vectorField faceNormals = mesh.boundary()[patchID].nf();

// loop over all boudary cell indexes
// this loop work for me like
// debugging with printing data to console

forAll(patchCells, faceI)
{
Info << "cellVolume:\t" << mesh.V()[patchCells[faceI]] << endl;

//scalar product of 2 vector * cell volume * normal of the elements
Info << "(Ub&Vb)*cV:\t" <<
( Ub[patchCells[faceI]] & Vb[patchCells[faceI]] ) * mesh.V()[patchCells[faceI]]
* faceNormals[faceI] << endl;
)
}
}

This above loop work fine - printing to console work. But I do not know, how to do that to get this value to the boundary of the faceCentroids.
Something like directly mapping.

My goal is get sensitivity map at the wall boundaries, which is described with direction and size. I would like visual this results in paraFoam. In the mean time, I can get results from the scalar product of the 2 vectors and direction vector is equal to the normal vector (see picture with cylinder).
I have still problem to get cell volume neighbour to the boundary.

Any hints?
With regards,
David

-----

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

-----

 sponiar February 25, 2009 05:09

Hello All, I was trying other

Hello All,
I was trying other combination, but when I am try more and deeper understand to threads of the boundary face and neighbour cell, I am confused of those things.

May I ask you to sort out my thoughts
I attach picture with typical boudanry prismatic cell with faceCentroid, cellCentroid wich is neighbour to the faceCentroid.

-----

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

-----

cellCentroid holds data like volVectorFiled of the velocity magnitude, volScalarField like pressuer ...
I can get this vector field:
label patchID = mesh.boundaryMesh().findPatchID("w_body");
vectorField Ub = U.boundaryField()[patchID]

Q1) How Can I get U.boudaryField()[patchID] to the boudary faceCentroids? I do that way. Is it right?
volVectorrField Ub
(
IOobject
(
"Ub",
runTime.timeName(),
mesh,
IOobject::NO_WRITE
),
U
);

Q2) How can I operate with scalar field like volume of prismatic cells at the boudary, normals of the boundaries elements and scalar product of two vectors.

I do it this way:
//get patch ID
label patchID = mesh.boundaryMesh().findPatchID("w_body");
//exist patch?
if(patchID != -1)
{

Info << " patch ID:" << patchID << exists << endl;

//get indexes of the patch nieghbour cells
labelList patchCells = mesh.boundary()[patchID].faceCells();

//get normals of boudary elements
vectorField faceNormals = mesh.boundary()[patchID].nf();

// loop over all boudary cell indexes
// this loop work for me like
// debugging with printing data to console

forAll(patchCells, faceI)
{
Info << "cellVolume:\t" << mesh.V()[patchCells[faceI]] << endl;

//scalar product of 2 vector * cell volume * normal of the elements
Info << "(Ub&Vb)*cV:\t" <<
( Ub[patchCells[faceI]] & Vb[patchCells[faceI]] ) * mesh.V()[patchCells[faceI]]
* faceNormals[faceI] << endl;
)
}
}

This above loop work fine - printing to console work. But I do not know, how to do that to get this value to the boundary of the faceCentroids.
Something like directly mapping.

My goal is get sensitivity map at the wall boundaries, which is described with direction and size. I would like visual this results in paraFoam. In the mean time, I can get results from the scalar product of the 2 vectors and direction vector is equal to the normal vector (see picture with cylinder).
I have still problem to get cell volume neighbour to the boundary.

Any hints?
With regards,
David

-----

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

-----

 sponiar February 25, 2009 06:03

Missing picture: Boundary c

Missing picture:

Boundary cell decription:
------

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

------

Sensitivity map at the cylinder:
------

http://www.cfd-online.com/OpenFOAM_D...your_image.gif

------
David

 All times are GMT -4. The time now is 11:31.