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

convert dimensioned<double>’ to ‘double’

Register Blogs Community New Posts Updated Threads Search

Like Tree13Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2010, 17:49
Default 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
nimasam is on a distinguished road
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 ,
Aabadani likes this.
nimasam is offline   Reply With Quote

Old   August 6, 2010, 05:22
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by nimasam View Post
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 ,
If you just need the value without the dimensions:
Code:
T[i ]= TSat.value();
should work.
This method is covered in the doxygen for dimensioned types:
http://foam.sourceforge.net/doc/Doxy...mensioned.html
olesen is offline   Reply With Quote

Old   August 8, 2010, 13:15
Default
  #3
New Member
 
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16
Pritika is on a distinguished road
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
Pritika is offline   Reply With Quote

Old   August 8, 2010, 14:21
Default
  #4
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
hi paritika
above solution works for me,
whats ur volscalarField variable in the right hand of equation?
nimasam is offline   Reply With Quote

Old   August 8, 2010, 16:11
Default
  #5
New Member
 
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16
Pritika is on a distinguished road
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.
Pritika is offline   Reply With Quote

Old   August 8, 2010, 16:54
Default
  #6
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,267
Blog Entries: 1
Rep Power: 25
nimasam is on a distinguished road
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 ?
nimasam is offline   Reply With Quote

Old   August 9, 2010, 03:26
Default
  #7
New Member
 
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16
Pritika is on a distinguished road
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
Pritika is offline   Reply With Quote

Old   August 9, 2010, 06:20
Default
  #8
New Member
 
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16
Pritika is on a distinguished road
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
Pritika is offline   Reply With Quote

Old   August 9, 2010, 07:20
Default
  #9
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,714
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by nimasam View Post
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();
}
If you use the zero-sized volScalarField 'E' as above, you are headed for a segfault.
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
    )
);
You'll need to work a bit on getting the dimensions correct, or else simply define everything to be dimensionless. This is for you to decide.
tomdylan likes this.
olesen is offline   Reply With Quote

Old   August 19, 2010, 09:18
Default
  #10
New Member
 
Pritika Goyal
Join Date: May 2010
Posts: 7
Rep Power: 16
Pritika is on a distinguished road
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?
Pritika is offline   Reply With Quote

Old   October 24, 2013, 10:56
Default
  #11
Senior Member
 
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13
Sherlock_1812 is on a distinguished road
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);
    }
When i compile it I get the following ---> "error: cannot convert ‘Foam::tmp<Foam::Field<double> >’ to ‘Foam::scalar {aka double}’ in initialization.

Can you tell me where I'm going wrong. Apologies if it is a basic mistake.
__________________
Regards,

Srivaths
Sherlock_1812 is offline   Reply With Quote

Old   October 26, 2013, 14:44
Default
  #12
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
__________________
wyldckat is offline   Reply With Quote

Old   October 27, 2013, 09:12
Default
  #13
Senior Member
 
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13
Sherlock_1812 is on a distinguished road
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
Sherlock_1812 is offline   Reply With Quote

Old   October 27, 2013, 09:20
Default
  #14
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,982
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
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
__________________
wyldckat is offline   Reply With Quote

Old   October 27, 2013, 12:59
Default
  #15
Senior Member
 
Srivathsan N
Join Date: Jan 2013
Location: India
Posts: 101
Rep Power: 13
Sherlock_1812 is on a distinguished road
That was a quick reply. Thank you Bruno! I'll have a look at that BC.
__________________
Regards,

Srivaths
Sherlock_1812 is offline   Reply With Quote

Old   December 18, 2013, 08:06
Default
  #16
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13
Thamali is on a distinguished road
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
Thamali is offline   Reply With Quote

Old   December 18, 2013, 08:18
Default
  #17
Senior Member
 
Bernhard
Join Date: Sep 2009
Location: Delft
Posts: 790
Rep Power: 22
Bernhard is on a distinguished road
It means that your function is returning the wrong type. Without code, it is difficult to say anything else.
Bernhard is offline   Reply With Quote

Old   December 18, 2013, 10:06
Default
  #18
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13
Thamali is on a distinguished road
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
Attached Files
File Type: h createFields.H (34.4 KB, 66 views)
Thamali is offline   Reply With Quote

Old   December 19, 2013, 00:07
Default
  #19
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13
Thamali is on a distinguished road
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.
Thamali is offline   Reply With Quote

Old   December 23, 2013, 08:04
Default Dear Foamers,
  #20
Member
 
Thamali
Join Date: Jul 2013
Posts: 67
Rep Power: 13
Thamali is on a distinguished road
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
Thanks.

Last edited by wyldckat; December 29, 2013 at 17:11. Reason: Added [CODE][/CODE]
Thamali is offline   Reply With Quote

Reply


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


All times are GMT -4. The time now is 11:50.