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

Debug help: Viscosity Model in compressibleInterFoam

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 1 Post By brunomramoa
  • 1 Post By brunomramoa
  • 1 Post By brunomramoa

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 12, 2021, 07:03
Default Debug help: Viscosity Model in compressibleInterFoam
  #1
New Member
 
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 6
brunomramoa is on a distinguished road
Hello Foamers,


I am starting my programming journey on OpenFOAM (with OFv2012). Currently, I am implementing a new viscosity model that depends on pressure, temperature and shear-rate to be used in compressibleInterFoam.


I was able to implement this by changing the 'basicThermo', 'FluidThermo', 'RhoThermo', 'HeRhoThermo' and the 'twoPhaseMixtureThermo' classes (copied and changed the name to my+<className>).


However, I am having issues with the update of the classes in the 'VoFphaseCompressibleTurbulenceModels' folder, specially the 'compressibleInterPhaseTransportModel' class.


After updating the names in this class (e.g. twoPhaseMixtureThermo by myTwoPhaseMixtureThermo, fluidThermo by myFluidThermo) I noticed that the header. #include "turbulentFluidThermoModel.H" has:


Code:
#ifndef turbulentFluidThermoModel_H
#define turbulentFluidThermoModel_H

#include"CompressibleTurbulenceModel.H"
#include"ThermalDiffusivity.H"
#include"EddyDiffusivity.H"
#include"laminarModel.H"
#include"RASModel.H"
#include"LESModel.H"
#include"fluidThermo.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespaceFoam
{
namespacecompressible
{
typedef ThermalDiffusivity<CompressibleTurbulenceModel<fluidThermo>>
           turbulenceModel;

typedef laminarModel<turbulenceModel> laminarModel;
typedef RASModel<EddyDiffusivity<turbulenceModel>> RASModel;
typedef LESModel<EddyDiffusivity<turbulenceModel>> LESModel;

template<classBasicCompressibleTurbulenceModel>
       autoPtr<BasicCompressibleTurbulenceModel> New
(
const volScalarField& rho,
const volVectorField& U,
const surfaceScalarField& phi,
consttypenameBasicCompressibleTurbulenceModel::transportModel&
               transport,
const word& propertiesName =turbulenceModel::propertiesName
);
}
}





Where the basic 'fluidThermo' class is used.

I copied this class and changed fluidThermo with myFluidThermo and got the following compiler error:

Code:

myCompressibleInterPhaseTransportModel.C: In constructor ‘Foam::myCompressibleInterPhaseTransportModel::myCompressibleInterPhaseTransportModel(const volScalarField&, const volVectorField&, const surfaceScalarField&, const surfaceScalarField&, const surfaceScalarField&, const Foam::myTwoPhaseMixtureThermo&)’:
myCompressibleInterPhaseTransportModel.C:134:9: error: no matching function for call to ‘Foam::ThermalDiffusivity<Foam::CompressibleTurbulenceModel<Foam::myFluidThermo> >::New(const volScalarField&, const volVectorField&, const surfaceScalarField&, const Foam::myTwoPhaseMixtureThermo&)’
        );
        ^
In file included from /home/pc/OpenFOAM/OpenFOAM-v2012/src/TurbulenceModels/compressible/lnInclude/ThermalDiffusivity.H:182:0,
                from myTurbulentFluidThermoModel.H:49,
                from myCompressibleInterPhaseTransportModel.H:51,
                from myCompressibleInterPhaseTransportModel.C:29:
