1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Steady-state solver for incompressible, turbulent flow, with implicit
29 coupling between pressure and velocity achieved by BlockLduMatrix
30 Turbulence is in this version solved using the existing turbulence
34 Klas Jareteg, Chalmers University of Technology,
35 Vuko Vukcevic, FMENA Zagreb.
37 \*---------------------------------------------------------------------------*/
40 #include "singlePhaseTransportModel.H"
43 #include "VectorNFieldTypes.H"
44 #include "volVectorNFields.H"
45 #include "blockLduSolvers.H"
46 #include "blockVectorNMatrices.H"
48 #include "blockMatrixTools.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 int main(int argc, char *argv[])
55 # include "setRootCase.H"
56 # include "createTime.H"
57 # include "createMesh.H"
58 # include "createFields.H"
59 # include "initContinuityErrs.H"
60 # include "readBlockSolverControls.H"
62 // Calculate coupling matrices only once since the mesh doesn't change and
63 // implicit div and grad operators are only dependant on Sf. Actually
64 // coupling terms (div(U) and grad(p)) in blockMatrix do not change, so they
65 // could be inserted only once, resetting other parts of blockMatrix to zero
66 // at the end of each time step. VV, 30/April/2014
67 # include "calculateCouplingMatrices.H"
69 Info<< "\nStarting time loop\n" << endl;
70 while (runTime.loop())
72 Info<< "Time = " << runTime.timeName() << nl << endl;
76 // Initialize block matrix
77 # include "initializeBlockMatrix.H"
79 // Assemble and insert momentum equation
82 // Assemble and insert pressure equation
85 // Insert coupling, updating the boundary contributions
86 // Last argument in insertBlockCoupling says if the first location
87 // should be incremented. This is needed for arbitrary positioning
88 // of U and p in the system. This could be better. VV, 30/April/2014
89 blockMatrixTools::insertBlockCoupling(3, 0, UInp, U, A, b, false);
90 blockMatrixTools::insertBlockCoupling(0, 3, pInU, p, A, b, true);
92 // Solve the block matrix
93 BlockSolverPerformance<vector4> solverPerf =
94 BlockLduSolver<vector4>::New
98 mesh.solutionDict().solver("Up")
104 blockMatrixTools::retrieveSolution(0, U.internalField(), Up);
105 blockMatrixTools::retrieveSolution(3, p.internalField(), Up);
107 U.correctBoundaryConditions();
108 p.correctBoundaryConditions();
110 phi = (fvc::interpolate(U) & mesh.Sf()) + pEqn.flux() + presSource;
112 # include "continuityErrs.H"
116 turbulence->correct();
119 Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
120 << " ClockTime = " << runTime.elapsedClockTime() << " s"
124 Info<< "End\n" << endl;