CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Again on fixing the value of a variable in e certain volume of the domain (http://www.cfd-online.com/Forums/openfoam/98081-again-fixing-value-variable-e-certain-volume-domain.html)

samiam1000 March 2, 2012 11:11

Again on fixing the value of a variable in e certain volume of the domain
 
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

calim_cfd March 2, 2012 12:55

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 :(

samiam1000 March 5, 2012 07:43

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?

calim_cfd March 5, 2012 08:00

Quote:

Originally Posted by samiam1000 (Post 347680)
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 :o
goodluck

samiam1000 March 5, 2012 09:40

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.

Aurelien Thinat March 5, 2012 10:09

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 ?

samiam1000 March 5, 2012 10:25

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

Aurelien Thinat March 5, 2012 10:46

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.

samiam1000 March 5, 2012 11:04

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

Aurelien Thinat March 5, 2012 12:01

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 March 5, 2012 12:05

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 March 8, 2012 04:53

Quote:

Originally Posted by Aurelien Thinat (Post 347733)
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


All times are GMT -4. The time now is 12:46.