1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
11 cfMesh is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
16 cfMesh is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with cfMesh. If not, see <http://www.gnu.org/licenses/>.
26 \*---------------------------------------------------------------------------*/
28 #include "demandDrivenData.H"
29 #include "meshSurfaceOptimizer.H"
30 #include "meshSurfaceEngineModifier.H"
31 #include "meshOctree.H"
34 #include "surfaceOptimizer.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 void meshSurfaceOptimizer::nodeDisplacementLaplacian
48 const bool transformIntoPlane
51 const point newP = newPositionLaplacian(bpI, transformIntoPlane);
53 meshSurfaceEngineModifier surfaceModifier(surfaceEngine_);
54 surfaceModifier.moveBoundaryVertex(bpI, newP);
57 void meshSurfaceOptimizer::nodeDisplacementLaplacianFC
60 const bool transformIntoPlane
63 const point newP = newPositionLaplacianFC(bpI, transformIntoPlane);
65 meshSurfaceEngineModifier surfaceModifier(surfaceEngine_);
66 surfaceModifier.moveBoundaryVertex(bpI, newP);
69 void meshSurfaceOptimizer::nodeDisplacementSurfaceOptimizer
75 const pointFieldPMG& points = surfaceEngine_.points();
76 const labelList& bPoints = surfaceEngine_.boundaryPoints();
79 Info << "Smoothing boundary node " << bpI << endl;
80 Info << "Node label in the mesh is " << bPoints[bpI] << endl;
81 Info << "Point coordinates " << points[bPoints[bpI]] << endl;
84 //- project vertices onto the plane
85 const vector& pNormal = surfaceEngine_.pointNormals()[bpI];
86 if( magSqr(pNormal) < VSMALL )
89 const plane pl(points[bPoints[bpI]], pNormal);
92 DynList<triFace> trias;
94 if( !transformIntoPlane(bpI, pl, vecX, vecY, pts, trias) )
96 Warning << "Cannot transform into plane" << endl;
100 surfaceOptimizer so(pts, trias);
101 point newPoint = so.optimizePoint(tol);
105 points[bPoints[bpI]] +
106 vecX * newPoint.x() +
110 meshSurfaceEngineModifier sm(surfaceEngine_);
111 sm.moveBoundaryVertex(bpI, newP);
114 void meshSurfaceOptimizer::edgeNodeDisplacement(const label bpI) const
116 const pointFieldPMG& points = surfaceEngine_.points();
117 const labelList& bPoints = surfaceEngine_.boundaryPoints();
119 const point pos = newEdgePositionLaplacian(bpI);
120 const point newP = 0.5 * (pos + points[bPoints[bpI]]);
123 Info << "New position for point is " << newP << endl;
126 meshSurfaceEngineModifier(surfaceEngine_).moveBoundaryVertex(bpI, newP);
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 } // End namespace Foam
133 // ************************************************************************* //