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

how to impose fixed value at a point (or region) during calculation ?

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   July 5, 2010, 06:34
Default how to impose averaged field equal to 0 at a point during calculation ?
  #1
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi!

In my subject, I need to solve equations with a condition of average-field-equal-to-zero.

I defined the average of the T field as :

Code:
T_moy=fvc::domainIntegrate(T) / V
where V is the volume of the domain.

how can I impose T_moy=0 during the calculation ?


Thank you for your precious help.

Last edited by Cyp; July 7, 2010 at 11:31.
Cyp is offline   Reply With Quote

Old   July 5, 2010, 08:23
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17
kathrin_kissling is on a distinguished road
Hi Cyp,

Do you went to impose a value on certain points or do you search for a condition which will make sure that after solving the transport equation your field T is in accordance with your implied condition.

Kathrin
kathrin_kissling is offline   Reply With Quote

Old   July 5, 2010, 09:57
Default
  #3
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
I want to be sure that after my calculation, the implied condition is satisfied.

In Comsol I imposed a constraint ( moy(T)=0) on one point (it is sufficient). what is the equivalent on OpenFOAM ?
Cyp is offline   Reply With Quote

Old   July 6, 2010, 03:40
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,715
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by Cyp View Post
I want to be sure that after my calculation, the implied condition is satisfied.

In Comsol I imposed a constraint ( moy(T)=0) on one point (it is sufficient). what is the equivalent on OpenFOAM ?
To impose values at specified cells, you'd want the fvMatrix::setValues() method.
http://foam.sourceforge.net/doc/Doxy...bc49953b884184
olesen is offline   Reply With Quote

Old   July 6, 2010, 04:59
Default
  #5
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
thank you for your answer !

The setValues definition precises that the imposed values are field value. In my case, I need to imposed a value for the average of a field over the domain.

Do you think setValue is a good hint for my problem ?
Cyp is offline   Reply With Quote

Old   July 6, 2010, 07:40
Default
  #6
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi Cyp,

I think it would be easier for us to help you, if you would show us your equation and boundary conditions in detail.

Regards,
Stefan
herbert is offline   Reply With Quote

Old   July 6, 2010, 09:52
Default
  #7
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Here is the problem I want to solve with OpenFOAM :

http://img5.imageshack.us/i/problemaaj.jpg/

It is the last condition ( <s_{gamma}>^{gamma}=0) I was talking about..


https://docs.google.com/leaf?id=0B3b...YWRlODRk&hl=en

Last edited by wyldckat; September 3, 2015 at 19:03. Reason: disabled embedded images
Cyp is offline   Reply With Quote

Old   July 8, 2010, 10:31
Default
  #8
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
I am a bit lost...

Such a condition (to impose averaged field on a region equal to 0) is fundamental in my calculation.

Can anyone give me a hint ??
Cyp is offline   Reply With Quote

Old   July 8, 2010, 12:47
Default
  #9
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi Cyp,

I'm still waiting for your equation and BC's. It would really help me to help you.

Regards,
Stefan
herbert is offline   Reply With Quote

Old   July 8, 2010, 12:49
Default
  #10
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
can't you see the picture in my previous message ??


http://img5.imageshack.us/i/problemaaj.jpg/
Cyp is offline   Reply With Quote

Old   July 8, 2010, 12:54
Default
  #11
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
No I can't. Sorry. But now I can take a look.

Thanks.
herbert is offline   Reply With Quote

Old   July 15, 2010, 13:21
Default
  #12
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi Herbert (and all of you of course!)

I still looking for a solution to my problem (it is a very fundamental point in my developpment).

Do you think I can use the setValue (or setReference) utility in my case ?


Thank you,
Cyprien
Cyp is offline   Reply With Quote

Old   July 16, 2010, 04:01
Default
  #13
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi Cyprien,

I did not come up to a solution as well. But I think you aren't able to use setValues or setReference.

