New scalar in phaseModel.c
-
I guess you use
myBeta_
just like alphaMax:myBeta()
, or just by its name?
the position where you put the declaration ofmyBeta_
shows thatmyBeta_
is a private variable.
myBeta_(phaseDict_.lookuporDefault("myBeta", 1.0)),
is OK, because it's just initialization.you should define a member function to return a private variable just like alphaMax().
the errors seems like lost address of something. Maybe the private variable's address without authority.
-
@kimy try this way: just define myBeta_ and do not use it.
see is there any error. if not, the errors are caused by function myBeta().
otherwise, keep on delete the part of code you added until the errors disapear.
you'll find the "error" code.if the error occurs after you delete all the modification. you should check the makefile.
principle: make sure origin code works well. then, add your code slowly. (add one or two lines and run it )
so it's easy find which part of code is wrong. -
I really don't know why the error always happen in which I did not used myBeta only definition. Even thought, I only added one piece of codes, such as "scalar myBeta". The same error occurs. Could you please help me to try to define one scalar in those file and see what will happen? Really thanks for your help!
-
here is diff result of lib file and case file compared with origin files.
diff.zipoutput:
PIMPLE: Iteration 1 alphaMax():0.62alphaMax lue lue lue lue lue lue alphamyBeta():1.23myBeta ha ha ha ha ha ha ha ha alphaMax():1alphaMax lue lue lue lue lue lue alphamyBeta():1myBeta ha ha ha ha ha ha ha ha MULES: Solving for alpha.particles MULES: Solving for alpha.air particles fraction, min, max = 0.275003 0 0.55 air fraction, min, max = 0.724997 0.45 1 Phase-sum volume fraction, min, max = 1 1 1 alphaMax():0.62alphaMax lue lue lue lue lue lue alphamyBeta():1.23myBeta ha ha ha ha ha ha ha ha alphaMax():1alphaMax lue lue lue lue lue lue alphamyBeta():1myBeta ha ha ha ha ha ha ha ha
my way(without mention the modification shown in diff file ):
- copy entire multiphaseEulerFoam into $FOAM_RUN/applications/solvers (bu not ./Allwamke)
can@x260-TC ~/Documents/code/C/openfoam/can-8/applications/solvers %tree -L 2 (git)-[master]- . └── multiphaseEulerFoam ├── Allwclean ├── Allwmake ├── functionObjects ├── include ├── interfacialCompositionModels ├── interfacialModels ├── multiphaseCompressibleMomentumTransportModels ├── multiphaseEulerFoam ├── multiphaseThermophysicalTransportModels └── phaseSystems 9 directories, 2 files
- find and replace all
$(FOAM_LIBBIN)
with$(FOAM_USER_LIBBIN)
find ./ -type f -exec sed -i 's/\$(FOAM_LIBBIN)/\$(FOAM_USER_LIBBIN)/' {} \;
- enter
phaseSystems
runwmake
to buildlibmyphaseSystem.so
- enter
multiphaseEulerFoam
runwmake
(not ./Allwamke) to build solvermymultiphaseEulerFoam
- run the case
-
@bestucan Many Thanks. I have a confusion that you defined the following two scalar and function in phaseModel.H
< scalar myBeta_; 195,196d193 < < scalar myBeta() const;
While in original file, according to the definition of alphaMax
scalar myBeta() const { return myBeta_; }
and you put this code in phaseModel.C ?
/home/can/.local/share/OpenFOAM/OpenFOAM-8/applications/solvers/multiphase/multiphaseEulerFoam/phaseSystems/phaseModel/phaseModel/phaseModel.C 88,89c88 < alphaMax_(fluid.subDict(phaseName).lookupOrDefault("alphaMax", 1.0)), < myBeta_(fluid.subDict(phaseName).lookupOrDefault("myBeta", 1.0)) --- > alphaMax_(fluid.subDict(phaseName).lookupOrDefault("alphaMax", 1.0)) 143,147d141 < } < < Foam::scalar Foam::phaseModel::myBeta() const < { < retu
-
@kimy yes, declaration in .H file and definition in .C file.
declaration of function myBeta() in phaseModel.H
//- Return the maximum phase-fraction (e.g. packing limit) scalar alphaMax() const; scalar myBeta() const;
and definition of function myBeta() in phaseModel.C
Foam::scalar Foam::phaseModel::alphaMax() const { return alphaMax_; } Foam::scalar Foam::phaseModel::myBeta() const { return myBeta_; }
-
@bestucan But why alphaMax() was originally defined in the phaseModel.H without any error?
scalar alphaMax() const { return alphaMax_; }
After I defined only scalar myBeta() in phaseModel.H, the following error occurs:
In file included from phaseModel/phaseModel.C:26:0: phaseModel/phaseModel.H:158:29: error: invalid declarator before 'd' tmp<volScalarField> d() const; ^ phaseModel/phaseModel.H:162:26: error: non-member function 'const Foam::PhaseCompressibleTurbulenceModel<Foam::phaseModel>& Foam::turbulence()' cannot have cv-qualifier turbulence() const;
-
@kimy because the position of this part
scalar alphaMax() const { return alphaMax_; }
in phaseModel.H belong to the declaration of class phaseModel.
so you do have to name alphaMax() as phaseModel::alphaMax()
as for "Foam::", just for rigorous."declaration in H and define in C" is not something like ban. just a rule free to follow. and it's a good habit.
you had edit your last post and delete the important part. I've seen it. you lost a ";". and error also said "invalid declarator before 'd'"
-
@bestucan I am a little bit crazy because my files are totally same as yours.......Still error after run. Note that I did not change the default library into user's library (All of them I leave it as defualt "LIB = $(FOAM_LIBBIN)/liblibcompressibleTwoPhaseSystem"
). -
Selecting default blending method: none Selecting dragModel for (solids in water): SchillerNaumann Selecting swarmCorrection for (solids in water): none #0 Foam::error::printStack(Foam::Ostream&) at ??:? #1 Foam::sigSegv::sigHandler(int) at ??:? #2 ? in /lib64/libc.so.6 #3 ? at ??:? #4 __libc_start_main in /lib64/libc.so.6 #5 ? at ??:? Segmentation fault (core dumped)
-
@kimy do it slowly.
1 find a normal case which works well. ensure basement is good
2 add myBeta() only, and not use it. ensure compile works
3 use cout << myBeta() << "somg flag". ensure function myBeta() works.
4 use myBeta_ as a constant value in calculation. ensure framework is well.
5 use myBeta_ as variabledivide int more step if needed
then use it as your wish. special case, special solver. If something wrong. there's nothing to do with myBeta(). maybe case? maybe solver? maybe variable overflow?
you combine all steps into one step. it's hardly to debug.
have you print myBeta_ value? just same as the value in case file?the error message seems not a special error. something about cout (Ostream&)
-
-
@bestucan Thanks a lot. What you mean is that you did not meet any problem in your OpenFOAM version? Could you please upload the whole modified solver files here (twophaseeulerfoam)? The files I uploaed above was copied from blueCFD (maybe openfoam 5). Additionally, I am also using HPC where openfoam-v1906 is loaded.
-
This is the solver file of openfoam_v1906