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

convert pointScalarField to volScalarField

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 4, 2017, 10:51
Default convert pointScalarField to volScalarField
  #1
New Member
 
Sara Lenzi
Join Date: Jun 2017
Location: Italy
Posts: 8
Rep Power: 9
saralen is on a distinguished road
Send a message via Skype™ to saralen
Hi All,

I'm new to OpenFOAM and I'm trying to convert a pointScalarField to a volScalarField. How can I do?

Thanks a lot for your help.
Sara
saralen is offline   Reply With Quote

Old   December 4, 2017, 11:21
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

You can iterate over volScalarField and use interpolatePointToCell function ( https://cpp.openfoam.org/v5/namespac...ec0038ef8cdd46).
saralen likes this.
alexeym is offline   Reply With Quote

Old   December 4, 2017, 12:00
Default
  #3
New Member
 
Sara Lenzi
Join Date: Jun 2017
Location: Italy
Posts: 8
Rep Power: 9
saralen is on a distinguished road
Send a message via Skype™ to saralen
Thanks for your answer alexeym!
Sara
saralen is offline   Reply With Quote

Old   December 6, 2017, 10:58
Default
  #4
New Member
 
Sara Lenzi
Join Date: Jun 2017
Location: Italy
Posts: 8
Rep Power: 9
saralen is on a distinguished road
Send a message via Skype™ to saralen
Can I also ask you for a description of a volScalarField 's "structure" ?

About the interpolateToPointCell function, I found it requests the following input : geometric field and a label index, isn't it?
To convert the pointScalarField in a volScalarField I'm going to do a "for loop" on the label index....could it be correct?
Anyway I can't understand if I'm wrong because I can't find the structure of a volScalarField in the user guide...

Thanks

Last edited by saralen; December 7, 2017 at 09:33.
saralen is offline   Reply With Quote

Old   December 6, 2017, 13:39
Default
  #5
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,938
Rep Power: 39
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Yes, you can (and you actually did ).

If we oversimplify, volScalarField is a list of scalar values one for each cell of a mesh, pointScalarField is a list of scalar values, one for each point of the mesh (and both are specialisation of GeometricField type, see volFieldsFwd.H and pointFields.H).

So, yes, you iterate over volume field with for loop or forAll macro, and pass label index and point field into interpolatePointToCell function. Function looks up faces of the cell, then for each face it looks up vertices of the face, takes values at these points and returns average (see https://cpp.openfoam.org/v5/interpol...8C_source.html). You take returned value and assign it to cell with above mentioned index.

Yet, depending on the nature of your data, maybe you could select another weighting strategy (rather than number of vertices of a given cell).
alexeym is offline   Reply With Quote

Reply

Tags
pointscalarfield, volvectorfield


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
Error in compiling new drag model k.farnagh OpenFOAM Programming & Development 13 May 21, 2016 04:08
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 04:25
Convert volScalarField to dimensionedScalar to be defined in transportProperties sabago OpenFOAM Programming & Development 8 June 1, 2015 13:11
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 07:16
mapping between pointScalarField and volScalarField liu OpenFOAM Running, Solving & CFD 3 October 22, 2010 11:06


All times are GMT -4. The time now is 06:46.