mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'feature/cvMesh'
This commit is contained in:
@ -25,6 +25,7 @@ License
|
|||||||
|
|
||||||
#include "scalarMatrices.H"
|
#include "scalarMatrices.H"
|
||||||
#include "vector.H"
|
#include "vector.H"
|
||||||
|
#include "IFstream.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
|
|||||||
3
applications/test/vectorTools/Make/files
Normal file
3
applications/test/vectorTools/Make/files
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
Test-vectorTools.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/Test-vectorTools
|
||||||
1
applications/test/vectorTools/Make/options
Normal file
1
applications/test/vectorTools/Make/options
Normal file
@ -0,0 +1 @@
|
|||||||
|
EXE_INC = -I$(FOAM_APP)/utilities/mesh/generation/cvMesh/vectorTools
|
||||||
71
applications/test/vectorTools/Test-vectorTools.C
Normal file
71
applications/test/vectorTools/Test-vectorTools.C
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
#include "vector.H"
|
||||||
|
#include "IOstreams.H"
|
||||||
|
#include "vectorTools.H"
|
||||||
|
#include "unitConversion.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
|
||||||
|
void test(const vector& a, const vector& b, const scalar tolerance)
|
||||||
|
{
|
||||||
|
Info<< "Vectors " << a << " and " << b
|
||||||
|
<< " are (to tolerance of " << tolerance << "): ";
|
||||||
|
|
||||||
|
if (vectorTools::areParallel(a, b, tolerance))
|
||||||
|
Info<< " parallel ";
|
||||||
|
|
||||||
|
if (vectorTools::areOrthogonal(a, b, tolerance))
|
||||||
|
Info<< " orthogonal ";
|
||||||
|
|
||||||
|
if (vectorTools::areAcute(a, b))
|
||||||
|
Info<< " acute ";
|
||||||
|
|
||||||
|
if (vectorTools::areObtuse(a, b))
|
||||||
|
Info<< " obtuse ";
|
||||||
|
|
||||||
|
Info<< ", angle = " << vectorTools::degAngleBetween(a, b);
|
||||||
|
|
||||||
|
Info<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
vector a(1.0, 1.0, 1.0);
|
||||||
|
vector b(2.0, 2.0, 2.0);
|
||||||
|
|
||||||
|
test(a, b, 0.0);
|
||||||
|
test(a, b, VSMALL);
|
||||||
|
test(a, b, SMALL);
|
||||||
|
test(a, b, 1e-3);
|
||||||
|
test(a, b, 1e-1);
|
||||||
|
|
||||||
|
a = vector(1,0,0);
|
||||||
|
b = vector(0,2,0);
|
||||||
|
|
||||||
|
test(a, b, 0.0);
|
||||||
|
test(a, b, VSMALL);
|
||||||
|
test(a, b, SMALL);
|
||||||
|
test(a, b, 1e-3);
|
||||||
|
test(a, b, 1e-1);
|
||||||
|
|
||||||
|
a = vector(1,0,0);
|
||||||
|
b = vector(-1,0,0);
|
||||||
|
|
||||||
|
test(a, b, 0.0);
|
||||||
|
test(a, b, VSMALL);
|
||||||
|
test(a, b, SMALL);
|
||||||
|
test(a, b, 1e-3);
|
||||||
|
test(a, b, 1e-1);
|
||||||
|
|
||||||
|
a = vector(1,0,0);
|
||||||
|
b = vector(-1,2,0);
|
||||||
|
|
||||||
|
test(a, b, 0.0);
|
||||||
|
test(a, b, VSMALL);
|
||||||
|
test(a, b, SMALL);
|
||||||
|
test(a, b, 1e-3);
|
||||||
|
test(a, b, 1e-1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@ -2,16 +2,24 @@
|
|||||||
| ========= | |
|
| ========= | |
|
||||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
| \\ / O peration | Version: dev |
|
| \\ / O peration | Version: dev |
|
||||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
| \\ / A nd | Web: http://www.openfoam.org |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
FoamFile
|
FoamFile
|
||||||
{
|
{
|
||||||
version 2.0;
|
version 2.0;
|
||||||
format ascii;
|
format ascii;
|
||||||
|
|
||||||
|
root "";
|
||||||
|
case "";
|
||||||
|
instance "";
|
||||||
|
local "";
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
object collapseDict;
|
object collapseDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// If on, after collapsing check the quality of the mesh. If bad faces are
|
// If on, after collapsing check the quality of the mesh. If bad faces are
|
||||||
@ -72,7 +80,7 @@ controlMeshQualityCoeffs
|
|||||||
|
|
||||||
// The amount that initialFaceLengthFactor will be reduced by for each
|
// The amount that initialFaceLengthFactor will be reduced by for each
|
||||||
// face if its collapse generates a poor quality face
|
// face if its collapse generates a poor quality face
|
||||||
faceReductionFactor $initialFaceLengthFactor;
|
faceReductionFactor 0.5;
|
||||||
|
|
||||||
// Maximum number of smoothing iterations for the reductionFactors
|
// Maximum number of smoothing iterations for the reductionFactors
|
||||||
maximumSmoothingIterations 2;
|
maximumSmoothingIterations 2;
|
||||||
|
|||||||
@ -72,10 +72,11 @@ int main(int argc, char *argv[])
|
|||||||
"Collapse small and sliver faces as well as small edges"
|
"Collapse small and sliver faces as well as small edges"
|
||||||
);
|
);
|
||||||
|
|
||||||
argList::addBoolOption
|
argList::addOption
|
||||||
(
|
(
|
||||||
"collapseIndirectPatchFaces",
|
"collapseFaceZone",
|
||||||
"Collapse faces that are in the face zone indirectPatchFaces"
|
"zoneName",
|
||||||
|
"Collapse faces that are in the supplied face zone"
|
||||||
);
|
);
|
||||||
|
|
||||||
# include "addOverwriteOption.H"
|
# include "addOverwriteOption.H"
|
||||||
@ -92,8 +93,7 @@ int main(int argc, char *argv[])
|
|||||||
const bool overwrite = args.optionFound("overwrite");
|
const bool overwrite = args.optionFound("overwrite");
|
||||||
|
|
||||||
const bool collapseFaces = args.optionFound("collapseFaces");
|
const bool collapseFaces = args.optionFound("collapseFaces");
|
||||||
const bool collapseIndirectPatchFaces =
|
const bool collapseFaceZone = args.optionFound("collapseFaceZone");
|
||||||
args.optionFound("collapseIndirectPatchFaces");
|
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
@ -115,11 +115,15 @@ int main(int argc, char *argv[])
|
|||||||
meshMod.changeMesh(mesh, false);
|
meshMod.changeMesh(mesh, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collapseIndirectPatchFaces)
|
if (collapseFaceZone)
|
||||||
{
|
{
|
||||||
|
const word faceZoneName = args.optionRead<word>("collapseFaceZone");
|
||||||
|
|
||||||
|
const faceZone& fZone = mesh.faceZones()[faceZoneName];
|
||||||
|
|
||||||
// Filter faces. Pass in the number of bad faces that are present
|
// Filter faces. Pass in the number of bad faces that are present
|
||||||
// from the previous edge filtering to use as a stopping criterion.
|
// from the previous edge filtering to use as a stopping criterion.
|
||||||
meshFilter.filterIndirectPatchFaces();
|
meshFilter.filterFaceZone(fZone);
|
||||||
{
|
{
|
||||||
polyTopoChange meshMod(newMesh);
|
polyTopoChange meshMod(newMesh);
|
||||||
|
|
||||||
|
|||||||
@ -9,5 +9,10 @@ extrude2DMesh/Allwmake
|
|||||||
|
|
||||||
wmake snappyHexMesh
|
wmake snappyHexMesh
|
||||||
|
|
||||||
|
if [ -d "$CGAL_ARCH_PATH" ]
|
||||||
|
then
|
||||||
|
foamyHexMesh/Allwmake
|
||||||
|
foamyHex2DMesh/Allwmake
|
||||||
|
fi
|
||||||
|
|
||||||
# ----------------------------------------------------------------- end-of-file
|
# ----------------------------------------------------------------- end-of-file
|
||||||
|
|||||||
@ -90,6 +90,7 @@ Foam::extrude2DMesh::extrude2DMesh
|
|||||||
dict_(dict),
|
dict_(dict),
|
||||||
//patchDict_(dict.subDict("patchInfo")),
|
//patchDict_(dict.subDict("patchInfo")),
|
||||||
model_(model),
|
model_(model),
|
||||||
|
modelType_(dict.lookup("extrudeModel")),
|
||||||
patchType_(dict.lookup("patchType")),
|
patchType_(dict.lookup("patchType")),
|
||||||
frontPatchI_(-1),
|
frontPatchI_(-1),
|
||||||
backPatchI_(-1)
|
backPatchI_(-1)
|
||||||
|
|||||||
@ -53,6 +53,7 @@ class polyMesh;
|
|||||||
class polyTopoChange;
|
class polyTopoChange;
|
||||||
class mapPolyMesh;
|
class mapPolyMesh;
|
||||||
class mapDistributePolyMesh;
|
class mapDistributePolyMesh;
|
||||||
|
class polyBoundaryMesh;
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*\
|
/*---------------------------------------------------------------------------*\
|
||||||
Class extrude2DMesh Declaration
|
Class extrude2DMesh Declaration
|
||||||
@ -65,24 +66,19 @@ class extrude2DMesh
|
|||||||
//- Reference to 2D mesh
|
//- Reference to 2D mesh
|
||||||
polyMesh& mesh_;
|
polyMesh& mesh_;
|
||||||
|
|
||||||
//- Extrusion dictionary
|
|
||||||
const dictionary dict_;
|
const dictionary dict_;
|
||||||
|
|
||||||
//const dictionary patchDict_;
|
//const dictionary patchDict_;
|
||||||
|
|
||||||
//- The extrusion model
|
|
||||||
const extrudeModel& model_;
|
const extrudeModel& model_;
|
||||||
|
|
||||||
//- Type of the patches that will be created by the extrusion.
|
const word modelType_;
|
||||||
|
|
||||||
const word patchType_;
|
const word patchType_;
|
||||||
|
|
||||||
//- Patch ID of the front patch
|
|
||||||
label frontPatchI_;
|
label frontPatchI_;
|
||||||
|
|
||||||
//- Patch ID of the back patch
|
|
||||||
label backPatchI_;
|
label backPatchI_;
|
||||||
|
|
||||||
|
|
||||||
// Private Member Functions
|
// Private Member Functions
|
||||||
|
|
||||||
//- Check the mesh is 2D
|
//- Check the mesh is 2D
|
||||||
@ -97,7 +93,6 @@ class extrude2DMesh
|
|||||||
//- Disallow default bitwise assignment
|
//- Disallow default bitwise assignment
|
||||||
void operator=(const extrude2DMesh&);
|
void operator=(const extrude2DMesh&);
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -105,8 +100,6 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Constructors
|
// Constructors
|
||||||
|
|
||||||
//- Construct from a 2D polyMesh, a dictionary and an extrusion model
|
|
||||||
extrude2DMesh
|
extrude2DMesh
|
||||||
(
|
(
|
||||||
polyMesh&,
|
polyMesh&,
|
||||||
@ -121,23 +114,6 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
// Access
|
|
||||||
|
|
||||||
//- Return the patch ID of the front patch
|
|
||||||
inline label frontPatchI() const
|
|
||||||
{
|
|
||||||
return frontPatchI_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the patch ID of the back patch
|
|
||||||
inline label backPatchI() const
|
|
||||||
{
|
|
||||||
return backPatchI_;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// Edit
|
|
||||||
|
|
||||||
//- Add front and back patches
|
//- Add front and back patches
|
||||||
void addFrontBackPatches();
|
void addFrontBackPatches();
|
||||||
|
|
||||||
@ -151,6 +127,17 @@ public:
|
|||||||
//- Force recalculation of locally stored data for mesh distribution
|
//- Force recalculation of locally stored data for mesh distribution
|
||||||
void distribute(const mapDistributePolyMesh&)
|
void distribute(const mapDistributePolyMesh&)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
label frontPatchI() const
|
||||||
|
{
|
||||||
|
return frontPatchI_;
|
||||||
|
}
|
||||||
|
|
||||||
|
label backPatchI() const
|
||||||
|
{
|
||||||
|
return backPatchI_;
|
||||||
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -5,48 +5,42 @@
|
|||||||
| \\ / A nd | Web: www.OpenFOAM.org |
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
| \\/ M anipulation | |
|
| \\/ M anipulation | |
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
FoamFile
|
FoamFile
|
||||||
{
|
{
|
||||||
version 2.0;
|
version 2.0;
|
||||||
format ascii;
|
format ascii;
|
||||||
|
|
||||||
|
root "";
|
||||||
|
case "";
|
||||||
|
instance "";
|
||||||
|
local "";
|
||||||
|
|
||||||
class dictionary;
|
class dictionary;
|
||||||
object extrude2DMeshDict;
|
object extrude2DMeshDict;
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
// Type of extrusion
|
|
||||||
extrudeModel linearDirection;
|
extrudeModel linearDirection;
|
||||||
//extrudeModel wedge;
|
//extrudeModel wedge;
|
||||||
|
|
||||||
// Patch type the extruded patches will take
|
|
||||||
patchType empty;
|
patchType empty;
|
||||||
//patchType wedge;
|
//patchType wedge;
|
||||||
|
|
||||||
// Number of layers to extrude
|
|
||||||
nLayers 1;
|
nLayers 1;
|
||||||
|
|
||||||
// Expansion ratio. If >1 then grows the layers
|
|
||||||
expansionRatio 1.0;
|
expansionRatio 1.0;
|
||||||
|
|
||||||
linearDirectionCoeffs
|
linearDirectionCoeffs
|
||||||
{
|
{
|
||||||
// Direction of extrusion
|
|
||||||
direction (0 0 1);
|
direction (0 0 1);
|
||||||
|
|
||||||
// Width of newly extruded cells
|
|
||||||
thickness 0.1;
|
thickness 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
wedgeCoeffs
|
wedgeCoeffs
|
||||||
{
|
{
|
||||||
// Point the extrusion axis goes through
|
|
||||||
axisPt (0 0 0);
|
axisPt (0 0 0);
|
||||||
|
|
||||||
// Axis to extrude around
|
|
||||||
axis (1 0 0);
|
axis (1 0 0);
|
||||||
|
|
||||||
// Total angle of the wedge in degrees
|
|
||||||
angle 10;
|
angle 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ************************************************************************* //
|
|
||||||
8
applications/utilities/mesh/generation/foamyHex2DMesh/Allwclean
Executable file
8
applications/utilities/mesh/generation/foamyHex2DMesh/Allwclean
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # run from this directory
|
||||||
|
set -x
|
||||||
|
|
||||||
|
wclean libso conformalVoronoi2DMesh
|
||||||
|
wclean
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------- end-of-file
|
||||||
8
applications/utilities/mesh/generation/foamyHex2DMesh/Allwmake
Executable file
8
applications/utilities/mesh/generation/foamyHex2DMesh/Allwmake
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # run from this directory
|
||||||
|
set -x
|
||||||
|
|
||||||
|
wmake libso conformalVoronoi2DMesh
|
||||||
|
wmake
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------- end-of-file
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedefs
|
||||||
|
CGALTriangulation2DKernel
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CGALTriangulation2DKernel_H
|
||||||
|
#define CGALTriangulation2DKernel_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "CGAL/Delaunay_triangulation_2.h"
|
||||||
|
|
||||||
|
#ifdef CGAL_INEXACT
|
||||||
|
|
||||||
|
// Fast kernel using a double as the storage type but the triangulation
|
||||||
|
// may fail
|
||||||
|
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
|
||||||
|
|
||||||
|
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Very robust but expensive kernel
|
||||||
|
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
|
||||||
|
|
||||||
|
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,76 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Typedefs
|
||||||
|
CGALTriangulation2Ddefs
|
||||||
|
|
||||||
|
Description
|
||||||
|
CGAL data structures used for 2D Delaunay meshing.
|
||||||
|
|
||||||
|
Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
|
||||||
|
otherwise the more robust but much less efficient
|
||||||
|
Exact_predicates_exact_constructions will be used.
|
||||||
|
|
||||||
|
Define CGAL_HIERARCHY to use hierarchical Delaunay triangulation which is
|
||||||
|
faster but uses more memory than the standard Delaunay triangulation.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CGALTriangulation2Ddefs_H
|
||||||
|
#define CGALTriangulation2Ddefs_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "CGALTriangulation2DKernel.H"
|
||||||
|
|
||||||
|
#include "indexedVertex.H"
|
||||||
|
#include "indexedFace.H"
|
||||||
|
|
||||||
|
typedef CGAL::indexedVertex<K> Vb;
|
||||||
|
typedef CGAL::indexedFace<K> Fb;
|
||||||
|
|
||||||
|
#ifdef CGAL_HIERARCHY
|
||||||
|
|
||||||
|
// Data structures for hierarchical Delaunay triangulation which is more
|
||||||
|
// efficient but also uses more storage
|
||||||
|
#include "CGAL/Triangulation_hierarchy_2.h"
|
||||||
|
|
||||||
|
typedef CGAL::Triangulation_hierarchy_vertex_base_2<Vb> Vbh;
|
||||||
|
typedef CGAL::Triangulation_data_structure_2<Vbh, Fb> Tds;
|
||||||
|
typedef CGAL::Delaunay_triangulation_2<K, Tds> DT;
|
||||||
|
typedef CGAL::Triangulation_hierarchy_2<DT> Delaunay;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
// Data structures for standard Delaunay triangulation
|
||||||
|
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
|
||||||
|
typedef CGAL::Delaunay_triangulation_2<K, Tds> Delaunay;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
1000
applications/utilities/mesh/generation/foamyHex2DMesh/CV2D.C
Normal file
1000
applications/utilities/mesh/generation/foamyHex2DMesh/CV2D.C
Normal file
File diff suppressed because it is too large
Load Diff
474
applications/utilities/mesh/generation/foamyHex2DMesh/CV2D.H
Normal file
474
applications/utilities/mesh/generation/foamyHex2DMesh/CV2D.H
Normal file
@ -0,0 +1,474 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
CV2D
|
||||||
|
|
||||||
|
Description
|
||||||
|
Conformal-Voronoi 2D automatic mesher with grid or read initial points
|
||||||
|
and point position relaxation with optional "squarification".
|
||||||
|
|
||||||
|
There are a substantial number of options to this mesher read from
|
||||||
|
CV2DMesherDict file e.g.:
|
||||||
|
|
||||||
|
// Min cell size used in tolerances when inserting points for
|
||||||
|
// boundary conforming.
|
||||||
|
// Also used to as the grid spacing usind in insertGrid.
|
||||||
|
minCellSize 0.05;
|
||||||
|
|
||||||
|
// Feature angle used to inser feature points
|
||||||
|
// 0 = all features, 180 = no features
|
||||||
|
featureAngle 45;
|
||||||
|
|
||||||
|
// Maximum quadrant angle allowed at a concave corner before
|
||||||
|
// additional "mitering" lines are added
|
||||||
|
maxQuadAngle 110;
|
||||||
|
|
||||||
|
// Should the mesh be square-dominated or of unbiased hexagons
|
||||||
|
squares yes;
|
||||||
|
|
||||||
|
// Near-wall region where cells are aligned with the wall specified as a
|
||||||
|
// number of cell layers
|
||||||
|
nearWallAlignedDist 3;
|
||||||
|
|
||||||
|
// Chose if the cell orientation should relax during the iterations
|
||||||
|
// or remain fixed to the x-y directions
|
||||||
|
relaxOrientation no;
|
||||||
|
|
||||||
|
// Insert near-boundary point mirror or point-pairs
|
||||||
|
insertSurfaceNearestPointPairs yes;
|
||||||
|
|
||||||
|
// Mirror near-boundary points rather than insert point-pairs
|
||||||
|
mirrorPoints no;
|
||||||
|
|
||||||
|
// Insert point-pairs vor dual-cell vertices very near the surface
|
||||||
|
insertSurfaceNearPointPairs yes;
|
||||||
|
|
||||||
|
// Choose if to randomise the initial grid created by insertGrid.
|
||||||
|
randomiseInitialGrid yes;
|
||||||
|
|
||||||
|
// Perturbation fraction, 1 = cell-size.
|
||||||
|
randomPurturbation 0.1;
|
||||||
|
|
||||||
|
// Number of relaxation iterations.
|
||||||
|
nIterations 5;
|
||||||
|
|
||||||
|
// Relaxation factor at the start of the iteration sequence.
|
||||||
|
// 0.5 is a sensible maximum and < 0.2 converges better.
|
||||||
|
relaxationFactorStart 0.8;
|
||||||
|
|
||||||
|
// Relaxation factor at the end of the iteration sequence.
|
||||||
|
// Should be <= relaxationFactorStart
|
||||||
|
relaxationFactorEnd 0;
|
||||||
|
|
||||||
|
writeInitialTriangulation no;
|
||||||
|
writeFeatureTriangulation no;
|
||||||
|
writeNearestTriangulation no;
|
||||||
|
writeInsertedPointPairs no;
|
||||||
|
writeFinalTriangulation yes;
|
||||||
|
|
||||||
|
// Maximum number of iterations used in boundaryConform.
|
||||||
|
maxBoundaryConformingIter 5;
|
||||||
|
|
||||||
|
minEdgeLenCoeff 0.5;
|
||||||
|
maxNotchLenCoeff 0.3;
|
||||||
|
minNearPointDistCoeff 0.25;
|
||||||
|
ppDistCoeff 0.05;
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
CGALTriangulation2Ddefs.H
|
||||||
|
indexedVertex.H
|
||||||
|
indexedFace.H
|
||||||
|
CV2DI.H
|
||||||
|
CV2D.C
|
||||||
|
CV2DIO.C
|
||||||
|
tolerances.C
|
||||||
|
controls.C
|
||||||
|
insertFeaturePoints.C
|
||||||
|
insertSurfaceNearestPointPairs.C
|
||||||
|
insertSurfaceNearPointPairs.C
|
||||||
|
insertBoundaryConformPointPairs.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef CV2D_H
|
||||||
|
#define CV2D_H
|
||||||
|
|
||||||
|
#define CGAL_INEXACT
|
||||||
|
#define CGAL_HIERARCHY
|
||||||
|
|
||||||
|
#include "CGALTriangulation2Ddefs.H"
|
||||||
|
|
||||||
|
#include "Time.H"
|
||||||
|
#include "point2DFieldFwd.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
#include "PackedBoolList.H"
|
||||||
|
#include "EdgeMap.H"
|
||||||
|
#include "cv2DControls.H"
|
||||||
|
#include "tolerances.H"
|
||||||
|
#include "meshTools.H"
|
||||||
|
#include "triSurface.H"
|
||||||
|
#include "searchableSurfaces.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "relaxationModel.H"
|
||||||
|
#include "cellSizeAndAlignmentControls.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class CV2D Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class CV2D
|
||||||
|
:
|
||||||
|
public Delaunay
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The time registry of the application
|
||||||
|
const Time& runTime_;
|
||||||
|
|
||||||
|
mutable Random rndGen_;
|
||||||
|
|
||||||
|
//- The surface to mesh
|
||||||
|
//const querySurface& qSurf_;
|
||||||
|
//- All geometry of the meshing process, including surfaces to be
|
||||||
|
// conformed to and those to be used for refinement
|
||||||
|
searchableSurfaces allGeometry_;
|
||||||
|
|
||||||
|
conformationSurfaces qSurf_;
|
||||||
|
|
||||||
|
//- Meshing controls
|
||||||
|
cv2DControls controls_;
|
||||||
|
|
||||||
|
//- The cell size control object
|
||||||
|
cellSizeAndAlignmentControls cellSizeControl_;
|
||||||
|
|
||||||
|
//- Relaxation coefficient model. Runtime selectable.
|
||||||
|
autoPtr<relaxationModel> relaxationModel_;
|
||||||
|
|
||||||
|
//- z-level
|
||||||
|
scalar z_;
|
||||||
|
|
||||||
|
//- Keep track of the start of the internal points
|
||||||
|
label startOfInternalPoints_;
|
||||||
|
|
||||||
|
//- Keep track of the start of the surface point-pairs
|
||||||
|
label startOfSurfacePointPairs_;
|
||||||
|
|
||||||
|
//- Keep track of the boundary conform point-pairs
|
||||||
|
// stored after the insertion of the surface point-pairs in case
|
||||||
|
// the boundary conform function is called more than once without
|
||||||
|
// removing and insertin the surface point-pairs
|
||||||
|
label startOfBoundaryConformPointPairs_;
|
||||||
|
|
||||||
|
//- Store the feature points
|
||||||
|
std::list<Vb> featurePoints_;
|
||||||
|
|
||||||
|
//- Temporary storage for a dual-cell
|
||||||
|
static const label maxNvert = 20;
|
||||||
|
mutable point2D vertices[maxNvert+1];
|
||||||
|
mutable vector2D edges[maxNvert+1];
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
CV2D(const CV2D&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const CV2D&);
|
||||||
|
|
||||||
|
|
||||||
|
//- Insert point and return it's index
|
||||||
|
inline label insertPoint
|
||||||
|
(
|
||||||
|
const point2D& pt,
|
||||||
|
const label type
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Insert point and return it's index
|
||||||
|
inline label insertPoint
|
||||||
|
(
|
||||||
|
const point2D& pt,
|
||||||
|
const label index,
|
||||||
|
const label type
|
||||||
|
);
|
||||||
|
|
||||||
|
inline label insertPoint
|
||||||
|
(
|
||||||
|
const Point& p,
|
||||||
|
const label index,
|
||||||
|
const label type
|
||||||
|
);
|
||||||
|
|
||||||
|
inline bool insertMirrorPoint
|
||||||
|
(
|
||||||
|
const point2D& nearSurfPt,
|
||||||
|
const point2D& surfPt
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Insert a point-pair at a distance ppDist either side of
|
||||||
|
// surface point point surfPt in the direction n
|
||||||
|
inline void insertPointPair
|
||||||
|
(
|
||||||
|
const scalar mirrorDist,
|
||||||
|
const point2D& surfPt,
|
||||||
|
const vector2D& n
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Create the initial mesh from the bounding-box
|
||||||
|
void insertBoundingBox();
|
||||||
|
|
||||||
|
//- Check if a point is within a line.
|
||||||
|
bool on2DLine(const point2D& p, const linePointRef& line);
|
||||||
|
|
||||||
|
//- Insert point groups at the feature points.
|
||||||
|
void insertFeaturePoints();
|
||||||
|
|
||||||
|
//- Re-insert point groups at the feature points.
|
||||||
|
void reinsertFeaturePoints();
|
||||||
|
|
||||||
|
//- Insert point-pairs at the given set of points using the surface
|
||||||
|
// normals corresponding to the given set of surface triangles
|
||||||
|
// and write the inserted point locations to the given file.
|
||||||
|
void insertPointPairs
|
||||||
|
(
|
||||||
|
const DynamicList<point2D>& nearSurfacePoints,
|
||||||
|
const DynamicList<point2D>& surfacePoints,
|
||||||
|
const DynamicList<label>& surfaceTris,
|
||||||
|
const DynamicList<label>& surfaceHits,
|
||||||
|
const fileName fName
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Check to see if dual cell specified by given vertex iterator
|
||||||
|
// intersects the boundary and hence reqires a point-pair.
|
||||||
|
bool dualCellSurfaceIntersection
|
||||||
|
(
|
||||||
|
const Triangulation::Finite_vertices_iterator& vit
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Insert point-pairs at the nearest points on the surface to the
|
||||||
|
// control vertex of dual-cells which intersect the boundary in order
|
||||||
|
// to provide a boundary-layer mesh.
|
||||||
|
// NB: This is not guaranteed to close the boundary
|
||||||
|
void insertSurfaceNearestPointPairs();
|
||||||
|
|
||||||
|
//- Insert point-pairs at small dual-cell edges on the surface in order
|
||||||
|
// to improve the boundary-layer mesh generated by
|
||||||
|
// insertSurfaceNearestPointPairs.
|
||||||
|
void insertSurfaceNearPointPairs();
|
||||||
|
|
||||||
|
//- Insert point-pair and correcting the Finite_vertices_iterator
|
||||||
|
// to account for the additional vertices
|
||||||
|
void insertPointPair
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator& vit,
|
||||||
|
const point2D& p,
|
||||||
|
const label trii,
|
||||||
|
const label hitSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Insert point-pair at the best intersection point between the lines
|
||||||
|
// from the dual-cell real centroid and it's vertices and the surface.
|
||||||
|
bool insertPointPairAtIntersection
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator& vit,
|
||||||
|
const point2D& defVert,
|
||||||
|
const point2D vertices[],
|
||||||
|
const scalar maxProtSize
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Insert point-pairs corresponding to dual-cells which intersect
|
||||||
|
// the boundary surface
|
||||||
|
label insertBoundaryConformPointPairs(const fileName& fName);
|
||||||
|
|
||||||
|
void markNearBoundaryPoints();
|
||||||
|
|
||||||
|
//- Restore the Delaunay contraint
|
||||||
|
void fast_restore_Delaunay(Vertex_handle vh);
|
||||||
|
|
||||||
|
// Flip operations used by fast_restore_Delaunay
|
||||||
|
void external_flip(Face_handle& f, int i);
|
||||||
|
bool internal_flip(Face_handle& f, int i);
|
||||||
|
|
||||||
|
//- Write all the faces and all the triangles at a particular stage.
|
||||||
|
void write(const word& stage) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("CV2D");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct for given surface
|
||||||
|
CV2D(const Time& runTime, const dictionary& controlDict);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~CV2D();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
inline const cv2DControls& meshControls() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Conversion functions between point2D, point and Point
|
||||||
|
|
||||||
|
inline const point2D& toPoint2D(const point&) const;
|
||||||
|
inline const point2DField toPoint2D(const pointField&) const;
|
||||||
|
inline point toPoint3D(const point2D&) const;
|
||||||
|
|
||||||
|
#ifdef CGAL_INEXACT
|
||||||
|
typedef const point2D& point2DFromPoint;
|
||||||
|
typedef const Point& PointFromPoint2D;
|
||||||
|
#else
|
||||||
|
typedef point2D point2DFromPoint;
|
||||||
|
typedef Point PointFromPoint2D;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
inline point2DFromPoint toPoint2D(const Point&) const;
|
||||||
|
inline PointFromPoint2D toPoint(const point2D&) const;
|
||||||
|
inline point toPoint3D(const Point&) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Point insertion
|
||||||
|
|
||||||
|
//- Create the initial mesh from the given internal points.
|
||||||
|
// Points must be inside the boundary by at least nearness
|
||||||
|
// otherwise they are ignored.
|
||||||
|
void insertPoints
|
||||||
|
(
|
||||||
|
const point2DField& points,
|
||||||
|
const scalar nearness
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Create the initial mesh from the internal points in the given
|
||||||
|
// file. Points outside the geometry are ignored.
|
||||||
|
void insertPoints(const fileName& pointFileName);
|
||||||
|
|
||||||
|
//- Create the initial mesh as a regular grid of points.
|
||||||
|
// Points outside the geometry are ignored.
|
||||||
|
void insertGrid();
|
||||||
|
|
||||||
|
//- Insert all surface point-pairs from
|
||||||
|
// insertSurfaceNearestPointPairs and
|
||||||
|
// findIntersectionForOutsideCentroid
|
||||||
|
void insertSurfacePointPairs();
|
||||||
|
|
||||||
|
//- Insert point-pairs where there are protrusions into
|
||||||
|
// or out of the surface
|
||||||
|
void boundaryConform();
|
||||||
|
|
||||||
|
|
||||||
|
// Point removal
|
||||||
|
|
||||||
|
//- Remove the point-pairs introduced by insertSurfacePointPairs
|
||||||
|
// and boundaryConform
|
||||||
|
void removeSurfacePointPairs();
|
||||||
|
|
||||||
|
|
||||||
|
// Point motion
|
||||||
|
|
||||||
|
inline void movePoint(const Vertex_handle& vh, const Point& P);
|
||||||
|
|
||||||
|
//- Move the internal points to the given new locations and update
|
||||||
|
// the triangulation to ensure it is Delaunay
|
||||||
|
// void moveInternalPoints(const point2DField& newPoints);
|
||||||
|
|
||||||
|
//- Calculate the displacements to create the new points
|
||||||
|
void newPoints();
|
||||||
|
|
||||||
|
//- Extract patch names and sizes.
|
||||||
|
void extractPatches
|
||||||
|
(
|
||||||
|
wordList& patchNames,
|
||||||
|
labelList& patchSizes,
|
||||||
|
EdgeMap<label>& mapEdgesRegion,
|
||||||
|
EdgeMap<label>& indirectPatchEdge
|
||||||
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write internal points to .obj file
|
||||||
|
void writePoints(const fileName& fName, bool internalOnly) const;
|
||||||
|
|
||||||
|
//- Write triangles as .obj file
|
||||||
|
void writeTriangles(const fileName& fName, bool internalOnly) const;
|
||||||
|
|
||||||
|
//- Write dual faces as .obj file
|
||||||
|
void writeFaces(const fileName& fName, bool internalOnly) const;
|
||||||
|
|
||||||
|
//- Calculates dual points (circumcentres of tets) and faces
|
||||||
|
// (point-cell walk of tets).
|
||||||
|
// Returns:
|
||||||
|
// - dualPoints (in triangle ordering)
|
||||||
|
// - dualFaces (compacted)
|
||||||
|
void calcDual
|
||||||
|
(
|
||||||
|
point2DField& dualPoints,
|
||||||
|
faceList& dualFaces,
|
||||||
|
wordList& patchNames,
|
||||||
|
labelList& patchSizes,
|
||||||
|
EdgeMap<label>& mapEdgesRegion,
|
||||||
|
EdgeMap<label>& indirectPatchEdge
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Write patch
|
||||||
|
void writePatch(const fileName& fName) const;
|
||||||
|
|
||||||
|
void write() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline bool boundaryTriangle(const CV2D::Face_handle fc);
|
||||||
|
inline bool outsideTriangle(const CV2D::Face_handle fc);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "CV2DI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
227
applications/utilities/mesh/generation/foamyHex2DMesh/CV2DI.H
Normal file
227
applications/utilities/mesh/generation/foamyHex2DMesh/CV2DI.H
Normal file
@ -0,0 +1,227 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::label Foam::CV2D::insertPoint
|
||||||
|
(
|
||||||
|
const point2D& p,
|
||||||
|
const label type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint nVert = number_of_vertices();
|
||||||
|
|
||||||
|
return insertPoint(toPoint(p), nVert, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::CV2D::insertPoint
|
||||||
|
(
|
||||||
|
const point2D& p,
|
||||||
|
const label index,
|
||||||
|
const label type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return insertPoint(toPoint(p), index, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::CV2D::insertPoint
|
||||||
|
(
|
||||||
|
const Point& p,
|
||||||
|
const label index,
|
||||||
|
const label type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
uint nVert = number_of_vertices();
|
||||||
|
|
||||||
|
Vertex_handle vh = insert(p);
|
||||||
|
|
||||||
|
if (nVert == number_of_vertices())
|
||||||
|
{
|
||||||
|
WarningIn("Foam::CV2D::insertPoint")
|
||||||
|
<< "Failed to insert point " << toPoint2D(p) << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vh->index() = index;
|
||||||
|
vh->type() = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return vh->index();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::CV2D::insertMirrorPoint
|
||||||
|
(
|
||||||
|
const point2D& nearSurfPt,
|
||||||
|
const point2D& surfPt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
point2D mirrorPoint(2*surfPt - nearSurfPt);
|
||||||
|
|
||||||
|
if (qSurf_.outside(toPoint3D(mirrorPoint)))
|
||||||
|
{
|
||||||
|
insertPoint(mirrorPoint, Vb::MIRROR_POINT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::CV2D::insertPointPair
|
||||||
|
(
|
||||||
|
const scalar ppDist,
|
||||||
|
const point2D& surfPt,
|
||||||
|
const vector2D& n
|
||||||
|
)
|
||||||
|
{
|
||||||
|
vector2D ppDistn = ppDist*n;
|
||||||
|
|
||||||
|
label master = insertPoint
|
||||||
|
(
|
||||||
|
surfPt - ppDistn,
|
||||||
|
number_of_vertices() + 1
|
||||||
|
);
|
||||||
|
|
||||||
|
insertPoint(surfPt + ppDistn, master);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline const Foam::cv2DControls& Foam::CV2D::meshControls() const
|
||||||
|
{
|
||||||
|
return controls_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::point2D& Foam::CV2D::toPoint2D(const point& p) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<const point2D&>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::point2DField Foam::CV2D::toPoint2D(const pointField& p) const
|
||||||
|
{
|
||||||
|
point2DField temp(p.size());
|
||||||
|
forAll(temp, pointI)
|
||||||
|
{
|
||||||
|
temp[pointI] = point2D(p[pointI].x(), p[pointI].y());
|
||||||
|
}
|
||||||
|
return temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::point Foam::CV2D::toPoint3D(const point2D& p) const
|
||||||
|
{
|
||||||
|
return point(p.x(), p.y(), z_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CGAL_INEXACT
|
||||||
|
|
||||||
|
inline Foam::CV2D::point2DFromPoint Foam::CV2D::toPoint2D(const Point& P) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<point2DFromPoint>(P);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::CV2D::PointFromPoint2D Foam::CV2D::toPoint(const point2D& p) const
|
||||||
|
{
|
||||||
|
return reinterpret_cast<PointFromPoint2D>(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
inline Foam::CV2D::point2DFromPoint Foam::CV2D::toPoint2D(const Point& P) const
|
||||||
|
{
|
||||||
|
return point2D(CGAL::to_double(P.x()), CGAL::to_double(P.y()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::CV2D::PointFromPoint2D Foam::CV2D::toPoint(const point2D& p) const
|
||||||
|
{
|
||||||
|
return Point(p.x(), p.y());
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::point Foam::CV2D::toPoint3D(const Point& P) const
|
||||||
|
{
|
||||||
|
return point(CGAL::to_double(P.x()), CGAL::to_double(P.y()), z_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline void Foam::CV2D::movePoint(const Vertex_handle& vh, const Point& P)
|
||||||
|
{
|
||||||
|
int i = vh->index();
|
||||||
|
int t = vh->type();
|
||||||
|
|
||||||
|
remove(vh);
|
||||||
|
|
||||||
|
Vertex_handle newVh = insert(P);
|
||||||
|
|
||||||
|
newVh->index() = i;
|
||||||
|
newVh->type() = t;
|
||||||
|
|
||||||
|
// label i = vh->index();
|
||||||
|
// move(vh, P);
|
||||||
|
// vh->index() = i;
|
||||||
|
|
||||||
|
//vh->set_point(P);
|
||||||
|
//fast_restore_Delaunay(vh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::boundaryTriangle(const CV2D::Face_handle fc)
|
||||||
|
{
|
||||||
|
return boundaryTriangle
|
||||||
|
(
|
||||||
|
*fc->vertex(0),
|
||||||
|
*fc->vertex(1),
|
||||||
|
*fc->vertex(2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::outsideTriangle(const CV2D::Face_handle fc)
|
||||||
|
{
|
||||||
|
return outsideTriangle
|
||||||
|
(
|
||||||
|
*fc->vertex(0),
|
||||||
|
*fc->vertex(1),
|
||||||
|
*fc->vertex(2)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
386
applications/utilities/mesh/generation/foamyHex2DMesh/CV2DIO.C
Normal file
386
applications/utilities/mesh/generation/foamyHex2DMesh/CV2DIO.C
Normal file
@ -0,0 +1,386 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::CV2D::writePoints(const fileName& fName, bool internalOnly) const
|
||||||
|
{
|
||||||
|
Info<< "Writing points to " << fName << nl << endl;
|
||||||
|
OFstream str(fName);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!internalOnly || vit->internalOrBoundaryPoint())
|
||||||
|
{
|
||||||
|
meshTools::writeOBJ(str, toPoint3D(vit->point()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::writeTriangles(const fileName& fName, bool internalOnly) const
|
||||||
|
{
|
||||||
|
Info<< "Writing triangles to " << fName << nl << endl;
|
||||||
|
OFstream str(fName);
|
||||||
|
|
||||||
|
labelList vertexMap(number_of_vertices(), -2);
|
||||||
|
label verti = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!internalOnly || !vit->farPoint())
|
||||||
|
{
|
||||||
|
vertexMap[vit->index()] = verti++;
|
||||||
|
meshTools::writeOBJ(str, toPoint3D(vit->point()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_faces_iterator fit = finite_faces_begin();
|
||||||
|
fit != finite_faces_end();
|
||||||
|
++fit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!internalOnly
|
||||||
|
|| (
|
||||||
|
fit->vertex(0)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(1)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(2)->internalOrBoundaryPoint()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
str << "f";
|
||||||
|
for (label i = 0; i < 3; ++i)
|
||||||
|
{
|
||||||
|
str << " " << vertexMap[fit->vertex(i)->index()] + 1;
|
||||||
|
}
|
||||||
|
str << nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::writeFaces(const fileName& fName, bool internalOnly) const
|
||||||
|
{
|
||||||
|
Info<< "Writing dual faces to " << fName << nl << endl;
|
||||||
|
OFstream str(fName);
|
||||||
|
|
||||||
|
label dualVerti = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_faces_iterator fit = finite_faces_begin();
|
||||||
|
fit != finite_faces_end();
|
||||||
|
++fit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!internalOnly
|
||||||
|
|| (
|
||||||
|
fit->vertex(0)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(1)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(2)->internalOrBoundaryPoint()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fit->faceIndex() = dualVerti++;
|
||||||
|
meshTools::writeOBJ(str, toPoint3D(circumcenter(fit)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fit->faceIndex() = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!internalOnly || vit->internalOrBoundaryPoint())
|
||||||
|
{
|
||||||
|
Face_circulator fcStart = incident_faces(vit);
|
||||||
|
Face_circulator fc = fcStart;
|
||||||
|
|
||||||
|
str<< 'f';
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!is_infinite(fc))
|
||||||
|
{
|
||||||
|
if (fc->faceIndex() < 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::CV2D::writeFaces"
|
||||||
|
"(const fileName& fName, bool internalOnly)"
|
||||||
|
)<< "Dual face uses vertex defined by a triangle"
|
||||||
|
" defined by an external point"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
str<< ' ' << fc->faceIndex() + 1;
|
||||||
|
}
|
||||||
|
} while (++fc != fcStart);
|
||||||
|
|
||||||
|
str<< nl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::extractPatches
|
||||||
|
(
|
||||||
|
wordList& patchNames,
|
||||||
|
labelList& patchSizes,
|
||||||
|
EdgeMap<label>& mapEdgesRegion,
|
||||||
|
EdgeMap<label>& indirectPatchEdge
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
label nPatches = qSurf_.patchNames().size() + 1;
|
||||||
|
label defaultPatchIndex = qSurf_.patchNames().size();
|
||||||
|
|
||||||
|
patchNames.setSize(nPatches);
|
||||||
|
patchSizes.setSize(nPatches, 0);
|
||||||
|
mapEdgesRegion.clear();
|
||||||
|
|
||||||
|
const wordList& existingPatches = qSurf_.patchNames();
|
||||||
|
|
||||||
|
forAll(existingPatches, sP)
|
||||||
|
{
|
||||||
|
patchNames[sP] = existingPatches[sP];
|
||||||
|
}
|
||||||
|
|
||||||
|
patchNames[defaultPatchIndex] = "CV2D_default_patch";
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||||
|
eit != finite_edges_end();
|
||||||
|
++eit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Face_handle fOwner = eit->first;
|
||||||
|
Face_handle fNeighbor = fOwner->neighbor(eit->second);
|
||||||
|
|
||||||
|
Vertex_handle vA = fOwner->vertex(cw(eit->second));
|
||||||
|
Vertex_handle vB = fOwner->vertex(ccw(eit->second));
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
(vA->internalOrBoundaryPoint() && !vB->internalOrBoundaryPoint())
|
||||||
|
|| (vB->internalOrBoundaryPoint() && !vA->internalOrBoundaryPoint())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
point ptA = toPoint3D(vA->point());
|
||||||
|
point ptB = toPoint3D(vB->point());
|
||||||
|
|
||||||
|
label patchIndex = qSurf_.findPatch(ptA, ptB);
|
||||||
|
|
||||||
|
if (patchIndex == -1)
|
||||||
|
{
|
||||||
|
patchIndex = defaultPatchIndex;
|
||||||
|
|
||||||
|
WarningIn("Foam::CV2D::extractPatches")
|
||||||
|
<< "Dual face found that is not on a surface "
|
||||||
|
<< "patch. Adding to CV2D_default_patch."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
edge e(fOwner->faceIndex(), fNeighbor->faceIndex());
|
||||||
|
patchSizes[patchIndex]++;
|
||||||
|
mapEdgesRegion.insert(e, patchIndex);
|
||||||
|
|
||||||
|
if (!pointPair(*vA, *vB))
|
||||||
|
{
|
||||||
|
indirectPatchEdge.insert(e, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::calcDual
|
||||||
|
(
|
||||||
|
point2DField& dualPoints,
|
||||||
|
faceList& dualFaces,
|
||||||
|
wordList& patchNames,
|
||||||
|
labelList& patchSizes,
|
||||||
|
EdgeMap<label>& mapEdgesRegion,
|
||||||
|
EdgeMap<label>& indirectPatchEdge
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Dual points stored in triangle order.
|
||||||
|
dualPoints.setSize(number_of_faces());
|
||||||
|
label dualVerti = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_faces_iterator fit = finite_faces_begin();
|
||||||
|
fit != finite_faces_end();
|
||||||
|
++fit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
fit->vertex(0)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(1)->internalOrBoundaryPoint()
|
||||||
|
|| fit->vertex(2)->internalOrBoundaryPoint()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
fit->faceIndex() = dualVerti;
|
||||||
|
|
||||||
|
dualPoints[dualVerti++] = toPoint2D(circumcenter(fit));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fit->faceIndex() = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dualPoints.setSize(dualVerti);
|
||||||
|
|
||||||
|
extractPatches(patchNames, patchSizes, mapEdgesRegion, indirectPatchEdge);
|
||||||
|
|
||||||
|
forAll(patchNames, patchI)
|
||||||
|
{
|
||||||
|
Info<< "Patch " << patchNames[patchI]
|
||||||
|
<< " has size " << patchSizes[patchI] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create dual faces
|
||||||
|
// ~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
dualFaces.setSize(number_of_vertices());
|
||||||
|
label dualFacei = 0;
|
||||||
|
labelList faceVerts(maxNvert);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->internalOrBoundaryPoint())
|
||||||
|
{
|
||||||
|
Face_circulator fcStart = incident_faces(vit);
|
||||||
|
Face_circulator fc = fcStart;
|
||||||
|
label verti = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!is_infinite(fc))
|
||||||
|
{
|
||||||
|
if (fc->faceIndex() < 0)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::CV2D::calcDual"
|
||||||
|
"(point2DField& dualPoints, faceList& dualFaces)"
|
||||||
|
)<< "Dual face uses vertex defined by a triangle"
|
||||||
|
" defined by an external point"
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Look up the index of the triangle
|
||||||
|
faceVerts[verti++] = fc->faceIndex();
|
||||||
|
}
|
||||||
|
} while (++fc != fcStart);
|
||||||
|
|
||||||
|
if (faceVerts.size() > 2)
|
||||||
|
{
|
||||||
|
dualFaces[dualFacei++] =
|
||||||
|
face(labelList::subList(faceVerts, verti));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "From triangle point:" << vit->index()
|
||||||
|
<< " coord:" << toPoint2D(vit->point())
|
||||||
|
<< " generated illegal dualFace:" << faceVerts
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dualFaces.setSize(dualFacei);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::writePatch(const fileName& fName) const
|
||||||
|
{
|
||||||
|
point2DField dual2DPoints;
|
||||||
|
faceList dualFaces;
|
||||||
|
wordList patchNames;
|
||||||
|
labelList patchSizes;
|
||||||
|
EdgeMap<label> mapEdgesRegion;
|
||||||
|
EdgeMap<label> indirectPatchEdge;
|
||||||
|
|
||||||
|
calcDual
|
||||||
|
(
|
||||||
|
dual2DPoints,
|
||||||
|
dualFaces,
|
||||||
|
patchNames,
|
||||||
|
patchSizes,
|
||||||
|
mapEdgesRegion,
|
||||||
|
indirectPatchEdge
|
||||||
|
);
|
||||||
|
|
||||||
|
pointField dualPoints(dual2DPoints.size());
|
||||||
|
forAll(dualPoints, ip)
|
||||||
|
{
|
||||||
|
dualPoints[ip] = toPoint3D(dual2DPoints[ip]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dump as primitive patch to be read by extrudeMesh.
|
||||||
|
OFstream str(fName);
|
||||||
|
|
||||||
|
Info<< "Writing patch to be used with extrudeMesh to file " << fName
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
str << dualPoints << nl << dualFaces << nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
12
applications/utilities/mesh/generation/foamyHex2DMesh/Make/files
Executable file
12
applications/utilities/mesh/generation/foamyHex2DMesh/Make/files
Executable file
@ -0,0 +1,12 @@
|
|||||||
|
#include CGAL_FILES
|
||||||
|
|
||||||
|
CV2D.C
|
||||||
|
insertFeaturePoints.C
|
||||||
|
insertSurfaceNearestPointPairs.C
|
||||||
|
insertSurfaceNearPointPairs.C
|
||||||
|
insertBoundaryConformPointPairs.C
|
||||||
|
CV2DIO.C
|
||||||
|
shortEdgeFilter2D.C
|
||||||
|
foamyHex2DMesh.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/foamyHex2DMesh
|
||||||
43
applications/utilities/mesh/generation/foamyHex2DMesh/Make/options
Executable file
43
applications/utilities/mesh/generation/foamyHex2DMesh/Make/options
Executable file
@ -0,0 +1,43 @@
|
|||||||
|
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||||
|
EXE_FROUNDING_MATH = -frounding-math
|
||||||
|
EXE_NDEBUG = -DNDEBUG
|
||||||
|
|
||||||
|
include $(GENERAL_RULES)/CGAL
|
||||||
|
FFLAGS = -DCGAL_FILES='"${CGAL_ARCH_PATH}/share/files"'
|
||||||
|
|
||||||
|
EXE_INC = \
|
||||||
|
${EXE_FROUNDING_MATH} \
|
||||||
|
${EXE_NDEBUG} \
|
||||||
|
${CGAL_INC} \
|
||||||
|
-I$(FOAM_APP)/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/lnInclude \
|
||||||
|
-I../cvMesh/vectorTools \
|
||||||
|
-IconformalVoronoi2DMesh/lnInclude \
|
||||||
|
-I$(FOAM_APP)/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/mesh/extrudeModel/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
$(CGAL_LIBS) \
|
||||||
|
-lboost_thread \
|
||||||
|
-lmpfr \
|
||||||
|
-lextrude2DMesh \
|
||||||
|
-lextrudeModel \
|
||||||
|
-lcv2DMesh \
|
||||||
|
-lconformalVoronoiMesh \
|
||||||
|
-lmeshTools \
|
||||||
|
-lsurfMesh \
|
||||||
|
-ledgeMesh \
|
||||||
|
-ltriSurface \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-ldecompositionMethods \
|
||||||
|
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
|
||||||
|
-lsampling \
|
||||||
|
-lfileFormats
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
cv2DControls/cv2DControls.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libcv2DMesh
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
EXE_INC =
|
||||||
|
|
||||||
|
LIB_LIBS =
|
||||||
@ -0,0 +1,154 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cv2DControls.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
Foam::cv2DControls::cv2DControls
|
||||||
|
(
|
||||||
|
const dictionary& controlDict,
|
||||||
|
const boundBox& bb
|
||||||
|
)
|
||||||
|
:
|
||||||
|
dict_(controlDict),
|
||||||
|
|
||||||
|
motionControl_(controlDict.subDict("motionControl")),
|
||||||
|
conformationControl_(controlDict.subDict("surfaceConformation")),
|
||||||
|
|
||||||
|
minCellSize_(readScalar(motionControl_.lookup("minCellSize"))),
|
||||||
|
minCellSize2_(Foam::sqr(minCellSize_)),
|
||||||
|
|
||||||
|
maxQuadAngle_(readScalar(conformationControl_.lookup("maxQuadAngle"))),
|
||||||
|
|
||||||
|
nearWallAlignedDist_
|
||||||
|
(
|
||||||
|
readScalar(motionControl_.lookup("nearWallAlignedDist"))*minCellSize_
|
||||||
|
),
|
||||||
|
nearWallAlignedDist2_(Foam::sqr(nearWallAlignedDist_)),
|
||||||
|
|
||||||
|
insertSurfaceNearestPointPairs_
|
||||||
|
(
|
||||||
|
conformationControl_.lookup("insertSurfaceNearestPointPairs")
|
||||||
|
),
|
||||||
|
mirrorPoints_(conformationControl_.lookup("mirrorPoints")),
|
||||||
|
insertSurfaceNearPointPairs_
|
||||||
|
(
|
||||||
|
conformationControl_.lookup("insertSurfaceNearPointPairs")
|
||||||
|
),
|
||||||
|
|
||||||
|
objOutput_(motionControl_.lookupOrDefault<Switch>("objOutput", false)),
|
||||||
|
|
||||||
|
meshedSurfaceOutput_
|
||||||
|
(
|
||||||
|
motionControl_.lookupOrDefault<Switch>("meshedSurfaceOutput", false)
|
||||||
|
),
|
||||||
|
|
||||||
|
randomiseInitialGrid_(conformationControl_.lookup("randomiseInitialGrid")),
|
||||||
|
randomPerturbation_
|
||||||
|
(
|
||||||
|
readScalar(conformationControl_.lookup("randomPerturbation"))
|
||||||
|
),
|
||||||
|
|
||||||
|
maxBoundaryConformingIter_
|
||||||
|
(
|
||||||
|
readLabel(conformationControl_.lookup("maxBoundaryConformingIter"))
|
||||||
|
),
|
||||||
|
|
||||||
|
span_
|
||||||
|
(
|
||||||
|
max(mag(bb.max().x()), mag(bb.min().x()))
|
||||||
|
+ max(mag(bb.max().y()), mag(bb.min().y()))
|
||||||
|
),
|
||||||
|
span2_(Foam::sqr(span_)),
|
||||||
|
|
||||||
|
minEdgeLen_
|
||||||
|
(
|
||||||
|
readScalar(conformationControl_.lookup("minEdgeLenCoeff"))
|
||||||
|
*minCellSize_
|
||||||
|
),
|
||||||
|
minEdgeLen2_(Foam::sqr(minEdgeLen_)),
|
||||||
|
|
||||||
|
maxNotchLen_
|
||||||
|
(
|
||||||
|
readScalar(conformationControl_.lookup("maxNotchLenCoeff"))
|
||||||
|
*minCellSize_
|
||||||
|
),
|
||||||
|
maxNotchLen2_(Foam::sqr(maxNotchLen_)),
|
||||||
|
|
||||||
|
minNearPointDist_
|
||||||
|
(
|
||||||
|
readScalar(conformationControl_.lookup("minNearPointDistCoeff"))
|
||||||
|
*minCellSize_
|
||||||
|
),
|
||||||
|
minNearPointDist2_(Foam::sqr(minNearPointDist_)),
|
||||||
|
|
||||||
|
ppDist_
|
||||||
|
(
|
||||||
|
readScalar(conformationControl_.lookup("pointPairDistanceCoeff"))
|
||||||
|
*minCellSize_
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cv2DControls::~cv2DControls()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cv2DControls::write(Ostream& os) const
|
||||||
|
{
|
||||||
|
os.indentLevel() = 1;
|
||||||
|
os.precision(2);
|
||||||
|
os.flags(ios_base::scientific);
|
||||||
|
|
||||||
|
os << nl << "Outputting CV2D Mesher controls:" << nl
|
||||||
|
<< token::BEGIN_BLOCK << nl
|
||||||
|
<< indent << "minCellSize2_ : " << minCellSize2_ << nl
|
||||||
|
<< indent << "span_ / span2_ : " << span_ << " / " << span2_ << nl
|
||||||
|
<< indent << "maxNotchLen2_ : " << maxNotchLen2_ << nl
|
||||||
|
<< indent << "minNearPointDist2_ : " << minNearPointDist2_ << nl
|
||||||
|
<< indent << "nearWallAlignedDist2_ : " << nearWallAlignedDist2_ << nl
|
||||||
|
<< indent << "ppDist_ : " << ppDist_ << nl
|
||||||
|
<< indent << "minEdgeLen2_ : " << minEdgeLen2_ << nl
|
||||||
|
<< token::END_BLOCK << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::Ostream& Foam::operator<<(Ostream& os, const cv2DControls& s)
|
||||||
|
{
|
||||||
|
s.write(os);
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,260 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cv2DControls
|
||||||
|
|
||||||
|
Description
|
||||||
|
Controls for the 2D CV mesh generator.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cv2DControls.C
|
||||||
|
cv2DControlsI.H
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cv2DControls_H
|
||||||
|
#define cv2DControls_H
|
||||||
|
|
||||||
|
#include "Switch.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "boundBox.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cv2DControls Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cv2DControls
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Description of data_
|
||||||
|
const dictionary& dict_;
|
||||||
|
|
||||||
|
const dictionary& motionControl_;
|
||||||
|
|
||||||
|
const dictionary& conformationControl_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cv2DControls(const cv2DControls&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cv2DControls&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Controls
|
||||||
|
|
||||||
|
//- Minimum cell size below which protusions through the surface are
|
||||||
|
// not split
|
||||||
|
scalar minCellSize_;
|
||||||
|
|
||||||
|
//- Square of minCellSize
|
||||||
|
scalar minCellSize2_;
|
||||||
|
|
||||||
|
//- Maximum quadrant angle allowed at a concave corner before
|
||||||
|
// additional "mitering" lines are added
|
||||||
|
scalar maxQuadAngle_;
|
||||||
|
|
||||||
|
//- Near-wall region where cells are aligned with the wall
|
||||||
|
scalar nearWallAlignedDist_;
|
||||||
|
|
||||||
|
//- Square of nearWallAlignedDist
|
||||||
|
scalar nearWallAlignedDist2_;
|
||||||
|
|
||||||
|
//- Insert near-boundary point mirror or point-pairs
|
||||||
|
Switch insertSurfaceNearestPointPairs_;
|
||||||
|
|
||||||
|
//- Mirror near-boundary points rather than insert point-pairs
|
||||||
|
Switch mirrorPoints_;
|
||||||
|
|
||||||
|
//- Insert point-pairs vor dual-cell vertices very near the surface
|
||||||
|
Switch insertSurfaceNearPointPairs_;
|
||||||
|
|
||||||
|
Switch objOutput_;
|
||||||
|
|
||||||
|
Switch meshedSurfaceOutput_;
|
||||||
|
|
||||||
|
Switch randomiseInitialGrid_;
|
||||||
|
|
||||||
|
scalar randomPerturbation_;
|
||||||
|
|
||||||
|
label maxBoundaryConformingIter_;
|
||||||
|
|
||||||
|
|
||||||
|
// Tolerances
|
||||||
|
|
||||||
|
//- Maximum cartesian span of the geometry
|
||||||
|
scalar span_;
|
||||||
|
|
||||||
|
//- Square of span
|
||||||
|
scalar span2_;
|
||||||
|
|
||||||
|
//- Minumum edge-length of the cell size below which protusions
|
||||||
|
// through the surface are not split
|
||||||
|
scalar minEdgeLen_;
|
||||||
|
|
||||||
|
//- Square of minEdgeLen
|
||||||
|
scalar minEdgeLen2_;
|
||||||
|
|
||||||
|
//- Maximum notch size below which protusions into the surface are
|
||||||
|
// not filled
|
||||||
|
scalar maxNotchLen_;
|
||||||
|
|
||||||
|
//- Square of maxNotchLen
|
||||||
|
scalar maxNotchLen2_;
|
||||||
|
|
||||||
|
//- The minimum distance alowed between a dual-cell vertex
|
||||||
|
// and the surface before a point-pair is introduced
|
||||||
|
scalar minNearPointDist_;
|
||||||
|
|
||||||
|
//- Square of minNearPoint
|
||||||
|
scalar minNearPointDist2_;
|
||||||
|
|
||||||
|
//- Distance between boundary conforming point-pairs
|
||||||
|
scalar ppDist_;
|
||||||
|
|
||||||
|
//- Square of ppDist
|
||||||
|
scalar ppDist2_;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
cv2DControls
|
||||||
|
(
|
||||||
|
const dictionary& controlDict,
|
||||||
|
const boundBox& bb
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~cv2DControls();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return the minimum cell size
|
||||||
|
inline scalar minCellSize() const;
|
||||||
|
|
||||||
|
//- Return the square of the minimum cell size
|
||||||
|
inline scalar minCellSize2() const;
|
||||||
|
|
||||||
|
//- Return the maximum quadrant angle
|
||||||
|
inline scalar maxQuadAngle() const;
|
||||||
|
|
||||||
|
//- Return number of layers to align with the nearest wall
|
||||||
|
inline scalar nearWallAlignedDist() const;
|
||||||
|
|
||||||
|
//- Return square of nearWallAlignedDist
|
||||||
|
inline scalar nearWallAlignedDist2() const;
|
||||||
|
|
||||||
|
//- Return insertSurfaceNearestPointPairs Switch
|
||||||
|
inline Switch insertSurfaceNearestPointPairs() const;
|
||||||
|
|
||||||
|
//- Return mirrorPoints Switch
|
||||||
|
inline Switch mirrorPoints() const;
|
||||||
|
|
||||||
|
//- Return insertSurfaceNearPointPairs Switch
|
||||||
|
inline Switch insertSurfaceNearPointPairs() const;
|
||||||
|
|
||||||
|
//- Return the objOutput Switch
|
||||||
|
inline Switch objOutput() const;
|
||||||
|
|
||||||
|
//- Return the meshedSurfaceOutput Switch
|
||||||
|
inline Switch meshedSurfaceOutput() const;
|
||||||
|
|
||||||
|
//- Return the randomise initial point layout Switch
|
||||||
|
inline Switch randomiseInitialGrid() const;
|
||||||
|
|
||||||
|
//- Return the random perturbation factor
|
||||||
|
inline scalar randomPerturbation() const;
|
||||||
|
|
||||||
|
//- Return the maximum number of boundary conformation iterations
|
||||||
|
inline label maxBoundaryConformingIter() const;
|
||||||
|
|
||||||
|
//- Return the span
|
||||||
|
inline scalar span() const;
|
||||||
|
|
||||||
|
//- Return the span squared
|
||||||
|
inline scalar span2() const;
|
||||||
|
|
||||||
|
//- Return the minEdgeLen
|
||||||
|
inline scalar minEdgeLen() const;
|
||||||
|
|
||||||
|
//- Return the minEdgeLen squared
|
||||||
|
inline scalar minEdgeLen2() const;
|
||||||
|
|
||||||
|
//- Return the maxNotchLen
|
||||||
|
inline scalar maxNotchLen() const;
|
||||||
|
|
||||||
|
//- Return the maxNotchLen squared
|
||||||
|
inline scalar maxNotchLen2() const;
|
||||||
|
|
||||||
|
//- Return the minNearPointDist
|
||||||
|
inline scalar minNearPointDist() const;
|
||||||
|
|
||||||
|
//- Return the minNearPointDist squared
|
||||||
|
inline scalar minNearPointDist2() const;
|
||||||
|
|
||||||
|
//- Return the ppDist
|
||||||
|
inline scalar ppDist() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- Write controls to output stream.
|
||||||
|
void write(Ostream& os) const;
|
||||||
|
|
||||||
|
//- Ostream Operator
|
||||||
|
friend Ostream& operator<<
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const cv2DControls& s
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "cv2DControlsI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minCellSize() const
|
||||||
|
{
|
||||||
|
return minCellSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minCellSize2() const
|
||||||
|
{
|
||||||
|
return minCellSize2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::maxQuadAngle() const
|
||||||
|
{
|
||||||
|
return maxQuadAngle_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::nearWallAlignedDist() const
|
||||||
|
{
|
||||||
|
return nearWallAlignedDist_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::nearWallAlignedDist2() const
|
||||||
|
{
|
||||||
|
return nearWallAlignedDist2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::insertSurfaceNearestPointPairs() const
|
||||||
|
{
|
||||||
|
return insertSurfaceNearestPointPairs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::mirrorPoints() const
|
||||||
|
{
|
||||||
|
return mirrorPoints_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::insertSurfaceNearPointPairs() const
|
||||||
|
{
|
||||||
|
return insertSurfaceNearPointPairs_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::objOutput() const
|
||||||
|
{
|
||||||
|
return objOutput_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::meshedSurfaceOutput() const
|
||||||
|
{
|
||||||
|
return meshedSurfaceOutput_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::Switch Foam::cv2DControls::randomiseInitialGrid() const
|
||||||
|
{
|
||||||
|
return randomiseInitialGrid_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::randomPerturbation() const
|
||||||
|
{
|
||||||
|
return randomPerturbation_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::label Foam::cv2DControls::maxBoundaryConformingIter() const
|
||||||
|
{
|
||||||
|
return maxBoundaryConformingIter_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::span() const
|
||||||
|
{
|
||||||
|
return span_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::span2() const
|
||||||
|
{
|
||||||
|
return span2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minEdgeLen() const
|
||||||
|
{
|
||||||
|
return minEdgeLen_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minEdgeLen2() const
|
||||||
|
{
|
||||||
|
return minEdgeLen2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::maxNotchLen() const
|
||||||
|
{
|
||||||
|
return maxNotchLen_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::maxNotchLen2() const
|
||||||
|
{
|
||||||
|
return maxNotchLen2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minNearPointDist() const
|
||||||
|
{
|
||||||
|
return minNearPointDist_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::minNearPointDist2() const
|
||||||
|
{
|
||||||
|
return minNearPointDist2_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::scalar Foam::cv2DControls::ppDist() const
|
||||||
|
{
|
||||||
|
return ppDist_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,230 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
foamyHex2DMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
Conformal-Voronoi 2D extruding automatic mesher with grid or read
|
||||||
|
initial points and point position relaxation with optional
|
||||||
|
"squarification".
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
#include "argList.H"
|
||||||
|
|
||||||
|
#include "MeshedSurfaces.H"
|
||||||
|
#include "shortEdgeFilter2D.H"
|
||||||
|
#include "extrude2DMesh.H"
|
||||||
|
#include "polyMesh.H"
|
||||||
|
#include "patchToPoly2DMesh.H"
|
||||||
|
#include "extrudeModel.H"
|
||||||
|
#include "polyTopoChange.H"
|
||||||
|
#include "edgeCollapser.H"
|
||||||
|
#include "globalIndex.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
argList::noParallel();
|
||||||
|
argList::validArgs.clear();
|
||||||
|
argList::validOptions.insert
|
||||||
|
(
|
||||||
|
"pointsFile",
|
||||||
|
"filename"
|
||||||
|
);
|
||||||
|
|
||||||
|
#include "addOverwriteOption.H"
|
||||||
|
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
|
||||||
|
// Read control dictionary
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
IOdictionary controlDict
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
args.executable() + "Dict",
|
||||||
|
runTime.system(),
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ_IF_MODIFIED,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const dictionary& shortEdgeFilterDict
|
||||||
|
(
|
||||||
|
controlDict.subDict("shortEdgeFilter")
|
||||||
|
);
|
||||||
|
const dictionary& extrusionDict(controlDict.subDict("extrusion"));
|
||||||
|
|
||||||
|
Switch extrude(extrusionDict.lookup("extrude"));
|
||||||
|
const bool overwrite = args.optionFound("overwrite");
|
||||||
|
|
||||||
|
// Read and triangulation
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
CV2D mesh(runTime, controlDict);
|
||||||
|
|
||||||
|
if (args.options().found("pointsFile"))
|
||||||
|
{
|
||||||
|
fileName pointFileName(IStringStream(args.options()["pointsFile"])());
|
||||||
|
mesh.insertPoints(pointFileName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mesh.insertGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.insertSurfacePointPairs();
|
||||||
|
mesh.boundaryConform();
|
||||||
|
|
||||||
|
while (runTime.loop())
|
||||||
|
{
|
||||||
|
Info<< nl << "Time = " << runTime.timeName() << endl;
|
||||||
|
|
||||||
|
mesh.newPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.write();
|
||||||
|
|
||||||
|
Info<< "Finished Delaunay in = " << runTime.cpuTimeIncrement() << " s."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
Info<< "Begin filtering short edges:" << endl;
|
||||||
|
shortEdgeFilter2D sef(mesh, shortEdgeFilterDict);
|
||||||
|
|
||||||
|
sef.filter();
|
||||||
|
|
||||||
|
Info<< "Meshed surface after edge filtering :" << endl;
|
||||||
|
sef.fMesh().writeStats(Info);
|
||||||
|
|
||||||
|
if (mesh.meshControls().meshedSurfaceOutput())
|
||||||
|
{
|
||||||
|
Info<< "Write .obj file of the 2D mesh: MeshedSurface.obj" << endl;
|
||||||
|
sef.fMesh().write("MeshedSurface.obj");
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "Finished filtering in = " << runTime.cpuTimeIncrement() << " s."
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
Info<< "Begin constructing a polyMesh:" << endl;
|
||||||
|
|
||||||
|
patchToPoly2DMesh poly2DMesh
|
||||||
|
(
|
||||||
|
sef.fMesh(),
|
||||||
|
sef.patchNames(),
|
||||||
|
sef.patchSizes(),
|
||||||
|
sef.mapEdgesRegion()
|
||||||
|
);
|
||||||
|
|
||||||
|
poly2DMesh.createMesh();
|
||||||
|
|
||||||
|
polyMesh pMesh
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
polyMesh::defaultRegion,
|
||||||
|
runTime.constant(),
|
||||||
|
runTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
),
|
||||||
|
xferMove(poly2DMesh.points()),
|
||||||
|
xferMove(poly2DMesh.faces()),
|
||||||
|
xferMove(poly2DMesh.owner()),
|
||||||
|
xferMove(poly2DMesh.neighbour())
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Constructing patches." << endl;
|
||||||
|
List<polyPatch*> patches(poly2DMesh.patchNames().size());
|
||||||
|
label countPatches = 0;
|
||||||
|
|
||||||
|
forAll(patches, patchI)
|
||||||
|
{
|
||||||
|
if (poly2DMesh.patchSizes()[patchI] != 0)
|
||||||
|
{
|
||||||
|
patches[countPatches] = new polyPatch
|
||||||
|
(
|
||||||
|
poly2DMesh.patchNames()[patchI],
|
||||||
|
poly2DMesh.patchSizes()[patchI],
|
||||||
|
poly2DMesh.patchStarts()[patchI],
|
||||||
|
countPatches,
|
||||||
|
pMesh.boundaryMesh(),
|
||||||
|
word::null
|
||||||
|
);
|
||||||
|
|
||||||
|
countPatches++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
patches.setSize(countPatches);
|
||||||
|
pMesh.addPatches(patches);
|
||||||
|
|
||||||
|
if (extrude)
|
||||||
|
{
|
||||||
|
Info<< "Begin extruding the polyMesh:" << endl;
|
||||||
|
|
||||||
|
{
|
||||||
|
// Point generator
|
||||||
|
autoPtr<extrudeModel> model(extrudeModel::New(extrusionDict));
|
||||||
|
|
||||||
|
extrude2DMesh extruder(pMesh, extrusionDict, model());
|
||||||
|
|
||||||
|
extruder.addFrontBackPatches();
|
||||||
|
|
||||||
|
polyTopoChange meshMod(pMesh.boundaryMesh().size());
|
||||||
|
|
||||||
|
extruder.setRefinement(meshMod);
|
||||||
|
|
||||||
|
autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(pMesh, false);
|
||||||
|
|
||||||
|
pMesh.updateMesh(morphMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!overwrite)
|
||||||
|
{
|
||||||
|
runTime++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pMesh.setInstance("constant");
|
||||||
|
}
|
||||||
|
|
||||||
|
pMesh.write();
|
||||||
|
|
||||||
|
Info<< "Finished extruding in = "
|
||||||
|
<< runTime.cpuTimeIncrement() << " s." << endl;
|
||||||
|
|
||||||
|
Info<< nl << "End\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,202 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: dev |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.org |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object foamyHex2DMeshDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
geometry
|
||||||
|
{
|
||||||
|
laurence_clean_preciser.stl
|
||||||
|
{
|
||||||
|
name laurence_clean_preciser;
|
||||||
|
type closedTriSurfaceMesh;
|
||||||
|
//type triSurfaceMesh;
|
||||||
|
}
|
||||||
|
// refinementBox
|
||||||
|
// {
|
||||||
|
// type searchableBox;
|
||||||
|
// min (-0.5 0.35 -1000);
|
||||||
|
// max (-0.5 0.35 1000);
|
||||||
|
// }
|
||||||
|
// refinementSphere
|
||||||
|
// {
|
||||||
|
// type searchableSphere;
|
||||||
|
// centre (0.85 0.4 0.0);
|
||||||
|
// radius 0.01;
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
surfaceConformation
|
||||||
|
{
|
||||||
|
locationInMesh (-2.8 0.7 0.5);
|
||||||
|
|
||||||
|
pointPairDistanceCoeff 0.005;
|
||||||
|
|
||||||
|
minEdgeLenCoeff 0.005;
|
||||||
|
|
||||||
|
maxNotchLenCoeff 0.003;
|
||||||
|
|
||||||
|
minNearPointDistCoeff 0.0025;
|
||||||
|
|
||||||
|
maxQuadAngle 125;
|
||||||
|
|
||||||
|
// Insert near-boundary point mirror or point-pairs
|
||||||
|
insertSurfaceNearestPointPairs yes;
|
||||||
|
|
||||||
|
// Mirror near-boundary points rather than insert point-pairs
|
||||||
|
mirrorPoints no;
|
||||||
|
|
||||||
|
// Insert point-pairs vor dual-cell vertices very near the surface
|
||||||
|
insertSurfaceNearPointPairs yes;
|
||||||
|
|
||||||
|
// Maximum number of iterations used in boundaryConform.
|
||||||
|
maxBoundaryConformingIter 5;
|
||||||
|
|
||||||
|
geometryToConformTo
|
||||||
|
{
|
||||||
|
laurence_clean_preciser
|
||||||
|
{
|
||||||
|
featureMethod extendedFeatureEdgeMesh;
|
||||||
|
extendedFeatureEdgeMesh "laurence_clean_preciser.extendedFeatureEdgeMesh";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
additionalFeatures
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Choose if to randomise the initial grid created by insertGrid.
|
||||||
|
randomiseInitialGrid yes;
|
||||||
|
|
||||||
|
// Perturbation fraction, 1 = cell-size.
|
||||||
|
randomPerturbation 0.1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
motionControl
|
||||||
|
{
|
||||||
|
defaultCellSize 0.05;
|
||||||
|
|
||||||
|
// Assign a priority to all requests for cell sizes, the highest overrules.
|
||||||
|
defaultPriority 0;
|
||||||
|
|
||||||
|
cellSizeControlGeometry
|
||||||
|
{
|
||||||
|
laurence_clean_preciser
|
||||||
|
{
|
||||||
|
priority 1;
|
||||||
|
mode bothSides;
|
||||||
|
cellSizeFunction linearDistance;
|
||||||
|
linearDistanceCoeffs
|
||||||
|
{
|
||||||
|
distanceCellSize 0.05;
|
||||||
|
surfaceCellSize 0.01;
|
||||||
|
distance 0.5;
|
||||||
|
}
|
||||||
|
uniformCoeffs
|
||||||
|
{
|
||||||
|
cellSize 0.01;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// refinementBox
|
||||||
|
// {
|
||||||
|
// priority 1;
|
||||||
|
// mode outside;
|
||||||
|
// cellSizeFunction linearDistance;
|
||||||
|
// linearDistanceCoeffs
|
||||||
|
// {
|
||||||
|
// distanceCellSize 0.04;
|
||||||
|
// surfaceCellSize 0.005;
|
||||||
|
// distance 0.2;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// refinementSphere
|
||||||
|
// {
|
||||||
|
// priority 1;
|
||||||
|
// mode outside;
|
||||||
|
// cellSizeFunction linearDistance;
|
||||||
|
// linearDistanceCoeffs
|
||||||
|
// {
|
||||||
|
// distanceCellSize 0.04;
|
||||||
|
// surfaceCellSize 0.005;
|
||||||
|
// distance 0.2;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
relaxationModel adaptiveLinear;
|
||||||
|
|
||||||
|
adaptiveLinearCoeffs
|
||||||
|
{
|
||||||
|
relaxationStart 1.0;
|
||||||
|
relaxationEnd 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
objOutput no;
|
||||||
|
|
||||||
|
// Near-wall region where cells are aligned with the wall specified as a number
|
||||||
|
// of cell layers
|
||||||
|
nearWallAlignedDist 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
shortEdgeFilter
|
||||||
|
{
|
||||||
|
// Factor to multiply the average of a face's edge lengths by.
|
||||||
|
// If an edge of that face is smaller than that value then delete it.
|
||||||
|
shortEdgeFilterFactor 0.2;
|
||||||
|
|
||||||
|
// Weighting for the lengths of edges that are attached to the boundaries.
|
||||||
|
// Used when calculating the length of an edge. Default 2.0.
|
||||||
|
edgeAttachedToBoundaryFactor 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
extrusion
|
||||||
|
{
|
||||||
|
extrude on;
|
||||||
|
|
||||||
|
extrudeModel linearDirection;
|
||||||
|
//extrudeModel wedge;
|
||||||
|
|
||||||
|
patchInfo
|
||||||
|
{
|
||||||
|
//type empty;
|
||||||
|
//startFace
|
||||||
|
}
|
||||||
|
|
||||||
|
patchType empty;
|
||||||
|
//patchType wedge;
|
||||||
|
|
||||||
|
nLayers 1;
|
||||||
|
|
||||||
|
expansionRatio 1.0; //0.9;
|
||||||
|
|
||||||
|
linearDirectionCoeffs
|
||||||
|
{
|
||||||
|
direction (0 0 1);
|
||||||
|
thickness 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wedgeCoeffs
|
||||||
|
{
|
||||||
|
axisPt (0 0 0);
|
||||||
|
axis (1 0 0);
|
||||||
|
angle 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
thickness 0.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,135 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
indexedFace
|
||||||
|
|
||||||
|
Description
|
||||||
|
An indexed form of CGAL::Triangulation_face_base_2<K> used to keep
|
||||||
|
track of the vertices in the triangulation.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef indexedFace_H
|
||||||
|
#define indexedFace_H
|
||||||
|
|
||||||
|
#include <CGAL/Triangulation_2.h>
|
||||||
|
#include "indexedVertex.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class indexedFace Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Gt, class Fb=CGAL::Triangulation_face_base_2<Gt> >
|
||||||
|
class indexedFace
|
||||||
|
:
|
||||||
|
public Fb
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The index for this triangle face
|
||||||
|
// -1: triangle and changed and associated data needs updating
|
||||||
|
// >=0: index of triangles, set by external update algorithm
|
||||||
|
int index_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum faceTypes
|
||||||
|
{
|
||||||
|
UNCHANGED = 0,
|
||||||
|
CHANGED = -1,
|
||||||
|
SAVE_CHANGED = -2
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef typename Fb::Vertex_handle Vertex_handle;
|
||||||
|
typedef typename Fb::Face_handle Face_handle;
|
||||||
|
|
||||||
|
template<typename TDS2>
|
||||||
|
struct Rebind_TDS
|
||||||
|
{
|
||||||
|
typedef typename Fb::template Rebind_TDS<TDS2>::Other Fb2;
|
||||||
|
typedef indexedFace<Gt, Fb2> Other;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
inline indexedFace();
|
||||||
|
|
||||||
|
inline indexedFace
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2
|
||||||
|
);
|
||||||
|
|
||||||
|
inline indexedFace
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2,
|
||||||
|
Face_handle n0,
|
||||||
|
Face_handle n1,
|
||||||
|
Face_handle n2
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
inline void set_vertex(int i, Vertex_handle v);
|
||||||
|
|
||||||
|
inline void set_vertices();
|
||||||
|
|
||||||
|
inline void set_vertices
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2
|
||||||
|
);
|
||||||
|
|
||||||
|
inline int& faceIndex();
|
||||||
|
|
||||||
|
inline int faceIndex() const;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace CGAL
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "indexedFaceI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,110 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline CGAL::indexedFace<Gt, Fb>::indexedFace()
|
||||||
|
:
|
||||||
|
Fb(),
|
||||||
|
index_(CHANGED)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline CGAL::indexedFace<Gt, Fb>::indexedFace
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Fb(v0, v1, v2),
|
||||||
|
index_(CHANGED)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline CGAL::indexedFace<Gt, Fb>::indexedFace
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2,
|
||||||
|
Face_handle n0,
|
||||||
|
Face_handle n1,
|
||||||
|
Face_handle n2
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Fb(v0, v1, v2, n0, n1, n2),
|
||||||
|
index_(CHANGED)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline void CGAL::indexedFace<Gt, Fb>::set_vertex(int i, Vertex_handle v)
|
||||||
|
{
|
||||||
|
index_ = CHANGED;
|
||||||
|
Fb::set_vertex(i, v);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline void CGAL::indexedFace<Gt, Fb>::set_vertices()
|
||||||
|
{
|
||||||
|
index_ = CHANGED;
|
||||||
|
Fb::set_vertices();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline void CGAL::indexedFace<Gt, Fb>::set_vertices
|
||||||
|
(
|
||||||
|
Vertex_handle v0,
|
||||||
|
Vertex_handle v1,
|
||||||
|
Vertex_handle v2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
index_ = CHANGED;
|
||||||
|
Fb::set_vertices(v0, v1, v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline int& CGAL::indexedFace<Gt, Fb>::faceIndex()
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Fb>
|
||||||
|
inline int CGAL::indexedFace<Gt, Fb>::faceIndex() const
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -0,0 +1,210 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
indexedVertex
|
||||||
|
|
||||||
|
Description
|
||||||
|
An indexed form of CGAL::Triangulation_vertex_base_2<K> used to keep
|
||||||
|
track of the vertices in the triangulation.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef indexedVertex_H
|
||||||
|
#define indexedVertex_H
|
||||||
|
|
||||||
|
#include <CGAL/Triangulation_2.h>
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace CGAL
|
||||||
|
{
|
||||||
|
|
||||||
|
// Forward declaration of friend functions and operators
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
class indexedVertex;
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool pointPair
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool boundaryTriangle
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool outsideTriangle
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
);
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class indexedVertex Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Gt, class Vb=CGAL::Triangulation_vertex_base_2<Gt> >
|
||||||
|
class indexedVertex
|
||||||
|
:
|
||||||
|
public Vb
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- The index for this triangle vertex
|
||||||
|
int index_;
|
||||||
|
|
||||||
|
//- Index of pair-point :
|
||||||
|
// NEAR_BOUNDARY_POINT : internal near boundary point.
|
||||||
|
// INTERNAL_POINT : internal point.
|
||||||
|
// FAR_POINT : far-point.
|
||||||
|
// >= 0 : part of point-pair. Index of other point.
|
||||||
|
// Lowest numbered is inside one (master).
|
||||||
|
int type_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum pointTypes
|
||||||
|
{
|
||||||
|
NEAR_BOUNDARY_POINT = -4,
|
||||||
|
INTERNAL_POINT = -3,
|
||||||
|
MIRROR_POINT = -2,
|
||||||
|
FAR_POINT = -1
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef typename Vb::Vertex_handle Vertex_handle;
|
||||||
|
typedef typename Vb::Face_handle Face_handle;
|
||||||
|
typedef typename Vb::Point Point;
|
||||||
|
|
||||||
|
template<typename TDS2>
|
||||||
|
struct Rebind_TDS
|
||||||
|
{
|
||||||
|
typedef typename Vb::template Rebind_TDS<TDS2>::Other Vb2;
|
||||||
|
typedef indexedVertex<Gt,Vb2> Other;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
inline indexedVertex();
|
||||||
|
|
||||||
|
inline indexedVertex(const Point& p);
|
||||||
|
|
||||||
|
inline indexedVertex(const Point& p, const int index, const int& type);
|
||||||
|
|
||||||
|
inline indexedVertex(const Point& p, Face_handle f);
|
||||||
|
|
||||||
|
inline indexedVertex(Face_handle f);
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
inline int& index();
|
||||||
|
|
||||||
|
inline int index() const;
|
||||||
|
|
||||||
|
inline int& type();
|
||||||
|
|
||||||
|
inline int type() const;
|
||||||
|
|
||||||
|
//- Is point a far-point
|
||||||
|
inline bool farPoint() const;
|
||||||
|
|
||||||
|
//- Is point internal, i.e. not on boundary
|
||||||
|
inline bool internalPoint() const;
|
||||||
|
|
||||||
|
//- Is point internal and near the boundary
|
||||||
|
inline bool nearBoundary() const;
|
||||||
|
|
||||||
|
//- Set the point to be near the boundary
|
||||||
|
inline void setNearBoundary();
|
||||||
|
|
||||||
|
//- Is point a mirror point
|
||||||
|
inline bool mirrorPoint() const;
|
||||||
|
|
||||||
|
//- Either master or slave of pointPair.
|
||||||
|
inline bool pairPoint() const;
|
||||||
|
|
||||||
|
//- Master of a pointPair is the lowest numbered one.
|
||||||
|
inline bool ppMaster() const;
|
||||||
|
|
||||||
|
//- Slave of a pointPair is the highest numbered one.
|
||||||
|
inline bool ppSlave() const;
|
||||||
|
|
||||||
|
//- Either original internal point or master of pointPair.
|
||||||
|
inline bool internalOrBoundaryPoint() const;
|
||||||
|
|
||||||
|
//- Is point near the boundary or part of the boundary definition
|
||||||
|
inline bool nearOrOnBoundary() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Friend Functions
|
||||||
|
|
||||||
|
//- Do the two given vertices consitute a boundary point-pair
|
||||||
|
friend bool pointPair <Gt, Vb>
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Do the three given vertices consitute a boundary triangle
|
||||||
|
friend bool boundaryTriangle <Gt, Vb>
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Do the three given vertices consitute an outside triangle
|
||||||
|
friend bool outsideTriangle <Gt, Vb>
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace CGAL
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "indexedVertexI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,233 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex()
|
||||||
|
:
|
||||||
|
Vb(),
|
||||||
|
index_(INTERNAL_POINT),
|
||||||
|
type_(INTERNAL_POINT)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p)
|
||||||
|
:
|
||||||
|
Vb(p),
|
||||||
|
index_(INTERNAL_POINT),
|
||||||
|
type_(INTERNAL_POINT)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex
|
||||||
|
(
|
||||||
|
const Point& p,
|
||||||
|
const int index,
|
||||||
|
const int& type
|
||||||
|
)
|
||||||
|
:
|
||||||
|
Vb(p),
|
||||||
|
index_(index),
|
||||||
|
type_(type)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(const Point& p, Face_handle f)
|
||||||
|
:
|
||||||
|
Vb(f, p),
|
||||||
|
index_(INTERNAL_POINT),
|
||||||
|
type_(INTERNAL_POINT)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline CGAL::indexedVertex<Gt, Vb>::indexedVertex(Face_handle f)
|
||||||
|
:
|
||||||
|
Vb(f),
|
||||||
|
index_(INTERNAL_POINT),
|
||||||
|
type_(INTERNAL_POINT)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline int& CGAL::indexedVertex<Gt, Vb>::index()
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline int CGAL::indexedVertex<Gt, Vb>::index() const
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline int& CGAL::indexedVertex<Gt, Vb>::type()
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline int CGAL::indexedVertex<Gt, Vb>::type() const
|
||||||
|
{
|
||||||
|
return type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::farPoint() const
|
||||||
|
{
|
||||||
|
return type_ == FAR_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::internalPoint() const
|
||||||
|
{
|
||||||
|
return type_ <= INTERNAL_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::nearBoundary() const
|
||||||
|
{
|
||||||
|
return type_ == NEAR_BOUNDARY_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline void CGAL::indexedVertex<Gt, Vb>::setNearBoundary()
|
||||||
|
{
|
||||||
|
type_ = NEAR_BOUNDARY_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::mirrorPoint() const
|
||||||
|
{
|
||||||
|
return type_ == MIRROR_POINT;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::pairPoint() const
|
||||||
|
{
|
||||||
|
return type_ >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::ppMaster() const
|
||||||
|
{
|
||||||
|
if (type_ > index_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::ppSlave() const
|
||||||
|
{
|
||||||
|
if (type_ >= 0 && type_ < index_)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::internalOrBoundaryPoint() const
|
||||||
|
{
|
||||||
|
return internalPoint() || ppMaster();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
inline bool CGAL::indexedVertex<Gt, Vb>::nearOrOnBoundary() const
|
||||||
|
{
|
||||||
|
return pairPoint() || mirrorPoint() || nearBoundary();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool CGAL::pointPair
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return v0.index_ == v1.type_ || v1.index_ == v0.type_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool CGAL::boundaryTriangle
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (v0.pairPoint() && pointPair(v1, v2))
|
||||||
|
|| (v1.pairPoint() && pointPair(v2, v0))
|
||||||
|
|| (v2.pairPoint() && pointPair(v0, v1));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Gt, class Vb>
|
||||||
|
bool CGAL::outsideTriangle
|
||||||
|
(
|
||||||
|
const indexedVertex<Gt, Vb>& v0,
|
||||||
|
const indexedVertex<Gt, Vb>& v1,
|
||||||
|
const indexedVertex<Gt, Vb>& v2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return (v0.farPoint() || v0.ppSlave())
|
||||||
|
|| (v1.farPoint() || v1.ppSlave())
|
||||||
|
|| (v2.farPoint() || v2.ppSlave());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
@ -0,0 +1,323 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::CV2D::insertPointPair
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator& vit,
|
||||||
|
const point2D& p,
|
||||||
|
const label trii,
|
||||||
|
const label hitSurface
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!meshControls().mirrorPoints()
|
||||||
|
|| !insertMirrorPoint(toPoint2D(vit->point()), p)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointIndexHit pHit
|
||||||
|
(
|
||||||
|
true,
|
||||||
|
toPoint3D(p),
|
||||||
|
trii
|
||||||
|
);
|
||||||
|
|
||||||
|
vectorField norm(1);
|
||||||
|
qSurf_.geometry()[hitSurface].getNormal
|
||||||
|
(
|
||||||
|
List<pointIndexHit>(1, pHit),
|
||||||
|
norm
|
||||||
|
);
|
||||||
|
|
||||||
|
insertPointPair
|
||||||
|
(
|
||||||
|
meshControls().ppDist(),
|
||||||
|
p,
|
||||||
|
toPoint2D(norm[0])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
vit = Triangulation::Finite_vertices_iterator
|
||||||
|
(
|
||||||
|
CGAL::Filter_iterator
|
||||||
|
<
|
||||||
|
Triangulation::All_vertices_iterator,
|
||||||
|
Triangulation::Infinite_tester
|
||||||
|
>(finite_vertices_end(), vit.predicate(), vit.base())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::CV2D::insertPointPairAtIntersection
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator& vit,
|
||||||
|
const point2D& defVert,
|
||||||
|
const point2D vertices[],
|
||||||
|
const scalar maxProtSize2
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
point2D interPoint;
|
||||||
|
label interTri = -1;
|
||||||
|
label interHitSurface = -1;
|
||||||
|
scalar interDist2 = 0;
|
||||||
|
|
||||||
|
Face_circulator fcStart = incident_faces(vit);
|
||||||
|
Face_circulator fc = fcStart;
|
||||||
|
label vi = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!is_infinite(fc))
|
||||||
|
{
|
||||||
|
pointIndexHit pHit;
|
||||||
|
label hitSurface = -1;
|
||||||
|
|
||||||
|
qSurf_.findSurfaceNearestIntersection
|
||||||
|
(
|
||||||
|
toPoint3D(defVert),
|
||||||
|
toPoint3D(vertices[vi]),
|
||||||
|
pHit,
|
||||||
|
hitSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pHit.hit())
|
||||||
|
{
|
||||||
|
scalar dist2 =
|
||||||
|
magSqr(toPoint2D(pHit.hitPoint()) - vertices[vi]);
|
||||||
|
|
||||||
|
// Check the point is further away than the furthest so far
|
||||||
|
if (dist2 > interDist2)
|
||||||
|
{
|
||||||
|
scalar mps2 = maxProtSize2;
|
||||||
|
|
||||||
|
// If this is a boundary triangle reset the tolerance
|
||||||
|
// to avoid finding a hit point very close to a boundary
|
||||||
|
// vertex
|
||||||
|
if (boundaryTriangle(fc))
|
||||||
|
{
|
||||||
|
mps2 = meshControls().maxNotchLen2();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dist2 > mps2)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
interPoint = toPoint2D(pHit.hitPoint());
|
||||||
|
interTri = pHit.index();
|
||||||
|
interDist2 = dist2;
|
||||||
|
interHitSurface = hitSurface;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
vi++;
|
||||||
|
}
|
||||||
|
} while (++fc != fcStart);
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
insertPointPair(vit, interPoint, interTri, interHitSurface);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::CV2D::insertBoundaryConformPointPairs
|
||||||
|
(
|
||||||
|
const fileName& fName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label nIntersections = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
vit++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Consider only those points part of point-pairs or near boundary
|
||||||
|
if (!vit->nearOrOnBoundary())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Counter-clockwise circulator
|
||||||
|
Face_circulator fcStart = incident_faces(vit);
|
||||||
|
Face_circulator fc = fcStart;
|
||||||
|
|
||||||
|
bool infinite = false;
|
||||||
|
bool changed = false;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (is_infinite(fc))
|
||||||
|
{
|
||||||
|
infinite = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (fc->faceIndex() < Fb::UNCHANGED)
|
||||||
|
{
|
||||||
|
changed = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (++fc != fcStart);
|
||||||
|
|
||||||
|
// If the dual-cell is connected to the infinite point or none of the
|
||||||
|
// faces whose circumcentres it uses have changed ignore
|
||||||
|
if (infinite || !changed) continue;
|
||||||
|
|
||||||
|
fc = fcStart;
|
||||||
|
label nVerts = 0;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
vertices[nVerts++] = toPoint2D(circumcenter(fc));
|
||||||
|
|
||||||
|
if (nVerts == maxNvert)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (++fc != fcStart);
|
||||||
|
|
||||||
|
// Check if dual-cell has a large number of faces in which case
|
||||||
|
// assumed to be in the far-field and reject
|
||||||
|
if (nVerts == maxNvert) continue;
|
||||||
|
|
||||||
|
// Set n+1 vertex to the first vertex for easy circulating
|
||||||
|
vertices[nVerts] = vertices[0];
|
||||||
|
|
||||||
|
// Convert triangle vertex to OpenFOAM point
|
||||||
|
point2DFromPoint defVert = toPoint2D(vit->point());
|
||||||
|
|
||||||
|
scalar maxProtSize2 = meshControls().maxNotchLen2();
|
||||||
|
|
||||||
|
if (vit->internalOrBoundaryPoint())
|
||||||
|
{
|
||||||
|
// Calculate metrics of the dual-cell
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
// The perimeter of the dual-cell
|
||||||
|
scalar perimeter = 0;
|
||||||
|
|
||||||
|
// Twice the area of the dual-cell
|
||||||
|
scalar areaT2 = 0;
|
||||||
|
|
||||||
|
for (int vi=0; vi<nVerts; vi++)
|
||||||
|
{
|
||||||
|
vector2D edge(vertices[vi+1] - vertices[vi]);
|
||||||
|
perimeter += mag(edge);
|
||||||
|
vector2D otherEdge = defVert - vertices[vi];
|
||||||
|
areaT2 += mag(edge.x()*otherEdge.y() - edge.y()*otherEdge.x());
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the dual-cell is very small reject refinement
|
||||||
|
if (areaT2 < meshControls().minEdgeLen2()) continue;
|
||||||
|
|
||||||
|
// Estimate the cell width
|
||||||
|
scalar cellWidth = areaT2/perimeter;
|
||||||
|
|
||||||
|
|
||||||
|
// Check dimensions of dual-cell
|
||||||
|
/*
|
||||||
|
// Quick rejection of dual-cell refinement based on it's perimeter
|
||||||
|
if (perimeter < 2*meshControls().minCellSize()) continue;
|
||||||
|
|
||||||
|
// Also check the area of the cell and reject refinement
|
||||||
|
// if it is less than that allowed
|
||||||
|
if (areaT2 < meshControls().minCellSize2()) continue;
|
||||||
|
|
||||||
|
// Estimate the cell width and reject refinement if it is less than
|
||||||
|
// that allowed
|
||||||
|
if (cellWidth < 0.5*meshControls().minEdgeLen()) continue;
|
||||||
|
*/
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
perimeter > 2*meshControls().minCellSize()
|
||||||
|
&& areaT2 > meshControls().minCellSize2()
|
||||||
|
&& cellWidth > 0.5*meshControls().minEdgeLen()
|
||||||
|
)
|
||||||
|
{
|
||||||
|
maxProtSize2 = 0.25*meshControls().maxNotchLen2();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insertPointPairAtIntersection(vit, defVert, vertices, maxProtSize2))
|
||||||
|
{
|
||||||
|
nIntersections++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nIntersections;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::markNearBoundaryPoints()
|
||||||
|
{
|
||||||
|
label count = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
vit++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->internalPoint())
|
||||||
|
{
|
||||||
|
point vert(toPoint3D(vit->point()));
|
||||||
|
|
||||||
|
pointIndexHit pHit;
|
||||||
|
label hitSurface = -1;
|
||||||
|
|
||||||
|
qSurf_.findSurfaceNearest
|
||||||
|
(
|
||||||
|
vert,
|
||||||
|
4*meshControls().minCellSize2(),
|
||||||
|
pHit,
|
||||||
|
hitSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pHit.hit())
|
||||||
|
{
|
||||||
|
vit->setNearBoundary();
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< count << " points marked as being near a boundary" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,394 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
#include "plane.H"
|
||||||
|
#include "unitConversion.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::CV2D::on2DLine(const point2D& p, const linePointRef& line)
|
||||||
|
{
|
||||||
|
const point2D& a = toPoint2D(line.start());
|
||||||
|
const point2D& b = toPoint2D(line.end());
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
p.x() < min(a.x(), b.x())
|
||||||
|
|| p.x() > max(a.x(), b.x())
|
||||||
|
|| p.y() < min(a.y(), b.y())
|
||||||
|
|| p.y() > max(a.y(), b.y())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::insertFeaturePoints()
|
||||||
|
{
|
||||||
|
featurePoints_.clear();
|
||||||
|
label nVert = number_of_vertices();
|
||||||
|
|
||||||
|
const PtrList<extendedFeatureEdgeMesh>& feMeshes
|
||||||
|
(
|
||||||
|
qSurf_.features()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (feMeshes.empty())
|
||||||
|
{
|
||||||
|
WarningIn("CV2D::insertFeaturePoints")
|
||||||
|
<< "Extended Feature Edge Mesh is empty so no feature points will "
|
||||||
|
<< "be found." << nl
|
||||||
|
<< " Use: featureMethod extendedFeatureEdgeMesh;" << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(feMeshes, i)
|
||||||
|
{
|
||||||
|
const extendedFeatureEdgeMesh& feMesh(feMeshes[i]);
|
||||||
|
const edgeList& edges = feMesh.edges();
|
||||||
|
const pointField& points = feMesh.points();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
label nConvex = feMesh.concaveStart() - feMesh.convexStart();
|
||||||
|
label nConcave = feMesh.mixedStart() - feMesh.concaveStart();
|
||||||
|
label nMixed = feMesh.nonFeatureStart() - feMesh.mixedStart();
|
||||||
|
label nExternal = feMesh.internalStart() - feMesh.externalStart();
|
||||||
|
label nInternal = feMesh.flatStart() - feMesh.internalStart();
|
||||||
|
label nFlat = feMesh.openStart() - feMesh.flatStart();
|
||||||
|
label nOpen = feMesh.multipleStart() - feMesh.openStart();
|
||||||
|
label nMultiple = edges.size() - feMesh.multipleStart();
|
||||||
|
|
||||||
|
Info<< "Inserting Feature Points:" << nl
|
||||||
|
<< " Convex points: " << nConvex << nl
|
||||||
|
<< " Concave points: " << nConcave << nl
|
||||||
|
<< " Mixed points: " << nMixed << nl
|
||||||
|
<< " External edges: " << nExternal << nl
|
||||||
|
<< " Internal edges: " << nInternal << nl
|
||||||
|
<< " Flat edges: " << nFlat << nl
|
||||||
|
<< " Open edges: " << nOpen << nl
|
||||||
|
<< " Multiple edges: " << nMultiple << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Args: (base point, normal)
|
||||||
|
// @todo allow user to input this
|
||||||
|
plane zPlane(vector(0, 0, z_), vector(0, 0, 1));
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " plane: " << zPlane << " " << z_ << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(edges, edgeI)
|
||||||
|
{
|
||||||
|
const edge& e = feMesh.edges()[edgeI];
|
||||||
|
|
||||||
|
const point& ep0 = points[e.start()];
|
||||||
|
const point& ep1 = points[e.end()];
|
||||||
|
|
||||||
|
const linePointRef line(ep0, ep1);
|
||||||
|
|
||||||
|
scalar intersect = zPlane.lineIntersect(line);
|
||||||
|
|
||||||
|
point2D featPoint = toPoint2D(intersect * (ep1 - ep0) + ep0);
|
||||||
|
|
||||||
|
if (on2DLine(featPoint, line))
|
||||||
|
{
|
||||||
|
vector2DField fpn = toPoint2D(feMesh.edgeNormals(edgeI));
|
||||||
|
|
||||||
|
vector2D cornerNormal = sum(fpn);
|
||||||
|
cornerNormal /= mag(cornerNormal);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< nl << " line: " << line << nl
|
||||||
|
<< " vec: " << line.vec() << nl
|
||||||
|
<< " featurePoint: " << featPoint << nl
|
||||||
|
<< " line length: " << line.mag() << nl
|
||||||
|
<< " intersect: " << intersect << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
feMesh.getEdgeStatus(edgeI)
|
||||||
|
== extendedFeatureEdgeMesh::EXTERNAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Convex Point
|
||||||
|
Foam::point2D internalPt =
|
||||||
|
featPoint - meshControls().ppDist()*cornerNormal;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "PREC: " << internalPt << nl
|
||||||
|
<< " : " << featPoint << nl
|
||||||
|
<< " : " << meshControls().ppDist() << nl
|
||||||
|
<< " : " << cornerNormal << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(internalPt),
|
||||||
|
nVert,
|
||||||
|
nVert + 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
label masterPtIndex = nVert++;
|
||||||
|
|
||||||
|
forAll(fpn, nI)
|
||||||
|
{
|
||||||
|
const vector n3D(fpn[nI][0], fpn[nI][1], 0.0);
|
||||||
|
|
||||||
|
plane planeN = plane(toPoint3D(featPoint), n3D);
|
||||||
|
|
||||||
|
Foam::point2D externalPt =
|
||||||
|
internalPt
|
||||||
|
+ (
|
||||||
|
2.0
|
||||||
|
* planeN.distance(toPoint3D(internalPt))
|
||||||
|
* fpn[nI]
|
||||||
|
);
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(externalPt),
|
||||||
|
nVert++,
|
||||||
|
masterPtIndex
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " side point: " << externalPt << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Convex Point: " << featPoint << nl
|
||||||
|
<< " corner norm: " << cornerNormal << nl
|
||||||
|
<< " reference: " << internalPt << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
feMesh.getEdgeStatus(edgeI)
|
||||||
|
== extendedFeatureEdgeMesh::INTERNAL
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Concave Point
|
||||||
|
Foam::point2D externalPt =
|
||||||
|
featPoint + meshControls().ppDist()*cornerNormal;
|
||||||
|
|
||||||
|
Foam::point2D refPt =
|
||||||
|
featPoint - meshControls().ppDist()*cornerNormal;
|
||||||
|
|
||||||
|
label slavePointIndex = 0;
|
||||||
|
|
||||||
|
scalar totalAngle =
|
||||||
|
radToDeg
|
||||||
|
(
|
||||||
|
constant::mathematical::pi
|
||||||
|
+ acos(mag(fpn[0] & fpn[1]))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Number of quadrants the angle should be split into
|
||||||
|
int nQuads =
|
||||||
|
int(totalAngle/meshControls().maxQuadAngle()) + 1;
|
||||||
|
|
||||||
|
// The number of additional master points needed to
|
||||||
|
//obtain the required number of quadrants.
|
||||||
|
int nAddPoints = min(max(nQuads - 2, 0), 2);
|
||||||
|
|
||||||
|
// index of reflMaster
|
||||||
|
label reflectedMaster = nVert + 2 + nAddPoints;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Concave Point: " << featPoint << nl
|
||||||
|
<< " corner norm: " << cornerNormal << nl
|
||||||
|
<< " external: " << externalPt << nl
|
||||||
|
<< " reference: " << refPt << nl
|
||||||
|
<< " angle: " << totalAngle << nl
|
||||||
|
<< " nQuads: " << nQuads << nl
|
||||||
|
<< " nAddPoints: " << nAddPoints << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(fpn, nI)
|
||||||
|
{
|
||||||
|
const vector n3D(fpn[nI][0], fpn[nI][1], 0.0);
|
||||||
|
|
||||||
|
plane planeN = plane(toPoint3D(featPoint), n3D);
|
||||||
|
|
||||||
|
Foam::point2D internalPt =
|
||||||
|
externalPt
|
||||||
|
- (
|
||||||
|
2.0
|
||||||
|
* planeN.distance(toPoint3D(externalPt))
|
||||||
|
* fpn[nI]
|
||||||
|
);
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(internalPt),
|
||||||
|
nVert,
|
||||||
|
reflectedMaster
|
||||||
|
)
|
||||||
|
);
|
||||||
|
slavePointIndex = nVert++;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Internal Point: " << internalPt << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nAddPoints == 1)
|
||||||
|
{
|
||||||
|
// One additional point is the reflection of the slave
|
||||||
|
// point, i.e., the original reference point
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(refPt),
|
||||||
|
nVert++,
|
||||||
|
reflectedMaster
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "ref Point: " << refPt << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nAddPoints == 2)
|
||||||
|
{
|
||||||
|
point2D reflectedAa =
|
||||||
|
refPt - ((featPoint - externalPt) & fpn[1])*fpn[1];
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(reflectedAa),
|
||||||
|
nVert++,
|
||||||
|
reflectedMaster
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
point2D reflectedBb =
|
||||||
|
refPt - ((featPoint - externalPt) & fpn[0])*fpn[0];
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(reflectedBb),
|
||||||
|
nVert++,
|
||||||
|
reflectedMaster
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "refA Point: " << reflectedAa << nl
|
||||||
|
<< "refb Point: " << reflectedBb << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
featurePoints_.push_back
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint(externalPt),
|
||||||
|
nVert++,
|
||||||
|
slavePointIndex
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn("void Foam::CV2D::insertFeaturePoints()")
|
||||||
|
<< "Feature Edge " << edges[edgeI] << nl
|
||||||
|
<< " points(" << points[edges[edgeI].start()]
|
||||||
|
<< ", " << points[edges[edgeI].end()] << ")" << nl
|
||||||
|
<< " is not labelled as either concave or convex, it"
|
||||||
|
<< " is labelled as (#2 = flat): "
|
||||||
|
<< feMesh.getEdgeStatus(edgeI) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn("void Foam::CV2D::insertFeaturePoints()")
|
||||||
|
<< "Point " << featPoint << " is not on the line "
|
||||||
|
<< line << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the feature points.
|
||||||
|
reinsertFeaturePoints();
|
||||||
|
|
||||||
|
if (meshControls().objOutput())
|
||||||
|
{
|
||||||
|
writePoints("feat_allPoints.obj", false);
|
||||||
|
writeFaces("feat_allFaces.obj", false);
|
||||||
|
writeFaces("feat_faces.obj", true);
|
||||||
|
writeTriangles("feat_triangles.obj", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::reinsertFeaturePoints()
|
||||||
|
{
|
||||||
|
for
|
||||||
|
(
|
||||||
|
std::list<Vb>::iterator vit=featurePoints_.begin();
|
||||||
|
vit != featurePoints_.end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
insertPoint
|
||||||
|
(
|
||||||
|
toPoint2D(vit->point()),
|
||||||
|
vit->index(),
|
||||||
|
vit->type()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,114 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::CV2D::insertSurfaceNearPointPairs()
|
||||||
|
{
|
||||||
|
Info<< "insertSurfaceNearPointPairs: ";
|
||||||
|
|
||||||
|
label nNearPoints = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_edges_iterator eit = finite_edges_begin();
|
||||||
|
eit != finite_edges_end();
|
||||||
|
eit++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Vertex_handle v0h = eit->first->vertex(cw(eit->second));
|
||||||
|
Vertex_handle v1h = eit->first->vertex(ccw(eit->second));
|
||||||
|
|
||||||
|
if (v0h->ppMaster() && v1h->ppMaster())
|
||||||
|
{
|
||||||
|
point2DFromPoint v0(toPoint2D(v0h->point()));
|
||||||
|
point2DFromPoint v1(toPoint2D(v1h->point()));
|
||||||
|
|
||||||
|
// Check that the two triangle vertices are further apart than the
|
||||||
|
// minimum cell size
|
||||||
|
if (magSqr(v1 - v0) > meshControls().minCellSize2())
|
||||||
|
{
|
||||||
|
point2D e0(toPoint2D(circumcenter(eit->first)));
|
||||||
|
|
||||||
|
point2D e1
|
||||||
|
(
|
||||||
|
toPoint2D(circumcenter(eit->first->neighbor(eit->second)))
|
||||||
|
);
|
||||||
|
|
||||||
|
// Calculate the length^2 of the edge normal to the surface
|
||||||
|
scalar edgeLen2 = magSqr(e0 - e1);
|
||||||
|
|
||||||
|
if (edgeLen2 < meshControls().minNearPointDist2())
|
||||||
|
{
|
||||||
|
pointIndexHit pHit;
|
||||||
|
label hitSurface = -1;
|
||||||
|
|
||||||
|
qSurf_.findSurfaceNearest
|
||||||
|
(
|
||||||
|
toPoint3D(e0),
|
||||||
|
meshControls().minEdgeLen2(),
|
||||||
|
pHit,
|
||||||
|
hitSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pHit.hit())
|
||||||
|
{
|
||||||
|
vectorField norm(1);
|
||||||
|
qSurf_.geometry()[hitSurface].getNormal
|
||||||
|
(
|
||||||
|
List<pointIndexHit>(1, pHit),
|
||||||
|
norm
|
||||||
|
);
|
||||||
|
|
||||||
|
insertPointPair
|
||||||
|
(
|
||||||
|
meshControls().ppDist(),
|
||||||
|
toPoint2D(pHit.hitPoint()),
|
||||||
|
toPoint2D(norm[0])
|
||||||
|
);
|
||||||
|
|
||||||
|
nNearPoints++;
|
||||||
|
|
||||||
|
// Correct the edge iterator for the change in the
|
||||||
|
// number of edges following the point-pair insertion
|
||||||
|
eit = Finite_edges_iterator
|
||||||
|
(
|
||||||
|
finite_edges_end().base(),
|
||||||
|
eit.predicate(),
|
||||||
|
eit.base()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nNearPoints << " point-pairs inserted" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,244 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*----------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CV2D.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::CV2D::dualCellSurfaceIntersection
|
||||||
|
(
|
||||||
|
const Triangulation::Finite_vertices_iterator& vit
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Triangulation::Edge_circulator ecStart = incident_edges(vit);
|
||||||
|
Triangulation::Edge_circulator ec = ecStart;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
if (!is_infinite(ec))
|
||||||
|
{
|
||||||
|
point e0 = toPoint3D(circumcenter(ec->first));
|
||||||
|
|
||||||
|
// If edge end is outside bounding box then edge cuts boundary
|
||||||
|
if (!qSurf_.globalBounds().contains(e0))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
point e1 = toPoint3D(circumcenter(ec->first->neighbor(ec->second)));
|
||||||
|
|
||||||
|
// If other edge end is ouside bounding box then edge cuts boundary
|
||||||
|
if (!qSurf_.globalBounds().contains(e1))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (magSqr(e1 - e0) > meshControls().minEdgeLen2())
|
||||||
|
{
|
||||||
|
if (qSurf_.findSurfaceAnyIntersection(e0, e1))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (++ec != ecStart);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::insertPointPairs
|
||||||
|
(
|
||||||
|
const DynamicList<point2D>& nearSurfacePoints,
|
||||||
|
const DynamicList<point2D>& surfacePoints,
|
||||||
|
const DynamicList<label>& surfaceTris,
|
||||||
|
const DynamicList<label>& surfaceHits,
|
||||||
|
const fileName fName
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (meshControls().mirrorPoints())
|
||||||
|
{
|
||||||
|
forAll(surfacePoints, ppi)
|
||||||
|
{
|
||||||
|
insertMirrorPoint
|
||||||
|
(
|
||||||
|
nearSurfacePoints[ppi],
|
||||||
|
surfacePoints[ppi]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(surfacePoints, ppi)
|
||||||
|
{
|
||||||
|
pointIndexHit pHit
|
||||||
|
(
|
||||||
|
true,
|
||||||
|
toPoint3D(surfacePoints[ppi]),
|
||||||
|
surfaceTris[ppi]
|
||||||
|
);
|
||||||
|
|
||||||
|
vectorField norm(1);
|
||||||
|
qSurf_.geometry()[surfaceHits[ppi]].getNormal
|
||||||
|
(
|
||||||
|
List<pointIndexHit>(1, pHit),
|
||||||
|
norm
|
||||||
|
);
|
||||||
|
|
||||||
|
insertPointPair
|
||||||
|
(
|
||||||
|
meshControls().ppDist(),
|
||||||
|
surfacePoints[ppi],
|
||||||
|
toPoint2D(norm[0])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< surfacePoints.size() << " point-pairs inserted" << endl;
|
||||||
|
|
||||||
|
if (meshControls().objOutput())
|
||||||
|
{
|
||||||
|
OFstream str(fName);
|
||||||
|
label vertI = 0;
|
||||||
|
|
||||||
|
forAll(surfacePoints, ppi)
|
||||||
|
{
|
||||||
|
meshTools::writeOBJ(str, toPoint3D(surfacePoints[ppi]));
|
||||||
|
vertI++;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "insertPointPairs: Written " << surfacePoints.size()
|
||||||
|
<< " inserted point-pair locations to file "
|
||||||
|
<< str.name() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::CV2D::insertSurfaceNearestPointPairs()
|
||||||
|
{
|
||||||
|
Info<< "insertSurfaceNearestPointPairs: ";
|
||||||
|
|
||||||
|
label nSurfacePointsEst =
|
||||||
|
min
|
||||||
|
(
|
||||||
|
number_of_vertices(),
|
||||||
|
size_t(10*sqrt(scalar(number_of_vertices())))
|
||||||
|
);
|
||||||
|
|
||||||
|
DynamicList<point2D> nearSurfacePoints(nSurfacePointsEst);
|
||||||
|
DynamicList<point2D> surfacePoints(nSurfacePointsEst);
|
||||||
|
DynamicList<label> surfaceTris(nSurfacePointsEst);
|
||||||
|
DynamicList<label> surfaceHits(nSurfacePointsEst);
|
||||||
|
|
||||||
|
// Local references to surface mesh addressing
|
||||||
|
// const pointField& localPoints = qSurf_.localPoints();
|
||||||
|
// const labelListList& edgeFaces = qSurf_.edgeFaces();
|
||||||
|
// const vectorField& faceNormals = qSurf_.faceNormals();
|
||||||
|
// const labelListList& faceEdges = qSurf_.faceEdges();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Triangulation::Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
vit++
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->internalPoint())
|
||||||
|
{
|
||||||
|
point2DFromPoint vert(toPoint2D(vit->point()));
|
||||||
|
|
||||||
|
pointIndexHit pHit;
|
||||||
|
label hitSurface = -1;
|
||||||
|
|
||||||
|
qSurf_.findSurfaceNearest
|
||||||
|
(
|
||||||
|
toPoint3D(vert),
|
||||||
|
4*meshControls().minCellSize2(),
|
||||||
|
pHit,
|
||||||
|
hitSurface
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pHit.hit())
|
||||||
|
{
|
||||||
|
vit->setNearBoundary();
|
||||||
|
|
||||||
|
// Reference to the nearest triangle
|
||||||
|
// const labelledTri& f = qSurf_[hitSurface];
|
||||||
|
|
||||||
|
// // Find where point is on triangle.
|
||||||
|
// // Note tolerance needed is relative one
|
||||||
|
// // (used in comparing normalized [0..1] triangle coordinates).
|
||||||
|
// label nearType, nearLabel;
|
||||||
|
// triPointRef
|
||||||
|
// (
|
||||||
|
// localPoints[f[0]],
|
||||||
|
// localPoints[f[1]],
|
||||||
|
// localPoints[f[2]]
|
||||||
|
// ).classify(pHit.hitPoint(), nearType, nearLabel);
|
||||||
|
|
||||||
|
// // If point is on a edge check if it is an internal feature
|
||||||
|
|
||||||
|
// bool internalFeatureEdge = false;
|
||||||
|
|
||||||
|
// if (nearType == triPointRef::EDGE)
|
||||||
|
// {
|
||||||
|
// label edgeI = faceEdges[hitSurface][nearLabel];
|
||||||
|
// const labelList& eFaces = edgeFaces[edgeI];
|
||||||
|
|
||||||
|
// if
|
||||||
|
// (
|
||||||
|
// eFaces.size() == 2
|
||||||
|
// && (faceNormals[eFaces[0]] & faceNormals[eFaces[1]])
|
||||||
|
// < -0.2
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// internalFeatureEdge = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
if (dualCellSurfaceIntersection(vit)) //&& !internalFeatureEdge)
|
||||||
|
{
|
||||||
|
nearSurfacePoints.append(vert);
|
||||||
|
surfacePoints.append(toPoint2D(pHit.hitPoint()));
|
||||||
|
surfaceTris.append(pHit.index());
|
||||||
|
surfaceHits.append(hitSurface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
insertPointPairs
|
||||||
|
(
|
||||||
|
nearSurfacePoints,
|
||||||
|
surfacePoints,
|
||||||
|
surfaceTris,
|
||||||
|
surfaceHits,
|
||||||
|
"surfaceNearestIntersections.obj"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,533 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "shortEdgeFilter2D.H"
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(shortEdgeFilter2D, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::shortEdgeFilter2D::shortEdgeFilter2D
|
||||||
|
(
|
||||||
|
const Foam::CV2D& cv2Dmesh,
|
||||||
|
const dictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cv2Dmesh_(cv2Dmesh),
|
||||||
|
shortEdgeFilterFactor_(readScalar(dict.lookup("shortEdgeFilterFactor"))),
|
||||||
|
edgeAttachedToBoundaryFactor_
|
||||||
|
(
|
||||||
|
dict.lookupOrDefault<scalar>("edgeAttachedToBoundaryFactor", 2.0)
|
||||||
|
),
|
||||||
|
patchNames_(wordList()),
|
||||||
|
patchSizes_(labelList()),
|
||||||
|
mapEdgesRegion_(),
|
||||||
|
indirectPatchEdge_()
|
||||||
|
{
|
||||||
|
point2DField points2D;
|
||||||
|
faceList faces;
|
||||||
|
|
||||||
|
cv2Dmesh.calcDual
|
||||||
|
(
|
||||||
|
points2D,
|
||||||
|
faces,
|
||||||
|
patchNames_,
|
||||||
|
patchSizes_,
|
||||||
|
mapEdgesRegion_,
|
||||||
|
indirectPatchEdge_
|
||||||
|
);
|
||||||
|
|
||||||
|
pointField points(points2D.size());
|
||||||
|
forAll(points, ip)
|
||||||
|
{
|
||||||
|
points[ip] = cv2Dmesh.toPoint3D(points2D[ip]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
OFstream str("indirectPatchEdges.obj");
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
Info<< "Writing indirectPatchEdges to " << str.name() << endl;
|
||||||
|
|
||||||
|
forAllConstIter(EdgeMap<label>, indirectPatchEdge_, iter)
|
||||||
|
{
|
||||||
|
const edge& e = iter.key();
|
||||||
|
|
||||||
|
meshTools::writeOBJ
|
||||||
|
(
|
||||||
|
str,
|
||||||
|
points[e.start()],
|
||||||
|
points[e.end()],
|
||||||
|
count
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
points2D.clear();
|
||||||
|
|
||||||
|
ms_ = MeshedSurface<face>(xferMove(points), xferMove(faces));
|
||||||
|
|
||||||
|
Info<< "Meshed surface stats before edge filtering :" << endl;
|
||||||
|
ms_.writeStats(Info);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
writeInfo(Info);
|
||||||
|
|
||||||
|
ms_.write("MeshedSurface_preFilter.obj");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::shortEdgeFilter2D::~shortEdgeFilter2D()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void
|
||||||
|
Foam::shortEdgeFilter2D::filter()
|
||||||
|
{
|
||||||
|
// These are global indices.
|
||||||
|
const pointField& points = ms_.points();
|
||||||
|
const edgeList& edges = ms_.edges();
|
||||||
|
const faceList& faces = ms_.faces();
|
||||||
|
const labelList& meshPoints = ms_.meshPoints();
|
||||||
|
const labelList& boundaryPoints = ms_.boundaryPoints();
|
||||||
|
|
||||||
|
label maxChain = 0;
|
||||||
|
label nPointsToRemove = 0;
|
||||||
|
|
||||||
|
labelList pointsToRemove(ms_.points().size(), -1);
|
||||||
|
|
||||||
|
// List of number of vertices in a face.
|
||||||
|
labelList newFaceVertexCount(faces.size(), -1);
|
||||||
|
forAll(faces, faceI)
|
||||||
|
{
|
||||||
|
newFaceVertexCount[faceI] = faces[faceI].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the point is a boundary point. Flag if it is so that
|
||||||
|
// it will not be deleted.
|
||||||
|
boolList boundaryPointFlags(points.size(), false);
|
||||||
|
// This has been removed, otherwise small edges on the boundary are not
|
||||||
|
// removed.
|
||||||
|
/* forAll(boundaryPointFlags, pointI)
|
||||||
|
{
|
||||||
|
forAll(boundaryPoints, bPoint)
|
||||||
|
{
|
||||||
|
if (meshPoints[boundaryPoints[bPoint]] == pointI)
|
||||||
|
{
|
||||||
|
boundaryPointFlags[pointI] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
// Check if an edge has a boundary point. It it does the edge length
|
||||||
|
// will be doubled when working out its length.
|
||||||
|
Info<< " Marking edges attached to boundaries." << endl;
|
||||||
|
boolList edgeAttachedToBoundary(edges.size(), false);
|
||||||
|
forAll(edges, edgeI)
|
||||||
|
{
|
||||||
|
const edge& e = edges[edgeI];
|
||||||
|
const label startVertex = e.start();
|
||||||
|
const label endVertex = e.end();
|
||||||
|
|
||||||
|
forAll(boundaryPoints, bPoint)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
boundaryPoints[bPoint] == startVertex
|
||||||
|
|| boundaryPoints[bPoint] == endVertex
|
||||||
|
)
|
||||||
|
{
|
||||||
|
edgeAttachedToBoundary[edgeI] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(edges, edgeI)
|
||||||
|
{
|
||||||
|
const edge& e = edges[edgeI];
|
||||||
|
|
||||||
|
// get the vertices of that edge.
|
||||||
|
const label startVertex = e.start();
|
||||||
|
const label endVertex = e.end();
|
||||||
|
|
||||||
|
scalar edgeLength =
|
||||||
|
mag
|
||||||
|
(
|
||||||
|
points[meshPoints[startVertex]]
|
||||||
|
- points[meshPoints[endVertex]]
|
||||||
|
);
|
||||||
|
|
||||||
|
if (edgeAttachedToBoundary[edgeI])
|
||||||
|
{
|
||||||
|
edgeLength *= edgeAttachedToBoundaryFactor_;
|
||||||
|
}
|
||||||
|
|
||||||
|
scalar shortEdgeFilterValue = 0.0;
|
||||||
|
|
||||||
|
const labelList& psEdges = ms_.pointEdges()[startVertex];
|
||||||
|
const labelList& peEdges = ms_.pointEdges()[endVertex];
|
||||||
|
|
||||||
|
forAll(psEdges, psEdgeI)
|
||||||
|
{
|
||||||
|
const edge& psE = edges[psEdges[psEdgeI]];
|
||||||
|
if (edgeI != psEdges[psEdgeI])
|
||||||
|
{
|
||||||
|
shortEdgeFilterValue +=
|
||||||
|
mag
|
||||||
|
(
|
||||||
|
points[meshPoints[psE.start()]]
|
||||||
|
- points[meshPoints[psE.end()]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(peEdges, peEdgeI)
|
||||||
|
{
|
||||||
|
const edge& peE = edges[peEdges[peEdgeI]];
|
||||||
|
if (edgeI != peEdges[peEdgeI])
|
||||||
|
{
|
||||||
|
shortEdgeFilterValue +=
|
||||||
|
mag
|
||||||
|
(
|
||||||
|
points[meshPoints[peE.start()]]
|
||||||
|
- points[meshPoints[peE.end()]]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
shortEdgeFilterValue *=
|
||||||
|
shortEdgeFilterFactor_
|
||||||
|
/(psEdges.size() + peEdges.size() - 2);
|
||||||
|
|
||||||
|
|
||||||
|
edge lookupInPatchEdge
|
||||||
|
(
|
||||||
|
meshPoints[startVertex],
|
||||||
|
meshPoints[endVertex]
|
||||||
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
edgeLength < shortEdgeFilterValue
|
||||||
|
|| indirectPatchEdge_.found(lookupInPatchEdge)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
bool flagDegenerateFace = false;
|
||||||
|
const labelList& pFaces = ms_.pointFaces()[startVertex];
|
||||||
|
|
||||||
|
forAll(pFaces, pFaceI)
|
||||||
|
{
|
||||||
|
const face& f = ms_.localFaces()[pFaces[pFaceI]];
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
// If the edge is part of this face...
|
||||||
|
if (f[fp] == endVertex)
|
||||||
|
{
|
||||||
|
// If deleting vertex would create a triangle, don't!
|
||||||
|
if (newFaceVertexCount[pFaces[pFaceI]] < 4)
|
||||||
|
{
|
||||||
|
flagDegenerateFace = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newFaceVertexCount[pFaces[pFaceI]]--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// If the edge is not part of this face...
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Deleting vertex of a triangle...
|
||||||
|
if (newFaceVertexCount[pFaces[pFaceI]] < 3)
|
||||||
|
{
|
||||||
|
flagDegenerateFace = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This if statement determines whether a point should be deleted.
|
||||||
|
if
|
||||||
|
(
|
||||||
|
pointsToRemove[meshPoints[startVertex]] == -1
|
||||||
|
&& pointsToRemove[meshPoints[endVertex]] == -1
|
||||||
|
&& !boundaryPointFlags[meshPoints[startVertex]]
|
||||||
|
&& !flagDegenerateFace
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointsToRemove[meshPoints[startVertex]] = meshPoints[endVertex];
|
||||||
|
++nPointsToRemove;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label totalNewPoints = points.size() - nPointsToRemove;
|
||||||
|
|
||||||
|
pointField newPoints(totalNewPoints, vector::zero);
|
||||||
|
labelList newPointNumbers(points.size(), -1);
|
||||||
|
label numberRemoved = 0;
|
||||||
|
|
||||||
|
forAll(points, pointI)
|
||||||
|
{
|
||||||
|
// If the point is NOT going to be removed.
|
||||||
|
if (pointsToRemove[pointI] == -1)
|
||||||
|
{
|
||||||
|
newPoints[pointI - numberRemoved] = points[pointI];
|
||||||
|
newPointNumbers[pointI] = pointI - numberRemoved;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
numberRemoved++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Need a new faceList
|
||||||
|
faceList newFaces(faces.size());
|
||||||
|
label newFaceI = 0;
|
||||||
|
|
||||||
|
labelList newFace;
|
||||||
|
label newFaceSize = 0;
|
||||||
|
|
||||||
|
// Now need to iterate over the faces and remove points. Global index.
|
||||||
|
forAll(faces, faceI)
|
||||||
|
{
|
||||||
|
const face& f = faces[faceI];
|
||||||
|
|
||||||
|
newFace.clear();
|
||||||
|
newFace.setSize(f.size());
|
||||||
|
newFaceSize = 0;
|
||||||
|
|
||||||
|
forAll(f, fp)
|
||||||
|
{
|
||||||
|
label pointI = f[fp];
|
||||||
|
// If not removing the point, then add it to the new face.
|
||||||
|
if (pointsToRemove[pointI] == -1)
|
||||||
|
{
|
||||||
|
newFace[newFaceSize++] = newPointNumbers[pointI];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label newPointI = pointsToRemove[pointI];
|
||||||
|
// Replace deleted point with point that it is being
|
||||||
|
// collapsed to.
|
||||||
|
if
|
||||||
|
(
|
||||||
|
f.nextLabel(fp) != newPointI
|
||||||
|
&& f.prevLabel(fp) != newPointI
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label pChain = newPointI;
|
||||||
|
label totalChain = 0;
|
||||||
|
for (label nChain = 0; nChain <= totalChain; ++nChain)
|
||||||
|
{
|
||||||
|
if (newPointNumbers[pChain] != -1)
|
||||||
|
{
|
||||||
|
newFace[newFaceSize++] = newPointNumbers[pChain];
|
||||||
|
newPointNumbers[pointI] = newPointNumbers[pChain];
|
||||||
|
maxChain = max(totalChain, maxChain);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
WarningIn("shortEdgeFilter")
|
||||||
|
<< "Point " << pChain
|
||||||
|
<< " marked for deletion as well as point "
|
||||||
|
<< pointI << nl
|
||||||
|
<< " Incrementing maxChain by 1 from "
|
||||||
|
<< totalChain << " to " << totalChain + 1
|
||||||
|
<< endl;
|
||||||
|
totalChain++;
|
||||||
|
}
|
||||||
|
pChain = pointsToRemove[pChain];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (newPointNumbers[newPointI] != -1)
|
||||||
|
{
|
||||||
|
newPointNumbers[pointI] = newPointNumbers[newPointI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newFace.setSize(newFaceSize);
|
||||||
|
|
||||||
|
if (newFace.size() > 2)
|
||||||
|
{
|
||||||
|
newFaces[newFaceI++] = face(newFace);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn("shortEdgeFilter")
|
||||||
|
<< "Only " << newFace.size() << " in face " << faceI
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newFaces.setSize(newFaceI);
|
||||||
|
|
||||||
|
MeshedSurface<face> fMesh
|
||||||
|
(
|
||||||
|
xferMove(newPoints),
|
||||||
|
xferMove(newFaces),
|
||||||
|
xferCopy(List<surfZone>())
|
||||||
|
);
|
||||||
|
|
||||||
|
const Map<int>& fMeshPointMap = fMesh.meshPointMap();
|
||||||
|
|
||||||
|
// Reset patchSizes_
|
||||||
|
patchSizes_.clear();
|
||||||
|
patchSizes_.setSize(patchNames_.size(), 0);
|
||||||
|
|
||||||
|
label equalEdges = 0;
|
||||||
|
label notFound = 0;
|
||||||
|
label matches = 0;
|
||||||
|
label negativeLabels = 0;
|
||||||
|
|
||||||
|
forAll(newPointNumbers, pointI)
|
||||||
|
{
|
||||||
|
if (newPointNumbers[pointI] == -1)
|
||||||
|
{
|
||||||
|
WarningIn("shortEdgeFilter")
|
||||||
|
<< pointI << " will be deleted and " << newPointNumbers[pointI]
|
||||||
|
<< ", so it will not be replaced. "
|
||||||
|
<< "This will cause edges to be deleted." << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create new EdgeMap.
|
||||||
|
Info<< "Creating new EdgeMap." << endl;
|
||||||
|
EdgeMap<label> newMapEdgesRegion(mapEdgesRegion_.size());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
label bEdgeI = ms_.nInternalEdges();
|
||||||
|
bEdgeI < edges.size();
|
||||||
|
++bEdgeI
|
||||||
|
)
|
||||||
|
{
|
||||||
|
label p1 = meshPoints[edges[bEdgeI][0]];
|
||||||
|
label p2 = meshPoints[edges[bEdgeI][1]];
|
||||||
|
|
||||||
|
edge e(p1, p2);
|
||||||
|
|
||||||
|
if (mapEdgesRegion_.found(e))
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
newPointNumbers[p1] != -1
|
||||||
|
&& newPointNumbers[p2] != -1
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (newPointNumbers[p1] != newPointNumbers[p2])
|
||||||
|
{
|
||||||
|
label region = mapEdgesRegion_.find(e)();
|
||||||
|
newMapEdgesRegion.insert
|
||||||
|
(
|
||||||
|
edge
|
||||||
|
(
|
||||||
|
fMeshPointMap[newPointNumbers[p1]],
|
||||||
|
fMeshPointMap[newPointNumbers[p2]]
|
||||||
|
),
|
||||||
|
region
|
||||||
|
);
|
||||||
|
patchSizes_[region]++;
|
||||||
|
matches++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
equalEdges++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
negativeLabels++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
notFound++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "EdgeMapping :" << nl
|
||||||
|
<< " Matches : " << matches << nl
|
||||||
|
<< " Equal : " << equalEdges << nl
|
||||||
|
<< " Negative : " << negativeLabels << nl
|
||||||
|
<< " Not Found: " << notFound << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapEdgesRegion_.transfer(newMapEdgesRegion);
|
||||||
|
|
||||||
|
ms_.transfer(fMesh);
|
||||||
|
|
||||||
|
Info<< " Maximum number of chained collapses = " << maxChain << endl;
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
writeInfo(Info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::shortEdgeFilter2D::writeInfo(Ostream& os)
|
||||||
|
{
|
||||||
|
os << "Short Edge Filtering Information:" << nl
|
||||||
|
<< " shortEdgeFilterFactor: " << shortEdgeFilterFactor_ << nl
|
||||||
|
<< " edgeAttachedToBoundaryFactor: " << edgeAttachedToBoundaryFactor_
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
forAll(patchNames_, patchI)
|
||||||
|
{
|
||||||
|
os << " Patch " << patchNames_[patchI]
|
||||||
|
<< ", size " << patchSizes_[patchI] << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
os << " There are " << mapEdgesRegion_.size()
|
||||||
|
<< " boundary edges." << endl;
|
||||||
|
|
||||||
|
os << " Mesh Info:" << nl
|
||||||
|
<< " Points: " << ms_.nPoints() << nl
|
||||||
|
<< " Faces: " << ms_.size() << nl
|
||||||
|
<< " Edges: " << ms_.nEdges() << nl
|
||||||
|
<< " Internal: " << ms_.nInternalEdges() << nl
|
||||||
|
<< " External: " << ms_.nEdges() - ms_.nInternalEdges()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,133 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::shortEdgeFilter2D
|
||||||
|
|
||||||
|
Description
|
||||||
|
This class filters short edges generated by the CV2D mesher.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
shortEdgeFilter2D.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef shortEdgeFilter2D_H
|
||||||
|
#define shortEdgeFilter2D_H
|
||||||
|
|
||||||
|
#include "MeshedSurfaces.H"
|
||||||
|
#include "CV2D.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class shortEdgeFilter2D Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class shortEdgeFilter2D
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const CV2D& cv2Dmesh_;
|
||||||
|
|
||||||
|
MeshedSurface<face> ms_;
|
||||||
|
|
||||||
|
const scalar shortEdgeFilterFactor_;
|
||||||
|
|
||||||
|
const scalar edgeAttachedToBoundaryFactor_;
|
||||||
|
|
||||||
|
wordList patchNames_;
|
||||||
|
|
||||||
|
labelList patchSizes_;
|
||||||
|
|
||||||
|
EdgeMap<label> mapEdgesRegion_;
|
||||||
|
|
||||||
|
EdgeMap<label> indirectPatchEdge_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
shortEdgeFilter2D(const shortEdgeFilter2D&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const shortEdgeFilter2D&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("shortEdgeFilter2D");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
shortEdgeFilter2D(const CV2D& cv2Dmesh, const dictionary& dict);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~shortEdgeFilter2D();
|
||||||
|
|
||||||
|
|
||||||
|
// Access Functions
|
||||||
|
|
||||||
|
const wordList& patchNames() const
|
||||||
|
{
|
||||||
|
return patchNames_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const labelList& patchSizes() const
|
||||||
|
{
|
||||||
|
return patchSizes_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EdgeMap<label>& mapEdgesRegion() const
|
||||||
|
{
|
||||||
|
return mapEdgesRegion_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MeshedSurface<face>& fMesh() const
|
||||||
|
{
|
||||||
|
return ms_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
void filter();
|
||||||
|
|
||||||
|
void writeInfo(Ostream& os);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
10
applications/utilities/mesh/generation/foamyHexMesh/Allwclean
Executable file
10
applications/utilities/mesh/generation/foamyHexMesh/Allwclean
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # run from this directory
|
||||||
|
set -x
|
||||||
|
|
||||||
|
wclean libso conformalVoronoiMesh
|
||||||
|
wclean
|
||||||
|
wclean cvMeshSurfaceSimplify
|
||||||
|
wclean cvMeshBackgroundMesh
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------- end-of-file
|
||||||
11
applications/utilities/mesh/generation/foamyHexMesh/Allwmake
Executable file
11
applications/utilities/mesh/generation/foamyHexMesh/Allwmake
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
cd ${0%/*} || exit 1 # run from this directory
|
||||||
|
set -x
|
||||||
|
|
||||||
|
wmake libso conformalVoronoiMesh
|
||||||
|
wmake
|
||||||
|
#wmake cvMeshBackgroundMesh
|
||||||
|
#(cd cvMeshSurfaceSimplify && ./Allwmake)
|
||||||
|
#wmake cellSizeAndAlignmentGrid
|
||||||
|
|
||||||
|
# ----------------------------------------------------------------- end-of-file
|
||||||
@ -0,0 +1,3 @@
|
|||||||
|
foamyHexMesh.C
|
||||||
|
|
||||||
|
EXE = $(FOAM_APPBIN)/foamyHexMesh
|
||||||
@ -0,0 +1,38 @@
|
|||||||
|
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||||
|
EXE_FROUNDING_MATH = -frounding-math
|
||||||
|
EXE_NDEBUG = -DNDEBUG
|
||||||
|
|
||||||
|
CGAL_EXACT = /*-DCGAL_DONT_USE_LAZY_KERNEL*/
|
||||||
|
CGAL_INEXACT = -DCGAL_INEXACT
|
||||||
|
|
||||||
|
include $(GENERAL_RULES)/CGAL
|
||||||
|
|
||||||
|
EXE_INC = \
|
||||||
|
${EXE_FROUNDING_MATH} \
|
||||||
|
${EXE_NDEBUG} \
|
||||||
|
${CGAL_INEXACT} \
|
||||||
|
${CGAL_INC} \
|
||||||
|
-IconformalVoronoiMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
|
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-IvectorTools
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
$(CGAL_LIBS) \
|
||||||
|
-lboost_thread \
|
||||||
|
-lmpfr \
|
||||||
|
-lconformalVoronoiMesh \
|
||||||
|
-lmeshTools \
|
||||||
|
-ldecompositionMethods \
|
||||||
|
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
|
||||||
|
-ledgeMesh \
|
||||||
|
-lfileFormats \
|
||||||
|
-ltriSurface \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-lsampling
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
cellSizeAndAlignmentGrid.C
|
||||||
|
EXE = $(FOAM_USER_APPBIN)/cellSizeAndAlignmentGrid
|
||||||
@ -0,0 +1,40 @@
|
|||||||
|
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||||
|
EXE_FROUNDING_MATH = -frounding-math
|
||||||
|
EXE_NDEBUG = -DNDEBUG
|
||||||
|
|
||||||
|
CGAL_EXACT = /*-DCGAL_DONT_USE_LAZY_KERNEL*/
|
||||||
|
CGAL_INEXACT = -DCGAL_INEXACT
|
||||||
|
|
||||||
|
include $(GENERAL_RULES)/CGAL
|
||||||
|
|
||||||
|
|
||||||
|
EXE_INC = \
|
||||||
|
${EXE_FROUNDING_MATH} \
|
||||||
|
${EXE_NDEBUG} \
|
||||||
|
${CGAL_INEXACT} \
|
||||||
|
${CGAL_INC} \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
|
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||||
|
-I$(FOAM_UTILITIES)/mesh/generation/cvMesh/conformalVoronoiMesh/lnInclude \
|
||||||
|
-I$(FOAM_UTILITIES)/mesh/generation/cvMesh/vectorTools
|
||||||
|
|
||||||
|
EXE_LIBS = \
|
||||||
|
$(CGAL_LIBS) \
|
||||||
|
-lmpfr \
|
||||||
|
-lboost_thread \
|
||||||
|
-lconformalVoronoiMesh \
|
||||||
|
-lfiniteVolume \
|
||||||
|
-lmeshTools \
|
||||||
|
-ldecompositionMethods \
|
||||||
|
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
|
||||||
|
-ledgeMesh \
|
||||||
|
-ltriSurface \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-lsampling \
|
||||||
|
-lfileFormats
|
||||||
@ -0,0 +1,716 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Application
|
||||||
|
Test-distributedDelaunayMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "CGALTriangulation3DKernel.H"
|
||||||
|
|
||||||
|
#include "indexedVertex.H"
|
||||||
|
#include "indexedCell.H"
|
||||||
|
|
||||||
|
#include "argList.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "DistributedDelaunayMesh.H"
|
||||||
|
#include "backgroundMeshDecomposition.H"
|
||||||
|
#include "searchableSurfaces.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "PrintTable.H"
|
||||||
|
#include "Random.H"
|
||||||
|
#include "boundBox.H"
|
||||||
|
#include "point.H"
|
||||||
|
#include "cellShapeControlMesh.H"
|
||||||
|
#include "triadField.H"
|
||||||
|
#include "scalarIOField.H"
|
||||||
|
#include "pointIOField.H"
|
||||||
|
#include "triadIOField.H"
|
||||||
|
|
||||||
|
using namespace Foam;
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
// Main program:
|
||||||
|
|
||||||
|
template<class Triangulation, class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type> > filterFarPoints
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
const Field<Type>& field
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmp<Field<Type> > tNewField(new Field<Type>(field.size()));
|
||||||
|
Field<Type>& newField = tNewField();
|
||||||
|
|
||||||
|
label added = 0;
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
newField[added++] = field[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
newField.resize(added);
|
||||||
|
|
||||||
|
return tNewField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
autoPtr<mapDistribute> buildMap
|
||||||
|
(
|
||||||
|
const T& mesh,
|
||||||
|
labelListList& pointPoints
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointPoints.setSize(mesh.vertexCount());
|
||||||
|
|
||||||
|
globalIndex globalIndexing(mesh.vertexCount());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<typename T::Vertex_handle> adjVerts;
|
||||||
|
mesh.finite_adjacent_vertices(vit, std::back_inserter(adjVerts));
|
||||||
|
|
||||||
|
DynamicList<label> indices(adjVerts.size());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename std::list<typename T::Vertex_handle>::const_iterator
|
||||||
|
adjVertI = adjVerts.begin();
|
||||||
|
adjVertI != adjVerts.end();
|
||||||
|
++adjVertI
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typename T::Vertex_handle vh = *adjVertI;
|
||||||
|
|
||||||
|
if (!vh->farPoint())
|
||||||
|
{
|
||||||
|
indices.append
|
||||||
|
(
|
||||||
|
globalIndexing.toGlobal(vh->procIndex(), vh->index())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pointPoints[vit->index()].transfer(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<label> > compactMap;
|
||||||
|
|
||||||
|
return autoPtr<mapDistribute>
|
||||||
|
(
|
||||||
|
new mapDistribute
|
||||||
|
(
|
||||||
|
globalIndexing,
|
||||||
|
pointPoints,
|
||||||
|
compactMap
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::tmp<Foam::triadField> buildAlignmentField(const T& mesh)
|
||||||
|
{
|
||||||
|
tmp<triadField> tAlignments
|
||||||
|
(
|
||||||
|
new triadField(mesh.vertexCount(), triad::unset)
|
||||||
|
);
|
||||||
|
triadField& alignments = tAlignments();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
alignments[vit->index()] = vit->alignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tAlignments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
Foam::tmp<Foam::pointField> buildPointField(const T& mesh)
|
||||||
|
{
|
||||||
|
tmp<pointField> tPoints
|
||||||
|
(
|
||||||
|
new pointField(mesh.vertexCount(), point(GREAT, GREAT, GREAT))
|
||||||
|
);
|
||||||
|
pointField& points = tPoints();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename T::Finite_vertices_iterator vit = mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
points[vit->index()] = topoint(vit->point());
|
||||||
|
}
|
||||||
|
|
||||||
|
return tPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void refine
|
||||||
|
(
|
||||||
|
cellShapeControlMesh& mesh,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const label maxRefinementIterations,
|
||||||
|
const scalar defaultCellSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
for (label iter = 0; iter < maxRefinementIterations; ++iter)
|
||||||
|
{
|
||||||
|
DynamicList<point> ptsToInsert;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_cells_iterator cit =
|
||||||
|
mesh.finite_cells_begin();
|
||||||
|
cit != mesh.finite_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const point newPoint =
|
||||||
|
topoint
|
||||||
|
(
|
||||||
|
CGAL::centroid
|
||||||
|
(
|
||||||
|
cit->vertex(0)->point(),
|
||||||
|
cit->vertex(1)->point(),
|
||||||
|
cit->vertex(2)->point(),
|
||||||
|
cit->vertex(3)->point()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if (geometryToConformTo.inside(newPoint))
|
||||||
|
{
|
||||||
|
ptsToInsert.append(newPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " Adding " << returnReduce(ptsToInsert.size(), sumOp<label>())
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
forAll(ptsToInsert, ptI)
|
||||||
|
{
|
||||||
|
mesh.insert
|
||||||
|
(
|
||||||
|
ptsToInsert[ptI],
|
||||||
|
defaultCellSize,
|
||||||
|
triad::unset,
|
||||||
|
Vb::vtInternal
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
label maxRefinementIterations = 2;
|
||||||
|
label maxSmoothingIterations = 200;
|
||||||
|
scalar minResidual = 0;
|
||||||
|
scalar defaultCellSize = 0.001;
|
||||||
|
scalar nearFeatDistSqrCoeff = 1e-8;
|
||||||
|
|
||||||
|
|
||||||
|
// Need to decouple vertex and cell type from this class?
|
||||||
|
// Vertex must have:
|
||||||
|
// + index
|
||||||
|
// + procIndex
|
||||||
|
// - type should be optional
|
||||||
|
cellShapeControlMesh mesh(runTime);
|
||||||
|
|
||||||
|
IOdictionary cvMeshDict
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"cvMeshDict",
|
||||||
|
runTime.system(),
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Random rndGen(64293*Pstream::myProcNo());
|
||||||
|
|
||||||
|
searchableSurfaces allGeometry
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"cvSearchableSurfaces",
|
||||||
|
runTime.constant(),
|
||||||
|
"triSurface",
|
||||||
|
runTime,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
cvMeshDict.subDict("geometry")
|
||||||
|
);
|
||||||
|
|
||||||
|
conformationSurfaces geometryToConformTo
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
rndGen,
|
||||||
|
allGeometry,
|
||||||
|
cvMeshDict.subDict("surfaceConformation")
|
||||||
|
);
|
||||||
|
|
||||||
|
autoPtr<backgroundMeshDecomposition> bMesh;
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
bMesh.set
|
||||||
|
(
|
||||||
|
new backgroundMeshDecomposition
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
rndGen,
|
||||||
|
geometryToConformTo,
|
||||||
|
cvMeshDict.subDict("backgroundMeshDecomposition")
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Nice to have IO for the delaunay mesh
|
||||||
|
// IO depend on vertex type.
|
||||||
|
//
|
||||||
|
// Define a delaunay mesh as:
|
||||||
|
// + list of points of the triangulation
|
||||||
|
// + optionally a list of cells
|
||||||
|
|
||||||
|
Info<< nl << "Loop over surfaces" << endl;
|
||||||
|
|
||||||
|
forAll(geometryToConformTo.surfaces(), sI)
|
||||||
|
{
|
||||||
|
const label surfI = geometryToConformTo.surfaces()[sI];
|
||||||
|
|
||||||
|
const searchableSurface& surface =
|
||||||
|
geometryToConformTo.geometry()[surfI];
|
||||||
|
|
||||||
|
Info<< nl << "Inserting points from surface " << surface.name()
|
||||||
|
<< " (" << surface.type() << ")" << endl;
|
||||||
|
|
||||||
|
const tmp<pointField> tpoints(surface.points());
|
||||||
|
const pointField& points = tpoints();
|
||||||
|
|
||||||
|
Info<< " Number of points = " << points.size() << endl;
|
||||||
|
|
||||||
|
forAll(points, pI)
|
||||||
|
{
|
||||||
|
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||||
|
// point normal, otherwise get the surface normal from
|
||||||
|
// searchableSurface
|
||||||
|
|
||||||
|
pointIndexHit info;
|
||||||
|
label infoFeature;
|
||||||
|
geometryToConformTo.findFeaturePointNearest
|
||||||
|
(
|
||||||
|
points[pI],
|
||||||
|
nearFeatDistSqrCoeff,
|
||||||
|
info,
|
||||||
|
infoFeature
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
autoPtr<triad> pointAlignment;
|
||||||
|
|
||||||
|
if (info.hit())
|
||||||
|
{
|
||||||
|
const extendedFeatureEdgeMesh& features =
|
||||||
|
geometryToConformTo.features()[infoFeature];
|
||||||
|
|
||||||
|
vectorField norms = features.featurePointNormals(info.index());
|
||||||
|
|
||||||
|
// Create a triad from these norms.
|
||||||
|
pointAlignment.set(new triad());
|
||||||
|
forAll(norms, nI)
|
||||||
|
{
|
||||||
|
pointAlignment() += norms[nI];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointAlignment().normalize();
|
||||||
|
pointAlignment().orthogonalize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
geometryToConformTo.findEdgeNearest
|
||||||
|
(
|
||||||
|
points[pI],
|
||||||
|
nearFeatDistSqrCoeff,
|
||||||
|
info,
|
||||||
|
infoFeature
|
||||||
|
);
|
||||||
|
|
||||||
|
if (info.hit())
|
||||||
|
{
|
||||||
|
const extendedFeatureEdgeMesh& features =
|
||||||
|
geometryToConformTo.features()[infoFeature];
|
||||||
|
|
||||||
|
vectorField norms = features.edgeNormals(info.index());
|
||||||
|
|
||||||
|
// Create a triad from these norms.
|
||||||
|
pointAlignment.set(new triad());
|
||||||
|
forAll(norms, nI)
|
||||||
|
{
|
||||||
|
pointAlignment() += norms[nI];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointAlignment().normalize();
|
||||||
|
pointAlignment().orthogonalize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pointField ptField(1, points[pI]);
|
||||||
|
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||||
|
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||||
|
|
||||||
|
surface.findNearest(ptField, distField, infoList);
|
||||||
|
|
||||||
|
vectorField normals(1);
|
||||||
|
surface.getNormal(infoList, normals);
|
||||||
|
|
||||||
|
pointAlignment.set(new triad(normals[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
if (bMesh().positionOnThisProcessor(points[pI]))
|
||||||
|
{
|
||||||
|
CellSizeDelaunay::Vertex_handle vh = mesh.insert
|
||||||
|
(
|
||||||
|
points[pI],
|
||||||
|
defaultCellSize,
|
||||||
|
pointAlignment(),
|
||||||
|
Vb::vtInternalNearBoundary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CellSizeDelaunay::Vertex_handle vh = mesh.insert
|
||||||
|
(
|
||||||
|
points[pI],
|
||||||
|
defaultCellSize,
|
||||||
|
pointAlignment(),
|
||||||
|
Vb::vtInternalNearBoundary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Refine the mesh
|
||||||
|
refine
|
||||||
|
(
|
||||||
|
mesh,
|
||||||
|
geometryToConformTo,
|
||||||
|
maxRefinementIterations,
|
||||||
|
defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
mesh.distribute(bMesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
labelListList pointPoints;
|
||||||
|
autoPtr<mapDistribute> meshDistributor = buildMap(mesh, pointPoints);
|
||||||
|
|
||||||
|
|
||||||
|
triadField alignments(buildAlignmentField(mesh));
|
||||||
|
pointField points(buildPointField(mesh));
|
||||||
|
|
||||||
|
mesh.printInfo(Info);
|
||||||
|
|
||||||
|
|
||||||
|
// Setup the sizes and alignments on each point
|
||||||
|
triadField fixedAlignments(mesh.vertexCount(), triad::unset);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->nearBoundary())
|
||||||
|
{
|
||||||
|
fixedAlignments[vit->index()] = vit->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << "Smoothing alignments" << endl;
|
||||||
|
|
||||||
|
for (label iter = 0; iter < maxSmoothingIterations; iter++)
|
||||||
|
{
|
||||||
|
Info<< "Iteration " << iter;
|
||||||
|
|
||||||
|
meshDistributor().distribute(points);
|
||||||
|
meshDistributor().distribute(alignments);
|
||||||
|
|
||||||
|
scalar residual = 0;
|
||||||
|
|
||||||
|
triadField triadAv(alignments.size(), triad::unset);
|
||||||
|
|
||||||
|
forAll(pointPoints, pI)
|
||||||
|
{
|
||||||
|
const labelList& pPoints = pointPoints[pI];
|
||||||
|
|
||||||
|
if (pPoints.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const triad& oldTriad = alignments[pI];
|
||||||
|
triad& newTriad = triadAv[pI];
|
||||||
|
|
||||||
|
// Enforce the boundary conditions
|
||||||
|
const triad& fixedAlignment = fixedAlignments[pI];
|
||||||
|
|
||||||
|
forAll(pPoints, adjPointI)
|
||||||
|
{
|
||||||
|
const label adjPointIndex = pPoints[adjPointI];
|
||||||
|
|
||||||
|
scalar dist = mag(points[pI] - points[adjPointIndex]);
|
||||||
|
|
||||||
|
// dist = max(dist, SMALL);
|
||||||
|
|
||||||
|
triad tmpTriad = alignments[adjPointIndex];
|
||||||
|
|
||||||
|
for (direction dir = 0; dir < 3; dir++)
|
||||||
|
{
|
||||||
|
if (tmpTriad.set(dir))
|
||||||
|
{
|
||||||
|
tmpTriad[dir] *= (1.0/dist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newTriad += tmpTriad;
|
||||||
|
}
|
||||||
|
|
||||||
|
newTriad.normalize();
|
||||||
|
newTriad.orthogonalize();
|
||||||
|
// newTriad = newTriad.sortxyz();
|
||||||
|
|
||||||
|
label nFixed = 0;
|
||||||
|
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
nFixed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nFixed == 1)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
newTriad.align(fixedAlignment[dirI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nFixed == 2)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
newTriad[dirI] = fixedAlignment[dirI];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newTriad[dirI] = triad::unset[dirI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newTriad.orthogonalize();
|
||||||
|
}
|
||||||
|
else if (nFixed == 3)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
newTriad[dirI] = fixedAlignment[dirI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (direction dir = 0; dir < 3; ++dir)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
newTriad.set(dir)
|
||||||
|
&& oldTriad.set(dir)
|
||||||
|
//&& !fixedAlignment.set(dir)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
scalar dotProd = (oldTriad[dir] & newTriad[dir]);
|
||||||
|
scalar diff = mag(dotProd) - 1.0;
|
||||||
|
|
||||||
|
residual += mag(diff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll(alignments, pI)
|
||||||
|
{
|
||||||
|
alignments[pI] = triadAv[pI].sortxyz();
|
||||||
|
}
|
||||||
|
|
||||||
|
reduce(residual, sumOp<scalar>());
|
||||||
|
|
||||||
|
Info<< ", Residual = " << residual << endl;
|
||||||
|
|
||||||
|
if (residual <= minResidual)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Write alignments to a .obj file
|
||||||
|
OFstream str(runTime.path()/"alignments.obj");
|
||||||
|
|
||||||
|
forAll(alignments, pI)
|
||||||
|
{
|
||||||
|
const triad& tri = alignments[pI];
|
||||||
|
|
||||||
|
if (tri.set())
|
||||||
|
{
|
||||||
|
forAll(tri, dirI)
|
||||||
|
{
|
||||||
|
meshTools::writeOBJ(str, points[pI], tri[dirI] + points[pI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Remove the far points
|
||||||
|
pointIOField pointsIO
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"points",
|
||||||
|
runTime.constant(),
|
||||||
|
runTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
filterFarPoints(mesh, points)
|
||||||
|
);
|
||||||
|
|
||||||
|
scalarField sizes(points.size(), defaultCellSize);
|
||||||
|
scalarIOField sizesIO
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"sizes",
|
||||||
|
runTime.constant(),
|
||||||
|
runTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
filterFarPoints(mesh, sizes)
|
||||||
|
);
|
||||||
|
|
||||||
|
triadIOField alignmentsIO
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"alignments",
|
||||||
|
runTime.constant(),
|
||||||
|
runTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
filterFarPoints(mesh, alignments)
|
||||||
|
);
|
||||||
|
|
||||||
|
pointsIO.write();
|
||||||
|
sizesIO.write();
|
||||||
|
alignmentsIO.write();
|
||||||
|
|
||||||
|
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||||
|
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||||
|
<< nl << endl;
|
||||||
|
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,263 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "DelaunayMesh.H"
|
||||||
|
#include "labelPair.H"
|
||||||
|
#include "PrintTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::DelaunayMesh<Triangulation>::DelaunayMesh()
|
||||||
|
:
|
||||||
|
Triangulation(),
|
||||||
|
vertexCount_(0),
|
||||||
|
cellCount_(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::DelaunayMesh<Triangulation>::~DelaunayMesh()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::reset()
|
||||||
|
{
|
||||||
|
Info<< "Clearing triangulation" << endl;
|
||||||
|
|
||||||
|
DynamicList<Vb> vertices;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||||
|
vit != Triangulation::finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->fixed())
|
||||||
|
{
|
||||||
|
vertices.append
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
vit->point(),
|
||||||
|
vit->index(),
|
||||||
|
vit->type(),
|
||||||
|
vit->procIndex()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
vertices.last().fixed() = vit->fixed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this->clear();
|
||||||
|
|
||||||
|
resetVertexCount();
|
||||||
|
resetCellCount();
|
||||||
|
|
||||||
|
insertPoints(vertices);
|
||||||
|
|
||||||
|
Info<< "Inserted " << vertexCount() << " fixed points" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::insertPoints(const List<Vb>& vertices)
|
||||||
|
{
|
||||||
|
rangeInsertWithInfo
|
||||||
|
(
|
||||||
|
vertices.begin(),
|
||||||
|
vertices.end(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_x_3::
|
||||||
|
operator()
|
||||||
|
(
|
||||||
|
const Point_3& p,
|
||||||
|
const Point_3& q
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return typename Gt::Less_x_3()(*(p.first), *(q.first));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_y_3::
|
||||||
|
operator()
|
||||||
|
(
|
||||||
|
const Point_3& p,
|
||||||
|
const Point_3& q
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return typename Gt::Less_y_3()(*(p.first), *(q.first));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_z_3::
|
||||||
|
operator()
|
||||||
|
(
|
||||||
|
const Point_3& p,
|
||||||
|
const Point_3& q
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return typename Gt::Less_z_3()(*(p.first), *(q.first));
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_x_3
|
||||||
|
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_x_3_object()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return Less_x_3();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_y_3
|
||||||
|
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_y_3_object()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return Less_y_3();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
typename Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::Less_z_3
|
||||||
|
Foam::DelaunayMesh<Triangulation>::Traits_for_spatial_sort::less_z_3_object()
|
||||||
|
const
|
||||||
|
{
|
||||||
|
return Less_z_3();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
template<class PointIterator>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::rangeInsertWithInfo
|
||||||
|
(
|
||||||
|
PointIterator begin,
|
||||||
|
PointIterator end,
|
||||||
|
bool printErrors
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typedef DynamicList
|
||||||
|
<
|
||||||
|
std::pair
|
||||||
|
<
|
||||||
|
const typename Triangulation::Point*,
|
||||||
|
label
|
||||||
|
>
|
||||||
|
> vectorPairPointIndex;
|
||||||
|
|
||||||
|
vectorPairPointIndex points;
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
for (PointIterator it = begin; it != end; ++it)
|
||||||
|
{
|
||||||
|
points.append
|
||||||
|
(
|
||||||
|
std::make_pair(&(it->point()), count++)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::random_shuffle(points.begin(), points.end());
|
||||||
|
|
||||||
|
spatial_sort
|
||||||
|
(
|
||||||
|
points.begin(),
|
||||||
|
points.end(),
|
||||||
|
Traits_for_spatial_sort()
|
||||||
|
);
|
||||||
|
|
||||||
|
Vertex_handle hint;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename vectorPairPointIndex::const_iterator p = points.begin();
|
||||||
|
p != points.end();
|
||||||
|
++p
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const size_t checkInsertion = Triangulation::number_of_vertices();
|
||||||
|
|
||||||
|
hint = this->insert(*(p->first), hint);
|
||||||
|
|
||||||
|
const Vb& vert = *(begin + p->second);
|
||||||
|
|
||||||
|
if (checkInsertion != Triangulation::number_of_vertices() - 1)
|
||||||
|
{
|
||||||
|
if (printErrors)
|
||||||
|
{
|
||||||
|
Vertex_handle nearV =
|
||||||
|
Triangulation::nearest_vertex(*(p->first));
|
||||||
|
|
||||||
|
Pout<< "Failed insertion : " << vert.info()
|
||||||
|
<< " nearest : " << nearV->info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hint->index() = getNewVertexIndex();
|
||||||
|
hint->type() = vert.type();
|
||||||
|
hint->procIndex() = vert.procIndex();
|
||||||
|
hint->targetCellSize() = vert.targetCellSize();
|
||||||
|
hint->alignment() = vert.alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "DelaunayMeshIO.C"
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,240 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::DelaunayMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
The vertex and cell classes must have an index defined
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
DelaunayMeshI.H
|
||||||
|
DelaunayMesh.C
|
||||||
|
DelaunayMeshIO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef DelaunayMesh_H
|
||||||
|
#define DelaunayMesh_H
|
||||||
|
|
||||||
|
#include "Pair.H"
|
||||||
|
#include "HashSet.H"
|
||||||
|
#include "FixedList.H"
|
||||||
|
#include "boundBox.H"
|
||||||
|
#include "indexedVertex.H"
|
||||||
|
#include "CGALTriangulation3Ddefs.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class fvMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class DelaunayMesh Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
class DelaunayMesh
|
||||||
|
:
|
||||||
|
public Triangulation
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename Triangulation::Cell_handle Cell_handle;
|
||||||
|
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||||
|
typedef typename Triangulation::Edge Edge;
|
||||||
|
typedef typename Triangulation::Point Point;
|
||||||
|
typedef typename Triangulation::Facet Facet;
|
||||||
|
|
||||||
|
typedef typename Triangulation::Finite_vertices_iterator
|
||||||
|
Finite_vertices_iterator;
|
||||||
|
typedef typename Triangulation::Finite_cells_iterator
|
||||||
|
Finite_cells_iterator;
|
||||||
|
typedef typename Triangulation::Finite_facets_iterator
|
||||||
|
Finite_facets_iterator;
|
||||||
|
|
||||||
|
typedef HashSet
|
||||||
|
<
|
||||||
|
Pair<label>,
|
||||||
|
FixedList<label, 2>::Hash<>
|
||||||
|
> labelPairHashSet;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Keep track of the number of vertices that have been added.
|
||||||
|
// This allows a unique index to be assigned to each vertex.
|
||||||
|
mutable label vertexCount_;
|
||||||
|
|
||||||
|
//- Keep track of the number of cells that have been added.
|
||||||
|
// This allows a unique index to be assigned to each cell.
|
||||||
|
mutable label cellCount_;
|
||||||
|
|
||||||
|
//- Spatial sort traits to use with a pair of point pointers and an int.
|
||||||
|
// Taken from a post on the CGAL lists: 2010-01/msg00004.html by
|
||||||
|
// Sebastien Loriot (Geometry Factory).
|
||||||
|
struct Traits_for_spatial_sort
|
||||||
|
:
|
||||||
|
public Triangulation::Geom_traits
|
||||||
|
{
|
||||||
|
typedef typename Triangulation::Geom_traits Gt;
|
||||||
|
|
||||||
|
typedef std::pair<const typename Triangulation::Point*, int>
|
||||||
|
Point_3;
|
||||||
|
|
||||||
|
struct Less_x_3
|
||||||
|
{
|
||||||
|
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Less_y_3
|
||||||
|
{
|
||||||
|
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Less_z_3
|
||||||
|
{
|
||||||
|
bool operator()(const Point_3& p, const Point_3& q) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
Less_x_3 less_x_3_object() const;
|
||||||
|
Less_y_3 less_y_3_object() const;
|
||||||
|
Less_z_3 less_z_3_object() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void sortFaces
|
||||||
|
(
|
||||||
|
faceList& faces,
|
||||||
|
labelList& owner,
|
||||||
|
labelList& neighbour
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void addPatches
|
||||||
|
(
|
||||||
|
const label nInternalFaces,
|
||||||
|
faceList& faces,
|
||||||
|
labelList& owner,
|
||||||
|
PtrList<dictionary>& patchDicts,
|
||||||
|
const List<DynamicList<face> >& patchFaces,
|
||||||
|
const List<DynamicList<label> >& patchOwners
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
DelaunayMesh(const DelaunayMesh<Triangulation>&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const DelaunayMesh<Triangulation>&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
DelaunayMesh();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~DelaunayMesh();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
inline label getNewVertexIndex() const;
|
||||||
|
|
||||||
|
inline label getNewCellIndex() const;
|
||||||
|
|
||||||
|
inline label cellCount() const;
|
||||||
|
|
||||||
|
inline void resetCellCount();
|
||||||
|
|
||||||
|
inline label vertexCount() const;
|
||||||
|
|
||||||
|
inline void resetVertexCount();
|
||||||
|
|
||||||
|
|
||||||
|
//- Remove the entire triangulation
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
void insertPoints(const List<Vb>& vertices);
|
||||||
|
|
||||||
|
//- Function inserting points into a triangulation and setting the
|
||||||
|
// index and type data of the point in the correct order. This is
|
||||||
|
// faster than inserting points individually.
|
||||||
|
//
|
||||||
|
// Adapted from a post on the CGAL lists: 2010-01/msg00004.html by
|
||||||
|
// Sebastien Loriot (Geometry Factory).
|
||||||
|
template<class PointIterator>
|
||||||
|
void rangeInsertWithInfo
|
||||||
|
(
|
||||||
|
PointIterator begin,
|
||||||
|
PointIterator end,
|
||||||
|
bool printErrors = true
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Queries
|
||||||
|
|
||||||
|
void printInfo(Ostream& os) const;
|
||||||
|
|
||||||
|
void printVertexInfo(Ostream& os) const;
|
||||||
|
|
||||||
|
//- Create an fvMesh from the triangulation.
|
||||||
|
// The mesh is not parallel consistent - only used for viewing
|
||||||
|
autoPtr<fvMesh> createMesh
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const Time& runTime,
|
||||||
|
labelList& vertexMap,
|
||||||
|
labelList& cellMap
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "DelaunayMeshI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "DelaunayMesh.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,119 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
inline Foam::label Foam::DelaunayMesh<Triangulation>::getNewVertexIndex() const
|
||||||
|
{
|
||||||
|
label id = vertexCount_++;
|
||||||
|
|
||||||
|
if (id == labelMax)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"Foam::DelaunayMesh<Triangulation>::getNewVertexIndex() const"
|
||||||
|
) << "Vertex counter has overflowed." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
inline Foam::label Foam::DelaunayMesh<Triangulation>::getNewCellIndex() const
|
||||||
|
{
|
||||||
|
label id = cellCount_++;
|
||||||
|
|
||||||
|
if (id == labelMax)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"Foam::DelaunayMesh<Triangulation>::getNewCellIndex() const"
|
||||||
|
) << "Cell counter has overflowed." << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::label Foam::DelaunayMesh<Triangulation>::cellCount() const
|
||||||
|
{
|
||||||
|
return cellCount_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::resetCellCount()
|
||||||
|
{
|
||||||
|
cellCount_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::label Foam::DelaunayMesh<Triangulation>::vertexCount() const
|
||||||
|
{
|
||||||
|
return vertexCount_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::resetVertexCount()
|
||||||
|
{
|
||||||
|
vertexCount_ = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,576 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "DelaunayMesh.H"
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "pointConversion.H"
|
||||||
|
#include "wallPolyPatch.H"
|
||||||
|
#include "processorPolyPatch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::sortFaces
|
||||||
|
(
|
||||||
|
faceList& faces,
|
||||||
|
labelList& owner,
|
||||||
|
labelList& neighbour
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Upper triangular order:
|
||||||
|
// + owner is sorted in ascending cell order
|
||||||
|
// + within each block of equal value for owner, neighbour is sorted in
|
||||||
|
// ascending cell order.
|
||||||
|
// + faces sorted to correspond
|
||||||
|
// e.g.
|
||||||
|
// owner | neighbour
|
||||||
|
// 0 | 2
|
||||||
|
// 0 | 23
|
||||||
|
// 0 | 71
|
||||||
|
// 1 | 23
|
||||||
|
// 1 | 24
|
||||||
|
// 1 | 91
|
||||||
|
|
||||||
|
List<labelPair> ownerNeighbourPair(owner.size());
|
||||||
|
|
||||||
|
forAll(ownerNeighbourPair, oNI)
|
||||||
|
{
|
||||||
|
ownerNeighbourPair[oNI] = labelPair(owner[oNI], neighbour[oNI]);
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl
|
||||||
|
<< "Sorting faces, owner and neighbour into upper triangular order"
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
labelList oldToNew;
|
||||||
|
|
||||||
|
sortedOrder(ownerNeighbourPair, oldToNew);
|
||||||
|
|
||||||
|
oldToNew = invert(oldToNew.size(), oldToNew);
|
||||||
|
|
||||||
|
inplaceReorder(oldToNew, faces);
|
||||||
|
inplaceReorder(oldToNew, owner);
|
||||||
|
inplaceReorder(oldToNew, neighbour);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::addPatches
|
||||||
|
(
|
||||||
|
const label nInternalFaces,
|
||||||
|
faceList& faces,
|
||||||
|
labelList& owner,
|
||||||
|
PtrList<dictionary>& patchDicts,
|
||||||
|
const List<DynamicList<face> >& patchFaces,
|
||||||
|
const List<DynamicList<label> >& patchOwners
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
label nPatches = patchFaces.size();
|
||||||
|
|
||||||
|
patchDicts.setSize(nPatches);
|
||||||
|
forAll(patchDicts, patchI)
|
||||||
|
{
|
||||||
|
patchDicts.set(patchI, new dictionary());
|
||||||
|
}
|
||||||
|
|
||||||
|
label nBoundaryFaces = 0;
|
||||||
|
|
||||||
|
forAll(patchFaces, p)
|
||||||
|
{
|
||||||
|
patchDicts[p].set("nFaces", patchFaces[p].size());
|
||||||
|
patchDicts[p].set("startFace", nInternalFaces + nBoundaryFaces);
|
||||||
|
|
||||||
|
nBoundaryFaces += patchFaces[p].size();
|
||||||
|
}
|
||||||
|
|
||||||
|
faces.setSize(nInternalFaces + nBoundaryFaces);
|
||||||
|
owner.setSize(nInternalFaces + nBoundaryFaces);
|
||||||
|
|
||||||
|
label faceI = nInternalFaces;
|
||||||
|
|
||||||
|
forAll(patchFaces, p)
|
||||||
|
{
|
||||||
|
forAll(patchFaces[p], f)
|
||||||
|
{
|
||||||
|
faces[faceI] = patchFaces[p][f];
|
||||||
|
owner[faceI] = patchOwners[p][f];
|
||||||
|
|
||||||
|
faceI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::printInfo(Ostream& os) const
|
||||||
|
{
|
||||||
|
PrintTable<word, label> triInfoTable("Mesh Statistics");
|
||||||
|
|
||||||
|
triInfoTable.add("Points", Triangulation::number_of_vertices());
|
||||||
|
triInfoTable.add("Edges", Triangulation::number_of_finite_edges());
|
||||||
|
triInfoTable.add("Faces", Triangulation::number_of_finite_facets());
|
||||||
|
triInfoTable.add("Cells", Triangulation::number_of_finite_cells());
|
||||||
|
|
||||||
|
scalar minSize = GREAT;
|
||||||
|
scalar maxSize = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||||
|
vit != Triangulation::finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->farPoint())
|
||||||
|
{
|
||||||
|
minSize = min(vit->targetCellSize(), minSize);
|
||||||
|
maxSize = max(vit->targetCellSize(), maxSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< incrIndent;
|
||||||
|
triInfoTable.print(Info, true, true);
|
||||||
|
|
||||||
|
Info<< "Size (Min/Max) = "
|
||||||
|
<< returnReduce(minSize, minOp<scalar>()) << " "
|
||||||
|
<< returnReduce(maxSize, maxOp<scalar>()) << endl;
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DelaunayMesh<Triangulation>::printVertexInfo(Ostream& os) const
|
||||||
|
{
|
||||||
|
label nInternal = 0;
|
||||||
|
label nInternalRef = 0;
|
||||||
|
label nUnassigned = 0;
|
||||||
|
label nUnassignedRef = 0;
|
||||||
|
label nInternalNearBoundary = 0;
|
||||||
|
label nInternalNearBoundaryRef = 0;
|
||||||
|
label nInternalSurface = 0;
|
||||||
|
label nInternalSurfaceRef = 0;
|
||||||
|
label nInternalFeatureEdge = 0;
|
||||||
|
label nInternalFeatureEdgeRef = 0;
|
||||||
|
label nInternalFeaturePoint = 0;
|
||||||
|
label nInternalFeaturePointRef = 0;
|
||||||
|
label nExternalSurface = 0;
|
||||||
|
label nExternalSurfaceRef = 0;
|
||||||
|
label nExternalFeatureEdge = 0;
|
||||||
|
label nExternalFeatureEdgeRef = 0;
|
||||||
|
label nExternalFeaturePoint = 0;
|
||||||
|
label nExternalFeaturePointRef = 0;
|
||||||
|
label nFar = 0;
|
||||||
|
label nReferred = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||||
|
vit != Triangulation::finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->type() == Vb::vtInternal)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nInternalRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nInternal++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtUnassigned)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nUnassignedRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nUnassigned++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtInternalNearBoundary)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nInternalNearBoundaryRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nInternalNearBoundary++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtInternalSurface)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nInternalSurfaceRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nInternalSurface++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtInternalFeatureEdge)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nInternalFeatureEdgeRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nInternalFeatureEdge++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtInternalFeaturePoint)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nInternalFeaturePointRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nInternalFeaturePoint++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtExternalSurface)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nExternalSurfaceRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nExternalSurface++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtExternalFeatureEdge)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nExternalFeatureEdgeRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nExternalFeatureEdge++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtExternalFeaturePoint)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
nReferred++;
|
||||||
|
nExternalFeaturePointRef++;
|
||||||
|
}
|
||||||
|
|
||||||
|
nExternalFeaturePoint++;
|
||||||
|
}
|
||||||
|
else if (vit->type() == Vb::vtFar)
|
||||||
|
{
|
||||||
|
nFar++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label nTotalVertices =
|
||||||
|
nUnassigned
|
||||||
|
+ nInternal
|
||||||
|
+ nInternalNearBoundary
|
||||||
|
+ nInternalSurface
|
||||||
|
+ nInternalFeatureEdge
|
||||||
|
+ nInternalFeaturePoint
|
||||||
|
+ nExternalSurface
|
||||||
|
+ nExternalFeatureEdge
|
||||||
|
+ nExternalFeaturePoint
|
||||||
|
+ nFar;
|
||||||
|
|
||||||
|
if (nTotalVertices != label(Triangulation::number_of_vertices()))
|
||||||
|
{
|
||||||
|
WarningIn("Foam::conformalVoronoiMesh::printVertexInfo()")
|
||||||
|
<< nTotalVertices << " does not equal "
|
||||||
|
<< Triangulation::number_of_vertices()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintTable<word, label> vertexTable("Vertex Type Information");
|
||||||
|
|
||||||
|
vertexTable.add("Total", nTotalVertices);
|
||||||
|
vertexTable.add("Unassigned", nUnassigned);
|
||||||
|
vertexTable.add("nInternal", nInternal);
|
||||||
|
vertexTable.add("nInternalNearBoundary", nInternalNearBoundary);
|
||||||
|
vertexTable.add("nInternalSurface", nInternalSurface);
|
||||||
|
vertexTable.add("nInternalFeatureEdge", nInternalFeatureEdge);
|
||||||
|
vertexTable.add("nInternalFeaturePoint", nInternalFeaturePoint);
|
||||||
|
vertexTable.add("nExternalSurface", nExternalSurface);
|
||||||
|
vertexTable.add("nExternalFeatureEdge", nExternalFeatureEdge);
|
||||||
|
vertexTable.add("nExternalFeaturePoint", nExternalFeaturePoint);
|
||||||
|
vertexTable.add("nFar", nFar);
|
||||||
|
vertexTable.add("nReferred", nReferred);
|
||||||
|
|
||||||
|
os << endl;
|
||||||
|
vertexTable.print(os);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::autoPtr<Foam::fvMesh>
|
||||||
|
Foam::DelaunayMesh<Triangulation>::createMesh
|
||||||
|
(
|
||||||
|
const fileName& name,
|
||||||
|
const Time& runTime,
|
||||||
|
labelList& vertexMap,
|
||||||
|
labelList& cellMap
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
pointField points(Triangulation::number_of_vertices());
|
||||||
|
faceList faces(Triangulation::number_of_finite_facets());
|
||||||
|
labelList owner(Triangulation::number_of_finite_facets());
|
||||||
|
labelList neighbour(Triangulation::number_of_finite_facets());
|
||||||
|
|
||||||
|
wordList patchNames(1, "foamyHexMesh_defaultPatch");
|
||||||
|
wordList patchTypes(1, wallPolyPatch::typeName);
|
||||||
|
|
||||||
|
PtrList<dictionary> patchDicts(1);
|
||||||
|
patchDicts.set(0, new dictionary());
|
||||||
|
|
||||||
|
List<DynamicList<face> > patchFaces(1, DynamicList<face>());
|
||||||
|
List<DynamicList<label> > patchOwners(1, DynamicList<label>());
|
||||||
|
|
||||||
|
vertexMap.setSize(vertexCount(), -1);
|
||||||
|
cellMap.setSize(Triangulation::number_of_finite_cells(), -1);
|
||||||
|
|
||||||
|
// Calculate pts and a map of point index to location in pts.
|
||||||
|
label vertI = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||||
|
vit != Triangulation::finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->farPoint())
|
||||||
|
{
|
||||||
|
vertexMap[vit->index()] = vertI;
|
||||||
|
points[vertI] = topoint(vit->point());
|
||||||
|
vertI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
points.setSize(vertI);
|
||||||
|
|
||||||
|
// Index the cells
|
||||||
|
label cellI = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_cells_iterator cit = Triangulation::finite_cells_begin();
|
||||||
|
cit != Triangulation::finite_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!cit->hasFarPoint()
|
||||||
|
&& !Triangulation::is_infinite(cit)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
cellMap[cit->cellIndex()] = cellI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label faceI = 0;
|
||||||
|
labelList verticesOnTriFace(3, -1);
|
||||||
|
face newFace(verticesOnTriFace);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_facets_iterator fit = Triangulation::finite_facets_begin();
|
||||||
|
fit != Triangulation::finite_facets_end();
|
||||||
|
++fit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const Cell_handle c1(fit->first);
|
||||||
|
const int oppositeVertex = fit->second;
|
||||||
|
const Cell_handle c2(c1->neighbor(oppositeVertex));
|
||||||
|
|
||||||
|
// Do not output if face has neither opposite vertex as an internal
|
||||||
|
// if
|
||||||
|
// (
|
||||||
|
// !c1->vertex(oppositeVertex)->internalPoint()
|
||||||
|
// || !Triangulation::mirror_vertex(c1, oppositeVertex)->internalPoint()
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
label c1I = Cb::ctFar;
|
||||||
|
bool c1Real = false;
|
||||||
|
if (!c1->hasFarPoint() && !Triangulation::is_infinite(c1))
|
||||||
|
{
|
||||||
|
c1I = cellMap[c1->cellIndex()];
|
||||||
|
c1Real = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
label c2I = Cb::ctFar;
|
||||||
|
bool c2Real = false;
|
||||||
|
if (!c2->hasFarPoint() && !Triangulation::is_infinite(c2))
|
||||||
|
{
|
||||||
|
c2I = cellMap[c2->cellIndex()];
|
||||||
|
c2Real = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!c1Real && !c2Real)
|
||||||
|
{
|
||||||
|
// Both tets are outside, skip
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
label ownerCell = -1;
|
||||||
|
label neighbourCell = -1;
|
||||||
|
|
||||||
|
for (label i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
verticesOnTriFace[i] = vertexMap
|
||||||
|
[
|
||||||
|
c1->vertex
|
||||||
|
(
|
||||||
|
Triangulation::vertex_triple_index(oppositeVertex, i)
|
||||||
|
)->index()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
newFace = face(verticesOnTriFace);
|
||||||
|
|
||||||
|
if (!c1Real || !c2Real)
|
||||||
|
{
|
||||||
|
// Boundary face...
|
||||||
|
if (!c1Real)
|
||||||
|
{
|
||||||
|
//... with c1 outside
|
||||||
|
ownerCell = c2I;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ... with c2 outside
|
||||||
|
ownerCell = c1I;
|
||||||
|
|
||||||
|
reverse(newFace);
|
||||||
|
}
|
||||||
|
|
||||||
|
patchFaces[0].append(newFace);
|
||||||
|
patchOwners[0].append(ownerCell);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Internal face...
|
||||||
|
if (c1I < c2I)
|
||||||
|
{
|
||||||
|
// ...with c1 as the ownerCell
|
||||||
|
ownerCell = c1I;
|
||||||
|
neighbourCell = c2I;
|
||||||
|
|
||||||
|
reverse(newFace);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// ...with c2 as the ownerCell
|
||||||
|
ownerCell = c2I;
|
||||||
|
neighbourCell = c1I;
|
||||||
|
}
|
||||||
|
|
||||||
|
faces[faceI] = newFace;
|
||||||
|
owner[faceI] = ownerCell;
|
||||||
|
neighbour[faceI] = neighbourCell;
|
||||||
|
faceI++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
faces.setSize(faceI);
|
||||||
|
owner.setSize(faceI);
|
||||||
|
neighbour.setSize(faceI);
|
||||||
|
|
||||||
|
sortFaces(faces, owner, neighbour);
|
||||||
|
|
||||||
|
Info<< "Creating patches" << endl;
|
||||||
|
|
||||||
|
addPatches
|
||||||
|
(
|
||||||
|
faceI,
|
||||||
|
faces,
|
||||||
|
owner,
|
||||||
|
patchDicts,
|
||||||
|
patchFaces,
|
||||||
|
patchOwners
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Creating mesh" << endl;
|
||||||
|
|
||||||
|
autoPtr<fvMesh> meshPtr
|
||||||
|
(
|
||||||
|
new fvMesh
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
runTime.timeName(),
|
||||||
|
runTime,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
xferMove(points),
|
||||||
|
xferMove(faces),
|
||||||
|
xferMove(owner),
|
||||||
|
xferMove(neighbour)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< "Adding patches" << endl;
|
||||||
|
|
||||||
|
List<polyPatch*> patches(patchNames.size());
|
||||||
|
|
||||||
|
label nValidPatches = 0;
|
||||||
|
|
||||||
|
forAll(patches, p)
|
||||||
|
{
|
||||||
|
patches[nValidPatches] = polyPatch::New
|
||||||
|
(
|
||||||
|
patchTypes[p],
|
||||||
|
patchNames[p],
|
||||||
|
patchDicts[p],
|
||||||
|
nValidPatches,
|
||||||
|
meshPtr().boundaryMesh()
|
||||||
|
).ptr();
|
||||||
|
|
||||||
|
nValidPatches++;
|
||||||
|
}
|
||||||
|
|
||||||
|
patches.setSize(nValidPatches);
|
||||||
|
|
||||||
|
meshPtr().addFvPatches(patches);
|
||||||
|
|
||||||
|
Info<< "Mesh created" << endl;
|
||||||
|
|
||||||
|
return meshPtr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,959 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "DistributedDelaunayMesh.H"
|
||||||
|
#include "meshSearch.H"
|
||||||
|
#include "mapDistribute.H"
|
||||||
|
#include "zeroGradientFvPatchFields.H"
|
||||||
|
#include "pointConversion.H"
|
||||||
|
#include "indexedVertexEnum.H"
|
||||||
|
#include "IOmanip.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::autoPtr<Foam::mapDistribute>
|
||||||
|
Foam::DistributedDelaunayMesh<Triangulation>::buildMap
|
||||||
|
(
|
||||||
|
const List<label>& toProc
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Determine send map
|
||||||
|
// ~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
// 1. Count
|
||||||
|
labelList nSend(Pstream::nProcs(), 0);
|
||||||
|
|
||||||
|
forAll(toProc, i)
|
||||||
|
{
|
||||||
|
label procI = toProc[i];
|
||||||
|
|
||||||
|
nSend[procI]++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send over how many I need to receive
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
labelListList sendSizes(Pstream::nProcs());
|
||||||
|
|
||||||
|
sendSizes[Pstream::myProcNo()] = nSend;
|
||||||
|
|
||||||
|
combineReduce(sendSizes, UPstream::listEq());
|
||||||
|
|
||||||
|
// 2. Size sendMap
|
||||||
|
labelListList sendMap(Pstream::nProcs());
|
||||||
|
|
||||||
|
forAll(nSend, procI)
|
||||||
|
{
|
||||||
|
sendMap[procI].setSize(nSend[procI]);
|
||||||
|
|
||||||
|
nSend[procI] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. Fill sendMap
|
||||||
|
forAll(toProc, i)
|
||||||
|
{
|
||||||
|
label procI = toProc[i];
|
||||||
|
|
||||||
|
sendMap[procI][nSend[procI]++] = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine receive map
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
labelListList constructMap(Pstream::nProcs());
|
||||||
|
|
||||||
|
// Local transfers first
|
||||||
|
constructMap[Pstream::myProcNo()] = identity
|
||||||
|
(
|
||||||
|
sendMap[Pstream::myProcNo()].size()
|
||||||
|
);
|
||||||
|
|
||||||
|
label constructSize = constructMap[Pstream::myProcNo()].size();
|
||||||
|
|
||||||
|
forAll(constructMap, procI)
|
||||||
|
{
|
||||||
|
if (procI != Pstream::myProcNo())
|
||||||
|
{
|
||||||
|
label nRecv = sendSizes[procI][Pstream::myProcNo()];
|
||||||
|
|
||||||
|
constructMap[procI].setSize(nRecv);
|
||||||
|
|
||||||
|
for (label i = 0; i < nRecv; i++)
|
||||||
|
{
|
||||||
|
constructMap[procI][i] = constructSize++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<mapDistribute>
|
||||||
|
(
|
||||||
|
new mapDistribute
|
||||||
|
(
|
||||||
|
constructSize,
|
||||||
|
sendMap.xfer(),
|
||||||
|
constructMap.xfer()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::DistributedDelaunayMesh<Triangulation>::DistributedDelaunayMesh()
|
||||||
|
:
|
||||||
|
DelaunayMesh<Triangulation>(),
|
||||||
|
allBackgroundMeshBounds_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::DistributedDelaunayMesh<Triangulation>::~DistributedDelaunayMesh()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DistributedDelaunayMesh<Triangulation>::distributeBoundBoxes
|
||||||
|
(
|
||||||
|
const boundBox& bb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
allBackgroundMeshBounds_.reset(new List<boundBox>(Pstream::nProcs()));
|
||||||
|
|
||||||
|
// Give the bounds of every processor to every other processor
|
||||||
|
allBackgroundMeshBounds_()[Pstream::myProcNo()] = bb;
|
||||||
|
|
||||||
|
Pstream::gatherList(allBackgroundMeshBounds_());
|
||||||
|
Pstream::scatterList(allBackgroundMeshBounds_());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DistributedDelaunayMesh<Triangulation>::isLocal
|
||||||
|
(
|
||||||
|
const Vertex_handle& v
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return isLocal(v->procIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DistributedDelaunayMesh<Triangulation>::isLocal
|
||||||
|
(
|
||||||
|
const label localProcIndex
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return localProcIndex == Pstream::myProcNo();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::labelList Foam::DistributedDelaunayMesh<Triangulation>::overlapProcessors
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar radiusSqr
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
DynamicList<label> toProc(Pstream::nProcs());
|
||||||
|
|
||||||
|
forAll(allBackgroundMeshBounds_(), procI)
|
||||||
|
{
|
||||||
|
// Test against the bounding box of the processor
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!isLocal(procI)
|
||||||
|
&& allBackgroundMeshBounds_()[procI].overlaps(centre, radiusSqr)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
toProc.append(procI);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return toProc;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DistributedDelaunayMesh<Triangulation>::checkProcBoundaryCell
|
||||||
|
(
|
||||||
|
const Cell_handle& cit,
|
||||||
|
Map<labelList>& circumsphereOverlaps
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const Foam::point& cc = cit->dual();
|
||||||
|
|
||||||
|
const scalar crSqr = magSqr
|
||||||
|
(
|
||||||
|
cc - topoint(cit->vertex(0)->point())
|
||||||
|
);
|
||||||
|
|
||||||
|
labelList circumsphereOverlap = overlapProcessors
|
||||||
|
(
|
||||||
|
cc,
|
||||||
|
sqr(1.01)*crSqr
|
||||||
|
);
|
||||||
|
|
||||||
|
cit->cellIndex() = this->getNewCellIndex();
|
||||||
|
|
||||||
|
if (!circumsphereOverlap.empty())
|
||||||
|
{
|
||||||
|
circumsphereOverlaps.insert(cit->cellIndex(), circumsphereOverlap);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DistributedDelaunayMesh<Triangulation>::findProcessorBoundaryCells
|
||||||
|
(
|
||||||
|
Map<labelList>& circumsphereOverlaps
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Start by assuming that all the cells have no index
|
||||||
|
// If they do, they have already been visited so ignore them
|
||||||
|
|
||||||
|
labelHashSet cellToCheck
|
||||||
|
(
|
||||||
|
Triangulation::number_of_finite_cells()
|
||||||
|
/Pstream::nProcs()
|
||||||
|
);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
All_cells_iterator cit = Triangulation::all_cells_begin();
|
||||||
|
cit != Triangulation::all_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Triangulation::is_infinite(cit))
|
||||||
|
{
|
||||||
|
// Index of infinite vertex in this cell.
|
||||||
|
int i = cit->index(Triangulation::infinite_vertex());
|
||||||
|
|
||||||
|
Cell_handle c = cit->neighbor(i);
|
||||||
|
|
||||||
|
if (c->unassigned())
|
||||||
|
{
|
||||||
|
c->cellIndex() = this->getNewCellIndex();
|
||||||
|
|
||||||
|
if (checkProcBoundaryCell(c, circumsphereOverlaps))
|
||||||
|
{
|
||||||
|
cellToCheck.insert(c->cellIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cit->parallelDualVertex())
|
||||||
|
{
|
||||||
|
if (cit->unassigned())
|
||||||
|
{
|
||||||
|
if (checkProcBoundaryCell(cit, circumsphereOverlaps))
|
||||||
|
{
|
||||||
|
cellToCheck.insert(cit->cellIndex());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_cells_iterator cit = Triangulation::finite_cells_begin();
|
||||||
|
cit != Triangulation::finite_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (cellToCheck.found(cit->cellIndex()))
|
||||||
|
{
|
||||||
|
// Get the neighbours and check them
|
||||||
|
for (label adjCellI = 0; adjCellI < 4; ++adjCellI)
|
||||||
|
{
|
||||||
|
Cell_handle citNeighbor = cit->neighbor(adjCellI);
|
||||||
|
|
||||||
|
// Ignore if has far point or previously visited
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!citNeighbor->unassigned()
|
||||||
|
|| !citNeighbor->internalOrBoundaryDualVertex()
|
||||||
|
|| Triangulation::is_infinite(citNeighbor)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkProcBoundaryCell
|
||||||
|
(
|
||||||
|
citNeighbor,
|
||||||
|
circumsphereOverlaps
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DistributedDelaunayMesh<Triangulation>::markVerticesToRefer
|
||||||
|
(
|
||||||
|
const Map<labelList>& circumsphereOverlaps,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
DynamicList<label>& targetProcessor,
|
||||||
|
DynamicList<Vb>& parallelInfluenceVertices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Relying on the order of iteration of cells being the same as before
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_cells_iterator cit = Triangulation::finite_cells_begin();
|
||||||
|
cit != Triangulation::finite_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (Triangulation::is_infinite(cit))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<labelList>::const_iterator iter =
|
||||||
|
circumsphereOverlaps.find(cit->cellIndex());
|
||||||
|
|
||||||
|
// Pre-tested circumsphere potential influence
|
||||||
|
if (iter != circumsphereOverlaps.cend())
|
||||||
|
{
|
||||||
|
const labelList& citOverlaps = iter();
|
||||||
|
|
||||||
|
forAll(citOverlaps, cOI)
|
||||||
|
{
|
||||||
|
label procI = citOverlaps[cOI];
|
||||||
|
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
Vertex_handle v = cit->vertex(i);
|
||||||
|
|
||||||
|
if (v->farPoint())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
label vProcIndex = v->procIndex();
|
||||||
|
label vIndex = v->index();
|
||||||
|
|
||||||
|
const labelPair procIndexPair(vProcIndex, vIndex);
|
||||||
|
|
||||||
|
// Using the hashSet to ensure that each vertex is only
|
||||||
|
// referred once to each processor.
|
||||||
|
// Do not refer a vertex to its own processor.
|
||||||
|
if (vProcIndex != procI)
|
||||||
|
{
|
||||||
|
if (referralVertices[procI].insert(procIndexPair))
|
||||||
|
{
|
||||||
|
targetProcessor.append(procI);
|
||||||
|
|
||||||
|
parallelInfluenceVertices.append
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
v->point(),
|
||||||
|
v->index(),
|
||||||
|
v->type(),
|
||||||
|
v->procIndex()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
parallelInfluenceVertices.last().targetCellSize() =
|
||||||
|
v->targetCellSize();
|
||||||
|
parallelInfluenceVertices.last().alignment() =
|
||||||
|
v->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::label Foam::DistributedDelaunayMesh<Triangulation>::referVertices
|
||||||
|
(
|
||||||
|
const DynamicList<label>& targetProcessor,
|
||||||
|
DynamicList<Vb>& parallelVertices,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
labelPairHashSet& receivedVertices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DynamicList<Vb> referredVertices(targetProcessor.size());
|
||||||
|
|
||||||
|
const label preDistributionSize = parallelVertices.size();
|
||||||
|
|
||||||
|
mapDistribute pointMap = buildMap(targetProcessor);
|
||||||
|
|
||||||
|
// Make a copy of the original list.
|
||||||
|
DynamicList<Vb> originalParallelVertices(parallelVertices);
|
||||||
|
|
||||||
|
pointMap.distribute(parallelVertices);
|
||||||
|
|
||||||
|
for (label procI = 0; procI < Pstream::nProcs(); procI++)
|
||||||
|
{
|
||||||
|
const labelList& constructMap = pointMap.constructMap()[procI];
|
||||||
|
|
||||||
|
if (constructMap.size())
|
||||||
|
{
|
||||||
|
forAll(constructMap, i)
|
||||||
|
{
|
||||||
|
const Vb& v = parallelVertices[constructMap[i]];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
v.procIndex() != Pstream::myProcNo()
|
||||||
|
&& !receivedVertices.found(labelPair(v.procIndex(), v.index()))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
referredVertices.append(v);
|
||||||
|
|
||||||
|
receivedVertices.insert
|
||||||
|
(
|
||||||
|
labelPair(v.procIndex(), v.index())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label preInsertionSize = Triangulation::number_of_vertices();
|
||||||
|
|
||||||
|
labelPairHashSet pointsNotInserted = rangeInsertReferredWithInfo
|
||||||
|
(
|
||||||
|
referredVertices.begin(),
|
||||||
|
referredVertices.end()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!pointsNotInserted.empty())
|
||||||
|
{
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename labelPairHashSet::const_iterator iter
|
||||||
|
= pointsNotInserted.begin();
|
||||||
|
iter != pointsNotInserted.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (receivedVertices.found(iter.key()))
|
||||||
|
{
|
||||||
|
receivedVertices.erase(iter.key());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolList pointInserted(parallelVertices.size(), true);
|
||||||
|
|
||||||
|
forAll(parallelVertices, vI)
|
||||||
|
{
|
||||||
|
const labelPair procIndexI
|
||||||
|
(
|
||||||
|
parallelVertices[vI].procIndex(),
|
||||||
|
parallelVertices[vI].index()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (pointsNotInserted.found(procIndexI))
|
||||||
|
{
|
||||||
|
pointInserted[vI] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pointMap.reverseDistribute(preDistributionSize, pointInserted);
|
||||||
|
|
||||||
|
forAll(originalParallelVertices, vI)
|
||||||
|
{
|
||||||
|
const label procIndex = targetProcessor[vI];
|
||||||
|
|
||||||
|
if (!pointInserted[vI])
|
||||||
|
{
|
||||||
|
if (referralVertices[procIndex].size())
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
!referralVertices[procIndex].unset
|
||||||
|
(
|
||||||
|
labelPair
|
||||||
|
(
|
||||||
|
originalParallelVertices[vI].procIndex(),
|
||||||
|
originalParallelVertices[vI].index()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Pout<< "*** not found "
|
||||||
|
<< originalParallelVertices[vI].procIndex()
|
||||||
|
<< " " << originalParallelVertices[vI].index() << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label postInsertionSize = Triangulation::number_of_vertices();
|
||||||
|
|
||||||
|
reduce(preInsertionSize, sumOp<label>());
|
||||||
|
reduce(postInsertionSize, sumOp<label>());
|
||||||
|
|
||||||
|
label nTotalToInsert = referredVertices.size();
|
||||||
|
|
||||||
|
reduce(nTotalToInsert, sumOp<label>());
|
||||||
|
|
||||||
|
if (preInsertionSize + nTotalToInsert != postInsertionSize)
|
||||||
|
{
|
||||||
|
label nNotInserted =
|
||||||
|
returnReduce(pointsNotInserted.size(), sumOp<label>());
|
||||||
|
|
||||||
|
Info<< " Inserted = "
|
||||||
|
<< setw(name(label(Triangulation::number_of_finite_cells())).size())
|
||||||
|
<< nTotalToInsert - nNotInserted
|
||||||
|
<< " / " << nTotalToInsert << endl;
|
||||||
|
|
||||||
|
nTotalToInsert -= nNotInserted;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< " Inserted = " << nTotalToInsert << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
return nTotalToInsert;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DistributedDelaunayMesh<Triangulation>::sync
|
||||||
|
(
|
||||||
|
const boundBox& bb,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
labelPairHashSet& receivedVertices,
|
||||||
|
bool iterateReferral
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allBackgroundMeshBounds_.empty())
|
||||||
|
{
|
||||||
|
distributeBoundBoxes(bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
label nVerts = Triangulation::number_of_vertices();
|
||||||
|
label nCells = Triangulation::number_of_finite_cells();
|
||||||
|
|
||||||
|
DynamicList<Vb> parallelInfluenceVertices(0.1*nVerts);
|
||||||
|
DynamicList<label> targetProcessor(0.1*nVerts);
|
||||||
|
|
||||||
|
// Some of these values will not be used, i.e. for non-real cells
|
||||||
|
DynamicList<Foam::point> circumcentre(0.1*nVerts);
|
||||||
|
DynamicList<scalar> circumradiusSqr(0.1*nVerts);
|
||||||
|
|
||||||
|
Map<labelList> circumsphereOverlaps(nCells);
|
||||||
|
|
||||||
|
findProcessorBoundaryCells(circumsphereOverlaps);
|
||||||
|
|
||||||
|
Info<< " Influences = "
|
||||||
|
<< setw(name(nCells).size())
|
||||||
|
<< returnReduce(circumsphereOverlaps.size(), sumOp<label>()) << " / "
|
||||||
|
<< returnReduce(nCells, sumOp<label>());
|
||||||
|
|
||||||
|
markVerticesToRefer
|
||||||
|
(
|
||||||
|
circumsphereOverlaps,
|
||||||
|
referralVertices,
|
||||||
|
targetProcessor,
|
||||||
|
parallelInfluenceVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
referVertices
|
||||||
|
(
|
||||||
|
targetProcessor,
|
||||||
|
parallelInfluenceVertices,
|
||||||
|
referralVertices,
|
||||||
|
receivedVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
if (iterateReferral)
|
||||||
|
{
|
||||||
|
label oldNReferred = 0;
|
||||||
|
label nIterations = 1;
|
||||||
|
|
||||||
|
Info<< incrIndent << indent
|
||||||
|
<< "Iteratively referring referred vertices..."
|
||||||
|
<< endl;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
Info<< indent << "Iteration " << nIterations++ << ":";
|
||||||
|
|
||||||
|
circumsphereOverlaps.clear();
|
||||||
|
targetProcessor.clear();
|
||||||
|
parallelInfluenceVertices.clear();
|
||||||
|
|
||||||
|
findProcessorBoundaryCells(circumsphereOverlaps);
|
||||||
|
|
||||||
|
nCells = Triangulation::number_of_finite_cells();
|
||||||
|
|
||||||
|
Info<< " Influences = "
|
||||||
|
<< setw(name(nCells).size())
|
||||||
|
<< returnReduce(circumsphereOverlaps.size(), sumOp<label>())
|
||||||
|
<< " / "
|
||||||
|
<< returnReduce(nCells, sumOp<label>());
|
||||||
|
|
||||||
|
markVerticesToRefer
|
||||||
|
(
|
||||||
|
circumsphereOverlaps,
|
||||||
|
referralVertices,
|
||||||
|
targetProcessor,
|
||||||
|
parallelInfluenceVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
label nReferred = referVertices
|
||||||
|
(
|
||||||
|
targetProcessor,
|
||||||
|
parallelInfluenceVertices,
|
||||||
|
referralVertices,
|
||||||
|
receivedVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nReferred == 0 || nReferred == oldNReferred)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
oldNReferred = nReferred;
|
||||||
|
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
bool Foam::DistributedDelaunayMesh<Triangulation>::distribute
|
||||||
|
(
|
||||||
|
const boundBox& bb
|
||||||
|
)
|
||||||
|
{
|
||||||
|
notImplemented
|
||||||
|
(
|
||||||
|
"Foam::DistributedDelaunayMesh<Triangulation>::distribute"
|
||||||
|
"("
|
||||||
|
" const boundBox& bb"
|
||||||
|
")"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
distributeBoundBoxes(bb);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::autoPtr<Foam::mapDistribute>
|
||||||
|
Foam::DistributedDelaunayMesh<Triangulation>::distribute
|
||||||
|
(
|
||||||
|
const backgroundMeshDecomposition& decomposition
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
return autoPtr<mapDistribute>();
|
||||||
|
}
|
||||||
|
|
||||||
|
distributeBoundBoxes(decomposition.procBounds());
|
||||||
|
|
||||||
|
DynamicList<point> points(Triangulation::number_of_vertices());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = Triangulation::finite_vertices_begin();
|
||||||
|
vit != Triangulation::finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
points.append(topoint(vit->point()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
autoPtr<mapDistribute> mapDist = decomposition.distributePoints(points);
|
||||||
|
|
||||||
|
return mapDist;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
void Foam::DistributedDelaunayMesh<Triangulation>::sync(const boundBox& bb)
|
||||||
|
{
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allBackgroundMeshBounds_.empty())
|
||||||
|
{
|
||||||
|
distributeBoundBoxes(bb);
|
||||||
|
}
|
||||||
|
|
||||||
|
const label nApproxReferred =
|
||||||
|
Triangulation::number_of_vertices()
|
||||||
|
/Pstream::nProcs();
|
||||||
|
|
||||||
|
PtrList<labelPairHashSet> referralVertices(Pstream::nProcs());
|
||||||
|
forAll(referralVertices, procI)
|
||||||
|
{
|
||||||
|
if (!isLocal(procI))
|
||||||
|
{
|
||||||
|
referralVertices.set(procI, new labelPairHashSet(nApproxReferred));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labelPairHashSet receivedVertices(nApproxReferred);
|
||||||
|
|
||||||
|
sync
|
||||||
|
(
|
||||||
|
bb,
|
||||||
|
referralVertices,
|
||||||
|
receivedVertices,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
template<class PointIterator>
|
||||||
|
typename Foam::DistributedDelaunayMesh<Triangulation>::labelPairHashSet
|
||||||
|
Foam::DistributedDelaunayMesh<Triangulation>::rangeInsertReferredWithInfo
|
||||||
|
(
|
||||||
|
PointIterator begin,
|
||||||
|
PointIterator end,
|
||||||
|
bool printErrors
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const boundBox& bb = allBackgroundMeshBounds_()[Pstream::myProcNo()];
|
||||||
|
|
||||||
|
typedef DynamicList
|
||||||
|
<
|
||||||
|
std::pair<scalar, label>
|
||||||
|
> vectorPairPointIndex;
|
||||||
|
|
||||||
|
vectorPairPointIndex pointsBbDistSqr;
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
for (PointIterator it = begin; it != end; ++it)
|
||||||
|
{
|
||||||
|
const Foam::point samplePoint(topoint(it->point()));
|
||||||
|
|
||||||
|
scalar distFromBbSqr = 0;
|
||||||
|
|
||||||
|
if (!bb.contains(samplePoint))
|
||||||
|
{
|
||||||
|
const Foam::point nearestPoint = bb.nearest(samplePoint);
|
||||||
|
|
||||||
|
distFromBbSqr = magSqr(nearestPoint - samplePoint);
|
||||||
|
}
|
||||||
|
|
||||||
|
pointsBbDistSqr.append
|
||||||
|
(
|
||||||
|
std::make_pair(distFromBbSqr, count++)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::random_shuffle(pointsBbDistSqr.begin(), pointsBbDistSqr.end());
|
||||||
|
|
||||||
|
// Sort in ascending order by the distance of the point from the centre
|
||||||
|
// of the processor bounding box
|
||||||
|
sort(pointsBbDistSqr.begin(), pointsBbDistSqr.end());
|
||||||
|
|
||||||
|
typename Triangulation::Vertex_handle hint;
|
||||||
|
|
||||||
|
typename Triangulation::Locate_type lt;
|
||||||
|
int li, lj;
|
||||||
|
|
||||||
|
label nNotInserted = 0;
|
||||||
|
|
||||||
|
labelPairHashSet uninserted
|
||||||
|
(
|
||||||
|
Triangulation::number_of_vertices()
|
||||||
|
/Pstream::nProcs()
|
||||||
|
);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename vectorPairPointIndex::const_iterator p =
|
||||||
|
pointsBbDistSqr.begin();
|
||||||
|
p != pointsBbDistSqr.end();
|
||||||
|
++p
|
||||||
|
)
|
||||||
|
{
|
||||||
|
const size_t checkInsertion = Triangulation::number_of_vertices();
|
||||||
|
|
||||||
|
const Vb& vert = *(begin + p->second);
|
||||||
|
const Point& pointToInsert = vert.point();
|
||||||
|
|
||||||
|
// Locate the point
|
||||||
|
Cell_handle c = Triangulation::locate(pointToInsert, lt, li, lj, hint);
|
||||||
|
|
||||||
|
bool inserted = false;
|
||||||
|
|
||||||
|
if (lt == Triangulation::VERTEX)
|
||||||
|
{
|
||||||
|
if (printErrors)
|
||||||
|
{
|
||||||
|
Vertex_handle nearV =
|
||||||
|
Triangulation::nearest_vertex(pointToInsert);
|
||||||
|
|
||||||
|
Pout<< "Failed insertion, point already exists" << nl
|
||||||
|
<< "Failed insertion : " << vert.info()
|
||||||
|
<< " nearest : " << nearV->info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (lt == Triangulation::OUTSIDE_AFFINE_HULL)
|
||||||
|
{
|
||||||
|
WarningIn
|
||||||
|
(
|
||||||
|
"Foam::DistributedDelaunayMesh<Triangulation>"
|
||||||
|
"::rangeInsertReferredWithInfo"
|
||||||
|
) << "Point is outside affine hull! pt = " << pointToInsert
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Get the cells that conflict with p in a vector V,
|
||||||
|
// and a facet on the boundary of this hole in f.
|
||||||
|
std::vector<Cell_handle> V;
|
||||||
|
typename Triangulation::Facet f;
|
||||||
|
|
||||||
|
Triangulation::find_conflicts
|
||||||
|
(
|
||||||
|
pointToInsert,
|
||||||
|
c,
|
||||||
|
CGAL::Oneset_iterator<typename Triangulation::Facet>(f),
|
||||||
|
std::back_inserter(V)
|
||||||
|
);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < V.size(); ++i)
|
||||||
|
{
|
||||||
|
Cell_handle conflictingCell = V[i];
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
Triangulation::dimension() < 3 // 2D triangulation
|
||||||
|
||
|
||||||
|
(
|
||||||
|
!Triangulation::is_infinite(conflictingCell)
|
||||||
|
&& (
|
||||||
|
conflictingCell->real()
|
||||||
|
|| conflictingCell->hasFarPoint()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
hint = Triangulation::insert_in_hole
|
||||||
|
(
|
||||||
|
pointToInsert,
|
||||||
|
V.begin(),
|
||||||
|
V.end(),
|
||||||
|
f.first,
|
||||||
|
f.second
|
||||||
|
);
|
||||||
|
|
||||||
|
inserted = true;
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inserted)
|
||||||
|
{
|
||||||
|
if (checkInsertion != Triangulation::number_of_vertices() - 1)
|
||||||
|
{
|
||||||
|
if (printErrors)
|
||||||
|
{
|
||||||
|
Vertex_handle nearV =
|
||||||
|
Triangulation::nearest_vertex(pointToInsert);
|
||||||
|
|
||||||
|
Pout<< "Failed insertion : " << vert.info()
|
||||||
|
<< " nearest : " << nearV->info();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hint->index() = vert.index();
|
||||||
|
hint->type() = vert.type();
|
||||||
|
hint->procIndex() = vert.procIndex();
|
||||||
|
hint->targetCellSize() = vert.targetCellSize();
|
||||||
|
hint->alignment() = vert.alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uninserted.insert(labelPair(vert.procIndex(), vert.index()));
|
||||||
|
nNotInserted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return uninserted;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,208 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::DistributedDelaunayMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
DistributedDelaunayMeshI.H
|
||||||
|
DistributedDelaunayMesh.C
|
||||||
|
DistributedDelaunayMeshIO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef DistributedDelaunayMesh_H
|
||||||
|
#define DistributedDelaunayMesh_H
|
||||||
|
|
||||||
|
#include "DelaunayMesh.H"
|
||||||
|
#include "backgroundMeshDecomposition.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "boundBox.H"
|
||||||
|
#include "indexedVertex.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class mapDistribute;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class DistributedDelaunayMesh Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
class DistributedDelaunayMesh
|
||||||
|
:
|
||||||
|
public DelaunayMesh<Triangulation>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef typename Triangulation::Vertex_handle Vertex_handle;
|
||||||
|
typedef typename Triangulation::Cell_handle Cell_handle;
|
||||||
|
typedef typename Triangulation::Point Point;
|
||||||
|
|
||||||
|
typedef typename Triangulation::Finite_vertices_iterator
|
||||||
|
Finite_vertices_iterator;
|
||||||
|
typedef typename Triangulation::Finite_cells_iterator
|
||||||
|
Finite_cells_iterator;
|
||||||
|
typedef typename Triangulation::All_cells_iterator
|
||||||
|
All_cells_iterator;
|
||||||
|
|
||||||
|
typedef typename DelaunayMesh<Triangulation>::labelPairHashSet
|
||||||
|
labelPairHashSet;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
autoPtr<List<boundBox> > allBackgroundMeshBounds_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//-
|
||||||
|
bool distributeBoundBoxes(const boundBox& bb);
|
||||||
|
|
||||||
|
//-
|
||||||
|
bool isLocal(const Vertex_handle& v) const;
|
||||||
|
|
||||||
|
bool isLocal(const label localProcIndex) const;
|
||||||
|
|
||||||
|
labelList overlapProcessors
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar radiusSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
|
bool checkProcBoundaryCell
|
||||||
|
(
|
||||||
|
const Cell_handle& cit,
|
||||||
|
Map<labelList>& circumsphereOverlaps
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void findProcessorBoundaryCells
|
||||||
|
(
|
||||||
|
Map<labelList>& circumsphereOverlaps
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void markVerticesToRefer
|
||||||
|
(
|
||||||
|
const Map<labelList>& circumsphereOverlaps,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
DynamicList<label>& targetProcessor,
|
||||||
|
DynamicList<Vb>& parallelInfluenceVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
label referVertices
|
||||||
|
(
|
||||||
|
const DynamicList<label>& targetProcessor,
|
||||||
|
DynamicList<Vb>& parallelVertices,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
labelPairHashSet& receivedVertices
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
DistributedDelaunayMesh(const DistributedDelaunayMesh<Triangulation>&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const DistributedDelaunayMesh<Triangulation>&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
DistributedDelaunayMesh();
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~DistributedDelaunayMesh();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Build a mapDistribute for the supplied destination processor data
|
||||||
|
static autoPtr<mapDistribute> buildMap(const List<label>& toProc);
|
||||||
|
|
||||||
|
//-
|
||||||
|
bool distribute(const boundBox& bb);
|
||||||
|
|
||||||
|
autoPtr<mapDistribute> distribute
|
||||||
|
(
|
||||||
|
const backgroundMeshDecomposition& decomposition
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Refer vertices so that the processor interfaces are consistent
|
||||||
|
void sync(const boundBox& bb);
|
||||||
|
|
||||||
|
//- Refer vertices so that the processor interfaces are consistent
|
||||||
|
void sync
|
||||||
|
(
|
||||||
|
const boundBox& bb,
|
||||||
|
PtrList<labelPairHashSet>& referralVertices,
|
||||||
|
labelPairHashSet& receivedVertices,
|
||||||
|
bool iterateReferral = true
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Inserts points into the triangulation if the point is within
|
||||||
|
// the circumsphere of another cell. Returns HashSet of failed
|
||||||
|
// point insertions
|
||||||
|
template<class PointIterator>
|
||||||
|
labelPairHashSet rangeInsertReferredWithInfo
|
||||||
|
(
|
||||||
|
PointIterator begin,
|
||||||
|
PointIterator end,
|
||||||
|
bool printErrors = true
|
||||||
|
);
|
||||||
|
|
||||||
|
// distributeField();
|
||||||
|
|
||||||
|
|
||||||
|
// Queries
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//#include "DistributedDelaunayMeshI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "DistributedDelaunayMesh.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,74 @@
|
|||||||
|
#include CGAL_FILES
|
||||||
|
|
||||||
|
conformalVoronoiMesh/indexedVertex/indexedVertexEnum.C
|
||||||
|
conformalVoronoiMesh/indexedCell/indexedCellEnum.C
|
||||||
|
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMesh.C
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMeshConformToSurface.C
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMeshIO.C
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMeshFeaturePoints.C
|
||||||
|
conformalVoronoiMesh/conformalVoronoiMeshFeaturePointSpecialisations.C
|
||||||
|
|
||||||
|
cvControls/cvControls.C
|
||||||
|
|
||||||
|
conformationSurfaces/conformationSurfaces.C
|
||||||
|
|
||||||
|
backgroundMeshDecomposition/backgroundMeshDecomposition.C
|
||||||
|
|
||||||
|
cellShapeControl/cellShapeControl/cellShapeControl.C
|
||||||
|
|
||||||
|
cellShapeControl/cellShapeControlMesh/cellShapeControlMesh.C
|
||||||
|
|
||||||
|
cellSizeAndAlignmentControl = cellShapeControl/cellSizeAndAlignmentControl
|
||||||
|
$(cellSizeAndAlignmentControl)/cellSizeAndAlignmentControls.C
|
||||||
|
$(cellSizeAndAlignmentControl)/cellSizeAndAlignmentControl/cellSizeAndAlignmentControl.C
|
||||||
|
$(cellSizeAndAlignmentControl)/fileControl/fileControl.C
|
||||||
|
$(cellSizeAndAlignmentControl)/searchableSurfaceControl/searchableSurfaceControl.C
|
||||||
|
/*cellShapeControl/pQuadCoorControl/pQuadCoorControl.C*/
|
||||||
|
|
||||||
|
cellShapeControl/cellAspectRatioControl/cellAspectRatioControl.C
|
||||||
|
|
||||||
|
cellShapeControl/smoothAlignmentSolver/smoothAlignmentSolver.C
|
||||||
|
|
||||||
|
cellShapeControl/controlMeshRefinement/controlMeshRefinement.C
|
||||||
|
|
||||||
|
/*cellSizeControlSurfaces/cellSizeControlSurfaces.C*/
|
||||||
|
|
||||||
|
cellSizeFunctions = cellSizeControlSurfaces/cellSizeFunction
|
||||||
|
$(cellSizeFunctions)/cellSizeFunction/cellSizeFunction.C
|
||||||
|
$(cellSizeFunctions)/uniform/uniform.C
|
||||||
|
$(cellSizeFunctions)/uniformDistance/uniformDistance.C
|
||||||
|
$(cellSizeFunctions)/linearDistance/linearDistance.C
|
||||||
|
$(cellSizeFunctions)/surfaceOffsetLinearDistance/surfaceOffsetLinearDistance.C
|
||||||
|
$(cellSizeFunctions)/linearSpatial/linearSpatial.C
|
||||||
|
|
||||||
|
surfaceCellSizeFunctions = cellSizeControlSurfaces/surfaceCellSizeFunction
|
||||||
|
$(surfaceCellSizeFunctions)/surfaceCellSizeFunction/surfaceCellSizeFunction.C
|
||||||
|
$(surfaceCellSizeFunctions)/uniformValue/uniformValue.C
|
||||||
|
$(surfaceCellSizeFunctions)/nonUniformField/nonUniformField.C
|
||||||
|
|
||||||
|
cellSizeCalculationType = $(surfaceCellSizeFunctions)/cellSizeCalculationType
|
||||||
|
$(cellSizeCalculationType)/cellSizeCalculationType/cellSizeCalculationType.C
|
||||||
|
$(cellSizeCalculationType)/fieldFromFile/fieldFromFile.C
|
||||||
|
$(cellSizeCalculationType)/automatic/automatic.C
|
||||||
|
|
||||||
|
initialPointsMethod/initialPointsMethod/initialPointsMethod.C
|
||||||
|
initialPointsMethod/uniformGrid/uniformGrid.C
|
||||||
|
initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
|
||||||
|
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
|
||||||
|
initialPointsMethod/pointFile/pointFile.C
|
||||||
|
initialPointsMethod/autoDensity/autoDensity.C
|
||||||
|
|
||||||
|
relaxationModel/relaxationModel/relaxationModel.C
|
||||||
|
relaxationModel/adaptiveLinear/adaptiveLinear.C
|
||||||
|
relaxationModel/rampHoldFall/rampHoldFall.C
|
||||||
|
|
||||||
|
faceAreaWeightModel/faceAreaWeightModel/faceAreaWeightModel.C
|
||||||
|
faceAreaWeightModel/piecewiseLinearRamp/piecewiseLinearRamp.C
|
||||||
|
|
||||||
|
searchableSurfaceFeatures/searchableSurfaceFeatures.C
|
||||||
|
searchableSurfaceFeatures/searchableBoxFeatures.C
|
||||||
|
searchableSurfaceFeatures/triSurfaceMeshFeatures.C
|
||||||
|
|
||||||
|
LIB = $(FOAM_LIBBIN)/libconformalVoronoiMesh
|
||||||
@ -0,0 +1,35 @@
|
|||||||
|
EXE_DEBUG = -DFULLDEBUG -g -O0
|
||||||
|
EXE_FROUNDING_MATH = -frounding-math
|
||||||
|
EXE_NDEBUG = -DNDEBUG
|
||||||
|
|
||||||
|
CGAL_EXACT = /*-DCGAL_DONT_USE_LAZY_KERNEL*/
|
||||||
|
CGAL_INEXACT = -DCGAL_INEXACT
|
||||||
|
|
||||||
|
include $(GENERAL_RULES)/CGAL
|
||||||
|
FFLAGS = -DCGAL_FILES='"${CGAL_ARCH_PATH}/share/files"'
|
||||||
|
|
||||||
|
EXE_INC = \
|
||||||
|
${EXE_FROUNDING_MATH} \
|
||||||
|
${EXE_NDEBUG} \
|
||||||
|
${CGAL_INEXACT} \
|
||||||
|
${CGAL_INC} \
|
||||||
|
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||||
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
|
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||||
|
-I$(LIB_SRC)/edgeMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
|
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/surfMesh/lnInclude \
|
||||||
|
-I$(LIB_SRC)/triSurface/lnInclude \
|
||||||
|
-I$(LIB_SRC)/sampling/lnInclude \
|
||||||
|
-IPrintTable \
|
||||||
|
-I../vectorTools
|
||||||
|
|
||||||
|
LIB_LIBS = \
|
||||||
|
-lmeshTools \
|
||||||
|
-ledgeMesh \
|
||||||
|
-lfileFormats \
|
||||||
|
-ltriSurface \
|
||||||
|
-ldynamicMesh \
|
||||||
|
-lsurfMesh \
|
||||||
|
-lsampling
|
||||||
@ -0,0 +1,235 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "PrintTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
Foam::PrintTable<KeyType, DataType>::PrintTable()
|
||||||
|
:
|
||||||
|
table_(),
|
||||||
|
title_(string::null)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
Foam::PrintTable<KeyType, DataType>::PrintTable(const string& title)
|
||||||
|
:
|
||||||
|
table_(),
|
||||||
|
title_(title)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
Foam::PrintTable<KeyType, DataType>::PrintTable
|
||||||
|
(
|
||||||
|
const PrintTable<KeyType, DataType>& table
|
||||||
|
)
|
||||||
|
:
|
||||||
|
table_(table.table_),
|
||||||
|
title_(table.title_)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
Foam::PrintTable<KeyType, DataType>::~PrintTable()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
void Foam::PrintTable<KeyType, DataType>::print
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const bool printSum,
|
||||||
|
const bool printAverage
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
HashTable<HashTable<DataType, label>, KeyType> combinedTable;
|
||||||
|
|
||||||
|
List<HashTableData> procData(Pstream::nProcs(), HashTableData());
|
||||||
|
|
||||||
|
procData[Pstream::myProcNo()] = table_;
|
||||||
|
|
||||||
|
Pstream::gatherList(procData);
|
||||||
|
|
||||||
|
if (Pstream::master())
|
||||||
|
{
|
||||||
|
label largestKeyLength = 6;
|
||||||
|
label largestDataLength = 0;
|
||||||
|
|
||||||
|
List<label> largestProcSize(Pstream::nProcs(), 0);
|
||||||
|
|
||||||
|
forAll(procData, procI)
|
||||||
|
{
|
||||||
|
const HashTableData& procIData = procData[procI];
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename HashTableData::const_iterator iter = procIData.begin();
|
||||||
|
iter != procIData.end();
|
||||||
|
++iter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!combinedTable.found(iter.key()))
|
||||||
|
{
|
||||||
|
combinedTable.insert
|
||||||
|
(
|
||||||
|
iter.key(),
|
||||||
|
HashTable<DataType, label>()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
HashTable<DataType, label>& key = combinedTable[iter.key()];
|
||||||
|
|
||||||
|
key.insert(procI, iter());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename HashTable<DataType, label>
|
||||||
|
::const_iterator dataIter = key.begin();
|
||||||
|
dataIter != key.end();
|
||||||
|
++dataIter
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::ostringstream buf;
|
||||||
|
buf << dataIter();
|
||||||
|
|
||||||
|
largestDataLength = max
|
||||||
|
(
|
||||||
|
largestDataLength,
|
||||||
|
label(buf.str().length())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostringstream buf;
|
||||||
|
buf << iter.key();
|
||||||
|
|
||||||
|
largestKeyLength = max
|
||||||
|
(
|
||||||
|
largestKeyLength,
|
||||||
|
label(buf.str().length())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os.width(largestKeyLength);
|
||||||
|
os << nl << indent << tab << "# " << title_.c_str() << endl;
|
||||||
|
|
||||||
|
os.width(largestKeyLength);
|
||||||
|
os << indent << "# Proc No";
|
||||||
|
|
||||||
|
forAll(procData, procI)
|
||||||
|
{
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << procI;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printSum)
|
||||||
|
{
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << "Sum";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printAverage)
|
||||||
|
{
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << "Average";
|
||||||
|
}
|
||||||
|
|
||||||
|
os << endl;
|
||||||
|
|
||||||
|
const List<KeyType>& sortedTable = combinedTable.sortedToc();
|
||||||
|
|
||||||
|
forAll(sortedTable, keyI)
|
||||||
|
{
|
||||||
|
const HashTable<DataType, label>& procDataList
|
||||||
|
= combinedTable[sortedTable[keyI]];
|
||||||
|
|
||||||
|
os.width(largestKeyLength);
|
||||||
|
os << indent << sortedTable[keyI];
|
||||||
|
|
||||||
|
forAll(procDataList, elemI)
|
||||||
|
{
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << procDataList[elemI];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (printSum)
|
||||||
|
{
|
||||||
|
DataType sum = 0;
|
||||||
|
forAll(procDataList, elemI)
|
||||||
|
{
|
||||||
|
sum += procDataList[elemI];
|
||||||
|
}
|
||||||
|
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << sum;
|
||||||
|
|
||||||
|
if (printAverage)
|
||||||
|
{
|
||||||
|
os << tab;
|
||||||
|
os.width(largestDataLength);
|
||||||
|
os << sum/Pstream::nProcs();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
os << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
void Foam::PrintTable<KeyType, DataType>::operator=
|
||||||
|
(
|
||||||
|
const PrintTable<KeyType, DataType>& rhs
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Check for assignment to self
|
||||||
|
if (this == &rhs)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::PrintTable<KeyType, DataType>::operator="
|
||||||
|
"(const Foam::PrintTable<KeyType, DataType>&)"
|
||||||
|
) << "Attempted assignment to self"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,140 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::PrintTable
|
||||||
|
|
||||||
|
Description
|
||||||
|
Print a table in parallel, e.g.;
|
||||||
|
|
||||||
|
\verbatim
|
||||||
|
Vertex Type Information
|
||||||
|
Proc # 0 1 2 3
|
||||||
|
Total 145680 145278 145751 145359
|
||||||
|
Unassigned 0 0 0 0
|
||||||
|
nExternalFeatureEdge 883 829 828 960
|
||||||
|
nExternalFeaturePoint 8 10 10 12
|
||||||
|
nExternalSurface 9533 9488 9502 9482
|
||||||
|
nFar 0 0 0 0
|
||||||
|
nInternal 125494 125198 125642 125174
|
||||||
|
nInternalFeatureEdge 238 241 241 240
|
||||||
|
nInternalFeaturePoint 2 2 2 2
|
||||||
|
nInternalNearBoundary 0 0 0 0
|
||||||
|
nInternalSurface 9522 9510 9526 9489
|
||||||
|
nReferred 7545 7497 7500 7587
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
PrintTableI.H
|
||||||
|
PrintTable.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef PrintTable_H
|
||||||
|
#define PrintTable_H
|
||||||
|
|
||||||
|
#include "HashTable.H"
|
||||||
|
#include "Ostream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class PrintTable Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
class PrintTable
|
||||||
|
{
|
||||||
|
typedef HashTable<DataType, KeyType> HashTableData;
|
||||||
|
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Hash table holding the data
|
||||||
|
HashTableData table_;
|
||||||
|
|
||||||
|
//- Title of the table
|
||||||
|
string title_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const PrintTable<KeyType, DataType>&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Null constructor
|
||||||
|
PrintTable();
|
||||||
|
|
||||||
|
//- Construct with a title
|
||||||
|
explicit PrintTable(const string& title);
|
||||||
|
|
||||||
|
//- Copy constructor
|
||||||
|
PrintTable(const PrintTable<KeyType, DataType>& table);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~PrintTable();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Add an entry (D) to the given key(K)
|
||||||
|
void add(const KeyType& K, const DataType& D);
|
||||||
|
|
||||||
|
//- Print the table
|
||||||
|
void print
|
||||||
|
(
|
||||||
|
Ostream& os,
|
||||||
|
const bool printSum = false,
|
||||||
|
const bool printAverage = false
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "PrintTableI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#ifdef NoRepository
|
||||||
|
# include "PrintTable.C"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,42 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class KeyType, class DataType>
|
||||||
|
void Foam::PrintTable<KeyType, DataType>::add
|
||||||
|
(
|
||||||
|
const KeyType& K,
|
||||||
|
const DataType& D
|
||||||
|
)
|
||||||
|
{
|
||||||
|
table_.set(K, D);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,341 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::backgroundMeshDecomposition
|
||||||
|
|
||||||
|
Description
|
||||||
|
Store a background polyMesh to use for the decomposition of space and
|
||||||
|
queries for parallel conformalVoronoiMesh.
|
||||||
|
|
||||||
|
The requirements are:
|
||||||
|
|
||||||
|
+ To have a decomposition of space which can quickly interrogate an
|
||||||
|
arbitrary location from any processor to reliably and unambiguously
|
||||||
|
determine which processor owns the space that the point is in, i.e. as
|
||||||
|
the vertices move, or need inserted as part of the surface conformation,
|
||||||
|
send them to the correct proc.
|
||||||
|
|
||||||
|
+ To be able to be dynamically built, refined and redistributed to other
|
||||||
|
procs the partitioning as the meshing progresses to balance the load.
|
||||||
|
|
||||||
|
+ To be able to query whether a sphere (the circumsphere of a Delaunay tet)
|
||||||
|
overlaps any part of the space defined by the structure, and whether a
|
||||||
|
ray (Voronoi edge) penetrates any part of the space defined by the
|
||||||
|
structure, this is what determines if points get referred to a processor.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
backgroundMeshDecompositionI.H
|
||||||
|
backgroundMeshDecomposition.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef backgroundMeshDecomposition_H
|
||||||
|
#define backgroundMeshDecomposition_H
|
||||||
|
|
||||||
|
#include "fvMesh.H"
|
||||||
|
#include "hexRef8.H"
|
||||||
|
#include "cellSet.H"
|
||||||
|
#include "meshTools.H"
|
||||||
|
#include "polyTopoChange.H"
|
||||||
|
#include "mapPolyMesh.H"
|
||||||
|
#include "decompositionMethod.H"
|
||||||
|
#include "fvMeshDistribute.H"
|
||||||
|
#include "removeCells.H"
|
||||||
|
#include "mapDistributePolyMesh.H"
|
||||||
|
#include "globalIndex.H"
|
||||||
|
#include "treeBoundBox.H"
|
||||||
|
#include "primitivePatch.H"
|
||||||
|
#include "face.H"
|
||||||
|
#include "labelList.H"
|
||||||
|
#include "pointField.H"
|
||||||
|
#include "indexedOctree.H"
|
||||||
|
#include "treeDataPrimitivePatch.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef PrimitivePatch<face, List, const pointField, point> bPatch;
|
||||||
|
typedef treeDataPrimitivePatch<bPatch> treeDataBPatch;
|
||||||
|
|
||||||
|
class Time;
|
||||||
|
class Random;
|
||||||
|
class conformationSurfaces;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class backgroundMeshDecomposition Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class backgroundMeshDecomposition
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Method details dictionary
|
||||||
|
//dictionary coeffsDict_;
|
||||||
|
|
||||||
|
//- Reference to runtime
|
||||||
|
const Time& runTime_;
|
||||||
|
|
||||||
|
//- Reference to surface
|
||||||
|
const conformationSurfaces& geometryToConformTo_;
|
||||||
|
|
||||||
|
//- Random number generator
|
||||||
|
Random& rndGen_;
|
||||||
|
|
||||||
|
//- Mesh stored on for this processor, specifiying the domain that it
|
||||||
|
// is responsible for.
|
||||||
|
fvMesh mesh_;
|
||||||
|
|
||||||
|
//- Refinement object
|
||||||
|
hexRef8 meshCutter_;
|
||||||
|
|
||||||
|
//- Patch containing an independent representation of the surface of the
|
||||||
|
// mesh of this processor
|
||||||
|
autoPtr<bPatch> boundaryFacesPtr_;
|
||||||
|
|
||||||
|
//- Search tree for the boundaryFaces_ patch
|
||||||
|
autoPtr<indexedOctree<treeDataBPatch> > bFTreePtr_;
|
||||||
|
|
||||||
|
//- The bounds of all background meshes on all processors
|
||||||
|
treeBoundBoxList allBackgroundMeshBounds_;
|
||||||
|
|
||||||
|
//- The overall bounds of all of the background meshes, used to test if
|
||||||
|
// a point that is not found on any processor is in the domain at all
|
||||||
|
treeBoundBox globalBackgroundBounds_;
|
||||||
|
|
||||||
|
//- Decomposition dictionary
|
||||||
|
IOdictionary decomposeDict_;
|
||||||
|
|
||||||
|
//- Decomposition method
|
||||||
|
autoPtr<decompositionMethod> decomposerPtr_;
|
||||||
|
|
||||||
|
//- merge distance required by fvMeshDistribute
|
||||||
|
scalar mergeDist_;
|
||||||
|
|
||||||
|
//- Scale of a cell span vs cell size used to decide to refine a cell
|
||||||
|
scalar spanScale_;
|
||||||
|
|
||||||
|
//- Smallest minimum cell size allowed, i.e. to avoid high initial
|
||||||
|
// refinement of areas of small size
|
||||||
|
scalar minCellSizeLimit_;
|
||||||
|
|
||||||
|
//- Minimum normal level of refinement
|
||||||
|
label minLevels_;
|
||||||
|
|
||||||
|
//- How fine should the initial sample of the volume a box be to
|
||||||
|
// investigate the local cell size
|
||||||
|
label volRes_;
|
||||||
|
|
||||||
|
//- Allowed factor above the average cell weight before a background
|
||||||
|
// cell needs to be split
|
||||||
|
scalar maxCellWeightCoeff_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void initialRefinement();
|
||||||
|
|
||||||
|
//- Print details of the decomposed mesh
|
||||||
|
void printMeshData(const polyMesh& mesh) const;
|
||||||
|
|
||||||
|
//- Estimate the number of vertices that will be in this cell, returns
|
||||||
|
// true if the cell is to be split because of the density ratio inside
|
||||||
|
// it
|
||||||
|
bool refineCell
|
||||||
|
(
|
||||||
|
label cellI,
|
||||||
|
volumeType volType,
|
||||||
|
scalar& weightEstimate
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Select cells for refinement at the surface of the geometry to be
|
||||||
|
// meshed
|
||||||
|
labelList selectRefinementCells
|
||||||
|
(
|
||||||
|
List<volumeType>& volumeStatus,
|
||||||
|
volScalarField& cellWeights
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Build the surface patch and search tree
|
||||||
|
void buildPatchAndTree();
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
backgroundMeshDecomposition(const backgroundMeshDecomposition&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const backgroundMeshDecomposition&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("backgroundMeshDecomposition");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components in foamyHexMesh operation
|
||||||
|
backgroundMeshDecomposition
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
Random& rndGen,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const dictionary& coeffsDict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~backgroundMeshDecomposition();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Build a mapDistribute for the supplied destination processor data
|
||||||
|
static autoPtr<mapDistribute> buildMap(const List<label>& toProc);
|
||||||
|
|
||||||
|
//- Redistribute the background mesh based on a supplied weight field,
|
||||||
|
// returning a map to use to redistribute vertices.
|
||||||
|
autoPtr<mapDistributePolyMesh> distribute
|
||||||
|
(
|
||||||
|
volScalarField& cellWeights
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Distribute supplied the points to the appropriate processor
|
||||||
|
autoPtr<mapDistribute> distributePoints(List<point>& points) const;
|
||||||
|
|
||||||
|
//- Is the given position inside the domain of this decomposition
|
||||||
|
bool positionOnThisProcessor(const point& pt) const;
|
||||||
|
|
||||||
|
//- Are the given positions inside the domain of this decomposition
|
||||||
|
boolList positionOnThisProcessor(const List<point>& pts) const;
|
||||||
|
|
||||||
|
//- Does the given box overlap the faces of the boundary of this
|
||||||
|
// processor
|
||||||
|
bool overlapsThisProcessor(const treeBoundBox& box) const;
|
||||||
|
|
||||||
|
//- Does the given sphere overlap the faces of the boundary of this
|
||||||
|
// processor
|
||||||
|
bool overlapsThisProcessor
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar radiusSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Find nearest intersection of line between start and end, (exposing
|
||||||
|
// underlying indexedOctree)
|
||||||
|
pointIndexHit findLine
|
||||||
|
(
|
||||||
|
const point& start,
|
||||||
|
const point& end
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Find any intersection of line between start and end, (exposing
|
||||||
|
// underlying indexedOctree)
|
||||||
|
pointIndexHit findLineAny
|
||||||
|
(
|
||||||
|
const point& start,
|
||||||
|
const point& end
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- What processor is the given position on?
|
||||||
|
labelList processorPosition(const List<point>& pts) const;
|
||||||
|
|
||||||
|
//- What is the nearest processor to the given position?
|
||||||
|
labelList processorNearestPosition(const List<point>& pts) const;
|
||||||
|
|
||||||
|
//- Which processors are intersected by the line segment, returns all
|
||||||
|
// processors whose boundary patch is intersected by the sphere. By
|
||||||
|
// default this does not return the processor that the query is
|
||||||
|
// launched from, it is assumed that the point is on that processor.
|
||||||
|
// The index data member of the pointIndexHit is replaced with the
|
||||||
|
// processor index.
|
||||||
|
List<List<pointIndexHit> > intersectsProcessors
|
||||||
|
(
|
||||||
|
const List<point>& starts,
|
||||||
|
const List<point>& ends,
|
||||||
|
bool includeOwnProcessor = false
|
||||||
|
) const;
|
||||||
|
|
||||||
|
bool overlapsOtherProcessors
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar& radiusSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
|
labelList overlapProcessors
|
||||||
|
(
|
||||||
|
const point& centre,
|
||||||
|
const scalar radiusSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
|
// //- Which processors overlap the given sphere, returns all processors
|
||||||
|
// // whose boundary patch is touched by the sphere or whom the sphere
|
||||||
|
// // is inside. By default this does not return the processor that the
|
||||||
|
// // query is launched from, it is assumed that the point is on that
|
||||||
|
// // processor.
|
||||||
|
// labelListList overlapsProcessors
|
||||||
|
// (
|
||||||
|
// const List<point>& centres,
|
||||||
|
// const List<scalar>& radiusSqrs,
|
||||||
|
// const Delaunay& T,
|
||||||
|
// bool includeOwnProcessor
|
||||||
|
// ) const;
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
//- Return access to the underlying mesh
|
||||||
|
inline const fvMesh& mesh() const;
|
||||||
|
|
||||||
|
//- Return access to the underlying tree
|
||||||
|
inline const indexedOctree<treeDataBPatch>& tree() const;
|
||||||
|
|
||||||
|
//- Return the boundBox of this processor
|
||||||
|
inline const treeBoundBox& procBounds() const;
|
||||||
|
|
||||||
|
//- Return the cell level of the underlying mesh
|
||||||
|
inline const labelList& cellLevel() const;
|
||||||
|
|
||||||
|
//- Return the point level of the underlying mesh
|
||||||
|
inline const labelList& pointLevel() const;
|
||||||
|
|
||||||
|
//- Return the current decomposition method
|
||||||
|
inline const decompositionMethod& decomposer() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "backgroundMeshDecompositionI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,67 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::fvMesh& Foam::backgroundMeshDecomposition::mesh() const
|
||||||
|
{
|
||||||
|
return mesh_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::indexedOctree<Foam::treeDataBPatch>&
|
||||||
|
Foam::backgroundMeshDecomposition::tree() const
|
||||||
|
{
|
||||||
|
return bFTreePtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::treeBoundBox&
|
||||||
|
Foam::backgroundMeshDecomposition::procBounds() const
|
||||||
|
{
|
||||||
|
return allBackgroundMeshBounds_[Pstream::myProcNo()];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::labelList& Foam::backgroundMeshDecomposition::cellLevel() const
|
||||||
|
{
|
||||||
|
return meshCutter_.cellLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::labelList& Foam::backgroundMeshDecomposition::pointLevel() const
|
||||||
|
{
|
||||||
|
return meshCutter_.pointLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::decompositionMethod&
|
||||||
|
Foam::backgroundMeshDecomposition::decomposer() const
|
||||||
|
{
|
||||||
|
return decomposerPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,111 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellAspectRatioControl.H"
|
||||||
|
#include "vectorTools.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellAspectRatioControl::cellAspectRatioControl
|
||||||
|
(
|
||||||
|
const dictionary& motionDict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
aspectRatioDict_(motionDict.subOrEmptyDict("cellAspectRatioControl")),
|
||||||
|
aspectRatio_(aspectRatioDict_.lookupOrDefault<scalar>("aspectRatio", 1.0)),
|
||||||
|
aspectRatioDirection_
|
||||||
|
(
|
||||||
|
aspectRatioDict_.lookupOrDefault<vector>
|
||||||
|
(
|
||||||
|
"aspectRatioDirection",
|
||||||
|
vector(0, 0, 0)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< nl << "Cell Aspect Ratio Control" << nl
|
||||||
|
<< " Ratio : " << aspectRatio_ << nl
|
||||||
|
<< " Direction : " << aspectRatioDirection_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellAspectRatioControl::~cellAspectRatioControl()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cellAspectRatioControl::updateCellSizeAndFaceArea
|
||||||
|
(
|
||||||
|
vector& alignmentDir,
|
||||||
|
scalar& targetFaceArea,
|
||||||
|
scalar& targetCellSize
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar cosAngle = mag
|
||||||
|
(
|
||||||
|
vectorTools::cosPhi(alignmentDir, aspectRatioDirection_)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Change target face area based on aspect ratio
|
||||||
|
targetFaceArea
|
||||||
|
+= targetFaceArea
|
||||||
|
*(aspectRatio_ - 1.0)
|
||||||
|
*(1.0 - cosAngle);
|
||||||
|
|
||||||
|
// Change target cell size based on aspect ratio
|
||||||
|
targetCellSize
|
||||||
|
+= targetCellSize
|
||||||
|
*(aspectRatio_ - 1.0)
|
||||||
|
*cosAngle;
|
||||||
|
|
||||||
|
alignmentDir *= 0.5*targetCellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellAspectRatioControl::updateDeltaVector
|
||||||
|
(
|
||||||
|
const vector& alignmentDir,
|
||||||
|
const scalar targetCellSize,
|
||||||
|
const scalar rABMag,
|
||||||
|
vector& delta
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar cosAngle = mag
|
||||||
|
(
|
||||||
|
vectorTools::cosPhi(alignmentDir, aspectRatioDirection_)
|
||||||
|
);
|
||||||
|
|
||||||
|
delta += 0.5
|
||||||
|
*delta
|
||||||
|
*cosAngle
|
||||||
|
*(targetCellSize/rABMag)
|
||||||
|
*(aspectRatio_ - 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,115 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellAspectRatioControl
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellAspectRatioControl.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellAspectRatioControl_H
|
||||||
|
#define cellAspectRatioControl_H
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "vector.H"
|
||||||
|
#include "scalar.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellAspectRatioControl Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellAspectRatioControl
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const dictionary aspectRatioDict_;
|
||||||
|
|
||||||
|
const scalar aspectRatio_;
|
||||||
|
|
||||||
|
const vector aspectRatioDirection_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellAspectRatioControl(const cellAspectRatioControl&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellAspectRatioControl&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cellAspectRatioControl
|
||||||
|
(
|
||||||
|
const dictionary& motionDict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellAspectRatioControl();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
void updateCellSizeAndFaceArea
|
||||||
|
(
|
||||||
|
vector& alignmentDir,
|
||||||
|
scalar& targetFaceArea,
|
||||||
|
scalar& targetCellSize
|
||||||
|
) const;
|
||||||
|
|
||||||
|
void updateDeltaVector
|
||||||
|
(
|
||||||
|
const vector& alignmentDir,
|
||||||
|
const scalar targetCellSize,
|
||||||
|
const scalar rABMag,
|
||||||
|
vector& delta
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,368 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellShapeControl.H"
|
||||||
|
#include "pointField.H"
|
||||||
|
#include "scalarField.H"
|
||||||
|
#include "triadField.H"
|
||||||
|
#include "cellSizeAndAlignmentControl.H"
|
||||||
|
#include "searchableSurfaceControl.H"
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellShapeControl, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellShapeControl::cellShapeControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const cvControls& foamyHexMeshControls,
|
||||||
|
const searchableSurfaces& allGeometry,
|
||||||
|
const conformationSurfaces& geometryToConformTo
|
||||||
|
)
|
||||||
|
:
|
||||||
|
dictionary
|
||||||
|
(
|
||||||
|
foamyHexMeshControls.foamyHexMeshDict().subDict("motionControl")
|
||||||
|
),
|
||||||
|
runTime_(runTime),
|
||||||
|
allGeometry_(allGeometry),
|
||||||
|
geometryToConformTo_(geometryToConformTo),
|
||||||
|
defaultCellSize_(foamyHexMeshControls.defaultCellSize()),
|
||||||
|
minimumCellSize_(foamyHexMeshControls.minimumCellSize()),
|
||||||
|
shapeControlMesh_(runTime),
|
||||||
|
aspectRatio_(*this),
|
||||||
|
sizeAndAlignment_
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
subDict("shapeControlFunctions"),
|
||||||
|
geometryToConformTo_,
|
||||||
|
defaultCellSize_
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellShapeControl::~cellShapeControl()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalarField Foam::cellShapeControl::cellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
scalarField cellSizes(pts.size());
|
||||||
|
|
||||||
|
forAll(pts, i)
|
||||||
|
{
|
||||||
|
cellSizes[i] = cellSize(pts[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return cellSizes;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::cellShapeControl::cellSize(const point& pt) const
|
||||||
|
{
|
||||||
|
scalarList bary;
|
||||||
|
cellShapeControlMesh::Cell_handle ch;
|
||||||
|
|
||||||
|
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
|
||||||
|
scalar size = 0;
|
||||||
|
|
||||||
|
if (shapeControlMesh_.dimension() < 3)
|
||||||
|
{
|
||||||
|
size = sizeAndAlignment_.cellSize(pt);
|
||||||
|
}
|
||||||
|
else if (shapeControlMesh_.is_infinite(ch))
|
||||||
|
{
|
||||||
|
// if (nFarPoints != 0)
|
||||||
|
// {
|
||||||
|
// for (label pI = 0; pI < 4; ++pI)
|
||||||
|
// {
|
||||||
|
// if (!ch->vertex(pI)->farPoint())
|
||||||
|
// {
|
||||||
|
// size = ch->vertex(pI)->targetCellSize();
|
||||||
|
// return size;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// cellShapeControlMesh::Vertex_handle nearV =
|
||||||
|
// shapeControlMesh_.nearest_vertex_in_cell
|
||||||
|
// (
|
||||||
|
// toPoint<cellShapeControlMesh::Point>(pt),
|
||||||
|
// ch
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// size = nearV->targetCellSize();
|
||||||
|
|
||||||
|
// Find nearest surface. This can be quite slow if there are a lot of
|
||||||
|
// surfaces
|
||||||
|
size = sizeAndAlignment_.cellSize(pt);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label nFarPoints = 0;
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (ch->vertex(pI)->farPoint())
|
||||||
|
{
|
||||||
|
nFarPoints++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nFarPoints != 0)
|
||||||
|
{
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (!ch->vertex(pI)->uninitialised())
|
||||||
|
{
|
||||||
|
size = ch->vertex(pI)->targetCellSize();
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
forAll(bary, pI)
|
||||||
|
{
|
||||||
|
size += bary[pI]*ch->vertex(pI)->targetCellSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Return the cell alignment at the given location
|
||||||
|
Foam::tensor Foam::cellShapeControl::cellAlignment(const point& pt) const
|
||||||
|
{
|
||||||
|
scalarList bary;
|
||||||
|
cellShapeControlMesh::Cell_handle ch;
|
||||||
|
|
||||||
|
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
|
||||||
|
tensor alignment = tensor::zero;
|
||||||
|
|
||||||
|
if (shapeControlMesh_.dimension() < 3 || shapeControlMesh_.is_infinite(ch))
|
||||||
|
{
|
||||||
|
alignment = tensor::I;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label nFarPoints = 0;
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (ch->vertex(pI)->farPoint())
|
||||||
|
{
|
||||||
|
nFarPoints++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (nFarPoints != 0)
|
||||||
|
// {
|
||||||
|
// for (label pI = 0; pI < 4; ++pI)
|
||||||
|
// {
|
||||||
|
// if (!ch->vertex(pI)->farPoint())
|
||||||
|
// {
|
||||||
|
// alignment = ch->vertex(pI)->alignment();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
{
|
||||||
|
triad tri;
|
||||||
|
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (bary[pI] > SMALL)
|
||||||
|
{
|
||||||
|
tri += triad(bary[pI]*ch->vertex(pI)->alignment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tri.normalize();
|
||||||
|
tri.orthogonalize();
|
||||||
|
tri = tri.sortxyz();
|
||||||
|
|
||||||
|
alignment = tri;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cellShapeControlMesh::Vertex_handle nearV =
|
||||||
|
// shapeControlMesh_.nearest_vertex_in_cell
|
||||||
|
// (
|
||||||
|
// toPoint<cellShapeControlMesh::Point>(pt),
|
||||||
|
// ch
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// alignment = nearV->alignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellShapeControl::cellSizeAndAlignment
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size,
|
||||||
|
tensor& alignment
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
scalarList bary;
|
||||||
|
cellShapeControlMesh::Cell_handle ch;
|
||||||
|
|
||||||
|
shapeControlMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
|
||||||
|
alignment = tensor::zero;
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
if (shapeControlMesh_.dimension() < 3 || shapeControlMesh_.is_infinite(ch))
|
||||||
|
{
|
||||||
|
// Find nearest surface
|
||||||
|
size = sizeAndAlignment_.cellSize(pt);
|
||||||
|
alignment = tensor::I;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
label nFarPoints = 0;
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (ch->vertex(pI)->farPoint())
|
||||||
|
{
|
||||||
|
nFarPoints++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nFarPoints != 0)
|
||||||
|
{
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
if (!ch->vertex(pI)->uninitialised())
|
||||||
|
{
|
||||||
|
size = ch->vertex(pI)->targetCellSize();
|
||||||
|
alignment = ch->vertex(pI)->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
triad tri;
|
||||||
|
|
||||||
|
for (label pI = 0; pI < 4; ++pI)
|
||||||
|
{
|
||||||
|
size += bary[pI]*ch->vertex(pI)->targetCellSize();
|
||||||
|
|
||||||
|
if (bary[pI] > SMALL)
|
||||||
|
{
|
||||||
|
tri += triad(bary[pI]*ch->vertex(pI)->alignment());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tri.normalize();
|
||||||
|
tri.orthogonalize();
|
||||||
|
tri = tri.sortxyz();
|
||||||
|
|
||||||
|
alignment = tri;
|
||||||
|
|
||||||
|
// cellShapeControlMesh::Vertex_handle nearV =
|
||||||
|
// shapeControlMesh_.nearest_vertex
|
||||||
|
// (
|
||||||
|
// toPoint<cellShapeControlMesh::Point>(pt)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// alignment = nearV->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (label dir = 0; dir < 3; dir++)
|
||||||
|
{
|
||||||
|
triad v = alignment;
|
||||||
|
|
||||||
|
if (!v.set(dir) || size == 0)
|
||||||
|
{
|
||||||
|
// Force orthogonalization of triad.
|
||||||
|
|
||||||
|
scalar dotProd = GREAT;
|
||||||
|
if (dir == 0)
|
||||||
|
{
|
||||||
|
dotProd = v[1] & v[2];
|
||||||
|
|
||||||
|
v[dir] = v[1] ^ v[2];
|
||||||
|
}
|
||||||
|
if (dir == 1)
|
||||||
|
{
|
||||||
|
dotProd = v[0] & v[2];
|
||||||
|
|
||||||
|
v[dir] = v[0] ^ v[2];
|
||||||
|
}
|
||||||
|
if (dir == 2)
|
||||||
|
{
|
||||||
|
dotProd = v[0] & v[1];
|
||||||
|
|
||||||
|
v[dir] = v[0] ^ v[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
v.normalize();
|
||||||
|
v.orthogonalize();
|
||||||
|
|
||||||
|
Pout<< "Dot prod = " << dotProd << endl;
|
||||||
|
Pout<< "Alignment = " << v << endl;
|
||||||
|
|
||||||
|
alignment = v;
|
||||||
|
|
||||||
|
// FatalErrorIn
|
||||||
|
// (
|
||||||
|
// "Foam::conformalVoronoiMesh::setVertexSizeAndAlignment()"
|
||||||
|
// ) << "Point has bad alignment! "
|
||||||
|
// << pt << " " << size << " " << alignment << nl
|
||||||
|
// << "Bary Coords = " << bary << nl
|
||||||
|
// << ch->vertex(0)->info() << nl
|
||||||
|
// << ch->vertex(1)->info() << nl
|
||||||
|
// << ch->vertex(2)->info() << nl
|
||||||
|
// << ch->vertex(3)->info()
|
||||||
|
// << abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,166 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellShapeControl
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellShapeControlI.H
|
||||||
|
cellShapeControl.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellShapeControl_H
|
||||||
|
#define cellShapeControl_H
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "tensor.H"
|
||||||
|
#include "point.H"
|
||||||
|
#include "primitiveFieldsFwd.H"
|
||||||
|
#include "pointFieldFwd.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "searchableSurfaces.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "cellAspectRatioControl.H"
|
||||||
|
#include "cellSizeAndAlignmentControls.H"
|
||||||
|
#include "cellShapeControlMesh.H"
|
||||||
|
#include "backgroundMeshDecomposition.H"
|
||||||
|
#include "cvControls.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellShapeControl Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellShapeControl
|
||||||
|
:
|
||||||
|
public dictionary
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const Time& runTime_;
|
||||||
|
|
||||||
|
const searchableSurfaces& allGeometry_;
|
||||||
|
|
||||||
|
const conformationSurfaces& geometryToConformTo_;
|
||||||
|
|
||||||
|
const scalar defaultCellSize_;
|
||||||
|
|
||||||
|
const scalar minimumCellSize_;
|
||||||
|
|
||||||
|
cellShapeControlMesh shapeControlMesh_;
|
||||||
|
|
||||||
|
cellAspectRatioControl aspectRatio_;
|
||||||
|
|
||||||
|
cellSizeAndAlignmentControls sizeAndAlignment_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellShapeControl(const cellShapeControl&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellShapeControl&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("cellShapeControl");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||||
|
// searchableSurfaces
|
||||||
|
cellShapeControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const cvControls& foamyHexMeshControls,
|
||||||
|
const searchableSurfaces& allGeometry,
|
||||||
|
const conformationSurfaces& geometryToConformTo
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~cellShapeControl();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
inline const scalar& defaultCellSize() const;
|
||||||
|
|
||||||
|
inline cellShapeControlMesh& shapeControlMesh();
|
||||||
|
|
||||||
|
inline const cellShapeControlMesh& shapeControlMesh() const;
|
||||||
|
|
||||||
|
inline const cellAspectRatioControl& aspectRatio() const;
|
||||||
|
|
||||||
|
inline const cellSizeAndAlignmentControls& sizeAndAlignment() const;
|
||||||
|
|
||||||
|
inline const scalar& minimumCellSize() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
//- Return the cell size at the given location
|
||||||
|
scalar cellSize(const point& pt) const;
|
||||||
|
|
||||||
|
scalarField cellSize(const pointField& pts) const;
|
||||||
|
|
||||||
|
//- Return the cell alignment at the given location
|
||||||
|
tensor cellAlignment(const point& pt) const;
|
||||||
|
|
||||||
|
void cellSizeAndAlignment
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size,
|
||||||
|
tensor& alignment
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "cellShapeControlI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline Foam::cellShapeControlMesh&
|
||||||
|
Foam::cellShapeControl::shapeControlMesh()
|
||||||
|
{
|
||||||
|
return shapeControlMesh_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::cellShapeControlMesh&
|
||||||
|
Foam::cellShapeControl::shapeControlMesh() const
|
||||||
|
{
|
||||||
|
return shapeControlMesh_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::scalar& Foam::cellShapeControl::defaultCellSize() const
|
||||||
|
{
|
||||||
|
return defaultCellSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::cellAspectRatioControl&
|
||||||
|
Foam::cellShapeControl::aspectRatio() const
|
||||||
|
{
|
||||||
|
return aspectRatio_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::cellSizeAndAlignmentControls&
|
||||||
|
Foam::cellShapeControl::sizeAndAlignment() const
|
||||||
|
{
|
||||||
|
return sizeAndAlignment_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::scalar& Foam::cellShapeControl::minimumCellSize() const
|
||||||
|
{
|
||||||
|
return minimumCellSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,836 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellShapeControlMesh.H"
|
||||||
|
#include "cellSizeAndAlignmentControls.H"
|
||||||
|
#include "pointIOField.H"
|
||||||
|
#include "scalarIOField.H"
|
||||||
|
#include "tensorIOField.H"
|
||||||
|
#include "tetrahedron.H"
|
||||||
|
#include "plane.H"
|
||||||
|
#include "transform.H"
|
||||||
|
#include "meshTools.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellShapeControlMesh, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//Foam::tensor Foam::cellShapeControlMesh::requiredAlignment
|
||||||
|
//(
|
||||||
|
// const Foam::point& pt,
|
||||||
|
// const searchableSurfaces& allGeometry,
|
||||||
|
// const conformationSurfaces& geometryToConformTo
|
||||||
|
//) const
|
||||||
|
//{
|
||||||
|
// pointIndexHit surfHit;
|
||||||
|
// label hitSurface;
|
||||||
|
//
|
||||||
|
// geometryToConformTo.findSurfaceNearest
|
||||||
|
// (
|
||||||
|
// pt,
|
||||||
|
// sqr(GREAT),
|
||||||
|
// surfHit,
|
||||||
|
// hitSurface
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (!surfHit.hit())
|
||||||
|
// {
|
||||||
|
// FatalErrorIn
|
||||||
|
// (
|
||||||
|
// "Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment"
|
||||||
|
// ) << "findSurfaceNearest did not find a hit across the surfaces."
|
||||||
|
// << exit(FatalError) << endl;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Primary alignment
|
||||||
|
//
|
||||||
|
// vectorField norm(1);
|
||||||
|
//
|
||||||
|
// allGeometry[hitSurface].getNormal
|
||||||
|
// (
|
||||||
|
// List<pointIndexHit>(1, surfHit),
|
||||||
|
// norm
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// const vector np = norm[0];
|
||||||
|
//
|
||||||
|
// // Generate equally spaced 'spokes' in a circle normal to the
|
||||||
|
// // direction from the vertex to the closest point on the surface
|
||||||
|
// // and look for a secondary intersection.
|
||||||
|
//
|
||||||
|
// const vector d = surfHit.hitPoint() - pt;
|
||||||
|
//
|
||||||
|
// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||||
|
//
|
||||||
|
// const label s = 36;//foamyHexMeshControls().alignmentSearchSpokes();
|
||||||
|
//
|
||||||
|
// scalar closestSpokeHitDistance = GREAT;
|
||||||
|
//
|
||||||
|
// pointIndexHit closestSpokeHit;
|
||||||
|
//
|
||||||
|
// label closestSpokeSurface = -1;
|
||||||
|
//
|
||||||
|
// const scalar spanMag = geometryToConformTo.globalBounds().mag();
|
||||||
|
//
|
||||||
|
// for (label i = 0; i < s; i++)
|
||||||
|
// {
|
||||||
|
// vector spoke
|
||||||
|
// (
|
||||||
|
// Foam::cos(i*constant::mathematical::twoPi/s),
|
||||||
|
// Foam::sin(i*constant::mathematical::twoPi/s),
|
||||||
|
// 0
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// spoke *= spanMag;
|
||||||
|
//
|
||||||
|
// spoke = Rp & spoke;
|
||||||
|
//
|
||||||
|
// pointIndexHit spokeHit;
|
||||||
|
//
|
||||||
|
// label spokeSurface = -1;
|
||||||
|
//
|
||||||
|
// // internal spoke
|
||||||
|
//
|
||||||
|
// geometryToConformTo.findSurfaceNearestIntersection
|
||||||
|
// (
|
||||||
|
// pt,
|
||||||
|
// pt + spoke,
|
||||||
|
// spokeHit,
|
||||||
|
// spokeSurface
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (spokeHit.hit())
|
||||||
|
// {
|
||||||
|
// scalar spokeHitDistance = mag
|
||||||
|
// (
|
||||||
|
// spokeHit.hitPoint() - pt
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (spokeHitDistance < closestSpokeHitDistance)
|
||||||
|
// {
|
||||||
|
// closestSpokeHit = spokeHit;
|
||||||
|
// closestSpokeSurface = spokeSurface;
|
||||||
|
// closestSpokeHitDistance = spokeHitDistance;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //external spoke
|
||||||
|
//
|
||||||
|
// Foam::point mirrorPt = pt + 2*d;
|
||||||
|
//
|
||||||
|
// geometryToConformTo.findSurfaceNearestIntersection
|
||||||
|
// (
|
||||||
|
// mirrorPt,
|
||||||
|
// mirrorPt + spoke,
|
||||||
|
// spokeHit,
|
||||||
|
// spokeSurface
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (spokeHit.hit())
|
||||||
|
// {
|
||||||
|
// scalar spokeHitDistance = mag
|
||||||
|
// (
|
||||||
|
// spokeHit.hitPoint() - mirrorPt
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (spokeHitDistance < closestSpokeHitDistance)
|
||||||
|
// {
|
||||||
|
// closestSpokeHit = spokeHit;
|
||||||
|
// closestSpokeSurface = spokeSurface;
|
||||||
|
// closestSpokeHitDistance = spokeHitDistance;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// if (closestSpokeSurface == -1)
|
||||||
|
// {
|
||||||
|
//// WarningIn
|
||||||
|
//// (
|
||||||
|
//// "conformalVoronoiMesh::requiredAlignment"
|
||||||
|
//// "("
|
||||||
|
//// "const Foam::point& pt"
|
||||||
|
//// ") const"
|
||||||
|
//// ) << "No secondary surface hit found in spoke search "
|
||||||
|
//// << "using " << s
|
||||||
|
//// << " spokes, try increasing alignmentSearchSpokes."
|
||||||
|
//// << endl;
|
||||||
|
//
|
||||||
|
// return I;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Auxiliary alignment generated by spoke intersection normal.
|
||||||
|
//
|
||||||
|
// allGeometry[closestSpokeSurface].getNormal
|
||||||
|
// (
|
||||||
|
// List<pointIndexHit>(1, closestSpokeHit),
|
||||||
|
// norm
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// const vector& na = norm[0];
|
||||||
|
//
|
||||||
|
// // Secondary alignment
|
||||||
|
// vector ns = np ^ na;
|
||||||
|
//
|
||||||
|
// if (mag(ns) < SMALL)
|
||||||
|
// {
|
||||||
|
// FatalErrorIn("conformalVoronoiMesh::requiredAlignment")
|
||||||
|
// << "Parallel normals detected in spoke search." << nl
|
||||||
|
// << "point: " << pt << nl
|
||||||
|
// << "closest surface point: " << surfHit.hitPoint() << nl
|
||||||
|
// << "closest spoke hit: " << closestSpokeHit.hitPoint() << nl
|
||||||
|
// << "np: " << surfHit.hitPoint() + np << nl
|
||||||
|
// << "ns: " << closestSpokeHit.hitPoint() + na << nl
|
||||||
|
// << exit(FatalError);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ns /= mag(ns);
|
||||||
|
//
|
||||||
|
// tensor Rs = rotationTensor((Rp & vector(0,1,0)), ns);
|
||||||
|
//
|
||||||
|
// return (Rs & Rp);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::cellShapeControlMesh::removePoints()
|
||||||
|
{
|
||||||
|
label nRemoved = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
std::list<Vertex_handle> verts;
|
||||||
|
adjacent_vertices(vit, std::back_inserter(verts));
|
||||||
|
|
||||||
|
bool removePt = true;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
std::list<Vertex_handle>::iterator aVit = verts.begin();
|
||||||
|
aVit != verts.end();
|
||||||
|
++aVit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Vertex_handle avh = *aVit;
|
||||||
|
|
||||||
|
scalar diff =
|
||||||
|
mag(avh->targetCellSize() - vit->targetCellSize())
|
||||||
|
/max(vit->targetCellSize(), 1e-6);
|
||||||
|
|
||||||
|
if (diff > 0.05)
|
||||||
|
{
|
||||||
|
removePt = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (removePt)
|
||||||
|
{
|
||||||
|
remove(vit);
|
||||||
|
nRemoved++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nRemoved;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::pointField> Foam::cellShapeControlMesh::cellCentres() const
|
||||||
|
{
|
||||||
|
tmp<pointField> tcellCentres(new pointField(number_of_finite_cells()));
|
||||||
|
pointField& cellCentres = tcellCentres();
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_cells_iterator c = finite_cells_begin();
|
||||||
|
c != finite_cells_end();
|
||||||
|
++c
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (c->hasFarPoint())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
scalarList bary;
|
||||||
|
cellShapeControlMesh::Cell_handle ch;
|
||||||
|
|
||||||
|
const Foam::point centre = topoint
|
||||||
|
(
|
||||||
|
CGAL::centroid<baseK>
|
||||||
|
(
|
||||||
|
c->vertex(0)->point(),
|
||||||
|
c->vertex(1)->point(),
|
||||||
|
c->vertex(2)->point(),
|
||||||
|
c->vertex(3)->point()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
cellCentres[count++] = centre;
|
||||||
|
}
|
||||||
|
|
||||||
|
cellCentres.resize(count);
|
||||||
|
|
||||||
|
return tcellCentres;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellShapeControlMesh::writeTriangulation()
|
||||||
|
{
|
||||||
|
OFstream str
|
||||||
|
(
|
||||||
|
"refinementTriangulation_"
|
||||||
|
+ name(Pstream::myProcNo())
|
||||||
|
+ ".obj"
|
||||||
|
);
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
Info<< "Write refinementTriangulation" << endl;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_edges_iterator e = finite_edges_begin();
|
||||||
|
e != finite_edges_end();
|
||||||
|
++e
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Cell_handle c = e->first;
|
||||||
|
Vertex_handle vA = c->vertex(e->second);
|
||||||
|
Vertex_handle vB = c->vertex(e->third);
|
||||||
|
|
||||||
|
// Don't write far edges
|
||||||
|
if (vA->farPoint() || vB->farPoint())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Don't write unowned edges
|
||||||
|
if (vA->referred() && vB->referred())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointFromPoint p1 = topoint(vA->point());
|
||||||
|
pointFromPoint p2 = topoint(vB->point());
|
||||||
|
|
||||||
|
meshTools::writeOBJ(str, p1, p2, count);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_valid())
|
||||||
|
{
|
||||||
|
Info<< " Triangulation is valid" << endl;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::triangulatedMesh::writeRefinementTriangulation()"
|
||||||
|
) << "Triangulation is not valid"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellShapeControlMesh::cellShapeControlMesh(const Time& runTime)
|
||||||
|
:
|
||||||
|
runTime_(runTime),
|
||||||
|
defaultCellSize_(0.0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
//Foam::triangulatedMesh::triangulatedMesh
|
||||||
|
//(
|
||||||
|
// const Time& runTime,
|
||||||
|
// const fileName& pointsFile,
|
||||||
|
// const fileName& sizesFile,
|
||||||
|
// const fileName& alignmentsFile,
|
||||||
|
// const scalar& defaultCellSize
|
||||||
|
//)
|
||||||
|
//:
|
||||||
|
// defaultCellSize_(defaultCellSize)
|
||||||
|
//{
|
||||||
|
// Info<< " Reading points from file : " << pointsFile << endl;
|
||||||
|
//
|
||||||
|
// pointIOField points
|
||||||
|
// (
|
||||||
|
// IOobject
|
||||||
|
// (
|
||||||
|
// pointsFile,
|
||||||
|
// runTime.constant(),
|
||||||
|
// runTime,
|
||||||
|
// IOobject::MUST_READ,
|
||||||
|
// IOobject::NO_WRITE
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// Info<< " Reading sizes from file : " << sizesFile << endl;
|
||||||
|
//
|
||||||
|
// scalarIOField sizes
|
||||||
|
// (
|
||||||
|
// IOobject
|
||||||
|
// (
|
||||||
|
// sizesFile,
|
||||||
|
// runTime.constant(),
|
||||||
|
// runTime,
|
||||||
|
// IOobject::MUST_READ,
|
||||||
|
// IOobject::NO_WRITE
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// Info<< " Reading alignments from file : " << alignmentsFile << endl;
|
||||||
|
//
|
||||||
|
// tensorIOField alignments
|
||||||
|
// (
|
||||||
|
// IOobject
|
||||||
|
// (
|
||||||
|
// alignmentsFile,
|
||||||
|
// runTime.constant(),
|
||||||
|
// runTime,
|
||||||
|
// IOobject::MUST_READ,
|
||||||
|
// IOobject::NO_WRITE
|
||||||
|
// )
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// Info<< " Number of points : " << points.size() << endl;
|
||||||
|
// Info<< " Minimum size : " << min(sizes) << endl;
|
||||||
|
// Info<< " Average size : " << average(sizes) << endl;
|
||||||
|
// Info<< " Maximum size : " << max(sizes) << endl;
|
||||||
|
//
|
||||||
|
// forAll(points, pI)
|
||||||
|
// {
|
||||||
|
// size_t nVert = number_of_vertices();
|
||||||
|
//
|
||||||
|
// Vertex_handle v = insert
|
||||||
|
// (
|
||||||
|
// Point(points[pI].x(), points[pI].y(), points[pI].z())
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (number_of_vertices() == nVert)
|
||||||
|
// {
|
||||||
|
// Info<< " Failed to insert point : " << points[pI] << endl;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// v->targetCellSize() = sizes[pI];
|
||||||
|
//
|
||||||
|
// const tensor& alignment = alignments[pI];
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// v->alignment() = alignment;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// scalar factor = 1.0;
|
||||||
|
//// label maxIteration = 1;
|
||||||
|
////
|
||||||
|
//// for (label iteration = 0; iteration < maxIteration; ++iteration)
|
||||||
|
//// {
|
||||||
|
//// Info<< "Iteration : " << iteration << endl;
|
||||||
|
////
|
||||||
|
//// label nRefined = refineTriangulation(factor);
|
||||||
|
////
|
||||||
|
//// Info<< " Number of cells refined in refinement iteration : "
|
||||||
|
//// << nRefined << nl << endl;
|
||||||
|
////
|
||||||
|
//// if (nRefined <= 0 && iteration != 0)
|
||||||
|
//// {
|
||||||
|
//// break;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
//// factor *= 1.5;
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// //writeRefinementTriangulation();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//Foam::triangulatedMesh::triangulatedMesh
|
||||||
|
//(
|
||||||
|
// const Time& runTime,
|
||||||
|
// const DynamicList<Foam::point>& points,
|
||||||
|
// const DynamicList<scalar>& sizes,
|
||||||
|
// const DynamicList<tensor>& alignments,
|
||||||
|
// const scalar& defaultCellSize
|
||||||
|
//)
|
||||||
|
//:
|
||||||
|
// defaultCellSize_(defaultCellSize)
|
||||||
|
//{
|
||||||
|
// forAll(points, pI)
|
||||||
|
// {
|
||||||
|
// size_t nVert = number_of_vertices();
|
||||||
|
//
|
||||||
|
// Vertex_handle v = insert
|
||||||
|
// (
|
||||||
|
// Point(points[pI].x(), points[pI].y(), points[pI].z())
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (number_of_vertices() == nVert)
|
||||||
|
// {
|
||||||
|
// Info<< "Failed to insert point : " << points[pI] << endl;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// v->targetCellSize() = sizes[pI];
|
||||||
|
//
|
||||||
|
// v->alignment() = alignments[pI];
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// //writeRefinementTriangulation();
|
||||||
|
//
|
||||||
|
// Info<< nl << "Refinement triangulation information: " << endl;
|
||||||
|
// Info<< " Number of vertices: " << label(number_of_vertices()) << endl;
|
||||||
|
// Info<< " Number of cells : "
|
||||||
|
// << label(number_of_finite_cells()) << endl;
|
||||||
|
// Info<< " Number of faces : "
|
||||||
|
// << label(number_of_finite_facets()) << endl;
|
||||||
|
// Info<< " Number of edges : "
|
||||||
|
// << label(number_of_finite_edges()) << endl;
|
||||||
|
// Info<< " Dimensionality : " << label(dimension()) << nl << endl;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellShapeControlMesh::~cellShapeControlMesh()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::cellShapeControlMesh::barycentricCoords
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
scalarList& bary,
|
||||||
|
Cell_handle& ch
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Use the previous cell handle as a hint on where to start searching
|
||||||
|
// Giving a hint causes strange errors...
|
||||||
|
ch = locate(toPoint<Point>(pt));
|
||||||
|
|
||||||
|
if (dimension() > 2 && !is_infinite(ch))
|
||||||
|
{
|
||||||
|
oldCellHandle_ = ch;
|
||||||
|
|
||||||
|
tetPointRef tet
|
||||||
|
(
|
||||||
|
topoint(ch->vertex(0)->point()),
|
||||||
|
topoint(ch->vertex(1)->point()),
|
||||||
|
topoint(ch->vertex(2)->point()),
|
||||||
|
topoint(ch->vertex(3)->point())
|
||||||
|
);
|
||||||
|
|
||||||
|
tet.barycentric(pt, bary);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::boundBox Foam::cellShapeControlMesh::bounds() const
|
||||||
|
{
|
||||||
|
DynamicList<Foam::point> pts(number_of_vertices());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
pts.append(topoint(vit->point()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boundBox bb(pts);
|
||||||
|
|
||||||
|
return bb;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellShapeControlMesh::distribute
|
||||||
|
(
|
||||||
|
const backgroundMeshDecomposition& decomposition
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!Pstream::parRun())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoPtr<mapDistribute> mapDist =
|
||||||
|
DistributedDelaunayMesh<CellSizeDelaunay>::distribute(decomposition);
|
||||||
|
|
||||||
|
DynamicList<Foam::point> points(number_of_vertices());
|
||||||
|
DynamicList<scalar> sizes(number_of_vertices());
|
||||||
|
DynamicList<tensor> alignments(number_of_vertices());
|
||||||
|
|
||||||
|
DynamicList<Vb> farPts(8);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
points.append(topoint(vit->point()));
|
||||||
|
sizes.append(vit->targetCellSize());
|
||||||
|
alignments.append(vit->alignment());
|
||||||
|
}
|
||||||
|
else if (vit->farPoint())
|
||||||
|
{
|
||||||
|
farPts.append
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
vit->point(),
|
||||||
|
-1,
|
||||||
|
Vb::vtFar,
|
||||||
|
Pstream::myProcNo()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
farPts.last().targetCellSize() = vit->targetCellSize();
|
||||||
|
farPts.last().alignment() = vit->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mapDist().distribute(points);
|
||||||
|
mapDist().distribute(sizes);
|
||||||
|
mapDist().distribute(alignments);
|
||||||
|
|
||||||
|
// Reset the entire tessellation
|
||||||
|
DelaunayMesh<CellSizeDelaunay>::reset();
|
||||||
|
|
||||||
|
|
||||||
|
// Internal points have to be inserted first
|
||||||
|
DynamicList<Vb> verticesToInsert(points.size());
|
||||||
|
|
||||||
|
|
||||||
|
forAll(farPts, ptI)
|
||||||
|
{
|
||||||
|
verticesToInsert.append(farPts[ptI]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
forAll(points, pI)
|
||||||
|
{
|
||||||
|
verticesToInsert.append
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint<Point>(points[pI]),
|
||||||
|
-1,
|
||||||
|
Vb::vtInternal,
|
||||||
|
Pstream::myProcNo()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
verticesToInsert.last().targetCellSize() = sizes[pI];
|
||||||
|
verticesToInsert.last().alignment() = alignments[pI];
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << " Inserting distributed background tessellation..." << endl;
|
||||||
|
|
||||||
|
this->rangeInsertWithInfo
|
||||||
|
(
|
||||||
|
verticesToInsert.begin(),
|
||||||
|
verticesToInsert.end(),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
sync(decomposition.procBounds());
|
||||||
|
|
||||||
|
Info<< " Total number of vertices after redistribution "
|
||||||
|
<< returnReduce(label(number_of_vertices()), sumOp<label>()) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tensorField Foam::cellShapeControlMesh::dumpAlignments() const
|
||||||
|
{
|
||||||
|
tensorField alignmentsTmp(number_of_vertices(), tensor::zero);
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
alignmentsTmp[count++] = vit->alignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return alignmentsTmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellShapeControlMesh::insertBoundingPoints
|
||||||
|
(
|
||||||
|
const boundBox& bb,
|
||||||
|
const cellSizeAndAlignmentControls& sizeControls
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// Loop over bound box points and get cell size and alignment
|
||||||
|
const pointField bbPoints(bb.points());
|
||||||
|
|
||||||
|
forAll(bbPoints, pI)
|
||||||
|
{
|
||||||
|
const Foam::point& pt = bbPoints[pI];
|
||||||
|
|
||||||
|
// Cell size here will return default cell size
|
||||||
|
const scalar cellSize = sizeControls.cellSize(pt);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Insert Bounding Point: " << pt << " " << cellSize << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the cell size of the nearest surface.
|
||||||
|
// geometryToConformTo_.findSurfaceNearest
|
||||||
|
// (
|
||||||
|
// pt,
|
||||||
|
// GREAT,
|
||||||
|
// surfHit,
|
||||||
|
// hitSurface
|
||||||
|
// );
|
||||||
|
|
||||||
|
const tensor alignment = tensor::I;
|
||||||
|
|
||||||
|
insert
|
||||||
|
(
|
||||||
|
pt,
|
||||||
|
cellSize,
|
||||||
|
alignment,
|
||||||
|
Vb::vtInternalNearBoundary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::cellShapeControlMesh::write() const
|
||||||
|
{
|
||||||
|
Info<< "Writing cell size and alignment mesh" << endl;
|
||||||
|
|
||||||
|
const fileName name("cellSizeAndAlignmentMesh");
|
||||||
|
|
||||||
|
// Reindex the cells
|
||||||
|
label cellCount = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_cells_iterator cit = finite_cells_begin();
|
||||||
|
cit != finite_cells_end();
|
||||||
|
++cit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!cit->hasFarPoint() && !is_infinite(cit))
|
||||||
|
{
|
||||||
|
cit->cellIndex() = cellCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labelList vertexMap;
|
||||||
|
labelList cellMap;
|
||||||
|
|
||||||
|
autoPtr<fvMesh> meshPtr = DelaunayMesh<CellSizeDelaunay>::createMesh
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
runTime_,
|
||||||
|
vertexMap,
|
||||||
|
cellMap
|
||||||
|
);
|
||||||
|
const fvMesh& mesh = meshPtr();
|
||||||
|
|
||||||
|
pointScalarField sizes
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"sizes",
|
||||||
|
mesh.time().timeName(),
|
||||||
|
mesh,
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::AUTO_WRITE
|
||||||
|
),
|
||||||
|
pointMesh::New(mesh),
|
||||||
|
scalar(0)
|
||||||
|
);
|
||||||
|
|
||||||
|
OFstream str(runTime_.path()/"alignments.obj");
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
Finite_vertices_iterator vit = finite_vertices_begin();
|
||||||
|
vit != finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->farPoint())
|
||||||
|
{
|
||||||
|
// Populate sizes
|
||||||
|
sizes[vertexMap[vit->index()]] = vit->targetCellSize();
|
||||||
|
|
||||||
|
// Write alignments
|
||||||
|
const tensor& alignment = vit->alignment();
|
||||||
|
pointFromPoint pt = topoint(vit->point());
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
alignment.x() == triad::unset[0]
|
||||||
|
|| alignment.y() == triad::unset[0]
|
||||||
|
|| alignment.z() == triad::unset[0]
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "Bad alignment = " << vit->info();
|
||||||
|
|
||||||
|
vit->alignment() = tensor::I;
|
||||||
|
|
||||||
|
Info<< "New alignment = " << vit->info();
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
meshTools::writeOBJ(str, pt, alignment.x() + pt);
|
||||||
|
meshTools::writeOBJ(str, pt, alignment.y() + pt);
|
||||||
|
meshTools::writeOBJ(str, pt, alignment.z() + pt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh.write();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellShapeControlMesh
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellShapeControlMeshI.H
|
||||||
|
cellShapeControlMesh.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellShapeControlMesh_H
|
||||||
|
#define cellShapeControlMesh_H
|
||||||
|
|
||||||
|
#include "Time.H"
|
||||||
|
#include "scalar.H"
|
||||||
|
#include "point.H"
|
||||||
|
#include "tensor.H"
|
||||||
|
#include "triad.H"
|
||||||
|
#include "fileName.H"
|
||||||
|
#include "searchableSurfaces.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "DistributedDelaunayMesh.H"
|
||||||
|
#include "CGALTriangulation3Ddefs.H"
|
||||||
|
#include "backgroundMeshDecomposition.H"
|
||||||
|
#include "boundBox.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class cellSizeAndAlignmentControls;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellShapeControlMesh Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellShapeControlMesh
|
||||||
|
:
|
||||||
|
public DistributedDelaunayMesh<CellSizeDelaunay>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef CellSizeDelaunay::Cell_handle Cell_handle;
|
||||||
|
typedef CellSizeDelaunay::Vertex_handle Vertex_handle;
|
||||||
|
typedef CellSizeDelaunay::Point Point;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const Time& runTime_;
|
||||||
|
|
||||||
|
mutable Cell_handle oldCellHandle_;
|
||||||
|
|
||||||
|
const scalar defaultCellSize_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellShapeControlMesh(const cellShapeControlMesh&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellShapeControlMesh&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("cellShapeControlMesh");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
explicit cellShapeControlMesh(const Time& runTime);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~cellShapeControlMesh();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
const Time& time() const
|
||||||
|
{
|
||||||
|
return runTime_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Calculate and return the barycentric coordinates for
|
||||||
|
// interpolating quantities on the background mesh
|
||||||
|
void barycentricCoords
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
scalarList& bary,
|
||||||
|
Cell_handle& ch
|
||||||
|
) const;
|
||||||
|
|
||||||
|
boundBox bounds() const;
|
||||||
|
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
label removePoints();
|
||||||
|
|
||||||
|
//- Get the centres of all the tets
|
||||||
|
tmp<pointField> cellCentres() const;
|
||||||
|
|
||||||
|
inline Vertex_handle insert
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
const scalar& size,
|
||||||
|
const triad& alignment,
|
||||||
|
const Foam::indexedVertexEnum::vertexType type = Vb::vtInternal
|
||||||
|
);
|
||||||
|
|
||||||
|
inline Vertex_handle insertFar
|
||||||
|
(
|
||||||
|
const Foam::point& pt
|
||||||
|
);
|
||||||
|
|
||||||
|
void distribute(const backgroundMeshDecomposition& decomposition);
|
||||||
|
|
||||||
|
tensorField dumpAlignments() const;
|
||||||
|
|
||||||
|
void insertBoundingPoints
|
||||||
|
(
|
||||||
|
const boundBox& bb,
|
||||||
|
const cellSizeAndAlignmentControls& sizeControls
|
||||||
|
);
|
||||||
|
|
||||||
|
void writeTriangulation();
|
||||||
|
|
||||||
|
void write() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "cellShapeControlMeshI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellShapeControlMesh::Vertex_handle Foam::cellShapeControlMesh::insert
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
const scalar& size,
|
||||||
|
const triad& alignment,
|
||||||
|
const Foam::indexedVertexEnum::vertexType type
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Vertex_handle v = CellSizeDelaunay::insert
|
||||||
|
(
|
||||||
|
Point(pt.x(), pt.y(), pt.z())
|
||||||
|
);
|
||||||
|
v->type() = type;
|
||||||
|
v->index() = getNewVertexIndex();
|
||||||
|
v->procIndex() = Pstream::myProcNo();
|
||||||
|
v->targetCellSize() = size;
|
||||||
|
v->alignment() = tensor(alignment.x(), alignment.y(), alignment.z());
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::cellShapeControlMesh::Vertex_handle Foam::cellShapeControlMesh::insertFar
|
||||||
|
(
|
||||||
|
const Foam::point& pt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Vertex_handle v = CellSizeDelaunay::insert
|
||||||
|
(
|
||||||
|
Point(pt.x(), pt.y(), pt.z())
|
||||||
|
);
|
||||||
|
v->type() = Vb::vtFar;
|
||||||
|
// v->type() = Vb::vtExternalFeaturePoint;
|
||||||
|
v->index() = getNewVertexIndex();
|
||||||
|
v->procIndex() = Pstream::myProcNo();
|
||||||
|
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellSizeAndAlignmentControl.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellSizeAndAlignmentControl, 0);
|
||||||
|
defineRunTimeSelectionTable(cellSizeAndAlignmentControl, dictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeAndAlignmentControl::cellSizeAndAlignmentControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
runTime_(runTime),
|
||||||
|
defaultCellSize_(defaultCellSize),
|
||||||
|
forceInitialPointInsertion_
|
||||||
|
(
|
||||||
|
controlFunctionDict.lookupOrDefault<Switch>
|
||||||
|
(
|
||||||
|
"forceInitialPointInsertion",
|
||||||
|
"off"
|
||||||
|
)
|
||||||
|
),
|
||||||
|
name_(name)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::cellSizeAndAlignmentControl>
|
||||||
|
Foam::cellSizeAndAlignmentControl::New
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
word cellSizeAndAlignmentControlTypeName
|
||||||
|
(
|
||||||
|
controlFunctionDict.lookup("type")
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< indent << "Selecting cellSizeAndAlignmentControl "
|
||||||
|
<< cellSizeAndAlignmentControlTypeName << endl;
|
||||||
|
|
||||||
|
dictionaryConstructorTable::iterator cstrIter =
|
||||||
|
dictionaryConstructorTablePtr_->find
|
||||||
|
(
|
||||||
|
cellSizeAndAlignmentControlTypeName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"cellSizeAndAlignmentControl::New()"
|
||||||
|
) << "Unknown cellSizeAndAlignmentControl type "
|
||||||
|
<< cellSizeAndAlignmentControlTypeName
|
||||||
|
<< endl << endl
|
||||||
|
<< "Valid cellSizeAndAlignmentControl types are :" << endl
|
||||||
|
<< dictionaryConstructorTablePtr_->toc()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<cellSizeAndAlignmentControl>
|
||||||
|
(
|
||||||
|
cstrIter()
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
name,
|
||||||
|
controlFunctionDict,
|
||||||
|
geometryToConformTo,
|
||||||
|
defaultCellSize
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeAndAlignmentControl::~cellSizeAndAlignmentControl()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,184 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellSizeAndAlignmentControl
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellSizeAndAlignmentControlI.H
|
||||||
|
cellSizeAndAlignmentControl.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellSizeAndAlignmentControl_H
|
||||||
|
#define cellSizeAndAlignmentControl_H
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "quaternion.H"
|
||||||
|
#include "triadField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellSizeAndAlignmentControl Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellSizeAndAlignmentControl
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
const Time& runTime_;
|
||||||
|
|
||||||
|
const scalar& defaultCellSize_;
|
||||||
|
|
||||||
|
Switch forceInitialPointInsertion_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const word name_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellSizeAndAlignmentControl(const cellSizeAndAlignmentControl&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellSizeAndAlignmentControl&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cellSizeAndAlignmentControl");
|
||||||
|
|
||||||
|
|
||||||
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
cellSizeAndAlignmentControl,
|
||||||
|
dictionary,
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
),
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
name,
|
||||||
|
controlFunctionDict,
|
||||||
|
geometryToConformTo,
|
||||||
|
defaultCellSize
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||||
|
// searchableSurfaces
|
||||||
|
cellSizeAndAlignmentControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Selectors
|
||||||
|
|
||||||
|
//- Return a reference to the selected cellShapeControl
|
||||||
|
static autoPtr<cellSizeAndAlignmentControl> New
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellSizeAndAlignmentControl();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
const word& name() const
|
||||||
|
{
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Switch& forceInitialPointInsertion() const
|
||||||
|
{
|
||||||
|
return forceInitialPointInsertion_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
virtual label maxPriority() const = 0;
|
||||||
|
|
||||||
|
virtual void cellSizeFunctionVertices
|
||||||
|
(
|
||||||
|
DynamicList<Foam::point>& pts,
|
||||||
|
DynamicList<scalar>& sizes
|
||||||
|
) const = 0;
|
||||||
|
|
||||||
|
virtual void initialVertices
|
||||||
|
(
|
||||||
|
pointField& pts,
|
||||||
|
scalarField& sizes,
|
||||||
|
triadField& alignments
|
||||||
|
) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellSizeAndAlignmentControls.H"
|
||||||
|
#include "searchableSurfaceControl.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellSizeAndAlignmentControls, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool Foam::cellSizeAndAlignmentControls::evalCellSizeFunctions
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& minSize,
|
||||||
|
label& maxPriority
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
bool anyFunctionFound = false;
|
||||||
|
|
||||||
|
// Regions requesting with the same priority take the smallest
|
||||||
|
|
||||||
|
if (controlFunctions_.size())
|
||||||
|
{
|
||||||
|
// Maintain priority of current hit. Initialise so it always goes
|
||||||
|
// through at least once.
|
||||||
|
label previousPriority = labelMin;
|
||||||
|
|
||||||
|
forAll(controlFunctions_, i)
|
||||||
|
{
|
||||||
|
const cellSizeAndAlignmentControl& cSF = controlFunctions_[i];
|
||||||
|
|
||||||
|
if (isA<searchableSurfaceControl>(cSF))
|
||||||
|
{
|
||||||
|
const searchableSurfaceControl& sSC =
|
||||||
|
refCast<const searchableSurfaceControl>(cSF);
|
||||||
|
|
||||||
|
anyFunctionFound = sSC.cellSize(pt, minSize, previousPriority);
|
||||||
|
|
||||||
|
if (previousPriority > maxPriority)
|
||||||
|
{
|
||||||
|
maxPriority = previousPriority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyFunctionFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeAndAlignmentControls::cellSizeAndAlignmentControls
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& shapeControlDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
shapeControlDict_(shapeControlDict),
|
||||||
|
geometryToConformTo_(geometryToConformTo),
|
||||||
|
controlFunctions_(shapeControlDict_.size()),
|
||||||
|
defaultCellSize_(defaultCellSize)
|
||||||
|
{
|
||||||
|
label functionI = 0;
|
||||||
|
|
||||||
|
forAllConstIter(dictionary, shapeControlDict_, iter)
|
||||||
|
{
|
||||||
|
word shapeControlEntryName = iter().keyword();
|
||||||
|
|
||||||
|
const dictionary& controlFunctionDict
|
||||||
|
(
|
||||||
|
shapeControlDict_.subDict(shapeControlEntryName)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< nl << "Shape Control : " << shapeControlEntryName << endl;
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
|
controlFunctions_.set
|
||||||
|
(
|
||||||
|
functionI,
|
||||||
|
cellSizeAndAlignmentControl::New
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
shapeControlEntryName,
|
||||||
|
controlFunctionDict,
|
||||||
|
geometryToConformTo_,
|
||||||
|
defaultCellSize_
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
|
|
||||||
|
functionI++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort controlFunctions_ by maxPriority
|
||||||
|
SortableList<label> functionPriorities(functionI);
|
||||||
|
|
||||||
|
forAll(controlFunctions_, funcI)
|
||||||
|
{
|
||||||
|
functionPriorities[funcI] = controlFunctions_[funcI].maxPriority();
|
||||||
|
}
|
||||||
|
|
||||||
|
functionPriorities.reverseSort();
|
||||||
|
|
||||||
|
labelList invertedFunctionPriorities =
|
||||||
|
invert(functionPriorities.size(), functionPriorities.indices());
|
||||||
|
|
||||||
|
controlFunctions_.reorder(invertedFunctionPriorities);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeAndAlignmentControls::~cellSizeAndAlignmentControls()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::cellSizeAndAlignmentControls::cellSize
|
||||||
|
(
|
||||||
|
const point& pt
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
scalar size = defaultCellSize_;
|
||||||
|
label maxPriority = -1;
|
||||||
|
|
||||||
|
evalCellSizeFunctions(pt, size, maxPriority);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::scalar Foam::cellSizeAndAlignmentControls::cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
label& maxPriority
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
scalar size = defaultCellSize_;
|
||||||
|
maxPriority = -1;
|
||||||
|
|
||||||
|
evalCellSizeFunctions(pt, size, maxPriority);
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellSizeAndAlignmentControls
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellSizeAndAlignmentControls.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellSizeAndAlignmentControls_H
|
||||||
|
#define cellSizeAndAlignmentControls_H
|
||||||
|
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "cellSizeAndAlignmentControl.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellSizeAndAlignmentControls Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellSizeAndAlignmentControls
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const dictionary& shapeControlDict_;
|
||||||
|
|
||||||
|
const conformationSurfaces& geometryToConformTo_;
|
||||||
|
|
||||||
|
PtrList<cellSizeAndAlignmentControl> controlFunctions_;
|
||||||
|
|
||||||
|
const scalar defaultCellSize_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
bool evalCellSizeFunctions
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& minSize,
|
||||||
|
label& maxPriority
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellSizeAndAlignmentControls(const cellSizeAndAlignmentControls&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellSizeAndAlignmentControls&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("cellSizeAndAlignmentControls");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary
|
||||||
|
cellSizeAndAlignmentControls
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const dictionary& shapeControlDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellSizeAndAlignmentControls();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
inline const PtrList<cellSizeAndAlignmentControl>&
|
||||||
|
controlFunctions() const
|
||||||
|
{
|
||||||
|
return controlFunctions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const conformationSurfaces& geometryToConformTo() const
|
||||||
|
{
|
||||||
|
return geometryToConformTo_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
scalar cellSize(const point& pt) const;
|
||||||
|
|
||||||
|
scalar cellSize(const point& pt, label& maxPriority) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,256 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fileControl.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "tetrahedron.H"
|
||||||
|
#include "scalarList.H"
|
||||||
|
#include "vectorTools.H"
|
||||||
|
#include "pointIOField.H"
|
||||||
|
#include "scalarIOField.H"
|
||||||
|
#include "triadIOField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(fileControl, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
cellSizeAndAlignmentControl,
|
||||||
|
fileControl,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileControl::fileControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeAndAlignmentControl
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
name,
|
||||||
|
controlFunctionDict,
|
||||||
|
geometryToConformTo,
|
||||||
|
defaultCellSize
|
||||||
|
),
|
||||||
|
pointsFile_(controlFunctionDict.lookup("pointsFile")),
|
||||||
|
sizesFile_(controlFunctionDict.lookup("sizesFile")),
|
||||||
|
alignmentsFile_(controlFunctionDict.lookup("alignmentsFile")),
|
||||||
|
maxPriority_(readLabel(controlFunctionDict.lookup("priority")))
|
||||||
|
{
|
||||||
|
Info<< indent << "Loading " << name << " from file:" << nl
|
||||||
|
<< indent << " priority : " << maxPriority_ << nl
|
||||||
|
<< indent << " points : " << pointsFile_ << nl
|
||||||
|
<< indent << " sizes : " << sizesFile_ << nl
|
||||||
|
<< indent << " alignments : " << alignmentsFile_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fileControl::~fileControl()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
//
|
||||||
|
//Foam::scalar Foam::fileControl::cellSize(const point& pt) const
|
||||||
|
//{
|
||||||
|
// scalarList bary;
|
||||||
|
// Cell_handle ch;
|
||||||
|
//
|
||||||
|
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
//
|
||||||
|
// scalar size = 0;
|
||||||
|
// forAll(bary, pI)
|
||||||
|
// {
|
||||||
|
// size += bary[pI]*ch->vertex(pI)->size();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return size;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////- Return the cell alignment at the given location
|
||||||
|
//Foam::tensor Foam::fileControl::cellAlignment(const point& pt) const
|
||||||
|
//{
|
||||||
|
// scalarList bary;
|
||||||
|
// Cell_handle ch;
|
||||||
|
//
|
||||||
|
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
//
|
||||||
|
// label nearest = 0;
|
||||||
|
//
|
||||||
|
// tensor alignment = Foam::tensor::zero;
|
||||||
|
// forAll(bary, pI)
|
||||||
|
// {
|
||||||
|
// //alignment += bary[pI]*ch->vertex(pI)->alignment();
|
||||||
|
//
|
||||||
|
// // Find nearest point
|
||||||
|
// if (bary[pI] > nearest)
|
||||||
|
// {
|
||||||
|
// alignment = ch->vertex(pI)->alignment();
|
||||||
|
// nearest = bary[pI];
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return alignment;
|
||||||
|
//}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
////- Return the cell alignment at the given location
|
||||||
|
//void Foam::fileControl::cellSizeAndAlignment
|
||||||
|
//(
|
||||||
|
// const point& pt,
|
||||||
|
// scalar& size,
|
||||||
|
// tensor& alignment
|
||||||
|
//) const
|
||||||
|
//{
|
||||||
|
// scalarList bary;
|
||||||
|
// Cell_handle ch;
|
||||||
|
//
|
||||||
|
// triangulatedMesh_.barycentricCoords(pt, bary, ch);
|
||||||
|
//
|
||||||
|
// size = 0;
|
||||||
|
// forAll(bary, pI)
|
||||||
|
// {
|
||||||
|
// size += bary[pI]*ch->vertex(pI)->size();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//// alignment = Foam::tensor::zero;
|
||||||
|
//// forAll(bary, pI)
|
||||||
|
//// {
|
||||||
|
//// alignment += bary[pI]*ch->vertex(pI)->alignment();
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// alignment = cellAlignment(pt);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileControl::cellSizeFunctionVertices
|
||||||
|
(
|
||||||
|
DynamicList<Foam::point>& pts,
|
||||||
|
DynamicList<scalar>& sizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::fileControl::initialVertices
|
||||||
|
(
|
||||||
|
pointField& pts,
|
||||||
|
scalarField& sizes,
|
||||||
|
triadField& alignments
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Info<< " Reading points from file : " << pointsFile_ << endl;
|
||||||
|
|
||||||
|
pointIOField pointsTmp
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
pointsFile_,
|
||||||
|
runTime_.constant(),
|
||||||
|
runTime_,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
pts.transfer(pointsTmp);
|
||||||
|
|
||||||
|
Info<< " Reading sizes from file : " << sizesFile_ << endl;
|
||||||
|
|
||||||
|
scalarIOField sizesTmp
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
sizesFile_,
|
||||||
|
runTime_.constant(),
|
||||||
|
runTime_,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
sizes.transfer(sizesTmp);
|
||||||
|
|
||||||
|
Info<< " Reading alignments from file : " << alignmentsFile_ << endl;
|
||||||
|
|
||||||
|
triadIOField alignmentsTmp
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
alignmentsFile_,
|
||||||
|
runTime_.constant(),
|
||||||
|
runTime_,
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
alignments.transfer(alignmentsTmp);
|
||||||
|
|
||||||
|
if ((pts.size() != sizes.size()) || (pts.size() != alignments.size()))
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::fileControl::initialVertices"
|
||||||
|
"("
|
||||||
|
" pointField&,"
|
||||||
|
" scalarField&,"
|
||||||
|
" Field<triad>&"
|
||||||
|
")"
|
||||||
|
) << "Size of list of points, sizes and alignments do not match:"
|
||||||
|
<< nl
|
||||||
|
<< "Points size = " << pts.size() << nl
|
||||||
|
<< "Sizes size = " << sizes.size() << nl
|
||||||
|
<< "Alignments size = " << alignments.size()
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,147 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fileControl
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fileControl.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fileControl_H
|
||||||
|
#define fileControl_H
|
||||||
|
|
||||||
|
#include "cellSizeAndAlignmentControl.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fileControl Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fileControl
|
||||||
|
:
|
||||||
|
public cellSizeAndAlignmentControl
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const fileName pointsFile_;
|
||||||
|
|
||||||
|
const fileName sizesFile_;
|
||||||
|
|
||||||
|
const fileName alignmentsFile_;
|
||||||
|
|
||||||
|
label maxPriority_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
fileControl(const fileControl&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const fileControl&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("fileControl");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||||
|
// searchableSurfaces
|
||||||
|
fileControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~fileControl();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
// //- Return the cell size at the given location
|
||||||
|
// virtual scalar cellSize(const point& pt) const;
|
||||||
|
//
|
||||||
|
// //- Return the cell alignment at the given location
|
||||||
|
// virtual tensor cellAlignment(const point& pt) const;
|
||||||
|
//
|
||||||
|
// virtual void cellSizeAndAlignment
|
||||||
|
// (
|
||||||
|
// const point& pt,
|
||||||
|
// scalar& size,
|
||||||
|
// tensor& alignment
|
||||||
|
// ) const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual label maxPriority() const
|
||||||
|
{
|
||||||
|
return maxPriority_;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
virtual void cellSizeFunctionVertices
|
||||||
|
(
|
||||||
|
DynamicList<Foam::point>& pts,
|
||||||
|
DynamicList<scalar>& sizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void initialVertices
|
||||||
|
(
|
||||||
|
pointField& pts,
|
||||||
|
scalarField& sizes,
|
||||||
|
triadField& alignments
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,573 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "searchableSurfaceControl.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "searchableBox.H"
|
||||||
|
#include "tetrahedron.H"
|
||||||
|
#include "vectorTools.H"
|
||||||
|
#include "quaternion.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(searchableSurfaceControl, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
cellSizeAndAlignmentControl,
|
||||||
|
searchableSurfaceControl,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//Foam::tensor Foam::surfaceControl::requiredAlignment
|
||||||
|
//(
|
||||||
|
// const Foam::point& pt,
|
||||||
|
// const vectorField& ptNormals
|
||||||
|
//) const
|
||||||
|
//{
|
||||||
|
//// pointIndexHit surfHit;
|
||||||
|
//// label hitSurface;
|
||||||
|
////
|
||||||
|
//// geometryToConformTo_.findSurfaceNearest
|
||||||
|
//// (
|
||||||
|
//// pt,
|
||||||
|
//// sqr(GREAT),
|
||||||
|
//// surfHit,
|
||||||
|
//// hitSurface
|
||||||
|
//// );
|
||||||
|
////
|
||||||
|
//// if (!surfHit.hit())
|
||||||
|
//// {
|
||||||
|
//// FatalErrorIn
|
||||||
|
//// (
|
||||||
|
//// "Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment"
|
||||||
|
//// )
|
||||||
|
//// << "findSurfaceNearest did not find a hit across the surfaces."
|
||||||
|
//// << exit(FatalError) << endl;
|
||||||
|
//// }
|
||||||
|
////
|
||||||
|
////// Primary alignment
|
||||||
|
////
|
||||||
|
//// vectorField norm(1);
|
||||||
|
////
|
||||||
|
//// allGeometry_[hitSurface].getNormal
|
||||||
|
//// (
|
||||||
|
//// List<pointIndexHit>(1, surfHit),
|
||||||
|
//// norm
|
||||||
|
//// );
|
||||||
|
////
|
||||||
|
//// const vector np = norm[0];
|
||||||
|
////
|
||||||
|
//// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||||
|
////
|
||||||
|
//// return (Rp);
|
||||||
|
//
|
||||||
|
//// Info<< "Point : " << pt << endl;
|
||||||
|
//// forAll(ptNormals, pnI)
|
||||||
|
//// {
|
||||||
|
//// Info<< " normal " << pnI << " : " << ptNormals[pnI] << endl;
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// vector np = ptNormals[0];
|
||||||
|
//
|
||||||
|
// const tensor Rp = rotationTensor(vector(0,0,1), np);
|
||||||
|
//
|
||||||
|
// vector na = vector::zero;
|
||||||
|
//
|
||||||
|
// scalar smallestAngle = GREAT;
|
||||||
|
//
|
||||||
|
// for (label pnI = 1; pnI < ptNormals.size(); ++pnI)
|
||||||
|
// {
|
||||||
|
// const vector& nextNormal = ptNormals[pnI];
|
||||||
|
//
|
||||||
|
// const scalar cosPhi = vectorTools::cosPhi(np, nextNormal);
|
||||||
|
//
|
||||||
|
// if (mag(cosPhi) < smallestAngle)
|
||||||
|
// {
|
||||||
|
// na = nextNormal;
|
||||||
|
// smallestAngle = cosPhi;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// // Secondary alignment
|
||||||
|
// vector ns = np ^ na;
|
||||||
|
//
|
||||||
|
// if (mag(ns) < SMALL)
|
||||||
|
// {
|
||||||
|
// WarningIn("conformalVoronoiMesh::requiredAlignment")
|
||||||
|
// << "Parallel normals detected in spoke search." << nl
|
||||||
|
// << "point: " << pt << nl
|
||||||
|
// << "np : " << np << nl
|
||||||
|
// << "na : " << na << nl
|
||||||
|
// << "ns : " << ns << nl
|
||||||
|
// << endl;
|
||||||
|
//
|
||||||
|
// ns = np;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// ns /= mag(ns);
|
||||||
|
//
|
||||||
|
// tensor Rs = rotationTensor((Rp & vector(0,1,0)), ns);
|
||||||
|
//
|
||||||
|
//// Info<< "Point " << pt << nl
|
||||||
|
//// << " np : " << np << nl
|
||||||
|
//// << " ns : " << ns << nl
|
||||||
|
//// << " Rp : " << Rp << nl
|
||||||
|
//// << " Rs : " << Rs << nl
|
||||||
|
//// << " Rs&Rp: " << (Rs & Rp) << endl;
|
||||||
|
//
|
||||||
|
// return (Rs & Rp);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::searchableSurfaceControl::searchableSurfaceControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeAndAlignmentControl
|
||||||
|
(
|
||||||
|
runTime,
|
||||||
|
name,
|
||||||
|
controlFunctionDict,
|
||||||
|
geometryToConformTo,
|
||||||
|
defaultCellSize
|
||||||
|
),
|
||||||
|
surfaceName_(controlFunctionDict.lookupOrDefault<word>("surface", name)),
|
||||||
|
searchableSurface_(geometryToConformTo.geometry()[surfaceName_]),
|
||||||
|
geometryToConformTo_(geometryToConformTo),
|
||||||
|
cellSizeFunctions_(1),
|
||||||
|
regionToCellSizeFunctions_(geometryToConformTo_.patchNames().size(), -1),
|
||||||
|
maxPriority_(-1)
|
||||||
|
{
|
||||||
|
Info<< indent << "Master settings:" << endl;
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
|
cellSizeFunctions_.set
|
||||||
|
(
|
||||||
|
0,
|
||||||
|
cellSizeFunction::New
|
||||||
|
(
|
||||||
|
controlFunctionDict,
|
||||||
|
searchableSurface_,
|
||||||
|
defaultCellSize_,
|
||||||
|
labelList()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
|
|
||||||
|
PtrList<cellSizeFunction> regionCellSizeFunctions;
|
||||||
|
|
||||||
|
DynamicList<label> defaultCellSizeRegions;
|
||||||
|
|
||||||
|
label nRegionCellSizeFunctions = 0;
|
||||||
|
|
||||||
|
// Loop over regions - if any entry is not specified they should
|
||||||
|
// inherit values from the parent surface.
|
||||||
|
if (controlFunctionDict.found("regions"))
|
||||||
|
{
|
||||||
|
const dictionary& regionsDict = controlFunctionDict.subDict("regions");
|
||||||
|
const wordList& regionNames = geometryToConformTo_.patchNames();
|
||||||
|
|
||||||
|
label nRegions = regionsDict.size();
|
||||||
|
|
||||||
|
regionCellSizeFunctions.setSize(nRegions + 1);
|
||||||
|
defaultCellSizeRegions.setCapacity(nRegions);
|
||||||
|
|
||||||
|
forAll(regionNames, regionI)
|
||||||
|
{
|
||||||
|
const word& regionName = regionNames[regionI];
|
||||||
|
|
||||||
|
label regionID = geometryToConformTo_.geometry().findSurfaceRegionID
|
||||||
|
(
|
||||||
|
this->name(),
|
||||||
|
regionName
|
||||||
|
);
|
||||||
|
|
||||||
|
if (regionsDict.found(regionName))
|
||||||
|
{
|
||||||
|
// Get the dictionary for region
|
||||||
|
const dictionary& regionDict = regionsDict.subDict(regionName);
|
||||||
|
|
||||||
|
Info<< indent << "Region " << regionName
|
||||||
|
<< " (ID = " << regionID << ")" << " settings:"
|
||||||
|
<< endl;
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
|
regionCellSizeFunctions.set
|
||||||
|
(
|
||||||
|
nRegionCellSizeFunctions,
|
||||||
|
cellSizeFunction::New
|
||||||
|
(
|
||||||
|
regionDict,
|
||||||
|
searchableSurface_,
|
||||||
|
defaultCellSize_,
|
||||||
|
labelList(1, regionID)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
Info<< decrIndent;
|
||||||
|
|
||||||
|
regionToCellSizeFunctions_[regionID] = nRegionCellSizeFunctions;
|
||||||
|
|
||||||
|
nRegionCellSizeFunctions++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Add to default list
|
||||||
|
defaultCellSizeRegions.append(regionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultCellSizeRegions.empty() && !regionCellSizeFunctions.empty())
|
||||||
|
{
|
||||||
|
cellSizeFunctions_.transfer(regionCellSizeFunctions);
|
||||||
|
}
|
||||||
|
else if (nRegionCellSizeFunctions > 0)
|
||||||
|
{
|
||||||
|
regionCellSizeFunctions.set
|
||||||
|
(
|
||||||
|
nRegionCellSizeFunctions,
|
||||||
|
cellSizeFunction::New
|
||||||
|
(
|
||||||
|
controlFunctionDict,
|
||||||
|
searchableSurface_,
|
||||||
|
defaultCellSize_,
|
||||||
|
labelList()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const wordList& regionNames = geometryToConformTo_.patchNames();
|
||||||
|
|
||||||
|
forAll(regionNames, regionI)
|
||||||
|
{
|
||||||
|
if (regionToCellSizeFunctions_[regionI] == -1)
|
||||||
|
{
|
||||||
|
regionToCellSizeFunctions_[regionI] = nRegionCellSizeFunctions;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cellSizeFunctions_.transfer(regionCellSizeFunctions);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const wordList& regionNames = geometryToConformTo_.patchNames();
|
||||||
|
|
||||||
|
forAll(regionNames, regionI)
|
||||||
|
{
|
||||||
|
if (regionToCellSizeFunctions_[regionI] == -1)
|
||||||
|
{
|
||||||
|
regionToCellSizeFunctions_[regionI] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
forAll(cellSizeFunctions_, funcI)
|
||||||
|
{
|
||||||
|
const label funcPriority = cellSizeFunctions_[funcI].priority();
|
||||||
|
|
||||||
|
if (funcPriority > maxPriority_)
|
||||||
|
{
|
||||||
|
maxPriority_ = funcPriority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sort controlFunctions_ by maxPriority
|
||||||
|
SortableList<label> functionPriorities(cellSizeFunctions_.size());
|
||||||
|
|
||||||
|
forAll(cellSizeFunctions_, funcI)
|
||||||
|
{
|
||||||
|
functionPriorities[funcI] = cellSizeFunctions_[funcI].priority();
|
||||||
|
}
|
||||||
|
|
||||||
|
functionPriorities.reverseSort();
|
||||||
|
|
||||||
|
labelList invertedFunctionPriorities =
|
||||||
|
invert(functionPriorities.size(), functionPriorities.indices());
|
||||||
|
|
||||||
|
cellSizeFunctions_.reorder(invertedFunctionPriorities);
|
||||||
|
|
||||||
|
Info<< nl << "There are " << cellSizeFunctions_.size()
|
||||||
|
<< " region control functions" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::searchableSurfaceControl::~searchableSurfaceControl()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::searchableSurfaceControl::initialVertices
|
||||||
|
(
|
||||||
|
pointField& pts,
|
||||||
|
scalarField& sizes,
|
||||||
|
triadField& alignments
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
pts = searchableSurface_.points();
|
||||||
|
sizes.setSize(pts.size());
|
||||||
|
alignments.setSize(pts.size());
|
||||||
|
|
||||||
|
const scalar nearFeatDistSqrCoeff = 1e-8;
|
||||||
|
|
||||||
|
forAll(pts, pI)
|
||||||
|
{
|
||||||
|
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||||
|
// point normal, otherwise get the surface normal from
|
||||||
|
// searchableSurface
|
||||||
|
|
||||||
|
pointIndexHit info;
|
||||||
|
label infoFeature;
|
||||||
|
geometryToConformTo_.findFeaturePointNearest
|
||||||
|
(
|
||||||
|
pts[pI],
|
||||||
|
nearFeatDistSqrCoeff,
|
||||||
|
info,
|
||||||
|
infoFeature
|
||||||
|
);
|
||||||
|
|
||||||
|
scalar limitedCellSize = GREAT;
|
||||||
|
|
||||||
|
autoPtr<triad> pointAlignment;
|
||||||
|
|
||||||
|
if (info.hit())
|
||||||
|
{
|
||||||
|
const extendedFeatureEdgeMesh& features =
|
||||||
|
geometryToConformTo_.features()[infoFeature];
|
||||||
|
|
||||||
|
vectorField norms = features.featurePointNormals(info.index());
|
||||||
|
|
||||||
|
// Create a triad from these norms.
|
||||||
|
pointAlignment.set(new triad());
|
||||||
|
forAll(norms, nI)
|
||||||
|
{
|
||||||
|
pointAlignment() += norms[nI];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointAlignment().normalize();
|
||||||
|
pointAlignment().orthogonalize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
geometryToConformTo_.findEdgeNearest
|
||||||
|
(
|
||||||
|
pts[pI],
|
||||||
|
nearFeatDistSqrCoeff,
|
||||||
|
info,
|
||||||
|
infoFeature
|
||||||
|
);
|
||||||
|
|
||||||
|
if (info.hit())
|
||||||
|
{
|
||||||
|
const extendedFeatureEdgeMesh& features =
|
||||||
|
geometryToConformTo_.features()[infoFeature];
|
||||||
|
|
||||||
|
vectorField norms = features.edgeNormals(info.index());
|
||||||
|
|
||||||
|
// Create a triad from these norms.
|
||||||
|
pointAlignment.set(new triad());
|
||||||
|
forAll(norms, nI)
|
||||||
|
{
|
||||||
|
pointAlignment() += norms[nI];
|
||||||
|
}
|
||||||
|
|
||||||
|
pointAlignment().normalize();
|
||||||
|
pointAlignment().orthogonalize();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pointField ptField(1, pts[pI]);
|
||||||
|
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||||
|
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||||
|
|
||||||
|
searchableSurface_.findNearest(ptField, distField, infoList);
|
||||||
|
|
||||||
|
vectorField normals(1);
|
||||||
|
searchableSurface_.getNormal(infoList, normals);
|
||||||
|
|
||||||
|
pointAlignment.set(new triad(normals[0]));
|
||||||
|
|
||||||
|
// Limit cell size
|
||||||
|
const vector vN =
|
||||||
|
infoList[0].hitPoint()
|
||||||
|
- 2.0*normals[0]*defaultCellSize_;
|
||||||
|
|
||||||
|
List<pointIndexHit> intersectionList;
|
||||||
|
searchableSurface_.findLineAny
|
||||||
|
(
|
||||||
|
ptField,
|
||||||
|
pointField(1, vN),
|
||||||
|
intersectionList
|
||||||
|
);
|
||||||
|
|
||||||
|
if (intersectionList[0].hit())
|
||||||
|
{
|
||||||
|
scalar dist = mag(intersectionList[0].hitPoint() - pts[pI]);
|
||||||
|
|
||||||
|
//limitedCellSize = dist/2.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label priority = -1;
|
||||||
|
if (!cellSize(pts[pI], sizes[pI], priority))
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"Foam::searchableSurfaceControl::initialVertices"
|
||||||
|
"(pointField&, scalarField&, tensorField&)"
|
||||||
|
) << "Could not calculate cell size"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
sizes[pI] = min(limitedCellSize, sizes[pI]);
|
||||||
|
|
||||||
|
alignments[pI] = pointAlignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::searchableSurfaceControl::cellSizeFunctionVertices
|
||||||
|
(
|
||||||
|
DynamicList<Foam::point>& pts,
|
||||||
|
DynamicList<scalar>& sizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const tmp<pointField> tmpPoints = searchableSurface_.points();
|
||||||
|
const pointField& points = tmpPoints();
|
||||||
|
|
||||||
|
const scalar nearFeatDistSqrCoeff = 1e-8;
|
||||||
|
|
||||||
|
forAll(points, pI)
|
||||||
|
{
|
||||||
|
// Is the point in the extendedFeatureEdgeMesh? If so get the
|
||||||
|
// point normal, otherwise get the surface normal from
|
||||||
|
// searchableSurface
|
||||||
|
|
||||||
|
pointField ptField(1, points[pI]);
|
||||||
|
scalarField distField(1, nearFeatDistSqrCoeff);
|
||||||
|
List<pointIndexHit> infoList(1, pointIndexHit());
|
||||||
|
|
||||||
|
searchableSurface_.findNearest(ptField, distField, infoList);
|
||||||
|
|
||||||
|
if (infoList[0].hit())
|
||||||
|
{
|
||||||
|
vectorField normals(1);
|
||||||
|
searchableSurface_.getNormal(infoList, normals);
|
||||||
|
|
||||||
|
labelList region(1, -1);
|
||||||
|
searchableSurface_.getRegion(infoList, region);
|
||||||
|
|
||||||
|
const cellSizeFunction& sizeFunc =
|
||||||
|
sizeFunctions()[regionToCellSizeFunctions_[region[0]]];
|
||||||
|
|
||||||
|
pointField extraPts;
|
||||||
|
scalarField extraSizes;
|
||||||
|
sizeFunc.sizeLocations
|
||||||
|
(
|
||||||
|
infoList[0],
|
||||||
|
normals[0],
|
||||||
|
extraPts,
|
||||||
|
extraSizes
|
||||||
|
);
|
||||||
|
|
||||||
|
pts.append(extraPts);
|
||||||
|
sizes.append(extraSizes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::searchableSurfaceControl::cellSize
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
scalar& cellSize,
|
||||||
|
label& priority
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
bool anyFunctionFound = false;
|
||||||
|
|
||||||
|
forAll(sizeFunctions(), funcI)
|
||||||
|
{
|
||||||
|
const cellSizeFunction& sizeFunc = sizeFunctions()[funcI];
|
||||||
|
|
||||||
|
if (sizeFunc.priority() < priority)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
scalar sizeI = -1;
|
||||||
|
|
||||||
|
if (sizeFunc.cellSize(pt, sizeI))
|
||||||
|
{
|
||||||
|
anyFunctionFound = true;
|
||||||
|
|
||||||
|
if (sizeFunc.priority() == priority)
|
||||||
|
{
|
||||||
|
if (sizeI < cellSize)
|
||||||
|
{
|
||||||
|
cellSize = sizeI;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellSize = sizeI;
|
||||||
|
|
||||||
|
priority = sizeFunc.priority();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " sizeI " << sizeI
|
||||||
|
<<" minSize " << cellSize << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyFunctionFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,191 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::searchableSurfaceControl
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
searchableSurfaceControl.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef searchableSurfaceControl_H
|
||||||
|
#define searchableSurfaceControl_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
#include "triad.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class surfaceControl Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class searchableSurfaceControl
|
||||||
|
:
|
||||||
|
public cellSizeAndAlignmentControl
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Name of the surface
|
||||||
|
const word surfaceName_;
|
||||||
|
|
||||||
|
//- Reference to the searchableSurface object holding the geometry data
|
||||||
|
const searchableSurface& searchableSurface_;
|
||||||
|
|
||||||
|
const conformationSurfaces& geometryToConformTo_;
|
||||||
|
|
||||||
|
PtrList<cellSizeFunction> cellSizeFunctions_;
|
||||||
|
|
||||||
|
labelList regionToCellSizeFunctions_;
|
||||||
|
|
||||||
|
label maxPriority_;
|
||||||
|
|
||||||
|
|
||||||
|
// const conformationSurfaces& geometryToConformTo_;
|
||||||
|
//
|
||||||
|
// //- Indices of surfaces in allGeometry that are to be conformed to
|
||||||
|
// labelList surfaces_;
|
||||||
|
//
|
||||||
|
// //- A list of all of the cellSizeFunction objects
|
||||||
|
// PtrList<cellSizeFunction> cellSizeFunctions_;
|
||||||
|
//
|
||||||
|
// autoPtr<triangulatedMesh> triangulatedMesh_;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // Private Member Functions
|
||||||
|
//
|
||||||
|
// //-
|
||||||
|
// tensor requiredAlignment
|
||||||
|
// (
|
||||||
|
// const point& pt,
|
||||||
|
// const vectorField& ptNormals
|
||||||
|
// ) const;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
searchableSurfaceControl(const searchableSurfaceControl&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const searchableSurfaceControl&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("searchableSurfaceControl");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from dictionary and references to conformalVoronoiMesh and
|
||||||
|
// searchableSurfaces
|
||||||
|
searchableSurfaceControl
|
||||||
|
(
|
||||||
|
const Time& runTime,
|
||||||
|
const word& name,
|
||||||
|
const dictionary& controlFunctionDict,
|
||||||
|
const conformationSurfaces& geometryToConformTo,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~searchableSurfaceControl();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Access
|
||||||
|
|
||||||
|
// //- Return reference to the searchableSurfaces object containing
|
||||||
|
// // all of the geometry
|
||||||
|
// inline const searchableSurfaces& geometry() const;
|
||||||
|
//
|
||||||
|
// //- Return the surface indices
|
||||||
|
// inline const labelList& surfaces() const;
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// // Query
|
||||||
|
//
|
||||||
|
// //- Return the cell size at the given location
|
||||||
|
// virtual scalar cellSize(const point& pt) const;
|
||||||
|
//
|
||||||
|
// //- Return the cell alignment at the given location
|
||||||
|
// virtual tensor cellAlignment(const point& pt) const;
|
||||||
|
//
|
||||||
|
// virtual void cellSizeAndAlignment
|
||||||
|
// (
|
||||||
|
// const point& pt,
|
||||||
|
// scalar& size,
|
||||||
|
// tensor& alignment
|
||||||
|
// ) const;
|
||||||
|
|
||||||
|
virtual void cellSizeFunctionVertices
|
||||||
|
(
|
||||||
|
DynamicList<Foam::point>& pts,
|
||||||
|
DynamicList<scalar>& sizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
virtual void initialVertices
|
||||||
|
(
|
||||||
|
pointField& pts,
|
||||||
|
scalarField& sizes,
|
||||||
|
triadField& alignments
|
||||||
|
) const;
|
||||||
|
|
||||||
|
const PtrList<cellSizeFunction>& sizeFunctions() const
|
||||||
|
{
|
||||||
|
return cellSizeFunctions_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual label maxPriority() const
|
||||||
|
{
|
||||||
|
return maxPriority_;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool cellSize
|
||||||
|
(
|
||||||
|
const Foam::point& pt,
|
||||||
|
scalar& cellSize,
|
||||||
|
label& priority
|
||||||
|
) const;
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,788 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "controlMeshRefinement.H"
|
||||||
|
#include "cellSizeAndAlignmentControl.H"
|
||||||
|
#include "OFstream.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(controlMeshRefinement, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::controlMeshRefinement::calcFirstDerivative
|
||||||
|
(
|
||||||
|
const Foam::point& a,
|
||||||
|
const scalar& cellSizeA,
|
||||||
|
const Foam::point& b,
|
||||||
|
const scalar& cellSizeB
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return (cellSizeA - cellSizeB)/mag(a - b);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Foam::scalar Foam::controlMeshRefinement::calcSecondDerivative
|
||||||
|
//(
|
||||||
|
// const Foam::point& a,
|
||||||
|
// const scalar& cellSizeA,
|
||||||
|
// const Foam::point& midPoint,
|
||||||
|
// const scalar& cellSizeMid,
|
||||||
|
// const Foam::point& b,
|
||||||
|
// const scalar& cellSizeB
|
||||||
|
//) const
|
||||||
|
//{
|
||||||
|
// return (cellSizeA - 2*cellSizeMid + cellSizeB)/magSqr((a - b)/2);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::controlMeshRefinement::detectEdge
|
||||||
|
(
|
||||||
|
const Foam::point& startPt,
|
||||||
|
const Foam::point& endPt,
|
||||||
|
pointHit& pointFound,
|
||||||
|
const scalar tolSqr,
|
||||||
|
const scalar secondDerivTolSqr
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
Foam::point a(startPt);
|
||||||
|
Foam::point b(endPt);
|
||||||
|
|
||||||
|
Foam::point midPoint = (a + b)/2.0;
|
||||||
|
|
||||||
|
label nIterations = 0;
|
||||||
|
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
nIterations++;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
magSqr(a - b) < tolSqr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointFound.setPoint(midPoint);
|
||||||
|
pointFound.setHit();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split into two regions
|
||||||
|
|
||||||
|
scalar cellSizeA = sizeControls_.cellSize(a);
|
||||||
|
scalar cellSizeB = sizeControls_.cellSize(b);
|
||||||
|
|
||||||
|
// if (magSqr(cellSizeA - cellSizeB) < 1e-6)
|
||||||
|
// {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
|
||||||
|
scalar cellSizeMid = sizeControls_.cellSize(midPoint);
|
||||||
|
|
||||||
|
// Region 1
|
||||||
|
Foam::point midPoint1 = (a + midPoint)/2.0;
|
||||||
|
const scalar cellSizeMid1 = sizeControls_.cellSize(midPoint1);
|
||||||
|
|
||||||
|
// scalar firstDerivative1 =
|
||||||
|
// calcFirstDerivative(cellSizeA, cellSizeMid);
|
||||||
|
|
||||||
|
scalar secondDerivative1 =
|
||||||
|
calcSecondDerivative
|
||||||
|
(
|
||||||
|
a,
|
||||||
|
cellSizeA,
|
||||||
|
midPoint1,
|
||||||
|
cellSizeMid1,
|
||||||
|
midPoint,
|
||||||
|
cellSizeMid
|
||||||
|
);
|
||||||
|
|
||||||
|
// Region 2
|
||||||
|
Foam::point midPoint2 = (midPoint + b)/2.0;
|
||||||
|
const scalar cellSizeMid2 = sizeControls_.cellSize(midPoint2);
|
||||||
|
|
||||||
|
// scalar firstDerivative2 =
|
||||||
|
// calcFirstDerivative(f, cellSizeMid, cellSizeB);
|
||||||
|
|
||||||
|
scalar secondDerivative2 =
|
||||||
|
calcSecondDerivative
|
||||||
|
(
|
||||||
|
midPoint,
|
||||||
|
cellSizeMid,
|
||||||
|
midPoint2,
|
||||||
|
cellSizeMid2,
|
||||||
|
b,
|
||||||
|
cellSizeB
|
||||||
|
);
|
||||||
|
|
||||||
|
// Neither region appears to have an inflection
|
||||||
|
// To be sure should use higher order derivatives
|
||||||
|
if
|
||||||
|
(
|
||||||
|
magSqr(secondDerivative1) < secondDerivTolSqr
|
||||||
|
&& magSqr(secondDerivative2) < secondDerivTolSqr
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pick region with greatest second derivative
|
||||||
|
if (magSqr(secondDerivative1) > magSqr(secondDerivative2))
|
||||||
|
{
|
||||||
|
b = midPoint;
|
||||||
|
midPoint = midPoint1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
a = midPoint;
|
||||||
|
midPoint = midPoint2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::pointHit Foam::controlMeshRefinement::findDiscontinuities
|
||||||
|
(
|
||||||
|
const linePointRef& l
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
pointHit p(point::max);
|
||||||
|
|
||||||
|
const scalar tolSqr = sqr(1e-3);
|
||||||
|
const scalar secondDerivTolSqr = sqr(1e-3);
|
||||||
|
|
||||||
|
detectEdge
|
||||||
|
(
|
||||||
|
l.start(),
|
||||||
|
l.end(),
|
||||||
|
p,
|
||||||
|
tolSqr,
|
||||||
|
secondDerivTolSqr
|
||||||
|
);
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::controlMeshRefinement::controlMeshRefinement
|
||||||
|
(
|
||||||
|
cellShapeControl& shapeController
|
||||||
|
)
|
||||||
|
:
|
||||||
|
shapeController_(shapeController),
|
||||||
|
mesh_(shapeController.shapeControlMesh()),
|
||||||
|
sizeControls_(shapeController.sizeAndAlignment()),
|
||||||
|
geometryToConformTo_(sizeControls_.geometryToConformTo())
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::controlMeshRefinement::~controlMeshRefinement()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::controlMeshRefinement::initialMeshPopulation
|
||||||
|
(
|
||||||
|
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||||
|
)
|
||||||
|
{
|
||||||
|
autoPtr<boundBox> overallBoundBox;
|
||||||
|
|
||||||
|
// Need to pass in the background mesh decomposition so that can test if
|
||||||
|
// a point to insert is on the processor.
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
// overallBoundBox.set(new boundBox(decomposition().procBounds()));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// overallBoundBox.set
|
||||||
|
// (
|
||||||
|
// new boundBox(geometryToConformTo_.geometry().bounds())
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// mesh_.insertBoundingPoints
|
||||||
|
// (
|
||||||
|
// overallBoundBox(),
|
||||||
|
// sizeControls_
|
||||||
|
// );
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<label> priorityMap;
|
||||||
|
|
||||||
|
const PtrList<cellSizeAndAlignmentControl>& controlFunctions =
|
||||||
|
sizeControls_.controlFunctions();
|
||||||
|
|
||||||
|
forAll(controlFunctions, fI)
|
||||||
|
{
|
||||||
|
const cellSizeAndAlignmentControl& controlFunction =
|
||||||
|
controlFunctions[fI];
|
||||||
|
|
||||||
|
const Switch& forceInsertion =
|
||||||
|
controlFunction.forceInitialPointInsertion();
|
||||||
|
|
||||||
|
Info<< "Inserting points from " << controlFunction.name()
|
||||||
|
<< " (" << controlFunction.type() << ")" << endl;
|
||||||
|
Info<< " Force insertion is " << forceInsertion.asText() << endl;
|
||||||
|
|
||||||
|
pointField pts;
|
||||||
|
scalarField sizes;
|
||||||
|
triadField alignments;
|
||||||
|
|
||||||
|
controlFunction.initialVertices(pts, sizes, alignments);
|
||||||
|
|
||||||
|
Info<< " Got initial vertices list" << endl;
|
||||||
|
|
||||||
|
List<Vb> vertices(pts.size());
|
||||||
|
|
||||||
|
// Clip the minimum size
|
||||||
|
for (label vI = 0; vI < pts.size(); ++vI)
|
||||||
|
{
|
||||||
|
vertices[vI] = Vb(pts[vI], Vb::vtInternalNearBoundary);
|
||||||
|
|
||||||
|
// Info<< "Find size of vertex " << vI << endl;
|
||||||
|
|
||||||
|
label maxPriority = -1;
|
||||||
|
scalar size = sizeControls_.cellSize(pts[vI], maxPriority);
|
||||||
|
|
||||||
|
// Info<< " Size = " << size << ", priority = " << maxPriority
|
||||||
|
// << endl;
|
||||||
|
|
||||||
|
if (maxPriority > controlFunction.maxPriority())
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
size,
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (maxPriority == controlFunction.maxPriority())
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
min(sizes[vI], size),
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
sizes[vI],
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
vertices[vI].alignment() = alignments[vI];
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< " Clipped minimum size" << endl;
|
||||||
|
|
||||||
|
pts.clear();
|
||||||
|
sizes.clear();
|
||||||
|
alignments.clear();
|
||||||
|
|
||||||
|
label nRejected = 0;
|
||||||
|
|
||||||
|
PackedBoolList keepVertex(vertices.size(), true);
|
||||||
|
|
||||||
|
forAll(vertices, vI)
|
||||||
|
{
|
||||||
|
bool keep = true;
|
||||||
|
|
||||||
|
pointFromPoint pt = topoint(vertices[vI].point());
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
keep = decomposition().positionOnThisProcessor(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keep && geometryToConformTo_.wellOutside(pt, SMALL))
|
||||||
|
{
|
||||||
|
keep = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keep)
|
||||||
|
{
|
||||||
|
keepVertex[vI] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inplaceSubset(keepVertex, vertices);
|
||||||
|
|
||||||
|
const label preInsertedSize = mesh_.number_of_vertices();
|
||||||
|
|
||||||
|
Info<< " Check sizes" << endl;
|
||||||
|
|
||||||
|
forAll(vertices, vI)
|
||||||
|
{
|
||||||
|
bool insertPoint = false;
|
||||||
|
|
||||||
|
pointFromPoint pt(topoint(vertices[vI].point()));
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
mesh_.dimension() < 3
|
||||||
|
|| mesh_.is_infinite
|
||||||
|
(
|
||||||
|
mesh_.locate(vertices[vI].point())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
insertPoint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scalar interpolatedCellSize = shapeController_.cellSize(pt);
|
||||||
|
const triad interpolatedAlignment =
|
||||||
|
shapeController_.cellAlignment(pt);
|
||||||
|
const scalar calculatedCellSize = vertices[vI].targetCellSize();
|
||||||
|
const triad calculatedAlignment = vertices[vI].alignment();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Point = " << pt << nl
|
||||||
|
<< " Size(interp) = " << interpolatedCellSize << nl
|
||||||
|
<< " Size(calc) = " << calculatedCellSize << nl
|
||||||
|
<< " Align(interp) = " << interpolatedAlignment << nl
|
||||||
|
<< " Align(calc) = " << calculatedAlignment << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scalar sizeDiff =
|
||||||
|
mag(interpolatedCellSize - calculatedCellSize);
|
||||||
|
const scalar alignmentDiff =
|
||||||
|
diff(interpolatedAlignment, calculatedAlignment);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " size difference = " << sizeDiff << nl
|
||||||
|
<< ", alignment difference = " << alignmentDiff << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Also need to base it on the alignments
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sizeDiff/interpolatedCellSize > 0.1
|
||||||
|
|| alignmentDiff > 0.15
|
||||||
|
)
|
||||||
|
{
|
||||||
|
insertPoint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceInsertion || insertPoint)
|
||||||
|
{
|
||||||
|
const label oldSize = mesh_.vertexCount();
|
||||||
|
|
||||||
|
cellShapeControlMesh::Vertex_handle insertedVert = mesh_.insert
|
||||||
|
(
|
||||||
|
pt,
|
||||||
|
calculatedCellSize,
|
||||||
|
vertices[vI].alignment(),
|
||||||
|
Vb::vtInternalNearBoundary
|
||||||
|
);
|
||||||
|
|
||||||
|
if (oldSize == mesh_.vertexCount() - 1)
|
||||||
|
{
|
||||||
|
priorityMap.insert
|
||||||
|
(
|
||||||
|
insertedVert->index(),
|
||||||
|
controlFunction.maxPriority()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//mesh_.rangeInsertWithInfo(vertices.begin(), vertices.end());
|
||||||
|
|
||||||
|
Info<< " Inserted "
|
||||||
|
<< returnReduce
|
||||||
|
(
|
||||||
|
label(mesh_.number_of_vertices()) - preInsertedSize,
|
||||||
|
sumOp<label>()
|
||||||
|
)
|
||||||
|
<< "/" << returnReduce(vertices.size(), sumOp<label>())
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
forAll(controlFunctions, fI)
|
||||||
|
{
|
||||||
|
const cellSizeAndAlignmentControl& controlFunction =
|
||||||
|
controlFunctions[fI];
|
||||||
|
|
||||||
|
const Switch& forceInsertion =
|
||||||
|
controlFunction.forceInitialPointInsertion();
|
||||||
|
|
||||||
|
Info<< "Inserting points from " << controlFunction.name()
|
||||||
|
<< " (" << controlFunction.type() << ")" << endl;
|
||||||
|
Info<< " Force insertion is " << forceInsertion.asText() << endl;
|
||||||
|
|
||||||
|
DynamicList<Foam::point> extraPts;
|
||||||
|
DynamicList<scalar> extraSizes;
|
||||||
|
|
||||||
|
controlFunction.cellSizeFunctionVertices(extraPts, extraSizes);
|
||||||
|
|
||||||
|
List<Vb> vertices(extraPts.size());
|
||||||
|
|
||||||
|
// Clip the minimum size
|
||||||
|
for (label vI = 0; vI < extraPts.size(); ++vI)
|
||||||
|
{
|
||||||
|
vertices[vI] = Vb(extraPts[vI], Vb::vtUnassigned);
|
||||||
|
|
||||||
|
label maxPriority = -1;
|
||||||
|
scalar size = sizeControls_.cellSize(extraPts[vI], maxPriority);
|
||||||
|
|
||||||
|
if (maxPriority > controlFunction.maxPriority())
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
size,
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (maxPriority == controlFunction.maxPriority())
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
min(extraSizes[vI], size),
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vertices[vI].targetCellSize() = max
|
||||||
|
(
|
||||||
|
extraSizes[vI],
|
||||||
|
shapeController_.minimumCellSize()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
label nRejected = 0;
|
||||||
|
|
||||||
|
PackedBoolList keepVertex(vertices.size(), true);
|
||||||
|
|
||||||
|
forAll(vertices, vI)
|
||||||
|
{
|
||||||
|
bool keep = true;
|
||||||
|
|
||||||
|
pointFromPoint pt = topoint(vertices[vI].point());
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
keep = decomposition().positionOnThisProcessor(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keep && geometryToConformTo_.wellOutside(pt, SMALL))
|
||||||
|
{
|
||||||
|
keep = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keep)
|
||||||
|
{
|
||||||
|
keepVertex[vI] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inplaceSubset(keepVertex, vertices);
|
||||||
|
|
||||||
|
const label preInsertedSize = mesh_.number_of_vertices();
|
||||||
|
|
||||||
|
forAll(vertices, vI)
|
||||||
|
{
|
||||||
|
bool insertPoint = false;
|
||||||
|
|
||||||
|
pointFromPoint pt(topoint(vertices[vI].point()));
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
mesh_.dimension() < 3
|
||||||
|
|| mesh_.is_infinite
|
||||||
|
(
|
||||||
|
mesh_.locate(vertices[vI].point())
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
insertPoint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scalar interpolatedCellSize = shapeController_.cellSize(pt);
|
||||||
|
const scalar calculatedCellSize = vertices[vI].targetCellSize();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< "Point = " << pt << nl
|
||||||
|
<< " Size(interp) = " << interpolatedCellSize << nl
|
||||||
|
<< " Size(calc) = " << calculatedCellSize << nl
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
const scalar sizeDiff =
|
||||||
|
mag(interpolatedCellSize - calculatedCellSize);
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< " size difference = " << sizeDiff << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// @todo Also need to base it on the alignments
|
||||||
|
if (sizeDiff/interpolatedCellSize > 0.1)
|
||||||
|
{
|
||||||
|
insertPoint = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (forceInsertion || insertPoint)
|
||||||
|
{
|
||||||
|
// Check the priority
|
||||||
|
|
||||||
|
// cellShapeControlMesh::Cell_handle ch =
|
||||||
|
// mesh_.locate(toPoint<cellShapeControlMesh::Point>(pt));
|
||||||
|
|
||||||
|
// if (mesh_.is_infinite(ch))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const label newPtPriority = controlFunction.maxPriority();
|
||||||
|
|
||||||
|
// label highestPriority = -1;
|
||||||
|
// for (label cI = 0; cI < 4; ++cI)
|
||||||
|
// {
|
||||||
|
// if (mesh_.is_infinite(ch->vertex(cI)))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// const label vertPriority =
|
||||||
|
// priorityMap[ch->vertex(cI)->index()];
|
||||||
|
|
||||||
|
// if (vertPriority > highestPriority)
|
||||||
|
// {
|
||||||
|
// highestPriority = vertPriority;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (newPtPriority >= highestPriority)
|
||||||
|
// {
|
||||||
|
const label oldSize = mesh_.vertexCount();
|
||||||
|
|
||||||
|
cellShapeControlMesh::Vertex_handle insertedVert =
|
||||||
|
mesh_.insert
|
||||||
|
(
|
||||||
|
pt,
|
||||||
|
calculatedCellSize,
|
||||||
|
vertices[vI].alignment(),
|
||||||
|
Vb::vtInternal
|
||||||
|
);
|
||||||
|
|
||||||
|
// if (oldSize == mesh_.vertexCount() - 1)
|
||||||
|
// {
|
||||||
|
// priorityMap.insert
|
||||||
|
// (
|
||||||
|
// insertedVert->index(),
|
||||||
|
// newPtPriority
|
||||||
|
// );
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//mesh_.rangeInsertWithInfo(vertices.begin(), vertices.end());
|
||||||
|
|
||||||
|
Info<< " Inserted extra points "
|
||||||
|
<< returnReduce
|
||||||
|
(
|
||||||
|
label(mesh_.number_of_vertices()) - preInsertedSize,
|
||||||
|
sumOp<label>()
|
||||||
|
)
|
||||||
|
<< "/" << returnReduce(vertices.size(), sumOp<label>())
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Change cell size function of bounding points to be consistent
|
||||||
|
// with their nearest neighbours
|
||||||
|
// for
|
||||||
|
// (
|
||||||
|
// CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
// mesh_.finite_vertices_begin();
|
||||||
|
// vit != mesh_.finite_vertices_end();
|
||||||
|
// ++vit
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// if (vit->uninitialised())
|
||||||
|
// {
|
||||||
|
// // Get its adjacent vertices
|
||||||
|
// std::list<CellSizeDelaunay::Vertex_handle> adjacentVertices;
|
||||||
|
//
|
||||||
|
// mesh_.adjacent_vertices
|
||||||
|
// (
|
||||||
|
// vit,
|
||||||
|
// std::back_inserter(adjacentVertices)
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// scalar totalCellSize = 0;
|
||||||
|
// label nVerts = 0;
|
||||||
|
//
|
||||||
|
// for
|
||||||
|
// (
|
||||||
|
// std::list<CellSizeDelaunay::Vertex_handle>::iterator avit =
|
||||||
|
// adjacentVertices.begin();
|
||||||
|
// avit != adjacentVertices.end();
|
||||||
|
// ++avit
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// if (!(*avit)->uninitialised())
|
||||||
|
// {
|
||||||
|
// totalCellSize += (*avit)->targetCellSize();
|
||||||
|
// nVerts++;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Pout<< "Changing " << vit->info();
|
||||||
|
//
|
||||||
|
// vit->targetCellSize() = totalCellSize/nVerts;
|
||||||
|
// vit->type() = Vb::vtInternalNearBoundary;
|
||||||
|
//
|
||||||
|
// Pout<< "to " << vit->info() << endl;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::label Foam::controlMeshRefinement::refineMesh
|
||||||
|
(
|
||||||
|
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< "Iterate over "
|
||||||
|
<< returnReduce(label(mesh_.number_of_finite_edges()), sumOp<label>())
|
||||||
|
<< " cell size mesh edges" << endl;
|
||||||
|
|
||||||
|
DynamicList<Vb> verts(mesh_.number_of_vertices());
|
||||||
|
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_edges_iterator eit =
|
||||||
|
mesh_.finite_edges_begin();
|
||||||
|
eit != mesh_.finite_edges_end();
|
||||||
|
++eit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (count % 10000 == 0)
|
||||||
|
{
|
||||||
|
Info<< count << " edges, inserted " << verts.size()
|
||||||
|
<< " Time = " << mesh_.time().elapsedCpuTime()
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
|
||||||
|
CellSizeDelaunay::Cell_handle c = eit->first;
|
||||||
|
CellSizeDelaunay::Vertex_handle vA = c->vertex(eit->second);
|
||||||
|
CellSizeDelaunay::Vertex_handle vB = c->vertex(eit->third);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
mesh_.is_infinite(vA)
|
||||||
|
|| mesh_.is_infinite(vB)
|
||||||
|
|| (vA->referred() && vB->referred())
|
||||||
|
|| (vA->referred() && (vA->procIndex() > vB->procIndex()))
|
||||||
|
|| (vB->referred() && (vB->procIndex() > vA->procIndex()))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointFromPoint ptA(topoint(vA->point()));
|
||||||
|
pointFromPoint ptB(topoint(vB->point()));
|
||||||
|
|
||||||
|
linePointRef l(ptA, ptB);
|
||||||
|
|
||||||
|
const pointHit hitPt = findDiscontinuities(l);
|
||||||
|
|
||||||
|
if (hitPt.hit())
|
||||||
|
{
|
||||||
|
const Foam::point& pt = hitPt.hitPoint();
|
||||||
|
|
||||||
|
if (!geometryToConformTo_.inside(pt))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
if (!decomposition().positionOnThisProcessor(pt))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
verts.append
|
||||||
|
(
|
||||||
|
Vb
|
||||||
|
(
|
||||||
|
toPoint<cellShapeControlMesh::Point>(pt),
|
||||||
|
Vb::vtInternal
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
verts.last().targetCellSize() = sizeControls_.cellSize(pt);
|
||||||
|
verts.last().alignment() = triad::unset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mesh_.insertPoints(verts);
|
||||||
|
|
||||||
|
return verts.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,149 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::controlMeshRefinement
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
controlMeshRefinementI.H
|
||||||
|
controlMeshRefinement.C
|
||||||
|
controlMeshRefinementIO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef controlMeshRefinement_H
|
||||||
|
#define controlMeshRefinement_H
|
||||||
|
|
||||||
|
#include "cellShapeControl.H"
|
||||||
|
#include "cellShapeControlMesh.H"
|
||||||
|
#include "cellSizeAndAlignmentControls.H"
|
||||||
|
#include "conformationSurfaces.H"
|
||||||
|
#include "backgroundMeshDecomposition.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class controlMeshRefinement Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class controlMeshRefinement
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const cellShapeControl& shapeController_;
|
||||||
|
|
||||||
|
cellShapeControlMesh& mesh_;
|
||||||
|
|
||||||
|
const cellSizeAndAlignmentControls& sizeControls_;
|
||||||
|
|
||||||
|
const conformationSurfaces& geometryToConformTo_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
scalar calcFirstDerivative
|
||||||
|
(
|
||||||
|
const Foam::point& a,
|
||||||
|
const scalar& cellSizeA,
|
||||||
|
const Foam::point& b,
|
||||||
|
const scalar& cellSizeB
|
||||||
|
) const;
|
||||||
|
|
||||||
|
scalar calcSecondDerivative
|
||||||
|
(
|
||||||
|
const Foam::point& a,
|
||||||
|
const scalar& cellSizeA,
|
||||||
|
const Foam::point& midPoint,
|
||||||
|
const scalar& cellSizeMid,
|
||||||
|
const Foam::point& b,
|
||||||
|
const scalar& cellSizeB
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return (cellSizeA - 2*cellSizeMid + cellSizeB)/magSqr((a - b)/2);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool detectEdge
|
||||||
|
(
|
||||||
|
const Foam::point& startPt,
|
||||||
|
const Foam::point& endPt,
|
||||||
|
pointHit& pointFound,
|
||||||
|
const scalar tolSqr,
|
||||||
|
const scalar secondDerivTolSqr
|
||||||
|
) const;
|
||||||
|
|
||||||
|
pointHit findDiscontinuities(const linePointRef& l) const;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
controlMeshRefinement(const controlMeshRefinement&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const controlMeshRefinement&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
ClassName("controlMeshRefinement");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
controlMeshRefinement(cellShapeControl& shapeController);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~controlMeshRefinement();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
void initialMeshPopulation
|
||||||
|
(
|
||||||
|
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||||
|
);
|
||||||
|
|
||||||
|
label refineMesh
|
||||||
|
(
|
||||||
|
const autoPtr<backgroundMeshDecomposition>& decomposition
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,480 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "smoothAlignmentSolver.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Triangulation, class Type>
|
||||||
|
Foam::tmp<Foam::Field<Type> > Foam::smoothAlignmentSolver::filterFarPoints
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
const Field<Type>& field
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmp<Field<Type> > tNewField(new Field<Type>(field.size()));
|
||||||
|
Field<Type>& newField = tNewField();
|
||||||
|
|
||||||
|
label added = 0;
|
||||||
|
label count = 0;
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
newField[added++] = field[count];
|
||||||
|
}
|
||||||
|
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
newField.resize(added);
|
||||||
|
|
||||||
|
return tNewField;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::autoPtr<Foam::mapDistribute> Foam::smoothAlignmentSolver::buildReferredMap
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
labelList& indices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
globalIndex globalIndexing(mesh.vertexCount());
|
||||||
|
|
||||||
|
DynamicList<label> dynIndices(mesh.vertexCount()/10);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
dynIndices.append
|
||||||
|
(
|
||||||
|
globalIndexing.toGlobal(vit->procIndex(), vit->index())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
indices.transfer(dynIndices);
|
||||||
|
|
||||||
|
List<Map<label> > compactMap;
|
||||||
|
return autoPtr<mapDistribute>
|
||||||
|
(
|
||||||
|
new mapDistribute
|
||||||
|
(
|
||||||
|
globalIndexing,
|
||||||
|
indices,
|
||||||
|
compactMap
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::autoPtr<Foam::mapDistribute> Foam::smoothAlignmentSolver::buildMap
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
labelListList& pointPoints
|
||||||
|
)
|
||||||
|
{
|
||||||
|
pointPoints.setSize(mesh.vertexCount());
|
||||||
|
|
||||||
|
globalIndex globalIndexing(mesh.vertexCount());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::list<typename Triangulation::Vertex_handle> adjVerts;
|
||||||
|
mesh.finite_adjacent_vertices(vit, std::back_inserter(adjVerts));
|
||||||
|
|
||||||
|
DynamicList<label> indices(adjVerts.size());
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename std::list<typename Triangulation::Vertex_handle>::
|
||||||
|
const_iterator adjVertI = adjVerts.begin();
|
||||||
|
adjVertI != adjVerts.end();
|
||||||
|
++adjVertI
|
||||||
|
)
|
||||||
|
{
|
||||||
|
typename Triangulation::Vertex_handle vh = *adjVertI;
|
||||||
|
|
||||||
|
if (!vh->farPoint())
|
||||||
|
{
|
||||||
|
indices.append
|
||||||
|
(
|
||||||
|
globalIndexing.toGlobal(vh->procIndex(), vh->index())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pointPoints[vit->index()].transfer(indices);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Map<label> > compactMap;
|
||||||
|
return autoPtr<mapDistribute>
|
||||||
|
(
|
||||||
|
new mapDistribute
|
||||||
|
(
|
||||||
|
globalIndexing,
|
||||||
|
pointPoints,
|
||||||
|
compactMap
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::tmp<Foam::triadField> Foam::smoothAlignmentSolver::buildAlignmentField
|
||||||
|
(
|
||||||
|
const Triangulation& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmp<triadField> tAlignments
|
||||||
|
(
|
||||||
|
new triadField(mesh.vertexCount(), triad::unset)
|
||||||
|
);
|
||||||
|
triadField& alignments = tAlignments();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
alignments[vit->index()] = vit->alignment();
|
||||||
|
}
|
||||||
|
|
||||||
|
return tAlignments;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
Foam::tmp<Foam::pointField> Foam::smoothAlignmentSolver::buildPointField
|
||||||
|
(
|
||||||
|
const Triangulation& mesh
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmp<pointField> tPoints
|
||||||
|
(
|
||||||
|
new pointField(mesh.vertexCount(), point(GREAT, GREAT, GREAT))
|
||||||
|
);
|
||||||
|
pointField& points = tPoints();
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
typename Triangulation::Finite_vertices_iterator vit =
|
||||||
|
mesh.finite_vertices_begin();
|
||||||
|
vit != mesh.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!vit->real())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
points[vit->index()] = topoint(vit->point());
|
||||||
|
}
|
||||||
|
|
||||||
|
return tPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::smoothAlignmentSolver::applyBoundaryConditions
|
||||||
|
(
|
||||||
|
const triad& fixedAlignment,
|
||||||
|
triad& t
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
label nFixed = 0;
|
||||||
|
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
nFixed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nFixed == 1)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
t.align(fixedAlignment[dirI]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (nFixed == 2)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
t[dirI] = fixedAlignment[dirI];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
t[dirI] = triad::unset[dirI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
t.orthogonalize();
|
||||||
|
}
|
||||||
|
else if (nFixed == 3)
|
||||||
|
{
|
||||||
|
forAll(fixedAlignment, dirI)
|
||||||
|
{
|
||||||
|
if (fixedAlignment.set(dirI))
|
||||||
|
{
|
||||||
|
t[dirI] = fixedAlignment[dirI];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::smoothAlignmentSolver::smoothAlignmentSolver(cellShapeControlMesh& mesh)
|
||||||
|
:
|
||||||
|
mesh_(mesh)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::smoothAlignmentSolver::~smoothAlignmentSolver()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::smoothAlignmentSolver::smoothAlignments
|
||||||
|
(
|
||||||
|
const label maxSmoothingIterations
|
||||||
|
)
|
||||||
|
{
|
||||||
|
scalar minResidual = 0;
|
||||||
|
|
||||||
|
labelListList pointPoints;
|
||||||
|
autoPtr<mapDistribute> meshDistributor = buildMap
|
||||||
|
(
|
||||||
|
mesh_,
|
||||||
|
pointPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
triadField alignments(buildAlignmentField(mesh_));
|
||||||
|
pointField points(buildPointField(mesh_));
|
||||||
|
|
||||||
|
// Setup the sizes and alignments on each point
|
||||||
|
triadField fixedAlignments(mesh_.vertexCount(), triad::unset);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
mesh_.finite_vertices_begin();
|
||||||
|
vit != mesh_.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
fixedAlignments[vit->index()] = vit->alignment();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< nl << "Smoothing alignments" << endl;
|
||||||
|
|
||||||
|
|
||||||
|
for (label iter = 0; iter < maxSmoothingIterations; iter++)
|
||||||
|
{
|
||||||
|
Info<< "Iteration " << iter;
|
||||||
|
|
||||||
|
meshDistributor().distribute(points);
|
||||||
|
meshDistributor().distribute(fixedAlignments);
|
||||||
|
meshDistributor().distribute(alignments);
|
||||||
|
|
||||||
|
scalar residual = 0;
|
||||||
|
|
||||||
|
triadField triadAv(alignments.size(), triad::unset);
|
||||||
|
|
||||||
|
forAll(pointPoints, pI)
|
||||||
|
{
|
||||||
|
const labelList& pPoints = pointPoints[pI];
|
||||||
|
|
||||||
|
if (pPoints.empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
triad& newTriad = triadAv[pI];
|
||||||
|
|
||||||
|
forAll(pPoints, adjPointI)
|
||||||
|
{
|
||||||
|
const label adjPointIndex = pPoints[adjPointI];
|
||||||
|
|
||||||
|
scalar dist = mag(points[pI] - points[adjPointIndex]);
|
||||||
|
|
||||||
|
triad tmpTriad = alignments[adjPointIndex];
|
||||||
|
|
||||||
|
for (direction dir = 0; dir < 3; dir++)
|
||||||
|
{
|
||||||
|
if (tmpTriad.set(dir))
|
||||||
|
{
|
||||||
|
tmpTriad[dir] *= 1.0/(dist + SMALL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
newTriad += tmpTriad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the alignment field
|
||||||
|
forAll(alignments, pI)
|
||||||
|
{
|
||||||
|
const triad& oldTriad = alignments[pI];
|
||||||
|
triad& newTriad = triadAv[pI];
|
||||||
|
|
||||||
|
newTriad.normalize();
|
||||||
|
newTriad.orthogonalize();
|
||||||
|
|
||||||
|
// Enforce the boundary conditions
|
||||||
|
const triad& fixedAlignment = fixedAlignments[pI];
|
||||||
|
|
||||||
|
applyBoundaryConditions
|
||||||
|
(
|
||||||
|
fixedAlignment,
|
||||||
|
newTriad
|
||||||
|
);
|
||||||
|
|
||||||
|
newTriad = newTriad.sortxyz();
|
||||||
|
|
||||||
|
// Residual Calculation
|
||||||
|
for (direction dir = 0; dir < 3; ++dir)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
newTriad.set(dir)
|
||||||
|
&& oldTriad.set(dir)
|
||||||
|
&& !fixedAlignment.set(dir)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
residual += diff(oldTriad, newTriad);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
alignments[pI] = newTriad;
|
||||||
|
}
|
||||||
|
|
||||||
|
reduce(residual, sumOp<scalar>());
|
||||||
|
|
||||||
|
Info<< ", Residual = "
|
||||||
|
<< residual
|
||||||
|
/returnReduce(points.size(), sumOp<label>())
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
if (iter > 0 && residual <= minResidual)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
meshDistributor().distribute(alignments);
|
||||||
|
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
mesh_.finite_vertices_begin();
|
||||||
|
vit != mesh_.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->real())
|
||||||
|
{
|
||||||
|
vit->alignment() = alignments[vit->index()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
labelList referredPoints;
|
||||||
|
autoPtr<mapDistribute> referredDistributor = buildReferredMap
|
||||||
|
(
|
||||||
|
mesh_,
|
||||||
|
referredPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
alignments.setSize(mesh_.vertexCount());
|
||||||
|
referredDistributor().distribute(alignments);
|
||||||
|
|
||||||
|
label referredI = 0;
|
||||||
|
for
|
||||||
|
(
|
||||||
|
CellSizeDelaunay::Finite_vertices_iterator vit =
|
||||||
|
mesh_.finite_vertices_begin();
|
||||||
|
vit != mesh_.finite_vertices_end();
|
||||||
|
++vit
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (vit->referred())
|
||||||
|
{
|
||||||
|
vit->alignment() = alignments[referredPoints[referredI++]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::smoothAlignmentSolver
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
smoothAlignmentSolverI.H
|
||||||
|
smoothAlignmentSolver.C
|
||||||
|
smoothAlignmentSolverIO.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef smoothAlignmentSolver_H
|
||||||
|
#define smoothAlignmentSolver_H
|
||||||
|
|
||||||
|
#include "cellShapeControlMesh.H"
|
||||||
|
#include "triadField.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class smoothAlignmentSolver Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class smoothAlignmentSolver
|
||||||
|
{
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
cellShapeControlMesh& mesh_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
template<class Triangulation, class Type>
|
||||||
|
tmp<Field<Type> > filterFarPoints
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
const Field<Type>& field
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
autoPtr<mapDistribute> buildMap
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
labelListList& pointPoints
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
autoPtr<mapDistribute> buildReferredMap
|
||||||
|
(
|
||||||
|
const Triangulation& mesh,
|
||||||
|
labelList& indices
|
||||||
|
);
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
tmp<triadField> buildAlignmentField(const Triangulation& mesh);
|
||||||
|
|
||||||
|
template<class Triangulation>
|
||||||
|
tmp<pointField> buildPointField(const Triangulation& mesh);
|
||||||
|
|
||||||
|
//- Apply the fixed alignments to the triad
|
||||||
|
void applyBoundaryConditions
|
||||||
|
(
|
||||||
|
const triad& fixedAlignment,
|
||||||
|
triad& t
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
smoothAlignmentSolver(const smoothAlignmentSolver&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const smoothAlignmentSolver&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct null
|
||||||
|
smoothAlignmentSolver(cellShapeControlMesh& mesh);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~smoothAlignmentSolver();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Edit
|
||||||
|
|
||||||
|
//- Smooth the alignments on the mesh
|
||||||
|
void smoothAlignments(const label maxSmoothingIterations);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,169 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellSizeFunction, 0);
|
||||||
|
defineRunTimeSelectionTable(cellSizeFunction, dictionary);
|
||||||
|
|
||||||
|
scalar cellSizeFunction::snapToSurfaceTol_ = 1e-10;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeFunction::cellSizeFunction
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
dictionary(cellSizeFunctionDict),
|
||||||
|
surface_(surface),
|
||||||
|
surfaceCellSizeFunction_
|
||||||
|
(
|
||||||
|
surfaceCellSizeFunction::New
|
||||||
|
(
|
||||||
|
cellSizeFunctionDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize
|
||||||
|
)
|
||||||
|
),
|
||||||
|
coeffsDict_(subDict(type + "Coeffs")),
|
||||||
|
defaultCellSize_(defaultCellSize),
|
||||||
|
regionIndices_(regionIndices),
|
||||||
|
sideMode_(),
|
||||||
|
priority_(readLabel(cellSizeFunctionDict.lookup("priority", true)))
|
||||||
|
{
|
||||||
|
word mode = cellSizeFunctionDict.lookup("mode", true);
|
||||||
|
|
||||||
|
if (surface_.hasVolumeType())
|
||||||
|
{
|
||||||
|
if (mode == "inside")
|
||||||
|
{
|
||||||
|
sideMode_ = smInside;
|
||||||
|
}
|
||||||
|
else if (mode == "outside")
|
||||||
|
{
|
||||||
|
sideMode_ = smOutside;
|
||||||
|
}
|
||||||
|
else if (mode == "bothSides")
|
||||||
|
{
|
||||||
|
sideMode_ = rmBothsides;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn("searchableSurfaceControl::searchableSurfaceControl")
|
||||||
|
<< "Unknown mode, expected: inside, outside or bothSides" << nl
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (mode != "bothSides")
|
||||||
|
{
|
||||||
|
WarningIn("searchableSurfaceControl::searchableSurfaceControl")
|
||||||
|
<< "surface does not support volumeType, defaulting mode to "
|
||||||
|
<< "bothSides."
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
sideMode_ = rmBothsides;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
Info<< nl
|
||||||
|
<< "Cell size function for surface " << surface.name()
|
||||||
|
<< ", " << mode
|
||||||
|
<< ", priority = " << priority_
|
||||||
|
<< ", regions = " << regionIndices_
|
||||||
|
<< endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::cellSizeFunction> Foam::cellSizeFunction::New
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
{
|
||||||
|
word cellSizeFunctionTypeName
|
||||||
|
(
|
||||||
|
cellSizeFunctionDict.lookup("cellSizeFunction")
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< indent << "Selecting cellSizeFunction " << cellSizeFunctionTypeName
|
||||||
|
<< endl;
|
||||||
|
|
||||||
|
dictionaryConstructorTable::iterator cstrIter =
|
||||||
|
dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
|
||||||
|
|
||||||
|
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"cellSizeFunction::New(dictionary&, "
|
||||||
|
"const conformalVoronoiMesh&, const searchableSurface&)"
|
||||||
|
) << "Unknown cellSizeFunction type "
|
||||||
|
<< cellSizeFunctionTypeName
|
||||||
|
<< endl << endl
|
||||||
|
<< "Valid cellSizeFunction types are :" << endl
|
||||||
|
<< dictionaryConstructorTablePtr_->toc()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<cellSizeFunction>
|
||||||
|
(
|
||||||
|
cstrIter()
|
||||||
|
(
|
||||||
|
cellSizeFunctionDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeFunction::~cellSizeFunction()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,221 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellSizeFunction
|
||||||
|
|
||||||
|
Description
|
||||||
|
Abstract base class for specifying target cell sizes
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellSizeFunction.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellSizeFunction_H
|
||||||
|
#define cellSizeFunction_H
|
||||||
|
|
||||||
|
#include "point.H"
|
||||||
|
#include "conformalVoronoiMesh.H"
|
||||||
|
#include "searchableSurface.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "runTimeSelectionTables.H"
|
||||||
|
#include "surfaceCellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellSizeFunction Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellSizeFunction
|
||||||
|
:
|
||||||
|
public dictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Surface side mode
|
||||||
|
enum sideMode
|
||||||
|
{
|
||||||
|
smInside, // Control inside the surface
|
||||||
|
smOutside, // Control outside the surface
|
||||||
|
rmBothsides // Control on both sides of a surface
|
||||||
|
};
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cellSizeFunction");
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Static data
|
||||||
|
|
||||||
|
//- Point closeness tolerance to a surface where the function "snaps" to
|
||||||
|
// including the surface
|
||||||
|
static scalar snapToSurfaceTol_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Reference to the searchableSurface that cellSizeFunction
|
||||||
|
// relates to
|
||||||
|
const searchableSurface& surface_;
|
||||||
|
|
||||||
|
//- Cell size at the surface
|
||||||
|
scalarField surfaceCellSize_;
|
||||||
|
|
||||||
|
autoPtr<surfaceCellSizeFunction> surfaceCellSizeFunction_;
|
||||||
|
|
||||||
|
//- Method details dictionary
|
||||||
|
dictionary coeffsDict_;
|
||||||
|
|
||||||
|
const scalar& defaultCellSize_;
|
||||||
|
|
||||||
|
//- Index of the region of the surface that this cell size function
|
||||||
|
// applies to
|
||||||
|
const labelList regionIndices_;
|
||||||
|
|
||||||
|
//- Mode of size specification, i.e. inside, outside or bothSides
|
||||||
|
sideMode sideMode_;
|
||||||
|
|
||||||
|
label priority_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellSizeFunction(const cellSizeFunction&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellSizeFunction&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
cellSizeFunction,
|
||||||
|
dictionary,
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
),
|
||||||
|
(cellSizeFunctionDict, surface, defaultCellSize, regionIndices)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Selectors
|
||||||
|
|
||||||
|
//- Return a reference to the selected cellSizeFunction
|
||||||
|
static autoPtr<cellSizeFunction> New
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellSizeFunction();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Const access to the details dictionary
|
||||||
|
inline const dictionary& coeffsDict() const
|
||||||
|
{
|
||||||
|
return coeffsDict_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const = 0;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
)
|
||||||
|
{
|
||||||
|
WarningIn("cellSizeFunction::setCellSize(const pointField&)")
|
||||||
|
<< "Not overloaded."
|
||||||
|
<< endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
label priority() const
|
||||||
|
{
|
||||||
|
return priority_;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,256 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "linearDistance.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(linearDistance, 0);
|
||||||
|
addToRunTimeSelectionTable(cellSizeFunction, linearDistance, dictionary);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
linearDistance::linearDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
initialPointsDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
),
|
||||||
|
distanceCellSize_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("distanceCellSizeCoeff"))
|
||||||
|
*defaultCellSize
|
||||||
|
),
|
||||||
|
distance_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("distanceCoeff"))*defaultCellSize
|
||||||
|
),
|
||||||
|
distanceSqr_(sqr(distance_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
scalar linearDistance::sizeFunction
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar d,
|
||||||
|
label index
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar interpolatedSize
|
||||||
|
= surfaceCellSizeFunction_().interpolate(pt, index);
|
||||||
|
|
||||||
|
scalar gradient
|
||||||
|
= (distanceCellSize_ - interpolatedSize)
|
||||||
|
/distance_;
|
||||||
|
|
||||||
|
scalar size = gradient*d + interpolatedSize;
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool linearDistance::sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const Foam::point& pt = hitPt.hitPoint();
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
shapePts.resize(2);
|
||||||
|
shapeSizes.resize(2);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize_;
|
||||||
|
|
||||||
|
shapePts[1] = pt + n*distance_;
|
||||||
|
shapeSizes[1] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smInside)
|
||||||
|
{
|
||||||
|
shapePts.resize(1);
|
||||||
|
shapeSizes.resize(1);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smOutside)
|
||||||
|
{
|
||||||
|
shapePts.resize(1);
|
||||||
|
shapeSizes.resize(1);
|
||||||
|
|
||||||
|
shapePts[0] = pt + n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool linearDistance::cellSize(const point& pt, scalar& size) const
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, distanceSqr_),
|
||||||
|
regionIndices_,
|
||||||
|
hits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& hitInfo = hits[0];
|
||||||
|
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
const point& hitPt = hitInfo.hitPoint();
|
||||||
|
const label hitIndex = hitInfo.index();
|
||||||
|
|
||||||
|
const scalar dist = mag(pt - hitPt);
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the nearest point is essentially on the surface, do not do a
|
||||||
|
// getVolumeType calculation, as it will be prone to error.
|
||||||
|
if (dist < snapToSurfaceTol_)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, 0, hitIndex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointField ptF(1, pt);
|
||||||
|
List<volumeType> vTL;
|
||||||
|
|
||||||
|
surface_.getVolumeType(ptF, vTL);
|
||||||
|
|
||||||
|
bool functionApplied = false;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sideMode_ == smInside
|
||||||
|
&& vTL[0] == volumeType::INSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
sideMode_ == smOutside
|
||||||
|
&& vTL[0] == volumeType::OUTSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return functionApplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool linearDistance::setCellSize(const pointField& pts)
|
||||||
|
{
|
||||||
|
// labelHashSet surfaceAlreadyHit(surfaceCellSize_.size());
|
||||||
|
|
||||||
|
// forAll(pts, ptI)
|
||||||
|
// {
|
||||||
|
// const Foam::point& pt = pts[ptI];
|
||||||
|
|
||||||
|
// List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
// surface_.findNearest
|
||||||
|
// (
|
||||||
|
// pointField(1, pt),
|
||||||
|
// scalarField(1, distanceSqr_),
|
||||||
|
// regionIndices_,
|
||||||
|
// hits
|
||||||
|
// );
|
||||||
|
|
||||||
|
// const label surfHitI = hits[0].index();
|
||||||
|
|
||||||
|
// if
|
||||||
|
// (
|
||||||
|
// hits[0].hit()
|
||||||
|
// && !surfaceAlreadyHit.found(surfHitI)
|
||||||
|
// )
|
||||||
|
// {
|
||||||
|
// // Halving cell size is arbitrary
|
||||||
|
// surfaceCellSizeFunction_().refineSurfaceSize(surfHitI);
|
||||||
|
|
||||||
|
// surfaceAlreadyHit.insert(surfHitI);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::linearDistance
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
linearDistance.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef linearDistance_H
|
||||||
|
#define linearDistance_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class linearDistance Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class linearDistance
|
||||||
|
:
|
||||||
|
public cellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- cell size at distance_ from the surface
|
||||||
|
scalar distanceCellSize_;
|
||||||
|
|
||||||
|
//- distance from the surface to control over
|
||||||
|
scalar distance_;
|
||||||
|
|
||||||
|
//- distance squared
|
||||||
|
scalar distanceSqr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Calculate the cell size as a function of the given distance
|
||||||
|
scalar sizeFunction(const point& pt, scalar d, label index) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("linearDistance");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
linearDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~linearDistance()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Adapt local cell size. Return true if anything changed.
|
||||||
|
virtual bool setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,180 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "linearSpatial.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(linearSpatial, 0);
|
||||||
|
addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
linearSpatial::linearSpatial
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
initialPointsDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
),
|
||||||
|
referencePoint_(coeffsDict().lookup("referencePoint")),
|
||||||
|
referenceCellSize_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("referenceCellSizeCoeff"))
|
||||||
|
*defaultCellSize
|
||||||
|
),
|
||||||
|
direction_(coeffsDict().lookup("direction")),
|
||||||
|
cellSizeGradient_(readScalar(coeffsDict().lookup("cellSizeGradient")))
|
||||||
|
{
|
||||||
|
direction_ /= mag(direction_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
scalar linearSpatial::sizeFunction(const point& pt) const
|
||||||
|
{
|
||||||
|
return
|
||||||
|
referenceCellSize_
|
||||||
|
+ ((pt - referencePoint_) & direction_)*cellSizeGradient_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool linearSpatial::sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smInside)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smOutside)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool linearSpatial::cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
size = sizeFunction(pt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, sqr(snapToSurfaceTol_)),
|
||||||
|
regionIndices_,
|
||||||
|
hits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& hitInfo = hits[0];
|
||||||
|
|
||||||
|
// If the nearest point is essentially on the surface, do not do a
|
||||||
|
// getVolumeType calculation, as it will be prone to error.
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
size = sizeFunction(pt);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointField ptF(1, pt);
|
||||||
|
List<volumeType> vTL;
|
||||||
|
|
||||||
|
surface_.getVolumeType(ptF, vTL);
|
||||||
|
|
||||||
|
bool functionApplied = false;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sideMode_ == smInside
|
||||||
|
&& vTL[0] == volumeType::INSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(pt);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
sideMode_ == smOutside
|
||||||
|
&& vTL[0] == volumeType::OUTSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(pt);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return functionApplied;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,130 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::linearSpatial
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
linearSpatial.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef linearSpatial_H
|
||||||
|
#define linearSpatial_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class linearSpatial Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class linearSpatial
|
||||||
|
:
|
||||||
|
public cellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Reference point for spatial size grading
|
||||||
|
point referencePoint_;
|
||||||
|
|
||||||
|
//- Cell size at reference point
|
||||||
|
scalar referenceCellSize_;
|
||||||
|
|
||||||
|
//- Direction of cell size grading, stored as unit vector, may be
|
||||||
|
// supplied with any magnitude
|
||||||
|
vector direction_;
|
||||||
|
|
||||||
|
//- Gradient of cell size change in direction of direction_
|
||||||
|
scalar cellSizeGradient_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Calculate the cell size as a function of the given position
|
||||||
|
scalar sizeFunction(const point& pt) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("linearSpatial");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
linearSpatial
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~linearSpatial()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,298 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "surfaceOffsetLinearDistance.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(surfaceOffsetLinearDistance, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
cellSizeFunction,
|
||||||
|
surfaceOffsetLinearDistance,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
surfaceOffsetLinearDistance::surfaceOffsetLinearDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
initialPointsDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
),
|
||||||
|
distanceCellSize_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("distanceCellSizeCoeff"))
|
||||||
|
*defaultCellSize
|
||||||
|
),
|
||||||
|
surfaceOffset_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("surfaceOffsetCoeff"))*defaultCellSize
|
||||||
|
),
|
||||||
|
totalDistance_(),
|
||||||
|
totalDistanceSqr_()
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
coeffsDict().found("totalDistanceCoeff")
|
||||||
|
|| coeffsDict().found("linearDistanceCoeff")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if
|
||||||
|
(
|
||||||
|
coeffsDict().found("totalDistanceCoeff")
|
||||||
|
&& coeffsDict().found("linearDistanceCoeff")
|
||||||
|
)
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
|
||||||
|
"("
|
||||||
|
" const dictionary& initialPointsDict,"
|
||||||
|
" const searchableSurface& surface,"
|
||||||
|
" const scalar& defaultCellSize"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
<< "totalDistanceCoeff and linearDistanceCoeff found, "
|
||||||
|
<< "specify one or other, not both."
|
||||||
|
<< nl << exit(FatalError) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (coeffsDict().found("totalDistanceCoeff"))
|
||||||
|
{
|
||||||
|
totalDistance_ =
|
||||||
|
readScalar(coeffsDict().lookup("totalDistanceCoeff"))
|
||||||
|
*defaultCellSize;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
totalDistance_ =
|
||||||
|
readScalar(coeffsDict().lookup("linearDistanceCoeff"))
|
||||||
|
*defaultCellSize
|
||||||
|
+ surfaceOffset_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"surfaceOffsetLinearDistance::surfaceOffsetLinearDistance"
|
||||||
|
"("
|
||||||
|
" const dictionary& initialPointsDict,"
|
||||||
|
" const searchableSurface& surface,"
|
||||||
|
" const scalar& defaultCellSize"
|
||||||
|
")"
|
||||||
|
)
|
||||||
|
<< "totalDistanceCoeff or linearDistanceCoeff not found."
|
||||||
|
<< nl << exit(FatalError) << endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
totalDistanceSqr_ = sqr(totalDistance_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
scalar surfaceOffsetLinearDistance::sizeFunction
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar d,
|
||||||
|
label index
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const scalar interpolatedSize
|
||||||
|
= surfaceCellSizeFunction_().interpolate(pt, index);
|
||||||
|
|
||||||
|
if (d <= surfaceOffset_)
|
||||||
|
{
|
||||||
|
return interpolatedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
scalar gradient =
|
||||||
|
(distanceCellSize_ - interpolatedSize)
|
||||||
|
/(totalDistance_ - surfaceOffset_);
|
||||||
|
|
||||||
|
scalar intercept = interpolatedSize - gradient*surfaceOffset_;
|
||||||
|
|
||||||
|
return gradient*d + intercept;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool surfaceOffsetLinearDistance::sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const Foam::point& pt = hitPt.hitPoint();
|
||||||
|
|
||||||
|
const scalar offsetCellSize =
|
||||||
|
surfaceCellSizeFunction_().interpolate(pt, hitPt.index());
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
shapePts.resize(4);
|
||||||
|
shapeSizes.resize(4);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*surfaceOffset_;
|
||||||
|
shapeSizes[0] = offsetCellSize;
|
||||||
|
shapePts[1] = pt - n*totalDistance_;
|
||||||
|
shapeSizes[1] = distanceCellSize_;
|
||||||
|
|
||||||
|
shapePts[2] = pt + n*surfaceOffset_;
|
||||||
|
shapeSizes[2] = offsetCellSize;
|
||||||
|
shapePts[3] = pt + n*totalDistance_;
|
||||||
|
shapeSizes[3] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smInside)
|
||||||
|
{
|
||||||
|
shapePts.resize(2);
|
||||||
|
shapeSizes.resize(2);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*surfaceOffset_;
|
||||||
|
shapeSizes[0] = offsetCellSize;
|
||||||
|
shapePts[1] = pt - n*totalDistance_;
|
||||||
|
shapeSizes[1] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smOutside)
|
||||||
|
{
|
||||||
|
shapePts.resize(2);
|
||||||
|
shapeSizes.resize(2);
|
||||||
|
|
||||||
|
shapePts[0] = pt + n*surfaceOffset_;
|
||||||
|
shapeSizes[0] = offsetCellSize;
|
||||||
|
shapePts[1] = pt + n*totalDistance_;
|
||||||
|
shapeSizes[1] = distanceCellSize_;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool surfaceOffsetLinearDistance::cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, totalDistanceSqr_),
|
||||||
|
regionIndices_,
|
||||||
|
hits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& hitInfo = hits[0];
|
||||||
|
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
const point& hitPt = hitInfo.hitPoint();
|
||||||
|
const label hitIndex = hitInfo.index();
|
||||||
|
|
||||||
|
const scalar dist = mag(pt - hitPt);
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the nearest point is essentially on the surface, do not do a
|
||||||
|
// getVolumeType calculation, as it will be prone to error.
|
||||||
|
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, 0, hitIndex);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointField ptF(1, pt);
|
||||||
|
List<volumeType> vTL;
|
||||||
|
|
||||||
|
surface_.getVolumeType(ptF, vTL);
|
||||||
|
|
||||||
|
bool functionApplied = false;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sideMode_ == smInside
|
||||||
|
&& vTL[0] == volumeType::INSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
sideMode_ == smOutside
|
||||||
|
&& vTL[0] == volumeType::OUTSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = sizeFunction(hitPt, dist, hitIndex);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return functionApplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,129 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::surfaceOffsetLinearDistance
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
surfaceOffsetLinearDistance.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef surfaceOffsetLinearDistance_H
|
||||||
|
#define surfaceOffsetLinearDistance_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class surfaceOffsetLinearDistance Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class surfaceOffsetLinearDistance
|
||||||
|
:
|
||||||
|
public cellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- cell size at distance_ from the surface
|
||||||
|
scalar distanceCellSize_;
|
||||||
|
|
||||||
|
//- Offset distance from surface for constant size portion
|
||||||
|
scalar surfaceOffset_;
|
||||||
|
|
||||||
|
//- Total distance from the surface to control over (distance +
|
||||||
|
// surfaceOffset)
|
||||||
|
scalar totalDistance_;
|
||||||
|
|
||||||
|
//- totalDistance squared
|
||||||
|
scalar totalDistanceSqr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Calculate the cell size as a function of the given distance
|
||||||
|
scalar sizeFunction(const point& pt, scalar d, label index) const;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("surfaceOffsetLinearDistance");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
surfaceOffsetLinearDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~surfaceOffsetLinearDistance()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,202 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "uniform.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(uniform, 0);
|
||||||
|
addToRunTimeSelectionTable(cellSizeFunction, uniform, dictionary);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
uniform::uniform
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
initialPointsDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
bool uniform::sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
shapePts.setSize(0);
|
||||||
|
shapeSizes.setSize(0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool uniform::cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, sqr(GREAT)),
|
||||||
|
regionIndices_,
|
||||||
|
hits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& hitInfo = hits[0];
|
||||||
|
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
const point& hitPt = hitInfo.hitPoint();
|
||||||
|
const label index = hitInfo.index();
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
List<pointIndexHit> closeToSurfaceHits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, sqr(snapToSurfaceTol_)),
|
||||||
|
regionIndices_,
|
||||||
|
closeToSurfaceHits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& closeToSurface = closeToSurfaceHits[0];
|
||||||
|
|
||||||
|
// If the nearest point is essentially on the surface, do not do a
|
||||||
|
// getVolumeType calculation, as it will be prone to error.
|
||||||
|
if (closeToSurface.hit())
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointField ptF(1, pt);
|
||||||
|
List<volumeType> vTL(1);
|
||||||
|
|
||||||
|
surface_.getVolumeType(ptF, vTL);
|
||||||
|
|
||||||
|
bool functionApplied = false;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sideMode_ == smInside
|
||||||
|
&& vTL[0] == volumeType::INSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
sideMode_ == smOutside
|
||||||
|
&& vTL[0] == volumeType::OUTSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return functionApplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool uniform::setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// labelHashSet surfaceAlreadyHit(cellSize_.size());
|
||||||
|
//
|
||||||
|
// forAll(pts, ptI)
|
||||||
|
// {
|
||||||
|
// const Foam::point& pt = pts[ptI];
|
||||||
|
//
|
||||||
|
// List<pointIndexHit> hits;
|
||||||
|
//
|
||||||
|
// surface_.findNearest
|
||||||
|
// (
|
||||||
|
// pointField(1, pt),
|
||||||
|
// scalarField(1, sqr(GREAT)),
|
||||||
|
// hits
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
|
||||||
|
// {
|
||||||
|
// surfaceCellSizeFunction_().refineCellSize(hits[0].index());
|
||||||
|
//
|
||||||
|
// surfaceAlreadyHit.insert(hits[0].index());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,116 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::uniform
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
uniform.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef uniform_H
|
||||||
|
#define uniform_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class uniform Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class uniform
|
||||||
|
:
|
||||||
|
public cellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("uniform");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
uniform
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~uniform()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Adapt local cell size. Return true if anything changed.
|
||||||
|
virtual bool setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,229 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "uniformDistance.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "volumeType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(uniformDistance, 0);
|
||||||
|
addToRunTimeSelectionTable(cellSizeFunction, uniformDistance, dictionary);
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
uniformDistance::uniformDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
initialPointsDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize,
|
||||||
|
regionIndices
|
||||||
|
),
|
||||||
|
distance_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict().lookup("distanceCoeff"))*defaultCellSize
|
||||||
|
),
|
||||||
|
distanceSqr_(sqr(distance_))
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
|
bool uniformDistance::sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const Foam::point& pt = hitPt.hitPoint();
|
||||||
|
|
||||||
|
const scalar distanceCellSize =
|
||||||
|
surfaceCellSizeFunction_().interpolate(pt, hitPt.index());
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
shapePts.resize(2);
|
||||||
|
shapeSizes.resize(2);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize;
|
||||||
|
|
||||||
|
shapePts[1] = pt + n*distance_;
|
||||||
|
shapeSizes[1] = distanceCellSize;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smInside)
|
||||||
|
{
|
||||||
|
shapePts.resize(1);
|
||||||
|
shapeSizes.resize(1);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize;
|
||||||
|
}
|
||||||
|
else if (sideMode_ == smOutside)
|
||||||
|
{
|
||||||
|
shapePts.resize(1);
|
||||||
|
shapeSizes.resize(1);
|
||||||
|
|
||||||
|
shapePts[0] = pt - n*distance_;
|
||||||
|
shapeSizes[0] = distanceCellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool uniformDistance::cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
size = 0;
|
||||||
|
|
||||||
|
List<pointIndexHit> hits;
|
||||||
|
|
||||||
|
surface_.findNearest
|
||||||
|
(
|
||||||
|
pointField(1, pt),
|
||||||
|
scalarField(1, distanceSqr_),
|
||||||
|
regionIndices_,
|
||||||
|
hits
|
||||||
|
);
|
||||||
|
|
||||||
|
const pointIndexHit& hitInfo = hits[0];
|
||||||
|
|
||||||
|
if (hitInfo.hit())
|
||||||
|
{
|
||||||
|
const point& hitPt = hitInfo.hitPoint();
|
||||||
|
const label index = hitInfo.index();
|
||||||
|
|
||||||
|
if (sideMode_ == rmBothsides)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the nearest point is essentially on the surface, do not do a
|
||||||
|
// getVolumeType calculation, as it will be prone to error.
|
||||||
|
if (mag(pt - hitInfo.hitPoint()) < snapToSurfaceTol_)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
pointField ptF(1, pt);
|
||||||
|
List<volumeType> vTL;
|
||||||
|
|
||||||
|
surface_.getVolumeType(ptF, vTL);
|
||||||
|
|
||||||
|
bool functionApplied = false;
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
sideMode_ == smInside
|
||||||
|
&& vTL[0] == volumeType::INSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
sideMode_ == smOutside
|
||||||
|
&& vTL[0] == volumeType::OUTSIDE
|
||||||
|
)
|
||||||
|
{
|
||||||
|
size = surfaceCellSizeFunction_().interpolate(hitPt, index);
|
||||||
|
|
||||||
|
functionApplied = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return functionApplied;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool uniformDistance::setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
)
|
||||||
|
{
|
||||||
|
// labelHashSet surfaceAlreadyHit(surface_.size());
|
||||||
|
//
|
||||||
|
// forAll(pts, ptI)
|
||||||
|
// {
|
||||||
|
// const Foam::point& pt = pts[ptI];
|
||||||
|
//
|
||||||
|
// List<pointIndexHit> hits;
|
||||||
|
//
|
||||||
|
// surface_.findNearest
|
||||||
|
// (
|
||||||
|
// pointField(1, pt),
|
||||||
|
// scalarField(1, distanceSqr_),
|
||||||
|
// regionIndices_,
|
||||||
|
// hits
|
||||||
|
// );
|
||||||
|
//
|
||||||
|
// if (hits[0].hit() && !surfaceAlreadyHit.found(hits[0].index()))
|
||||||
|
// {
|
||||||
|
// surfaceCellSizeFunction_().refineSurfaceSize(hits[0].index());
|
||||||
|
//
|
||||||
|
// surfaceAlreadyHit.insert(hits[0].index());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,122 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::uniformDistance
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
uniformDistance.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef uniformDistance_H
|
||||||
|
#define uniformDistance_H
|
||||||
|
|
||||||
|
#include "cellSizeFunction.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class uniformDistance Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class uniformDistance
|
||||||
|
:
|
||||||
|
public cellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Distance
|
||||||
|
scalar distance_;
|
||||||
|
|
||||||
|
//- Distance squared
|
||||||
|
scalar distanceSqr_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("uniformDistance");
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
uniformDistance
|
||||||
|
(
|
||||||
|
const dictionary& initialPointsDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize,
|
||||||
|
const labelList regionIndices
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~uniformDistance()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
virtual bool sizeLocations
|
||||||
|
(
|
||||||
|
const pointIndexHit& hitPt,
|
||||||
|
const vector& n,
|
||||||
|
pointField& shapePts,
|
||||||
|
scalarField& shapeSizes
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Modify scalar argument to the cell size specified by function.
|
||||||
|
// Return a boolean specifying if the function was used, i.e. false if
|
||||||
|
// the point was not in range of the surface for a spatially varying
|
||||||
|
// size.
|
||||||
|
virtual bool cellSize
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
scalar& size
|
||||||
|
) const;
|
||||||
|
|
||||||
|
//- Adapt local cell size. Return true if anything changed.
|
||||||
|
virtual bool setCellSize
|
||||||
|
(
|
||||||
|
const pointField& pts
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,301 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "automatic.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "vtkSurfaceWriter.H"
|
||||||
|
#include "primitivePatchInterpolation.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(automatic, 0);
|
||||||
|
addToRunTimeSelectionTable(cellSizeCalculationType, automatic, dictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::automatic::smoothField(triSurfaceScalarField& surf)
|
||||||
|
{
|
||||||
|
label nSmoothingIterations = 10;
|
||||||
|
|
||||||
|
for (label iter = 0; iter < nSmoothingIterations; ++iter)
|
||||||
|
{
|
||||||
|
const pointField& faceCentres = surface_.faceCentres();
|
||||||
|
|
||||||
|
forAll(surf, sI)
|
||||||
|
{
|
||||||
|
const labelList& faceFaces = surface_.faceFaces()[sI];
|
||||||
|
|
||||||
|
const point& fC = faceCentres[sI];
|
||||||
|
const scalar value = surf[sI];
|
||||||
|
|
||||||
|
scalar newValue = 0;
|
||||||
|
scalar totalDist = 0;
|
||||||
|
|
||||||
|
label nFaces = 0;
|
||||||
|
|
||||||
|
forAll(faceFaces, fI)
|
||||||
|
{
|
||||||
|
const label faceLabel = faceFaces[fI];
|
||||||
|
const point& faceCentre = faceCentres[faceLabel];
|
||||||
|
|
||||||
|
const scalar faceValue = surf[faceLabel];
|
||||||
|
const scalar distance = mag(faceCentre - fC);
|
||||||
|
|
||||||
|
newValue += faceValue/(distance + SMALL);
|
||||||
|
|
||||||
|
totalDist += 1.0/(distance + SMALL);
|
||||||
|
|
||||||
|
if (value < faceValue)
|
||||||
|
{
|
||||||
|
nFaces++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not smooth out the peak values
|
||||||
|
if (nFaces == faceFaces.size())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
surf[sI] = newValue/totalDist;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::automatic::automatic
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalcTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeCalculationType
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
cellSizeCalcTypeDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize
|
||||||
|
),
|
||||||
|
coeffsDict_(cellSizeCalcTypeDict.subDict(typeName + "Coeffs")),
|
||||||
|
surfaceName_(surface.searchableSurface::name()),
|
||||||
|
readCurvature_(Switch(coeffsDict_.lookup("curvature"))),
|
||||||
|
curvatureFile_(coeffsDict_.lookup("curvatureFile")),
|
||||||
|
readFeatureProximity_(Switch(coeffsDict_.lookup("featureProximity"))),
|
||||||
|
featureProximityFile_(coeffsDict_.lookup("featureProximityFile")),
|
||||||
|
readInternalCloseness_(Switch(coeffsDict_.lookup("internalCloseness"))),
|
||||||
|
internalClosenessFile_(coeffsDict_.lookup("internalClosenessFile")),
|
||||||
|
curvatureCellSizeCoeff_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict_.lookup("curvatureCellSizeCoeff"))
|
||||||
|
),
|
||||||
|
maximumCellSize_
|
||||||
|
(
|
||||||
|
readScalar(coeffsDict_.lookup("maximumCellSizeCoeff"))*defaultCellSize
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::tmp<Foam::triSurfacePointScalarField> Foam::automatic::load()
|
||||||
|
{
|
||||||
|
Info<< indent
|
||||||
|
<< "Calculating cell size on surface: " << surfaceName_ << endl;
|
||||||
|
|
||||||
|
tmp<triSurfacePointScalarField> tPointCellSize
|
||||||
|
(
|
||||||
|
new triSurfacePointScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
surfaceName_ + ".cellSize",
|
||||||
|
surface_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surface_.searchableSurface::time(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surface_,
|
||||||
|
dimLength,
|
||||||
|
scalarField(surface_.nPoints(), maximumCellSize_)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
triSurfacePointScalarField& pointCellSize = tPointCellSize();
|
||||||
|
|
||||||
|
if (readCurvature_)
|
||||||
|
{
|
||||||
|
Info<< indent
|
||||||
|
<< "Reading curvature : " << curvatureFile_ << endl;
|
||||||
|
|
||||||
|
triSurfacePointScalarField curvature
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
curvatureFile_,
|
||||||
|
surface_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surface_.searchableSurface::time(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surface_,
|
||||||
|
dimLength,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
forAll(pointCellSize, pI)
|
||||||
|
{
|
||||||
|
pointCellSize[pI] =
|
||||||
|
min
|
||||||
|
(
|
||||||
|
1.0
|
||||||
|
/max
|
||||||
|
(
|
||||||
|
(1.0/curvatureCellSizeCoeff_)*mag(curvature[pI]),
|
||||||
|
1.0/maximumCellSize_
|
||||||
|
),
|
||||||
|
pointCellSize[pI]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PrimitivePatchInterpolation
|
||||||
|
<
|
||||||
|
PrimitivePatch<labelledTri, ::Foam::List, pointField, point>
|
||||||
|
> patchInterpolate(surface_);
|
||||||
|
|
||||||
|
const Map<label>& meshPointMap = surface_.meshPointMap();
|
||||||
|
|
||||||
|
if (readInternalCloseness_)
|
||||||
|
{
|
||||||
|
Info<< indent
|
||||||
|
<< "Reading internal closeness: " << internalClosenessFile_ << endl;
|
||||||
|
|
||||||
|
triSurfaceScalarField internalCloseness
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
internalClosenessFile_,
|
||||||
|
surface_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surface_.searchableSurface::time(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surface_,
|
||||||
|
dimLength,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
scalarField internalClosenessPointField =
|
||||||
|
patchInterpolate.faceToPointInterpolate(internalCloseness);
|
||||||
|
|
||||||
|
forAll(pointCellSize, pI)
|
||||||
|
{
|
||||||
|
pointCellSize[pI] =
|
||||||
|
min
|
||||||
|
(
|
||||||
|
internalClosenessPointField[meshPointMap[pI]],
|
||||||
|
pointCellSize[pI]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (readFeatureProximity_)
|
||||||
|
{
|
||||||
|
Info<< indent
|
||||||
|
<< "Reading feature proximity : " << featureProximityFile_ << endl;
|
||||||
|
|
||||||
|
triSurfaceScalarField featureProximity
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
featureProximityFile_,
|
||||||
|
surface_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surface_.searchableSurface::time(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surface_,
|
||||||
|
dimLength,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
|
scalarField featureProximityPointField =
|
||||||
|
patchInterpolate.faceToPointInterpolate(featureProximity);
|
||||||
|
|
||||||
|
forAll(pointCellSize, pI)
|
||||||
|
{
|
||||||
|
pointCellSize[pI] =
|
||||||
|
min
|
||||||
|
(
|
||||||
|
featureProximityPointField[meshPointMap[pI]],
|
||||||
|
pointCellSize[pI]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//smoothField(surfaceCellSize);
|
||||||
|
|
||||||
|
pointCellSize.write();
|
||||||
|
|
||||||
|
if (debug)
|
||||||
|
{
|
||||||
|
faceList faces(surface_.size());
|
||||||
|
|
||||||
|
forAll(surface_, fI)
|
||||||
|
{
|
||||||
|
faces[fI] = surface_.triSurface::operator[](fI).triFaceFace();
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkSurfaceWriter().write
|
||||||
|
(
|
||||||
|
surface_.searchableSurface::time().constant()/"triSurface",
|
||||||
|
surfaceName_.lessExt().name(),
|
||||||
|
surface_.points(),
|
||||||
|
faces,
|
||||||
|
"cellSize",
|
||||||
|
pointCellSize,
|
||||||
|
true,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tPointCellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,127 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::automatic
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
automatic.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef automatic_H
|
||||||
|
#define automatic_H
|
||||||
|
|
||||||
|
#include "cellSizeCalculationType.H"
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
#include "PrimitivePatchInterpolation.H"
|
||||||
|
#include "Switch.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class triSurfaceMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class automatic Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class automatic
|
||||||
|
:
|
||||||
|
public cellSizeCalculationType
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Dictionary of coefficients for automatic cell sizing
|
||||||
|
const dictionary& coeffsDict_;
|
||||||
|
|
||||||
|
//- Name of the surface. Used to write the cell size field
|
||||||
|
const fileName surfaceName_;
|
||||||
|
|
||||||
|
const Switch readCurvature_;
|
||||||
|
const word curvatureFile_;
|
||||||
|
|
||||||
|
const Switch readFeatureProximity_;
|
||||||
|
const word featureProximityFile_;
|
||||||
|
|
||||||
|
const Switch readInternalCloseness_;
|
||||||
|
const word internalClosenessFile_;
|
||||||
|
|
||||||
|
//- The curvature values are multiplied by the inverse of this value to
|
||||||
|
// get the cell size
|
||||||
|
const scalar curvatureCellSizeCoeff_;
|
||||||
|
|
||||||
|
//- The maximum allowable sell size
|
||||||
|
const scalar maximumCellSize_;
|
||||||
|
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
void smoothField(triSurfaceScalarField& surf);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("automatic");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
automatic
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalcTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~automatic()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Load the cell size field
|
||||||
|
virtual tmp<triSurfacePointScalarField> load();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,101 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "cellSizeCalculationType.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(cellSizeCalculationType, 0);
|
||||||
|
defineRunTimeSelectionTable(cellSizeCalculationType, dictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeCalculationType::cellSizeCalculationType
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& cellSizeCalculationTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeCalculationTypeDict_(cellSizeCalculationTypeDict),
|
||||||
|
surface_(surface),
|
||||||
|
defaultCellSize_(defaultCellSize)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::cellSizeCalculationType> Foam::cellSizeCalculationType::New
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalculationTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
word cellSizeCalculationTypeTypeName
|
||||||
|
(
|
||||||
|
cellSizeCalculationTypeDict.lookup("cellSizeCalculationType")
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< indent << "Selecting cellSizeCalculationType "
|
||||||
|
<< cellSizeCalculationTypeTypeName << endl;
|
||||||
|
|
||||||
|
dictionaryConstructorTable::iterator cstrIter =
|
||||||
|
dictionaryConstructorTablePtr_->find(cellSizeCalculationTypeTypeName);
|
||||||
|
|
||||||
|
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"cellSizeCalculationType::New(dictionary&, "
|
||||||
|
"const conformalVoronoiMesh&, const searchableSurface&)"
|
||||||
|
) << "Unknown cellSizeCalculationType type "
|
||||||
|
<< cellSizeCalculationTypeTypeName
|
||||||
|
<< endl << endl
|
||||||
|
<< "Valid cellSizeCalculationType types are :" << endl
|
||||||
|
<< dictionaryConstructorTablePtr_->toc()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<cellSizeCalculationType>
|
||||||
|
(
|
||||||
|
cstrIter()(cellSizeCalculationTypeDict, surface, defaultCellSize)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::cellSizeCalculationType::~cellSizeCalculationType()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,141 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::cellSizeCalculationType
|
||||||
|
|
||||||
|
Description
|
||||||
|
Abstract base class for specifying target cell sizes
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
cellSizeCalculationType.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef cellSizeCalculationType_H
|
||||||
|
#define cellSizeCalculationType_H
|
||||||
|
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "runTimeSelectionTables.H"
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class triSurfaceMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class cellSizeCalculationType Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class cellSizeCalculationType
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
const dictionary& cellSizeCalculationTypeDict_;
|
||||||
|
|
||||||
|
//- Reference to the triSurfaceMesh
|
||||||
|
const triSurfaceMesh& surface_;
|
||||||
|
|
||||||
|
const scalar& defaultCellSize_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
cellSizeCalculationType(const cellSizeCalculationType&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const cellSizeCalculationType&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("cellSizeCalculationType");
|
||||||
|
|
||||||
|
|
||||||
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
cellSizeCalculationType,
|
||||||
|
dictionary,
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalculationTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
),
|
||||||
|
(cellSizeCalculationTypeDict, surface, defaultCellSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
cellSizeCalculationType
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& cellSizeCalculationTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Selectors
|
||||||
|
|
||||||
|
//- Return a reference to the selected cellSizeCalculationType
|
||||||
|
static autoPtr<cellSizeCalculationType> New
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalculationTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~cellSizeCalculationType();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Load the cell size
|
||||||
|
virtual tmp<triSurfacePointScalarField> load() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "fieldFromFile.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(fieldFromFile, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
cellSizeCalculationType,
|
||||||
|
fieldFromFile,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::fieldFromFile::fieldFromFile
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalcTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
cellSizeCalculationType
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
cellSizeCalcTypeDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize
|
||||||
|
),
|
||||||
|
fileName_
|
||||||
|
(
|
||||||
|
cellSizeCalcTypeDict.subDict(typeName + "Coeffs").lookup("fieldFile")
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::tmp<Foam::triSurfacePointScalarField> Foam::fieldFromFile::load()
|
||||||
|
{
|
||||||
|
Info<< indent << "Loading: " << fileName_ << endl;
|
||||||
|
|
||||||
|
tmp<triSurfacePointScalarField> pointCellSize
|
||||||
|
(
|
||||||
|
new triSurfacePointScalarField
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
fileName_,
|
||||||
|
surface_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surface_.searchableSurface::time(),
|
||||||
|
IOobject::MUST_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surface_,
|
||||||
|
dimLength,
|
||||||
|
true
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
return pointCellSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,103 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::fieldFromFile
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
fieldFromFile.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef fieldFromFile_H
|
||||||
|
#define fieldFromFile_H
|
||||||
|
|
||||||
|
#include "cellSizeCalculationType.H"
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
#include "PrimitivePatchInterpolation.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class triSurfaceMesh;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class fieldFromFile Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class fieldFromFile
|
||||||
|
:
|
||||||
|
public cellSizeCalculationType
|
||||||
|
{
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
//- Name of the triSurfaceScalarField file to load in. Must be in
|
||||||
|
// constant/triSurface
|
||||||
|
const word fileName_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("fieldFromFile");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
fieldFromFile
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeCalcTypeDict,
|
||||||
|
const triSurfaceMesh& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~fieldFromFile()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Load the cell size field
|
||||||
|
virtual tmp<triSurfacePointScalarField> load();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,131 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "nonUniformField.H"
|
||||||
|
#include "triSurfaceMesh.H"
|
||||||
|
#include "searchableSurface.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
#include "Time.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(nonUniformField, 0);
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
surfaceCellSizeFunction,
|
||||||
|
nonUniformField,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::nonUniformField::nonUniformField
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
surfaceCellSizeFunction
|
||||||
|
(
|
||||||
|
typeName,
|
||||||
|
cellSizeFunctionDict,
|
||||||
|
surface,
|
||||||
|
defaultCellSize
|
||||||
|
),
|
||||||
|
surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
|
||||||
|
cellSizeCalculationType_
|
||||||
|
(
|
||||||
|
cellSizeCalculationType::New
|
||||||
|
(
|
||||||
|
coeffsDict(),
|
||||||
|
surfaceTriMesh_,
|
||||||
|
defaultCellSize
|
||||||
|
)
|
||||||
|
),
|
||||||
|
pointCellSize_
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
"pointCellSize.cellSize",
|
||||||
|
surfaceTriMesh_.searchableSurface::time().constant(),
|
||||||
|
"triSurface",
|
||||||
|
surfaceTriMesh_.searchableSurface::time(),
|
||||||
|
IOobject::NO_READ,
|
||||||
|
IOobject::NO_WRITE
|
||||||
|
),
|
||||||
|
surfaceTriMesh_,
|
||||||
|
dimLength,
|
||||||
|
false
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Info<< incrIndent;
|
||||||
|
|
||||||
|
pointCellSize_ = cellSizeCalculationType_().load();
|
||||||
|
|
||||||
|
Info<< indent << "Cell size field statistics:" << nl
|
||||||
|
<< indent << " Minimum: " << min(pointCellSize_).value() << nl
|
||||||
|
<< indent << " Average: " << average(pointCellSize_).value() << nl
|
||||||
|
<< indent << " Maximum: " << max(pointCellSize_).value() << endl;
|
||||||
|
|
||||||
|
Info<< decrIndent;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::scalar Foam::nonUniformField::interpolate
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
const label index
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
|
||||||
|
|
||||||
|
const pointField& pts = surfaceTriMesh_.points();
|
||||||
|
const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
|
||||||
|
|
||||||
|
triPointRef tri
|
||||||
|
(
|
||||||
|
pts[faceHitByPt[0]],
|
||||||
|
pts[faceHitByPt[1]],
|
||||||
|
pts[faceHitByPt[2]]
|
||||||
|
);
|
||||||
|
|
||||||
|
scalarList bary(3, 0.0);
|
||||||
|
|
||||||
|
tri.barycentric(pt, bary);
|
||||||
|
|
||||||
|
return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0]
|
||||||
|
+ pointCellSize_[pMap[faceHitByPt[1]]]*bary[1]
|
||||||
|
+ pointCellSize_[pMap[faceHitByPt[2]]]*bary[2];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,122 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::nonUniformField
|
||||||
|
|
||||||
|
Description
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
nonUniformField.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef nonUniformField_H
|
||||||
|
#define nonUniformField_H
|
||||||
|
|
||||||
|
#include "triSurfaceFields.H"
|
||||||
|
#include "PrimitivePatchInterpolation.H"
|
||||||
|
#include "surfaceCellSizeFunction.H"
|
||||||
|
#include "cellSizeCalculationType.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
class triSurfaceMesh;
|
||||||
|
class searchableSurface;
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class nonUniformField Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class nonUniformField
|
||||||
|
:
|
||||||
|
public surfaceCellSizeFunction
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Private typedef
|
||||||
|
|
||||||
|
typedef PrimitivePatchInterpolation
|
||||||
|
<
|
||||||
|
PrimitivePatch<labelledTri, List, pointField, point>
|
||||||
|
> primitivePatchInterpolation;
|
||||||
|
|
||||||
|
|
||||||
|
// Private data
|
||||||
|
|
||||||
|
const triSurfaceMesh& surfaceTriMesh_;
|
||||||
|
|
||||||
|
autoPtr<cellSizeCalculationType> cellSizeCalculationType_;
|
||||||
|
|
||||||
|
triSurfacePointScalarField pointCellSize_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("nonUniformField");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
nonUniformField
|
||||||
|
(
|
||||||
|
const dictionary& cellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~nonUniformField()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
// Query
|
||||||
|
|
||||||
|
//- Return the interpolated cell size for a point in the given
|
||||||
|
// surface triangle
|
||||||
|
virtual scalar interpolate
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
const label index
|
||||||
|
) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "surfaceCellSizeFunction.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(surfaceCellSizeFunction, 0);
|
||||||
|
defineRunTimeSelectionTable(surfaceCellSizeFunction, dictionary);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceCellSizeFunction::surfaceCellSizeFunction
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& surfaceCellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
:
|
||||||
|
dictionary(surfaceCellSizeFunctionDict),
|
||||||
|
surface_(surface),
|
||||||
|
coeffsDict_(subDict(type + "Coeffs")),
|
||||||
|
defaultCellSize_(defaultCellSize),
|
||||||
|
refinementFactor_
|
||||||
|
(
|
||||||
|
lookupOrDefault<scalar>("refinementFactor", 1.0)
|
||||||
|
)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::autoPtr<Foam::surfaceCellSizeFunction> Foam::surfaceCellSizeFunction::New
|
||||||
|
(
|
||||||
|
const dictionary& surfaceCellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
word surfaceCellSizeFunctionTypeName
|
||||||
|
(
|
||||||
|
surfaceCellSizeFunctionDict.lookup("surfaceCellSizeFunction")
|
||||||
|
);
|
||||||
|
|
||||||
|
Info<< indent << "Selecting surfaceCellSizeFunction "
|
||||||
|
<< surfaceCellSizeFunctionTypeName << endl;
|
||||||
|
|
||||||
|
dictionaryConstructorTable::iterator cstrIter =
|
||||||
|
dictionaryConstructorTablePtr_->find(surfaceCellSizeFunctionTypeName);
|
||||||
|
|
||||||
|
if (cstrIter == dictionaryConstructorTablePtr_->end())
|
||||||
|
{
|
||||||
|
FatalErrorIn
|
||||||
|
(
|
||||||
|
"surfaceCellSizeFunction::New(dictionary&, "
|
||||||
|
"const conformalVoronoiMesh&, const searchableSurface&)"
|
||||||
|
) << "Unknown surfaceCellSizeFunction type "
|
||||||
|
<< surfaceCellSizeFunctionTypeName
|
||||||
|
<< endl << endl
|
||||||
|
<< "Valid surfaceCellSizeFunction types are :" << endl
|
||||||
|
<< dictionaryConstructorTablePtr_->toc()
|
||||||
|
<< exit(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return autoPtr<surfaceCellSizeFunction>
|
||||||
|
(
|
||||||
|
cstrIter()(surfaceCellSizeFunctionDict, surface, defaultCellSize)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::surfaceCellSizeFunction::~surfaceCellSizeFunction()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,158 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM 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.
|
||||||
|
|
||||||
|
OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::surfaceCellSizeFunction
|
||||||
|
|
||||||
|
Description
|
||||||
|
Abstract base class for specifying target cell sizes
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
surfaceCellSizeFunction.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef surfaceCellSizeFunction_H
|
||||||
|
#define surfaceCellSizeFunction_H
|
||||||
|
|
||||||
|
#include "searchableSurface.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "autoPtr.H"
|
||||||
|
#include "runTimeSelectionTables.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class surfaceCellSizeFunction Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class surfaceCellSizeFunction
|
||||||
|
:
|
||||||
|
public dictionary
|
||||||
|
{
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Reference to the searchableSurface that surfaceCellSizeFunction
|
||||||
|
// relates to
|
||||||
|
const searchableSurface& surface_;
|
||||||
|
|
||||||
|
const dictionary coeffsDict_;
|
||||||
|
|
||||||
|
const scalar& defaultCellSize_;
|
||||||
|
|
||||||
|
//- If cell resizing is allowed, this is the factor of the old cell size
|
||||||
|
// to get the new cell size
|
||||||
|
scalar refinementFactor_;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
surfaceCellSizeFunction(const surfaceCellSizeFunction&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const surfaceCellSizeFunction&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("surfaceCellSizeFunction");
|
||||||
|
|
||||||
|
|
||||||
|
// Declare run-time constructor selection table
|
||||||
|
|
||||||
|
declareRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
autoPtr,
|
||||||
|
surfaceCellSizeFunction,
|
||||||
|
dictionary,
|
||||||
|
(
|
||||||
|
const dictionary& surfaceCellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
),
|
||||||
|
(surfaceCellSizeFunctionDict, surface, defaultCellSize)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from components
|
||||||
|
surfaceCellSizeFunction
|
||||||
|
(
|
||||||
|
const word& type,
|
||||||
|
const dictionary& surfaceCellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Selectors
|
||||||
|
|
||||||
|
//- Return a reference to the selected surfaceCellSizeFunction
|
||||||
|
static autoPtr<surfaceCellSizeFunction> New
|
||||||
|
(
|
||||||
|
const dictionary& surfaceCellSizeFunctionDict,
|
||||||
|
const searchableSurface& surface,
|
||||||
|
const scalar& defaultCellSize
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~surfaceCellSizeFunction();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Const access to the details dictionary
|
||||||
|
inline const dictionary& coeffsDict() const
|
||||||
|
{
|
||||||
|
return coeffsDict_;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual scalar interpolate
|
||||||
|
(
|
||||||
|
const point& pt,
|
||||||
|
const label index
|
||||||
|
) const = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user