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

Invoke the pressure value inside a library

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 12, 2021, 10:15
Default Invoke the pressure value inside a library
  #1
New Member
 
rocco
Join Date: Nov 2020
Posts: 13
Rep Power: 5
rocco96 is on a distinguished road
Hi everyone,
Does anyone know if it is possible to recall the pressure value found at each iteration of the solver (which solves PEqn.H, the solver is interCondensatingEvaporatingFoam) in the "constant.C" library?
The OpenFoam version is v-2012, and the solver is interCondensatingEvaporatingFoam. I am trying to make TSat (saturation temperature) dependent on pressure, and therefore I need to have access from the file constant.C to the pressure value p found by solving the momentum equation.

kinds regard,
Rocco
rocco96 is offline   Reply With Quote

Old   April 12, 2021, 10:55
Default
  #2
New Member
 
rocco
Join Date: Nov 2020
Posts: 13
Rep Power: 5
rocco96 is on a distinguished road
I relase the code inside createFields.H


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

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

#include "createPhi.H"

//-------------modified_start--------------//

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

//-------------modified_end--------------//



// Creating e based thermo
autoPtr<twoPhaseMixtureEThermo> thermo
(
new twoPhaseMixtureEThermo(U, phi)
);

// Create mixture and
Info<< "Creating temperaturePhaseChangeTwoPhaseMixture\n" << endl;
autoPtr<temperaturePhaseChangeTwoPhaseMixture> mixture =
temperaturePhaseChangeTwoPhaseMixture::New(thermo( ), mesh);


volScalarField& alpha1(thermo->alpha1());
volScalarField& alpha2(thermo->alpha2());

const dimensionedScalar& rho1 = thermo->rho1();
const dimensionedScalar& rho2 = thermo->rho2();

// Need to store rho for ddt(rho, U)
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
alpha1*rho1 + alpha2*rho2
);
rho.oldTime();



// Mass flux
surfaceScalarField rhoPhi
(
IOobject
(
"rhoPhi",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
fvc::interpolate(rho)*phi
);

// Construct interface from alpha1 distribution
interfaceProperties interface
(
alpha1,
U,
thermo->transportPropertiesDict()
);

// Construct incompressible turbulence model
autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, thermo())
);

#include "readGravitationalAcceleration.H"
#include "readhRef.H"
#include "gh.H"

volScalarField& p = thermo->p();

label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
p_rgh,
pimple.dict(),
pRefCell,
pRefValue
);

if (p_rgh.needReference())
{
p += dimensionedScalar
(
"p",
p.dimensions(),
pRefValue - getRefCellValue(p, pRefCell)
);
p_rgh = p - rho*gh;
}

mesh.setFluxRequired(p_rgh.name());
mesh.setFluxRequired(alpha1.name());

// MULES compressed flux is registered in case scalarTransport FO needs it.
surfaceScalarField alphaPhiUn
(
IOobject
(
"alphaPhiUn",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar(phi.dimensions(), Zero)
);

#include "createMRF.H"
#include "createFvOptions.H"

// Turbulent Prandtl number
dimensionedScalar Prt("Prt", dimless, thermo->transportPropertiesDict());

volScalarField kappaEff
(
IOobject
(
"kappaEff",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermo->kappa()
);



// Need to store rho for ddt(rhoCp, U)
volScalarField rhoCp
(
IOobject
(
"rhoCp",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
rho*thermo->Cp()
);

rhoCp.oldTime();
rocco96 is offline   Reply With Quote

Old   April 6, 2022, 13:40
Default
  #3
New Member
 
roham seif
Join Date: Jul 2020
Posts: 6
Rep Power: 5
Roham..Seif is on a distinguished road
Quote:
Originally Posted by rocco96 View Post
Hi everyone,
Does anyone know if it is possible to recall the pressure value found at each iteration of the solver (which solves PEqn.H, the solver is interCondensatingEvaporatingFoam) in the "constant.C" library?
The OpenFoam version is v-2012, and the solver is interCondensatingEvaporatingFoam. I am trying to make TSat (saturation temperature) dependent on pressure, and therefore I need to have access from the file constant.C to the pressure value p found by solving the momentum equation.

kinds regard,
Rocco
Hi Rocco,
Could you manage to make TSat (saturation temperature) dependent on pressure in interCondensatingEvaporatingFoam solver?
Roham..Seif is offline   Reply With Quote

Old   April 6, 2022, 13:50
Default
  #4
New Member
 
rocco
Join Date: Nov 2020
Posts: 13
Rep Power: 5
rocco96 is on a distinguished road
Quote:
Originally Posted by Roham..Seif View Post
Hi Rocco,
Could you manage to make TSat (saturation temperature) dependent on pressure in interCondensatingEvaporatingFoam solver?
Hi Roham,
I maked this a lot of time ago. The answer for the your question is YES, is possibile, but if you do this, will be very difficult to manage the evaporation and condensation. I will try to find the material and I will try to explain how you can do.
Regards,
Rocco
rocco96 is offline   Reply With Quote

Reply


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
Pressure Inlet Boundary Conditions Mr.Goodcat FLUENT 5 June 20, 2019 01:47
CFX Solver stopped with error when requested for backup during solver running Mfaizan CFX 40 May 13, 2016 06:50
Pressure Outlet Guage pressure Mohsin FLUENT 36 April 29, 2016 17:16
Pulsatile pressure inlet with pressure outlet a.lynchy FLUENT 3 March 23, 2012 13:45
Neumann pressure BC and velocity field Antech Main CFD Forum 0 April 25, 2006 02:15


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