CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   internalField of a volField & geoMesh (https://www.cfd-online.com/Forums/openfoam-programming-development/179910-internalfield-volfield-geomesh.html)

toboto November 10, 2016 13:25

internalField of a volField & geoMesh
 
Dear All,

I have some questions and I would appreciate if someone help me.

Q1: I am a little bit confused about the difference between volField and it's associated internalField. I can't see any difference although many claims that there is (I think that should be the case).

In the GeometricField.H we can find the definition of the interalField as

Code:

  39 Foam::GeometricField<Type, PatchField, GeoMesh>::Internal&
  40 Foam::GeometricField<Type, PatchField, GeoMesh>::
  41 internalField() const
  42 {
  43    return *this;
  44 }

Also I made a small test to get some attribute of those two fields as follows:
Code:

volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
Info << U.size() << endl;
Info <<U.internalField().size() << endl;
Info << typeid(U).name() << endl;
Info << typeid(U.internalField()).name() << endl;

and the output was
Code:

58539
58539
N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE
N4Foam14GeometricFieldINS_6VectorIdEENS_12fvPatchFieldENS_7volMeshEEE

I.e. the same type and the same size. Also if I print them I get the same values where U.internalField() also contain the boundary information.

So may someone elaborate a little bit on the difference between them.

Q2: where does GeoMesh class reside in the mesh heirarchy in OpenFoam or simply what is the relation between GeoMesh and fvMesh. I tried to find that by looking into the cpp docs but I caouldn't figure out.

Q3: What is the difference/relation between GeometricField and DimensionedField?

Best regards.

rhythm November 10, 2016 19:20

Hi,

Won't be able to fully answer your question but can give some input.

Q3) GeometricField is derived from DimensionedField. To my basic understanding it adds boundary field to DimensionedField and I guess a bunch of other functions and parameters that are associated with it.
Code:

template<class Type, template<class> class PatchField, class GeoMesh>
class GeometricField
:
    public  DimensionedField<Type, GeoMesh>
{
...
}

Q2) Similar answer. GeoMesh is a 'wrapper' class for different mesh types and volMesh is a derivative class of it:
Code:

class volMesh
:
    public    GeoMesh<fvMesh>
{
...
}

Q1) I'm not entirely sure, so will leave it for someone else to give their input :)

Cheers,
Ben

toboto November 14, 2016 10:14

Dear Ben,

Thanks for your contribution. It really helps. Can you please elaborate on this:
Quote:

GeoMesh is a 'wrapper' class
what does wrapper class mean and for which purpose volMesh for example is used?

Best regards.

anishtain4 November 15, 2016 16:09

I'm not sure how to give you a good answer as I doubt if I have a proper understanding of the matter at hand. But I think reading the programmer's guide might help:
http://foam.sourceforge.net/docs/Gui...mmersGuide.pdf
Go to page 27 and start reading from section 2.2

rhythm November 16, 2016 07:47

Quote:

Originally Posted by toboto (Post 625273)
Dear Ben,

Thanks for your contribution. It really helps. Can you please elaborate on this:

what does wrapper class mean and for which purpose volMesh for example is used?

Best regards.


Hi,

Well I used the terminology that is used in description of the GeoMesh file ($FOAM_SRC/OpenFOAM/meshes/GeoMesh/GeoMesh.H).

Anyways, I believe that what it means is that GeoMesh is simply a class out of which all of the other mesh classes are derived.
My guess is that they call it wrapper because it does not have the regular *.H *.C code structure and it does not really do much. Anyways, we are delving into semantics here (which I probably would be butchered for by proper C++ programmers :D).

As I have said classes like volMesh, surfaceMesh, pointMesh, etc. are derived from GeoMesh class/wrapper.

For the future hierarchy questions I would recommend checking doxygen page of OpenFOAM as it gives a graphical representation of how parent-daughter classes are connected -> http://openfoam.com/documentation/cpp-guide/html/
volMesh: http://openfoam.com/documentation/cp...ml/a03059.html

Hope this helps.
Cheers,
Ben

toboto November 20, 2016 23:03

O.K. I think now it's clear enough. Thanks again Ben.
Still question 1 if any one can help

olesen November 21, 2016 02:10

Better said that GeoMesh is a template parameter, not a wrapper.

olesen November 21, 2016 02:19

A volField has dimensions, an internalField and a boundaryField. You'll see this in the field files (eg, 0/U etc).
There are various ways that you could use to have these three bits of information in a class: bundle each as a data member, use multiple inheritance, inherit one or more and add the balance as data members.
You could, for instance, think of a volField as an internal field with an additional boundary field 'attached' to it.

Michael@UW April 28, 2020 12:40

Quote:

Originally Posted by toboto (Post 626120)
O.K. I think now it's clear enough. Thanks again Ben.
Still question 1 if any one can help

Can you explain a little bit about volMesh? What is the purpose of this class? Since it is derived from GeoMesh<fvMesh>, then it has everything from fvMesh. If we have a fvMesh, why do we need volMesh?

granzer December 22, 2020 05:47

Quote:

Originally Posted by Michael@UW (Post 767704)
Can you explain a little bit about volMesh? What is the purpose of this class? Since it is derived from GeoMesh<fvMesh>, then it has everything from fvMesh. If we have a fvMesh, why do we need volMesh?

Here is what I have learned sofar and I am not sure this is a perfect account of how things work as I have still a lot to learn on how OF works. But I will give it a go.
As you said volMesh does inherit from the GeoMesh<fvmesh>. But if you read about the GeoMesh template its actually GeoMesh<MESH>, where MESH is just an identifier for a data type/class that GeoMesh <MESH> template will me 'templated' on. GeoMesh can be templated on, as in our case, fvMesh but also on other types of mesh like polyMesh etc. Now the GeoMesh template is a wrapper class. A wrapper class mean that it will extend the functionalities of 'something' either by giving more functions or changing the interface to the 'somethig' (so its like an API). That 'something' here in our case is fvMesh, but it could also be surfMesh, faMesh, polymesh etc... and the GeoMesh further 'extends' all these different types of meshes by allowing us to deal with all of them in a similar way(ie we don't have to worry if we have a fvMesh or faMesh or polyMesh etc when we 'wrape' it using GeoMesh).
You are right in saying that when there is fvMesh we don't actually need volMesh. But volMesh class is created so as to make our life easy in accessing certain info required for FV discritization (for example size() function in volMesh) . That info is ofcourse already present in fvMesh but if we had to access it from fvMesh we would have to write few lines of code. Since this info is required quite regularly a separate class was created called volMesh. Now the info that volMesh deals with has to do with cell centers and it doesn't deal with other info that are present in fvMesh like face centers etc. (That will be delt with by surfaceMesh)

Note: Compare volMesh, surfaceMesh, pointMesh with volField<type>, surfaceField<type> and pointField<type> to understand more.

If someone with more knowledge can verify what I have written that will be great.


All times are GMT -4. The time now is 10:59.