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

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

 July 5, 2010, 05:34 how to impose averaged field equal to 0 at a point during calculation ? #1 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 10:31.

 July 5, 2010, 07:23 #2 Senior Member   Kathrin Kissling Join Date: Mar 2009 Location: Besigheim, Germany Posts: 134 Rep Power: 8 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

 July 5, 2010, 08:57 #3 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 ?

July 6, 2010, 02:40
#4
Senior Member

Mark Olesen
Join Date: Mar 2009
Location: http://olesenm.github.io/
Posts: 779
Rep Power: 18
Quote:
 Originally Posted by Cyp 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

 July 6, 2010, 03:59 #5 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 ?

 July 6, 2010, 06:40 #6 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 8 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

 July 6, 2010, 08:52 #7 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 Here is the problem I want to solve with OpenFOAM : http://img5.imageshack.us/i/problemaaj.jpg/ It is the last condition ( ^{gamma}=0) I was talking about.. https://docs.google.com/leaf?id=0B3b...YWRlODRk&hl=en Last edited by wyldckat; September 3, 2015 at 18:03. Reason: disabled embedded images

 July 8, 2010, 09:31 #8 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 ??

 July 8, 2010, 11:47 #9 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 8 Hi Cyp, I'm still waiting for your equation and BC's. It would really help me to help you. Regards, Stefan

 July 8, 2010, 11:49 #10 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 can't you see the picture in my previous message ?? http://img5.imageshack.us/i/problemaaj.jpg/

 July 8, 2010, 11:54 #11 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 8 No I can't. Sorry. But now I can take a look. Thanks.

 July 15, 2010, 12:21 #12 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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

 July 16, 2010, 03:01 #13 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 8 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

 July 16, 2010, 05:44 #14 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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..

 July 19, 2010, 08:30 #15 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 ??

 July 20, 2010, 10:06 #16 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 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 ?

 July 20, 2010, 11:15 #17 Senior Member   Stefan Herbert Join Date: Dec 2009 Location: Darmstadt, Germany Posts: 129 Rep Power: 8 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

 July 21, 2010, 03:18 #18 Senior Member   Cyprien Join Date: Feb 2010 Location: Stanford University Posts: 236 Rep Power: 9 Hi Stefan! It perfectly works !! Thank you very much!

 August 3, 2010, 09:19 accessing cells from a patch #19 Member   George Pichurov Join Date: Jul 2010 Posts: 39 Rep Power: 7 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.

February 24, 2012, 06:41
#20
Senior Member

Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 10
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

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Mojtaba Main CFD Forum 0 February 14, 2009 01:58 Mojtaba Main CFD Forum 0 February 9, 2009 01:08 Chie Min CFX 5 July 12, 2001 23:19 Mark Render Main CFD Forum 8 May 2, 2000 07:09 Aspens Main CFD Forum 1 February 23, 2000 15:15

All times are GMT -4. The time now is 03:00.