CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Running, Solving & CFD

How to scale a volScalarField by cell volume?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By stevenvanharen

Reply
 
LinkBack Thread Tools Display Modes
Old   July 9, 2012, 09:13
Default How to scale a volScalarField by cell volume?
  #1
New Member
 
Tyler V
Join Date: Jul 2012
Posts: 24
Rep Power: 5
tgvosk is on a distinguished road
Hello,

I am trying to scale a volScalarField (myField) by cell volume. Based on other threads on this topic, I have the following code (which works)

Code:
    volScalarField cellVolume
    (
        IOobject
        (
            "cellVolume",
            runTime.timeName(),
            mesh,
            IOobject::NO_READ,
            IOobject::NO_WRITE
        ),
        mesh,
        dimensionedScalar("zero", dimensionSet(0, 3, 0, 0, 0, 0, 0), 0.0)
    );

    cellVolume.internalField() = mesh.V();

    myField = myField * cellVolume;
What I would like to know is whether there is a way of doing this directly with field operations (without creating an intermediate volScalarField to store the cell volume or looping through all cells and multiplying cell-by-cell).

Any suggestions?
tgvosk is offline   Reply With Quote

Old   July 9, 2012, 09:58
Default
  #2
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 7
stevenvanharen is on a distinguished road
Use this:

Code:
T.internalField() *=  mesh.V();
tgvosk likes this.
stevenvanharen is offline   Reply With Quote

Old   July 9, 2012, 10:25
Smile Thanks!
  #3
New Member
 
Tyler V
Join Date: Jul 2012
Posts: 24
Rep Power: 5
tgvosk is on a distinguished road
Steven,

Thanks, that's what I was looking for! Both of the following work as expected.

Code:
 myField = mag(fvc::laplacian(T));
 myField.internalField() *= mesh.V();
Code:
myField.internalField() = mag(fvc::laplacian(T)) * mesh.V();
tgvosk is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
draw any scalar vs. cell volume wersoe OpenFOAM Post-Processing 0 April 3, 2012 03:52
error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Native Meshers: blockMesh 2 March 14, 2012 10:56
mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 12 December 12, 2011 05:16
Cell centroid and cell volume in general, and in Fluent zmester Main CFD Forum 3 October 17, 2009 11:05
fluent add additional zones for the mesh file SSL FLUENT 2 January 26, 2008 12:55


All times are GMT -4. The time now is 15:21.