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

volScalarField on Mac

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 1, 2016, 03:39
Default volScalarField on Mac
  #1
New Member
 
Xavier Lamboley
Join Date: Jan 2015
Location: Bordeaux, France
Posts: 13
Rep Power: 11
tilasoldo is on a distinguished road
Hi,

I'm having a very weird issue about compilation in OpenFoam 3&4, hope you guys can help me.

I'm developing my own turbulence model in OF and I have different results under Linux and Mac on the following line :

Code:
volScalarField F_wake = Foam::exp(-Foam::pow(Rew / 1e5, 2.0));
where Rew is a volScalarField. This code compile with no errors under Linux (Linux Mint 18), but under macOS 10.12 I get :

Code:
../turbulenceModels/lnInclude/sstTransitionBase.C:620:20: error: conversion from 'tmp<GeometricField<scalar, fvPatchField, Foam::volMesh> >' (aka 'tmp<GeometricField<double, fvPatchField, Foam::volMesh> >') to 'volScalarField'
      (aka 'GeometricField<double, fvPatchField, Foam::volMesh>') is ambiguous
    volScalarField F_wake = Foam::exp(-Foam::pow(Rew / 1e5, 2.0));
                   ^        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
$WM_PROJECT_DIR/src/OpenFOAM/lnInclude/tmp.H:153:16: note: candidate function
        inline operator const T&() const;
               ^
$WM_PROJECT_DIR/src/OpenFOAM/lnInclude/GeometricField.H:374:9: note: candidate constructor
        GeometricField
        ^
I don't understand what is ambiguous in that, and most of all why it is ambiguous on Mac but not on Linux!
If I replace the F_wake definition by
Code:
volScalarField F_wake(Foam::exp(-Foam::pow(Rew / 1e5, 2.0)));
the problem disappear, but I'm not fully satisfied since I don't understand.

Code:
$ clang --version
Apple LLVM version 8.0.0 (clang-800.0.42.1)
Target: x86_64-apple-darwin16.1.0
Thread model: posix
tilasoldo is offline   Reply With Quote

Old   December 1, 2016, 08:17
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Foam::exp(...) returns tmp<volScalarField>. So

Code:
volScalarField F_wake(Foam::exp(-Foam::pow(Rew / 1e5, 2.0)));
just invokes constructor from tmp<volScalarField> (http://cpp.openfoam.org/v4/a00931.ht...89f53565172607), no ambiguity; while behaviour of the code

Code:
volScalarField F_wake = Foam::exp(-Foam::pow(Rew / 1e5, 2.0));
is compiler-dependent (since it involves creation of temporary object). In case of clang it can not decide what you would like to use: constructor from tmp<...> or copy-constructor (http://cpp.openfoam.org/v4/a00931.ht...b4937af8da4bff), since tmp<T> can be converted to const T&.

Not sure if this behaviour is Mac-specific, guess, clang on Linux will also emit the error.
alexeym is offline   Reply With Quote

Old   December 1, 2016, 08:47
Default
  #3
New Member
 
Xavier Lamboley
Join Date: Jan 2015
Location: Bordeaux, France
Posts: 13
Rep Power: 11
tilasoldo is on a distinguished road
Thank you for your quick reply, I understand better now

Have a nice day!
tilasoldo 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
Compressible 2D airfoil rhoSimpleFoam fatal error volScalarField none jfournier OpenFOAM Running, Solving & CFD 4 September 28, 2017 06:28
execFlowFunctionObjects - unknown field problem Toorop OpenFOAM Post-Processing 16 March 14, 2016 03:25
using chemkin JMDag2004 OpenFOAM Pre-Processing 2 March 8, 2016 22:38
make a dimensionedScalar to be volScalarField sharonyue OpenFOAM Programming & Development 4 April 2, 2014 05:44
writing execFlowFunctionObjects immortality OpenFOAM Post-Processing 30 September 15, 2013 06:16


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