Commit 3c4200e6 authored by Andrew Heather's avatar Andrew Heather
Browse files

update to make extrusion run-time selectable

parent 934b0769
#!/bin/sh
set -x
wclean libso extrudeModel
wclean
#!/bin/sh
set -x
wmake libso extrudeModel
wmake
EXE_INC = \
-IextrudedMesh \
-IextrudeModel/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ldynamicMesh
-ldynamicMesh \
-lextrudeModel
......@@ -3,6 +3,6 @@
Time runTimeExtruded
(
Time::controlDictName,
rootDirTarget,
caseDirTarget
args.rootPath(),
args.caseName()
);
......@@ -23,39 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Extrude mesh from existing patch or from patch read from file. Merges close
points so be careful.
Extrude mesh from existing patch or from patch read from file.
Note: Merges close points so be careful.
Can do wedges:
- use wedgeExtruder instead of e.g. linearNormalExtruder
- extrusion is opposite the surface/patch normal so inwards the source
mesh
- axis direction has to be consistent with this.
- use -mergeFaces option if doing full 360 and want to merge front and back
E.g. starting from 'movingWall' patch of cavity tutorial:
- we want to rotate around the left side of this patch (is at x=0,y=0.1)
for a full 360 degrees:
wedgeExtruder
(
point(0,0.1,0), // point on axis
vector(0,0,-1), // (normalized!) direction of axis
360.0/180.0*mathematicalConstant::pi // angle
)
- note direction of axis. This should be consistent with rotating against
the patch normal direction. If you get it wrong you'll see all cells
with extreme aspect ratio and internal faces wrong way around in
checkMesh
- call with e.g. 10 layers. Thickness argument (0.1) is not used!
extrudeMesh <root> <case> 10 0.1 \
-sourceRoot $FOAM_TUTORIALS/icoFoam \
-sourceCase cavity \
-sourcePatch movingWall
-mergeFaces
Type of extrusion prescribed by run-time selectable model.
\*---------------------------------------------------------------------------*/
......@@ -72,10 +43,7 @@ Description
#include "perfectInterface.H"
#include "extrudedMesh.H"
#include "linearNormalExtruder.H"
#include "linearRadialExtruder.H"
#include "sigmaRadialExtruder.H"
#include "wedgeExtruder.H"
#include "extrudeModel.H"
using namespace Foam;
......@@ -99,6 +67,23 @@ int main(int argc, char *argv[])
autoPtr<extrudedMesh> meshPtr(NULL);
autoPtr<extrudeModel> model
(
extrudeModel::New
(
IOdictionary
(
IOobject
(
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
)
)
);
if (args.options().found("sourceRoot"))
{
fileName rootDirSource(args.options()["sourceRoot"]);
......@@ -115,7 +100,6 @@ int main(int argc, char *argv[])
rootDirSource,
caseDirSource
);
# include "createPolyMesh.H"
label patchID = mesh.boundaryMesh().findPatchID(patchName);
......@@ -153,20 +137,7 @@ int main(int argc, char *argv[])
runTimeExtruded
),
pp,
nLayers, // number of layers
linearNormalExtruder(-thickness) // overall thickness(signed!)
//wedgeExtruder
//(
// point(0,0.1,0), // point on axis
// vector(0,0,-1), // (normalized!) direction of axis
// 360.0/180.0*mathematicalConstant::pi // angle
//)
//wedgeExtruder
//(
// point(0,0,0), // point on axis
// vector(0,1,0), // (normalized!) direction of axis
// 30.0/180.0*mathematicalConstant::pi // angle
//)
model()
)
);
}
......@@ -198,12 +169,10 @@ int main(int argc, char *argv[])
runTimeExtruded
),
fMesh,
nLayers, // number of layers
linearNormalExtruder(-thickness) // overall thickness (signed!)
model()
)
);
}
extrudedMesh& mesh = meshPtr();
......
extrudeModel/extrudeModel.C
extrudeModel/newExtrudeModel.C
linearNormal/linearNormal.C
linearRadial/linearRadial.C
sigmaRadial/sigmaRadial.C
wedge/wedge.C
LIB = $(FOAM_LIBBIN)/libextrudeModel
EXE_INC = \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ldynamicMesh
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "extrudeModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(extrudeModel, 0);
defineRunTimeSelectionTable(extrudeModel, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::extrudeModel::extrudeModel
(
const word& modelType,
const dictionary& dict
)
:
nLayers_(readLabel(dict.lookup("nLayers"))),
dict_(dict),
coeffDict_(dict.subDict(modelType + "Coeffs"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::extrudeModel::~extrudeModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::extrudeModel::nLayers() const
{
return nLayers_;
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::extrudeModel
Description
Top level extrusion model class
SourceFiles
extrudeModel.C
\*---------------------------------------------------------------------------*/
#ifndef extrudeModel_H
#define extrudeModel_H
#include "dictionary.H"
#include "point.H"
#include "autoPtr.H"
#include "runTimeSelectionTables.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class extrudeModel Declaration
\*---------------------------------------------------------------------------*/
class extrudeModel
{
protected:
// Protected data
const label nLayers_;
const dictionary& dict_;
const dictionary& coeffDict_;
// Private Member Functions
//- Disallow default bitwise copy construct
extrudeModel(const extrudeModel&);
//- Disallow default bitwise assignment
void operator=(const extrudeModel&);
public:
//- Runtime type information
TypeName("extrudeModel");
//- Declare runtime constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
extrudeModel,
dictionary,
(
const dictionary& dict
),
(dict)
);
// Constructors
//- Construct from dictionary
extrudeModel(const word& modelType, const dictionary&);
// Selectors
//- Select null constructed
static autoPtr<extrudeModel> New(const dictionary&);
//- Destructor
virtual ~extrudeModel();
// Member Functions
// Access
label nLayers() const;
// Member Operators
virtual point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::extrudeModel> Foam::extrudeModel::New
(
const dictionary& dict
)
{
word extrudeModelType(dict.lookup("extrudeModel"));
Info<< "Selecting extrudeModel " << extrudeModelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(extrudeModelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn("extrudeModel::New(const dictionary&)")
<< "Unknown extrudeModelType type "
<< extrudeModelType
<< ", constructor not in hash table" << nl << nl
<< " Valid extrudeModel types are :" << nl
<< dictionaryConstructorTablePtr_->toc() << nl
<< exit(FatalError);
}
return autoPtr<extrudeModel>(cstrIter()(dict));
}
// ************************************************************************* //
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "linearNormal.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearNormal, 0);
addToRunTimeSelectionTable(extrudeModel, linearNormal, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearNormal::linearNormal(const dictionary& dict)
:
extrudeModel(typeName, dict),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearNormal::~linearNormal()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearNormal::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
scalar d = thickness_*layer/nLayers_;
return surfacePoint + d*surfaceNormal;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //
......@@ -23,27 +23,33 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::linearNormalExtruder
Foam::extrudeModels::linearNormal
Description
Extrudes by transforming points normal to the surface by a given distance
\*---------------------------------------------------------------------------*/
#ifndef linearNormalExtruder_H
#define linearNormalExtruder_H
#ifndef linearNormal_H
#define linearNormal_H
#include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearNormalExtruder Declaration
Class linearNormal Declaration
\*---------------------------------------------------------------------------*/
class linearNormalExtruder
class linearNormal
:
public extrudeModel
{
// Private data
......@@ -53,13 +59,17 @@ class linearNormalExtruder
public:
//- Runtime type information
TypeName("linearNormal");
// Constructors
//- Construct from components
linearNormalExtruder(const scalar thickness)
:
thickness_(thickness)
{}
linearNormal(const dictionary& dict);
//- Destructor
~linearNormal();
// Member Operators
......@@ -68,19 +78,14 @@ public:
(
const point& surfacePoint,
const vector& surfaceNormal,
const label nLayers,
const label layer
) const
{