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

What happen with this square root??

Register Blogs Community New Posts Updated Threads Search

Like Tree9Likes
  • 9 Post By darlopez

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 21, 2013, 12:30
Default What happen with this square root??
  #1
New Member
 
Darío López
Join Date: Oct 2011
Location: Vigo, Spain
Posts: 10
Rep Power: 14
darlopez is on a distinguished road
Hi everybody!

I want to write a simple operation in my solver:

Tension = zF*sqrt(1-(calcDistance0-0.5)/2.4*(calcDistance0-0.5)/2.4); + forceStatic*(calcDistance0-0.5)/2.4;

Where Tension, zF, calcDistance0 and forceStatic are scalars (static scalar ...)
When I try to compile I find this error:

solveForceBalance.H:154: error: call of overloaded 'sqrt(Foam::scalar)' is ambiguous
/usr/include/bits/mathcalls.h:157: note: candidates are: double sqrt(double)


Help me please!!!
darlopez is offline   Reply With Quote

Old   September 21, 2013, 12:40
Default
  #2
New Member
 
Darío López
Join Date: Oct 2011
Location: Vigo, Spain
Posts: 10
Rep Power: 14
darlopez is on a distinguished road
Solved!

scalar aux = Foam:: sqrt(....)
darlopez is offline   Reply With Quote

Old   May 16, 2018, 21:15
Default
  #3
Member
 
Join Date: Oct 2013
Posts: 92
Rep Power: 12
fedvasu is on a distinguished road
Quote:
Originally Posted by darlopez View Post
Solved!

scalar aux = Foam:: sqrt(....)
Thank you I didn't think it was a namespace issue. I thought it was a library overload issue.
fedvasu is offline   Reply With Quote

Old   November 7, 2019, 03:59
Default
  #4
Member
 
David Andersson
Join Date: Oct 2019
Posts: 46
Rep Power: 6
sippanspojk is on a distinguished road
I have a similar problem. I tried to simplify it to see if sqrt() works at all for me so now I am basically writing sqrt(4) to a vector and that's it. It still doesn't work and I get the following error message:

Code:
error: no matching function for call to ‘Foam::Vector<double>::Vector(<brace-enclosed initializer list>)’
     Foam::Vector<double> testVec{1, 2, sqrt(4)};
It is worth mentioning that I am new to coding in OpenFOAM and also to C++ so I am most likely doing something very trivial wrong.
Can someone tell me what I am doing wrong here?
sippanspojk is offline   Reply With Quote

Old   November 7, 2019, 17:52
Default
  #5
Member
 
Join Date: Oct 2013
Posts: 92
Rep Power: 12
fedvasu is on a distinguished road
Quote:
Originally Posted by sippanspojk View Post
I have a similar problem. I tried to simplify it to see if sqrt() works at all for me so now I am basically writing sqrt(4) to a vector and that's it. It still doesn't work and I get the following error message:

Code:
error: no matching function for call to ‘Foam::Vector<double>::Vector(<brace-enclosed initializer list>)’
     Foam::Vector<double> testVec{1, 2, sqrt(4)};
It is worth mentioning that I am new to coding in OpenFOAM and also to C++ so I am most likely doing something very trivial wrong.
Can someone tell me what I am doing wrong here?
Problem isn't with sqrt, error says problem is with {}.

And also use Foam::sqrt for clarity
fedvasu is offline   Reply With Quote

Old   March 12, 2020, 02:59
Default
  #6
Senior Member
 
TWB
Join Date: Mar 2009
Posts: 402
Rep Power: 19
quarkz is on a distinguished road
Hi,

I got the same error and I'm trying to do my correction. However, it doesn't seem to work.

I need to change the Turbulent frequency equation from :

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)

...

to

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*sqrt(rho)*DomegaEff(F1), sqrt(rho)*omega_)

I got the error and I changed to:

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*Foam::sqrt(rho)*DomegaEff(F1), Foam::sqrt(rho)*omega_)

but the error remains. So how should I change it?

Thanks.
quarkz is offline   Reply With Quote

Old   March 12, 2020, 03:56
Default
  #7
Senior Member
 
TWB
Join Date: Mar 2009
Posts: 402
Rep Power: 19
quarkz is on a distinguished road
Hi, I followed the corrections recommended here too:

https://openfoamwiki.net/index.php/F...9_is_ambiguous

Possible solutions, instead of simply using sqrt(2.0):

::sqrt(2.0)
scalar(::sqrt(2.0))
::sqrt(scalar(2.0))

but it still can't work, although the error msg has changed:

