Skip to content

Commit

Permalink
Bug-fix:
Browse files Browse the repository at this point in the history
 - Correctly handle empty patch types in 2D parallel
 - Bring some changes from branches into sync
  • Loading branch information
smenon committed Jun 29, 2014
1 parent 44b4804 commit 078079c
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 18 deletions.
114 changes: 96 additions & 18 deletions dynamicTopoFvMesh/fieldMapping/topoMapper.C
Expand Up @@ -40,7 +40,6 @@ Author
#include "topoCellMapper.H"
#include "topoSurfaceMapper.H"
#include "topoBoundaryMeshMapper.H"
#include "fixedValueFvPatchFields.H"

namespace Foam
{
Expand All @@ -65,6 +64,10 @@ void topoMapper::storeGradients() const
//- Store geometric information
void topoMapper::storeGeometry() const
{
typedef volVectorField::PatchFieldType PatchFieldType;
typedef volVectorField::GeometricBoundaryField GeomBdyFieldType;
typedef volVectorField::DimensionedInternalField DimInternalField;

// Wipe out existing information
deleteDemandDrivenData(cellCentresPtr_);

Expand All @@ -75,26 +78,41 @@ void topoMapper::storeGeometry() const
label nPatches = mesh_.boundary().size();

// Create field parts
PtrList<fvPatchField<vector> > volCentrePatches(nPatches);
PtrList<PatchFieldType> volCentrePatches(nPatches);

// Define patch type names
word emptyType("empty");
word fixedValueType("fixedValue");

// Over-ride and set all patches to fixedValue
for (label patchI = 0; patchI < nPatches; patchI++)
// Create dummy types for initial field creation
forAll(volCentrePatches, patchI)
{
volCentrePatches.set
(
patchI,
new fixedValueFvPatchField<vector>
if (mesh_.boundary()[patchI].type() == emptyType)
{
volCentrePatches.set
(
mesh_.boundary()[patchI],
DimensionedField<vector, volMesh>::null()
)
);

// Slice field to patch (forced assignment)
volCentrePatches[patchI] ==
(
mesh_.boundaryMesh()[patchI].patchSlice(Cf)
);
patchI,
PatchFieldType::New
(
emptyType,
mesh_.boundary()[patchI],
DimInternalField::null()
)
);
}
else
{
volCentrePatches.set
(
patchI,
PatchFieldType::New
(
fixedValueType,
mesh_.boundary()[patchI],
DimInternalField::null()
)
);
}
}

// Set the cell-centres pointer.
Expand All @@ -117,6 +135,48 @@ void topoMapper::storeGeometry() const
volCentrePatches
)
);

// Alias for convenience
volVectorField& centres = *cellCentresPtr_;

// Set correct references for patch internal fields
GeomBdyFieldType& bf = centres.boundaryField();

forAll(bf, patchI)
{
if (mesh_.boundary()[patchI].type() == emptyType)
{
bf.set
(
patchI,
PatchFieldType::New
(
emptyType,
mesh_.boundary()[patchI],
centres.dimensionedInternalField()
)
);
}
else
{
bf.set
(
patchI,
PatchFieldType::New
(
fixedValueType,
mesh_.boundary()[patchI],
centres.dimensionedInternalField()
)
);

// Slice field to patch (forced assignment)
bf[patchI] == mesh_.boundaryMesh()[patchI].patchSlice(Cf);
}
}

// Set the cell-volumes pointer
cellVolumesPtr_ = new scalarField(mesh_.cellVolumes());
}

// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Expand All @@ -134,6 +194,7 @@ topoMapper::topoMapper
surfaceMap_(NULL),
boundaryMap_(NULL),
fluxCorrector_(fluxCorrector::New(mesh, dict)),
cellVolumesPtr_(NULL),
cellCentresPtr_(NULL)
{}

Expand Down Expand Up @@ -341,6 +402,22 @@ const vectorField& topoMapper::internalCentres() const
}


//- Return non-const access to cell volumes
scalarField& topoMapper::internalVolumes() const
{
if (!cellVolumesPtr_)
{
FatalErrorIn
(
"scalarField& topoMapper::internalVolumes() const"
) << nl << " Pointer has not been set. "
<< abort(FatalError);
}

return *cellVolumesPtr_;
}


//- Return stored patch centre information
const vectorField& topoMapper::patchCentres(const label i) const
{
Expand Down Expand Up @@ -519,6 +596,7 @@ void topoMapper::clear() const
vGradPtrs_.clear();

// Wipe out geomtry information
deleteDemandDrivenData(cellVolumesPtr_);
deleteDemandDrivenData(cellCentresPtr_);

// Clear maps
Expand Down
4 changes: 4 additions & 0 deletions dynamicTopoFvMesh/fieldMapping/topoMapper.H
Expand Up @@ -100,6 +100,7 @@ class topoMapper
mutable PtrList<volTensorField> vGradPtrs_;

//- Geometric information on the old mesh
mutable scalarField* cellVolumesPtr_;
mutable volVectorField* cellCentresPtr_;

//- Intersection weights
Expand Down Expand Up @@ -228,6 +229,9 @@ public:
//- Return non-const access to cell centres
volVectorField& volCentres() const;

//- Return non-const access to cell volumes
scalarField& internalVolumes() const;

//- Return stored cell centre information
const vectorField& internalCentres() const;

Expand Down

0 comments on commit 078079c

Please sign in to comment.