CFD Online Discussion Forums

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

shash July 3, 2012 04:19

converting from dimensionedScalar to volScalarField
 
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 :D

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
);

akidess July 3, 2012 05:28

Is this a question?

shash July 3, 2012 13:17

:D 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.

akidess July 4, 2012 03:34

Cutting down to relevant code:

Quote:

Originally Posted by shash (Post 369461)
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
);


shash July 5, 2012 00:44

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 ???

akidess July 5, 2012 02:36

Indeed I overlooked the dimensions. What units does s1 have, and is it also a scalar?

shash July 5, 2012 04:48

s1 is dimensionless and scalarfield as in code.

akidess July 11, 2012 05:02

What is the error message you are getting?


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