CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   changing a volScalarField to a dimensionedScalar (http://www.cfd-online.com/Forums/openfoam-solving/88731-changing-volscalarfield-dimensionedscalar.html)

 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 = twoPhaseProperties.mu();
const volScalarField& nu = twoPhaseProperties.nu();

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

dimensionedScalar DBU = 1.0/(2.0*(mu ^ rho));
DBU.name() = "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:
Code:

dimensionedScalar dsMu
(
"mu",
fieldMu.dimensions(),
fieldMu.average()
);

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

 wschosta May 25, 2011 16:13

marupio~

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.

 marupio May 25, 2011 16:55

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

Code:

// dsNu is a dimensionedScalar
dsNu.dimensions().reset(newDimensions);
//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?

Best,
Sandra

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