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

Workings of setValuesFromList

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By lrunber

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 30, 2011, 20:48
Default Workings of setValuesFromList
  #1
New Member
 
lazio
Join Date: Apr 2010
Posts: 22
Rep Power: 16
lrunber is on a distinguished road
Dear Foamers,

I am trying to understand the function setValuesFromList which is in fvMatrix.C lines 181-267 in OF 2.1.0.

As I understand the core is executed in lines 207 & 208:
Code:
        psi[celli] = value;
        source_[celli] = value*Diag[celli];
which sets the source vector equal to the diagonal times the value specified. This makes sense and I can understand.

However I fail to fully grasp lines 220-232, i.e.,

Code:
             if (symmetric())
                    {
                        if (celli == own[facei])
                        {
                            source_[nei[facei]] -= upper()[facei]*value;
                        }
                        else
                        {
                            source_[own[facei]] -= upper()[facei]*value;
                        }

                        upper()[facei] = 0.0;
                    }
* What is the meaning of upper()?
* What is the meaning of "source_[nei[facei]] -= upper()[facei]*value", does this set the source vector of the neighbor cells, and why does it only subtract and not set?
* Would it not be suffice to just set the neighbor matrix coefficients (a_N) to zero?

Thank you very much, all input is very much appreciated.
lrunber is offline   Reply With Quote

Old   December 31, 2011, 11:17
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings lrunber,

I'm not familiar with this part of the code of OpenFOAM, but since we are near the end of 2011 and beginning of 2012 (and if will be like last year), the experts on this subject won't come back for a another few days.

So, based on the following information:
  • Source: http://foam.sourceforge.net/docs/cpp....html#_details
    Quote:
    lduMatrix is a general matrix class in which the coefficients are stored as three arrays, one for the upper triangle, one for the lower triangle and a third for the diagonal.
    Addressing arrays must be supplied for the upper and lower triangles.
  • The outer if block checks for symmetry, therefore the contents are meant to be related only to symmetry.

Quote:
Originally Posted by lrunber View Post
* What is the meaning of upper()?
Should be the reference to the Upper matrix of a symmetric matrix. This way only half of the matrix needs to be stored.

Quote:
Originally Posted by lrunber View Post
* What is the meaning of "source_[nei[facei]] -= upper()[facei]*value", does this set the source vector of the neighbor cells, and why does it only subtract and not set?
In OpenFOAM, operators sometimes don't do what we expect them to do. Check the source code when in doubt: http://foam.sourceforge.net/docs/cpp...ce.html#l00215

Quote:
Originally Posted by lrunber View Post
* Would it not be suffice to just set the neighbor matrix coefficients (a_N) to zero?
By what I can deduce from that set of code, for whatever reason, that "upper" matrix seems to only contain weights. That is why the set value is weighed-in with the upper value, then neutralized so it won't be used in future iterations.

This should get you going forward, at least until someone more experienced can answer you!

Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   December 31, 2011, 13:30
Default
  #3
New Member
 
lazio
Join Date: Apr 2010
Posts: 22
Rep Power: 16
lrunber is on a distinguished road
Thank you very much Bruno!
May I also take this opportunity to wish you a fantastic 2012

I think I may have figured it out, I will write out my understanding and if someone could please just comment on the correctness..

The discretized FVM equation for each cell can be written out as:

a_p \phi_p + \sum a_n \phi_n = r (Eq. 1)

In the ldumatrix these terms correspond to:
a_p = diag()
a_n = upper() and lower()
r = source_

and the solution variable corresponds to:
\phi = psi_

To "force" the solution in the specified cells (cellLabels) to the specified values (values), the following operations are performed on the matrix for each of the concerned equations:
\phi_p = value (line: 207)
r = value * a_p (line: 208)
a_n = 0.0 (line: 231 or 244 & 245, depending on matrix symmetry)

This results in the trivial solution of Eq. 1 i.e.,
a_p \phi_p + \sum 0.0 * \phi_n = a_p \phi_p

However, there remains the important aspect of the influence of the fixed cells on their neighbor cells and setting a_n = 0.0 removes this influence (since it is zero'd!). This is where I am very impressed with this code (if I understand it correctly), since before the zero'ing of a_n, the influence of the concerned cells is added to neighbors by modifying the source term for the neighboring cells (r^* ) using the old a_n value before setting it to zero.
r^* = r^* - \sum a_n * value (lines 224 & 228 or 237 & 241 depending on symmetry)

I hope my understanding is correct. Thanks again Bruno for putting me on track.
wyldckat likes this.
lrunber 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
question about uds tanven FLUENT 2 July 5, 2015 11:22
Unanswered question niklas OpenFOAM 2 July 31, 2013 16:03
internal field question - PitzDaily Case atareen64 OpenFOAM Running, Solving & CFD 2 January 26, 2011 15:26
CHANNEL FLOW: a question and a request Carlos Main CFD Forum 4 August 23, 2002 05:55
question K.L.Huang Siemens 1 March 29, 2000 04:57


All times are GMT -4. The time now is 16:52.