CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   define volscalarfield (http://www.cfd-online.com/Forums/openfoam/111987-define-volscalarfield.html)

vahidzanganeh January 19, 2013 03:57

define volscalarfield
 
hi foamers
i have to want a volumetric heat transfer coefficient defined in my new solver.
i have the following:
volScalarField Hv
(
IOobject
(
"Hv",
runTime.timeName(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::AUTO_WRITE
),
mesh,
dimensionedScalar
(
"Hv",
dimensionSet(1, -1, -3, -1, 0, 0, 0),
10000.0
)
);
forAll(mesh.C(),i)
{
Hv[i] = ((Nuseltv[i]*thermo.alpha()[i] * thermo.Cp())/pow(porousdim,2));
}
__________________________
comment:
alpha is volscalarfield
Cp is volscalarfield
porousdim is dimeter: defined in constant folder
porousdim porousdim [0 1 0 0 0 0 0] 0.00083;
---------------------------------------------------
The following error is generated executable file
*************************
parameter.H: In function ‘int main(int, char**)’:
parameter.H:98: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment
**************************************
line 98 is : Hv[i] = ((Nuseltv[i]*thermo.alpha()[i] * thermo.Cp())/pow(porousdim,2));
******************************
who can help me?
best regards

nimasam January 19, 2013 12:28

is Cp volscalarField or dimensionedScalar ?
however
if it is volScalarField, i guess it should be
thermo.Cp()[i]
also
porousdim is a dimensionedScalar, here you need just its value, so it should be
porousdim.value()

vahidzanganeh January 21, 2013 02:23

dear nima
thanks your reply
Cp is volscalarfield in basicThermo.H file
I have changed the formula of volumetric heat transfer coefficient but the error is
***********
parameter.H: In function ‘int main(int, char**)’:
parameter.H:101: error: no match for ‘operator[]’ in ‘Foam::basicThermo::Cp()[i]
****************************
comment:
Hv[i] = ((Nuseltv[i] * thermo.alpha()[i] * thermo.Cp()[i])/pow(porousdim.value(),2));
********************
and
error is
parameter.H: In function ‘int main(int, char**)’:
parameter.H:101: error: cannot convert ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘double’ in assignment
***********************************
comment:
Hv[i] = ((Nuseltv[i] * thermo.alpha()[i] * thermo.Cp())/pow(porousdim.value(),2));
**********************************

best regards

nimasam January 21, 2013 02:39

you can use this setting:
volScalarField Cp1=thermo.Cp();
then use
Cp1[i]

vahidzanganeh January 21, 2013 05:14

thanks your reply
this problem was solved.
but with Info Cp and Cp1 in log file
***************
cp=dimensions [0 2 -2 -1 0 0 0];
internalField uniform 1009.12;
boundaryField
{
.........
}
*******************
cp1=dimensions [0 0 1.49095e-264 1.51456e-264 0 0 0];
internalField nonuniform 0();
boundaryField
{
}
****************************
why?? :(
best regards

nimasam January 21, 2013 05:36

Dear vahid
thats strange error, i've never seen this before
may its better you define Cp first as:
volScalarField Cp
(
IOobject
(
"Cp",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
thermo.Cp()
);

then use
Cp[i]

vahidzanganeh January 21, 2013 07:35

thanks your reply
this problem was solved
I hope it takes time to thank.


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