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

converting from dimensionedScalar to volScalarField

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

Reply
 
LinkBack Thread Tools Display Modes
Old   July 3, 2012, 04:19
Default converting from dimensionedScalar to volScalarField
  #1
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 5
shash is on a distinguished road
hi openfoamers,

i was working with twophaseeulerfoam solver and i am required to change the rhoa from being a constant value to a scalar field , i modified the createfields.H .

only relevant code is copied

volVectorField& Ua = phasea->U();
surfaceScalarField& phia = phasea->phi();
// const dimensionedScalar& rhoa = phasea->rho();
const dimensionedScalar& nua = phasea->nu();

volVectorField& Ub = phaseb->U();
surfaceScalarField& phib = phaseb->phi();
const dimensionedScalar& rhob = phaseb->rho();
const dimensionedScalar& nub = phaseb->nu();
Info<< "Reading field alpha\n" << endl;
volScalarField alpha
(
IOobject
(
"alpha",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

volScalarField beta
(
IOobject
(
"beta",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
scalar(1) - alpha

Info<< "Reading field s1\n" << endl;
volScalarField s1
(
IOobject
(
"s1",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);

Info<< "Reading field rhoa\n" << endl;
volScalarField rhoa
(
IOobject
(
"rhoa",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
((phasea->rho)+(1041* s1))/2
);


volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh
),
alpha*rhoa + beta*rhob
);
shash is offline   Reply With Quote

Old   July 3, 2012, 05:28
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Is this a question?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oam-technology
akidess is offline   Reply With Quote

Old   July 3, 2012, 13:17
Default
  #3
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 5
shash is on a distinguished road
yaa its a question , i am getting errors while trying to convert rhoa from dimensionedscalar to volscalarfield . can you please suggest the correct modification in the code.
shash is offline   Reply With Quote

Old   July 4, 2012, 03:34
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Cutting down to relevant code:

Quote:
Originally Posted by shash View Post
Info<< "Reading field rhoa\n" << endl;
volScalarField rhoa
(
IOobject
(
"rhoa",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
((phasea->rho)+(1041* s1))/2
);
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oam-technology
akidess is offline   Reply With Quote

Old   July 5, 2012, 00:44
Question
  #5
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 5
shash is on a distinguished road
hi akidess ,
i tried even resetting dimension yet getting errors, modification were:

rhoa.dimensions().reset(dimless);
rhoa = (998 + (1041 * s1))/2;
rhoa.dimensions().reset(rhoa1);
can you please suggest what's wrong ???
shash is offline   Reply With Quote

Old   July 5, 2012, 02:36
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
Indeed I overlooked the dimensions. What units does s1 have, and is it also a scalar?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oam-technology
akidess is offline   Reply With Quote

Old   July 5, 2012, 04:48
Default
  #7
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 5
shash is on a distinguished road
s1 is dimensionless and scalarfield as in code.
shash is offline   Reply With Quote

Old   July 11, 2012, 05:02
Default
  #8
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Delft, Netherlands
Posts: 919
Rep Power: 17
akidess will become famous soon enough
What is the error message you are getting?
__________________
*On twitter @akidTwit
*Spend as much time formulating your questions as you expect people to spend on their answer.
*Help define the OpenFOAM stackexchange Q&A site: http://area51.stackexchange.com/prop...oam-technology
akidess 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
libOpenSMOKE Tobi OpenFOAM Programming & Development 502 July 23, 2015 21:14
changing a volScalarField to a dimensionedScalar wschosta OpenFOAM Running, Solving & CFD 5 May 6, 2015 10:20
Problem with pow and volScalarField _Stefan_ OpenFOAM Programming & Development 14 August 7, 2012 11:04
dimensionedScalar + volScalarField is evaluated elementwisely ? tianyikillua OpenFOAM Programming & Development 1 March 30, 2012 03:12
Confused about how OF handles operation between volScalarField and dimensionedScalar Edy OpenFOAM 3 September 30, 2010 10:07


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