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

Tensor mathematics forAll macro combination tensors with vectors

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 13, 2009, 12:23
Default The forAll(..) macro has reall
  #1
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
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.
olesen is offline   Reply With Quote

Old   February 13, 2009, 13:48
Default Hi Mark, thank you for your r
  #2
New Member
 
David Sponiar
Join Date: Mar 2009
Location: Prague, Czech rep.
Posts: 27
Rep Power: 17
sponiar is on a distinguished road
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 is offline   Reply With Quote

Old   February 25, 2009, 05:04
Default Hello All, I was trying other
  #3
New Member
 
David Sponiar
Join Date: Mar 2009
Location: Prague, Czech rep.
Posts: 27
Rep Power: 17
sponiar is on a distinguished road
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.

-----



-----

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_READ,
IOobject::NO_WRITE
),
U
zeroGradientFvPatchVectorField::typeName,
);
gradUb.correctBoundaryConditions();



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

-----



-----
sponiar is offline   Reply With Quote

Old   February 25, 2009, 05:09
Default Hello All, I was trying other
  #4
New Member
 
David Sponiar
Join Date: Mar 2009
Location: Prague, Czech rep.
Posts: 27
Rep Power: 17
sponiar is on a distinguished road
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.

-----



-----

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_READ,
IOobject::NO_WRITE
),
U
zeroGradientFvPatchVectorField::typeName,
);
gradUb.correctBoundaryConditions();



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

-----



-----
sponiar is offline   Reply With Quote

Old   February 25, 2009, 06:03
Default Missing picture: Boundary c
  #5
New Member
 
David Sponiar
Join Date: Mar 2009
Location: Prague, Czech rep.
Posts: 27
Rep Power: 17
sponiar is on a distinguished road
Missing picture:

Boundary cell decription:
------



------



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



------
David
sponiar is offline   Reply With Quote

Reply


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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ForAll loop and vector comparison juho OpenFOAM Running, Solving & CFD 4 June 17, 2011 10:51
tensors cofactors maka OpenFOAM Bugs 5 November 17, 2008 09:31
load sheme macro (Solv Execute Command macro) manu FLUENT 2 March 13, 2008 02:00
Why doesnbt the macro forall work for the volVectorField variable siwen OpenFOAM Running, Solving & CFD 2 February 24, 2006 16:27
Books on the Mathematics of FEM? Pat Sonoco Main CFD Forum 2 January 27, 1999 03:42


All times are GMT -4. The time now is 17:30.