update to make extrusion run-time selectable

This commit is contained in:
andy
2008-06-30 11:09:38 +01:00
parent 934b076910
commit 3c4200e62e
24 changed files with 887 additions and 259 deletions

View File

@ -0,0 +1,6 @@
#!/bin/sh
set -x
wclean libso extrudeModel
wclean

View File

@ -0,0 +1,6 @@
#!/bin/sh
set -x
wmake libso extrudeModel
wmake

View File

@ -1,3 +1,4 @@
extrudeMesh.C extrudeMesh.C
EXE = $(FOAM_APPBIN)/extrudeMesh EXE = $(FOAM_APPBIN)/extrudeMesh

View File

@ -1,8 +1,11 @@
EXE_INC = \ EXE_INC = \
-IextrudedMesh \ -IextrudedMesh \
-IextrudeModel/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude \ -I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude -I$(FOAM_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-ldynamicMesh -ldynamicMesh \
-lextrudeModel

View File

@ -3,6 +3,6 @@
Time runTimeExtruded Time runTimeExtruded
( (
Time::controlDictName, Time::controlDictName,
rootDirTarget, args.rootPath(),
caseDirTarget args.caseName()
); );

View File

@ -23,39 +23,10 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description Description
Extrude mesh from existing patch or from patch read from file. Merges close Extrude mesh from existing patch or from patch read from file.
points so be careful. Note: Merges close points so be careful.
Can do wedges: Type of extrusion prescribed by run-time selectable model.
- 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
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -72,10 +43,7 @@ Description
#include "perfectInterface.H" #include "perfectInterface.H"
#include "extrudedMesh.H" #include "extrudedMesh.H"
#include "linearNormalExtruder.H" #include "extrudeModel.H"
#include "linearRadialExtruder.H"
#include "sigmaRadialExtruder.H"
#include "wedgeExtruder.H"
using namespace Foam; using namespace Foam;
@ -99,6 +67,23 @@ int main(int argc, char *argv[])
autoPtr<extrudedMesh> meshPtr(NULL); autoPtr<extrudedMesh> meshPtr(NULL);
autoPtr<extrudeModel> model
(
extrudeModel::New
(
IOdictionary
(
IOobject
(
"extrudeProperties",
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::MUST_READ
)
)
)
);
if (args.options().found("sourceRoot")) if (args.options().found("sourceRoot"))
{ {
fileName rootDirSource(args.options()["sourceRoot"]); fileName rootDirSource(args.options()["sourceRoot"]);
@ -115,7 +100,6 @@ int main(int argc, char *argv[])
rootDirSource, rootDirSource,
caseDirSource caseDirSource
); );
# include "createPolyMesh.H" # include "createPolyMesh.H"
label patchID = mesh.boundaryMesh().findPatchID(patchName); label patchID = mesh.boundaryMesh().findPatchID(patchName);
@ -153,20 +137,7 @@ int main(int argc, char *argv[])
runTimeExtruded runTimeExtruded
), ),
pp, pp,
nLayers, // number of layers model()
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
//)
) )
); );
} }
@ -198,12 +169,10 @@ int main(int argc, char *argv[])
runTimeExtruded runTimeExtruded
), ),
fMesh, fMesh,
nLayers, // number of layers model()
linearNormalExtruder(-thickness) // overall thickness (signed!)
) )
); );
} }
extrudedMesh& mesh = meshPtr(); extrudedMesh& mesh = meshPtr();

View File

@ -0,0 +1,9 @@
extrudeModel/extrudeModel.C
extrudeModel/newExtrudeModel.C
linearNormal/linearNormal.C
linearRadial/linearRadial.C
sigmaRadial/sigmaRadial.C
wedge/wedge.C
LIB = $(FOAM_LIBBIN)/libextrudeModel

View File

@ -0,0 +1,8 @@
EXE_INC = \
-I$(FOAM_SRC)/meshTools/lnInclude \
-I$(FOAM_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lmeshTools \
-ldynamicMesh

View File

@ -0,0 +1,66 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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_;
}
// ************************************************************************* //

View File

@ -0,0 +1,136 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -0,0 +1,59 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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));
}
// ************************************************************************* //

View File

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
// ************************************************************************* //

View File

