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

Can I establish two or more fvMatrix objects in one program?

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 15, 2022, 06:35
Default Can I establish two or more fvMatrix objects in one program?
  #1
New Member
 
Chao Li
Join Date: Oct 2019
Posts: 6
Rep Power: 7
chaosCFD is on a distinguished road
Dear Foamers,

Does OpenFOAM allow to establish two fvMatrix objects in one program? I tried the following code:
Code:
	fvVectorMatrix DEqn1
        (
            fvm::laplacian(impKf_, D(), "laplacian(DD,D)")
            - fvc::laplacian(impKf_, D(), "laplacian(DD,D)")
	);

        fvVectorMatrix DEqn2
       (
          fvm::laplacian(impKf_, D(), "laplacian(DD,D)")
          - fvc::laplacian(impKf_, D(), "laplacian(DD,D)")
       );

Info << "source of DEqn1: " << DEqn1.source() << endl;
Info << "source of DEqn2: " << DEqn2.source() << endl;
And the output is:

Code:
source of DEqn1: 4{(0 0 0)}
source of DEqn2: 4((0 0 0) (0 0 0) (0 0 0) (0 -27000 0))
Why the sources of the two fvMatrixes are different? They are established with the same parameters.

BTW, the fvc::laplacian(impKf_, D(), "laplacian(DD,D)") is:
Code:
dimensions      [1 -2 -2 0 0 0 0];

internalField   nonuniform List<vector> 4((0 0 0) (0 0 0) (0 0 0) (0 -180000 0));

boundaryField
{
    top
    {
        type            zeroGradient;
    }
    left
    {
        type            zeroGradient;
    }
    right
    {
        type            zeroGradient;
    }
    bottom
    {
        type            zeroGradient;
    }
    front
    {
        type            empty;
    }
    back
    {
        type            empty;
    }
}
chaosCFD is offline   Reply With Quote

Old   December 28, 2022, 22:45
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,907
Rep Power: 33
hjasak will become famous soon enough
Why D(), ie why do you need brackets? Is there a memory leak, or a reference to temporary?

Try making a field D and repeat the exercise.it looks like your second D or second equation has got a fixedValue boundary condition on the bottom patch. I’m not sure how this happened.

There are always dozens of such matrices created all the time - this must work.

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

Old   January 3, 2023, 09:33
Default
  #3
New Member
 
Chao Li
Join Date: Oct 2019
Posts: 6
Rep Power: 7
chaosCFD is on a distinguished road
Quote:
Originally Posted by hjasak View Post
Why D(), ie why do you need brackets? Is there a memory leak, or a reference to temporary?

Try making a field D and repeat the exercise.it looks like your second D or second equation has got a fixedValue boundary condition on the bottom patch. I’m not sure how this happened.

There are always dozens of such matrices created all the time - this must work.

Hrv
Dear Prof. Jasak
D() returns a volVectorField D_. The definition is in the base class.
Code:
            
virtual volVectorField& D()
            {
                return D_;
            }
Is this way of writing more likely to cause memory leak?
chaosCFD is offline   Reply With Quote

Reply

Tags
development, fvmatrix, openfoam, solids4foam


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
[TUTORIAL] Run fluent on distributed memory with 2 windows 7 64 bit machines ghost82 FLUENT 54 February 9, 2022 04:32
fvMatrix, fvOptions and SuSp: automatic implicit/explicit source-term treatment Zeppo OpenFOAM Programming & Development 7 December 15, 2021 11:20
Incompatible dimensions for operation ruben23 OpenFOAM Running, Solving & CFD 2 June 12, 2015 05:14
the openfoam source term and fvmatrix problem wenxu OpenFOAM Programming & Development 0 September 5, 2014 11:56
Update boundary conditions calculated by an external program CedricVH OpenFOAM 2 January 15, 2010 12:55


All times are GMT -4. The time now is 20:11.