2010-05-12 13:27:55 +00:00
|
|
|
/*---------------------------------------------------------------------------*\
|
|
|
|
========= |
|
2013-12-11 16:09:41 +00:00
|
|
|
\\ / F ield | foam-extend: Open Source CFD
|
2015-05-17 13:32:07 +00:00
|
|
|
\\ / O peration | Version: 3.2
|
|
|
|
\\ / A nd | Web: http://www.foam-extend.org
|
|
|
|
\\/ M anipulation | For copyright notice see file Copyright
|
2010-05-12 13:27:55 +00:00
|
|
|
-------------------------------------------------------------------------------
|
|
|
|
License
|
2013-12-11 16:09:41 +00:00
|
|
|
This file is part of foam-extend.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
foam-extend is free software: you can redistribute it and/or modify it
|
2010-05-12 13:27:55 +00:00
|
|
|
under the terms of the GNU General Public License as published by the
|
2013-12-11 16:09:41 +00:00
|
|
|
Free Software Foundation, either version 3 of the License, or (at your
|
2010-05-12 13:27:55 +00:00
|
|
|
option) any later version.
|
|
|
|
|
2013-12-11 16:09:41 +00:00
|
|
|
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.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
2013-12-11 16:09:41 +00:00
|
|
|
along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
\*---------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "freeSurface.H"
|
|
|
|
#include "primitivePatchInterpolation.H"
|
|
|
|
#include "emptyFaPatch.H"
|
2010-12-21 10:44:28 +00:00
|
|
|
#include "wedgeFaPatch.H"
|
|
|
|
#include "PstreamCombineReduceOps.H"
|
|
|
|
#include "coordinateSystem.H"
|
|
|
|
#include "scalarMatrices.H"
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
namespace Foam
|
|
|
|
{
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
|
|
|
|
|
|
|
|
|
|
|
tmp<vectorField> freeSurface::pointDisplacement(const scalarField& deltaH)
|
|
|
|
{
|
|
|
|
const pointField& points = aMesh().patch().localPoints();
|
|
|
|
const labelListList& pointFaces = aMesh().patch().pointFaces();
|
|
|
|
|
|
|
|
controlPoints() += facesDisplacementDir()*deltaH;
|
|
|
|
|
|
|
|
tmp<vectorField> tdisplacement
|
|
|
|
(
|
|
|
|
new vectorField
|
|
|
|
(
|
|
|
|
points.size(),
|
|
|
|
vector::zero
|
|
|
|
)
|
|
|
|
);
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
vectorField& displacement = tdisplacement();
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate displacement of internal points
|
2010-12-21 10:44:28 +00:00
|
|
|
const vectorField& pointNormals = aMesh().pointAreaNormals();
|
2010-05-12 13:27:55 +00:00
|
|
|
const edgeList& edges = aMesh().patch().edges();
|
|
|
|
labelList internalPoints = aMesh().internalPoints();
|
|
|
|
|
|
|
|
forAll (internalPoints, pointI)
|
|
|
|
{
|
|
|
|
label curPoint = internalPoints[pointI];
|
|
|
|
|
|
|
|
const labelList& curPointFaces = pointFaces[curPoint];
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vectorField lsPoints(curPointFaces.size(), vector::zero);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
for (label i=0; i<curPointFaces.size(); i++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label curFace = curPointFaces[i];
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPoints[i] = controlPoints()[curFace];
|
|
|
|
}
|
2013-07-18 01:02:34 +00:00
|
|
|
|
|
|
|
vectorField pointAndNormal =
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPlanePointAndNormal
|
2010-05-12 13:27:55 +00:00
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
lsPoints,
|
|
|
|
points[curPoint],
|
2010-12-21 10:44:28 +00:00
|
|
|
pointNormals[curPoint]
|
2010-05-12 13:27:55 +00:00
|
|
|
);
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vector& P = pointAndNormal[0];
|
|
|
|
vector& N = pointAndNormal[1];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
displacement[curPoint] =
|
2010-12-21 10:44:28 +00:00
|
|
|
pointsDisplacementDir()[curPoint]
|
|
|
|
*((P - points[curPoint])&N)
|
|
|
|
/(pointsDisplacementDir()[curPoint]&N);
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
// Mirror control points
|
|
|
|
FieldField<Field, vector> patchMirrorPoints(aMesh().boundary().size());
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
forAll(patchMirrorPoints, patchI)
|
|
|
|
{
|
|
|
|
patchMirrorPoints.set
|
|
|
|
(
|
|
|
|
patchI,
|
|
|
|
new vectorField
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
aMesh().boundary()[patchI].faPatch::size(),
|
2010-12-21 10:44:28 +00:00
|
|
|
vector::zero
|
|
|
|
)
|
|
|
|
);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
vectorField N =
|
2010-12-21 10:44:28 +00:00
|
|
|
aMesh().boundary()[patchI].ngbPolyPatchFaceNormals();
|
2013-07-18 01:02:34 +00:00
|
|
|
|
|
|
|
const labelList peFaces =
|
2010-12-21 10:44:28 +00:00
|
|
|
labelList::subList
|
|
|
|
(
|
|
|
|
aMesh().edgeOwner(),
|
|
|
|
aMesh().boundary()[patchI].faPatch::size(),
|
|
|
|
aMesh().boundary()[patchI].start()
|
|
|
|
);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
const labelList& pEdges = aMesh().boundary()[patchI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vectorField peCentres(pEdges.size(), vector::zero);
|
|
|
|
forAll(peCentres, edgeI)
|
|
|
|
{
|
2013-07-18 01:02:34 +00:00
|
|
|
peCentres[edgeI] =
|
2010-12-21 10:44:28 +00:00
|
|
|
edges[pEdges[edgeI]].centre(points);
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vectorField delta =
|
|
|
|
vectorField(controlPoints(), peFaces)
|
|
|
|
- peCentres;
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
patchMirrorPoints[patchI] =
|
2010-12-21 10:44:28 +00:00
|
|
|
peCentres + ((I - 2*N*N)&delta);
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
// Calculate displacement of boundary points
|
2010-05-12 13:27:55 +00:00
|
|
|
labelList boundaryPoints = aMesh().boundaryPoints();
|
|
|
|
|
|
|
|
const labelListList& edgeFaces = aMesh().patch().edgeFaces();
|
|
|
|
const labelListList& pointEdges = aMesh().patch().pointEdges();
|
|
|
|
|
|
|
|
forAll (boundaryPoints, pointI)
|
|
|
|
{
|
|
|
|
label curPoint = boundaryPoints[pointI];
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
if (motionPointsMask()[curPoint] == 1)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
|
|
|
// Calculating mirror points
|
|
|
|
const labelList& curPointEdges = pointEdges[curPoint];
|
|
|
|
|
|
|
|
vectorField mirrorPoints(2, vector::zero);
|
|
|
|
|
|
|
|
label counter = -1;
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
forAll (curPointEdges, edgeI)
|
|
|
|
{
|
|
|
|
label curEdge = curPointEdges[edgeI];
|
2010-12-21 10:44:28 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
if(edgeFaces[curEdge].size() == 1)
|
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label patchID = -1;
|
|
|
|
label edgeID = -1;
|
|
|
|
forAll(aMesh().boundary(), patchI)
|
|
|
|
{
|
|
|
|
const labelList& pEdges =
|
|
|
|
aMesh().boundary()[patchI];
|
|
|
|
label index = findIndex(pEdges, curEdge);
|
|
|
|
if (index != -1)
|
|
|
|
{
|
|
|
|
patchID = patchI;
|
|
|
|
edgeID = index;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
mirrorPoints[++counter] =
|
2010-12-21 10:44:28 +00:00
|
|
|
patchMirrorPoints[patchID][edgeID];
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
// Calculating LS plane fit
|
2010-05-12 13:27:55 +00:00
|
|
|
const labelList& curPointFaces = pointFaces[curPoint];
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vectorField lsPoints
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
curPointFaces.size() + mirrorPoints.size(),
|
2010-12-21 10:44:28 +00:00
|
|
|
vector::zero
|
|
|
|
);
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
counter = -1;
|
|
|
|
|
|
|
|
for (label i=0; i<curPointFaces.size(); i++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label curFace = curPointFaces[i];
|
|
|
|
|
|
|
|
lsPoints[++counter] = controlPoints()[curFace];
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
for (label i=0; i<mirrorPoints.size(); i++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPoints[++counter] = mirrorPoints[i];
|
|
|
|
}
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
vectorField pointAndNormal =
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPlanePointAndNormal
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
lsPoints,
|
|
|
|
points[curPoint],
|
2010-12-21 10:44:28 +00:00
|
|
|
pointNormals[curPoint]
|
|
|
|
);
|
|
|
|
|
|
|
|
vector& P = pointAndNormal[0];
|
|
|
|
vector& N = pointAndNormal[1];
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
displacement[curPoint] =
|
2010-12-21 10:44:28 +00:00
|
|
|
pointsDisplacementDir()[curPoint]
|
|
|
|
*((P - points[curPoint])&N)
|
|
|
|
/(pointsDisplacementDir()[curPoint]&N);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate displacement of axis point
|
|
|
|
forAll (aMesh().boundary(), patchI)
|
|
|
|
{
|
|
|
|
if
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
aMesh().boundary()[patchI].type()
|
2010-12-21 10:44:28 +00:00
|
|
|
== wedgeFaPatch::typeName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const wedgeFaPatch& wedgePatch =
|
|
|
|
refCast<const wedgeFaPatch>(aMesh().boundary()[patchI]);
|
|
|
|
|
|
|
|
if(wedgePatch.axisPoint() > -1)
|
|
|
|
{
|
|
|
|
label axisPoint = wedgePatch.axisPoint();
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
displacement[axisPoint] =
|
|
|
|
pointsDisplacementDir()[axisPoint]
|
|
|
|
*(
|
|
|
|
pointsDisplacementDir()[axisPoint]
|
|
|
|
&(
|
|
|
|
controlPoints()[pointFaces[axisPoint][0]]
|
|
|
|
- points[axisPoint]
|
|
|
|
)
|
2010-05-12 13:27:55 +00:00
|
|
|
);
|
|
|
|
}
|
2010-12-21 10:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
// Calculate displacement of processor patch points
|
|
|
|
forAll (aMesh().boundary(), patchI)
|
|
|
|
{
|
|
|
|
if
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
aMesh().boundary()[patchI].type()
|
2010-12-21 10:44:28 +00:00
|
|
|
== processorFaPatch::typeName
|
|
|
|
)
|
|
|
|
{
|
|
|
|
const processorFaPatch& procPatch =
|
|
|
|
refCast<const processorFaPatch>(aMesh().boundary()[patchI]);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
const labelList& patchPointLabels =
|
|
|
|
procPatch.pointLabels();
|
|
|
|
|
|
|
|
FieldField<Field, vector> lsPoints(patchPointLabels.size());
|
|
|
|
forAll(lsPoints, pointI)
|
|
|
|
{
|
|
|
|
lsPoints.set(pointI, new vectorField(0, vector::zero));
|
|
|
|
}
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
const labelList& nonGlobalPatchPoints =
|
2010-12-21 10:44:28 +00:00
|
|
|
procPatch.nonGlobalPatchPoints();
|
|
|
|
|
|
|
|
forAll(nonGlobalPatchPoints, pointI)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label curPatchPoint =
|
|
|
|
nonGlobalPatchPoints[pointI];
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
label curPoint =
|
2010-12-21 10:44:28 +00:00
|
|
|
patchPointLabels[curPatchPoint];
|
|
|
|
|
|
|
|
const labelList& curPointFaces = pointFaces[curPoint];
|
|
|
|
|
|
|
|
lsPoints[curPatchPoint].setSize(curPointFaces.size());
|
|
|
|
|
|
|
|
forAll(curPointFaces, faceI)
|
|
|
|
{
|
|
|
|
label curFace = curPointFaces[faceI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPoints[curPatchPoint][faceI] = controlPoints()[curFace];
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
# include "boundaryProcessorFaPatchPoints.H"
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
scalar lsPointsSize = 0;
|
|
|
|
forAll(lsPoints, pointI)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPointsSize +=
|
|
|
|
2*lsPoints[pointI].size()*sizeof(vector);
|
|
|
|
}
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
// Parallel data exchange
|
|
|
|
{
|
|
|
|
OPstream toNeighbProc
|
|
|
|
(
|
|
|
|
Pstream::blocking,
|
2013-07-18 01:02:34 +00:00
|
|
|
procPatch.neighbProcNo(),
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPointsSize
|
|
|
|
);
|
|
|
|
|
|
|
|
toNeighbProc << lsPoints;
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
FieldField<Field, vector> ngbLsPoints(patchPointLabels.size());
|
|
|
|
|
|
|
|
{
|
|
|
|
IPstream fromNeighbProc
|
|
|
|
(
|
|
|
|
Pstream::blocking,
|
|
|
|
procPatch.neighbProcNo(),
|
|
|
|
lsPointsSize
|
|
|
|
);
|
|
|
|
|
|
|
|
fromNeighbProc >> ngbLsPoints;
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
forAll(nonGlobalPatchPoints, pointI)
|
|
|
|
{
|
2011-02-27 02:17:59 +00:00
|
|
|
label curPatchPoint =
|
2010-12-21 10:44:28 +00:00
|
|
|
nonGlobalPatchPoints[pointI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2011-02-27 02:17:59 +00:00
|
|
|
label curPoint =
|
2010-12-21 10:44:28 +00:00
|
|
|
patchPointLabels[curPatchPoint];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
label curNgbPoint = procPatch.neighbPoints()[curPatchPoint];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
vectorField allLsPoints
|
|
|
|
(
|
|
|
|
lsPoints[curPatchPoint].size()
|
|
|
|
+ ngbLsPoints[curNgbPoint].size(),
|
|
|
|
vector::zero
|
|
|
|
);
|
2011-02-27 02:17:59 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
label counter = -1;
|
|
|
|
forAll(lsPoints[curPatchPoint], pointI)
|
|
|
|
{
|
|
|
|
allLsPoints[++counter] = lsPoints[curPatchPoint][pointI];
|
|
|
|
}
|
|
|
|
forAll(ngbLsPoints[curNgbPoint], pointI)
|
|
|
|
{
|
|
|
|
allLsPoints[++counter] = ngbLsPoints[curNgbPoint][pointI];
|
|
|
|
}
|
|
|
|
|
2011-02-27 02:17:59 +00:00
|
|
|
vectorField pointAndNormal =
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPlanePointAndNormal
|
|
|
|
(
|
2011-02-27 02:17:59 +00:00
|
|
|
allLsPoints,
|
|
|
|
points[curPoint],
|
2010-12-21 10:44:28 +00:00
|
|
|
pointNormals[curPoint]
|
|
|
|
);
|
|
|
|
|
|
|
|
vector& P = pointAndNormal[0];
|
|
|
|
vector& N = pointAndNormal[1];
|
2011-02-27 02:17:59 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
if (motionPointsMask()[curPoint] != 0)
|
|
|
|
{
|
2011-02-27 02:17:59 +00:00
|
|
|
displacement[curPoint] =
|
2010-12-21 10:44:28 +00:00
|
|
|
pointsDisplacementDir()[curPoint]
|
|
|
|
*((P - points[curPoint])&N)
|
|
|
|
/(pointsDisplacementDir()[curPoint]&N);
|
|
|
|
}
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
|
|
|
|
// Calculate displacement of global processor patch points
|
|
|
|
if (aMesh().globalData().nGlobalPoints() > 0)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
const labelList& spLabels =
|
|
|
|
aMesh().globalData().sharedPointLabels();
|
|
|
|
|
|
|
|
const labelList& addr = aMesh().globalData().sharedPointAddr();
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
for (label k=0; k<aMesh().globalData().nGlobalPoints(); k++)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
List<List<vector> > procLsPoints(Pstream::nProcs());
|
|
|
|
|
|
|
|
label curSharedPointIndex = findIndex(addr, k);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
if (curSharedPointIndex != -1)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label curPoint = spLabels[curSharedPointIndex];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
const labelList& curPointFaces = pointFaces[curPoint];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
procLsPoints[Pstream::myProcNo()] =
|
2010-12-21 10:44:28 +00:00
|
|
|
List<vector>(curPointFaces.size());
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
forAll (curPointFaces, faceI)
|
|
|
|
{
|
|
|
|
label curFace = curPointFaces[faceI];
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
procLsPoints[Pstream::myProcNo()][faceI] =
|
2010-12-21 10:44:28 +00:00
|
|
|
controlPoints()[curFace];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Pstream::gatherList(procLsPoints);
|
|
|
|
Pstream::scatterList(procLsPoints);
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
if (curSharedPointIndex != -1)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
label curPoint = spLabels[curSharedPointIndex];
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
label nAllPoints = 0;
|
|
|
|
forAll(procLsPoints, procI)
|
2010-05-12 13:27:55 +00:00
|
|
|
{
|
2010-12-21 10:44:28 +00:00
|
|
|
nAllPoints += procLsPoints[procI].size();
|
|
|
|
}
|
|
|
|
|
|
|
|
vectorField allPoints(nAllPoints, vector::zero);
|
2010-05-12 13:27:55 +00:00
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
label counter = 0;
|
|
|
|
forAll(procLsPoints, procI)
|
|
|
|
{
|
|
|
|
forAll(procLsPoints[procI], pointI)
|
|
|
|
{
|
|
|
|
allPoints[counter++] =
|
|
|
|
procLsPoints[procI][pointI];
|
|
|
|
}
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
vectorField pointAndNormal =
|
2010-12-21 10:44:28 +00:00
|
|
|
lsPlanePointAndNormal
|
|
|
|
(
|
2013-07-18 01:02:34 +00:00
|
|
|
allPoints,
|
|
|
|
points[curPoint],
|
2010-12-21 10:44:28 +00:00
|
|
|
pointNormals[curPoint]
|
|
|
|
);
|
|
|
|
|
|
|
|
const vector& P = pointAndNormal[0];
|
|
|
|
const vector& N = pointAndNormal[1];
|
|
|
|
|
2013-07-18 01:02:34 +00:00
|
|
|
displacement[curPoint] =
|
2010-12-21 10:44:28 +00:00
|
|
|
pointsDisplacementDir()[curPoint]
|
|
|
|
*((P - points[curPoint])&N)
|
|
|
|
/(pointsDisplacementDir()[curPoint]&N);
|
2010-05-12 13:27:55 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return tdisplacement;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-21 10:44:28 +00:00
|
|
|
tmp<vectorField> freeSurface::lsPlanePointAndNormal
|
|
|
|
(
|
|
|
|
const vectorField& points,
|
|
|
|
const vector& origin,
|
|
|
|
const vector& axis
|
|
|
|
) const
|
|
|
|
{
|
|
|
|
// LS in local CS
|
|
|
|
vector dir = (points[0] - origin);
|
|
|
|
dir -= axis*(axis&dir);
|
|
|
|
dir /= mag(dir);
|
|
|
|
coordinateSystem cs("cs", origin, axis, dir);
|
|
|
|
|
|
|
|
vectorField localPoints = cs.localPosition(points);
|
|
|
|
scalarField W = 1.0/(mag(points - origin) + SMALL);
|
|
|
|
|
|
|
|
scalarRectangularMatrix M
|
|
|
|
(
|
|
|
|
points.size(),
|
|
|
|
3,
|
|
|
|
0.0
|
|
|
|
);
|
|
|
|
|
|
|
|
for (label i=0; i<localPoints.size(); i++)
|
|
|
|
{
|
|
|
|
M[i][0] = localPoints[i].x();
|
|
|
|
M[i][1] = localPoints[i].y();
|
|
|
|
M[i][2] = 1.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
scalarSquareMatrix MtM(3, 0.0);
|
|
|
|
for (label i = 0; i < MtM.n(); i++)
|
|
|
|
{
|
|
|
|
for (label j = 0; j < MtM.m(); j++)
|
|
|
|
{
|
|
|
|
for (label k = 0; k < M.n(); k++)
|
|
|
|
{
|
|
|
|
MtM[i][j] += M[k][i]*M[k][j]*W[k];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scalarField MtR(3, 0);
|
|
|
|
for (label i = 0; i < MtR.size(); i++)
|
|
|
|
{
|
|
|
|
for (label j = 0; j < M.n(); j++)
|
|
|
|
{
|
|
|
|
MtR[i] += M[j][i]*localPoints[j].z()*W[j];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
scalarSquareMatrix::LUsolve(MtM, MtR);
|
|
|
|
|
|
|
|
vector n0 = vector(-MtR[0], -MtR[1], 1);
|
|
|
|
n0 = cs.globalVector(n0);
|
|
|
|
n0 /= mag(n0);
|
|
|
|
|
|
|
|
vector p0 = vector(0, 0, MtR[2]);
|
|
|
|
p0 = cs.globalPosition(p0);
|
|
|
|
|
|
|
|
tmp<vectorField> pointAndNormal
|
|
|
|
(
|
|
|
|
new vectorField(2, vector::zero)
|
|
|
|
);
|
|
|
|
|
|
|
|
pointAndNormal()[0] = p0;
|
|
|
|
pointAndNormal()[1] = n0;
|
|
|
|
|
|
|
|
return pointAndNormal;
|
|
|
|
}
|
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
|
|
|
|
// tmp<vectorField> freeSurface::pointDisplacementSM()
|
|
|
|
// {
|
|
|
|
// const pointField& points = aMesh().patch().localPoints();
|
|
|
|
// const labelListList& pointFaces = aMesh().patch().pointFaces();
|
|
|
|
|
|
|
|
|
|
|
|
// tmp<vectorField> tdisplacement
|
|
|
|
// (
|
|
|
|
// new vectorField
|
|
|
|
// (
|
|
|
|
// points.size(),
|
|
|
|
// vector::zero
|
|
|
|
// )
|
|
|
|
// );
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
// vectorField& displacement = tdisplacement();
|
|
|
|
|
|
|
|
|
|
|
|
// forAll (pointFaces, pointI)
|
|
|
|
// {
|
|
|
|
// scalar weightsSum = 0.0;
|
|
|
|
|
|
|
|
// const labelList& curPointFaces = pointFaces[pointI];
|
|
|
|
|
|
|
|
// forAll (curPointFaces, faceI)
|
|
|
|
// {
|
|
|
|
// label curFace = curPointFaces[faceI];
|
|
|
|
|
|
|
|
// scalar weight = 1.0/mag
|
|
|
|
// (
|
|
|
|
// points[pointI]
|
|
|
|
// - controlPoints()[curFace]
|
|
|
|
// );
|
|
|
|
|
|
|
|
// displacement[pointI] += weight*controlPoints()[curFace];
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
// weightsSum += weight;
|
|
|
|
// }
|
|
|
|
|
|
|
|
// displacement[pointI] /= weightsSum;
|
2013-07-18 01:02:34 +00:00
|
|
|
|
2010-05-12 13:27:55 +00:00
|
|
|
// displacement[pointI] -= points[pointI];
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// displacement = motionPointsMask()*
|
|
|
|
// (pointsDisplacementDir()&displacement)*
|
|
|
|
// pointsDisplacementDir();
|
|
|
|
|
|
|
|
|
|
|
|
// return tdisplacement;
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
|
|
|
|
|
|
|
} // End namespace Foam
|
|
|
|
|
|
|
|
// ************************************************************************* //
|