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

Reading the subdict in the boundaryField of a pointVectorField

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 1 Post By olesen
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 21, 2023, 02:37
Default Reading the subdict in the boundaryField of a pointVectorField
  #1
New Member
 
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6
syuico is on a distinguished road
Hi all and dear Foamers,

I want to read the subdict "initialPoints" in the boundaryFieid of pointVectorField "pointDisplacement".

In sixDoFRigidBodyDisplacementPointPatchVectorField.C , it is read as
Code:
if (dict.found("initialPoints"))
{
    initialPoints_ = vectorField("initialPoints", dict , p.size());
}
I output the name of dict:
dict.name()=".../test/1/pointDisplacement.boundaryField.object"

I also find out that there is a dict in fixedValuePointPatchField.C, so I believe there must be a way to create a dictionary from pointVectorField.

This problem is quite similar to: Accessing boundary patch dictionary within thermodynamic library and given a volScalarField object, how to read inputs from its dictionary, but I failed to figure it out.

My question: How can I get the patch-dictionary of a pointVectorField?

Thank you in advance.
Attached Images
File Type: png Screenshot from 2023-12-21 15-25-15.png (89.7 KB, 1 views)
syuico is offline   Reply With Quote

Old   December 21, 2023, 03:34
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by syuico View Post
Hi all and dear Foamers,

I want to read the subdict "initialPoints" in the boundaryFieid of pointVectorField "pointDisplacement".

In sixDoFRigidBodyDisplacementPointPatchVectorField.C , it is read as
Code:
if (dict.found("initialPoints"))
{
    initialPoints_ = vectorField("initialPoints", dict , p.size());
}
I output the name of dict:
dict.name()=".../test/1/pointDisplacement.boundaryField.object"

I also find out that there is a dict in fixedValuePointPatchField.C, so I believe there must be a way to create a dictionary from pointVectorField.

This problem is quite similar to: Accessing boundary patch dictionary within thermodynamic library and given a volScalarField object, how to read inputs from its dictionary, but I failed to figure it out.

My question: How can I get the patch-dictionary of a pointVectorField?

Thank you in advance.

You will have to either rethink what you are trying to do, or need to re-explain here, but what you describe is not generally possible at.


When OpenFOAM constructs a GeometricField (volume, surface, point, etc) from a file, it does so by using the IOobject information (name, path, repository) combined with a given "instance" (eg, the time "0.02") to find a file and open it as an input stream. The contents of the input stream are parsed/tokenized as a general dictionary (in memory). From this dictionary, entries such as dimensions, internalField, boundaryField are used to populate the different field components. This is normally termed "de-serialization".
What you see in the code snippet you provided is part of that de-serialization for a specific boundary patch, using its respective parsed sub-dictionary.
Since all of these dictionaries only exist temporarily in memory (constructed from the stream), there are no dictionaries that you can get at later on.
Another way to think about it: if the field is generated on the fly, for example as the result of adding two fields, there would also be no dictionary for the result of that operation.


If you really need to get at the raw dictionary contents, you will need to replicate part of what I described above: get a path to a location (eg, 0.02/myField) open the contents and parse as plain dictionary. Then walk to the entry of interest and get the values you need.
If you only need the boundary information, take a look at the polyBoundaryMeshEntries class for some ideas.
syuico likes this.
olesen is offline   Reply With Quote

Old   December 21, 2023, 05:07
Default
  #3
New Member
 
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6
syuico is on a distinguished road
Quote:
Originally Posted by olesen View Post
You will have to either rethink what you are trying to do, or need to re-explain here, but what you describe is not generally possible at.


When OpenFOAM constructs a GeometricField (volume, surface, point, etc) from a file, it does so by using the IOobject information (name, path, repository) combined with a given "instance" (eg, the time "0.02") to find a file and open it as an input stream. The contents of the input stream are parsed/tokenized as a general dictionary (in memory). From this dictionary, entries such as dimensions, internalField, boundaryField are used to populate the different field components. This is normally termed "de-serialization".
What you see in the code snippet you provided is part of that de-serialization for a specific boundary patch, using its respective parsed sub-dictionary.
Since all of these dictionaries only exist temporarily in memory (constructed from the stream), there are no dictionaries that you can get at later on.
Another way to think about it: if the field is generated on the fly, for example as the result of adding two fields, there would also be no dictionary for the result of that operation.


If you really need to get at the raw dictionary contents, you will need to replicate part of what I described above: get a path to a location (eg, 0.02/myField) open the contents and parse as plain dictionary. Then walk to the entry of interest and get the values you need.
If you only need the boundary information, take a look at the polyBoundaryMeshEntries class for some ideas.
Thanks for your reply! You really answer my doubts. I can finally give up trying to convert the pointVectorField to a dictionary.

As for the solution, I do think about copying the file and changing the class to "dictionary" to read the values. But it seems a little dirty.
About the "polyBoundaryMeshEntries" class, it seems that I can only get the information of boundary mesh instead of boundary field values?
Please correct me if I'm wrong.

Thanks for your reply again!
syuico is offline   Reply With Quote

Old   December 21, 2023, 18:12
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
The fastest explanation - just try something like is already done in the code:

https://develop.openfoam.com/Develop...type=heads#L78


Can use with a specified type-name, or (see comments in IOobject typeHeaderOk) without checks for the "class" in the header.
syuico likes this.
olesen is offline   Reply With Quote

Old   December 21, 2023, 23:18
Default
  #5
New Member
 
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6
syuico is on a distinguished road
Quote:
Originally Posted by olesen View Post
The fastest explanation - just try something like is already done in the code:

https://develop.openfoam.com/Develop...type=heads#L78


Can use with a specified type-name, or (see comments in IOobject typeHeaderOk) without checks for the "class" in the header.
It works! THANK U SO MUCH!
syuico 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
[Commercial meshers] Problem with Mesh conversion from FLUENT Meshing to OpenFOAM mn17jyf OpenFOAM Meshing & Mesh Conversion 3 November 1, 2023 09:49
Postprocess: sampleDict works but creates no output folder shock77 OpenFOAM Post-Processing 14 November 15, 2021 08:27
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16
[Commercial meshers] fluentMeshToFoam multidomain mesh conversion problem Attesz OpenFOAM Meshing & Mesh Conversion 12 May 2, 2013 10:52


All times are GMT -4. The time now is 04:47.