|
[Sponsors] |
August 5, 2020, 08:30 |
New scalar like alphaMax in phaseModel.c
|
#1 |
Senior Member
|
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? |
|
August 7, 2020, 04:04 |
|
#2 |
Senior Member
|
Nobody has any suggestion?
|
|
August 18, 2020, 11:56 |
|
#3 |
Senior Member
|
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 ??:? |
|
August 18, 2020, 12:15 |
|
#4 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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 ) ); Hope that helps, Gerry. |
|
August 18, 2020, 12:41 |
|
#5 |
Senior Member
|
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) |
|
August 19, 2020, 04:39 |
|
#6 | |
Member
Rohit George Sebastian
Join Date: May 2017
Posts: 42
Rep Power: 9 |
Quote:
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; Code:
Info<< "Starting calculation loop" << endl; |
||
August 19, 2020, 05:51 |
|
#7 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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 ); Cheers, Gerry. |
|
August 19, 2020, 06:15 |
|
#8 | |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
Dear YQ:
Quote:
Gerry. |
||
August 20, 2020, 05:33 |
|
#9 |
Senior Member
|
Dear Gerry,
I really don't know where the error occurs. You did it successfully? |
|
August 20, 2020, 05:36 |
|
#10 | |
Senior Member
|
Quote:
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? |
||
August 20, 2020, 05:44 |
|
#11 | |
Senior Member
|
Quote:
I think the problem is the way of defining "myBeta". However, I have not yet find the solution. |
||
August 22, 2020, 03:27 |
|
#12 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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. |
|
August 24, 2020, 14:47 |
|
#13 | |
Senior Member
|
Quote:
|
||
August 24, 2020, 14:51 |
|
#14 |
Senior Member
|
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?
|
|
August 25, 2020, 05:27 |
|
#15 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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. |
|
August 25, 2020, 05:37 |
|
#16 | |
Senior Member
|
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:
|
||
August 25, 2020, 06:51 |
|
#17 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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. |
|
August 25, 2020, 06:58 |
|
#18 | |
Senior Member
|
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:
|
||
August 25, 2020, 11:20 |
|
#19 |
Senior Member
Gerry Kan
Join Date: May 2016
Posts: 376
Rep Power: 11 |
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. |
|
August 25, 2020, 12:21 |
|
#20 | |
Senior Member
|
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:
|
||
Tags |
phasemodel, twophaseeuelrfoam, twophasesystem |
|
|
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 |