ENH: extrudeMesh : reorganisation

This commit is contained in:
mattijs
2010-12-16 18:48:14 +00:00
parent 46ec7d65d5
commit cf47570812
24 changed files with 280 additions and 1503 deletions

View File

@ -3,6 +3,7 @@ cd ${0%/*} || exit 1 # run from this directory
set -x
wclean libso extrudeModel
wclean
wclean extrudeMesh
wclean extrudeToRegionMesh
# ----------------------------------------------------------------- end-of-file

View File

@ -3,6 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso extrudeModel
wmake
wmake extrudeMesh
wmake extrudeToRegionMesh
# ----------------------------------------------------------------- end-of-file

View File

@ -1,6 +1,6 @@
EXE_INC = \
-IextrudedMesh \
-IextrudeModel/lnInclude \
-I../extrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \

View File

@ -214,9 +214,8 @@ int main(int argc, char *argv[])
(
IOobject
(
"extrudeProperties",
runTimeExtruded.constant(),
regionDir,
"extrudeMeshDict",
runTimeExtruded.system(),
runTimeExtruded,
IOobject::MUST_READ_IF_MODIFIED
)

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object extrudeProperties;
object extrudeMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

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

View File

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

View File

@ -1,89 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "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"))),
expansionRatio_(readScalar(dict.lookup("expansionRatio"))),
dict_(dict),
coeffDict_(dict.subDict(modelType + "Coeffs"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::extrudeModel::~extrudeModel()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::extrudeModel::nLayers() const
{
return nLayers_;
}
Foam::scalar Foam::extrudeModel::expansionRatio() const
{
return expansionRatio_;
}
Foam::scalar Foam::extrudeModel::sumThickness(const label layer) const
{
// 1+r+r^2+ .. +r^(n-1) = (1-r^n)/(1-r)
if (mag(1.0-expansionRatio_) < SMALL)
{
return scalar(layer)/nLayers_;
}
else
{
return
(1.0-pow(expansionRatio_, layer))
/ (1.0-pow(expansionRatio_, nLayers_));
}
}
// ************************************************************************* //

View File

@ -1,143 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::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 scalar expansionRatio_;
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;
scalar expansionRatio() const;
// Member Operators
//- Helper: calculate cumulative relative thickness for layer.
// (layer=0 -> 0; layer=nLayers -> 1)
scalar sumThickness(const label layer) const;
virtual point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,58 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::extrudeModel> Foam::extrudeModel::New
(
const dictionary& dict
)
{
const word modelType(dict.lookup("extrudeModel"));
Info<< "Selecting extrudeModel " << modelType << endl;
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(modelType);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"extrudeModel::New(const dictionary&)"
) << "Unknown extrudeModel type "
<< modelType << nl << nl
<< "Valid extrudeModel types are :" << nl
<< dictionaryConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}
return autoPtr<extrudeModel>(cstrIter()(dict));
}
// ************************************************************************* //

View File

@ -1,89 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "linearDirection.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearDirection, 0);
addToRunTimeSelectionTable(extrudeModel, linearDirection, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
linearDirection::linearDirection(const dictionary& dict)
:
extrudeModel(typeName, dict),
direction_(coeffDict_.lookup("direction")),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{
direction_ /= mag(direction_);
if (thickness_ <= 0)
{
FatalErrorIn("linearDirection(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearDirection::~linearDirection()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearDirection::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*direction_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,98 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::extrudeModels::linearDirection
Description
Extrudes by transforming points in a specified direction by a given distance
\*---------------------------------------------------------------------------*/
#ifndef linearDirection_H
#define linearDirection_H
#include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearDirection Declaration
\*---------------------------------------------------------------------------*/
class linearDirection
:
public extrudeModel
{
// Private data
//- Extrude direction
vector direction_;
//- layer thickness
scalar thickness_;
public:
//- Runtime type information
TypeName("linearDirection");
// Constructors
//- Construct from dictionary
linearDirection(const dictionary& dict);
//- Destructor
~linearDirection();
// Member Operators
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,86 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "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")))
{
if (thickness_ <= 0)
{
FatalErrorIn("linearNormal(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearNormal::~linearNormal()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearNormal::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*surfaceNormal;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,95 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::extrudeModels::linearNormal
Description
Extrudes by transforming points normal to the surface by a given distance
\*---------------------------------------------------------------------------*/
#ifndef linearNormal_H
#define linearNormal_H
#include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearNormal Declaration
\*---------------------------------------------------------------------------*/
class linearNormal
:
public extrudeModel
{
// Private data
//- layer thickness
scalar thickness_;
public:
//- Runtime type information
TypeName("linearNormal");
// Constructors
//- Construct from dictionary
linearNormal(const dictionary& dict);
//- Destructor
~linearNormal();
// Member Operators
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,82 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "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"))),
Rsurface_(coeffDict_.lookupOrDefault<scalar>("Rsurface", -1))
{}
// * * * * * * * * * * * * * * * * 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;
if (Rsurface_ >= 0) rs = Rsurface_;
scalar r = rs + (R_ - rs)*sumThickness(layer);
return r*rsHat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,93 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::extrudeModels::linearRadial
Description
\*---------------------------------------------------------------------------*/
#ifndef linearRadial_H
#define linearRadial_H
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearRadial Declaration
\*---------------------------------------------------------------------------*/
class linearRadial
:
public extrudeModel
{
// Private data
scalar R_;
scalar Rsurface_;
public:
//- Runtime type information
TypeName("linearRadial");
// Constructors
//- Construct from dictionary
linearRadial(const dictionary& dict);
//- Destructor
~linearRadial();
// Member Operators
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,92 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "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")))
{
if (mag(expansionRatio() - 1.0) > SMALL)
{
WarningIn("sigmaRadial::sigmaRadial(const dictionary&)")
<< "Ignoring expansionRatio setting." << endl;
}
}
// * * * * * * * * * * * * * * * * 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

