Skip to content
Snippets Groups Projects
Commit f8ca65a4 authored by mattijs's avatar mattijs Committed by sergio
Browse files

ENH: assemblyFaceAreaPair: revert to faceAreaPair. Fixes #2

parent df0300e5
No related branches found
No related tags found
No related merge requests found
...@@ -27,7 +27,7 @@ License ...@@ -27,7 +27,7 @@ License
#include "lduMatrix.H" #include "lduMatrix.H"
#include "addToRunTimeSelectionTable.H" #include "addToRunTimeSelectionTable.H"
#include "lduPrimitiveMeshAssembly.H" #include "lduPrimitiveMeshAssembly.H"
#include "fvMatrix.H" #include "surfaceFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
...@@ -55,10 +55,7 @@ namespace Foam ...@@ -55,10 +55,7 @@ namespace Foam
Foam::assemblyFaceAreaPairGAMGAgglomeration:: Foam::assemblyFaceAreaPairGAMGAgglomeration::
~assemblyFaceAreaPairGAMGAgglomeration() ~assemblyFaceAreaPairGAMGAgglomeration()
{ {}
deleteDemandDrivenData(faceAreasPtr_);
deleteDemandDrivenData(cellVolumesPtr_);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
...@@ -69,123 +66,134 @@ assemblyFaceAreaPairGAMGAgglomeration ...@@ -69,123 +66,134 @@ assemblyFaceAreaPairGAMGAgglomeration
const dictionary& controlDict const dictionary& controlDict
) )
: :
pairGAMGAgglomeration(matrix.mesh(), controlDict), pairGAMGAgglomeration(matrix.mesh(), controlDict)
faceAreasPtr_(nullptr),
cellVolumesPtr_(nullptr)
{ {
const lduMesh& ldumesh = matrix.mesh(); const lduMesh& ldumesh = matrix.mesh();
if (!isA<lduPrimitiveMeshAssembly>(ldumesh)) if (isA<lduPrimitiveMeshAssembly>(ldumesh))
{ {
FatalErrorInFunction const lduPrimitiveMeshAssembly& mesh =
<< "assemblyFaceAreaPairGAMGAgglomeration requested but " refCast<const lduPrimitiveMeshAssembly>(ldumesh);
<< " lduMesh is not lduPrimitiveMeshAssembly." << nl
<< " Change agglomerator type to faceAreaPair "
<< abort(FatalError);
}
const lduPrimitiveMeshAssembly& mesh =
refCast<const lduPrimitiveMeshAssembly>(ldumesh);
faceAreasPtr_ = new vectorField(mesh.lduAddr().upperAddr().size(), Zero);
vectorField& faceAreas = *faceAreasPtr_;
cellVolumesPtr_ = new scalarField(mesh.lduAddr().size(), Zero); vectorField faceAreas(mesh.lduAddr().upperAddr().size(), Zero);
scalarField& cellVolumes = *cellVolumesPtr_; //scalarField cellVolumes(mesh.lduAddr().size(), Zero);
const labelListList& faceMap = mesh.faceMap(); const labelListList& faceMap = mesh.faceMap();
for (label i=0; i < mesh.meshes().size(); ++i) for (label i=0; i < mesh.meshes().size(); ++i)
{
const fvMesh& m = refCast<const fvMesh>(mesh.meshes()[i]);
const labelList& subFaceMap = faceMap[i];
const vectorField& areas = m.Sf();
forAll(subFaceMap, facei)
{ {
faceAreas[subFaceMap[facei]] = areas[facei]; const fvMesh& m = refCast<const fvMesh>(mesh.meshes()[i]);
} const labelList& subFaceMap = faceMap[i];
const vectorField& areas = m.Sf().internalField();
const polyBoundaryMesh& patches = m.boundaryMesh(); forAll(subFaceMap, facei)
{
faceAreas[subFaceMap[facei]] = areas[facei];
}
// Fill faceAreas for new faces const polyBoundaryMesh& patches = m.boundaryMesh();
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
label globalPatchID = mesh.patchMap()[i][patchI];
if (globalPatchID == -1) // Fill faceAreas for new faces
forAll(patches, patchI)
{ {
//const lduInterface& inter = m.interfaces()[patchI]; const polyPatch& pp = patches[patchI];
label globalPatchID = mesh.patchMap()[i][patchI];
if (pp.masterImplicit()) if (globalPatchID == -1)
{ {
const vectorField& sf = m.boundary()[patchI].Sf(); //const lduInterface& inter = m.interfaces()[patchI];
if (isA<cyclicAMIPolyPatch>(pp)) if (pp.masterImplicit())
{ {
const cyclicAMIPolyPatch& mpp = const vectorField& sf = m.boundary()[patchI].Sf();
refCast<const cyclicAMIPolyPatch>(patches[patchI]);
const scalarListList& srcWeight = mpp.AMI().srcWeights();
label subFaceI = 0; if (isA<cyclicAMIPolyPatch>(pp))
forAll(pp.faceCells(), faceI)
{ {
const scalarList& w = srcWeight[faceI]; const cyclicAMIPolyPatch& mpp =
refCast<const cyclicAMIPolyPatch>(pp);
const scalarListList& srcWeight =
mpp.AMI().srcWeights();
for(label j=0; j<w.size(); j++) label subFaceI = 0;
forAll(pp.faceCells(), faceI)
{ {
const label globalFaceI = const scalarList& w = srcWeight[faceI];
mesh.faceBoundMap()[i][patchI][subFaceI];
if (globalFaceI != -1) for(label j=0; j<w.size(); j++)
{ {
faceAreas[globalFaceI] = w[j]*sf[faceI]; const label globalFaceI =
mesh.faceBoundMap()[i][patchI][subFaceI];
if (globalFaceI != -1)
{
faceAreas[globalFaceI] = w[j]*sf[faceI];
}
subFaceI++;
} }
subFaceI++;
} }
} }
} else
else
{
forAll(pp.faceCells(), faceI)
{ {
const label globalFaceI = forAll(pp.faceCells(), faceI)
mesh.faceBoundMap()[i][patchI][faceI];
if (globalFaceI != -1)
{ {
faceAreas[globalFaceI] = sf[faceI]; const label globalFaceI =
mesh.faceBoundMap()[i][patchI][faceI];
if (globalFaceI != -1)
{
faceAreas[globalFaceI] = sf[faceI];
}
} }
} }
} }
} }
} }
}
// Fill cellVolumes
const scalarField& vol = m.V();
const label cellOffset = mesh.cellOffsets()[i];
forAll(vol, cellI) //// Fill cellVolumes
{ //const scalarField& vol = m.V();
cellVolumes[cellOffset + cellI] = vol[cellI]; //const label cellOffset = mesh.cellOffsets()[i];
//
//forAll(vol, cellI)
//{
// cellVolumes[cellOffset + cellI] = vol[cellI];
//}
} }
agglomerate
(
mesh,
mag
(
cmptMultiply
(
faceAreas/sqrt(mag(faceAreas)),
vector(1, 1.01, 1.02)
)
)
);
} }
else
{
// Revert to faceAreaPairGAMGAgglomeration
const fvMesh& fvmesh = refCast<const fvMesh>(matrix.mesh());
agglomerate agglomerate
(
mesh,
mag
( (
cmptMultiply matrix.mesh(),
mag
( (
*faceAreasPtr_/sqrt(mag(*faceAreasPtr_)), cmptMultiply
vector(1, 1.01, 1.02) (
fvmesh.Sf().primitiveField()
/sqrt(fvmesh.magSf().primitiveField()),
vector(1, 1.01, 1.02)
//vector::one
)
) )
) );
); }
} }
......
...@@ -50,14 +50,6 @@ class assemblyFaceAreaPairGAMGAgglomeration ...@@ -50,14 +50,6 @@ class assemblyFaceAreaPairGAMGAgglomeration
: :
public pairGAMGAgglomeration public pairGAMGAgglomeration
{ {
private:
//- Face areas of the assembled mesh
vectorField* faceAreasPtr_;
//- Cell volumes of the assembled mesh
scalarField* cellVolumesPtr_;
public: public:
//- Runtime type information //- Runtime type information
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment