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

New scalar like alphaMax in phaseModel.c

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 5, 2020, 08:30
Question New scalar like alphaMax in phaseModel.c
  #1
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Hi guys,

I added a new scalar in twophasesystem/phaseModel.C and I compiled successfully. The problem is that there is an error when I run the case. My objective is to use this constant in phasePair.C to calculate Re(). In oder to change the constant myBeta directly from dictionary (phaseProperties) without compiling every time, I think it is necessary to add a new scalar like alphaMax in phaseModel.C. Do you have any tip?
Attached Images
File Type: png WeChat Screenshot_20200805132154.png (64.8 KB, 23 views)
File Type: png WeChat Screenshot_20200805132232.png (44.0 KB, 15 views)
qi.yang@polimi.it is offline   Reply With Quote

Old   August 7, 2020, 04:04
Default
  #2
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Nobody has any suggestion?
qi.yang@polimi.it is offline   Reply With Quote

Old   August 18, 2020, 11:56
Default
  #3
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
The error message is as follows:

Reading g

Reading hRef
Creating twoPhaseSystem

Selecting thermodynamics package
{
type heRhoThermo;
mixture pureMixture;
transport const;
thermo hConst;
equationOfState rhoConst;
specie specie;
energy sensibleEnthalpy;
}

Calculating face flux field phi.solids
Selecting diameterModel for phase solids: constant
Selecting turbulence model type RAS
Selecting RAS turbulence model phasePressure
phasePressureCoeffs
{
preAlphaExp 500;
expMax 1000;
alphaMax 1;
g0 0;
}

Selecting thermodynamics package
{
type heRhoThermo;
mixture pureMixture;
transport const;
thermo hConst;
equationOfState rhoConst;
specie specie;
energy sensibleEnthalpy;
}

Calculating face flux field phi.water
Selecting diameterModel for phase water: constant
Selecting turbulence model type RAS
Selecting RAS turbulence model diffusionkEpsilon
RAS
{
RASModel diffusionkEpsilon;
turbulence on;
printCoeffs on;
Cmu 0.09;
C1 1.44;
C2 1.92;
C3 0;
sigmak 1;
sigmaEps 1.3;
mysigmake 1;
}

[3] #0 [4] #0 Foam::error:rintStack(Foam::Ostream&)[12] #0
[0] #1 Foam::sigSegv::sigHandler(int) at ??:?
at [3] #1 Foam::sigSegv::sigHandler(int)??:?
at ??:?
at at ??:?
??:?
at ??:?
[4] #1 Foam::sigSegv::sigHandler(int) at ??:?
at [10] #1 Foam::sigSegv::sigHandler(int) at ??:?
[13] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
[2] #1 Foam::sigSegv::sigHandler(int)??:?
at at [11] #1 Foam::sigSegv::sigHandler(int)??:?
??:?
[14] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
[28] #1 Foam::sigSegv::sigHandler(int)[24] #1 Foam::sigSegv::sigHandler(int)[26] #1 Foam::sigSegv::sigHandler(int)[16] #1 Foam::sigSegv::sigHandler(int)[18] #1 Foam::sigSegv::sigHandler(int)[27] #1 Foam::sigSegv::sigHandler(int)[22] #1 Foam::sigSegv::sigHandler(int)[25] #1 Foam::sigSegv::sigHandler(int) at ??:?
[12] #1 Foam::sigSegv::sigHandler(int) at ??:?
[29] #1 Foam::sigSegv::sigHandler(int) at ??:?
[21] #1 Foam::sigSegv::sigHandler(int) at ??:?
at [23] #1 Foam::sigSegv::sigHandler(int)??:?
[6] #1 Foam::sigSegv::sigHandler(int) at ??:?
[5] #1 Foam::sigSegv::sigHandler(int) at ??:?
at ??:?
at ??:?
at ??:?
at ??:?
[7] #1 Foam::sigSegv::sigHandler(int)[9] #1 Foam::sigSegv::sigHandler(int)[15] #1 Foam::sigSegv::sigHandler(int)[20] #1 Foam::sigSegv::sigHandler(int)[1] #1 Foam::sigSegv::sigHandler(int) at ??:?
qi.yang@polimi.it is offline   Reply With Quote

Old   August 18, 2020, 12:15
Default
  #4
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Salve YQ:

I think lookupOrDefault is now a templated function. You will need something like this (I am using OF7, and as far as I know it is introduced in OF6):

Code:
scalar myBeta_;
// in your constructor
myBeta_ ( phaseDict_.lookupOrDefault<scalar> ( "myBeta", 1.0 ) );
Now I have not used this in another constructor, so I don't know if the scalar type is understood in your case (though I doubt it).

Hope that helps, Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 18, 2020, 12:41
Default
  #5
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Thanks Gerry.

As you can see the default scalar alphaMax was already defined, thus I just copied it and changed the name. So weird.

After I changed the code like you show, the same error occurs:

Selecting default blending method: none
Selecting dragModel for (solids in water): SchillerNaumann
Selecting swarmCorrection for (solids in water): none
#0 Foam::error:rintStack(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)
qi.yang@polimi.it is offline   Reply With Quote

Old   August 19, 2020, 04:39
Default
  #6
RGS
Member
 
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9
RGS is on a distinguished road
Quote:
Originally Posted by qi.yang@polimi.it View Post
Thanks Gerry.

As you can see the default scalar alphaMax was already defined, thus I just copied it and changed the name. So weird.

After I changed the code like you show, the same error occurs:

Selecting default blending method: none
Selecting dragModel for (solids in water): SchillerNaumann
Selecting swarmCorrection for (solids in water): none
#0 Foam::error:rintStack(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)

Hi,

If you insert some info statements in the solver code, you will be able to better determine where exactly the error occurs and then work from there. Maybe there is some other line of code before reading myBeta that is causing the solver to crash. Or maybe the problem is not with the solver, but with the case files.

Code:
Info<< "Read field A" << endl;
or

Code:
Info<< "Starting calculation loop" << endl;
I hope this helps
RGS is offline   Reply With Quote

Old   August 19, 2020, 05:51
Default
  #7
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Buongiorno YQ:

I really don't know why. If you haven't tried it already, did you check if the constructor compiled and ran with a hard-coded value?

Code:
// in your constructor
myBeta_ ( 1.0 );
The code should run, and if it still crashes, the problem is probably somewhere else. (I mean, not on the lookupOrDefault)

Cheers, Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 19, 2020, 06:15
Default
  #8
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Dear YQ:

Quote:
Originally Posted by Gerry Kan View Post
Salve YQ:

I think lookupOrDefault is now a templated function. You will need something like this (I am using OF7, and as far as I know it is introduced in OF6):

Code:
scalar myBeta_;
// in your constructor
myBeta_ ( phaseDict_.lookupOrDefault<scalar> ( "myBeta", 1.0 ) );
I realized I was wrong. While working on a fvPatchField I saw that in the constructor you don't need the <scalar>. My bad.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 20, 2020, 05:33
Default
  #9
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Dear Gerry,

I really don't know where the error occurs. You did it successfully?
qi.yang@polimi.it is offline   Reply With Quote

Old   August 20, 2020, 05:36
Default
  #10
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Quote:
Originally Posted by Gerry Kan View Post
Buongiorno YQ:

I really don't know why. If you haven't tried it already, did you check if the constructor compiled and ran with a hard-coded value?

Code:
// in your constructor
myBeta_ ( 1.0 );
The code should run, and if it still crashes, the problem is probably somewhere else. (I mean, not on the lookupOrDefault)

Cheers, Gerry.
Buongiorno Gerry,

Grazie per le risposte. Pero ho il problem stesso ancora. Sei riuscito a definire un scalar come "myBeta" in quelli file e hai fatto la simulazione con successo?
qi.yang@polimi.it is offline   Reply With Quote

