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

How can I access the updated coordinates on a rotating region from a functionObject

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 17, 2021, 14:47
Default How can I access the updated coordinates on a rotating region from a functionObject
  #1
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
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
NotOverUnderated is offline   Reply With Quote

Old   October 18, 2021, 10:02
Default
  #2
Member
 
Bram Kerkhofs1
Join Date: Oct 2016
Posts: 30
Rep Power: 10
brammekeuh987 is on a distinguished road
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
brammekeuh987 is offline   Reply With Quote

Old   October 18, 2021, 18:45
Default
  #3
Member
 
s1291's Avatar
 
Join Date: Aug 2017
Location: Algeria
Posts: 98
Rep Power: 9
s1291 is on a distinguished road
Use writeCellCentres function object then use readFields Function object to read the centers as volVectorField.
s1291 is offline   Reply With Quote

Old   October 18, 2021, 18:49
Default
  #4
Senior Member
 
NotOverUnderated's Avatar
 
ONESP-RO
Join Date: Feb 2021
Location: Somwhere on Planet Earth
Posts: 127
Rep Power: 5
NotOverUnderated is on a distinguished road
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;
		}
	}

#}
NotOverUnderated is offline   Reply With Quote

Old   October 19, 2021, 03:48
Default
  #5
Member
 
Bram Kerkhofs1
Join Date: Oct 2016
Posts: 30
Rep Power: 10
brammekeuh987 is on a distinguished road
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!
brammekeuh987 is offline   Reply With Quote

Reply

Tags
openfoam


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
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


All times are GMT -4. The time now is 08:23.