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 if( vertexType_[bpI] & LOCKED )
54 const point newP = newPositionLaplacian(bpI, transformIntoPlane);
56 meshSurfaceEngineModifier surfaceModifier(surfaceEngine_);
57 surfaceModifier.moveBoundaryVertex(bpI, newP);
60 void meshSurfaceOptimizer::nodeDisplacementLaplacianFC
63 const bool transformIntoPlane
66 if( vertexType_[bpI] & LOCKED )
69 const point newP = newPositionLaplacianFC(bpI, transformIntoPlane);
71 meshSurfaceEngineModifier surfaceModifier(surfaceEngine_);
72 surfaceModifier.moveBoundaryVertex(bpI, newP);
75 void meshSurfaceOptimizer::nodeDisplacementSurfaceOptimizer
81 if( vertexType_[bpI] & LOCKED )
84 const pointFieldPMG& points = surfaceEngine_.points();
85 const labelList& bPoints = surfaceEngine_.boundaryPoints();
88 Info << "Smoothing boundary node " << bpI << endl;
89 Info << "Node label in the mesh is " << bPoints[bpI] << endl;
90 Info << "Point coordinates " << points[bPoints[bpI]] << endl;
93 //- project vertices onto the plane
94 const vector& pNormal = surfaceEngine_.pointNormals()[bpI];
95 if( magSqr(pNormal) < VSMALL )
98 const plane pl(points[bPoints[bpI]], pNormal);
101 DynList<triFace> trias;
103 if( !transformIntoPlane(bpI, pl, vecX, vecY, pts, trias) )
105 Warning << "Cannot transform into plane" << endl;
109 surfaceOptimizer so(pts, trias);
110 point newPoint = so.optimizePoint(tol);
114 points[bPoints[bpI]] +
115 vecX * newPoint.x() +
119 meshSurfaceEngineModifier sm(surfaceEngine_);
120 sm.moveBoundaryVertex(bpI, newP);
123 void meshSurfaceOptimizer::edgeNodeDisplacement(const label bpI) const
125 if( vertexType_[bpI] & LOCKED )
128 const pointFieldPMG& points = surfaceEngine_.points();
129 const labelList& bPoints = surfaceEngine_.boundaryPoints();
131 const point pos = newEdgePositionLaplacian(bpI);
132 const point newP = 0.5 * (pos + points[bPoints[bpI]]);
135 Info << "New position for point is " << newP << endl;
138 meshSurfaceEngineModifier(surfaceEngine_).moveBoundaryVertex(bpI, newP);
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 } // End namespace Foam
145 // ************************************************************************* //