|
[Sponsors] |
December 31, 2019, 08:25 |
GeometricField -> mesh() Function
|
#1 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
Hi all,
I am just wondering, if I am getting things correct (but my analysis will show that I am not correct). Assuming that we do have an object based on a volScalarField which is actually a GeometricField. For this field, we can apply the function named mesh(). This function is not implemented in the GeometricField class but as this class includes the DimensionedField class, we can see that it is implemented there. As I cannot find any other function named »mesh()«, I expect that this is correct. The mesh function returns a reference to an object based on the class Mesh: Code:
const Mesh& mesh() const; Code:
GeoMesh::Mesh Mesh; Code:
volScalarField T = ...; const Mesh& foobar = T.mesh(); Code:
.... = T.mesh().ddtScheme("foobar"); Code:
T.mesh() Code:
const fvMesh& test = T.mesh(); The only thing that I could image is the following:
Code:
typedef MESH Mesh
I hope that the last statement was clear Any hint is welcomed. Thanks in advance.
__________________
Keep foaming, Tobias Holzmann |
|
January 2, 2020, 17:11 |
|
#2 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22 |
Your analysis is quite correct. Here some code snippets to support your considerations:
Code:
//--- GeometricField.H --- template<class Type, template<class> class PatchField, class GeoMesh> class GeometricField : public DimensionedField<Type, GeoMesh> { Code:
//--- DimensionedField.H --- template<class Type, class GeoMesh> class DimensionedField : public regIOobject, public Field<Type> { public: // Public Typedefs //- Type of mesh on which this DimensionedField is instantiated typedef typename GeoMesh::Mesh Mesh; ... //- Return mesh inline const Mesh& mesh() const; Code:
//--- volFieldsFwd.H --- typedef GeometricField<scalar, fvPatchField, volMesh> volScalarField; Code:
//--- volMesh.H --- class volMesh : public GeoMesh<fvMesh> { Code:
//--- GeoMesh.H --- template<class MESH> class GeoMesh { ... public: // Public Typedefs typedef MESH Mesh; |
|
January 3, 2020, 18:03 |
|
#3 |
Senior Member
|
volVectorField T
( IOobject ( "T", runTime.timeName(), mesh, // 1 IOobject::MUST_READ, IOobject::NO_WRITE ), mesh // 2 ); mesh 1 is a registered object only for IOobject and DimensionedField, I guess it is transformed to GeoMesh even it is fvMesh. mesh 2 is the mesh where the filed lives, so it is volMesh for a volVectorField, which is actually fvMesh. T.mesh is not accessible and you need only use the global variable 'mesh' itself, as all the volVectorFields use the same 'mesh', otherwise you may have U.mesh(), p.mesh() and so on (stagger mesh technique uses different meshes for different fields, but OpenFOAM use collocated mesh). Above is just my analysis, please correct me if I am wrong. Actually, I am always wondering why volVectorField constructed from IOobject uses the second mesh argument. Your analysis inspired me and partially solves the puzzle. The first mesh could be runTime which is also an registryObject. For simplicity, even if the IOobject is registered to a fvMesh, we still pass the second mesh to construct a volVectorField. What do you think about the construction mechanism? |
|
January 3, 2020, 20:10 |
|
#4 |
Super Moderator
Tobias Holzmann
Join Date: Oct 2010
Location: Bad Wörishofen
Posts: 2,711
Blog Entries: 6
Rep Power: 52 |
The object mesh in your post is based on the fvMesh class. Both, your first end second mesh are identical, it is the same object but you know that. The only nice magic that happens here is the fact that the programming language is smart enough to return the object needed at the corresponding line but only due to the fact that the constructors are having the fvMesh class as argument or the code is smart enough to return the correct object.
The second mesh is of type Mesh which is actually GeoMesh::Mesh Mesh and the template type MESH is set to fvMesh. So here things are clear. The first mesh will return the registry object. Actually I don't know your Intension for your post as it is not related to mine and Zeppo already showed that my analysis was correct. Using this information you can resolve your topic. By the way. T.mesh is not even a function. So what should this peace of code do? I guess if you want direct access you have do do it with the scope operator.
__________________
Keep foaming, Tobias Holzmann |
|
March 22, 2020, 04:56 |
|
#5 | |
Senior Member
Mandeep Shetty
Join Date: Apr 2016
Posts: 188
Rep Power: 10 |
Quote:
|
||
April 1, 2020, 13:01 |
|
#6 | |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 22 |
Quote:
|
||
April 2, 2020, 11:16 |
|
#7 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Quote:
It does get a bit confusing sometimes, but you can think of an objectRegistry as being a database for holding objects (objects of type regIOobject to be specific). Since the objectRegistry itself is derived from a regIOobject, an objectRegistry can thus contain other object registries, and can potentially have a parent registry as well. Time is a special case of an objectRegistry that is also used to define the time coordination for multiple registries. At this stage it probably helps to think in terms of a file-system. The objectRegistry is analogous to a directory, the regIOobject is analogous to a file/directory. |
||
April 7, 2020, 09:04 |
|
#8 | |
Senior Member
Mandeep Shetty
Join Date: Apr 2016
Posts: 188
Rep Power: 10 |
Quote:
Am I right in understanding that a class like 'volScalarField' is also derived from 'regIOobject' and an object of volScalarField, say T, can be called a volScalarObject or a regIOobject? |
||
April 7, 2020, 15:09 |
|
#9 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40 |
Yup, your "T" is a volScalarField, which derives from a regIOobject. Continuing with the filesystem analogy, the volScalarField is like a file (not a directory). Your choice if you want to deal with it along with other "files" (eg a volVectorField) or want to dispatch something particular to its type. In the latter case, you can dynamic cast it from the regIOobject to the volScalarField.
|
|
November 11, 2020, 12:31 |
|
#10 |
New Member
Elol
Join Date: Feb 2020
Posts: 16
Rep Power: 6 |
Hi Foamers,
I just have a simple question, I don't know if it is related to this thread or not. Anyway, If I want to calculate something like that K= delta x^2 / deltat which x is the local cell distance (x,y,z) and deltat is the runTime.deltaT(). what function or how exactly represent delta x^2 in terms of programming ? Thanks in advance. |
|
November 19, 2020, 12:33 |
|
#11 |
Senior Member
Join Date: Apr 2020
Location: UK
Posts: 745
Rep Power: 14 |
Umm ... this topic seems to be completely unrelated to the previous one, so I hesitate to respond at all. Please start a new thread when you have a new, unrelated question ... you are also more likely to get a reply!
As for your question, take a look at a utility like postChannel. You can get the cell centre coords from Code:
const vectorField& centres = mesh.C(); |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[snappyHexMesh] SnappyHexMesh/splitMeshRegion : region1 in zone "-1" | GuiMagyar | OpenFOAM Meshing & Mesh Conversion | 3 | August 4, 2023 13:38 |
is internalField(U) equivalent to zeroGradient? | immortality | OpenFOAM Running, Solving & CFD | 7 | March 29, 2013 02:27 |
[Gmsh] 2D Mesh Generation Tutorial for GMSH | aeroslacker | OpenFOAM Meshing & Mesh Conversion | 12 | January 19, 2012 04:52 |
Icemcfd 11: Loss of mesh from surface mesh option? | Joe | CFX | 2 | March 26, 2007 19:10 |
Droplet Evaporation | Christian | Main CFD Forum | 2 | February 27, 2007 07:27 |