Old   August 20, 2020, 05:44
Default
  #11
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Quote:
Originally Posted by RGS View Post
Hi,

If you insert some info statements in the solver code, you will be able to better determine where exactly the error occurs and then work from there. Maybe there is some other line of code before reading myBeta that is causing the solver to crash. Or maybe the problem is not with the solver, but with the case files.

Code:
Info<< "Read field A" << endl;
or

Code:
Info<< "Starting calculation loop" << endl;
I hope this helps
Thanks a lot. Rohit
I think the problem is the way of defining "myBeta". However, I have not yet find the solution.
qi.yang@polimi.it is offline   Reply With Quote

Old   August 22, 2020, 03:27
Default
  #12
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Salve YQ,

è passato molto tempo dall'ultima volta che ho scritto in italiano, quindi contraccambio ...

Nel modo in cui volevi inizializzare il suo "scalar" in un costruttore, l'ho fatto solo all'interno di un fvPatchField. La variabile è dichiarata nella definizione della classe e le viene assegnato un valore iniziale (con un "dict", ad esempio) utilizzando un costruttore.

In qualsiasi altra parte del codice, in particolare nella funzione main (), li dichiaro semplicemente all'inizio del codice e assegno loro i valori del dizionario all'inizio. Ovviamente in questo caso deve definire il suo oggetto "dict".

Gerry.

Last edited by Gerry Kan; August 22, 2020 at 05:55.
Gerry Kan is offline   Reply With Quote

Old   August 24, 2020, 14:47
Default
  #13
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Quote:
Originally Posted by Gerry Kan View Post
Salve YQ,

è passato molto tempo dall'ultima volta che ho scritto in italiano, quindi contraccambio ...

Nel modo in cui volevi inizializzare il suo "scalar" in un costruttore, l'ho fatto solo all'interno di un fvPatchField. La variabile è dichiarata nella definizione della classe e le viene assegnato un valore iniziale (con un "dict", ad esempio) utilizzando un costruttore.

In qualsiasi altra parte del codice, in particolare nella funzione main (), li dichiaro semplicemente all'inizio del codice e assegno loro i valori del dizionario all'inizio. Ovviamente in questo caso deve definire il suo oggetto "dict".

Gerry.
Grazie tanto, Gerry. Sto incontrando il problem stesso. Non so come lo risolvo...
qi.yang@polimi.it is offline   Reply With Quote

Old   August 24, 2020, 14:51
Default
  #14
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Hi everyone, I uploaded the solver files but I deleted those two folders "phasecompressibleturbulencemodel" and "interfacialmodel". because I only modified the phaseModel file, in order to define a new scalar myBeta, according to the definition procedure of alphaMax. There is no compilation error but segmentation fault occurs after I run the case file. Do you have any tip?
Attached Files
File Type: zip 2020twoPhaseEulerFoam.zip (88.6 KB, 2 views)
qi.yang@polimi.it is offline   Reply With Quote

Old   August 25, 2020, 05:27
Default
  #15
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Dear YQ:

I looked quickly at your code, and like you said it should compile (and I think this is also what you saw).

A suggestion for you perhaps is to put faceMomentum and implicitPhasePressure in a separate dictionary. I don't know (and it is an expression of doubt) if you can just introduce your own keys in the system dicts just like that.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 25, 2020, 05:37
Default
  #16
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Dear Gerry,

Thanks. There is no error about compiling but only sementation fault occurs after ran the case file. As you can find, I only modified the phaseModel.C and phaseModel.H under the "twophasesystem" folder. The point is that I defined a new scalar in the same way as the default scalar definition. Why the problem will be generated?

Quote:
Originally Posted by Gerry Kan View Post
Dear YQ:

I looked quickly at your code, and like you said it should compile (and I think this is also what you saw).

A suggestion for you perhaps is to put faceMomentum and implicitPhasePressure in a separate dictionary. I don't know (and it is an expression of doubt) if you can just introduce your own keys in the system dicts just like that.

Gerry.
qi.yang@polimi.it is offline   Reply With Quote

