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

setReference in fvMatrix.C

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

Reply
 
LinkBack Thread Tools Display Modes
Old   April 16, 2015, 05:45
Default setReference in fvMatrix.C
  #1
New Member
 
Andre Weiner
Join Date: Aug 2012
Posts: 27
Rep Power: 4
andre.weiner is on a distinguished road
Hello Foamers!

The method setReference is widely used in OpenFOAM, for instance to set a reference pressure in simulations without a boundary with fixed pressure value. It's body looks the following:

Code:
line 517-520 in fvMatrix.C
    {
        source()[celli] += diag()[celli]*value;
        diag()[celli] += diag()[celli];
    }
My Question: Why do I arrive at the defined value by manipulating the diagonal matrix coefficient and the source in the given way?

Many thanks in advance!

Best, Andre
andre.weiner is offline   Reply With Quote

Old   April 24, 2015, 06:59
Default
  #2
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 675
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by andre.weiner View Post
Hello Foamers!

The method setReference is widely used in OpenFOAM, for instance to set a reference pressure in simulations without a boundary with fixed pressure value. It's body looks the following:

Code:
line 517-520 in fvMatrix.C
    {
        source()[celli] += diag()[celli]*value;
        diag()[celli] += diag()[celli];
    }
My Question: Why do I arrive at the defined value by manipulating the diagonal matrix coefficient and the source in the given way?

Many thanks in advance!

Best, Andre
I wrote it down and hopes this will give u some hints. pls see the image. Hopes im right


oh this image is way too big...Sorry about that, Im shocked...
sharonyue is offline   Reply With Quote

Old   April 24, 2015, 11:30
Default
  #3
New Member
 
Andre Weiner
Join Date: Aug 2012
Posts: 27
Rep Power: 4
andre.weiner is on a distinguished road
Ciao sharonyue!

Thanks a lot for your small example. I tried to formulate it a little bit more general

For each cell center P with the neighbours nb we can write the equation

a_P\ \varphi_P + \sum_{nb} a\varphi = S_\varphi

or

a_P\ \varphi_P + \sum_{nb} a\varphi - S_\varphi = 0 \ \ \ \ (1)

What we want is to set for a given P

\varphi_P = \varphi_{ref}

To incorporate this condition into outer algebraic system, first we multiply by a_P

a_P\varphi_P=a_P\varphi_{ref}

To this equation we now add (1) (we are adding 0) and get

a_P\ \varphi_P + a_P\ \varphi_P + \sum_{nb} a\varphi - S_\varphi = a_P\ \varphi_{ref}

which is reordered

2 a_P\ \varphi_P + \sum_{nb} a\varphi  = S_\varphi+ a_P\ \varphi_{ref}

This approach almost seems to simple and effective to be true
On the one hand you do not destroy the conditioning of the Matrix by applying some huge value to the diagonal and the source, and on the other hand the symmetry of the matrix is conserved (it would be also possible to set the off-diagonal coefficients to zero).

Thanks again for the support!

Best, Andre
andre.weiner is offline   Reply With Quote

Old   April 25, 2015, 04:19
Default
  #4
Senior Member
 
Dongyue Li
Join Date: Jun 2012
Location: Torino, Italy
Posts: 675
Rep Power: 8
sharonyue is on a distinguished road
Quote:
Originally Posted by andre.weiner View Post
Ciao sharonyue!

Thanks a lot for your small example. I tried to formulate it a little bit more general

For each cell center P with the neighbours nb we can write the equation

a_P\ \varphi_P + \sum_{nb} a\varphi = S_\varphi

or

a_P\ \varphi_P + \sum_{nb} a\varphi - S_\varphi = 0 \ \ \ \ (1)

What we want is to set for a given P

\varphi_P = \varphi_{ref}

To incorporate this condition into outer algebraic system, first we multiply by a_P

a_P\varphi_P=a_P\varphi_{ref}

To this equation we now add (1) (we are adding 0) and get

a_P\ \varphi_P + a_P\ \varphi_P + \sum_{nb} a\varphi - S_\varphi = a_P\ \varphi_{ref}

which is reordered

2 a_P\ \varphi_P + \sum_{nb} a\varphi  = S_\varphi+ a_P\ \varphi_{ref}

This approach almost seems to simple and effective to be true
On the one hand you do not destroy the conditioning of the Matrix by applying some huge value to the diagonal and the source, and on the other hand the symmetry of the matrix is conserved (it would be also possible to set the off-diagonal coefficients to zero).

Thanks again for the support!

Best, Andre
Neat! quite clear and simple,

Never too old to learn CFD. haha.

Best,
dongyue
sharonyue is offline   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
Some misleading about the treatment of coupled boundary liuhuafei OpenFOAM Bugs 4 February 22, 2014 16:01
Poisson eq w setReference works serial diverges in parallel tehache OpenFOAM Running, Solving & CFD 5 August 29, 2012 09:41
Appropriate boundary conditions for external incompressible flow mattamos OpenFOAM Running, Solving & CFD 7 July 28, 2005 12:03


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