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

How to scale a volScalarField by cell volume?

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By stevenvanharen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 9, 2012, 10:13
Default How to scale a volScalarField by cell volume?
  #1
New Member
 
Tyler V
Join Date: Jul 2012
Posts: 24
Rep Power: 14
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, 10:58
Default
  #2
Senior Member
 
Steven van Haren
Join Date: Aug 2010
Location: The Netherlands
Posts: 149
Rep Power: 16
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, 11:25
Smile Thanks!
  #3
New Member
 
Tyler V
Join Date: Jul 2012
Posts: 24
Rep Power: 14
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


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
[Other] mesh airfoil NACA0012 anand_30 OpenFOAM Meshing & Mesh Conversion 13 March 7, 2022 18:22
draw any scalar vs. cell volume wersoe OpenFOAM Post-Processing 0 April 3, 2012 04:52
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 10:56
Cell centroid and cell volume in general, and in Fluent zmester Main CFD Forum 3 October 17, 2009 12: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 09:37.