ENH: Add automatic feature extraction to foamyHexMesh

This commit is contained in:
laurence
2013-05-13 10:24:03 +01:00
parent f9372806da
commit 9a5b9e6ba2
12 changed files with 1088 additions and 409 deletions

View File

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "searchableBoxFeatures.H"
#include "addToRunTimeSelectionTable.H"
#include "treeBoundBox.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(searchableBoxFeatures, 0);
addToRunTimeSelectionTable
(
searchableSurfaceFeatures,
searchableBoxFeatures,
dict
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableBoxFeatures::searchableBoxFeatures
(
const searchableSurface& surface,
const dictionary& dict
)
:
searchableSurfaceFeatures(surface, dict),
mode_(extendedFeatureEdgeMesh::sideVolumeTypeNames_[dict.lookup("mode")])
{
Info<< indent
<< " Mesh mode = "
<< extendedFeatureEdgeMesh::sideVolumeTypeNames_[mode_]
<< endl;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableBoxFeatures::~searchableBoxFeatures()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::extendedFeatureEdgeMesh>
Foam::searchableBoxFeatures::features() const
{
autoPtr<extendedFeatureEdgeMesh> features;
vectorField faceNormals(List<vector>(treeBoundBox::faceNormals));
vectorField edgeDirections(12);
labelListList normalDirections(12);
labelListList edgeNormals(12);
forAll(edgeNormals, eI)
{
edgeNormals[eI].setSize(2, 0);
}
edgeNormals[0][0] = 2; edgeNormals[0][1] = 4;
edgeNormals[1][0] = 1; edgeNormals[1][1] = 4;
edgeNormals[2][0] = 3; edgeNormals[2][1] = 4;
edgeNormals[3][0] = 0; edgeNormals[3][1] = 4;
edgeNormals[4][0] = 2; edgeNormals[4][1] = 5;
edgeNormals[5][0] = 1; edgeNormals[5][1] = 5;
edgeNormals[6][0] = 3; edgeNormals[6][1] = 5;
edgeNormals[7][0] = 0; edgeNormals[7][1] = 5;
edgeNormals[8][0] = 0; edgeNormals[8][1] = 2;
edgeNormals[9][0] = 2; edgeNormals[9][1] = 1;
edgeNormals[10][0] = 1; edgeNormals[10][1] = 3;
edgeNormals[11][0] = 3; edgeNormals[11][1] = 0;
forAll(edgeDirections, eI)
{
edgeDirections[eI] =
surface().points()()[treeBoundBox::edges[eI].end()]
- surface().points()()[treeBoundBox::edges[eI].start()];
normalDirections[eI] = labelList(2, 0);
for (label j = 0; j < 2; ++j)
{
const vector cross =
(faceNormals[edgeNormals[eI][j]] ^ edgeDirections[eI]);
const vector fC0tofE0 =
0.5*(max(surface().points()() + min(surface().points()())))
- surface().points()()[treeBoundBox::edges[eI].start()];
normalDirections[eI][j] =
(
(
(cross/(mag(cross) + VSMALL))
& (fC0tofE0/(mag(fC0tofE0)+ VSMALL))
)
> 0.0
? 1
: -1
);
}
}
labelListList featurePointNormals(8);
labelListList featurePointEdges(8);
forAll(featurePointNormals, pI)
{
labelList& ftPtEdges = featurePointEdges[pI];
ftPtEdges.setSize(3, 0);
label edgeI = 0;
forAll(treeBoundBox::edges, eI)
{
const edge& e = treeBoundBox::edges[eI];
if (e.start() == pI)
{
ftPtEdges[edgeI++] = eI;
}
else if (e.end() == pI)
{
ftPtEdges[edgeI++] = eI;
}
}
labelList& ftPtNormals = featurePointNormals[pI];
ftPtNormals.setSize(3, 0);
ftPtNormals[0] = edgeNormals[ftPtEdges[0]][0];
ftPtNormals[1] = edgeNormals[ftPtEdges[0]][1];
ftPtNormals[2] = edgeNormals[ftPtEdges[1]][0];
}
labelList regionEdges;
features.set
(
new extendedFeatureEdgeMesh
(
IOobject
(
surface().name(),
surface().instance(),
"extendedFeatureEdgeMesh",
surface().db(),
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surface().points(),
treeBoundBox::edges,
8, 8, 8,
12, 12, 12, 12,
faceNormals,
PackedList<2>(12, mode_), // Need to be input by user
edgeDirections,
normalDirections,
edgeNormals,
featurePointNormals,
featurePointEdges,
regionEdges
)
);
return features;
}
// ************************************************************************* //

View File

@ -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/>.
Class
Foam::searchableBoxFeatures
Description
SourceFiles
searchableBoxFeatures.C
\*---------------------------------------------------------------------------*/
#ifndef searchableBoxFeatures_H
#define searchableBoxFeatures_H
#include "searchableSurfaceFeatures.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class searchableBoxFeatures Declaration
\*---------------------------------------------------------------------------*/
class searchableBoxFeatures
:
public searchableSurfaceFeatures
{
private:
// Private Member Data
//- Which side of the box to mesh
const extendedFeatureEdgeMesh::sideVolumeType mode_;
// Private Member Functions
//- Disallow default bitwise copy construct
searchableBoxFeatures(const searchableBoxFeatures&);
//- Disallow default bitwise assignment
void operator=(const searchableBoxFeatures&);
public:
//- Runtime type information
TypeName("searchableBoxFeatures");
// Constructors
//- Construct from searchable surface and dictionary
searchableBoxFeatures
(
const searchableSurface& surface,
const dictionary& dict
);
//- Destructor
virtual ~searchableBoxFeatures();
// Member Functions
//- Return true for a searchable box having features
virtual bool hasFeatures() const
{
return true;
}
//- Return an extendedFeatureEdgeMesh containing the features
virtual autoPtr<extendedFeatureEdgeMesh> features() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,90 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "searchableSurfaceFeatures.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(searchableSurfaceFeatures, 0);
defineRunTimeSelectionTable(searchableSurfaceFeatures, dict);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::searchableSurfaceFeatures>
Foam::searchableSurfaceFeatures::New
(
const searchableSurface& surface,
const dictionary& dict
)
{
word searchableSurfaceFeaturesType = surface.type() + "Features";
dictConstructorTable::iterator cstrIter =
dictConstructorTablePtr_->find(searchableSurfaceFeaturesType);
if (cstrIter == dictConstructorTablePtr_->end())
{
FatalErrorIn
(
"searchableSurfaceFeatures::New(const word&,"
" const searchableSurface&, const dictionary&)"
) << "Unknown searchableSurfaceFeatures type "
<< searchableSurfaceFeaturesType << endl << endl
<< "Valid searchableSurfaceFeatures types : " << endl
<< dictConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<searchableSurfaceFeatures>(cstrIter()(surface, dict));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableSurfaceFeatures::searchableSurfaceFeatures
(
const searchableSurface& surface,
const dictionary& dict
)
:
surface_(surface),
dict_(dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableSurfaceFeatures::~searchableSurfaceFeatures()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::searchableSurfaceFeatures
Description
Decorator that returns the features of a searchable surface.
SourceFiles
searchableSurfaceFeatures.C
\*---------------------------------------------------------------------------*/
#ifndef searchableSurfaceFeatures_H
#define searchableSurfaceFeatures_H
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "searchableSurface.H"
#include "extendedFeatureEdgeMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class searchableSurfaceFeatures Declaration
\*---------------------------------------------------------------------------*/
class searchableSurfaceFeatures
{
// Private data
const searchableSurface& surface_;
const dictionary& dict_;
// Private Member Functions
//- Disallow default bitwise copy construct
searchableSurfaceFeatures(const searchableSurfaceFeatures&);
//- Disallow default bitwise assignment
void operator=(const searchableSurfaceFeatures&);
public:
//- Runtime type information
TypeName("searchableSurfaceFeatures");
// Declare run-time constructor selection table
// For the dictionary constructor
declareRunTimeSelectionTable
(
autoPtr,
searchableSurfaceFeatures,
dict,
(
const searchableSurface& surface,
const dictionary& dict
),
(surface, dict)
);
// Constructors
//- Construct from components
searchableSurfaceFeatures
(
const searchableSurface& surface,
const dictionary& dict
);
//- Clone
virtual autoPtr<searchableSurfaceFeatures> clone() const
{
notImplemented("autoPtr<searchableSurfaceFeatures> clone() const");
return autoPtr<searchableSurfaceFeatures>(NULL);
}
// Selectors
//- Return a reference to the selected searchableSurfaceFeatures
static autoPtr<searchableSurfaceFeatures> New
(
const searchableSurface& surface,
const dictionary& dict
);
//- Destructor
virtual ~searchableSurfaceFeatures();
// Member Functions
//- Return a reference to the searchable surface
const searchableSurface& surface() const
{
return surface_;
}
//- Return a reference to the dictionary
const dictionary& dict() const
{
return dict_;
}
//- Return whether this searchable surface has features
virtual bool hasFeatures() const = 0;
//- Return an extendedFeatureEdgeMesh containing the features
virtual autoPtr<extendedFeatureEdgeMesh> features() const
{
return autoPtr<extendedFeatureEdgeMesh>();
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,102 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "triSurfaceMeshFeatures.H"
#include "addToRunTimeSelectionTable.H"
#include "triSurfaceMesh.H"
#include "surfaceFeatures.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(triSurfaceMeshFeatures, 0);
addToRunTimeSelectionTable
(
searchableSurfaceFeatures,
triSurfaceMeshFeatures,
dict
);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::triSurfaceMeshFeatures::triSurfaceMeshFeatures
(
const searchableSurface& surface,
const dictionary& dict
)
:
searchableSurfaceFeatures(surface, dict),
includedAngle_(readScalar(dict.lookup("includedAngle")))
{
Info<< indent
<< " Included angle = " << includedAngle_
<< endl;
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::triSurfaceMeshFeatures::~triSurfaceMeshFeatures()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::extendedFeatureEdgeMesh>
Foam::triSurfaceMeshFeatures::features() const
{
autoPtr<extendedFeatureEdgeMesh> features;
const triSurfaceMesh& surfMesh = refCast<const triSurfaceMesh>(surface());
surfaceFeatures sFeat(surfMesh, includedAngle_);
boolList surfBaffleRegions(surfMesh.patches().size(), false);
features.set
(
new extendedFeatureEdgeMesh
(
sFeat,
surface().db(),
surface().name() + ".extendedFeatureEdgeMesh",
surfBaffleRegions
)
);
return features;
}
// ************************************************************************* //

View File

@ -0,0 +1,109 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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::triSurfaceMeshFeatures
Description
SourceFiles
triSurfaceMeshFeatures.C
\*---------------------------------------------------------------------------*/
#ifndef triSurfaceMeshFeatures_H
#define triSurfaceMeshFeatures_H
#include "searchableSurfaceFeatures.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class triSurfaceMeshFeatures Declaration
\*---------------------------------------------------------------------------*/
class triSurfaceMeshFeatures
:
public searchableSurfaceFeatures
{
private:
// Private Member Data
const scalar includedAngle_;
// Private Member Functions
//- Disallow default bitwise copy construct
triSurfaceMeshFeatures(const triSurfaceMeshFeatures&);
//- Disallow default bitwise assignment
void operator=(const triSurfaceMeshFeatures&);
public:
//- Runtime type information
TypeName("triSurfaceMeshFeatures");
// Constructors
//- Construct from dictionary (used by searchableSurface)
triSurfaceMeshFeatures
(
const searchableSurface& surface,
const dictionary& dict
);
//- Destructor
virtual ~triSurfaceMeshFeatures();
// Member Functions
//- Return true for a triSurfaceMesh having features
virtual bool hasFeatures() const
{
return true;
}
//- Return an extendedFeatureEdgeMesh containing the features
virtual autoPtr<extendedFeatureEdgeMesh> features() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //