CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Again on fixing the value of a variable in e certain volume of the domain

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

Like Tree1Likes
  • 1 Post By Aurelien Thinat

Reply
 
LinkBack Thread Tools Display Modes
Old   March 2, 2012, 10:11
Default Again on fixing the value of a variable in e certain volume of the domain
  #1
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Dear All,

what I am trying to do has been discussed, yet.

Anyway, I am finding it a bit difficult to find a solution, since there are many threads about this question and I can not cope with them all.

So, I would like to ask you, for help.

What I wanna do is to edit the buoyantSimpleFoam solver, in order to fix the value of the temperature in a sub-volume of my domain.

I have a mesh whit a volume patch which contains the cell I want to fix the T (or h) value.

The problem I have to face first, are the following:
a. in the solver we do not have T, but h. This is not a problem, since for a PIG it stands h = C_p*T, with C_p = const.

Now, the question is: what are the next step?

Following this tutorial I created my own solver buoyantSimpleFoam_Mod.

I edited the file `files' in the Make directory and then I started editing the hEqn.H and the createFields files.

Following this thread, I figured out that my hEqn.H file should looks like this:

Code:
{
    fvScalarMatrix hEqn
    (
        fvm::div(phi, h)
      - fvm::Sp(fvc::div(phi), h)
      - fvm::laplacian(turbulence->alphaEff(), h)
     ==
        fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p))
      - p*fvc::div(phi/fvc::interpolate(rho))
    );

    hEqn.relax();
    hEqn.setValues(hCells, hVals);
    hEqn.solve();

    thermo.correct();
}
where hCells is a vector of cells and hVals is a vector containing the values that I want to impose at each cell of the hCells vector.

One question that comes to my mind is: where should I define these 2 vectors? And how?
Also, is it possible to insert the label of the volume patch, instead of the label of each cell?

Fuerthermore, I guess that I have to change the file fvSolution in the case/system directory and I think that it is enough to add the following line:
Code:
 
   
hCells	    0;
sVals      1000;
Is that correct? And how can I say to OF that hCells is the vector that contains all the cells in the patch I am interested in?

Could anyone help, please?

Thanks a lot,
Samuele

Last edited by samiam1000; March 2, 2012 at 10:40.
samiam1000 is online now   Reply With Quote

Old   March 2, 2012, 11:55
Default
  #2
Senior Member
 
calim_cfd's Avatar
 
mauricio
Join Date: Jun 2011
Posts: 135
Rep Power: 7
calim_cfd is on a distinguished road
Hi there

one quick thought!

u say ou wanna fix the temperature over a range of cells forming a continuous volume right?

if so wouldn’t it be easier to make a hole in you geometry and work with boundary conditions?

sry but i'm not that much into c++ syntax yet

Last edited by calim_cfd; March 2, 2012 at 11:56. Reason: spelling
calim_cfd is offline   Reply With Quote

Old   March 5, 2012, 06:43
Default
  #3
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Actually,

I want to impose the value in a volume in order to have a stronger condition. I have a flux of air inside that volume. And the faces of this volume could be either inlet or outlet .

And I don't know how other variables behave on that face.

That's why I can not create the cavity.

Any other idea?
samiam1000 is online now   Reply With Quote

Old   March 5, 2012, 07:00
Default
  #4
Senior Member
 
calim_cfd's Avatar
 
mauricio
Join Date: Jun 2011
Posts: 135
Rep Power: 7
calim_cfd is on a distinguished road
Quote:
Originally Posted by samiam1000 View Post
Actually,

I want to impose the value in a volume in order to have a stronger condition. I have a flux of air inside that volume. And the faces of this volume could be either inlet or outlet .

And I don't know how other variables behave on that face.

That's why I can not create the cavity.

Any other idea?
you're saying you need to account for backflow ? then wont the bcs below suffice?
Code:
inletOutlet
Switches U and p between fixedValue and zeroGradient depending on direction of U
outletInlet
Switches U and p between fixedValue and zeroGradient depending on direction of U
inletValue, value
outletValue,
regarding the other variables..i guess you could give it a try idk,,

sry if i'm missing sth theoretically basic here
goodluck
__________________
Best Regards
/calim

"Elune will grant us the strength"
calim_cfd is offline   Reply With Quote

Old   March 5, 2012, 08:40
Default
  #5
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Dear Claim,

I think that what you mean is not what I would like to get.

I know about the inletOutlet BC in order to take in account the reverse flow, but what I mean is that I have a volume through which the air flows.

So, what I wanna do is to fix the temperature, but I want to make the other variables being evaluated in the whole volume.
samiam1000 is online now   Reply With Quote

Old   March 5, 2012, 09:09
Default
  #6
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 148
Rep Power: 6
Aurelien Thinat is on a distinguished road
Hi samiam1000,

I have never done something like that. But my first shot would like :
- add a volScalarField I to the solver ;
- I = 0 in the volume you want a fixed temperature and 1 everywhere else ;
- modify the temperature equation by adding the factor I ;
- use setField to impose I and T at the begining.

I guess it would do the job no ?
Aurelien Thinat is offline   Reply With Quote

Old   March 5, 2012, 09:25
Default
  #7
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Dear Aurelien,

first of all, thanks for answering.

Well, I think that your idea may work, but I need your help..

I mean:
1. how can I add a volScalarField I to the solver? I mean, which is the file to edit and how?
2. how can I set the value of the field I?

Thanks for any help you will provide,
Samuele
samiam1000 is online now   Reply With Quote

Old   March 5, 2012, 09:46
Default
  #8
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 148
Rep Power: 6
Aurelien Thinat is on a distinguished road
1) Have a look at :

http://cfd.iut.ac.ir/files/Tutorial,...20Diego%20.pdf

At slide 18, you have an example, just follow these instructions on how to add a volscalarfield. You will just have to change the name T (they add the temperature equation to a basic solver) by any name of your choice.

The temperature equation is usually in the file "TEqn.H".

2) To set a value in a domain, have a look at the command "setField" and the "setFieldDict" (look at this in the tutorials). You can easily use this for a cube for example. For more complex geometries, you will have to find a way to define a cellSet.

You will have to define a new file "I" in the folder 0 with all your BCs and set fixedValue = 1 everywhere.
Then run the command setField.
Launch your solver.
Aurelien Thinat is offline   Reply With Quote

Old   March 5, 2012, 10:04
Default
  #9
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Hi Aurelien,

sorry for the silly question, but there is something that I am missing.

If you look at buoyantSimpleFoam you can see that you don't have the TEqn.H file, but you have a hEqn.H file. And, since for a PIG it stands h = C_p*T, hence you can modify the hEqn.H, fixing the enthalpy and not the temperature.

The point is that I can not und why I have to add a new scalar field. What I would like to do is to modify the existing one.

Also, what I can not understand is that if you look at the createField.H file inside the solver you will read:
Code:
    volScalarField& p = thermo.p();
    volScalarField& h = thermo.h();
    const volScalarField& psi = thermo.psi();
Also, tough the geometry is not easy, in the constant/polyMesh/cellsZones I have a patch (e.g. air_infinite) which includes all the cells I would like to fix the value of enthalpy, in.

Thanks again,
Samuele
samiam1000 is online now   Reply With Quote

Old   March 5, 2012, 11:01
Default
  #10
Senior Member
 
Aurelien Thinat
Join Date: Jul 2010
Posts: 148
Rep Power: 6
Aurelien Thinat is on a distinguished road
Well, my idea was basically to disable the equation of T or h somewhere in the domain by using a scalar 1 or 0 to detect the cellzone.

I saw in other posts that it's possible to fix a value directly (in OF 2.1) in the equations. Maybe you can try this.
samiam1000 likes this.
Aurelien Thinat is offline   Reply With Quote

Old   March 5, 2012, 11:05
Default
  #11
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
I am looking forward to having OF 2.1 installed.. Right now I am running OF 2.0 and I have to edit the source.

I'll try with your solution, though I am not very good with C++ and I will meet some difficulties ..

The point is `never give up'..

Thanks again,

Samuele
samiam1000 is online now   Reply With Quote

Old   March 8, 2012, 03:53
Default
  #12
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 446
Rep Power: 8
samiam1000 is on a distinguished road
Quote:
Originally Posted by Aurelien Thinat View Post
I saw in other posts that it's possible to fix a value directly (in OF 2.1) in the equations. Maybe you can try this.
Dear Aurelien,

could you link the post where this point is discussed?

Thanks a lot,

Samuele
samiam1000 is online now   Reply With Quote

Reply

Thread Tools
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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help.....Insufficient Catalogue Size Paresh Jain CFX 17 March 11, 2014 12:40
BlockMesh FOAM warning gaottino OpenFOAM Native Meshers: blockMesh 7 July 19, 2010 14:11
Solid volume inside computational domain francois OpenFOAM Native Meshers: blockMesh 7 November 19, 2008 16:11
How to compute total liquid volume of the whole domain hsieh OpenFOAM Post-Processing 2 July 13, 2007 18:18
Multi_component Vs Additional Variable Anurag CFX 2 February 4, 2005 16:45


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