Bugfix: Block solver AMG memory leak fix and cumulative update. AUthor: Hrvoje Jasak. Merge: Hrvoje Jasak.

This commit is contained in:
Hrvoje Jasak 2015-08-26 10:46:14 +01:00
commit 2a4dfcce3f
27 changed files with 189 additions and 144 deletions

View file

@ -28,7 +28,7 @@
fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)
- ghf*fvc::snGrad(rho)
- fvc::snGrad(pd)
) * mesh.magSf()
)*mesh.magSf()
)
);
}

View file

@ -1,5 +1,5 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
LIB_LIBS = \
-lmeshTools \
-lmeshTools

View file

@ -363,26 +363,52 @@ bool Foam::linearValveFvMesh::update()
Info << "Moving points post slider attach" << endl;
if (topoChangeMap3->morphing())
bool localMorphing3 = topoChangeMap3->morphing();
bool globalMorphing3 = localMorphing3;
reduce(globalMorphing3, orOp<bool>());
if (globalMorphing3)
{
pointField newPoints = allPoints();
if (localMorphing3)
{
msPtr_->updateMesh(topoChangeMap3());
if (debug)
{
Info << "Moving points post slider attach" << endl;
}
pointField newPoints = allPoints();
pointField mappedOldPointsNew(newPoints.size());
mappedOldPointsNew.map(oldPointsNew, topoChangeMap3->pointMap());
mappedOldPointsNew.map
(
oldPointsNew,
topoChangeMap3->pointMap()
);
// Solve the correct mesh motion to make sure motion fluxes
// are solved for and not mapped
movePoints(mappedOldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(mappedOldPointsNew);
resetMotion();
setV0();
movePoints(newPoints);
fvMesh::movePoints(newPoints);
}
else
{
// No local topological change. Execute double motion for
// sync with topological changes
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(oldPointsNew);
resetMotion();
setV0();
// Set new point motion
fvMesh::movePoints(newPoints);
}
}
}

View file

