/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration | Version: 4.0
\\ / A nd | Web: http://www.foam-extend.org
\\/ M anipulation | For copyright notice see file Copyright
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
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.
You should have received a copy of the GNU General Public License
along with foam-extend. If not, see .
\*---------------------------------------------------------------------------*/
#include "tetPointFieldReconstructor.H"
#include "PtrList.H"
#include "tetPolyPatchFields.H"
#include "tetFemMatrices.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
tmp >
tetPointFieldReconstructor::reconstructTetPointField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI]().time().timeName(),
procMeshes_[procI](),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field internalField(mesh_.nPoints());
// Create the patch fields
PtrList > patchFields(mesh_.boundary().size());
forAll (procMeshes_, procI)
{
const GeometricField&
procField = procFields[procI];
// Get processor-to-global addressing for use in rmap
labelList procToGlobalAddr = procAddressing(procI);
// Set the cell values in the reconstructed field
internalField.rmap
(
procField.internalField(),
procToGlobalAddr
);
// Set the boundary patch values in the reconstructed field
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
tetPolyPatchField::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField::null(),
tetPolyPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size(),
procField.boundaryField()[patchI].size()
)
)
);
}
// If the field stores values, do the rmap
if (patchFields[curBPatch].storesFieldData())
{
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
procPatchAddressing
(
procToGlobalAddr,
procI,
patchI
)
);
}
}
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp >
(
new GeometricField
(
IOobject
(
fieldIoObject.name(),
mesh_().time().timeName(),
mesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
template
tmp >
tetPointFieldReconstructor::reconstructElementField
(
const IOobject& fieldIoObject
)
{
// Read the field for all the processors
PtrList > procFields
(
procMeshes_.size()
);
forAll (procMeshes_, procI)
{
procFields.set
(
procI,
new GeometricField
(
IOobject
(
fieldIoObject.name(),
procMeshes_[procI]().time().timeName(),
procMeshes_[procI](),
IOobject::MUST_READ,
IOobject::NO_WRITE
),
procMeshes_[procI]
)
);
}
// Create the internalField
Field internalField(mesh_.nCells());
// Create the patch fields
PtrList > patchFields(mesh_.boundary().size());
forAll (procMeshes_, procI)
{
const GeometricField&
procField = procFields[procI];
// Set the cell values in the reconstructed field
internalField.rmap
(
procField.internalField(),
cellProcAddressing_[procI]
);
// Set the boundary patch values in the reconstructed field
forAll(boundaryProcAddressing_[procI], patchI)
{
// Get patch index of the original patch
const label curBPatch = boundaryProcAddressing_[procI][patchI];
// Get addressing slice for this patch
const labelList::subList cp =
procMeshes_[procI]().boundaryMesh()[patchI].patchSlice
(
faceProcAddressing_[procI]
);
// check if the boundary patch is not a processor patch
if (curBPatch >= 0)
{
if (!patchFields(curBPatch))
{
patchFields.set
(
curBPatch,
elementPatchField::New
(
procField.boundaryField()[patchI],
mesh_.boundary()[curBPatch],
DimensionedField::null(),
tetPolyPatchFieldReconstructor
(
mesh_.boundary()[curBPatch].size(),
procField.boundaryField()[patchI].size()
)
)
);
}
// If the field stores values, do the rmap
if (patchFields[curBPatch].storesFieldData())
{
const label curPatchStart =
mesh_().boundaryMesh()[curBPatch].start();
labelList reverseAddressing(cp.size());
forAll(cp, faceI)
{
// Subtract one to take into account offsets for
// face direction.
reverseAddressing[faceI] = cp[faceI] - 1
- curPatchStart;
}
patchFields[curBPatch].rmap
(
procField.boundaryField()[patchI],
reverseAddressing
);
}
}
}
}
// Now construct and write the field
// setting the internalField and patchFields
return tmp >
(
new GeometricField
(
IOobject
(
fieldIoObject.name(),
mesh_().time().timeName(),
mesh_(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
procFields[0].dimensions(),
internalField,
patchFields
)
);
}
template
void tetPointFieldReconstructor::reconstructTetPointFields
(
const IOobjectList& objects
)
{
word fieldClassName
(
GeometricField::typeName
);
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
for
(
IOobjectList::iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructTetPointField(*fieldIter())().write();
}
Info<< endl;
}
}
template
void tetPointFieldReconstructor::reconstructElementFields
(
const IOobjectList& objects
)
{
word fieldClassName
(
GeometricField::typeName
);
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
for
(
IOobjectList::iterator fieldIter = fields.begin();
fieldIter != fields.end();
++fieldIter
)
{
Info<< " " << fieldIter()->name() << endl;
reconstructElementField(*fieldIter())().write();
}
Info<< endl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //