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

fvVectorMatrix & blockMatrixSolver

Register Blogs Community New Posts Updated Threads Search

Like Tree4Likes

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 3, 2023, 11:01
Default
  #21
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 11
randolph is on a distinguished road
Quote:
Originally Posted by bigphil View Post
Hi Rdf,

It should be possible to do this by looking at the "solveSegregated" function in the fvMatrix class (see fvMatrixSolve.C).

The "solveSegregated" function forms the linear system for each direction before solving it.

fvMatrix stores the matrix without the boundary condition contributions because the boundary condition contribution may differ for each direction.
Before solving each direction, fvMatrix makes a copy of the matrix diagonal and modifies it with the boundary conditions for that direction before solving it; you could use similar code to prepare the matrix for each direction. For example, see how the addBoundaryDiag function is used inside the solveSegregated function:
Code:
   for (direction cmpt=0; cmpt<Type::nComponents; cmpt++)
    {
        if (validComponents[cmpt] == -1) continue;

	// copy field and source                                                                                                                                

        scalarField psiCmpt(psi.primitiveField().component(cmpt));
        addBoundaryDiag(diag(), cmpt);

        scalarField sourceCmpt(source.component(cmpt));

        // ...
Philip
Philip,

Just a step back, would there any high-level controls that allow the fvVectorMatrix to solve for specific components? For example, I want to solve Ux, Uy, but not Uz.

I look into the code and it looks like I have to write a new class for this purpose. What is your opinion?

Thanks,
Rdf
randolph is offline   Reply With Quote

Old   August 8, 2023, 13:03
Default
  #22
Super Moderator
 
bigphil's Avatar
 
Philip Cardiff
Join Date: Mar 2009
Location: Dublin, Ireland
Posts: 1,097
Rep Power: 34
bigphil will become famous soon enoughbigphil will become famous soon enough
Hi Rdf,

One way to control which components are solved by fvVectorMatrix is to manipulate the "empty" directions. For example, by default, fvVectorMatrix will not solve in an empty direction (like for a 2-D case).

In the code, you could hack the empty directions, e.g.
Code:
Vector<label>& solD = const_cast<Vector<label>&>(mesh.solutionD());

// Enable solution in the X direction
solD[vector::X] = 1;

// Enable solution in the Y direction
solD[vector::Y] = 1;

// Disable solution in the Z direction
solD[vector::Z] = -1;
This is a hack: it may work for you, but it may also have unintended consequences.
randolph likes this.
bigphil is offline   Reply With Quote

Reply

Tags
fvm::laplaciantranspose, pucoupledfoam


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
What does mean Operation Source in fvVectorMatrix ( .H())? EmadTandis OpenFOAM Programming & Development 2 April 29, 2011 07:03
FvVectorMatrix questions stephan OpenFOAM Running, Solving & CFD 6 May 4, 2007 07:23
Matrix shuo OpenFOAM Running, Solving & CFD 4 October 23, 2006 04:09
FvVectorMatrix cfdengineering OpenFOAM Running, Solving & CFD 0 December 1, 2005 10:51


All times are GMT -4. The time now is 06:57.