@ -1,94 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::extrudeModels::sigmaRadial
Description
\*---------------------------------------------------------------------------*/
#ifndef sigmaRadial_H
#define sigmaRadial_H
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class sigmaRadial Declaration
\*---------------------------------------------------------------------------*/
class sigmaRadial
:
public extrudeModel
{
// Private data
scalar RTbyg_;
scalar pRef_;
scalar pStrat_;
public:
//- Runtime type information
TypeName("sigmaRadial");
// Constructors
//- Construct from dictionary
sigmaRadial(const dictionary& dict);
//-Destructor
~sigmaRadial();
// Member Operators
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,125 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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 "wedge.H"
#include "addToRunTimeSelectionTable.H"
#include "unitConversion.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")),
axis_(coeffDict_.lookup("axis")),
angle_
(
degToRad(readScalar(coeffDict_.lookup("angle")))
)
{}
// * * * * * * * * * * * * * * * * 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/nLayers_;
sliceAngle = angle_*sumThickness(layer);
}
// 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 -= (axis_ & d)*axis_;
scalar dMag = mag(d);
point edgePt = surfacePoint - d;
// Rotate point around sliceAngle.
point rotatedPoint = edgePt;
if (dMag > VSMALL)
{
vector n = (d/dMag) ^ axis_;
rotatedPoint +=
+ cos(sliceAngle)*d
- sin(sliceAngle)*mag(d)*n; // Use either n or surfaceNormal
}
return rotatedPoint;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,107 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 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 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::extrudeModels::wedge
Description
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 wedge_H
#define wedge_H
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class wedge Declaration
\*---------------------------------------------------------------------------*/
class wedge
:
public extrudeModel
{
// Private data
//- Point on axis
const point axisPt_;
//- Normalized direction of axis
const vector axis_;
//- Overall angle (radians)
const scalar angle_;
public:
//- Runtime type information
TypeName("wedge");
// Constructors
//- Construct from dictionary
wedge(const dictionary& dict);
//- Destrcuctor
~wedge();
// Member Operators
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,9 +1,11 @@
EXE_INC = \
-I../extrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lextrudeModel \
-lfiniteVolume \
-lmeshTools \
-ldynamicMesh

View File

@ -185,18 +185,20 @@ Foam::createShellMesh::createShellMesh
void Foam::createShellMesh::setRefinement
(
const pointField& thickness,
const pointField& firstLayerDisp,
const scalar expansionRatio,
const label nLayers,
const labelList& topPatchID,
const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches,
polyTopoChange& meshMod
)
{
if (thickness.size() != regionPoints_.size())
if (firstLayerDisp.size() != regionPoints_.size())
{
FatalErrorIn("createShellMesh::setRefinement(..)")
<< "nRegions:" << regionPoints_.size()
<< " thickness:" << thickness.size()
<< " firstLayerDisp:" << firstLayerDisp.size()
<< exit(FatalError);
}
@ -224,22 +226,27 @@ void Foam::createShellMesh::setRefinement
// From cell to patch (trivial)
DynamicList<label> cellToFaceMap(patch_.size());
DynamicList<label> cellToFaceMap(nLayers*patch_.size());
// From face to patch+turning index
DynamicList<label> faceToFaceMap(2*patch_.size()+patch_.nEdges());
DynamicList<label> faceToFaceMap
(
(nLayers+1)*(patch_.size()+patch_.nEdges())
);
// From face to patch edge index
DynamicList<label> faceToEdgeMap(patch_.nEdges()+patch_.nEdges());
DynamicList<label> faceToEdgeMap(nLayers*(patch_.nEdges()+patch_.nEdges()));
// From point to patch point index
DynamicList<label> pointToPointMap(2*patch_.nPoints());
DynamicList<label> pointToPointMap((nLayers+1)*patch_.nPoints());
// Introduce new cell for every face
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelList addedCells(patch_.size());
labelList addedCells(nLayers*patch_.size());
forAll(patch_, faceI)
{
addedCells[faceI] = meshMod.addCell
for (label layerI = 0; layerI < nLayers; layerI++)
{
addedCells[nLayers*faceI+layerI] = meshMod.addCell
(
-1, // masterPointID
-1, // masterEdgeID
@ -249,6 +256,7 @@ void Foam::createShellMesh::setRefinement
);
cellToFaceMap.append(faceI);
}
}
// Introduce original points
@ -277,25 +285,28 @@ void Foam::createShellMesh::setRefinement
// Introduce new points (one for every region)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelList addedPoints(regionPoints_.size());
labelList addedPoints(nLayers*regionPoints_.size());
forAll(regionPoints_, regionI)
{
label pointI = regionPoints_[regionI];
point extrudedPt = patch_.localPoints()[pointI] + thickness[regionI];
addedPoints[regionI] = meshMod.addPoint
point pt = patch_.localPoints()[pointI];
point disp = firstLayerDisp[regionI];
for (label layerI = 0; layerI < nLayers; layerI++)
{
pt += disp;
addedPoints[nLayers*regionI+layerI] = meshMod.addPoint
(
extrudedPt, // point
pt, // point
pointToPointMap.size(), // masterPointID - used only addressing
-1, // zoneID
true // inCell
);
pointToPointMap.append(pointI);
//Pout<< "Added top point " << addedPoints[regionI]
// << " at " << extrudedPt
// << " from point " << pointI
// << endl;
disp *= expansionRatio;
}
}
@ -305,7 +316,7 @@ void Foam::createShellMesh::setRefinement
meshMod.addFace
(
patch_.localFaces()[faceI].reverseFace(),// vertices
addedCells[faceI], // own
addedCells[nLayers*faceI], // own
-1, // nei
-1, // masterPointID
-1, // masterEdgeID
@ -318,49 +329,72 @@ void Foam::createShellMesh::setRefinement
faceToFaceMap.append(-faceI-1); // points to flipped original face
faceToEdgeMap.append(-1);
//const face newF(patch_.localFaces()[faceI].reverseFace());
//Pout<< "Added bottom face "
// << patch_.localFaces()[faceI].reverseFace()
// << newF
// << " coords:" << UIndirectList<point>(meshMod.points(), newF)
// << " own " << addedCells[faceI]
// << " patch:" << bottomPatchID[faceI]
// << " at " << patch_.faceCentres()[faceI]
// << endl;
}
// Add face on top
// Add inbetween faces and face on top
forAll(patch_.localFaces(), faceI)
{
// Get face in original ordering
const face& f = patch_.localFaces()[faceI];
// Pick up point based on region
face newF(f.size());
for (label layerI = 0; layerI < nLayers; layerI++)
{
// Pick up point based on region and layer
forAll(f, fp)
{
label region = pointRegions_[faceI][fp];
newF[fp] = addedPoints[region];
newF[fp] = addedPoints[region*nLayers+layerI];
}
label own = addedCells[faceI*nLayers+layerI];
label nei;
label patchI;
if (layerI == nLayers-1)
{
nei = -1;
patchI = topPatchID[faceI];
}
else
{
nei = addedCells[faceI*nLayers+layerI+1];
patchI = -1;
}
meshMod.addFace
(
newF, // vertices
addedCells[faceI], // own
-1, // nei
own, // own
nei, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI
false, // flipFaceFlux
topPatchID[faceI], // patchID
patchI, // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(faceI+1); // unflipped
faceToEdgeMap.append(-1);
//Pout<< "Added top face " << newF
// << " own " << addedCells[faceI]
//Pout<< "Added inbetween face " << newF
// << " coords:" << UIndirectList<point>(meshMod.points(), newF)
// << " at layer " << layerI
// << " own " << own
// << " nei " << nei
// << " at " << patch_.faceCentres()[faceI]
// << endl;
}
}
// Add side faces
@ -376,8 +410,7 @@ void Foam::createShellMesh::setRefinement
if (ePatches.size() == 0)
{
// internal face.
// Internal face
if (eFaces.size() != 2)
{
FatalErrorIn("createShellMesh::setRefinement(..)")
@ -385,8 +418,20 @@ void Foam::createShellMesh::setRefinement
<< " not internal but does not have side-patches defined."
<< exit(FatalError);
}
}
else
{
if (eFaces.size() != ePatches.size())
{
FatalErrorIn("createShellMesh::setRefinement(..)")
<< "external/feature edge:" << edgeI
<< " has " << eFaces.size() << " connected extruded faces "
<< " but only " << ePatches.size()
<< " boundary faces defined." << exit(FatalError);
}
}
// Extrude
// Make face pointing in to eFaces[0] so out of new master face
const face& f = patch_.localFaces()[eFaces[0]];
@ -402,27 +447,61 @@ void Foam::createShellMesh::setRefinement
}
face newF(4);
for (label layerI = 0; layerI < nLayers; layerI++)
{
label region0 = pointRegions_[eFaces[0]][fp0];
label region1 = pointRegions_[eFaces[0]][fp1];
if (layerI == 0)
{
newF[0] = f[fp0];
newF[1] = f[fp1];
newF[2] = addedPoints[pointRegions_[eFaces[0]][fp1]];
newF[3] = addedPoints[pointRegions_[eFaces[0]][fp0]];
label minCellI = addedCells[eFaces[0]];
label maxCellI = addedCells[eFaces[1]];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
else
{
newF[0] = addedPoints[nLayers*region0+layerI-1];
newF[1] = addedPoints[nLayers*region1+layerI-1];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
label minCellI = addedCells[nLayers*eFaces[0]+layerI];
label maxCellI;
label patchI;
if (ePatches.size() == 0)
{
maxCellI = addedCells[nLayers*eFaces[1]+layerI];
if (minCellI > maxCellI)
{
// Swap
Swap(minCellI, maxCellI);
newF = newF.reverseFace();
}
patchI = -1;
}
else
{
maxCellI = -1;
patchI = ePatches[0];
}
//{
// Pout<< "Adding from face:" << patch_.faceCentres()[eFaces[0]]
// << " from edge:"
// << patch_.localPoints()[f[fp0]]
// << patch_.localPoints()[f[fp1]]
// << " at layer:" << layerI
// << " with new points:" << newF
// << " locations:"
// << UIndirectList<point>(meshMod.points(), newF)
// << " own:" << minCellI
// << " nei:" << maxCellI
// << endl;
//}
//Pout<< "for internal edge:" << e
// << " at:" << patch_.localPoints()[e[0]]
// << patch_.localPoints()[e[1]]
// << " adding face:" << newF
// << " from f:" << f
// << " inbetween " << minCellI << " and " << maxCellI << endl;
// newF already outwards pointing.
meshMod.addFace
@ -434,69 +513,7 @@ void Foam::createShellMesh::setRefinement
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID
false, // flipFaceFlux
-1, // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(0);
faceToEdgeMap.append(edgeI);
}
else
{
if (eFaces.size() != ePatches.size())
{
FatalErrorIn("createShellMesh::setRefinement(..)")
<< "external/feature edge:" << edgeI
<< " has " << eFaces.size() << " connected extruded faces "
<< " but only " << ePatches.size()
<< " boundary faces defined." << exit(FatalError);
}
// Extrude eFaces[0]
label minFaceI = eFaces[0];
// Make face pointing in to eFaces[0] so out of new master face
const face& f = patch_.localFaces()[minFaceI];
const edge& e = patch_.edges()[edgeI];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
if (f[fp1] != e[1])
{
fp1 = fp0;
fp0 = f.rcIndex(fp1);
}
face newF(4);
newF[0] = f[fp0];
newF[1] = f[fp1];
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]];
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]];
//Pout<< "for external edge:" << e
// << " at:" << patch_.localPoints()[e[0]]
// << patch_.localPoints()[e[1]]
// << " adding first patch face:" << newF
// << " from:" << f
// << " into patch:" << ePatches[0]
// << " own:" << addedCells[minFaceI]
// << endl;
// newF already outwards pointing.
meshMod.addFace
(
newF, // vertices
addedCells[minFaceI], // own
-1, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID
false, // flipFaceFlux
ePatches[0], // patchID
patchI, // patchID
-1, // zoneID
false // zoneFlip
);
@ -532,24 +549,45 @@ void Foam::createShellMesh::setRefinement
}
face newF(4);
for (label layerI = 0; layerI < nLayers; layerI++)
{
label region0 = pointRegions_[minFaceI][fp0];
label region1 = pointRegions_[minFaceI][fp1];
if (layerI == 0)
{
newF[0] = f[fp0];
newF[1] = f[fp1];
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]];
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
else
{
newF[0] = addedPoints[nLayers*region0+layerI-1];
newF[1] = addedPoints[nLayers*region1+layerI-1];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
//Pout<< "for external edge:" << e
// << " at:" << patch_.localPoints()[e[0]]
// << patch_.localPoints()[e[1]]
// << " adding patch face:" << newF
// << " from:" << f
// << " into patch:" << ePatches[i]
////if (ePatches.size() == 0)
//{
// Pout<< "Adding from MULTI face:"
// << patch_.faceCentres()[minFaceI]
// << " from edge:"
// << patch_.localPoints()[f[fp0]]
// << patch_.localPoints()[f[fp1]]
// << " at layer:" << layerI
// << " with new points:" << newF
// << " locations:"
// << UIndirectList<point>(meshMod.points(), newF)
// << endl;
//}
// newF already outwards pointing.
meshMod.addFace
(
newF, // vertices
addedCells[minFaceI], // own
addedCells[nLayers*minFaceI+layerI], // own
-1, // nei
-1, // masterPointID
-1, // masterEdgeID
@ -564,6 +602,7 @@ void Foam::createShellMesh::setRefinement
}
}
}
}
cellToFaceMap_.transfer(cellToFaceMap);

