|
[Sponsors] |
adding values to transportProperties in interFoam |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
April 15, 2010, 04:13 |
adding values to transportProperties in interFoam
|
#1 |
New Member
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16 |
Hi all!
I am trying to implement a temperature equation to the interFoam solver for simulation of the filling stage in a injection molding process. I have looked at the implementation made in: Diverging result for Temperature field in interFoam. The solver compiles just fine, but when i try to run a case, the solver stops before the equations are solved. I have found out that the error occurs in createFields.H when reading the specifik heat (cp) and thermal conductivity (kT) that i have added. Somehow OF reads the values i have specified in transportProperties wrong! Can anyone give me some idea as too what might be the problem? Code from createFields.H: Code:
... const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2(); const dimensionedScalar& cp1 = twoPhaseProperties.cp1(); const dimensionedScalar& cp2 = twoPhaseProperties.cp2(); const dimensionedScalar& kT1 = twoPhaseProperties.kT1(); const dimensionedScalar& kT2 = twoPhaseProperties.kT2(); Info << "Read transportproperties succesfully\n" << endl; // Need to store rho for ddt(rho, U) volScalarField rho ( IOobject ( "rho", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*rho1 + (scalar(1) - alpha1)*rho2, alpha1.boundaryField().types() ); rho.oldTime(); // Need to store cp for TEqn! Info << "Saving cp values!\n" << endl; volScalarField cp ( IOobject ( "cp", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*cp1 + (scalar(1) - alpha1)*cp2, alpha1.boundaryField().types() ); // cp.oldTime(); // what does this do? // Need to store kT for TEqn! Info << "Saving kT values!\n" << endl; volScalarField kT ( IOobject ( "kT", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT ), alpha1*kT1 + (scalar(1) - alpha1)*kT2, alpha1.boundaryField().types() ); // kT.oldTime(); // what does this do? ... Code:
/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | | \\ / O peration | Version: 1.6 | | \\ / A nd | Web: www.OpenFOAM.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ FoamFile { version 2.0; format ascii; class dictionary; location "constant"; object transportProperties; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // phase1 // Liquid { transportModel Newtonian; nu nu [ 0 2 -1 0 0 0 0 ] 1e-06; rho rho [ 1 -3 0 0 0 0 0 ] 1000; cp cp [ 0 2 -2 -1 0 0 0 ] 660; kT kT [ 1 1 -3 -1 0 0 0 ] 1.54; } phase2 // Air { transportModel Newtonian; nu nu [ 0 2 -1 0 0 0 0 ] 1.48e-05; rho rho [ 1 -3 0 0 0 0 0 ] 1; cp cp [ 0 2 -2 -1 0 0 0 ] 1009; kT kT [ 1 1 -3 -1 0 0 0 ] 2.85e-02; } sigma sigma [ 1 0 -2 0 0 0 0 ] 0.07; // ************************************************************************* // |
|
April 15, 2010, 08:27 |
|
#2 |
Senior Member
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18 |
Hi,
I've successfully implemented exactly this some time ago. Try this for reading cp (and kT as well): dictionary phase1 = transportProperties.subDict("phase1"); dimensionedScalar cp1 = phase1.lookup("cp"); Good luck Stefan |
|
April 15, 2010, 09:13 |
|
#3 |
New Member
Dan Gadensgaard
Join Date: Apr 2010
Posts: 13
Rep Power: 16 |
Thanks a lot herbert!
That worked like a charm! |
|
January 17, 2011, 09:46 |
|
#4 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Hi interFoamers,
if I want to define temperature-dependent densities for each phase, which implementation of twoPhaseMixture would you suggest me? Simply imitating already existing fields I came up with a couple of variants, but I haven't a clue what's the difference between them: in twoPhaseMixture.H: a) Code:
volScalarField rho1_; virtual tmp<volScalarField> rho1() const { return rho1_; } Code:
tmp<volScalarField> rho1() const; I will also need the T-field (temperature), so should I add following lines: twoPhaseMixture.H: Code:
const surfaceScalarField& T_; Code:
T_(T), And why twoPhaseMixture.C looks so complicated for alpha1? Code:
alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)), Code:
alpha1_(alpha1), |
|
January 17, 2011, 09:53 |
|
#5 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Well, yet another question:
Defining a temperature dependent rho1()-field would imply calculation of rho1-values even for those cells without phase1. Is there a more efficient way? Edit: Trying to answer my own question from the previous post (the first one), I guess that the a) variant makes sense since rho1_ is being used repeatedly in twoPhaseMixture.C. But it's still isn't clear to me if the public rho1() field has to be declared as virtual and tmp<>. The T_(T)-question is still open. Last edited by linch; January 17, 2011 at 12:37. |
|
May 27, 2011, 12:04 |
|
#6 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
Some more questions:
1). Being newcomer in C++ I don't really understand the implementation of the constructor for twoPhaseMixture objects. I walked though a C++ tutorial and learned, that a constructor for an object of the class Code:
class someClass {...}; Code:
someClass::someClass (inputParameters,...) {...}; Code:
twoPhaseMixture::twoPhaseMixture (inputParameters,...):somethingElse,... {...}; 2). For example twoPhaseMixture.H: Code:
const volVectorField& U_; //intern protected parameter ... const volVectorField& U, //public input parameter twoPhaseMixture.C (within the constructor): Code:
U_(U), |
|
May 28, 2011, 14:06 |
|
#7 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
1) The stuff after the colon is the initialiser list. It constructs other objects (such as transportModel) and its own member variables that you can see declared in the header file.
2) U_ is a reference to the velocity, U, that is passed by reference through the constructor for twoPhaseMixture.
__________________
Laurence R. McGlashan :: Website |
|
May 30, 2011, 05:16 |
|
#8 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
1) Thanks a lot, I've got it
2) What's the need of creating U_ if it is equal to U (both are const and both are pointers to the U-storage)? |
|
May 30, 2011, 06:41 |
|
#9 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
Don't think of references as pointers. Think of a reference as an alias for an object; U_is in fact U. U_ is needed if any of the member functions in twoPhaseMixture require knowledge of U.
__________________
Laurence R. McGlashan :: Website |
|
May 30, 2011, 07:30 |
|
#10 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
||
May 30, 2011, 07:41 |
|
#11 |
Senior Member
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23 |
You can use U in the class constructor to initialize objects and variables, but functions in the class cannot see U. Try accessing it from within a class member function and you'll see it doesn't compile.
That's why there is an alias, U_.
__________________
Laurence R. McGlashan :: Website |
|
May 30, 2011, 07:50 |
|
#12 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
I see...Thank you very much once again.
|
|
May 30, 2011, 08:20 |
|
#13 |
Senior Member
Illya Shevchuk
Join Date: Aug 2009
Location: Darmstadt, Germany
Posts: 176
Rep Power: 17 |
And how can one understand the initialisation of alpha1_ with:
Code:
U_.db().lookupObject<const volScalarField> (alpha1Name) |
|
September 4, 2011, 02:27 |
|
#14 |
New Member
Join Date: Nov 2010
Posts: 10
Rep Power: 16 |
hi dear
i have a case that i want to solve 2 phase (liq-air) with heat transfer. i read your note then i ask u to help me for solve this problem.(if its possible give me your code) thanks in advance. |
|
September 27, 2012, 17:59 |
newbie question about changes to interFoam
|
#15 |
Member
Join Date: Mar 2010
Posts: 31
Rep Power: 16 |
Hi,
I've been using openFoam for a couple of years now, have gotten comfortable with using the solvers that exist. Now it's time to get elbows deep and change a solver to deal with a new problem. I've read through the programmer's guide, and managed a tutorial or two I found on the web. In principle, I should be able to make the changes I need in a local solver, and not make changes at the top(library) level, is that correct? I'd like to add a new scalar and vector field to the interFoam example. Not unlike the transport discussed here (we'll save the vector field for another day). As the original poster had trouble defining the variables in createFields.H, I too had problems there. The solution which seemed to work was: dictionary phase1 = transportProperties.subDict("phase1"); dimensionedScalar cp1 = phase1.lookup("cp"); My question is: where does this get defined? In createFields.H ? or do I have to edit the class twoPhaseMixture? One of the examples I worked through just had a new vector field that got its own *.H in the */applications/solvers/(example) directory. The new data was included in the case/0 directory, and a local compile was all that was necessary. Any help would be appreciated. Or, more examples to work through. I have found tutorials of new variables specifically applied to interFoam, so if anyone knows of those I'd really appreciate that. Thanks |
|
April 16, 2019, 09:29 |
|
#16 |
New Member
xena
Join Date: Mar 2019
Posts: 13
Rep Power: 7 |
hi,
What does (sigma) in the transportproporties script mean? is it a constraint ? what does induce it ? |
|
Tags |
density, interfoam, programming, specifik heat, temperature, thermal conductivity |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Adding temperature field to InterFoam | yapalparvi | OpenFOAM Running, Solving & CFD | 8 | October 14, 2009 21:18 |
max node values exceed max element values in contour plot | jason_t | FLUENT | 0 | August 19, 2009 12:32 |
Adding imaginary patch for calculation of average values | bboonacker | OpenFOAM Running, Solving & CFD | 4 | June 2, 2009 00:00 |
strange node values @ solid/fluid interface - help | JB | FLUENT | 2 | November 1, 2008 13:04 |
Adding all the values in a post register | Cb | Siemens | 3 | March 11, 2005 14:40 |