@ -532,12 +532,16 @@ bool Foam::linearValveLayersFvMesh::update()
if (localMorphing2)
{
Info << "Topology change; executing pre-motion" << endl;
movePoints(topoChangeMap2->preMotionPoints());
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(topoChangeMap2->preMotionPoints());
newPoints = topoChangeMap2->preMotionPoints();
}
else
{
movePoints(newPoints);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(newPoints);
}
setV0();
@ -589,7 +593,9 @@ bool Foam::linearValveLayersFvMesh::update()
// Solve the correct mesh motion to make sure motion fluxes
// are solved for and not mapped
movePoints(mappedOldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(mappedOldPointsNew);
resetMotion();
setV0();
@ -601,7 +607,9 @@ bool Foam::linearValveLayersFvMesh::update()
{
// No local topological change. Execute double motion for
// sync with topological changes
movePoints(oldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(oldPointsNew);
resetMotion();
setV0();

View file

@ -477,7 +477,9 @@ bool Foam::mixerFvMesh::update()
pointField mappedOldPointsNew(allPoints().size());
mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
movePoints(mappedOldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(mappedOldPointsNew);
resetMotion();
setV0();
@ -488,7 +490,10 @@ bool Foam::mixerFvMesh::update()
else
{
pointField newPoints = allPoints();
movePoints(oldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(oldPointsNew);
resetMotion();
setV0();

View file

@ -276,7 +276,9 @@ bool Foam::movingBodyTopoFvMesh::update()
// pointField mappedOldPointsNew(allPoints().size());
// mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
// movePoints(mappedOldPointsNew);
// // Note: using setOldPoints instead of movePoints.
// // HJ, 23/Aug/2015
// setOldPoints(mappedOldPointsNew);
// resetMotion();
// setV0();
@ -286,7 +288,9 @@ bool Foam::movingBodyTopoFvMesh::update()
// else
// {
// // No change, use old points
// movePoints(oldPointsNew);
// // Note: using setOldPoints instead of movePoints.
// // HJ, 23/Aug/2015
// setOldPoints(oldPointsNew);
// resetMotion();
// setV0();
// }

View file

@ -284,7 +284,10 @@ bool Foam::multiMixerFvMesh::update()
pointField mappedOldPointsNew(allPoints().size());
mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
movePoints(mappedOldPointsNew);
// Note: using setOldPoints instead of movePoints.
// HJ, 23/Aug/2015
setOldPoints(mappedOldPointsNew);
resetMotion();
setV0();

View file

@ -236,7 +236,9 @@ bool Foam::multiTopoBodyFvMesh::update()
// pointField mappedOldPointsNew(allPoints().size());
// mappedOldPointsNew.map(oldPointsNew, topoChangeMap->pointMap());
// movePoints(mappedOldPointsNew);
// // Note: using setOldPoints instead of movePoints.
// // HJ, 23/Aug/2015
// setOldPoints(mappedOldPointsNew);
// resetMotion();
// setV0();

View file

@ -110,7 +110,6 @@ public:
typedef fvPatch Patch;
//- Runtime type information
TypeName("fvPatchField");

View file

@ -561,8 +561,6 @@ void GGIInterpolation<MasterPatch, SlavePatch>::findNeighboursBBOctree
{
result[i].transfer(candidateMasterNeighbors[i].shrink());
}
return;
}

View file

@ -34,11 +34,12 @@ Author
#include "BlockMatrixAgglomeration.H"
#include "boolList.H"
#include "tolerancesSwitch.H"
#include "coeffFields.H"
#include "addToRunTimeSelectionTable.H"
#include "BlockGAMGInterfaceField.H"
#include "processorLduInterfaceField.H"
#include "tolerancesSwitch.H"
#include "coarseBlockAmgLevel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -397,14 +398,14 @@ Foam::BlockMatrixAgglomeration<Type>::~BlockMatrixAgglomeration()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::BlockLduMatrix<Type> >
Foam::autoPtr<Foam::BlockAmgLevel<Type> >
Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
if (!coarsen_)
{
FatalErrorIn
(
"autoPtr<amgMatrix> "
"autoPtr<BlockAmgLevel<Type> > "
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Requesting coarse matrix when it cannot be created"
<< abort(FatalError);
@ -434,8 +435,8 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<BlockLduMatrix<Type> > BlockMatrixAgglomeration<Type>::"
"restrictMatrix() const"
"autoPtr<BlockLduMatrix<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "agglomIndex array does not correspond to fine level. " << endl
<< " Size: " << agglomIndex_.size()
<< " number of equations: " << matrix_.lduAddr().size()
@ -609,22 +610,22 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
const_cast<BlockLduMatrix<Type>&>(matrix_).interfaces();
// Set the coarse interfaces and coefficients
lduInterfacePtrsList* coarseInterfacesPtr =
new lduInterfacePtrsList(interfaceSize);
lduInterfacePtrsList& coarseInterfaces = *coarseInterfacesPtr;
lduInterfacePtrsList coarseInterfaces(interfaceSize);
labelListList coarseInterfaceAddr(interfaceSize);
// Add the coarse level
// Set the coarse ldu addressing onto the list
lduPrimitiveMesh* coarseAddrPtr =
autoPtr<lduPrimitiveMesh> coarseAddrPtr
(
new lduPrimitiveMesh
(
nCoarseEqns_,
coarseOwner,
coarseNeighbour,
true
)
);
// Initialise transfer of restrict addressing on the interface
@ -679,7 +680,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
intI,
GAMGInterface::New
(
*coarseAddrPtr,
coarseAddrPtr(),
fineInterface,
fineInterface.interfaceInternalField(agglomIndex_),
fineInterfaceAddr[intI]
@ -702,15 +703,17 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
// Add interfaces
coarseAddrPtr->addInterfaces
(
*coarseInterfacesPtr,
coarseInterfaces,
coarseInterfaceAddr,
matrix_.patchSchedule()
);
// Set the coarse level matrix
BlockLduMatrix<Type>* coarseMatrixPtr =
new BlockLduMatrix<Type>(*coarseAddrPtr);
BlockLduMatrix<Type>& coarseMatrix = *coarseMatrixPtr;
autoPtr<BlockLduMatrix<Type> > coarseMatrixPtr
(
new BlockLduMatrix<Type>(coarseAddrPtr())
);
BlockLduMatrix<Type>& coarseMatrix = coarseMatrixPtr();
typename BlockLduInterfaceFieldPtrsList<Type>::Type&
coarseInterfaceFieldsTransfer =
@ -818,7 +821,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of square type and upper of "
<< "linear type is not implemented"
@ -828,7 +831,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of square type and upper of "
<< "scalar type is not implemented"
@ -839,7 +842,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of linear type not implemented"
<< abort(FatalError);
@ -848,7 +851,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of scalar type not implemented"
<< abort(FatalError);
@ -900,7 +903,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of square type and upper of "
<< "linear type is not implemented"
@ -910,7 +913,7 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix>"
"autoPtr<BlockAmgLevel<Type> >"
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of square type and upper of "
<< "scalar type is not implemented"
@ -922,8 +925,8 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix> BlockMatrixAgglomeration<Type>::"
"restrictMatrix() const"
"autoPtr<BlockAmgLevel<Type> > "
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of linear type not implemented"
<< abort(FatalError);
}
@ -931,14 +934,25 @@ Foam::BlockMatrixAgglomeration<Type>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<amgMatrix> BlockMatrixAgglomeration<Type>::"
"restrictMatrix() const"
"autoPtr<BlockAmgLevel<Type> > "
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Matrix diagonal of scalar type not implemented"
<< abort(FatalError);
}
}
return autoPtr<BlockLduMatrix<Type> >(coarseMatrixPtr);
return autoPtr<BlockAmgLevel<Type> >
(
new coarseBlockAmgLevel<Type>
(
coarseAddrPtr,
coarseMatrixPtr,
this->dict(),
this->type(),
this->groupSize(),
this->minCoarseEqns()
)
);
}

View file

@ -138,7 +138,7 @@ public:
}
//- Restrict matrix
virtual autoPtr<BlockLduMatrix<Type> > restrictMatrix() const;
virtual autoPtr<BlockAmgLevel<Type> > restrictMatrix() const;
//- Restrict residual
virtual void restrictResidual

View file

@ -31,7 +31,8 @@ Class
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::BlockMatrixCoarsening<Type> > Foam::BlockMatrixCoarsening<Type>::New
Foam::autoPtr<Foam::BlockMatrixCoarsening<Type> >
Foam::BlockMatrixCoarsening<Type>::New
(
const word& coarseningType,
const BlockLduMatrix<Type>& matrix,
@ -47,7 +48,8 @@ Foam::autoPtr<Foam::BlockMatrixCoarsening<Type> > Foam::BlockMatrixCoarsening<Ty
{
FatalErrorIn
(
"autoPtr<BlockMatrixCoarsening<Type> > BlockMatrixCoarsening<Type>::New\n"
"autoPtr<BlockMatrixCoarsening<Type> > "
"BlockMatrixCoarsening<Type>::New\n"
"(\n"
" const word& coarseningType,\n"
" const lduMatrix& matrix,\n"

View file

@ -94,10 +94,6 @@ public:
//- Runtime type information
TypeName("BlockMatrixCoarsening");
// KRJ: 2012-12-15: Replaced by the above function
//- Runtime type information
//virtual const word& type() const = 0;
// Declare run-time constructor selection tables
@ -154,6 +150,12 @@ public:
// Member Functions
//- Return access to dictionary
const dictionary& dict() const
{
return dict_;
}
//- Return group size
label groupSize() const
{
@ -170,7 +172,7 @@ public:
virtual bool coarsen() const = 0;
//- Restrict matrix
virtual autoPtr<BlockLduMatrix<Type> > restrictMatrix
virtual autoPtr<BlockAmgLevel<Type> > restrictMatrix
() const = 0;
//- Restrict residual

View file

@ -25,6 +25,7 @@ License
#include "blockMatrixAgglomerations.H"
#include "blockMatrixCoarsenings.H"
#include "coarseBlockAmgLevel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View file

@ -58,18 +58,18 @@ namespace Foam
//- Restrict matrix
template<>
inline autoPtr<BlockLduMatrix<scalar> >
inline autoPtr<BlockAmgLevel<scalar> >
BlockMatrixAgglomeration<scalar>::restrictMatrix() const
{
FatalErrorIn
(
"autoPtr<BlockLduMatrix<scalar> > "
"autoPtr<BlockAmgLevel<scalar> > "
"BlockMatrixAgglomeration<Type>::restrictMatrix() const"
) << "Function not implemented for Type=scalar. " << endl
<< abort(FatalError);
// Dummy return to keep compiler happy
return autoPtr<BlockLduMatrix<scalar> >(NULL);
return autoPtr<BlockAmgLevel<scalar> >(NULL);
}

View file

@ -52,18 +52,20 @@ namespace Foam
//- Restrict matrix
template<>
inline autoPtr<BlockLduMatrix<tensor> > BlockMatrixAgglomeration<tensor>::restrictMatrix
inline autoPtr<BlockAmgLevel<tensor> >
BlockMatrixAgglomeration<tensor>::restrictMatrix
() const
{
FatalErrorIn
(
"autoPtr<BlockLduMatrix<tensor> > BlockMatrixAgglomeration<Type>::"
"autoPtr<BlockAmgLevel<tensor> > "
"BlockMatrixAgglomeration<Type>::"
"restrictMatrix() const"
) << "Function not implemented for Type=tensor. " << endl
<< abort(FatalError);
// Dummy return to keep compiler happy
return autoPtr<BlockLduMatrix<tensor> >(NULL);
return autoPtr<BlockAmgLevel<tensor> >(NULL);
}

View file

@ -52,19 +52,19 @@ namespace Foam
//- Restrict matrix
template<>
inline autoPtr<BlockLduMatrix<vector> >
inline autoPtr<BlockAmgLevel<vector> >
BlockMatrixAgglomeration<vector>::restrictMatrix
() const
{
FatalErrorIn
(
"autoPtr<BlockLduMatrix<vector> > BlockMatrixAgglomeration<Type>::"
"autoPtr<BlockAmgLevel<vector> > BlockMatrixAgglomeration<Type>::"
"restrictMatrix() const"
) << "Function not implemented for Type=vector. " << endl
<< abort(FatalError);
// Dummy return to keep compiler happy
return autoPtr<BlockLduMatrix<vector> >(NULL);
return autoPtr<BlockAmgLevel<vector> >(NULL);
}

View file

@ -47,14 +47,15 @@ Author
template<class Type>
Foam::coarseBlockAmgLevel<Type>::coarseBlockAmgLevel
(
autoPtr<lduPrimitiveMesh> addrPtr,
autoPtr<BlockLduMatrix<Type> > matrixPtr,
const dictionary& dict,
const word& coarseningType,
const label groupSize,
const label minCoarseEqns,
const word& smootherType
const label minCoarseEqns
)
:
addrPtr_(addrPtr),
matrixPtr_(matrixPtr),
x_(matrixPtr_->diag().size(),pTraits<Type>::zero),
b_(matrixPtr_->diag().size(),pTraits<Type>::zero),
@ -388,23 +389,12 @@ Foam::coarseBlockAmgLevel<Type>::makeNextLevel() const
{
if (coarseningPtr_->coarsen())
{
return autoPtr<Foam::BlockAmgLevel<Type> >
(
new coarseBlockAmgLevel
(
coarseningPtr_->restrictMatrix(),
dict(),
coarseningPtr_->type(),
coarseningPtr_->groupSize(),
coarseningPtr_->minCoarseEqns(),
smootherPtr_->type()
)
);
return coarseningPtr_->restrictMatrix();
}
else
{
// Final level: cannot coarsen
return autoPtr<Foam::BlockAmgLevel<Type> >();
return autoPtr<BlockAmgLevel<Type> >();
}
}

View file

@ -41,6 +41,7 @@ SourceFiles
#include "BlockAmgLevel.H"
#include "BlockLduSmoother.H"
#include "BlockLduMatrix.H"
#include "lduPrimitiveMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -58,6 +59,9 @@ class coarseBlockAmgLevel
{
// Private data
//- Matrix addressing object. This also contains coupling interfaces
autoPtr<lduPrimitiveMesh> addrPtr_;
//- Matrix
autoPtr<BlockLduMatrix<Type> > matrixPtr_;
@ -100,12 +104,12 @@ public:
//- Construct from components
coarseBlockAmgLevel
(
autoPtr<lduPrimitiveMesh> addrPtr,
autoPtr<BlockLduMatrix<Type> > matrixPtr,
const dictionary& dict,
const word& coarseningType,
const label groupSize,
const label minCoarseEqns,
const word& smootherType
const label minCoarseEqns
);

View file

@ -50,8 +50,7 @@ Foam::fineBlockAmgLevel<Type>::fineBlockAmgLevel
const dictionary& dict,
const word& coarseningType,
const label groupSize,
const label minCoarseEqns,
const word& smootherType
const label minCoarseEqns
)
:
matrix_(matrix),
@ -314,18 +313,7 @@ Foam::fineBlockAmgLevel<Type>::makeNextLevel() const
{
if (coarseningPtr_->coarsen())
{
return autoPtr<Foam::BlockAmgLevel<Type> >
(
new coarseBlockAmgLevel<Type>
(
coarseningPtr_->restrictMatrix(),
dict(),
coarseningPtr_->type(),
coarseningPtr_->groupSize(),
coarseningPtr_->minCoarseEqns(),
smootherPtr_->type()
)
);
return coarseningPtr_->restrictMatrix();
}
else
{

View file

@ -108,8 +108,7 @@ public:
const dictionary& dict,
const word& coarseningType,
const label groupSize,
const label minCoarseEqns,
const word& smootherType
const label minCoarseEqns
);

View file

@ -70,8 +70,7 @@ Foam::BlockAmgPrecon<Type>::BlockAmgPrecon
dict,
dict.lookup("coarseningType"),
readLabel(dict.lookup("groupSize")),
readLabel(dict.lookup("minCoarseEqns")),
dict.lookup("smoother")
readLabel(dict.lookup("minCoarseEqns"))
)
)
)

View file

@ -1243,7 +1243,6 @@ void Foam::polyMesh::setOldPoints
const pointField& setPoints
)
{
if(setPoints.size() != allPoints_.size())
{
FatalErrorIn

View file

@ -114,7 +114,7 @@ void Foam::ggiPolyPatch::calcRemoteZoneAddressing() const
if (debug)
{
Pout<< "ggiPolyPatch::calcRemoteZoneAddressing() const for patch "
<< index() << endl;
<< name() << endl;
}
// Once zone addressing is established, visit the opposite side and find

View file

@ -5,7 +5,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude
LIB_LIBS = \
-ldecompositionMethods \
@ -14,4 +14,4 @@ LIB_LIBS = \
-lfiniteVolume \
-llagrangian \
-lmeshTools \
-ledgeMesh \
-ledgeMesh