|
[Sponsors] |
error with new+modified interfaceProperties library |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
January 7, 2016, 10:50 |
error with new+modified interfaceProperties library
|
#1 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
Hello,
i am trying to modify the interfaceProperties lib. To do this i created a new library (say "myInterfaceProperties"), which, for the moment, looks exactly as the original one. The only difference is that i am trying to pass more fields to the library. I modified the constructors part in interfaceProperties.C as follow (red parts are new) Code:
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::myInterfaceProperties::myInterfaceProperties ( const volScalarField& alpha1, const volVectorField& U, const volScalarField& DeltaX, const volScalarField& DeltaY, const IOdictionary& dict ) : alpha1_(alpha1), U_(U), dx_(DeltaX), dy_(DeltaY), Code:
const volScalarField& alpha1_; const volVectorField& U_; const volScalarField& dx_; const volScalarField& dy_; I called the new library in createField.H as Code:
myInterfaceProperties interface(alpha1, U, DeltaX, DeltaY, twoPhaseProperties); Code:
Create mesh for time = 0 PIMPLE: Operating solver in PISO mode Reading field p_rgh Reading field U Reading/calculating face flux field phi Reading transportProperties Selecting incompressible transport model Newtonian Selecting incompressible transport model Newtonian #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 in "/lib/x86_64-linux-gnu/libc.so.6" #3 Foam::myInterfaceProperties::myInterfaceProperties(Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> const&, Foam::IOdictionary const&) at ??:? #4 at ??:? #5 __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6" #6 at ??:? Segmentation fault (core dumped) Any idea about the error? Andrea |
|
January 7, 2016, 12:21 |
|
#2 |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
Hi!
Which OF version are you using? OF2.4.0 or less? Did you pointed your Make/options file to new library, like that: Code:
EXE_INC = -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$myInterfaceProperties/lnInclude \ -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/fvOptions/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude EXE_LIBS = \ -L$(FOAM_USER_LIBBIN) \ -ltwoPhaseMixture \ -lmyInterfaceProperties \ -ltwoPhaseProperties \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleLESModels \ -lfiniteVolume \ -lmeshTools \ -lfvOptions \ -lsampling
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
|
January 7, 2016, 12:42 |
|
#3 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
Hi,
thanks for your reply. I am using 2.3.1 This is exactly what i have done. I created a new solver and linked to it the new libraries. This is how the Make/option file looks like (again in red the new parts) Code:
EXE_INC = \ -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/fvOptions/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I./myInterfaceProperties/lnInclude \ -I./myTwoPhaseProperties/lnInclude EXE_LIBS = \ -ltwoPhaseMixture \ -linterfaceProperties \ -ltwoPhaseProperties \ -lincompressibleTransportModels \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleLESModels \ -lsampling \ -lfiniteVolume \ -lfvOptions \ -ltriSurface \ -lmeshTools \ -lmyInterfaceProperties \ -lmyTwoPhaseProperties Andrea |
|
January 7, 2016, 12:53 |
|
#4 | |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
Quote:
- you will create and will use child class from interfaceProperties - you will leave only your own version of interfaceProperties
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
||
January 7, 2016, 13:08 |
|
#5 |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
By the way, did you renamed your twoPhaseProperties class?
It looks like a mismatch in data types naming
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
|
January 7, 2016, 13:37 |
|
#6 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
I quickly tried to remove the link i don't need to the old libraries, recompiled but the error is still there. The Make/option file now is
Code:
EXE_INC = \ -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/fvOptions/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/sampling/lnInclude \ -I./myInterfaceProperties/lnInclude \ -I./myTwoPhaseProperties/lnInclude EXE_LIBS = \ -ltwoPhaseMixture \ -ltwoPhaseProperties \ -lincompressibleTransportModels \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleLESModels \ -lsampling \ -lfiniteVolume \ -lfvOptions \ -ltriSurface \ -lmeshTools \ -lmyInterfaceProperties \ -lmyTwoPhaseProperties Before, I successfully compiled and used the same solver (with both "old" and "new" interfaceProperties and twoPhaseProperties linked to the main program) but without the additional fields (DeltaX and DeltaY) in the new myInterfaceProperties. Now i need to perform extra calculation and i would like to do it inside the library. That's why i am trying to pass the two fields. I think the error is somewhere there. maybe a wrong variable declaration? anyway thanks for spending your time on it! Andrea |
|
January 7, 2016, 13:49 |
|
#7 |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
There is a type conflict somewhere else. My suggestion is to re-use standard OpenFOAM classes:
in .H: Code:
class myInterfaceProperties : public interfaceProperties Code:
Foam::myInterfaceProperties::myInterfaceProperties ( const volScalarField& alpha1, const volVectorField& U, const volScalarField& DeltaX, const volScalarField& DeltaY, const IOdictionary& dict ) : interfaceProperties(alpha1, U, dict) dx_(DeltaX), dy_(DeltaY), Also, i took part in this thread where this problem was also solved Adding the Energy Equation to interFoam (OF 2.4.0)
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
|
January 8, 2016, 10:57 |
|
#8 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
Hello,
after a depth debugging i think i understand (at least) where the error comes from but still i do not know how to fix it. I rewrote the library adding things step by step. Now i am able to corretly pass the two fields DeltaX and DeltaY. The error seems to be generated by another volScalarField i defined inside the library. The variable is named nuGamma_ in myInterfaceProperties.C i added the variable constructor by copy paste nHatf_ from the original interfaceProperties.C Code:
nuGamma_ ( IOobject ( "nuGamma", alpha1_.time().timeName(), alpha1_.mesh() ), alpha1_.mesh(), dimensionedScalar("nuGamma", dimless, 0.0) ), Code:
/*---------------------------------------------------------------------------*\ Class myInterfaceProperties Declaration \*---------------------------------------------------------------------------*/ class myInterfaceProperties { . . volScalarField nuGamma_; . . . // Member Functions . const volScalarField& nuGamma() const { return nuGamma_; } With these lines i got the error in my first post, without these line the code runs with no problem. I really dont see where is the problem. |
|
January 8, 2016, 12:45 |
|
#9 |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
This problem can be solved easily - check that you are initializing alpha1_ before nuGamma_
If this works, tell me, and i will give explanation later
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
|
January 8, 2016, 15:41 |
|
#10 |
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 319
Rep Power: 16 |
oh...that was really easy...it works
I did not know it was important the initialization order...i learn new things every day... thank you very much andrea |
|
January 9, 2016, 03:29 |
|
#11 |
Senior Member
Matvey Kraposhin
Join Date: Mar 2009
Location: Moscow, Russian Federation
Posts: 355
Rep Power: 21 |
Hi,
Yes, initialization order makes sense. Sometimes, compiler watches for this - for example, if you declare dx_ and then dy_ in interfaceProperties.H, but initialize dx_ after dy_ in interfaceProperties.C, you will get compiler "warning". This should not generate error in most cases. But it is a good practice to declare and initialize variables in the same order In your case, you tried to use members of reference to object (volScalarField& alpha1_), which was not initialized. Reference - is a special type of C++, which must be initialized during it's definition. In your case, everything, that is between body of constructor " {} " and arguments " : " is treated as the default initialization for members, declared in interfaceProperties.H
__________________
MDPI Fluids (Q2) special issue for OSS software: https://www.mdpi.com/journal/fluids/..._modelling_OSS GitHub: https://github.com/unicfdlab Linkedin: https://linkedin.com/in/matvey-kraposhin-413869163 RG: https://www.researchgate.net/profile/Matvey_Kraposhin |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Multi species mass transport library [update] | novyno | OpenFOAM Community Contributions | 111 | November 9, 2021 23:37 |
ERROR: unable to find library | HJH | CFX | 6 | February 26, 2019 06:52 |
decomposePar is missing a library | whk1992 | OpenFOAM Pre-Processing | 8 | March 7, 2015 07:53 |
Compiled library vs. inInclude Files, DSMC solver crashes after run | GPesch | OpenFOAM Programming & Development | 8 | April 18, 2013 07:17 |
OpenFOAM141dev linking error on IBM AIX 52 | matthias | OpenFOAM Installation | 24 | April 28, 2008 15:49 |