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

changing a volScalarField to a dimensionedScalar

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By marupio

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 24, 2011, 15:38
Default changing a volScalarField to a dimensionedScalar
  #1
Member
 
Walter Schostak
Join Date: May 2011
Posts: 35
Rep Power: 14
wschosta is on a distinguished road
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
wschosta is offline   Reply With Quote

Old   May 24, 2011, 22:42
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
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.
MaLa likes this.
marupio is offline   Reply With Quote

Old   May 25, 2011, 16:13
Default
  #3
Member
 
Walter Schostak
Join Date: May 2011
Posts: 35
Rep Power: 14
wschosta is on a distinguished road
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.

Thanks in advance, Walter
wschosta is offline   Reply With Quote

Old   May 25, 2011, 16:55
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 21
marupio is on a distinguished road
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.
marupio is offline   Reply With Quote

Old   May 26, 2011, 11:22
Default
  #5
Member
 
Walter Schostak
Join Date: May 2011
Posts: 35
Rep Power: 14
wschosta is on a distinguished road
thanks, it worked like a charm!
wschosta is offline   Reply With Quote

Old   May 6, 2015, 10:20
Default
  #6
Member
 
Sandra
Join Date: Oct 2014
Posts: 58
Rep Power: 11
sabago is on a distinguished road
Dear OpenFOAMers!

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

Best,
Sandra
sabago 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
if-loop, volScalarField comparison volker OpenFOAM 7 March 6, 2020 20:03
Problems with creating a volScalarField georlade OpenFOAM Programming & Development 4 December 4, 2016 12:31
Confused about how OF handles operation between volScalarField and dimensionedScalar Edy OpenFOAM 3 September 30, 2010 10:07
scalar + volScalarField akidess OpenFOAM Programming & Development 0 September 3, 2010 11:11
Changing contact line tfe FLOW-3D 3 December 8, 2009 02:59


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