Old   August 25, 2020, 06:51
Default
  #17
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Dear YQ:

I did something similar in my solver, in which I read in dictionary values and load them in at the start of the solver before the time loop. I collected these custom settings in a separate dictionary and read them in accordingly. This worked for me.

From what I have seen in your code, it seems that you are trying to set up these keys in the default dictionaries (e.g., controlDict or fvSolution, to be honest I don't know what they are called). I personally don't know if you can modify these default dictionaries. This is why I suggested creating a separate dictionary for your own settings.

Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 25, 2020, 06:58
Default
  #18
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Hi Gerry,

In fact, I defined the scalar in the phaseProperty dictionary not fvSolution or controlDict. Because the scalar should be used in the files under twophasesystem class. Thus, I have to define it in the phaseModel.C, which can be changed in the phaseProperty dictionary in the case file.

Quote:
Originally Posted by Gerry Kan View Post
Dear YQ:

I did something similar in my solver, in which I read in dictionary values and load them in at the start of the solver before the time loop. I collected these custom settings in a separate dictionary and read them in accordingly. This worked for me.

From what I have seen in your code, it seems that you are trying to set up these keys in the default dictionaries (e.g., controlDict or fvSolution, to be honest I don't know what they are called). I personally don't know if you can modify these default dictionaries. This is why I suggested creating a separate dictionary for your own settings.

Gerry.
qi.yang@polimi.it is offline   Reply With Quote

Old   August 25, 2020, 11:20
Default
  #19
Senior Member
 
Gerry Kan's Avatar
 
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11
Gerry Kan is on a distinguished road
Dear YQ:

I am not familiar with two phase flows in OpenFOAM, so I would like to ask if phaseProperty a predefined dictionary? (From the fact that you didn't have to define it, I guess it comes from it).

What I wanted to say is, try to collect all your own keys in a new dictionary to see if it works.

Another thing, when you initialize your custom variables with hard coded values, did you solver still crash?

Gerry.
Gerry Kan is offline   Reply With Quote

Old   August 25, 2020, 12:21
Default
  #20
Senior Member
 
kimy
Join Date: Mar 2019
Location: https://t.me/pump_upp
Posts: 164
Rep Power: 7
qi.yang@polimi.it is on a distinguished road
Send a message via ICQ to qi.yang@polimi.it Send a message via AIM to qi.yang@polimi.it Send a message via Yahoo to qi.yang@polimi.it
Hi Gerry,

That is definite a predefined dictionary. What you mean is that we cannot define a new thing in that type of file? Previously, I used to define a new dictionary in createFields.H and call the variable I defined in the solver main files without any problem. However, now I have to define it in a sub model. Grazie comunque.



Quote:
Originally Posted by Gerry Kan View Post
Dear YQ:

I am not familiar with two phase flows in OpenFOAM, so I would like to ask if phaseProperty a predefined dictionary? (From the fact that you didn't have to define it, I guess it comes from it).

What I wanted to say is, try to collect all your own keys in a new dictionary to see if it works.

Another thing, when you initialize your custom variables with hard coded values, did you solver still crash?

Gerry.
qi.yang@polimi.it is offline   Reply With Quote

Reply

Tags
phasemodel, twophaseeuelrfoam, twophasesystem


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
problem during mpi in server: expected Scalar, found on line 0 the word 'nan' muth OpenFOAM Running, Solving & CFD 3 August 27, 2018 05:18
Division by zero exception - loop over scalarField Pat84 OpenFOAM Programming & Development 6 February 18, 2017 06:57
Issue symmetryPlane 2.5d extruded airfoil simulation 281419 OpenFOAM Running, Solving & CFD 5 November 28, 2015 14:09
Diverging solution in transonicMRFDyMFoam tsalter OpenFOAM Running, Solving & CFD 30 July 7, 2014 07:20
compressible flow in turbocharger riesotto OpenFOAM 50 May 26, 2014 02:47


All times are GMT -4. The time now is 17:53.