2010-10-18 13:15:37 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / O peration | Version: 3.2
|
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-09-29 18:57:03 +00:00
|
|
|
-------------------------------------------------------------------------------
|
2010-10-18 13:15:37 +00:00
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-09-29 18:57:03 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-10-18 13:15:37 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-10-18 13:15:37 +00:00
|
|
|
option) any later version.
|
2010-09-29 18:57:03 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is distributed in the hope that it will be useful, but
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
2010-10-18 13:15:37 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-10-18 13:15:37 +00:00
|
|
|
|
|
|
|
Application
|
|
|
|
testBlockMatrix
|
|
|
|
|
|
|
|
Author
|
|
|
|
Hrvoje Jasak, Wikki Ltd. All rights reserved.
|
|
|
|
|
|
|
|
Description
|
|
|
|
Test block matrix coefficient assembly
|
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
2010-09-29 18:57:03 +00:00
|
|
|
|
|
|
|
#include "argList.H"
|
|
|
|
#include "fieldTypes.H"
|
|
|
|
#include "blockLduMatrices.H"
|
|
|
|
#include "blockLduSolvers.H"
|
2015-06-17 13:53:59 +00:00
|
|
|
#include "foamTime.H"
|
2010-09-29 18:57:03 +00:00
|
|
|
#include "fvMesh.H"
|
|
|
|
|
|
|
|
#include "blockVector2Matrix.H"
|
|
|
|
#include "tensor2.H"
|
|
|
|
|
|
|
|
using namespace Foam;
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
// Main program:
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
# include "setRootCase.H"
|
|
|
|
# include "createTime.H"
|
|
|
|
# include "createMesh.H"
|
|
|
|
|
|
|
|
blockScalarMatrix scalarMatrix(mesh);
|
|
|
|
|
|
|
|
blockVectorMatrix blockMatrix(mesh);
|
|
|
|
|
|
|
|
const label diagSize = mesh.lduAddr().size();
|
|
|
|
const label ulSize = mesh.lduAddr().lowerAddr().size();
|
|
|
|
const scalar diagCoeff = -2.0;
|
|
|
|
// const scalar diagCoeff = -4.0;
|
|
|
|
|
|
|
|
// Info << "Doing diagonal matrix" << endl;
|
|
|
|
blockMatrix.upper() = scalarField(ulSize, 1.0);
|
|
|
|
|
|
|
|
scalarField dScalar(diagSize, diagCoeff);
|
|
|
|
dScalar[0] = -10000;
|
|
|
|
dScalar[diagSize - 1] = -10000;
|
|
|
|
|
|
|
|
blockMatrix.diag() = dScalar;
|
|
|
|
|
|
|
|
// tensorField dTensor
|
|
|
|
// (
|
|
|
|
// diagSize,
|
|
|
|
// tensor
|
|
|
|
// (
|
|
|
|
// diagCoeff, 0.0, 0.0,
|
|
|
|
// 0.0, diagCoeff, 0.0,
|
|
|
|
// 0.0, 0.0, -1.0
|
|
|
|
// )
|
|
|
|
// );
|
|
|
|
|
|
|
|
// dTensor[0] =
|
|
|
|
// tensor
|
|
|
|
// (
|
|
|
|
// -10000.0, 0.0, 0.0,
|
|
|
|
// 0.0, -10000.0, 0.0,
|
|
|
|
// 0.0, 0.0, -1.0
|
|
|
|
// );
|
|
|
|
|
|
|
|
// dTensor[diagSize - 1] =
|
|
|
|
// tensor
|
|
|
|
// (
|
|
|
|
// -1.0, 0.0, 0.0,
|
|
|
|
// 0.0, -1.0, 0.0,
|
|
|
|
// 0.0, 0.0, -1.0
|
|
|
|
// );
|
|
|
|
|
|
|
|
// blockMatrix.diag() = dTensor;
|
|
|
|
|
|
|
|
vectorField psi(diagSize, vector(0, 0, 0));
|
|
|
|
vectorField source(diagSize, vector(0, 0, 0));
|
|
|
|
source[0] = vector(0, 0, 0);
|
|
|
|
source[diagSize - 1] = vector(10000, 0, 0);
|
|
|
|
|
|
|
|
// psi[0] = vector(0, 0, 0);
|
|
|
|
// psi[diagSize - 1] = vector(-1, 0, 0);
|
|
|
|
|
|
|
|
BlockSolverPerformance<vector> solverPerf =
|
|
|
|
blockVectorSolver::New
|
|
|
|
(
|
|
|
|
"HrvsVar",
|
|
|
|
blockMatrix,
|
2011-08-14 16:39:59 +00:00
|
|
|
mesh.solutionDict().solver("HrvsVar")
|
2010-09-29 18:57:03 +00:00
|
|
|
)->solve(psi, source);
|
|
|
|
|
|
|
|
Info << "Psi: " << psi << endl;
|
|
|
|
// Info << "Psi: " << psi.component(vector::X) << endl;
|
|
|
|
|
|
|
|
// Large block matrix
|
|
|
|
BlockLduMatrix<vector2> vector2Matrix(mesh);
|
|
|
|
|
|
|
|
vector2Matrix.diag().asScalar() =
|
|
|
|
scalarField(vector2Matrix.diag().size(), 1);
|
|
|
|
|
|
|
|
vector2Matrix.diag() +=
|
|
|
|
Field<vector2>(vector2Matrix.diag().size(), vector2::one);
|
|
|
|
|
|
|
|
vector2Matrix.upper() =
|
|
|
|
Field<tensor2>(vector2Matrix.upper().size(), tensor2::one);
|
|
|
|
|
|
|
|
Info<< "End\n" << endl;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// ************************************************************************* //
|