/home/pc/OpenFOAM/OpenFOAM-v2012/src/TurbulenceModels/compressible/lnInclude/ThermalDiffusivity.C:63:1: note: candidate: static Foam::autoPtr<Foam::ThermalDiffusivity<BasicTurbulenceModel> > Foam::ThermalDiffusivity<BasicTurbulenceModel>::New(const alphaField&, const volScalarField&, const volVectorField&, const surfaceScalarField&, const surfaceScalarField&, const transportModel&, const Foam::word&) [with BasicTurbulenceModel = Foam::CompressibleTurbulenceModel<Foam::myFluidThermo>; Foam::ThermalDiffusivity<BasicTurbulenceModel>::alphaField = Foam::geometricOneField; Foam::volScalarField = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>; Foam::volVectorField = Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>; Foam::surfaceScalarField = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>; Foam::ThermalDiffusivity<BasicTurbulenceModel>::transportModel = Foam::myFluidThermo]
Foam::ThermalDiffusivity<BasicTurbulenceModel>::New
^~~~
/home/pc/OpenFOAM/OpenFOAM-v2012/src/TurbulenceModels/compressible/lnInclude/ThermalDiffusivity.C:63:1: note:   candidate expects 7 arguments, 4 provided
/home/pc/OpenFOAM/OpenFOAM-v2012/src/TurbulenceModels/compressible/lnInclude/ThermalDiffusivity.C:93:1: note: candidate: static Foam::autoPtr<Foam::ThermalDiffusivity<BasicTurbulenceModel> > Foam::ThermalDiffusivity<BasicTurbulenceModel>::New(const volScalarField&, const volVectorField&, const surfaceScalarField&, const transportModel&, const Foam::word&) [with BasicTurbulenceModel = Foam::CompressibleTurbulenceModel<Foam::myFluidThermo>; Foam::volScalarField = Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>; Foam::volVectorField = Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh>; Foam::surfaceScalarField = Foam::GeometricField<double, Foam::fvsPatchField, Foam::surfaceMesh>; Foam::ThermalDiffusivity<BasicTurbulenceModel>::transportModel = Foam::myFluidThermo]
Foam::ThermalDiffusivity<BasicTurbulenceModel>::New
^~~~
/home/pc/OpenFOAM/OpenFOAM-v2012/src/TurbulenceModels/compressible/lnInclude/ThermalDiffusivity.C:93:1: note:   no known conversion for argument 4 from ‘const Foam::myTwoPhaseMixtureThermo’ to ‘const transportModel& {aka const Foam::myFluidThermo&}’
/home/pc/OpenFOAM/OpenFOAM-v2012/wmake/rules/General/transform:34: recipe for target 'Make/linux64GccDPInt32Debug/myCompressibleInterPhaseTransportModel.o' failed
make: *** [Make/linux64GccDPInt32Debug/myCompressibleInterPhaseTransportModel.o] Error 1
From what I could understand it is saying that it has a problem on the 4th argument of a function (which will be on line 128 on compressibleInterPhaseTransportModel.C) which it does not know how to convert a Foam::myTwoPhaseMixtureThermo to a transportModel& {aka const Foam::myFluidThermo&}

Why does it convert with standard 'fluidThermo' class and not with the 'newFluidThermo' class?


The solver can be found here: https://drive.google.com/file/d/19e7...ew?usp=sharing

Any help would be highly appreciated!

Best Regards,
B. Ramoa
mnobrega likes this.
brunomramoa is offline   Reply With Quote

Old   February 12, 2021, 14:19
Default
  #2
New Member
 
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 6
brunomramoa is on a distinguished road
Solved this issue.



In the myTwoPhaseMixtureThermo.H file, the class inheres publicly from the psiThermo class which in turn inheres from the fluidThermo class.


Just needed to copy the psiThermo class and change it to myPsiThermo and make it inhere from the myFluidThermo class.


Best Regards.
mnobrega likes this.
brunomramoa is offline   Reply With Quote

Old   February 14, 2021, 11:32
Default
  #3
New Member
 
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 6
brunomramoa is on a distinguished road
Hello to all,


Now I am getting the following error:


