CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   How force fixed value of variable in one cell (https://www.cfd-online.com/Forums/openfoam-solving/59266-how-force-fixed-value-variable-one-cell.html)

normunds June 9, 2007 20:11

Dear Hvorje! It seems for m
 
Dear Hvorje!

It seems for me that your "soft-touch" value setting algorithm has problems with finite, non-zero gradients on boundaries. At least i got a problem with PISO pressure correction algorithm applied to incompressible NS equation (the same as icoFoam) but with volumetric forces. I started with an incompressible buoyancy force, so my "corrected" boundary condition for pressure is snGrad(p)=nf*(0,0,-alpha*g*(T-T0)) on the whole border of domain. Things went well until walls was heated in way which introduces non-zero pressure normal gradient on boundary. Perhaps, I can fix single point (p) value in a "hard" way, however than I can expect (as I got from your post above) the problem with pEqn.flux() algorithm. From the other hand the construction

phi-=fvc::interpolate(rUA*fvc::grad(p))&Mesh.Sf()

instead of

phi-=pEqn.flux()


at the end of PISO loop seems to do some work on well-posed structured mesh (results looks fine for "cubical" domain), however I am afraid this may be not so good on arbitrary unstructured grid. I don't know, it's just my guess about la Place operator which has different numeric discretization as interpolate(grad()), so that both constructions may not be the same.

My questions are

1. Do really setReference() function fails in the cases with non-zero gradients (but still only gradients) on boundary?

2. If yes, how difficult is to correct mass flux (what I mean is to restore/repair a matrix after solve(), so that .flux() method work again) in a single cell where field value is set in a "hard" way? May you (or someone else) can post (or point to location) where I can get information about how exactly flux method works, so I can fix this myself?

thanks a lot for any help!

regards,

/Normunds

normunds June 10, 2007 04:46

Dear Hrvoje and all! I am r
 
Dear Hrvoje and all!

I am really sorry about wrong spelling of your name as well about the content of my previous message - it seems I was wrong, the function setReference() do it's job well, it was not a cause of my problem.

I just recognized (to be more precise it's still my guess) that by adding volume force to momentum conservation equation (as it is suggested somewhere on this board)



fvVectorMatrix UEqn (
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
== volForce
);

solve(UEqn == - fvc::grad(p))


one may end up with mathematically ill defined problem for p due to differences in numeric implementation of operators. In other words integral of normal p derivative (p flux) over all boundary surfaces of solution domain must be exactly consumed by the volumetric source term in the pressure equation or pressure field equation has no solution. The latest seems to be a case when volForce is added to momentum equation in way shown above.

It looks like I have to do

fvVectorMatrix UEqn (
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);

solve(UEqn == - fvc::grad(p)+volForce)

and below in PISO loop

U = rUA*UEqn.H();

phi = (fvc::interpolate(U) & mesh.Sf())
+ (fvc::ddtPhiCorr(rUA, U, phi));

adjustPhi(phi, U, p); // I am not sure about this !!!!

U += rUA*volForce;
phi += (fvc::interpolate(rUA*volForce) & mesh.Sf());


or something like that so that non-zero p integral flux from boundary is exactly compensated by volForce yielded terms in div(phi). However, this is not anymore related to topic of this thread, my apologies to Ola.

Once again my apologies to all!

/Normunds

maka July 16, 2007 12:07

would you please post the file
 
would you please post the file that should be modified (copied from the above URL) for the above bug to fixed. I use OF V1.3. Thanks.

Best regards,
Maka.

stchouan November 7, 2007 12:51

Hi! im new in OpenFoam and tr
 
Hi!
im new in OpenFoam and trying to create a solver for a simple problem like: "div(-k grad (p)=f" with k=id (k might be heterogeneous later). First, how to discretize the source term f when its constant(f=1)? Second, I dont know how to simply impose Neumann boundary conditions. Can somebody help me please!!!
Thx!
stephane.

naoki December 25, 2007 01:51

Hi all. I want to fix the val
 
Hi all.
I want to fix the value of several cells using setValues while equation being solved.
So I think that I have to select cells with cellSet,
and then use setValues with the equation matrix in solver.

I read sets in solver file after cellSet as follows and it seems working fine.

const cellSet selectedCells
(
IOobject
(
"selectedCells",
"constant/polyMesh/sets",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

But, setValues function requires not cellSet but labelList....

Thus, my quastions are
1. How can I make labelList from cellSet?
(I think both are similar very much. Am I wrong?)
2. Does anybody think of better way? or Did anybody do the same thing?

regards,
Naoki

naoki December 25, 2007 02:09

Hi all I want to fix the valu
 
Hi all
I want to fix the value of several cells using setValues while equation being solved.
So I think that I have to select cells with cellSet,
and then use setValues with the equation matrix in solver.

I read sets in solver file after cellSet as follows and it seems working fine.

const cellSet selectedCells
(
IOobject
(
"selectedCells",
"constant/polyMesh/sets",
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);

But, setValues function requires not cellSet but labelList....

Thus, my quastions are
1. How can I make labelList from cellSet?
(I think both are similar very much. Am I wrong?)
2. Does anybody think of better way? or Did anybody do the same thing?

regards,
Naoki

naoki December 27, 2007 22:54

I 've solved the problem. I'm
 
I 've solved the problem.
I'm sorry for the silly question.
Here is a part of the code to change cellSet to labelList and do setValue with labelList.

---
cellSet newSet(mesh, setName);
labelList refCells;
refCells = newSet.toc();
scalarField refField(refCells.size());
...
...
someEqn().setValue(refCells,refField);
---
Actually setValue function helps me greatly.

regards,
Naoki

samiam1000 February 24, 2012 06:12

Dear friends,

I am facing the problem you solved in this thread. I ask you a question: maybe you can help.
I want to impose a fixed value of a temperature in a certain volume of my domain.
How can I do this? Should I use the fvMatrix::setValues() method?

Could you briefly explain and what I should practically do?

Thanks a lot,

Samuele


All times are GMT -4. The time now is 07:59.