convert dimensioned<double>’ to ‘double’
cannot convert ‘const Foam::dimensioned<double>’ to ‘double’ in assignment
hi friends i have following code what can i do for above compiling error ? T[i]=TSat; T is volscalarfield and Tsat is a dimensioned scalar , |
Quote:
Code:
T[i ]= TSat.value(); This method is covered in the doxygen for dimensioned types: http://foam.sourceforge.net/doc/Doxy...mensioned.html |
hey
i'm facing a similar problem while trying to build a new drag model i need to calcuate Eotvos number (E) which i have defined as a volScalarField. volScalarField E = Gravity.value()*(phaseb_.rho()-phasea_.rho())*pow(phasea_.d(),2.0)/sigma.value(); i needed to define g and sigma. i am defining them as dimensionedScalars but when i give them in the formula i get an error Models/SchillerNaumann/SchillerNaumann.C:89: error: conversion from ‘Foam::dimensioned<double>’ to non-scalar type ‘Foam::volScalarField’ requested Any suggestions how to get over this problem? i tried the variable.value() as suggested above but the error still remains. thanks. Pritika |
hi paritika
above solution works for me, whats ur volscalarField variable in the right hand of equation? |
hey
there is no volScalarField on the right side of the equation. they are all constants basically. rho (the density) and d (the diameter) are being read form the Phase model( i think as dimensioned scalars itself). gravity and sigma i have defined as dimensioned scalars. |
hi Pritika
so use the following code : volScalarField E; forAll (E,celli) { E[celli] = Gravity.value()*(phaseb_.rho()-phasea_.rho())*pow(phasea_.d(),2.0)/sigma.value(); } could you tell me why do u define E as volScalarField ? |
hey nima
i need E as a volScalarField as i need to compare it with reynolds number in an if condition and reynolds number is a volscalarField due to velocity. thanks for the help |
hey nima
i tried your suggested code but now i face a new error error: cannot convert ‘Foam::dimensioned<double>’ to ‘double’ in assignment. any suggestions? thanks again |
Quote:
You need to allocate/dimension it beforehand. If all of the values are indeed constants, then I'd think you'd use something like this: Code:
dimensionedScalar constE |
hey
i tried the above suggested method but i get the following errors error: ‘runTime’ was not declared in this scope dragModels/SchillerNaumann/SchillerNaumann.C:94: error: ‘mesh’ was not declared in this scope dragModels/SchillerNaumann/SchillerNaumann.C:105: error: no matching function for call to ‘Foam::dimensioned<double>::dimensioned(const char [4], Foam::dimensionSet, Foam::dimensioned<double>)’ i have tried something different now, instead of defining E as vol scalar i do the following dimensionedScalar E ( "E", dimensionSet(0,0,0,0,0,0,0), Gravity.value()*(phaseb_.rho() - phasea_.rho()) * sqr(phasea_.d()) / sigma.value() ); dimensionedScalar Cd2 ( "Cd2", dimensionSet(0,0,0,0,0,0,0), 8.0*(E.value()/E.value()+4)/3.0 ); then compare Cd2 as follows forAll(Re, celli) { if(Cds[celli] < Cd2) { Cds[celli] = Cd2; } } but i am still find an error error: no matching function for call to ‘Foam::dimensioned<double>::dimensioned(const char [2], Foam::dimensionSet, Foam::dimensioned<double>)’ any suggestions on this one? |
Hello all,
I have the following piece of code that I wrote for a boundary condition. Code:
const scalarField& x = patch().Cf().component(0); Can you tell me where I'm going wrong. Apologies if it is a basic mistake. |
Greetings Srivaths,
I can't figure out in which line that error is occurring. To which line is that message referring to? In addition, of what kind is the variable "scalarCoeff_"? Best regards, Bruno |
Hi Bruno,
Apologies, my bad! The error comes in the line where i assign Ux = scalarCoeff_*x[patchi]. And scalarCoeff is a ratio of two scalars that is to be given as input. In this BC, i'm trying to re-define the expression for refGradient with the vectorField 'modGrad'. I want to assign the first component of refGrad as the scalarCoeff_*(x-value of the face centre of each patch) on which this BC is applied. Am i making a basic mistake of assigning a scalarField to a scalar? |
Hi Srivaths,
If I'm not mistaken, I saw this just this past Friday. You're missing the forAll loop for the faces inside the patch. Let me see if I can find a piece of OpenFOAM code that does this... after a very quick search, have look into the file "src/finiteVolume/fields/fvPatchFields/derived/supersonicFreestream/supersonicFreestreamFvPatchVectorField.C" and/or look for other files that use the variable "facei". Best regards, Bruno |
That was a quick reply. Thank you Bruno! I'll have a look at that BC.
|
Dear Sherlock,
did you get through your problem? I am getting an error similar to one of yours, "cannot convert 'Foam::tmp<Foam::GeometricField<Foam::vector<doubl e>,Foam::fvPatchField,Foam::volMesh>>' to 'int' in return" Please see whether somwone can help me......:) Thanks in advance |
It means that your function is returning the wrong type. Without code, it is difficult to say anything else.
|
1 Attachment(s)
what I wanted is to create an anisotropic thermal conductivity field using 2volScalarFields and zero("0") for other direction.
my code is as follows(followed fromheSolidThermo.C) I tried 2 methods and neither of them worked. document is attaching. Method 1: is from line 800-892(which gives mentioned error) Method 2: is from line 762-798 2 volScalarFields are calculated using the equation k=(ko+.5*Re*Pr) and (ko+0.1*Re*Pr) Thanks |
although any of the 2 methods did not work.I managed to do that in following manner.(still I have to give BCs using 0 folder)
((ko ko 0)+(.1 .5 0)*Pr*Re) I think OF does not let generating a vectorField using 2 or 3 scalarfields as I have tried in earlier document attached.so,I used vector fields to generate the same. "wmake" is running but dont know what will arise when running the case file. However I would like to know your opinions on my early effort and this one too. |
Dear Foamers,
I am stucked with an error for some days and could not manage to solve it.As I mentioned earlier in my post.I resolved making the volVectorField.But this time it seems difficult to solve this without a help.
my error after runnign wmake is as follows.Please try to help. Code:
g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam222/src/finiteVolume/lnInclude -I/opt/openfoam222/src/fvOptions/lnInclude -I/opt/openfoam222/src/meshTools/lnInclude -I/opt/openfoam222/src/ODE/lnInclude -IlnInclude -I. -I/opt/openfoam222/src/OpenFOAM/lnInclude -I/opt/openfoam222/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linuxGccDPOpt/my_fireFoam.o -L/opt/openfoam222/platforms/linuxGccDPOpt/lib \ |
All times are GMT -4. The time now is 22:55. |