|
[Sponsors] |
Reading the subdict in the boundaryField of a pointVectorField |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
December 21, 2023, 02:37 |
Reading the subdict in the boundaryField of a pointVectorField
|
#1 |
New Member
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6 |
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()); } 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. |
|
December 21, 2023, 03:34 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40 |
Quote:
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. |
||
December 21, 2023, 05:07 |
|
#3 | |
New Member
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6 |
Quote:
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! |
||
December 21, 2023, 18:12 |
|
#4 |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40 |
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. |
|
December 21, 2023, 23:18 |
|
#5 | |
New Member
Huang Yichen
Join Date: May 2019
Posts: 3
Rep Power: 6 |
Quote:
|
||
|
|
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 |