This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/applications/solvers/solidMechanics/elasticPlasticNonLinULSolidFoam/calculatePointBoundaryWeights.H

122 lines
3.4 KiB
C
Raw Normal View History

2012-09-11 15:42:55 +00:00
//void volPointInterpolation::makeBoundaryWeights() const
//{
// const labelList& ptc = boundaryPoints();
// Calculate the correction vectors and weighting factors
//pointBoundaryWeightsPtr_ = new FieldField<Field, scalar>(ptc.size());
//FieldField<Field, scalar>& w = *pointBoundaryWeightsPtr_;
FieldField<Field, scalar> w(ptc.size());
{
const labelListList& pf = mesh.pointFaces();
2012-09-11 15:42:55 +00:00
const volVectorField& centres = mesh.C();
2012-09-11 15:42:55 +00:00
const fvBoundaryMesh& bm = mesh.boundary();
pointScalarField volPointSumWeights
2012-09-11 15:42:55 +00:00
(
IOobject
(
"volPointSumWeights",
mesh.polyMesh::instance(),
mesh
),
pMesh,
dimensionedScalar("zero", dimless, 0)
);
forAll (ptc, pointI)
2012-09-11 15:42:55 +00:00
{
const label curPoint = ptc[pointI];
const labelList& curFaces = pf[curPoint];
//w.hook(new scalarField(curFaces.size())); //philipc no hook function
w.set
(
pointI,
new scalarField(curFaces.size())
);
scalarField& curWeights = w[pointI];
label nFacesAroundPoint = 0;
const vector& pointLoc = mesh.points()[curPoint];
// Go through all the faces
forAll (curFaces, faceI)
{
if (!mesh.isInternalFace(curFaces[faceI]))
{
// This is a boundary face. If not in the empty patch
// or coupled calculate the extrapolation vector
label patchID =
mesh.boundaryMesh().whichPatch(curFaces[faceI]);
if
(
!isA<emptyFvPatch>(bm[patchID])
&& !(
bm[patchID].coupled()
//&& Pstream::parRun()
//&& !mesh.parallelData().cyclicParallel()
)
)
{
curWeights[nFacesAroundPoint] =
1.0/mag
(
pointLoc
- centres.boundaryField()[patchID]
[
bm[patchID].patch().whichFace(curFaces[faceI])
]
);
nFacesAroundPoint++;
}
}
}
// Reset the sizes of the local weights
curWeights.setSize(nFacesAroundPoint);
// Collect the sum of weights for parallel correction
volPointSumWeights[curPoint] += sum(curWeights);
}
// Do parallel correction of weights
// Update coupled boundaries
// Work-around for cyclic parallels.
/*if (Pstream::parRun() && !mesh.parallelData().cyclicParallel())
{
forAll (volPointSumWeights.boundaryField(), patchI)
{
if (volPointSumWeights.boundaryField()[patchI].coupled())
{
volPointSumWeights.boundaryField()[patchI].initAddField();
}
}
forAll (volPointSumWeights.boundaryField(), patchI)
{
if (volPointSumWeights.boundaryField()[patchI].coupled())
{
volPointSumWeights.boundaryField()[patchI].addField
(
volPointSumWeights.internalField()
);
}
}
}*/
// Re-scale the weights for the current point
forAll (ptc, pointI)
2012-09-11 15:42:55 +00:00
{
w[pointI] /= volPointSumWeights[ptc[pointI]];
2012-09-11 15:42:55 +00:00
}
}