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

Continuity equation in coupledFvMatrix

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   June 8, 2010, 04:51
Default Continuity equation in coupledFvMatrix
  #1
Senior Member
 
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20
bastil is on a distinguished road
HI all,

I try to write a coupled solver that uses continuity equation. I tried to do it that way:

Code:
        coupledFvScalarMatrix coupledEqns(1);

        coupledEqns.set
            (    
            0,
            new volScalarField
            (
                fvc::div(phi)
            )
        );
Does not seem to work that way. Do I need to convert to fvScalarMatrix? How? Thanks.

Regards Bastian
bastil is offline   Reply With Quote

Old   June 9, 2010, 05:07
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Just make it of type fvScalarMatrix:

Code:
coupledFvScalarMatrix coupledEqns(1);

coupledEqns.set
(    
   0,
   new fvScalarMatrix
   (
       fvm::ddt(rho)
       fvc::div(phi)
   )
);
where phi = rho*U interpolated to the cell faces. You can't solve what you had previously because fvc::grad calculates the gradient explicitly; there is no variable to solve for!
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   June 9, 2010, 10:40
Default
  #3
Senior Member
 
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20
bastil is on a distinguished road
Thanks Laurence,

since my code is steady-state and incompressible I do not really need fvm::ddt(rho). So I tried:

Code:
coupledFvScalarMatrix coupledEqns(1);

coupledEqns.set
(    
   0,
   new fvScalarMatrix
   (
       fvc::div(phi)
   )
);
This throws an error:

Code:
Making dependency list for source file coupledFoam.C
SOURCE=coupledFoam.C ;  g++ -m64 -Dlinux64 -DDP -DFOAM_DEV_REVISION_NUMBER=1716 -Wall -Wno-strict-aliasing -Wextra -Wno-unused-parameter -Wold-style-cast -O3  -DNoRepository -ftemplate-depth-40 -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/turbulenceModels/RAS -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/coupledMatrix/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/transportModels -IlnInclude -I. -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/OpenFOAM/lnInclude -I/opt/OpenFOAM/OpenFOAM-1.5-dev/src/OSspecific/Unix/lnInclude   -fPIC -c $SOURCE -o Make/linux64GccDPOpt/coupledFoam.o
In file included from coupledFoam.C:65:
coupledEqn.H: In function ‘int main(int, char**)’:
coupledEqn.H:14: error: no matching function for call to ‘Foam::fvMatrix<double>::fvMatrix(Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> >)’
/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/fvMatrix.C:327: note: candidates are: Foam::fvMatrix<Type>::fvMatrix(Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, Foam::Istream&) [with Type = double]
/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/fvMatrix.C:266: note:                 Foam::fvMatrix<Type>::fvMatrix(const Foam::tmp<Foam::fvMatrix<Type> >&) [with Type = double]
/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/fvMatrix.C:235: note:                 Foam::fvMatrix<Type>::fvMatrix(const Foam::fvMatrix<Type>&) [with Type = double]
/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/fvMatrix.C:188: note:                 Foam::fvMatrix<Type>::fvMatrix(Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>&, const Foam::dimensionSet&) [with Type = double]
/opt/OpenFOAM/OpenFOAM-1.5-dev/src/finiteVolume/lnInclude/initContinuityErrs.H:38: warning: unused variable ‘cumulativeContErr’
make: *** [Make/linux64GccDPOpt/coupledFoam.o] Error 1
I don't really understand why.
bastil is offline   Reply With Quote

Old   June 9, 2010, 13:15
Default
  #4
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Easy - you are trying to make a matrix and you are only giving it a field: fvc::div(phi).

That has no matrix coefficients - how do you expect to solve the system of equations that says

[0] * [x] = [b]

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

Old   June 9, 2010, 18:33
Default
  #5
Senior Member
 
BastiL
Join Date: Mar 2009
Posts: 530
Rep Power: 20
bastil is on a distinguished road
Quote:
Originally Posted by hjasak View Post

That has no matrix coefficients - how do you expect to solve the system of equations that says

[0] * [x] = [b]
Thanks Hrv,

that makes sence. I am not yet deep enough in it. So how is the correct formulation of the continuity equation?
bastil is offline   Reply With Quote

Old   February 10, 2012, 08:40
Default
  #6
Member
 
Join Date: Jun 2011
Posts: 42
Rep Power: 15
mikeP is on a distinguished road
Hello Mr. Jasak,

This is interesting. Could you also explain this code (fvm::div(phi, U) == 0) in the matrix form, similar to what you have written before as [0] * [x] = [b] ?

All the best
mikeP is offline   Reply With Quote

Old   February 10, 2012, 10:24
Default
  #7
Member
 
Join Date: Jun 2011
Posts: 42
Rep Power: 15
mikeP is on a distinguished road
another question - how is this possible? divergence of a scalar?

fvc::div(phi)
mikeP is offline   Reply With Quote

Old   October 13, 2014, 10:05
Default Hi
  #8
Senior Member
 
Join Date: Sep 2010
Posts: 226
Rep Power: 17
T.D. is on a distinguished road
Hi,

fvm: (div,phi) == 0

Briefly explaining,

fvm: stands for implicit. A discretization in space is done first (via the FVM) and in time if necessary and all the coeffs. are placed in a matrix form [O], then the resultant of the discretization of the source terms are placed to the right hand side of the equation in a vector [S].where the unknowns are the velocity field vector components on the mesh.
All above, are such that [O]*[U] = [S] which is solved to find [U] vector field components.

For the scalar issue: you should see 4.4.5 in:
http://www.openfoam.org/docs/user/fvSchemes.php

Regards,

T.D.
T.D. 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
How to write k and epsilon before the abnormal end xiuying OpenFOAM Running, Solving & CFD 8 August 27, 2013 16:33
Convergence moving mesh lr103476 OpenFOAM Running, Solving & CFD 30 November 19, 2007 15:09
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 03:58
continuity equation Rafal Main CFD Forum 4 November 29, 2006 10:27
Could anybody help me see this error and give help liugx212 OpenFOAM Running, Solving & CFD 3 January 4, 2006 19:07


All times are GMT -4. The time now is 02:54.