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

adding "h" field to sonicFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree1Likes
  • 1 Post By wyldckat

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 15, 2013, 10:38
Default adding "h" field to sonicFoam
  #1
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Hi
how can add "h" field to sonicFoam?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 12:00
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

It depends on how exactly you want to calculate the field "h" and if it should affect the flow of the fluid as well or not.

I did a bit of searching and this does not look like to be an easy task, at least according to this bug report: http://www.openfoam.org/mantisbt/view.php?id=86

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 15, 2013, 12:20
Default
  #3
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Hi dear Bruno
it only suffice that be calculated through e,p nd rho as you know:h=e+p/rho
and doesn't affect the flow.is it difficult to define a field for that so that it obtains from three other fields(e,p,rho)?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 12:46
Default
  #4
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Mmm... the "e" is a field that already exists... OK, try adding the following code, after the equation for "e" is solved:
Code:
volScalarField h
(
    IOobject
    (
         "h",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh,
     e+p/rho
);
I based myself on this tutorial: http://openfoamwiki.net/index.php/Ho...ure_to_icoFoam - but I have not tested it.
__________________
wyldckat is offline   Reply With Quote

Old   June 15, 2013, 12:57
Default
  #5
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
you mean in createFields,right?
where it should be exactly added?
Code:
Info<< "Reading thermophysical properties\n" << endl;

    autoPtr<psiThermo> pThermo
    (
        psiThermo::New(mesh)
    );
    psiThermo& thermo = pThermo();
    thermo.validate(args.executable(), "e");

    volScalarField& p = thermo.p();
    volScalarField& e = thermo.he();
    const volScalarField& psi = thermo.psi();

    volScalarField rho
    (
        IOobject
        (
            "rho",
            runTime.timeName(),
            mesh
        ),
        thermo.rho()
    );

    Info<< "Reading field U\n" << endl;
    volVectorField U
    (
        IOobject
        (
            "U",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );
    
    Info<< "Reading field gas\n" << endl;
    volScalarField gas
    (
        IOobject
        (
            "gas",
            runTime.timeName(),
            mesh,
            IOobject::MUST_READ,
            IOobject::AUTO_WRITE
        ),
        mesh
    );

    #include "compressibleCreatePhi.H"


    Info<< "Creating turbulence model\n" << endl;
    autoPtr<compressible::turbulenceModel> turbulence
    (
        compressible::turbulenceModel::New
        (
            rho,
            U,
            phi,
            thermo
        )
    );
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 13:00
Default
  #6
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
No, no... I said after solving the equation "e"... this means in "eEqn.H", if I'm not mistaken on the name of the file.
__________________
wyldckat is offline   Reply With Quote

Old   June 15, 2013, 13:47
Default
  #7
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
is it true?
Code:
{
    solve
    (
        fvm::ddt(rho, e)
      + fvm::div(phi, e)
      - fvm::laplacian(turbulence->alphaEff(), e)
     ==
      - p*fvc::div(phi/fvc::interpolate(rho))
    );

    thermo.correct();
}
volScalarField h
(
    IOobject
    (
         "h",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh,
     e+p/rho
);
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 13:51
Default
  #8
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
Bruno its the error:
Code:
ehsan@Ehsan-com:~/Desktop/Solvers/sonicFoamWGMaxCo_220$ wmake
Making dependency list for source file sonicFoamModified.C
SOURCE=sonicFoamModified.C ;  g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -Wnon-virtual-dtor -O3  -DNoRepository -ftemplate-depth-100 -I/opt/openfoam220/src/thermophysicalModels/basic/lnInclude -I/opt/openfoam220/src/turbulenceModels/compressible/turbulenceModel -I/opt/openfoam220/src/finiteVolume/lnInclude -I/opt/openfoam220/src/finiteVolume/cfdTools -I/opt/openfoam220/src/meshTools/lnInclude -I/opt/openfoam220/src/sampling/lnInclude -I/opt/openfoam220/src/fvOptions/lnInclude -IlnInclude -I. -I/opt/openfoam220/src/OpenFOAM/lnInclude -I/opt/openfoam220/src/OSspecific/POSIX/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/sonicFoamModified.o
In file included from sonicFoamModified.C:64:0:
eEqn.H: In function ‘int main(int, char**)’:
eEqn.H:25:1: error: no matching function for call to ‘Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField(Foam::IOobject, Foam::fvMesh&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
eEqn.H:25:1: note: candidates are:
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:605:1: note:   no known conversion for argument 2 from ‘Foam::fvMesh’ to ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:570:1: note:   no known conversion for argument 2 from ‘Foam::fvMesh’ to ‘const Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:540:1: note:   candidate expects 2 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::word&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:507:1: note:   candidate expects 2 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:475:1: note:   candidate expects 2 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:444:1: note:   candidate expects 1 argument, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::GeometricField<Type, PatchField, GeoMesh>&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:412:1: note:   candidate expects 1 argument, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dictionary&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:371:1: note:   no known conversion for argument 3 from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::dictionary&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:331:1: note:   candidate expects 2 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::Field<TypeR>&, const Foam::PtrList<PatchField<Type> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:304:1: note:   candidate expects 5 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:274:1: note:   candidate expects 5 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensioned<Form>&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:245:1: note:   no known conversion for argument 3 from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::dimensioned<double>&’
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const wordList&, const wordList&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh, Foam::wordList = Foam::List<Foam::word>]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:217:1: note:   candidate expects 5 arguments, 3 provided
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note: Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField(const Foam::IOobject&, const Mesh&, const Foam::dimensionSet&, const Foam::word&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh, Foam::GeometricField<Type, PatchField, GeoMesh>::Mesh = Foam::fvMesh]
/opt/openfoam220/src/OpenFOAM/lnInclude/GeometricField.C:187:1: note:   no known conversion for argument 3 from ‘Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >’ to ‘const Foam::dimensionSet&’
/opt/openfoam220/src/finiteVolume/lnInclude/readPISOControls.H:3:15: warning: unused variable ‘nOuterCorr’ [-Wunused-variable]
/opt/openfoam220/src/finiteVolume/lnInclude/readPISOControls.H:12:16: warning: unused variable ‘momentumPredictor’ [-Wunused-variable]
/opt/openfoam220/src/finiteVolume/lnInclude/readPISOControls.H:15:16: warning: unused variable ‘transonic’ [-Wunused-variable]
make: *** [Make/linux64GccDPOpt/sonicFoamModified.o] Error 1
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 14:04
Default
  #9
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
I'm trying this myself and it doesn't work. "p/rho" doesn't have the same units as "e" (edit: or structure?).

But I've just now remembered something... what thermal properties have you defined for your case?
Because the "e" field is in fact "thermo.he()", which means that it can be "h", depending on the options, therefore not requiring any additional coding.
__________________

Last edited by wyldckat; June 15, 2013 at 14:04. Reason: see "edit:"
wyldckat is offline   Reply With Quote

Old   June 15, 2013, 14:45
Default
  #10
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26
immortality is on a distinguished road
yes they both have the same dimension.
no it doesn't accept enthalpy as the bug link you gave confirm it.maybe can replace it by R*T that R is approximately 287.14 for air
is it possible?
in general adding a new field from existing fields doesn't have a routine method?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King.
To Be or Not To Be,Thats the Question!
The Only Stupid Question Is the One that Goes Unasked.
immortality is offline   Reply With Quote

Old   June 15, 2013, 16:07
Default
  #11
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,974
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Hi Ehsan,

Sorry, but something strange happened back then. I know that compiling went wrong when using "h = e + p/rho", but now it's working... very strange ...

OK, the modifications I did were as follows:
  1. Edit the file "createFields.H" and append the following code:
    Code:
        volScalarField h
        (
            IOobject
            (
                "h",
                runTime.timeName(),
                mesh,
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            e
        );
    Note: "e" instead of "mesh" is for initializing the field with the same dimensions.
  2. Then edit the file "eEqn.H" and add this line before the last "}":
    Code:
    h = e + p/rho;
  3. Don't forget to save the files (I might have forgotten to do this step a few hours ago ).
Then run:
Code:
wmake
And this is all it takes!


_____________
In regards to the initial idea, I had forgotten that the following:
Code:
volScalarField h
(
    IOobject
    (
         "h",
         runTime.timeName(),
         mesh,
         IOobject::MUST_READ,
         IOobject::AUTO_WRITE
     ),
     mesh,
     e+p/rho
);
should only be used when:
  1. The "e+p/rho" gave only a dimensioned scalar, not a complete dimensioned scalar field.
  2. "MUST_READ" would have given you troubles, since you only wanted to calculate it after everything was done...
Best regards,
Bruno
immortality likes this.
__________________
wyldckat is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
problems after decomposing for running alessio.nz OpenFOAM 7 March 5, 2021 05:49
Adding Temperature field to IcoFoam yapalparvi OpenFOAM Programming & Development 14 November 19, 2015 05:57
Field functions and table crevoise Siemens 0 March 20, 2013 11:51
Error trying to run steady-state sonicFoam dancfd OpenFOAM Running, Solving & CFD 2 February 12, 2013 04:15
Adding temperature field to InterFoam yapalparvi OpenFOAM Running, Solving & CFD 8 October 14, 2009 21:18


All times are GMT -4. The time now is 05:03.