|
[Sponsors] |
How can I access the updated coordinates on a rotating region from a functionObject |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
October 17, 2021, 14:47 |
How can I access the updated coordinates on a rotating region from a functionObject
|
#1 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Hello,
I have tried both the coded function object, and implemented a custom function object using foamNewFunctionObject to print the coordinates of a cell on a rotating cellZone. When I invoke the function object, the Velocity is returned correctly and changes with time, however, the coordinates printed of the cell do not change with time, even though the cellZone is correctly rotating. How can I solve that? in other words; how can I get the updated coordinates of cells in a rotating cellZone from within a functionObject? I am stuck, and can't progress further without solving that issue. Could you please provide me some insights? (I am using OpenFOAM7) Thank you |
|
October 18, 2021, 10:02 |
|
#2 |
Member
Bram Kerkhofs1
Join Date: Oct 2016
Posts: 30
Rep Power: 10 |
Hi D.Frank
Could you post your code? The simple answer is: you'll need to update the mesh or load the updated mesh. Most probably your reading the 'constant/polyMesh" over and over instead of the updated mesh regards |
|
October 18, 2021, 18:45 |
|
#3 |
Member
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9 |
Use writeCellCentres function object then use readFields Function object to read the centers as volVectorField.
|
|
October 18, 2021, 18:49 |
|
#4 |
Senior Member
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5 |
Here is a minimal example:
Code:
type coded; libs ("libutilityFunctionObjects.so"); name printMovingCoordinates; codeWrite #{ // The velocity field const volVectorField& U = mesh().lookupObject<volVectorField>("U"); // the id of myZone label zoneId = mesh().cellZones().findIndex("myZone"); label cell_id = -1; if (zoneId != -1) { const cellZone& zone = mesh().cellZones()[zoneId]; const cellZoneMesh& zoneMesh = zone.zoneMesh(); const labelList& cellsZone = zoneMesh[zoneId]; forAll(cellsZone, i) { cell_id = cellsZone[i]; Info << "The velocity is changing " << U[cell_id] << endl; Info << "But the cells are not changing over time: " C[cell_id] << endl; } } #} |
|
October 19, 2021, 03:48 |
|
#5 |
Member
Bram Kerkhofs1
Join Date: Oct 2016
Posts: 30
Rep Power: 10 |
Hi D.Frank
The code is correct: your cell_id isn't changing, and it shouldn't change. These ID's are the reference towards your cells. As per your code: your cell_id is a 'label' not a 'vector'. So your code is correct, but you're missing the link between the cell_id and the calculation of the cell centre. You can do as s1291 suggests, or manipulate the source code of the writeCellCenters function into your custom function. Or depending on what you're doing this thread could also help: functionObject to retrieve position writes correct to "Info<<" but wrongly to file Hope this helps! |
|
Tags |
openfoam |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
FloEFD rotating region | 310toumad | FloEFD, FloWorks & FloTHERM | 4 | September 11, 2019 10:28 |
Access (x y z) coordinates of cellSet | hxaxtma | OpenFOAM Programming & Development | 1 | January 21, 2016 06:40 |
Rotating region of a centr. pump - Counter R wall | Emre | CFX | 0 | September 20, 2007 10:58 |
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues | michele | OpenFOAM Meshing & Mesh Conversion | 2 | July 15, 2005 05:15 |
[Gmsh] Import gmsh msh to Foam | adorean | OpenFOAM Meshing & Mesh Conversion | 24 | April 27, 2005 09:19 |