Can you solve the equation without boundaries fixing values (only gradient bc's)? In that case you could solve the field using setReference and subtract the average field value afterwards.

I don't think there is a solution for your problem already existing in OpenFOAM.

Regards,
Stefan
herbert is offline   Reply With Quote

Old   July 16, 2010, 06:44
Default
  #14
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi!

In fact it is exactly what I do for the moment (subtract the average field value afterwards). But it only works with simple source terms. When I try this a more complicated source term, this method doesn't converge to a solution..
Cyp is offline   Reply With Quote

Old   July 19, 2010, 09:30
Default
  #15
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Someone told me that I should directly insert my problem into the matrix I want to solve. If I understand what it is suggested, I declare my problem as

Code:
fvScalarMatrix TEqn
   (
        fvm::ddt(rho,T)
      +fvm::div(phi,T)
      -fvm::laplacian(rho*DT,T)
   )
Then I calculate the average value of my T field over the gamma phase by

Code:
T_moy=domainIntegrate(phase_gamma*T)/V_gamma
where V_gamma is the volume of the gamma phase

The next step is to enlarge my TEqn matrix by adding T_moy in the last position of the diagonal and zeros elsewhere.

Finally I should get the result solving

Code:
solve(TEqn == f)
where f is the original source term of my problem with an additionnal 0 at the last position.



What do you think of this method ??

How can I enlarge my matrix ??
Cyp is offline   Reply With Quote

Old   July 20, 2010, 11:06
Default
  #16
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
In fact, I found a very easiest way to proceed!!

I just have to fix a value at a point (with setReference) which assure the convergence of my problem. Then I find out my real fields by subtracting the average value of the calculated field! I post the code if someone is interested by such a problem :

Code:
while(runtime.loop())
{
#   include "readSIMPLEControls.H"
    for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
    {
    fvScalarMatrix TEqn
        (
           fvm::ddt(rho,T)
          +fvm::div(phi,T)
          -fvm::laplacian(rho*DT,T)
          == f
        )

     TEqn.setReference(TRefCell,TRefValue)
     TEqn.solve()
    }
}

T= phase_gamma*(T-fvc:domainIntegrate(phase_gamma*T)/V_gamma)
  +phase_beta *(T-fvc:domainIntegrate(phase_gamma*T)/V_gamma)
In the next step of my project, I need to do similar calculation with a vector field B. I want to use a similar strategy but the setReference seems to work only with scalar...

How can I fix the value of my vector B at a point ?
Cyp is offline   Reply With Quote

Old   July 20, 2010, 12:15
Default
  #17
Senior Member
 
Stefan Herbert
Join Date: Dec 2009
Location: Darmstadt, Germany
Posts: 129
Rep Power: 18
herbert is on a distinguished road
Hi Cyp,

the you can use setValues. Even if you want to fix only one point, setValues needs a list of points to be fixed. The following should work:
Code:
label refCell = 12345;
labelList refCells (1,refCell);
vectorField refValues (1, vector(0,0,0));
TEqn.setValues(refCells, refValues);
Regards,
Stefan
wayne14 and Michael@UW like this.
herbert is offline   Reply With Quote

Old   July 21, 2010, 04:18
Default
  #18
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi Stefan!

It perfectly works !! Thank you very much!
Cyp is offline   Reply With Quote

Old   August 3, 2010, 10:19
Default accessing cells from a patch
  #19
Member
 
George Pichurov
Join Date: Jul 2010
Posts: 52
Rep Power: 16
jorkolino is on a distinguished road
Does anyone know how can I access the cells from a patch with name patchname ? I want to run a procedure (particle injection) for each of the cells. I have the code, but I need the cell index.
jorkolino is offline   Reply With Quote

Old   February 24, 2012, 06:41
Default
  #20
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 520
Rep Power: 19
samiam1000 is on a distinguished road
Hi everyone.

First of all, I would like to answer to this:

Quote:
Does anyone know how can I access the cells from a patch with name patchname ? I want to run a procedure (particle injection) for each of the cells. I have the code, but I need the cell index.
I think you can find whay you want in the case_path/constant/polyMesh folder where there are different files.

Also, I have a question: 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?

Thanks a lot,

Samuele
samiam1000 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
Torque Calculation at Arbitrary Point Mojtaba Main CFD Forum 0 February 14, 2009 01:58
Calculation torque on arbitrary point Mojtaba Main CFD Forum 0 February 9, 2009 01:08
CFX4.3 -build analysis form Chie Min CFX 5 July 13, 2001 00:19
Grid refinement with wall functions Mark Render Main CFD Forum 8 May 2, 2000 08:09
Non-uniform grid calculation Aspens Main CFD Forum 1 February 23, 2000 15:15


All times are GMT -4. The time now is 23:26.