In file included from ../turbulenceModels/lnInclude/kOmegaSSTBase.H:350:0,
from ../turbulenceModels/lnInclude/kOmegaSST.H:111,
from turbulentTransportModels/turbulentTransportModels.C:73:
../turbulenceModels/lnInclude/kOmegaSSTBase.C: In instantiation of ‘void Foam::kOmegaSSTBase<BasicEddyViscosityModel>::corr ect() [with BasicEddyViscosityModel = Foam::LESModels:ESModel<Foam::IncompressibleTurb ulenceModel<Foam::transportModel> >]’:
turbulentTransportModels/turbulentTransportModels.C:130:29: required from here
../turbulenceModels/lnInclude/kOmegaSSTBase.C:469:95: error: no matching function for call to ‘laplacian(Foam::tmp<Foam::GeometricField<dou ble, Foam::fvPatchField, Foam::volMesh> >, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
- fvm::laplacian(alpha*::sqrt(scalar(rho))*DomegaEff (F1), ::sqrt(scalar(rho))*omega_)
^
../turbulenceModels/lnInclude/kOmegaSSTBase.C:469:95: note: candidates are:
In file included from /home/users/nus/tsltaywb/OpenFOAM/OpenFOAM-v1706_mod/src/finiteVolume/lnInclude/fvmLaplacian.H:188:0,
from /home/users/nus/tsltaywb/OpenFOAM/OpenFOAM-v1706_mod/src/finiteVolume/lnInclude/fvm.H:46,
from ../turbulenceModels/lnInclude/linearViscousStress.C:28,
from ../turbulenceModels/lnInclude/linearViscousStress.H:114,
from ../turbulenceModels/lnInclude/Stokes.H:39,
from ../turbulenceModels/lnInclude/laminarModel.C:27,
from ../turbulenceModels/lnInclude/laminarModel.H:201,
from turbulentTransportModels/turbulentTransportModels.H:31,
from turbulentTransportModels/turbulentTransportModels.C:26:
/home/users/nus/tsltaywb/OpenFOAM/OpenFOAM-v1706_mod/src/finiteVolume/lnInclude/fvmLaplacian.C:45:1: note: template<class Type> Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::laplacian(const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::word&)
laplacian
^
/home/users/nus/tsltaywb/OpenFOAM/OpenFOAM-v1706_mod/src/finiteVolume/lnInclude/fvmLaplacian.C:45:1: note: template argument deduction/substitution failed:
In file included from ../turbulenceModels/lnInclude/kOmegaSSTBase.H:350:0,
from ../turbulenceModels/lnInclude/kOmegaSST.H:111,
from turbulentTransportModels/turbulentTransportModels.C:73:
../turbulenceModels/lnInclude/kOmegaSSTBase.C:469:95: note: ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ is not derived from ‘const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>’
- fvm::laplacian(alpha*::sqrt(scalar(rho))*DomegaEff (F1), ::sqrt(scalar(rho))*omega_)
quarkz is offline   Reply With Quote

Old   March 14, 2020, 19:16
Default
  #8
Member
 
Join Date: Oct 2013
Posts: 92
Rep Power: 12
fedvasu is on a distinguished road
Quote:
Originally Posted by quarkz View Post
Hi,

I got the same error and I'm trying to do my correction. However, it doesn't seem to work.

I need to change the Turbulent frequency equation from :

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*rho*DomegaEff(F1), omega_)

...

to

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*sqrt(rho)*DomegaEff(F1), sqrt(rho)*omega_)

I got the error and I changed to:

fvm::ddt(alpha, rho, omega_)
+ fvm::div(alphaRhoPhi, omega_)
- fvm::laplacian(alpha*Foam::sqrt(rho)*DomegaEff(F1), Foam::sqrt(rho)*omega_)

but the error remains. So how should I change it?

Thanks.
Code:
 - fvm::laplacian(alpha*sqrt(rho)*DomegaEff(F1), sqrt(rho)*omega_)
This above line is the problem, you are changing an unknown variable 'omega_' to 'sqrt(rho)*omega_' and it is dimensionally inconsistent with your other terms.

Code:
 - fvm::laplacian(alpha*Foam::sqrt(2.0)*DomegaEff(F1), omega_)
as you are only multiplying a (non-dim) scalar to the coefficient and not changing the variable, so the above line will work.

Code:
 - fvc::laplacian(alpha*Foam::sqrt(2.0)*DomegaEff(F1), Foam::sqrt(2.0)*omega_)
This COULD work, test it out, as you are calculating the term explicitly, 'fvc' not 'fvm'

Last edited by fedvasu; March 14, 2020 at 19:17. Reason: clarity and context
fedvasu is offline   Reply With Quote

Old   March 18, 2020, 21:54
Default
  #9
Senior Member
 
TWB
Join Date: Mar 2009
Posts: 402
Rep Power: 19
quarkz is on a distinguished road
I realised that actually using

::sqrt(rho)
scalar(::sqrt(rho))
::sqrt(scalar(rho))

for the sqrt part can work.

My error is due to representing the Laplacian as:

fvm::laplacian(alpha*::sqrt(rho)*DomegaEff(F1), ::sqrt(rho)*omega_)

The omega and sqrt(rho) are grouped together.

Someone seems to have similar enquires:

How to represent laplacian of a product of multiple terms?

Anyone has a solution?
quarkz 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
RMS root mean square velocity Fluent C.C FLUENT 4 August 29, 2022 21:10
root mean square velocity Far CFX 12 June 1, 2016 08:58
Environment errors with .deb install and ubuntu 13.04 64 bit jonathanbyrn OpenFOAM Installation 14 September 26, 2013 05:22
missing vtf3.h BPatch.h papi.h linch OpenFOAM Installation 41 July 24, 2012 14:45
root mean square John FLUENT 4 May 30, 2002 16:14


All times are GMT -4. The time now is 12:28.