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

converting from dimensionedScalar to volScalarField

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

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 3, 2012, 05:19
Default converting from dimensionedScalar to volScalarField
  #1
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 13
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, 06:28
Default
  #2
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   July 3, 2012, 14:17
Default
  #3
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 13
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, 04:34
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Old   July 5, 2012, 01:44
Question
  #5
Member
 
shiv
Join Date: Jun 2012
Location: Lucknow, IN
Posts: 51
Rep Power: 13
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, 03:36
Default
  #6
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

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

Old   July 11, 2012, 06:02
Default
  #8
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
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.
akidess is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[openSmoke] libOpenSMOKE Tobi OpenFOAM Community Contributions 562 January 25, 2023 10:21
Problem with pow and volScalarField _Stefan_ OpenFOAM Programming & Development 15 April 14, 2019 23:20
changing a volScalarField to a dimensionedScalar wschosta OpenFOAM Running, Solving & CFD 5 May 6, 2015 11:20
dimensionedScalar + volScalarField is evaluated elementwisely ? tianyikillua OpenFOAM Programming & Development 1 March 30, 2012 04:12
Confused about how OF handles operation between volScalarField and dimensionedScalar Edy OpenFOAM 3 September 30, 2010 11:07


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