@ -23,27 +23,33 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::linearNormalExtruder Foam::extrudeModels::linearNormal
Description Description
Extrudes by transforming points normal to the surface by a given distance
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef linearNormalExtruder_H #ifndef linearNormal_H
#define linearNormalExtruder_H #define linearNormal_H
#include "point.H" #include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class linearNormalExtruder Declaration Class linearNormal Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class linearNormalExtruder class linearNormal
:
public extrudeModel
{ {
// Private data // Private data
@ -53,13 +59,17 @@ class linearNormalExtruder
public: public:
//- Runtime type information
TypeName("linearNormal");
// Constructors // Constructors
//- Construct from components //- Construct from components
linearNormalExtruder(const scalar thickness) linearNormal(const dictionary& dict);
:
thickness_(thickness)
{} //- Destructor
~linearNormal();
// Member Operators // Member Operators
@ -68,19 +78,14 @@ public:
( (
const point& surfacePoint, const point& surfacePoint,
const vector& surfaceNormal, const vector& surfaceNormal,
const label nLayers,
const label layer const label layer
) const ) const;
{
scalar d = thickness_*layer/nLayers;
return surfacePoint + d*surfaceNormal;
}
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -88,3 +93,4 @@ public:
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,82 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "linearRadial.H"
#include "addToRunTimeSelectionTable.H"
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearRadial, 0);
addToRunTimeSelectionTable(extrudeModel, linearRadial, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearRadial::linearRadial(const dictionary& dict)
:
extrudeModel(typeName, dict),
R_(readScalar(coeffDict_.lookup("R")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearRadial::~linearRadial()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearRadial::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
// radius of the surface
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
scalar delta = (R_ - rs)/nLayers_;
scalar r = rs + layer*delta;
return r*rsHat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,27 +23,31 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::linearRadialExtruder Foam::extrudeModels::linearRadial
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef linearRadialExtruder_H #ifndef linearRadial_H
#define linearRadialExtruder_H #define linearRadial_H
#include "point.H" #include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class linearRadialExtruder Declaration Class linearRadial Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class linearRadialExtruder class linearRadial
:
public extrudeModel
{ {
// Private data // Private data
@ -52,13 +56,17 @@ class linearRadialExtruder
public: public:
//- Runtime type information
TypeName("linearRadial");
// Constructors // Constructors
//- Construct from components //- Construct from components
linearRadialExtruder(const scalar R) linearRadial(const dictionary& dict);
:
R_(R)
{} //- Destructor
~linearRadial();
// Member Operators // Member Operators
@ -67,23 +75,14 @@ public:
( (
const point& surfacePoint, const point& surfacePoint,
const vector& surfaceNormal, const vector& surfaceNormal,
const label nLayers,
const label layer const label layer
) const ) const;
{
// radius of the surface
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
scalar delta = (R_ - rs)/nLayers;
scalar r = rs + layer*delta;
return r*rsHat;
}
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -91,3 +90,4 @@ public:
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "sigmaRadial.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(sigmaRadial, 0);
addToRunTimeSelectionTable(extrudeModel, sigmaRadial, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
sigmaRadial::sigmaRadial(const dictionary& dict)
:
extrudeModel(typeName, dict),
RTbyg_(readScalar(coeffDict_.lookup("RTbyg"))),
pRef_(readScalar(coeffDict_.lookup("pRef"))),
pStrat_(readScalar(coeffDict_.lookup("pStrat")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
sigmaRadial::~sigmaRadial()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point sigmaRadial::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
// radius of the surface
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
scalar p = pRef_ - layer*(pRef_ - pStrat_)/nLayers_;
scalar r = rs - RTbyg_*log(p/pRef_);
return r*rsHat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,27 +23,31 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::sigmaRadialExtruder Foam::extrudeModels::sigmaRadial
Description Description
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef sigmaRadialExtruder_H #ifndef sigmaRadial_H
#define sigmaRadialExtruder_H #define sigmaRadial_H
#include "point.H" #include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class sigmaRadialExtruder Declaration Class sigmaRadial Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class sigmaRadialExtruder class sigmaRadial
:
public extrudeModel
{ {
// Private data // Private data
@ -54,20 +58,17 @@ class sigmaRadialExtruder
public: public:
//- Runtime type information
TypeName("sigmaRadial");
// Constructors // Constructors
//- Construct from components //- Construct from components
sigmaRadialExtruder sigmaRadial(const dictionary& dict);
(
const scalar RTbyg,
const scalar pRef, //-Destructor
const scalar pStrat ~sigmaRadial();
)
:
RTbyg_(RTbyg),
pRef_(pRef),
pStrat_(pStrat)
{}
// Member Operators // Member Operators
@ -76,24 +77,14 @@ public:
( (
const point& surfacePoint, const point& surfacePoint,
const vector& surfaceNormal, const vector& surfaceNormal,
const label nLayers,
const label layer const label layer
) const ) const;
{
// radius of the surface
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
scalar p = pRef_ - layer*(pRef_ - pStrat_)/nLayers;
scalar r = rs - RTbyg_*Foam::log(p/pRef_);
return r*rsHat;
}
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -101,3 +92,4 @@ public:
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,127 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "wedge.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(wedge, 0);
addToRunTimeSelectionTable(extrudeModel, wedge, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
wedge::wedge(const dictionary& dict)
:
extrudeModel(typeName, dict),
axisPt_(coeffDict_.lookup("axisPt")),
axisNormal_(coeffDict_.lookup("axisNormal")),
angle_
(
readScalar(coeffDict_.lookup("angle"))
*mathematicalConstant::pi/180.0
)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
wedge::~wedge()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point wedge::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
scalar sliceAngle;
// For the case of a single layer extrusion assume a
// symmetric wedge about the reference plane is required
if (nLayers_ == 1)
{
if (layer == 0)
{
sliceAngle = -angle_/2.0;
}
else
{
sliceAngle = angle_/2.0;
}
}
else
{
sliceAngle = angle_*(layer + 1)/nLayers_;
}
// Find projection onto axis (or rather decompose surfacePoint
// into vector along edge (proj), vector normal to edge in plane
// of surface point and surface normal.
point d = surfacePoint - axisPt_;
d -= (axisNormal_ & d)*axisNormal_;
scalar dMag = mag(d);
point edgePt = surfacePoint - d;
// Rotate point around sliceAngle.
point rotatedPoint = edgePt;
if (dMag > VSMALL)
{
vector n = (d/dMag) ^ axisNormal_;
rotatedPoint +=
+ cos(sliceAngle)*d
- sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
}
return rotatedPoint;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,29 +23,40 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class Class
Foam::wedgeExtruder Foam::extrudeModels::wedge
Description Description
Extrudes by rotating a surface around an axis Extrudes by rotating a surface around an axis
- 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
- 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
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef wedgeExtruder_H #ifndef wedge_H
#define wedgeExtruder_H #define wedge_H
#include "point.H" #include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class wedgeExtruder Declaration Class wedge Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class wedgeExtruder class wedge
:
public extrudeModel
{ {
// Private data // Private data
@ -58,22 +69,19 @@ class wedgeExtruder
//- overall angle (radians) //- overall angle (radians)
const scalar angle_; const scalar angle_;
public: public:
//- Runtime type information
TypeName("wedge");
// Constructors // Constructors
//- Construct from components //- Construct from components
wedgeExtruder wedge(const dictionary& dict);
(
const point& axisPt, //- Destrcuctor
const point& axisNormal, ~wedge();
const scalar angle
)
:
axisPt_(axisPt),
axisNormal_(axisNormal),
angle_(angle)
{}
// Member Operators // Member Operators
@ -82,60 +90,14 @@ public:
( (
const point& surfacePoint, const point& surfacePoint,
const vector& surfaceNormal, const vector& surfaceNormal,
const label nLayers,
const label layer const label layer
) const ) const;
{
scalar sliceAngle;
// For the case of a single layer extrusion assume a
// symmetric wedge about the reference plane is required
if (nLayers == 1)
{
if (layer == 0)
{
sliceAngle = -angle_/2.0;
}
else
{
sliceAngle = angle_/2.0;
}
}
else
{
sliceAngle = angle_ * (layer+1)/nLayers;
}
// Find projection onto axis (or rather decompose surfacePoint
// into vector along edge (proj), vector normal to edge in plane
// of surface point and surface normal.
point d = surfacePoint - axisPt_;
d -= (axisNormal_&d)*axisNormal_;
scalar dMag = mag(d);
point edgePt = surfacePoint - d;
// Rotate point around sliceAngle.
point rotatedPoint = edgePt;
if (dMag > VSMALL)
{
vector n = (d/dMag) ^ axisNormal_;
rotatedPoint +=
+ cos(sliceAngle)*d
- sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
}
return rotatedPoint;
}
}; };
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -0,0 +1,50 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.5 |
| \\ / A nd | Web: http://www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object extrudeProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
extrudeModel wedge;
//extrudeModel linearNormal;
//extrudeModel linearRadial;
//extrudeModel sigmaRadial;
nLayers 1;
wedgeCoeffs
{
axisPt (0 0 0);
axisNormal (0 -1 0);
angle 2.0;
}
linearNormalCoeffs
{
thickness 0.1;
}
linearRadialCoeffs
{
R 0.1;
}
sigmaRadialCoeffs
{
RTbyg 1;
pRef 1;
pStrat 1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -46,19 +46,19 @@ template
< <
class Face, class Face,
template<class> class FaceList, template<class> class FaceList,
class PointField, class PointField
class PointExtruder
> >
Foam::pointField Foam::extrudedMesh::extrudedPoints Foam::pointField Foam::extrudedMesh::extrudedPoints
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers, const extrudeModel& model
const PointExtruder& extruder
) )
{ {
const pointField& surfacePoints = extrudePatch.localPoints(); const pointField& surfacePoints = extrudePatch.localPoints();
const vectorField& surfaceNormals = extrudePatch.pointNormals(); const vectorField& surfaceNormals = extrudePatch.pointNormals();
const label nLayers = model.nLayers();
pointField ePoints((nLayers + 1)*surfacePoints.size()); pointField ePoints((nLayers + 1)*surfacePoints.size());
for (label layer=0; layer<=nLayers; layer++) for (label layer=0; layer<=nLayers; layer++)
@ -67,11 +67,10 @@ Foam::pointField Foam::extrudedMesh::extrudedPoints
forAll(surfacePoints, i) forAll(surfacePoints, i)
{ {
ePoints[offset + i] = extruder ePoints[offset + i] = model
( (
surfacePoints[i], surfacePoints[i],
surfaceNormals[i], surfaceNormals[i],
nLayers,
layer layer
); );
} }
@ -85,7 +84,7 @@ template<class Face, template<class> class FaceList, class PointField>
Foam::faceList Foam::extrudedMesh::extrudedFaces Foam::faceList Foam::extrudedMesh::extrudedFaces
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers const extrudeModel& model
) )
{ {
const pointField& surfacePoints = extrudePatch.localPoints(); const pointField& surfacePoints = extrudePatch.localPoints();
@ -93,6 +92,8 @@ Foam::faceList Foam::extrudedMesh::extrudedFaces
const edgeList& surfaceEdges = extrudePatch.edges(); const edgeList& surfaceEdges = extrudePatch.edges();
const label nInternalEdges = extrudePatch.nInternalEdges(); const label nInternalEdges = extrudePatch.nInternalEdges();
const label nLayers = model.nLayers();
label nFaces = label nFaces =
(nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size(); (nLayers + 1)*surfaceFaces.size() + nLayers*surfaceEdges.size();
@ -184,13 +185,15 @@ template<class Face, template<class> class FaceList, class PointField>
Foam::cellList Foam::extrudedMesh::extrudedCells Foam::cellList Foam::extrudedMesh::extrudedCells
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers const extrudeModel& model
) )
{ {
const List<face>& surfaceFaces = extrudePatch.localFaces(); const List<face>& surfaceFaces = extrudePatch.localFaces();
const edgeList& surfaceEdges = extrudePatch.edges(); const edgeList& surfaceEdges = extrudePatch.edges();
const label nInternalEdges = extrudePatch.nInternalEdges(); const label nInternalEdges = extrudePatch.nInternalEdges();
const label nLayers = model.nLayers();
cellList eCells(nLayers*surfaceFaces.size()); cellList eCells(nLayers*surfaceFaces.size());
// Size the cells // Size the cells
@ -290,30 +293,31 @@ template
< <
class Face, class Face,
template<class> class FaceList, template<class> class FaceList,
class PointField, class PointField
class PointExtruder
> >
Foam::extrudedMesh::extrudedMesh Foam::extrudedMesh::extrudedMesh
( (
const IOobject& io, const IOobject& io,
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers, const extrudeModel& model
const PointExtruder& extruder
) )
: :
polyMesh polyMesh
( (
io, io,
extrudedPoints(extrudePatch, nLayers, extruder), extrudedPoints(extrudePatch, model),
extrudedFaces(extrudePatch, nLayers), extrudedFaces(extrudePatch, model),
extrudedCells(extrudePatch, nLayers) extrudedCells(extrudePatch, model)
) ),
model_(model)
{ {
List<polyPatch*> patches(3); List<polyPatch*> patches(3);
label facei = nInternalFaces(); label facei = nInternalFaces();
label sz = nLayers*(extrudePatch.nEdges() - extrudePatch.nInternalEdges()); label sz =
model_.nLayers()
*(extrudePatch.nEdges() - extrudePatch.nInternalEdges());
patches[0] = new wallPolyPatch patches[0] = new wallPolyPatch
( (
@ -351,3 +355,4 @@ Foam::extrudedMesh::extrudedMesh
// ************************************************************************* // // ************************************************************************* //

View File

@ -36,6 +36,7 @@ SourceFiles
#define extrudedMesh_H #define extrudedMesh_H
#include "polyMesh.H" #include "polyMesh.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -50,24 +51,22 @@ class extrudedMesh
: :
public polyMesh public polyMesh
{ {
// Private data
const extrudeModel& model_;
// Private Member Functions // Private Member Functions
//- Do edge and face use points in same order? //- Do edge and face use points in same order?
static bool sameOrder(const face&, const edge&); static bool sameOrder(const face&, const edge&);
//- Construct and return the extruded mesh points //- Construct and return the extruded mesh points
template template<class Face, template<class> class FaceList, class PointField>
<
class Face,
template<class> class FaceList,
class PointField,
class PointExtruder
>
pointField extrudedPoints pointField extrudedPoints
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers, const extrudeModel& model
const PointExtruder& extruder
); );
//- Construct and return the extruded mesh faces //- Construct and return the extruded mesh faces
@ -75,7 +74,7 @@ class extrudedMesh
faceList extrudedFaces faceList extrudedFaces
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers const extrudeModel& model
); );
//- Construct and return the extruded mesh cells //- Construct and return the extruded mesh cells
@ -83,7 +82,7 @@ class extrudedMesh
cellList extrudedCells cellList extrudedCells
( (
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers const extrudeModel& model
); );
@ -99,19 +98,12 @@ public:
// Constructors // Constructors
//- Construct from the primitivePatch to extrude //- Construct from the primitivePatch to extrude
template template<class Face, template<class> class FaceList, class PointField>
<
class Face,
template<class> class FaceList,
class PointField,
class PointExtruder
>
extrudedMesh extrudedMesh
( (
const IOobject& io, const IOobject& io,
const PrimitivePatch<Face, FaceList, PointField>& extrudePatch, const PrimitivePatch<Face, FaceList, PointField>& extrudePatch,
const label nLayers, const extrudeModel& model
const PointExtruder& extruder
); );
}; };
@ -133,3 +125,4 @@ public:
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -51,6 +51,8 @@ class faceMesh
: :
public PrimitivePatch<face, List, pointField> public PrimitivePatch<face, List, pointField>
{ {
// Private member functions
PrimitivePatch<face, List, pointField> read(Istream& is) PrimitivePatch<face, List, pointField> read(Istream& is)
{ {
pointField points(is); pointField points(is);

View File

@ -1,13 +1,6 @@
argList::validArgs.clear(); argList::validArgs.clear();
argList::noParallel(); argList::noParallel();
argList::validArgs.append("target root");
argList::validArgs.append("target case");
argList::validArgs.append("nLayers");
argList::validArgs.append("overal thickness");
argList::validOptions.insert("sourceRoot", "source root"); argList::validOptions.insert("sourceRoot", "source root");
argList::validOptions.insert("sourceCase", "source case"); argList::validOptions.insert("sourceCase", "source case");
argList::validOptions.insert("sourcePatch", "source patch"); argList::validOptions.insert("sourcePatch", "source patch");
@ -23,16 +16,3 @@
FatalError.exit(); FatalError.exit();
} }
fileName rootDirTarget(args.additionalArgs()[0]);
fileName caseDirTarget(args.additionalArgs()[1]);
label nLayers(readLabel(IStringStream(args.additionalArgs()[2])()));
scalar thickness(readScalar(IStringStream(args.additionalArgs()[3])()));
Info<< "Target: " << rootDirTarget << " " << caseDirTarget << endl;
Info<< "Extruding layers:" << nl
<< " number of layers " << nLayers << nl
<< " overall thickness " << thickness << nl
<< endl;