mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -1220,6 +1220,7 @@ Foam::Time& Foam::Time::operator++()
|
||||
writeOnce_ = false;
|
||||
}
|
||||
|
||||
functionObjects_.timeSet();
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -202,6 +202,18 @@ bool Foam::OutputFilterFunctionObject<OutputFilter>::end()
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::timeSet()
|
||||
{
|
||||
if (active())
|
||||
{
|
||||
ptr_->timeSet();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
template<class OutputFilter>
|
||||
bool Foam::OutputFilterFunctionObject<OutputFilter>::read
|
||||
(
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -201,6 +201,8 @@ public:
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual bool timeSet();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -120,6 +120,12 @@ bool Foam::functionObject::end()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObject::timeSet()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::functionObject> Foam::functionObject::iNew::operator()
|
||||
(
|
||||
const word& name,
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -157,6 +157,9 @@ public:
|
||||
// By default it simply calls execute().
|
||||
virtual bool end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual bool timeSet();
|
||||
|
||||
//- Read and set the function object if its data have changed
|
||||
virtual bool read(const dictionary&) = 0;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -190,6 +190,27 @@ bool Foam::functionObjectList::end()
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::timeSet()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
if (execution_)
|
||||
{
|
||||
if (!updated_)
|
||||
{
|
||||
read();
|
||||
}
|
||||
|
||||
forAll(*this, objectI)
|
||||
{
|
||||
ok = operator[](objectI).timeSet() && ok;
|
||||
}
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjectList::read()
|
||||
{
|
||||
bool ok = true;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -163,6 +163,9 @@ public:
|
||||
//- Called when Time::run() determines that the time-loop exits
|
||||
virtual bool end();
|
||||
|
||||
//- Called when time was set at the end of the Time::operator++
|
||||
virtual bool timeSet();
|
||||
|
||||
//- Read and set the function objects if their data have changed
|
||||
virtual bool read();
|
||||
|
||||
|
||||
73
src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C
Normal file
73
src/OpenFOAM/matrices/SquareMatrix/SquareMatrix.C
Normal file
@ -0,0 +1,73 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM 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.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "SquareMatrix.H"
|
||||
#include "labelList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::scalar Foam::detDecomposed
|
||||
(
|
||||
const SquareMatrix<Type>& matrix,
|
||||
const label sign
|
||||
)
|
||||
{
|
||||
scalar diagProduct = 1.0;
|
||||
|
||||
for (label i = 0; i < matrix.n(); ++i)
|
||||
{
|
||||
diagProduct *= matrix[i][i];
|
||||
}
|
||||
|
||||
return sign*diagProduct;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::scalar Foam::det(const SquareMatrix<Type>& matrix)
|
||||
{
|
||||
SquareMatrix<Type> matrixTmp = matrix;
|
||||
|
||||
labelList pivotIndices(matrix.n());
|
||||
label sign;
|
||||
LUDecompose(matrixTmp, pivotIndices, sign);
|
||||
|
||||
return detDecomposed(matrixTmp, sign);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::scalar Foam::det(SquareMatrix<Type>& matrix)
|
||||
{
|
||||
labelList pivotIndices(matrix.n());
|
||||
label sign;
|
||||
LUDecompose(matrix, pivotIndices, sign);
|
||||
|
||||
return detDecomposed(matrix, sign);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -81,6 +81,21 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// Global functions
|
||||
|
||||
//- Return the LU decomposed SquareMatrix det
|
||||
template<class Type>
|
||||
scalar detDecomposed(const SquareMatrix<Type>&, const label sign);
|
||||
|
||||
//- Return the SquareMatrix det
|
||||
template<class Type>
|
||||
scalar det(const SquareMatrix<Type>&);
|
||||
|
||||
//- Return the SquareMatrix det and the LU decomposition in the original matrix
|
||||
template<class Type>
|
||||
scalar det(SquareMatrix<Type>&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
@ -91,6 +106,12 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "SquareMatrix.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -33,9 +33,22 @@ void Foam::LUDecompose
|
||||
scalarSquareMatrix& matrix,
|
||||
labelList& pivotIndices
|
||||
)
|
||||
{
|
||||
label sign;
|
||||
LUDecompose(matrix, pivotIndices, sign);
|
||||
}
|
||||
|
||||
|
||||
void Foam::LUDecompose
|
||||
(
|
||||
scalarSquareMatrix& matrix,
|
||||
labelList& pivotIndices,
|
||||
label& sign
|
||||
)
|
||||
{
|
||||
label n = matrix.n();
|
||||
scalar vv[n];
|
||||
sign = 1;
|
||||
|
||||
for (register label i=0; i<n; i++)
|
||||
{
|
||||
@ -113,6 +126,7 @@ void Foam::LUDecompose
|
||||
Swap(matrixj[k], matrixiMax[k]);
|
||||
}
|
||||
|
||||
sign *= -1;
|
||||
vv[iMax] = vv[j];
|
||||
}
|
||||
|
||||
|
||||
@ -79,6 +79,15 @@ void LUDecompose
|
||||
labelList& pivotIndices
|
||||
);
|
||||
|
||||
//- LU decompose the matrix with pivoting.
|
||||
// sign is -1 for odd number of row interchanges and 1 for even number.
|
||||
void LUDecompose
|
||||
(
|
||||
scalarSquareMatrix& matrix,
|
||||
labelList& pivotIndices,
|
||||
label& sign
|
||||
);
|
||||
|
||||
//- LU decompose the matrix into a lower (L) and upper (U) part. U = L.T()
|
||||
void LUDecompose(scalarSymmetricSquareMatrix& matrix);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user