|
[Sponsors] |
August 5, 2010, 17:49 |
convert dimensioned<double>’ to ‘double’
|
#1 |
Senior Member
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25 |
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 , |
|
August 6, 2010, 05:22 |
|
#2 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
Quote:
Code:
T[i ]= TSat.value(); This method is covered in the doxygen for dimensioned types: http://foam.sourceforge.net/doc/Doxy...mensioned.html |
||
August 8, 2010, 13:15 |
|
#3 |
New Member
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16 |
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 |
|
August 8, 2010, 16:11 |
|
#5 |
New Member
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16 |
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. |
|
August 8, 2010, 16:54 |
|
#6 |
Senior Member
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25 |
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 ? |
|
August 9, 2010, 03:26 |
|
#7 |
New Member
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16 |
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 |
|
August 9, 2010, 06:20 |
|
#8 |
New Member
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16 |
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 |
|
August 9, 2010, 07:20 |
|
#9 | |
Senior Member
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40 |
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 ( "E", someDimensions, (phaseb_.rho() - phasea_.rho()) * sqr(phasea_.d()) / sigma ); volScalarField E ( IOobject ( "E", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, constE ); // or combined: volScalarField E ( IOobject ( "E", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE ), mesh, dimensionedScalar ( "E", someDimensions, (phaseb_.rho() - phasea_.rho()) * sqr(phasea_.d()) / sigma ) ); |
||
August 19, 2010, 09:18 |
|
#10 |
New Member
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16 |
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? |
|
October 24, 2013, 10:56 |
|
#11 |
Senior Member
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13 |
Hello all,
I have the following piece of code that I wrote for a boundary condition. Code:
const scalarField& x = patch().Cf().component(0); const vectorField modGrad; // creating a vectorField called modGrad // Assigning values to the scalarFields forAll(modGrad, patchi) { scalar Ux = scalarCoeff_*x[patchi]; scalar Uy = 0; scalar Uz = 0; modGrad[patchi] = vector(Ux, Uy, Uz); } Can you tell me where I'm going wrong. Apologies if it is a basic mistake.
__________________
Regards, Srivaths |
|
October 26, 2013, 14:44 |
|
#12 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
October 27, 2013, 09:12 |
|
#13 |
Senior Member
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13 |
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?
__________________
Regards, Srivaths |
|
October 27, 2013, 09:20 |
|
#14 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128 |
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
__________________
|
|
October 27, 2013, 12:59 |
|
#15 |
Senior Member
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13 |
That was a quick reply. Thank you Bruno! I'll have a look at that BC.
__________________
Regards, Srivaths |
|
December 18, 2013, 08:06 |
|
#16 |
Member
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13 |
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 |
|
December 18, 2013, 08:18 |
|
#17 |
Senior Member
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22 |
It means that your function is returning the wrong type. Without code, it is difficult to say anything else.
|
|
December 18, 2013, 10:06 |
|
#18 |
Member
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13 |
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 |
|
December 19, 2013, 00:07 |
|
#19 |
Member
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13 |
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. |
|
December 23, 2013, 08:04 |
Dear Foamers,
|
#20 |
Member
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13 |
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 \ -lfiniteVolume -lfvOptions -lmeshTools -lODE -lOpenFOAM -ldl -lm -o /home/thamali/OpenFOAM/thamali-2.2.2/platforms/linuxGccDPOpt/bin/my_fireFoam Make/linuxGccDPOpt/my_fireFoam.o: In function `Foam::fv::laplacianScheme<double, Foam::Vector<double> >::New(Foam::fvMesh const&, Foam::Istream&)': my_fireFoam.C:(.text._ZN4Foam2fv15laplacianSchemeI dNS_6VectorIdEEE3NewERKNS_6fvMeshERNS_7IstreamE[Foam::fv::laplacianScheme<double, Foam::Vector<double> >::New(Foam::fvMesh const&, Foam::Istream&)]+0x53): undefined reference to `Foam::fv::laplacianScheme<double, Foam::Vector<double> >::IstreamConstructorTablePtr_' my_fireFoam.C:(.text._ZN4Foam2fv15laplacianSchemeI dNS_6VectorIdEEE3NewERKNS_6fvMeshERNS_7IstreamE[Foam::fv::laplacianScheme<double, Foam::Vector<double> >::New(Foam::fvMesh const&, Foam::Istream&)]+0x1a5): undefined reference to `Foam::fv::laplacianScheme<double, Foam::Vector<double> >::IstreamConstructorTablePtr_' my_fireFoam.C:(.text._ZN4Foam2fv15laplacianSchemeI dNS_6VectorIdEEE3NewERKNS_6fvMeshERNS_7IstreamE[Foam::fv::laplacianScheme<double, Foam::Vector<double> >::New(Foam::fvMesh const&, Foam::Istream&)]+0x1d5): undefined reference to `Foam::fv::laplacianScheme<double, Foam::Vector<double> >::IstreamConstructorTablePtr_' collect2: ld returned 1 exit status make: *** [/home/thamali/OpenFOAM/thamali-2.2.2/platforms/linuxGccDPOpt/bin/my_fireFoam] Error 1 Last edited by wyldckat; December 29, 2013 at 17:11. Reason: Added [CODE][/CODE] |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
convert virtual volume to a real one | djalil | FLUENT | 0 | January 22, 2009 16:07 |
Convert Real edges to Virtual in Gambit | Freeman | FLUENT | 6 | October 24, 2005 16:14 |
Convert from StarCD 3.10 to StarCD 3.15 | Jing | Siemens | 1 | April 17, 2002 10:22 |