
[Sponsors] 
March 22, 2011, 15:51 
Conjugate Mass Foam Solver with reaction?

#1 
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 604
Rep Power: 22 
Hello Foamers,
I managed to combine one of my solvers that solves for time dependent passive scalar transport in a turbulent flow field for at particular species with mass transport in a solid similar to conjugateHeatFoam. This works without a hitch, but when I try to attached a simple first order reaction based on a stationary species in the solid phase it gives some errors on runtime. At first, i defined the separate species as its own field, not part of the coupledFvScalarMatrix. This gave an error: > FOAM FATAL ERROR: incompatible fields for operation [C] + [Cmetal] I am sure it is from the source term (fvm::Sp(0.01*Csolid,Cmetal)) where i tried to couple a non coupleFvScalarMatrix field into the mix. I then decided to try and make a third region (identical to the solid region) that is overlayed on the solid region into a different mesh. Code:
// Add solidside equation CEqns.set ( 1, new fvScalarMatrix ( fvm::ddt(Csolid)  fvm::laplacian(Dsolid, Csolid) + fvm::Sp(0.01*Csolid,Cmetal) ) ); //solve the metal oxidation reaction only in the solid CEqns.set ( 2, new fvScalarMatrix ( fvm::ddt(Cmetal) + fvm::Sp(0.01*Csolid,Cmetal) ) ); > FOAM FATAL ERROR: incompatible fields for operation [C] + [C] I'm assuming that the error was because I was trying to solve a system in which one variable was defined on one mesh....and another defined on a separate mesh. how does one overcome this issue? Dan p.s. I am using 1.6ext 

March 22, 2011, 16:14 

#2 
Senior Member
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 12 
I'm pretty sure all the fields need to be on the same mesh, if they're not then you'll have to find a way of mapping the terms from one mesh to another. I would say try implementing your source term using an explicit source term first to see if that works, or even just a scalar value to see if it runs.


March 22, 2011, 18:40 

#3  
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 604
Rep Power: 22 
Quote:
Code:
// Add solidside equation CEqns.set ( 1, new fvScalarMatrix ( fvm::ddt(Csolid)  fvm::laplacian(Dsolid, Csolid) + k*Csolid*Cmetal ) ); //add the solidside equation for another scalar in the solid CEqns.set ( 2, new fvScalarMatrix ( fvm::ddt(Cmetal) + k*Csolid*Cmetal ) ); CEqns.solve(); Dan 

March 23, 2011, 05:16 

#4 
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 252
Rep Power: 11 
Hi!
If you want to use fvm::Sp() in the building of your matrix, you ought to inverse Csolid and Cmetal within the fonction Sp(). Indeed the second argument is the variable of the matrix: Code:
fvm::Sp(0.01*Cmetal,Csolid) Bests, Cyp 

March 23, 2011, 10:09 

#5  
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 604
Rep Power: 22 
Quote:
Code:
> FOAM FATAL ERROR: incompatible fields for operation [C] + [C] From function checkMethod(const fvMatrix<Type>&, const fvMatrix<Type>&) in file /home/dcombest/OpenFOAM/OpenFOAM1.6ext/src/finiteVolume/lnInclude/fvMatrix.C at line 1207. FOAM aborting Code:
// Add solidside equation CEqns.set ( 1, new fvScalarMatrix ( fvm::ddt(Csolid)  fvm::laplacian(Dsolid, Csolid) + fvm::Sp(k*Cmetal,Csolid)//k*Csolid*Cmetal ) ); //add the solidside equation for another scalar in the solid CEqns.set ( 2, new fvScalarMatrix ( fvm::ddt(Cmetal) + fvm::Sp(k*Cmetal,Csolid)//k*Csolid*Cmetal ) ); CEqns.solve(); Code:
// Add solidside equation CEqns.set ( 1, new fvScalarMatrix ( fvm::ddt(Csolid)  fvm::laplacian(Dsolid, Csolid) + k*Csolid*Cmetal ) ); //add the solidside equation for another scalar in the solid CEqns.set ( 2, new fvScalarMatrix ( fvm::ddt(Cmetal) + k*Csolid*Cmetal ) ); CEqns.solve(); Dan 

March 23, 2011, 10:18 

#6 
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 252
Rep Power: 11 
Hi!
Look at your second equation : if you want to construct a matrix for the variable Cmetal, the second argument of your source term fvm::Sp() must be Cmetal : Code:
fvm::Sp(k*Csolid,Cmetal) I think it should work now. 

March 23, 2011, 11:44 
Excellent!

#7 
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 604
Rep Power: 22 
That did the trick! I'm still unclear as to why the fvm::Sp() is better than just an explicit k*C*C in the equation. Is this a situation where k*C*C is collected in the b of Ax=b and fvm::Sp() collects the term into A of Ax = b? Is there an advantage? Thanks again for the help.
Dan 

March 23, 2011, 11:51 

#8  
Senior Member
Daniel P. Combest
Join Date: Mar 2009
Location: St. Louis, USA
Posts: 604
Rep Power: 22 
I actually found the answer on the message boards here (http://www.cfdonline.com/Forums/ope...fvmspb.html) which states:
Quote:


March 23, 2011, 11:53 

#9  
Senior Member
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 252
Rep Power: 11 
Quote:


Tags 
block matrix, conjugate, mass source term 
Thread Tools  
Display Modes  


Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
channelFoam for a 3D pipe  AlmostSurelyRob  OpenFOAM  3  June 24, 2011 13:06 
Import problem  ARC  Open Source Meshers: Gmsh, Netgen, CGNS, ...  0  February 27, 2010 11:56 
gmsh2ToFoam  sarajags_89  OpenFOAM  0  November 24, 2009 23:50 
Conjugate Gradient Solver.  Froed  Main CFD Forum  0  July 29, 2005 06:29 
Conjugate gradient solver for pressure.  R.F.  Main CFD Forum  0  November 12, 2004 12:49 