CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   changing a volScalarField to a dimensionedScalar (

wschosta May 24, 2011 15:38

changing a volScalarField to a dimensionedScalar
Hello Foamers,

I've been working on creating a union between interFoam and mhdFoam. Today I made some major progress on getting all the variables aligned but i ran into a bit of a problem.

interFoam treats mu and nu as volScalarFields but in order to do the DB and DBU parts of MHD they have to be scalars.

Any thoughts on switching back and forth?

interFoam calculates nu and mu in the file twoPhaseMixture.H and it calculates them to be scalars. I'm using predefined functions to read them into CreateFields.H

Read in of mu and nu:
const volScalarField& mu =;
const volScalarField& nu =;

DB and DBU code:
dimensionedScalar DB = 1.0/(mu*sigma); = "DB";

dimensionedScalar DBU = 1.0/(2.0*(mu ^ rho)); = "DBU";

Any help or pointers are greatly appreciated :)

marupio May 24, 2011 22:42

How do you want to represent an entire field of values with a single value? It's entirely up to you. You could take the average... I'd probably do that. Or take a reference point.

Average is:

    dimensionedScalar dsMu

or approximately that. I'm guessing - on the windows side of my computer right now.

wschosta May 25, 2011 16:13


that worked well, I now have a value that appears to be the correct average. I've been coming across some problems getting the correct dimensions and I was wondering if there was a way to reset dimensions. I've tried resetting them using setDimensions but then it starts to get snippy.

Thanks in advance, Walter

marupio May 25, 2011 16:55

To force the dimensions of a dimensionedScalar to change, use:


// dsNu is a dimensionedScalar
//newDimensions is (of course) a dimensionSet.

wschosta May 26, 2011 11:22

thanks, it worked like a charm!

sabago May 6, 2015 10:20

Dear OpenFOAMers!

Whatif I want to use the integrated value of the volScalarField instead of the average?


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