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

Ambiguity error while compiling modified solver

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By überschwupper

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2021, 17:16
Default Ambiguity error while compiling modified solver
  #1
New Member
 
Deshik
Join Date: Jun 2021
Location: India
Posts: 5
Rep Power: 5
sherlock45 is on a distinguished road
Hi all!!
I have followed a tutorial by Martin Anderson (Chalmers). (http://www.tfd.chalmers.se/~hani/kur...ChangeFoam.pdf) I have modified everything according to his report and I was getting good results till the last step which is replacing the static saturation pressure to saturation pressure that varies with temperature.
Till now I am able to add temperature field to the solver but when I have replaced Psat with Psat (variable with temperature), I am getting a compilation error. (I just entered 'wmake' command)

Here is the output I am getting while compilation of code..,
I have also attached the screenshot.


Code:
Making dependency list for source file myInterPhaseChangeFoam.C
g++ -std=c++11 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -O3  -DNoRepository -ftemplate-depth-100 -I. -I/opt/openfoam8/src/transportModels/lnInclude -I/opt/openfoam8/src/twoPhaseModels/twoPhaseMixture/lnInclude -I/opt/openfoam8/src/twoPhaseModels/interfaceProperties/lnInclude -I/opt/openfoam8/src/twoPhaseModels/incompressibleTwoPhaseMixture/lnInclude -I/opt/openfoam8/src/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude -IphaseChangeTwoPhaseMixtures/lnInclude -I/opt/openfoam8/src/MomentumTransportModels/momentumTransportModels/lnInclude -I/opt/openfoam8/src/MomentumTransportModels/incompressible/lnInclude -I/opt/openfoam8/src/finiteVolume/lnInclude -I/opt/openfoam8/src/dynamicFvMesh/lnInclude -I/opt/openfoam8/src/meshTools/lnInclude -I/opt/openfoam8/src/OpenFOAM/lnInclude -IlnInclude -I. -I/opt/openfoam8/src/OpenFOAM/lnInclude -I/opt/openfoam8/src/OSspecific/POSIX/lnInclude   -fPIC -c myInterPhaseChangeFoam.C -o Make/linux64GccDPInt32Opt/myInterPhaseChangeFoam.o
In file included from myInterPhaseChangeFoam.C:50:
phaseChangeTwoPhaseMixtures/lnInclude/phaseChangeTwoPhaseMixture.H: In member function ‘const volScalarField& Foam::phaseChangeTwoPhaseMixture::pSat() const’:
phaseChangeTwoPhaseMixtures/lnInclude/phaseChangeTwoPhaseMixture.H:129:42: error: reference to ‘alpha1_’ is ambiguous
  129 |             const volScalarField& pSat = alpha1_.db().lookupObject<volScalarField>("pSat");
      |                                          ^~~~~~~
In file included from /opt/openfoam8/src/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude/immiscibleIncompressibleTwoPhaseMixture.H:39,
                 from phaseChangeTwoPhaseMixtures/lnInclude/phaseChangeTwoPhaseMixture.H:38,
                 from myInterPhaseChangeFoam.C:50:
/opt/openfoam8/src/twoPhaseModels/interfaceProperties/lnInclude/interfaceProperties.H:69:31: note: candidates are: ‘const volScalarField& Foam::interfaceProperties::alpha1
’
   69 |         const volScalarField& alpha1_;
      |                               ^~~~~~~
In file included from /opt/openfoam8/src/twoPhaseModels/incompressibleTwoPhaseMixture/lnInclude/incompressibleTwoPhaseMixture.H:40,
                 from /opt/openfoam8/src/twoPhaseModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude/immiscibleIncompressibleTwoPhaseMixture.H:38,
                 from phaseChangeTwoPhaseMixtures/lnInclude/phaseChangeTwoPhaseMixture.H:38,
                 from myInterPhaseChangeFoam.C:50:
/opt/openfoam8/src/twoPhaseModels/twoPhaseMixture/lnInclude/twoPhaseMixture.H:58:24: note:                 ‘Foam::volScalarField Foam::twoPhaseMixture::alpha1_’
   58 |         volScalarField alpha1_;
      |                        ^~~~~~~
In file included from myInterPhaseChangeFoam.C:50:
phaseChangeTwoPhaseMixtures/lnInclude/phaseChangeTwoPhaseMixture.H:129:82: error: expected primary-expression before ‘>’ token
  129 |             const volScalarField& pSat = alpha1_.db().lookupObject<volScalarField>("pSat");
      |                                                                                  ^
make: *** [/opt/openfoam8/wmake/rules/General/transform:26: Make/linux64GccDPInt32Opt/myInterPhaseChangeFoam.o] Error 1
What I understood was that alpha1_ is defined twice in the header files (twoPhaseMixture.H and interfaceProperties.H) that were included in mainsolver code (myInterPhaseChangeFoam.C) and alpha1_ is called next to these header files. Which means the next header file doesn't know which alpha1_ to use.
I am a beginner in programming. Please help me......
Thanks
Attached Images
File Type: jpg Screenshot 2021-06-09 014535.jpg (190.4 KB, 5 views)

Last edited by sherlock45; June 10, 2021 at 09:40.
sherlock45 is offline   Reply With Quote

Old   April 6, 2022, 03:41
Default
  #2
New Member
 
Prithvi
Join Date: Mar 2022
Location: Darmstadt
Posts: 6
Rep Power: 4
prinux is on a distinguished road
Hi sherlock45,


Were you able to resolve this?
prinux is offline   Reply With Quote

Old   May 4, 2022, 04:20
Default
  #3
Member
 
Join Date: Jan 2022
Location: Germany
Posts: 72
Rep Power: 4
überschwupper is on a distinguished road
I was facing the same problem like OP and I wasnt able to explain this for myself, because in the more derivative class "immiscibleIncompressibleTwoPhaseMixture.H" was done basicly the same, just by having your class in between.


Long story short: Since the compiler is complaining about ambigiouity Iwas wondering why it worked for immiscibleIncompressibleTwoPhaseMixture.H I tried to put another class afterwards and THEN inherit from interfaceProperties and it worked.




My presumption in this case is, because both classes have defined alpha1_ and alpha2_ (one as variable (protected) the other as a const reference variable but as private member), normally I wouldnt expect any errors here but since there is an error.. yeah.. I believe there are two options to solve this problem: either by specifing which alpha is meant with twoPhaseMixture::alpha1_ or twoPhaseMixture::alpha1() or by putting a class before inheriting from interfaceProperties, where no member function is defined that wants access to a alpha value!
prinux likes this.

Last edited by überschwupper; May 10, 2022 at 02:22.
überschwupper is offline   Reply With Quote

Reply

Tags
alpha1_, ambiguity, custom solver, error, interphasechangefoam


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
Divergence detected in AMG solver. VOF. Mr.Mister Fluent Multiphase 4 September 25, 2023 08:10
Fail to converge when solving with a fabricated solution zizhou FLUENT 0 March 22, 2021 07:33
OF 2.1.1 error in compiling modified solver anuragm OpenFOAM Programming & Development 2 November 28, 2014 10:37
thobois class engineTopoChangerMesh error Peter_600 OpenFOAM 4 August 2, 2014 10:52
Compiling Solver: Clang error linker commander failed schwam OpenFOAM Programming & Development 11 May 25, 2014 05:31


All times are GMT -4. The time now is 01:45.