Commit d962d2e8 authored by Mark Olesen's avatar Mark Olesen
Browse files

STYLE: clarify input requirements for extrusion models (#1181)

- changed the sectorCoeffs keyword to 'point' from 'axisPt'
  for more similarity with other dictionaries.
  Continue to accept 'axisPt' for compatibility.
parent 645e4489
......@@ -71,9 +71,9 @@ nLayers 10;
expansionRatio 1.0;
sectorCoeffs
sectorCoeffs //<- Also used for wedge
{
axisPt (0 0.1 -0.05);
point (0 0.1 -0.05);
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
......@@ -92,8 +92,7 @@ linearDirectionCoeffs
linearRadialCoeffs
{
R 0.1;
// Optional inner radius
Rsurface 0.01;
Rsurface 0.01; // Optional inner radius
}
radialCoeffs
......
......@@ -85,9 +85,9 @@ linearNormalCoeffs
thickness 0.05;
}
wedgeCoeffs
sectorCoeffs //<- Also used for wedge
{
axisPt (0 0.1 -0.05);
point (0 0.1 -0.05);
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
......@@ -100,9 +100,8 @@ linearDirectionCoeffs
linearRadialCoeffs
{
R 0.1;
// Optional inner radius
Rsurface 0.01;
R 0.1;
Rsurface 0.01; // Optional inner radius
}
radialCoeffs
......
......@@ -32,9 +32,11 @@ linearDirectionCoeffs
thickness 0.1;
}
wedgeCoeffs
sectorCoeffs //<- Also used for wedge
{
axisPt (0 0 0);
point (0 0 0);
axis (1 0 0);
angle 10;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -175,14 +175,12 @@ extrusion
thickness 0.1;
}
wedgeCoeffs
sectorCoeffs //<- Also used for wedge
{
axisPt (0 0 0);
point (0 0 0);
axis (1 0 0);
angle 10;
}
thickness 0.1;
}
......
......@@ -517,6 +517,7 @@ DebugSwitches
exponential 0;
extendedLeastSquares 0;
extendedLeastSquaresVectors 0;
extrudeModel 1;
face 0;
faceAreaPair 0;
faceCoupleInfo 0;
......
......@@ -24,9 +24,9 @@ extrudeModel wedge;
sectorCoeffs
{
axisPt (0 0 0);
axis (1 0 0);
angle 1;
point (0 0 0);
axis (1 0 0);
angle 1;
}
flipNormals false;
......
......@@ -48,12 +48,6 @@ cyclicSector::cyclicSector(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
cyclicSector::~cyclicSector()
{}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
......
......@@ -27,6 +27,8 @@ Class
Description
Extrudes a sector.
Uses the sectorCoeffs dictionary.
See also
Foam::extrudeModels::sector
......@@ -52,7 +54,6 @@ class cyclicSector
:
public sector
{
public:
//- Runtime type information
......@@ -61,11 +62,11 @@ public:
// Constructors
//- Construct from dictionary
cyclicSector(const dictionary& dict);
explicit cyclicSector(const dictionary& dict);
//- Destructor
virtual ~cyclicSector();
virtual ~cyclicSector() = default;
};
......
......@@ -43,15 +43,12 @@ Foam::extrudeModel::extrudeModel
:
nLayers_(dict.lookupOrDefault<label>("nLayers", 1)),
expansionRatio_(dict.lookupOrDefault<scalar>("expansionRatio", 1)),
dict_(dict),
coeffDict_(dict.optionalSubDict(modelType + "Coeffs"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::extrudeModel::~extrudeModel()
{}
{
DebugInfo
<< "Selected extrudeModel for " << modelType
<< "using coeffs " << coeffDict_ << nl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -27,6 +27,13 @@ Class
Description
Top level extrusion model class
Dictionary entries
\table
Property | Description | Required | Default
nLayer | Number of extrusion layers | no | 1
expansionRatio | Expansion ratio | no | 1
\endtable
SourceFiles
extrudeModel.C
......@@ -59,8 +66,6 @@ protected:
const scalar expansionRatio_;
const dictionary& dict_;
const dictionary& coeffDict_;
......@@ -94,27 +99,30 @@ public:
// Constructors
//- Construct from dictionary
extrudeModel(const word& modelType, const dictionary&);
//- Construct from dictionary for given model type
// The corresponding model Coeffs dictionary must exist.
extrudeModel(const word& modelType, const dictionary& dict);
// Selectors
//- Select null constructed
static autoPtr<extrudeModel> New(const dictionary&);
static autoPtr<extrudeModel> New(const dictionary& dict);
//- Destructor
virtual ~extrudeModel();
virtual ~extrudeModel() = default;
// Member Functions
// Access
label nLayers() const;
//- Return the number of layers
label nLayers() const;
scalar expansionRatio() const;
//- Return the expansion ratio
scalar expansionRatio() const;
// Member Operators
......
......@@ -57,12 +57,6 @@ linearDirection::linearDirection(const dictionary& dict)
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearDirection::~linearDirection()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearDirection::operator()
......@@ -72,9 +66,7 @@ point linearDirection::operator()
const label layer
) const
{
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*direction_;
return surfacePoint + (thickness_*sumThickness(layer)) * direction_;
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -25,7 +25,15 @@ Class
Foam::extrudeModels::linearDirection
Description
Extrudes by transforming points in a specified direction by a given distance
Extrudes by transforming points in a specified direction by the given
distance.
The linearDirectionCoeffs dictionary entries
\table
Property | Description | Required | Default
direction | The extrusion direction, normalized on input | yes |
thickness | The extrusion thickness | yes |
\endtable
\*---------------------------------------------------------------------------*/
......@@ -67,11 +75,11 @@ public:
// Constructors
//- Construct from dictionary
linearDirection(const dictionary& dict);
explicit linearDirection(const dictionary& dict);
//- Destructor
virtual ~linearDirection();
virtual ~linearDirection() = default;
// Member Operators
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -46,7 +46,10 @@ linearNormal::linearNormal(const dictionary& dict)
:
extrudeModel(typeName, dict),
thickness_(coeffDict_.get<scalar>("thickness")),
firstCellThickness_(0),
firstCellThickness_
(
coeffDict_.lookupOrDefault<scalar>("firstCellThickness", 0)
),
layerPoints_(nLayers_)
{
if (thickness_ <= 0)
......@@ -56,42 +59,34 @@ linearNormal::linearNormal(const dictionary& dict)
<< exit(FatalError);
}
coeffDict_.readIfPresent("firstCellThickness", firstCellThickness_);
if (firstCellThickness_ >= thickness_)
if (nLayers_ > 1 && firstCellThickness_ > 0)
{
FatalErrorInFunction
<< "firstCellThickness is larger than thickness"
<< exit(FatalError);
}
if (thickness_ <= firstCellThickness_)
{
FatalErrorInFunction
<< "firstCellThickness leave no room for further layers"
<< exit(FatalError);
}
if (firstCellThickness_ > 0)
{
layerPoints_[0] = firstCellThickness_;
for (label layerI = 1; layerI < nLayers_; layerI++)
for (label layer = 1; layer < nLayers_; ++layer)
{
layerPoints_[layerI] =
layerPoints_[layer] =
(thickness_ - layerPoints_[0])
*sumThickness(layerI) + layerPoints_[0];
*sumThickness(layer) + layerPoints_[0];
}
}
else
{
for (label layerI = 0; layerI < nLayers_; layerI++)
for (label layer = 0; layer < nLayers_; ++layer)
{
layerPoints_[layerI] = thickness_*sumThickness(layerI + 1);
layerPoints_[layer] = thickness_*sumThickness(layer + 1);
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearNormal::~linearNormal()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearNormal::operator()
......@@ -101,14 +96,12 @@ point linearNormal::operator()
const label layer
) const
{
if (layer == 0)
if (layer <= 0)
{
return surfacePoint;
}
else
{
return surfacePoint + layerPoints_[layer - 1]*surfaceNormal;
}
return surfacePoint + layerPoints_[layer - 1]*surfaceNormal;
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -27,6 +27,13 @@ Class
Description
Extrudes by transforming points normal to the surface by a given distance.
The linearNormalCoeffs dictionary entries
\table
Property | Description | Required | Default
thickness | Extrusion thickness | yes |
firstCellThickness | Thickness of the first layer | no | 0
\endtable
\*---------------------------------------------------------------------------*/
#ifndef linearNormal_H
......@@ -44,7 +51,7 @@ namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearNormal Declaration
Class extrudeModels::linearNormal Declaration
\*---------------------------------------------------------------------------*/
class linearNormal
......@@ -63,7 +70,6 @@ class linearNormal
scalarList layerPoints_;
public:
//- Runtime type information
......@@ -72,11 +78,11 @@ public:
// Constructors
//- Construct from dictionary
linearNormal(const dictionary& dict);
explicit linearNormal(const dictionary& dict);
//- Destructor
virtual ~linearNormal();
virtual ~linearNormal() = default;
// Member Operators
......
......@@ -48,12 +48,6 @@ linearRadial::linearRadial(const dictionary& dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearRadial::~linearRadial()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearRadial::operator()
......@@ -66,6 +60,7 @@ point linearRadial::operator()
// radius of the surface
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
if (Rsurface_ >= 0) rs = Rsurface_;
scalar r = rs + (R_ - rs)*sumThickness(layer);
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -25,6 +25,14 @@ Class
Foam::extrudeModels::linearRadial
Description
Extrudes by transforming radially from the surface.
The linearRadialCoeffs dictionary entries
\table
Property | Description | Required | Default
R | The radial thickness | yes |
Rsurface | Surface inner radius | no | -1
\endtable
\*---------------------------------------------------------------------------*/
......@@ -41,7 +49,7 @@ namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class linearRadial Declaration
Class extrudeModels::linearRadial Declaration
\*---------------------------------------------------------------------------*/
class linearRadial
......@@ -62,15 +70,16 @@ public:
// Constructors
//- Construct from dictionary
linearRadial(const dictionary& dict);
explicit linearRadial(const dictionary& dict);
//- Destructor
virtual ~linearRadial();
virtual ~linearRadial() = default;
// Member Operators
//- Return point
point operator()
(
const point& surfacePoint,
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2015-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -51,24 +51,16 @@ offsetSurface::offsetSurface(const dictionary& dict)
project_(coeffDict_.lookupOrDefault("project", false))
{
// Read surface
fileName baseName(coeffDict_.lookup("baseSurface"));
baseName.expand();
fileName baseName(coeffDict_.get<fileName>("baseSurface").expand());
baseSurfPtr_.reset(new triSurface(baseName));
// Construct search engine
baseSearchPtr_.reset(new triSurfaceSearch(baseSurfPtr_()));
// Read offsetted surface
fileName offsetName(coeffDict_.lookup("offsetSurface"));
offsetName.expand();
fileName offsetName(coeffDict_.get<fileName>("offsetSurface").expand());
offsetSurfPtr_.reset(new triSurface(offsetName));
// Construct search engine
offsetSearchPtr_.reset(new triSurfaceSearch(offsetSurfPtr_()));
const triSurface& b = baseSurfPtr_();
const triSurface& o = offsetSurfPtr_();
const triSurface& b = *baseSurfPtr_;
const triSurface& o = *offsetSurfPtr_;
if
(
......@@ -78,10 +70,17 @@ offsetSurface::offsetSurface(const dictionary& dict)
)
{
FatalIOErrorInFunction(dict)
<< "offsetSurface " << offsetName
<< " should have exactly the same topology as the baseSurface "
<< baseName << exit(FatalIOError);
<< "offsetSurface:\n " << offsetName
<< " has different topology than the baseSurface:\n "
<< baseName << endl
<< exit(FatalIOError);
}
// Construct search engine
baseSearchPtr_.reset(new triSurfaceSearch(b));
// Construct search engine
offsetSearchPtr_.reset(new triSurfaceSearch(o));
}
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -29,6 +29,14 @@ Description
have to be topologically identical i.e. one has to be an offsetted version
of the other.
The offsetSurfaceCoeffs dictionary entries
\table
Property | Description | Required | Default
baseSurface | Base surface file name | yes |
offsetSurface | Offset surface file name | yes |
project | Project onto offsetted surface | no | false
\endtable
\*---------------------------------------------------------------------------*/
#ifndef offsetSurface_H
......@@ -41,16 +49,15 @@ Description
namespace Foam
{
// Forward declarations
class triSurface;
class triSurfaceSearch;
namespace extrudeModels