Add the OpenFOAM source tree

This commit is contained in:
Henry
2014-12-10 22:40:10 +00:00
parent ee487c860d
commit 446e5777f0
13379 changed files with 3983377 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,267 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::polyMeshFilter
Description
Remove the edges and faces of a polyMesh whilst satisfying the given mesh
quality criteria.
Works on a copy of the mesh.
SourceFiles
polyMeshFilter.C
polyMeshFilterTemplates.C
\*---------------------------------------------------------------------------*/
#ifndef polyMeshFilter_H
#define polyMeshFilter_H
#include "IOdictionary.H"
#include "Time.H"
#include "List.H"
#include "autoPtr.H"
#include "scalarField.H"
#include "polyMeshFilterSettings.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class polyMesh;
class fvMesh;
class PackedBoolList;
class faceSet;
/*---------------------------------------------------------------------------*\
Class polyMeshFilter Declaration
\*---------------------------------------------------------------------------*/
class polyMeshFilter
:
private polyMeshFilterSettings
{
// Private data
//- Reference to the original mesh
const fvMesh& mesh_;
//- Copy of the original mesh to perform the filtering on
autoPtr<fvMesh> newMeshPtr_;
//- Original point priorities. If a point has a higher priority than
// another point then the edge between them collapses towards the
// point with the higher priority. (e.g. 2 is a higher priority than 1)
labelList originalPointPriority_;
//- Point priority associated with the new mesh
autoPtr<labelList> pointPriority_;
//- The minimum edge length for each edge
scalarField minEdgeLen_;
//- The face filter factor for each face
scalarField faceFilterFactor_;
// Private Member Functions
template<typename T>
static void updateSets(const mapPolyMesh& map);
template<typename T>
static void copySets(const polyMesh& oldMesh, const polyMesh& newMesh);
label filterFacesLoop(const label nOriginalBadFaces);
label filterFaces
(
polyMesh& newMesh,
scalarField& newMeshFaceFilterFactor,
labelList& origToCurrentPointMap
);
label filterEdges
(
polyMesh& newMesh,
scalarField& newMeshMinEdgeLen,
labelList& origToCurrentPointMap
);
//- Increment pointErrorCount for points attached to a bad face
void updatePointErrorCount
(
const PackedBoolList& isErrorPoint,
const labelList& oldToNewMesh,
labelList& pointErrorCount
) const;
//- Given the new points that are part of bad faces, and a map from the
// old mesh points to the new mesh points, relax minEdgeLen_
void checkMeshEdgesAndRelaxEdges
(
const polyMesh& newMesh,
const labelList& oldToNewMesh,
const PackedBoolList& isErrorPoint,
const labelList& pointErrorCount
);
//- Given the new points that are part of bad faces, and a map from the
// old mesh points to the new mesh points, relax faceFilterFactor_
void checkMeshFacesAndRelaxEdges
(
const polyMesh& newMesh,
const labelList& oldToNewMesh,
const PackedBoolList& isErrorPoint,
const labelList& pointErrorCount
);
// Mark boundary points
// boundaryPoint:
// + -1 : point not on boundary
// + 0 : point on a real boundary
// + >0 : point on a processor patch with that ID
// @todo Need to mark boundaryEdges as well, as an edge may have two
// boundary points but not itself lie on a boundary
void updatePointPriorities
(
const polyMesh& newMesh,
const labelList& pointMap
);
//- Print min/mean/max data for a field
void printScalarFieldStats
(
const string desc,
const scalarField& fld
) const;
//- Update minEdgeLen_ for the new mesh based upon the movement of the
// old points to the new points
void mapOldMeshEdgeFieldToNewMesh
(
const polyMesh& newMesh,
const labelList& pointMap,
scalarField& newMeshMinEdgeLen
) const;
//- Update faceFilterFactor_ for the new mesh based upon the movement
// of the old faces to the new faces
void mapOldMeshFaceFieldToNewMesh
(
const polyMesh& newMesh,
const labelList& faceMap,
scalarField& newMeshFaceFilterFactor
) const;
//- Maintain a map of the original mesh points to the latest version of
// the filtered mesh.
void updateOldToNewPointMap
(
const labelList& currToNew,
labelList& origToCurrentPointMap
) const;
//- Disallow default bitwise copy construct
polyMeshFilter(const polyMeshFilter&);
//- Disallow default bitwise assignment
void operator=(const polyMeshFilter&);
public:
//- Runtime type information
ClassName("polyMeshFilter");
// Constructors
//- Construct from fvMesh
explicit polyMeshFilter(const fvMesh& mesh);
//- Construct from fvMesh and a label list of point priorities
polyMeshFilter(const fvMesh& mesh, const labelList& pointPriority);
//- Destructor
~polyMeshFilter();
// Member Functions
// Access
//- Return reference to the filtered mesh. Does not check if the
// mesh has actually been filtered.
const autoPtr<fvMesh>& filteredMesh() const;
//- Return the new pointPriority list.
const autoPtr<labelList>& pointPriority() const;
// Edit
//- Return a copy of an fvMesh
static autoPtr<fvMesh> copyMesh(const fvMesh& mesh);
//- Copy loaded topoSets from the old mesh to the new mesh
static void copySets
(
const polyMesh& oldMesh,
const polyMesh& newMesh
);
//- Update the loaded topoSets
static void updateSets(const mapPolyMesh& map);
//- Filter edges and faces
label filter(const label nOriginalBadFaces);
//- Filter all faces that are in the face set
label filter(const faceSet& fSet);
//- Filter edges only.
label filterEdges(const label nOriginalBadFaces);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "polyMeshFilterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "polyMeshFilterSettings.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polyMeshFilterSettings::polyMeshFilterSettings(const dictionary& dict)
:
dict_(dict),
controlMeshQuality_
(
dict_.lookupOrDefault<Switch>("controlMeshQuality", false)
),
collapseEdgesCoeffDict_(dict_.subDict("collapseEdgesCoeffs")),
collapseFacesCoeffDict_(dict_.subOrEmptyDict("collapseFacesCoeffs")),
meshQualityCoeffDict_(dict_.subOrEmptyDict("controlMeshQualityCoeffs")),
minLen_(readScalar(collapseEdgesCoeffDict_.lookup("minimumEdgeLength"))),
maxCos_
(
::cos
(
degToRad
(
readScalar(collapseEdgesCoeffDict_.lookup("maximumMergeAngle"))
)
)
),
edgeReductionFactor_
(
meshQualityCoeffDict_.lookupOrDefault<scalar>("edgeReductionFactor", -1)
),
maxIterations_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>("maximumIterations", 1)
),
maxSmoothIters_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>
(
"maximumSmoothingIterations",
0
)
),
initialFaceLengthFactor_
(
collapseFacesCoeffDict_.lookupOrAddDefault<scalar>
(
"initialFaceLengthFactor",
-1
)
),
faceReductionFactor_
(
meshQualityCoeffDict_.lookupOrAddDefault<scalar>
(
"faceReductionFactor",
-1
)
),
maxPointErrorCount_
(
meshQualityCoeffDict_.lookupOrAddDefault<label>("maxPointErrorCount", 0)
)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::polyMeshFilterSettings::writeSettings(Ostream& os) const
{
os << "Merging:" << nl
<< " edges with length less than " << minLen() << " metres" << nl
<< " edges split by a point with edges in line to within "
<< radToDeg(::acos(maxCos())) << " degrees" << nl
<< " Minimum edge length reduction factor = "
<< edgeReductionFactor() << nl
<< endl;
if (collapseFacesCoeffDict().empty())
{
os << "Face collapsing is off" << endl;
}
else
{
os << "Face collapsing is on" << endl;
os << " Initial face length factor = "<< initialFaceLengthFactor()
<< endl;
}
os << "Control mesh quality = " << controlMeshQuality().asText() << endl;
if (controlMeshQuality())
{
os << " Minimum edge length reduction factor = "
<< edgeReductionFactor() << nl
<< " Minimum face area reduction factor = "
<< faceReductionFactor() << endl;
os << " Maximum number of collapse iterations = " << maxIterations()
<< endl;
os << " Maximum number of edge/face reduction factor smoothing "
<< "iterations = " << maxSmoothIters() << endl;
os << " Maximum number of times a point can contribute to bad "
<< "faces across " << nl
<< " collapse iterations = " << maxPointErrorCount()
<< endl;
}
os << "Selectively disabling wanted collapses until resulting quality"
<< " satisfies constraints in system/meshQualityDict" << nl
<< endl;
}
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::polyMeshFilterSettings
Description
Class to store the settings for the polyMeshFilter class.
SourceFiles
polyMeshFilterSettings.C
polyMeshFilterSettingsI.H
\*---------------------------------------------------------------------------*/
#ifndef polyMeshFilterSettings_H
#define polyMeshFilterSettings_H
#include "dictionary.H"
#include "Switch.H"
#include "scalar.H"
#include "label.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class polyMeshFilterSettings Declaration
\*---------------------------------------------------------------------------*/
class polyMeshFilterSettings
{
// Private data
//- Dictionary containing the coefficient sub-dictionaries
const dictionary dict_;
//- After collapsing, check the mesh quality and redo the collapsing
// iteration if there are too many bad faces in the mesh
Switch controlMeshQuality_;
//- Coefficients for collapsing edges
const dictionary& collapseEdgesCoeffDict_;
//- Coefficients for collapsing faces
dictionary collapseFacesCoeffDict_;
//- Coefficients for controlling the mesh quality
dictionary meshQualityCoeffDict_;
//- Remove edges shorter than this length
const scalar minLen_;
//- Merge points that are only attached to two edges and have an angle
// between the edge greater than this value
const scalar maxCos_;
//- The amount that the local minimum edge length will be reduced by if
// the edge is part of a collapse string that generates poor quality
// faces
const scalar edgeReductionFactor_;
//- Maximum number of outer iterations
const label maxIterations_;
//- Maximum number of smoothing iterations of minEdgeLen_ and
// faceFilterFactor_
const label maxSmoothIters_;
//- Initialisation value of faceFilterFactor_
const scalar initialFaceLengthFactor_;
//- The amount that the local face size factor will be reduced by if
// the face is part of a collapse string that generates poor quality
// faces
const scalar faceReductionFactor_;
//- Maximum number of times a deleted point can be associated with the
// creation of a bad face it is forced to be kept.
const label maxPointErrorCount_;
public:
// Constructors
//- Construct from dictionary
explicit polyMeshFilterSettings(const dictionary& dict);
//- Destructor
~polyMeshFilterSettings(){};
// Member Functions
// Access
inline const dictionary& collapseEdgesCoeffDict() const;
inline const dictionary& collapseFacesCoeffDict() const;
inline const dictionary& meshQualityCoeffDict() const;
inline const Switch& controlMeshQuality() const;
inline const scalar& minLen() const;
inline const scalar& maxCos() const;
inline const scalar& edgeReductionFactor() const;
inline const label& maxIterations() const;
inline const label& maxSmoothIters() const;
inline const scalar& initialFaceLengthFactor() const;
inline const scalar& faceReductionFactor() const;
inline const label& maxPointErrorCount() const;
// Write
//- Write the settings to a stream
void writeSettings(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "polyMeshFilterSettingsI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::dictionary&
Foam::polyMeshFilterSettings::collapseEdgesCoeffDict() const
{
return collapseEdgesCoeffDict_;
}
inline const Foam::dictionary&
Foam::polyMeshFilterSettings::collapseFacesCoeffDict() const
{
return collapseFacesCoeffDict_;
}
inline const Foam::dictionary&
Foam::polyMeshFilterSettings::meshQualityCoeffDict() const
{
return meshQualityCoeffDict_;
}
inline const Foam::Switch&
Foam::polyMeshFilterSettings::controlMeshQuality() const
{
return controlMeshQuality_;
}
inline const Foam::scalar& Foam::polyMeshFilterSettings::minLen() const
{
return minLen_;
}
inline const Foam::scalar& Foam::polyMeshFilterSettings::maxCos() const
{
return maxCos_;
}
inline const Foam::scalar&
Foam::polyMeshFilterSettings::edgeReductionFactor() const
{
return edgeReductionFactor_;
}
inline const Foam::label& Foam::polyMeshFilterSettings::maxIterations() const
{
return maxIterations_;
}
inline const Foam::label& Foam::polyMeshFilterSettings::maxSmoothIters() const
{
return maxSmoothIters_;
}
inline const Foam::scalar&
Foam::polyMeshFilterSettings::initialFaceLengthFactor() const
{
return initialFaceLengthFactor_;
}
inline const Foam::scalar&
Foam::polyMeshFilterSettings::faceReductionFactor() const
{
return faceReductionFactor_;
}
inline const Foam::label&
Foam::polyMeshFilterSettings::maxPointErrorCount() const
{
return maxPointErrorCount_;
}
// ************************************************************************* //

View File

@ -0,0 +1,105 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "polyMeshFilter.H"
#include "polyMesh.H"
#include "mapPolyMesh.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
template<typename SetType>
void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
{
HashTable<const SetType*> sets =
map.mesh().objectRegistry::lookupClass<const SetType>();
forAllIter(typename HashTable<const SetType*>, sets, iter)
{
SetType& set = const_cast<SetType&>(*iter());
set.updateMesh(map);
set.sync(map.mesh());
}
IOobjectList Objects
(
map.mesh().time(),
map.mesh().facesInstance(),
"polyMesh/sets"
);
IOobjectList fileSets(Objects.lookupClass(SetType::typeName));
forAllConstIter(IOobjectList, fileSets, iter)
{
if (!sets.found(iter.key()))
{
// Not in memory. Load it.
SetType set(*iter());
set.updateMesh(map);
set.write();
}
}
}
template<typename SetType>
void Foam::polyMeshFilter::copySets
(
const polyMesh& oldMesh,
const polyMesh& newMesh
)
{
HashTable<const SetType*> sets =
oldMesh.objectRegistry::lookupClass<const SetType>();
forAllConstIter(typename HashTable<const SetType*>, sets, iter)
{
const SetType& set = *iter();
if (newMesh.objectRegistry::foundObject<SetType>(set.name()))
{
const SetType& origSet =
newMesh.objectRegistry::lookupObject<SetType>(set.name());
const_cast<SetType&>(origSet) = set;
const_cast<SetType&>(origSet).sync(newMesh);
}
else
{
SetType* newSet
(
new SetType(newMesh, set.name(), set, set.writeOpt())
);
newSet->store();
newSet->sync(newMesh);
}
}
}
// ************************************************************************* //