View File

@ -109,7 +109,8 @@ public:
// Access
//- From region cell to patch face
//- From region cell to patch face. Consecutively added so
// cell at layerI is at patchFaceI*nLayers+layerI
const labelList& cellToFaceMap() const
{
return cellToFaceMap_;
@ -120,7 +121,7 @@ public:
// be in top patch
// < 0 : face in opposite orientation as patch face. face will
// be in bottom patch
// = 0 : for all side faces
// = 0 : for all side and internal faces
const labelList& faceToFaceMap() const
{
return faceToFaceMap_;
@ -153,7 +154,9 @@ public:
//- Play commands into polyTopoChange to create layer mesh.
void setRefinement
(
const pointField& thickness,
const pointField& firstLayerThickness,
const scalar expansionRatio,
const label nLayers,
const labelList& topPatchID,
const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches,

View File

@ -133,6 +133,7 @@ Usage
#include "syncTools.H"
#include "cyclicPolyPatch.H"
#include "nonuniformTransformCyclicPolyPatch.H"
#include "extrudeModel.H"
using namespace Foam;
@ -689,39 +690,6 @@ void countExtrudePatches
}
// Lexical ordering for vectors.
bool lessThan(const point& x, const point& y)
{
for (direction dir = 0; dir < point::nComponents; dir++)
{
if (x[dir] < y[dir]) return true;
if (x[dir] > y[dir]) return false;
}
return false;
}
// Combine vectors
class minEqVectorOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (y != vector::zero)
{
if (x == vector::zero)
{
x = y;
}
else if (lessThan(y, x))
{
x = y;
}
}
}
};
// Constrain&sync normals on points that are on coupled patches to make sure
// the face extruded from the edge has a valid normal with its coupled
// equivalent.
@ -846,14 +814,14 @@ void constrainCoupledNormals
(
mesh,
edgeNormals0,
minEqVectorOp(),
maxMagSqrEqOp<vector>(),
vector::zero // nullValue
);
syncTools::syncEdgeList
(
mesh,
edgeNormals1,
minEqVectorOp(),
maxMagSqrEqOp<vector>(),
vector::zero // nullValue
);
@ -951,14 +919,9 @@ tmp<pointField> calcOffset
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("shellRegion");
argList::validArgs.append("faceZones");
argList::validArgs.append("thickness");
Foam::argList::addBoolOption
argList::addNote
(
"oneD",
"generate columns of 1D cells"
"Create region mesh by extruding a faceZone"
);
#include "addRegionOption.H"
@ -966,19 +929,34 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
const word oldInstance = mesh.pointsInstance();
word shellRegionName = args.additionalArgs()[0];
const wordList zoneNames(IStringStream(args.additionalArgs()[1])());
scalar thickness = readScalar(IStringStream(args.additionalArgs()[2])());
const word oldInstance = mesh.pointsInstance();
bool overwrite = args.optionFound("overwrite");
bool oneD = args.optionFound("oneD");
IOdictionary dict
(
IOobject
(
"extrudeToRegionMeshDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED
)
);
// Point generator
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Region
const word shellRegionName(dict.lookup("region"));
const wordList zoneNames(dict.lookup("faceZones"));
const Switch oneD(dict.lookup("oneD"));
Info<< "Extruding zones " << zoneNames
<< " on mesh " << regionName
<< " into shell mesh " << shellRegionName
<< " of thickness " << thickness << nl
<< endl;
if (shellRegionName == regionName)
@ -1081,7 +1059,6 @@ int main(int argc, char *argv[])
);
// Check whether the zone is internal or external faces to determine
// what patch type to insert. Cannot be mixed
// since then how to couple? - directMapped only valid for a whole patch.
@ -1437,6 +1414,8 @@ int main(int argc, char *argv[])
// Calculate a normal per region
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vectorField regionNormals(regionPoints.size(), vector::zero);
vectorField regionCentres(regionPoints.size(), vector::zero);
labelList nRegionFaces(regionPoints.size(), 0);
forAll(pointRegions, faceI)
{
@ -1446,9 +1425,15 @@ int main(int argc, char *argv[])
{
label region = pointRegions[faceI][fp];
regionNormals[region] += extrudePatch.faceNormals()[faceI];
regionCentres[region] += extrudePatch.faceCentres()[faceI];
nRegionFaces[region]++;
}
}
regionNormals /= mag(regionNormals);
forAll(regionCentres, regionI)
{
regionCentres[regionI] /= nRegionFaces[regionI];
}
// Constrain&sync normals on points that are on coupled patches.
@ -1463,10 +1448,13 @@ int main(int argc, char *argv[])
);
// For debugging: dump hedgehog plot of normals
if (false)
{
OFstream str(runTime.path()/"regionNormals.obj");
label vertI = 0;
scalar thickness = model().sumThickness(1);
forAll(pointRegions, faceI)
{
const face& f = extrudeFaces[faceI];
@ -1486,6 +1474,16 @@ int main(int argc, char *argv[])
}
// Use model to create displacements of first layer
vectorField firstDisp(regionNormals.size());
forAll(firstDisp, regionI)
{
const point& regionPt = regionCentres[regionI];
const vector& n = regionNormals[regionI];
firstDisp[regionI] = model()(regionPt, n, 1) - regionPt;
}
// Create a new mesh
// ~~~~~~~~~~~~~~~~~
@ -1500,7 +1498,9 @@ int main(int argc, char *argv[])
extruder.setRefinement
(
thickness*regionNormals,
firstDisp, // first displacement
model().expansionRatio(),
model().nLayers(), // nLayers
extrudeTopPatchID,
extrudeBottomPatchID,
extrudeEdgePatches,