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

Negative source term issues fvScalarMatrix

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 20, 2014, 19:51
Default Negative source term issues fvScalarMatrix
  #1
Member
 
james wilson
Join Date: Aug 2014
Location: Orlando, Fl
Posts: 39
Rep Power: 11
jameswilson620 is on a distinguished road
Hello all,

I would like to know how to solve the following equation when m_o < 0

## CODE BELOW##
dimensionedScalar D_dt(transportProperties.lookup("D_dt"));

fvScalarMatrix m_o_diffuseEqn
(
D_dt*fvm::laplacian(m_o_diffuse) == fvm::Sp(1,m_o_diffuse) - m_o
);
m_o_diffuseEqn.solve();
## CODE ABOVE##

where m_o is known (volScalarField) and m_o_diffuse will be determined. D_dt is simply a constant with units of m^2

I should say this solves just fine when m_o > 0. The code still compiles and solves when m_o < 0 the problem is that m_o_diffuse is identical to m_o i.e. nothing happened.

I've tried fvm::SuSp and many combinations of the source term handling features but OF doesnt seem to recognize anything:

error: no matching function for call to ‘SuSp(int, Foam::volScalarField&)’

I wouldnt be posting this if I haven't already tried applying information ive read in other posts. I simply cannot figure this one out!

Thanks, James
jameswilson620 is offline   Reply With Quote

Old   October 21, 2014, 17:55
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
You've got sign problem.

First, your equation should look like this


fvScalarMatrix m_o_diffuseEqn
(
- D_dt*fvm::laplacian(m_o_diffuse) == m_o - fvm::Sp(1,m_o_diffuse)
);
m_o_diffuseEqn.solve();

That's the same, but Sp and SuSp expect a positive diagonal (and yours was negative).

I would also consider solving for the variable of opposite sign, to make sure it remains positive. This definitely gets me to a known territory (elliptic relaxation). I think the negative variable should also work, but the meaning of source and sink terms etc. then becomes a bit weird.

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   October 21, 2014, 19:55
Default
  #3
Member
 
james wilson
Join Date: Aug 2014
Location: Orlando, Fl
Posts: 39
Rep Power: 11
jameswilson620 is on a distinguished road
Excellent! I will try this configuration. Also, another problem is that m_o can be both positive and negative. The implementation is not yet clear to me if the field has both mixed positive and negative values.

Perhaps a superposition of the negative portion on the RHS and the positive values either on the LHS or in an SuSp(1,m_o_positive) on the RHS of the equation you've provided? This is of course, where the summation of the split field results in the original field.

Thank you,

James
jameswilson620 is offline   Reply With Quote

Old   October 21, 2014, 19:58
Default
  #4
Member
 
james wilson
Join Date: Aug 2014
Location: Orlando, Fl
Posts: 39
Rep Power: 11
jameswilson620 is on a distinguished road
Amendment to last post:

The superposition of the two requires zeros in certain location s such that the sum of the two fields forms the original field. I would use either

+eps on the LHS instead of 0

And - eps for the other.

Would this work to eliminate divide by zero errors?
jameswilson620 is offline   Reply With Quote

Reply

Tags
diffusion equation, fvscalarmatrix, open foam, openfoam2.3, source term


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
OpenFOAM without MPI kokizzu OpenFOAM Installation 4 May 26, 2014 09:17
How does fluent handles the momentum source term? QBeast FLUENT 0 April 22, 2013 14:12
[blockMesh] non-orthogonal faces and incorrect orientation? nennbs OpenFOAM Meshing & Mesh Conversion 7 April 17, 2013 05:42
pisoFoam compiling error with OF 1.7.1 on MAC OSX Greg Givogue OpenFOAM Programming & Development 3 March 4, 2011 17:18
UDFs for Scalar Eqn - Fluid/Solid HT Greg Perkins FLUENT 0 October 11, 2000 03:43


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