# Block coupling three equations using foam extend 4.1

 Register Blogs Members List Search Today's Posts Mark Forums Read

 March 16, 2019, 12:29 Block coupling three equations using foam extend 4.1 #1 Member   Elwardi Fadeli Join Date: Dec 2016 Location: Boumerdes, Algeria Posts: 37 Rep Power: 5 Hi all, I'm using (trying to use ) foam-extend's coupledFvMatrix (https://github.com/Unofficial-Extend...vBlockMatrix.H) to couple three equations. The coupling terms consist of "laplacians" and Time derivatives . This thread explains how I'm approaching this and what the current results are. I know I'm doing something (Or more) wrong since these results are not sane enough . First, construct a volVectorField to hold solved (scalar) Fields: Code: ```volVector3Field pSwSg ( IOobject ( "pSwSg", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, dimensionedVector3("zero", dimless, vector3::zero) );``` Later in the code, define each fvScalarMatrix; for example: Code: ```// "Main" pressure equation fvScalarMatrix pEqn ( fvm::ddt(M, p) + fvm::laplacian(-D, p) + fvc::div(somePhi) ); // Coupled term between pEqn and some other SwEqn fvScalarMatrix SwInp ( - fvm::ddt(M1, Sw) // and maybe fvm::laplacian(D1, Sw) );``` The actual coupling is carried out when creating the block matrix: Code: ```// Instantiate the coubled matrix fvBlockMatrix resEqn(pSwSg); // Add equations resEqn.insertEquation(0, pEqn); resEqn.insertEquation(1, SwEqn); resEqn.insertEquation(2, SgEqn); // Insert coupling terms // Sw term in pEqn: resEqn.insertEquationCoupling(0, 1, SwInp); // Note that SwInp is a fvScalarMatrix // Add more couplings ...``` After this, we solve the blockMatrix and retrieve solutions. The problem is, inserting the following code: Code: ```Info<< "Lower Coupling:" << << resEqn.coupleLower() << nl << "Upper Coupling:" << << resEqn.coupleUpper() << nl << "Component Coupled:" << << resEqn.componentCoupled() << nl << "Coupled Diagonal:" << nl << resEqn.diag() << endl;``` somewhere before solving the equation, and testing it on a minimal case (1D 5cells mesh), results in the following output: Code: ```Lower Coupling: 3 ( unallocated 1 unallocated 1 unallocated 0 ) Upper Coupling: 3 ( unallocated 1 unallocated 1 unallocated 0 ) Component Coupled: 1 Coupled Diagonal: square 5 ( (-865.137 -7.42132e-07 -7.42132e-07 21.9694 7.42132e-06 0 -129771 -0.00011132 -0.000103899) (-14549.7 -1.51723e-13 -1.51723e-13 368.569 1.51723e-12 0 -2.18245e+06 -2.27584e-11 -2.12412e-11) (-302060 -4.08706e-29 -4.08706e-29 7645.23 4.08706e-28 0 -4.5309e+07 -6.13059e-27 -5.72188e-27) (-1.3066e+07 -8.3987e-74 -8.3987e-74 330590 8.3987e-73 0 -1.95991e+09 -1.2598e-71 -1.17582e-71) (-1.27778e+07 -3.88293e-254 -3.88293e-254 323294 3.88293e-253 0 -1.91666e+09 -5.8244e-252 -5.4361e-252) ) GMRES: Solving for pSwSg, Initial residual = (0.006936 0.000167427 0.992364), Final residual = (2.11584e-12 7.29283e-15 1.42317e-14), No Iterations 1``` Huh, no upper/lower coupling . Any help or orientation to some reference materials is greatly appreciated. Best regards, Kummi likes this.

 March 18, 2019, 22:20 #2 Senior Member   Hrvoje Jasak Join Date: Mar 2009 Location: London, England Posts: 1,863 Rep Power: 29 Are you looking at the right place? Look at the matrix: there is diag, upper and lower; then there is out-of-core coefficient like processor boundaries. From your output, you MUST get block clefs for upper and lower; otherwise GMT’s would not be called. I think you are looking at the wrong place. I also have doubts about your cross-mciupling matrix, but that’s another thing... __________________ Hrvoje Jasak Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk

March 19, 2019, 11:35
#3
Member

Join Date: Dec 2016
Location: Boumerdes, Algeria
Posts: 37
Rep Power: 5

As you pointed out, the coupled matrix seems to be OK unless I'm making a vague, invalid assumption somewhere (detailed log attached).

I need to be 100% sure of something though; Does

Code:
`fvBlockMatrix::insertEquationCoupling(id1, id2, 2In1)`
insert the matrix 2In1 as coupling term of variable of equation 2 in equation1 ?

(following the same convention of insertBlockCoupling used in pUCoupledFoam) Or is it the other way around.
Attached Files
 log.txt (2.8 KB, 3 views)

 Tags block matrix, block-coupling, foam ext 4.0, foam extend