Code:
/home/pc/OpenFOAM/OpenFOAM-v2012/platforms/linux64GccDPInt32Debug/lib/libmyVoFphaseCompressibleTurbulenceModels.so: undefined reference to `Foam::TurbulenceModel<Foam::geometricOneField, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>, Foam::compressibleTurbulenceModel, Foam::myFluidThermo>::dictionaryConstructorTablePtr_'
Link to updated version: https://drive.google.com/file/d/1C3F...ew?usp=sharing


The same problem happens with OpenFOAM 7: https://drive.google.com/file/d/1klf...ew?usp=sharing



Any suggestions on where could the problem be?

Last edited by brunomramoa; February 18, 2021 at 09:17.
brunomramoa is offline   Reply With Quote

Old   February 19, 2021, 09:22
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
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
Quick answer: The devil hides in the details...
The complaint is that the base turbulence model table does not exist, in other words, you're trying to add to or load from a non-existing table. But OpenFOAM is likely adding to an already existing table, when using its own names.


Since the error is at linking time, means that the requested object does exist in a compile C file on any of the selected libraries to link to.


I've tried looking at this from a few perspectives and the best I can assess is that you took one too many steps at a time. Simply copying and prefixing names with "my" is not always enough, because some details are implied on a common structure... so one single misplaced or absent "my" prefix is enough to through us for a loop...


My advice is that you retake one step at a time, make sure each change compiles, commit the ongoing development on a public or sharable Git repository.
One wrong step was enough for you to now be asking for help... the problem is that we don't know if you're in the Arctic or Antarctica or Siberia... or Mars?... all we know is that it's snowing and it's very cold... so retracing your steps is highly important here, hence the request for a Git repository.


One neat trick I can at least write now is to try and investigate the pre-compiled code... when you run wmake, something like this appears:
Code:
Making dependency list for source file myCompressibleInterFoam.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./VoF -I./Stuff -ImyTwoPhaseMixtureThermo -ImyVoFphaseCompressibleTurbulenceModels/lnInclude -I/opt/openfoam7/src/transportModels/compressible/lnInclude -I/opt/openfoam7/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam7/src/thermophysicalModels/specie/lnInclude -I/opt/openfoam7/src/transportModels/twoPhaseMixture/lnInclude -I/opt/openfoam7/src/transportModels/interfaceProperties/lnInclude -I/opt/openfoam7/src/TurbulenceModels/turbulenceModels/lnInclude -I/opt/openfoam7/src/TurbulenceModels/compressible/lnInclude -I/opt/openfoam7/src/TurbulenceModels/phaseCompressible/lnInclude -I/opt/openfoam7/src/meshTools/lnInclude -I/opt/openfoam7/src/dynamicMesh/lnInclude -I/opt/openfoam7/src/dynamicFvMesh/lnInclude -I/opt/openfoam7/src/finiteVolume/lnInclude -IlnInclude -I. -I/opt/openfoam7/src/OpenFOAM/lnInclude -I/opt/openfoam7/src/OSspecific/POSIX/lnInclude   -fPIC -c myCompressibleInterFoam.C -o Make/linux64GccDPInt32Opt/myCompressibleInterFoam.o
On-screen is wrapped around and looks like a large 10 line paragraph. Copy the second line that you have on screen, similar to the one above, which starts with "g++" and ends with the ".o" file name, then append "-E" and change the suffix, e.g.:
Code:
g++ -std=c++11 ................./myCompressibleInterFoam.E -E
Then open the resulting file that now ends with ".E" instead of ".o", open in a text editor. Then try looking for what the compiler is complaining about.


The annoying part is that what you're looking for could be anywhere... either in the main solver's ".o" file or in one of the library ".o" files.
__________________
wyldckat is offline   Reply With Quote

Old   February 19, 2021, 16:37
Default
  #5
New Member
 
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 6
brunomramoa is on a distinguished road
Hello Bruno,

Thank you very much for your input.

I placed the solver at github https://github.com/brunoramoa/myComp...commits/master with 3 commits to track the changes

In the first, the solver compiles. It is using the psiThermo class (which will inherit from the fluidThermo class which will inherit from the basicThermo class).

In the second, an error in compilation will occur. The psiThermo class was replaced by the myPsiThermo class. The compiler will have a conversion problem.

Code:
no known conversion for argument 4 from ‘const Foam::myTwoPhaseMixtureThermo’ to ‘const transportModel& {aka const Foam::fluidThermo&}’
In the third, this problem is solved by updating the fluidThermo class with the myFluidThermo class and the
Code:
/home/pc/OpenFOAM/OpenFOAM-v2012/platforms/linux64GccDPInt32Debug/lib/libmyVoFphaseCompressibleTurbulenceModels.so: undefined reference to `Foam::TurbulenceModel<Foam::geometricOneField, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>, Foam::compressibleTurbulenceModel, Foam::myFluidThermo>::dictionaryConstructorTablePtr_' problem occurs
However, I am still completely in the dark as to where this is coming from.
brunomramoa is offline   Reply With Quote

Old   February 22, 2021, 14:13
Default
  #6
New Member
 
Bruno Ramoa
Join Date: Jul 2019
Posts: 18
Rep Power: 6
brunomramoa is on a distinguished road
Found out the problem...

had to redefine the "turbulentFluidThermoModels.C" and turbulentFluidThermoModels.H" with the myFluidthermo and compile everything in the "myVoFphaseCompressibleTurbulenceModels" library.


Best regards.
Ankit Etha likes this.

Last edited by brunomramoa; February 22, 2021 at 15:23.
brunomramoa is offline   Reply With Quote

Old   June 29, 2022, 17:37
Default
  #7
New Member
 
Join Date: Aug 2016
Location: Maryland, USA
Posts: 1
Rep Power: 0
Ankit Etha is on a distinguished road
Quote:
Originally Posted by brunomramoa View Post
Found out the problem...

had to redefine the "turbulentFluidThermoModels.C" and turbulentFluidThermoModels.H" with the myFluidthermo and compile everything in the "myVoFphaseCompressibleTurbulenceModels" library.


Best regards.
Hey Bruno, I am currently trying to implement a shear-rate dependent viscosity in compressibleInterFoam. I am having trouble setting it up, specifically the passing of shear-rate argument. Could you share your updated solver? I would be much obliged.

Thanks and Regards.
Ankit Etha is offline   Reply With Quote

Reply

Tags
compressibleinterfoam, debug information


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
Use of k-epsilon and k-omega Models Jade M Main CFD Forum 40 January 27, 2023 07:18
Viscosity model - error: object is not allocated - C++ beginner avila.vc OpenFOAM Programming & Development 5 February 14, 2022 02:00
[swak4Foam] swakExpression not writing to log alexfells OpenFOAM Community Contributions 3 March 16, 2020 18:19
Using a new implemented viscosity model with simpleFoam TemC OpenFOAM Running, Solving & CFD 6 March 8, 2017 03:07
modelling solids viscosity in eulerian multiphase model derkaiser FLUENT 1 December 5, 2011 03:42


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