mirror of
https://github.com/OpenFOAM/OpenFOAM-6.git
synced 2025-12-08 06:57:46 +00:00
Add the OpenFOAM source tree
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
collapseEdges.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/collapseEdges
|
||||
@ -0,0 +1,9 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ldynamicMesh \
|
||||
-lmeshTools \
|
||||
-lfiniteVolume
|
||||
@ -0,0 +1,97 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: dev |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
|
||||
root "";
|
||||
case "";
|
||||
instance "";
|
||||
local "";
|
||||
|
||||
class dictionary;
|
||||
object collapseDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// If on, after collapsing check the quality of the mesh. If bad faces are
|
||||
// generated then redo the collapsing with stricter filtering.
|
||||
controlMeshQuality on;
|
||||
|
||||
|
||||
collapseEdgesCoeffs
|
||||
{
|
||||
// Edges shorter than this absolute value will be merged
|
||||
minimumEdgeLength 1e-6;
|
||||
|
||||
// The maximum angle between two edges that share a point attached to
|
||||
// no other edges
|
||||
maximumMergeAngle 30;
|
||||
}
|
||||
|
||||
|
||||
collapseFacesCoeffs
|
||||
{
|
||||
// The initial face length factor
|
||||
initialFaceLengthFactor 0.5;
|
||||
|
||||
// If the face can't be collapsed to an edge, and it has a span less than
|
||||
// the target face length multiplied by this coefficient, collapse it
|
||||
// to a point.
|
||||
maxCollapseFaceToPointSideLengthCoeff 0.3;
|
||||
|
||||
// Allow early collapse of edges to a point
|
||||
allowEarlyCollapseToPoint on;
|
||||
|
||||
// Fraction to premultiply maxCollapseFaceToPointSideLengthCoeff by if
|
||||
// allowEarlyCollapseToPoint is enabled
|
||||
allowEarlyCollapseCoeff 0.2;
|
||||
|
||||
// Defining how close to the midpoint (M) of the projected
|
||||
// vertices line a projected vertex (X) can be before making this
|
||||
// an invalid edge collapse
|
||||
//
|
||||
// X---X-g----------------M----X-----------g----X--X
|
||||
//
|
||||
// Only allow a collapse if all projected vertices are outwith
|
||||
// guardFraction (g) of the distance form the face centre to the
|
||||
// furthest vertex in the considered direction
|
||||
guardFraction 0.1;
|
||||
}
|
||||
|
||||
|
||||
controlMeshQualityCoeffs
|
||||
{
|
||||
// Name of the dictionary that has the mesh quality coefficients used
|
||||
// by motionSmoother::checkMesh
|
||||
#include "meshQualityDict";
|
||||
|
||||
// The amount that minimumEdgeLength will be reduced by for each
|
||||
// edge if that edge's collapse generates a poor quality face
|
||||
edgeReductionFactor 0.5;
|
||||
|
||||
// The amount that initialFaceLengthFactor will be reduced by for each
|
||||
// face if its collapse generates a poor quality face
|
||||
faceReductionFactor 0.5;
|
||||
|
||||
// Maximum number of smoothing iterations for the reductionFactors
|
||||
maximumSmoothingIterations 2;
|
||||
|
||||
// Maximum number of outer iterations is mesh quality checking is enabled
|
||||
maximumIterations 10;
|
||||
|
||||
// Maximum number of iterations deletion of a point can cause a bad face
|
||||
// to be constructed before it is forced to not be deleted
|
||||
maxPointErrorCount 5;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,247 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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/>.
|
||||
|
||||
Application
|
||||
collapseEdges
|
||||
|
||||
Description
|
||||
Collapses short edges and combines edges that are in line.
|
||||
|
||||
- collapse short edges. Length of edges to collapse provided as argument.
|
||||
- merge two edges if they are in line. Maximum angle provided as argument.
|
||||
- remove unused points.
|
||||
- collapse faces:
|
||||
- with small areas to a single point
|
||||
- that have a high aspect ratio (i.e. sliver face) to a single edge
|
||||
|
||||
Optionally checks the resulting mesh for bad faces and reduces the desired
|
||||
face length factor for those faces attached to the bad faces.
|
||||
|
||||
When collapsing an edge with one point on the boundary it will leave
|
||||
the boundary point intact. When both points inside it chooses random. When
|
||||
both points on boundary random again.
|
||||
|
||||
Usage
|
||||
- collapseEdges [OPTION]
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "timeSelector.H"
|
||||
#include "polyTopoChange.H"
|
||||
#include "fvMesh.H"
|
||||
#include "polyMeshFilter.H"
|
||||
#include "faceSet.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
timeSelector::addOptions(true, false);
|
||||
argList::addNote
|
||||
(
|
||||
"Collapses small edges to a point.\n"
|
||||
"Optionally collapse small faces to a point and thin faces to an edge."
|
||||
);
|
||||
|
||||
argList::addBoolOption
|
||||
(
|
||||
"collapseFaces",
|
||||
"Collapse small and sliver faces as well as small edges"
|
||||
);
|
||||
|
||||
argList::addOption
|
||||
(
|
||||
"collapseFaceSet",
|
||||
"faceSet",
|
||||
"Collapse faces that are in the supplied face set"
|
||||
);
|
||||
|
||||
# include "addOverwriteOption.H"
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
|
||||
runTime.functionObjects().off();
|
||||
instantList timeDirs = timeSelector::selectIfPresent(runTime, args);
|
||||
|
||||
# include "createMesh.H"
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const bool overwrite = args.optionFound("overwrite");
|
||||
|
||||
const bool collapseFaces = args.optionFound("collapseFaces");
|
||||
const bool collapseFaceSet = args.optionFound("collapseFaceSet");
|
||||
|
||||
if (collapseFaces && collapseFaceSet)
|
||||
{
|
||||
FatalErrorIn("main(int, char*[])")
|
||||
<< "Both face zone collapsing and face collapsing have been"
|
||||
<< "selected. Choose only one of:" << nl
|
||||
<< " -collapseFaces" << nl
|
||||
<< " -collapseFaceSet <faceSet>"
|
||||
<< abort(FatalError);
|
||||
}
|
||||
|
||||
|
||||
// maintain indirectPatchFaces if it is there (default) or force
|
||||
// (if collapseFaceSet option provided)
|
||||
word faceSetName("indirectPatchFaces");
|
||||
IOobject::readOption readFlag = IOobject::READ_IF_PRESENT;
|
||||
|
||||
if (args.optionReadIfPresent("collapseFaceSet", faceSetName))
|
||||
{
|
||||
readFlag = IOobject::MUST_READ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
labelIOList pointPriority
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"pointPriority",
|
||||
runTime.timeName(),
|
||||
runTime,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::AUTO_WRITE
|
||||
),
|
||||
labelList(mesh.nPoints(), labelMin)
|
||||
);
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
autoPtr<polyMeshFilter> meshFilterPtr;
|
||||
|
||||
label nBadFaces = 0;
|
||||
|
||||
faceSet indirectPatchFaces
|
||||
(
|
||||
mesh,
|
||||
faceSetName,
|
||||
readFlag,
|
||||
IOobject::AUTO_WRITE
|
||||
);
|
||||
Info<< "Read faceSet " << indirectPatchFaces.name()
|
||||
<< " with "
|
||||
<< returnReduce(indirectPatchFaces.size(), sumOp<label>())
|
||||
<< " faces" << endl;
|
||||
|
||||
|
||||
{
|
||||
meshFilterPtr.set(new polyMeshFilter(mesh, pointPriority));
|
||||
polyMeshFilter& meshFilter = meshFilterPtr();
|
||||
|
||||
// newMesh will be empty until it is filtered
|
||||
const autoPtr<fvMesh>& newMesh = meshFilter.filteredMesh();
|
||||
|
||||
// Filter small edges only. This reduces the number of faces so that
|
||||
// the face filtering is sped up.
|
||||
nBadFaces = meshFilter.filterEdges(0);
|
||||
{
|
||||
polyTopoChange meshMod(newMesh());
|
||||
|
||||
meshMod.changeMesh(mesh, false);
|
||||
|
||||
polyMeshFilter::copySets(newMesh(), mesh);
|
||||
}
|
||||
|
||||
pointPriority = meshFilter.pointPriority();
|
||||
}
|
||||
|
||||
if (collapseFaceSet)
|
||||
{
|
||||
meshFilterPtr.reset(new polyMeshFilter(mesh, pointPriority));
|
||||
polyMeshFilter& meshFilter = meshFilterPtr();
|
||||
|
||||
const autoPtr<fvMesh>& newMesh = meshFilter.filteredMesh();
|
||||
|
||||
// Filter faces. Pass in the number of bad faces that are present
|
||||
// from the previous edge filtering to use as a stopping criterion.
|
||||
meshFilter.filter(indirectPatchFaces);
|
||||
{
|
||||
polyTopoChange meshMod(newMesh);
|
||||
|
||||
meshMod.changeMesh(mesh, false);
|
||||
|
||||
polyMeshFilter::copySets(newMesh(), mesh);
|
||||
}
|
||||
|
||||
pointPriority = meshFilter.pointPriority();
|
||||
}
|
||||
|
||||
if (collapseFaces)
|
||||
{
|
||||
meshFilterPtr.reset(new polyMeshFilter(mesh, pointPriority));
|
||||
polyMeshFilter& meshFilter = meshFilterPtr();
|
||||
|
||||
const autoPtr<fvMesh>& newMesh = meshFilter.filteredMesh();
|
||||
|
||||
// Filter faces. Pass in the number of bad faces that are present
|
||||
// from the previous edge filtering to use as a stopping criterion.
|
||||
meshFilter.filter(nBadFaces);
|
||||
{
|
||||
polyTopoChange meshMod(newMesh);
|
||||
|
||||
meshMod.changeMesh(mesh, false);
|
||||
|
||||
polyMeshFilter::copySets(newMesh(), mesh);
|
||||
}
|
||||
|
||||
pointPriority = meshFilter.pointPriority();
|
||||
}
|
||||
|
||||
// Write resulting mesh
|
||||
if (!overwrite)
|
||||
{
|
||||
runTime++;
|
||||
}
|
||||
else
|
||||
{
|
||||
mesh.setInstance(oldInstance);
|
||||
}
|
||||
|
||||
Info<< nl << "Writing collapsed mesh to time "
|
||||
<< runTime.timeName() << nl << endl;
|
||||
|
||||
mesh.write();
|
||||
pointPriority.write();
|
||||
}
|
||||
|
||||
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
|
||||
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
|
||||
<< nl << endl;
|
||||
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,67 @@
|
||||
/*--------------------------------*- 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;
|
||||
object meshQualityDict;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- Maximum non-orthogonality allowed. Set to 180 to disable.
|
||||
maxNonOrtho 65;
|
||||
|
||||
//- Max skewness allowed. Set to <0 to disable.
|
||||
maxBoundarySkewness 50;
|
||||
|
||||
//- Max skewness allowed. Set to <0 to disable.
|
||||
maxInternalSkewness 10;
|
||||
|
||||
//- Max concaveness allowed. Is angle (in degrees) below which concavity
|
||||
// is allowed. 0 is straight face, <0 would be convex face.
|
||||
// Set to 180 to disable.
|
||||
maxConcave 80;
|
||||
|
||||
//- Minimum pyramid volume. Is absolute volume of cell pyramid.
|
||||
// Set to a sensible fraction of the smallest cell volume expected.
|
||||
// Set to very negative number (e.g. -1E30) to disable.
|
||||
minVol 1e-20;
|
||||
|
||||
//- Minimum quality of the tet formed by the face-centre
|
||||
// and variable base point minimum decomposition triangles and
|
||||
// the cell centre. This has to be a positive number for tracking
|
||||
// to work. Set to very negative number (e.g. -1E30) to
|
||||
// disable.
|
||||
// <0 = inside out tet,
|
||||
// 0 = flat tet
|
||||
// 1 = regular tet
|
||||
minTetQuality 1e-30;
|
||||
|
||||
//- Minimum face area. Set to <0 to disable.
|
||||
minArea -1;
|
||||
|
||||
//- Minimum face twist. Set to <-1 to disable. dot product of face normal
|
||||
//- and face centre triangles normal
|
||||
minTwist 0.0;
|
||||
|
||||
//- minimum normalised cell determinant
|
||||
//- 1 = hex, <= 0 = folded or flattened illegal cell
|
||||
minDeterminant 0.001;
|
||||
|
||||
//- minFaceWeight (0 -> 0.5)
|
||||
minFaceWeight 0.02;
|
||||
|
||||
//- minVolRatio (0 -> 1)
|
||||
minVolRatio 0.01;
|
||||
|
||||
//must be >0 for Fluent compatibility
|
||||
minTriangleTwist -1;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user