Merge branch 'master' into splitCyclic

Conflicts:
	applications/utilities/mesh/generation/blockMesh/blockMeshApp.C
	applications/utilities/parallelProcessing/decomposePar/decomposeMesh.C
	etc/bashrc
	etc/cshrc
	src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C
	src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/processor/processorPolyPatch.C
	src/decompositionMethods/parMetisDecomp/parMetisDecomp.C
	src/dynamicMesh/Make/files
	src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C
	src/dynamicMesh/perfectInterface/perfectInterface.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H
	src/finiteVolume/Make/files
	src/mesh/blockMesh/blockMesh/blockMesh.C
	src/mesh/blockMesh/blockMesh/blockMeshTopology.C
	src/meshTools/Make/files
	src/meshTools/sets/topoSets/faceSet.C
This commit is contained in:
mattijs
2009-11-30 15:20:52 +00:00
2132 changed files with 217596 additions and 24407 deletions

View File

@ -1,31 +1,3 @@
curvedEdges = curvedEdges
$(curvedEdges)/curvedEdge.C
$(curvedEdges)/lineEdge.C
$(curvedEdges)/polyLine.C
$(curvedEdges)/polyLineEdge.C
$(curvedEdges)/arcEdge.C
$(curvedEdges)/spline.C
$(curvedEdges)/BSpline.C
$(curvedEdges)/simpleSplineEdge.C
$(curvedEdges)/polySplineEdge.C
$(curvedEdges)/lineDivide.C
blockMesh.C
blockDescriptor.C
setEdge.C
block.C
createTopology.C
checkBlockMesh.C
createBlockOffsets.C
createMergeList.C
createPoints.C
createCells.C
createPatches.C
blockPoints.C
blockCells.C
blockBoundary.C
blockMeshApp.C
EXE = $(FOAM_APPBIN)/blockMesh

View File

@ -1,8 +1,9 @@
EXE_INC = \
-I$(curvedEdges) \
-I$(LIB_SRC)/mesh/blockMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lblockMesh \
-lmeshTools \
-ldynamicMesh

View File

@ -1,114 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
label block::vtxLabel(label a, label b, label c)
{
return (a + b*(blockDef_.n().x() + 1)
+ c*(blockDef_.n().x() + 1)*(blockDef_.n().y() + 1));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from description
block::block(const blockDescriptor& definition)
:
blockDef_(definition),
vertices_
(
((blockDef_.n().x() + 1)*(blockDef_.n().y() + 1)*(blockDef_.n().z() + 1))
),
cells_
(
(blockDef_.n().x()*blockDef_.n().y()*blockDef_.n().z())
),
boundaryPatches_(6)
{
// create points
blockPoints();
// generate internal cells
blockCells();
// generate boundary patches
blockBoundary();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const blockDescriptor& block::blockDef() const
{
return blockDef_;
}
const pointField& block::points() const
{
return vertices_;
}
const labelListList& block::cells() const
{
return cells_;
}
const labelListListList& block::boundaryPatches() const
{
return boundaryPatches_;
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const block& b)
{
os << b.vertices_ << nl
<< b.cells_ << nl
<< b.boundaryPatches_ << endl;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,131 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::block
Description
creates a single block of cells from point coordinates,
numbers of cells in each direction and expansion ratio
SourceFiles
block.C
\*---------------------------------------------------------------------------*/
#ifndef block_H
#define block_H
#include "pointField.H"
#include "labelList.H"
#include "blockDescriptor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Istream;
class Ostream;
/*---------------------------------------------------------------------------*\
Class block Declaration
\*---------------------------------------------------------------------------*/
class block
{
// Private data
//- block definition
blockDescriptor blockDef_;
//- list of vertices
pointField vertices_;
//- list of cells
labelListList cells_;
//- boundary patches
labelListListList boundaryPatches_;
// private member functions
label vtxLabel(label i, label j, label k);
void blockPoints();
void blockCells();
void blockBoundary();
public:
// Constructors
//- Construct from the block definition
block(const blockDescriptor&);
//- Clone
autoPtr<block> clone() const
{
notImplemented("block::clone()");
return autoPtr<block>(NULL);
}
// Member Functions
// Access
const blockDescriptor& blockDef() const;
const pointField& points() const;
const labelListList& cells() const;
const labelListListList& boundaryPatches() const;
// Ostream Operator
friend Ostream& operator<<(Ostream&, const block&);
};
inline Istream& operator>>(Istream& is, block*)
{
notImplemented("Istream& operator>>(Istream& is, block*)");
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,209 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
private member of block. Creates boundary patches for the block
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::block::blockBoundary()
{
label ni = blockDef_.n().x();
label nj = blockDef_.n().y();
label nk = blockDef_.n().z();
// x-direction
label wallLabel = 0;
label wallCellLabel = 0;
// x-min
boundaryPatches_[wallLabel].setSize(nj*nk);
for (label k = 0; k <= nk - 1; k++)
{
for (label j = 0; j <= nj - 1; j++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(0, j, k);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(0, j, k + 1);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(0, j + 1, k + 1);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(0, j + 1, k);
// update the counter
wallCellLabel++;
}
}
// x-max
wallLabel++;
wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(nj*nk);
for (label k = 0; k <= nk - 1; k++)
{
for (label j = 0; j <= nj - 1; j++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(ni, j, k);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(ni, j+1, k);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(ni, j+1, k+1);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(ni, j, k+1);
// update the counter
wallCellLabel++;
}
}
// y-direction
// y-min
wallLabel++;
wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(ni*nk);
for (label i = 0; i <= ni - 1; i++)
{
for (label k = 0; k <= nk - 1; k++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(i, 0, k);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(i + 1, 0, k);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(i + 1, 0, k + 1);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(i, 0, k + 1);
// update the counter
wallCellLabel++;
}
}
// y-max
wallLabel++;
wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(ni*nk);
for (label i = 0; i <= ni - 1; i++)
{
for (label k = 0; k <= nk - 1; k++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(i, nj, k);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(i, nj, k + 1);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(i + 1, nj, k + 1);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(i + 1, nj, k);
// update the counter
wallCellLabel++;
}
}
// z-direction
// z-min
wallLabel++;
wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(ni*nj);
for (label i = 0; i <= ni - 1; i++)
{
for (label j = 0; j <= nj - 1; j++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(i, j, 0);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(i, j + 1, 0);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(i + 1, j + 1, 0);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(i + 1, j, 0);
// update the counter
wallCellLabel++;
}
}
// z-max
wallLabel++;
wallCellLabel = 0;
boundaryPatches_[wallLabel].setSize(ni*nj);
for (label i = 0; i <= ni - 1; i++)
{
for (label j = 0; j <= nj - 1; j++)
{
boundaryPatches_[wallLabel][wallCellLabel].setSize(4);
// set the points
boundaryPatches_[wallLabel][wallCellLabel][0] =
vtxLabel(i, j, nk);
boundaryPatches_[wallLabel][wallCellLabel][1] =
vtxLabel(i + 1, j, nk);
boundaryPatches_[wallLabel][wallCellLabel][2] =
vtxLabel(i + 1, j + 1, nk);
boundaryPatches_[wallLabel][wallCellLabel][3] =
vtxLabel(i, j + 1, nk);
// update the counter
wallCellLabel++;
}
}
}
// ************************************************************************* //

View File

@ -1,65 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
private member of block. Creates cells for the block.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::block::blockCells()
{
label ni = blockDef_.n().x();
label nj = blockDef_.n().y();
label nk = blockDef_.n().z();
label cellNo = 0;
for (label k = 0; k <= nk - 1; k++)
{
for (label j = 0; j <= nj - 1; j++)
{
for (label i = 0; i <= ni - 1; i++)
{
cells_[cellNo].setSize(8);
cells_[cellNo][0] = vtxLabel(i, j, k);
cells_[cellNo][1] = vtxLabel(i+1, j, k);
cells_[cellNo][2] = vtxLabel(i+1, j+1, k);
cells_[cellNo][3] = vtxLabel(i, j+1, k);
cells_[cellNo][4] = vtxLabel(i, j, k+1);
cells_[cellNo][5] = vtxLabel(i+1, j, k+1);
cells_[cellNo][6] = vtxLabel(i+1, j+1, k+1);
cells_[cellNo][7] = vtxLabel(i, j+1, k+1);
cellNo++;
}
}
}
}
// ************************************************************************* //

View File

@ -1,248 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockDescriptor.H"
#include "scalarList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void blockDescriptor::makeBlockEdges()
{
// for all edges check the list of curved edges. If the edge is curved,
// add it to the list. If the edge is not found, create is as a line
setEdge(0, 0, 1, n_.x());
setEdge(1, 3, 2, n_.x());
setEdge(2, 7, 6, n_.x());
setEdge(3, 4, 5, n_.x());
setEdge(4, 0, 3, n_.y());
setEdge(5, 1, 2, n_.y());
setEdge(6, 5, 6, n_.y());
setEdge(7, 4, 7, n_.y());
setEdge(8, 0, 4, n_.z());
setEdge(9, 1, 5, n_.z());
setEdge(10, 2, 6, n_.z());
setEdge(11, 3, 7, n_.z());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// from components
blockDescriptor::blockDescriptor
(
const cellShape& bshape,
const pointField& blockMeshPoints,
const curvedEdgeList& edges,
const Vector<label>& n,
const scalarList& expand,
const word& zoneName
)
:
blockMeshPoints_(blockMeshPoints),
blockShape_(bshape),
curvedEdges_(edges),
edgePoints_(12),
edgeWeights_(12),
n_(n),
expand_(expand),
zoneName_(zoneName)
{
if (expand_.size() != 12)
{
FatalErrorIn
(
"blockDescriptor::blockDescriptor"
"(const cellShape& bshape, const pointField& blockMeshPoints, "
"const curvedEdgeList& edges, label xnum, label ynum, label znum, "
"const scalarList& expand, const word& zoneName)"
) << "Unknown definition of expansion ratios"
<< exit(FatalError);
}
makeBlockEdges();
}
// from Istream
blockDescriptor::blockDescriptor
(
const pointField& blockMeshPoints,
const curvedEdgeList& edges,
Istream& is
)
:
blockMeshPoints_(blockMeshPoints),
blockShape_(is),
curvedEdges_(edges),
edgePoints_(12),
edgeWeights_(12),
n_(),
expand_(12),
zoneName_()
{
// Look at first token
token t(is);
is.putBack(t);
// Optional zone name
if (t.isWord())
{
zoneName_ = t.wordToken();
// Consume zoneName token
is >> t;
// New look-ahead
is >> t;
is.putBack(t);
}
if (t.isPunctuation())
{
if (t.pToken() == token::BEGIN_LIST)
{
is >> n_;
}
else
{
FatalIOErrorIn
(
"blockDescriptor::blockDescriptor"
"(const pointField&, const curvedEdgeList&, Istream& is)",
is
) << "incorrect token while reading n, expected '(', found "
<< t.info()
<< exit(FatalIOError);
}
}
else
{
is >> n_.x() >> n_.y() >> n_.z();
}
is >> t;
if (!t.isWord())
{
is.putBack(t);
}
scalarList expRatios(is);
if (expRatios.size() == 3)
{
expand_[0] = expRatios[0];
expand_[1] = expRatios[0];
expand_[2] = expRatios[0];
expand_[3] = expRatios[0];
expand_[4] = expRatios[1];
expand_[5] = expRatios[1];
expand_[6] = expRatios[1];
expand_[7] = expRatios[1];
expand_[8] = expRatios[2];
expand_[9] = expRatios[2];
expand_[10] = expRatios[2];
expand_[11] = expRatios[2];
}
else if (expRatios.size() == 12)
{
expand_ = expRatios;
}
else
{
FatalErrorIn
(
"blockDescriptor::blockDescriptor"
"(const pointField& blockMeshPoints, const curvedEdgeList& edges,"
"Istream& is)"
) << "Unknown definition of expansion ratios"
<< exit(FatalError);
}
// create a list of edges
makeBlockEdges();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const pointField& blockDescriptor::points() const
{
return blockMeshPoints_;
}
const cellShape& blockDescriptor::blockShape() const
{
return blockShape_;
}
const List<List<point> >& blockDescriptor::blockEdgePoints() const
{
return edgePoints_;
}
const scalarListList& blockDescriptor::blockEdgeWeights() const
{
return edgeWeights_;
}
const Vector<label>& blockDescriptor::n() const
{
return n_;
}
const word& blockDescriptor::zoneName() const
{
return zoneName_;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void blockDescriptor::operator=(const blockDescriptor&)
{
notImplemented("void blockDescriptor::operator=(const blockDescriptor&)");
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,168 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::blockDescriptor
Description
block descriptor. Takes the description of the block and the list
of curved edges and creates a list of points on edges together
with the weighting factors
SourceFiles
blockDescriptor.C
\*---------------------------------------------------------------------------*/
#ifndef blockDescriptor_H
#define blockDescriptor_H
#include "scalar.H"
#include "label.H"
#include "point.H"
#include "cellShape.H"
#include "scalarList.H"
#include "curvedEdgeList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Istream;
class Ostream;
/*---------------------------------------------------------------------------*\
Class blockDescriptor Declaration
\*---------------------------------------------------------------------------*/
class blockDescriptor
{
// Private data
//- Block mesh points
const pointField& blockMeshPoints_;
//- block shape
cellShape blockShape_;
// reference to a list of curved edges
const curvedEdgeList& curvedEdges_;
// block edge points
List<List<point> > edgePoints_;
//- block edge weighting factors
scalarListList edgeWeights_;
//- number of point in each direction
Vector<label> n_;
//- expansion ratios in all directions
scalarList expand_;
//- name of the zone (empty string if none)
word zoneName_;
// Private member functions
void makeBlockEdges();
void setEdge(label edge, label start, label end, label dim);
public:
// Constructors
//- Construct from components. Optional cellSet/zone name.
blockDescriptor
(
const cellShape&,
const pointField& blockMeshPoints,
const curvedEdgeList& edges,
const Vector<label>& n,
const scalarList& expand,
const word& zoneName = ""
);
//- Construct from Istream
blockDescriptor
(
const pointField& blockMeshPoints,
const curvedEdgeList& edges,
Istream& is
);
//- Clone
autoPtr<blockDescriptor> clone() const
{
notImplemented("blockDescriptor::clone()");
return autoPtr<blockDescriptor>(NULL);
}
// Member Functions
// Access
const pointField& points() const;
const cellShape& blockShape() const;
const List<List<point> >& blockEdgePoints() const;
const scalarListList& blockEdgeWeights() const;
const Vector<label>& n() const;
const word& zoneName() const;
// Member Operators
void operator=(const blockDescriptor&);
// IOstream Operators
friend Ostream& operator<<(Ostream&, const blockDescriptor&);
};
inline Istream& operator>>(Istream& is, blockDescriptor*)
{
notImplemented("Istream& operator>>(Istream& is, blockDescriptor*)");
return is;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,59 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
InClass
Foam::blockList
Description
SourceFiles
blockList.C
\*---------------------------------------------------------------------------*/
#ifndef blockList_H
#define blockList_H
#include "block.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<block> blockList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,173 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Application
blockMesh
Description
Mesh generator
\*---------------------------------------------------------------------------*/
#include "blockMesh.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from IOdictionary
Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
:
topologyPtr_(createTopology(meshDescription)),
blockOffsets_(createBlockOffsets()),
mergeList_(createMergeList()),
points_(createPoints(meshDescription)),
cells_(createCells()),
patches_(createPatches())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::blockMesh::~blockMesh()
{
delete topologyPtr_;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::polyMesh& Foam::blockMesh::topology() const
{
if (!topologyPtr_)
{
FatalErrorIn("blockMesh::topology() const")
<< "topologyPtr_ not allocated"
<< exit(FatalError);
}
return *topologyPtr_;
}
Foam::PtrList<Foam::dictionary> Foam::blockMesh::patchDicts() const
{
const polyPatchList& patchTopologies = topology().boundaryMesh();
PtrList<dictionary> patchDicts(patchTopologies.size());
forAll(patchTopologies, patchI)
{
OStringStream os;
patchTopologies[patchI].write(os);
IStringStream is(os.str());
patchDicts.set(patchI, new dictionary(is));
patchDicts[patchI].set("name", patchTopologies[patchI].name());
}
return patchDicts;
}
//Foam::wordList Foam::blockMesh::patchNames() const
//{
// const polyPatchList& patchTopologies = topology().boundaryMesh();
// wordList names(patchTopologies.size());
//
// forAll (names, patchI)
// {
// names[patchI] = patchTopologies[patchI].name();
// }
//
// return names;
//}
//
//
//Foam::wordList Foam::blockMesh::patchTypes() const
//{
// const polyPatchList& patchTopologies = topology().boundaryMesh();
// wordList types(patchTopologies.size());
//
// forAll (types, patchI)
// {
// types[patchI] = patchTopologies[patchI].type();
// }
//
// return types;
//}
//
//
//Foam::wordList Foam::blockMesh::patchPhysicalTypes() const
//{
// const polyPatchList& patchTopologies = topology().boundaryMesh();
// wordList physicalTypes(patchTopologies.size());
//
// forAll (physicalTypes, patchI)
// {
// OStringStream os;
// patchTopologies[patchI].write(os);
// IStringStream is(os.str());
// patchDicts.set(patchI, new dictionary(is));
// patchDicts[patchI].set("name", patchTopologies[patchI].name());
// }
// return patchDicts;
//}
Foam::label Foam::blockMesh::numZonedBlocks() const
{
label num = 0;
forAll(*this, blockI)
{
if (operator[](blockI).blockDef().zoneName().size())
{
num++;
}
}
return num;
}
void Foam::blockMesh::writeTopology(Ostream& os) const
{
const pointField& pts = topology().points();
forAll(pts, pI)
{
const point& pt = pts[pI];
os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
}
const edgeList& edges = topology().edges();
forAll(edges, eI)
{
const edge& e = edges[eI];
os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
}
}
// ************************************************************************* //

View File

@ -1,198 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::blockMesh
Description
SourceFiles
blockMesh.C
\*---------------------------------------------------------------------------*/
#ifndef blockMesh_H
#define blockMesh_H
#include "blockList.H"
#include "polyMesh.H"
#include "IOdictionary.H"
#include "curvedEdgeList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class blockMesh Declaration
\*---------------------------------------------------------------------------*/
class blockMesh
:
public blockList
{
// Private data
label nPoints_;
label nCells_;
curvedEdgeList edges_;
polyMesh* topologyPtr_;
labelList blockOffsets_;
labelList mergeList_;
pointField points_;
cellShapeList cells_;
faceListList patches_;
// Private Member Functions
bool blockLabelsOK
(
const label blockLabel,
const pointField& points,
const cellShape& blockShape
);
bool patchLabelsOK
(
const label patchLabel,
const pointField& points,
const faceList& patchShapes
);
bool readPatches
(
const dictionary& meshDescription,
const pointField& tmpBlockPoints,
faceListList& tmpBlocksPatches,
wordList& patchNames,
wordList& patchTypes,
wordList& nbrPatchNames
);
bool readBoundary
(
const dictionary& meshDescription,
const pointField& tmpBlockPoints,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
);
void createCellShapes
(
const pointField& tmpBlockPoints,
PtrList<cellShape>& tmpBlockCells
);
polyMesh* createTopology(IOdictionary&);
void checkBlockMesh(const polyMesh&);
labelList createBlockOffsets();
labelList createMergeList();
pointField createPoints(const dictionary&);
cellShapeList createCells();
faceList createPatchFaces(const polyPatch& patchTopologyFaces);
faceListList createPatches();
//- as copy (not implemented)
blockMesh(const blockMesh&);
public:
// Constructors
//- Construct from IOdictionary
blockMesh(IOdictionary&);
// Destructor
~blockMesh();
// Member Functions
// Access
const polyMesh& topology() const;
const curvedEdgeList& edges() const
{
return edges_;
}
const pointField& points() const
{
return points_;
}
const cellShapeList& cells() const
{
return cells_;
}
const faceListList& patches() const
{
return patches_;
}
//- Get patch information from the topology mesh
PtrList<dictionary> patchDicts() const;
// wordList patchNames() const;
//
// wordList patchTypes() const;
//
// wordList patchPhysicalTypes() const;
//- Number of blocks with specified zones
label numZonedBlocks() const;
// Write
//- Writes edges of blockMesh in OBJ format.
void writeTopology(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -146,8 +146,10 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
Info<< nl << "Creating block mesh from\n "
<< meshDictIoPtr->objectPath() << nl << endl;
Info<< "Creating block mesh from\n "
<< meshDictIoPtr->objectPath() << endl;
blockMesh::verbose(true);
IOdictionary meshDict(meshDictIoPtr());
blockMesh blocks(meshDict);
@ -195,12 +197,10 @@ int main(int argc, char *argv[])
}
Info<< nl << "Creating mesh from block mesh" << endl;
Info<< nl << "Creating polyMesh from blockMesh" << endl;
word defaultFacesName = "defaultFaces";
word defaultFacesType = emptyPolyPatch::typeName;
polyMesh mesh
(
IOobject
@ -322,7 +322,7 @@ int main(int argc, char *argv[])
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
Info << nl << "Writing polyMesh" << endl;
Info<< nl << "Writing polyMesh" << endl;
mesh.removeFiles();
if (!mesh.write())
{
@ -331,6 +331,38 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
//
// write some information
//
{
const polyPatchList& patches = mesh.boundaryMesh();
Info<< "----------------" << nl
<< "Mesh Information" << nl
<< "----------------" << nl
<< " " << "boundingBox: " << boundBox(mesh.points()) << nl
<< " " << "nPoints: " << mesh.nPoints() << nl
<< " " << "nCells: " << mesh.nCells() << nl
<< " " << "nFaces: " << mesh.nFaces() << nl
<< " " << "nInternalFaces: " << mesh.nInternalFaces() << nl;
Info<< "----------------" << nl
<< "Patches" << nl
<< "----------------" << nl;
forAll(patches, patchI)
{
const polyPatch& p = patches[patchI];
Info<< " " << "patch " << patchI
<< " (start: " << p.start()
<< " size: " << p.size()
<< ") name: " << p.name()
<< nl;
}
}
Info<< nl << "End" << endl;
return 0;

View File

@ -1,232 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
private member of block. Creates vertices for cells filling the block.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "block.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::block::blockPoints()
{
// set local variables for mesh specification
const label ni = blockDef_.n().x();
const label nj = blockDef_.n().y();
const label nk = blockDef_.n().z();
const point p000 = blockDef_.points()[blockDef_.blockShape()[0]];
const point p100 = blockDef_.points()[blockDef_.blockShape()[1]];
const point p110 = blockDef_.points()[blockDef_.blockShape()[2]];
const point p010 = blockDef_.points()[blockDef_.blockShape()[3]];
const point p001 = blockDef_.points()[blockDef_.blockShape()[4]];
const point p101 = blockDef_.points()[blockDef_.blockShape()[5]];
const point p111 = blockDef_.points()[blockDef_.blockShape()[6]];
const point p011 = blockDef_.points()[blockDef_.blockShape()[7]];
// list of edge point and weighting factors
const List<List<point> >& p = blockDef_.blockEdgePoints();
const scalarListList& w = blockDef_.blockEdgeWeights();
// generate vertices
for (label k = 0; k <= nk; k++)
{
for (label j = 0; j <= nj; j++)
{
for (label i = 0; i <= ni; i++)
{
label vertexNo = vtxLabel(i, j, k);
// points on edges
vector edgex1 = p000 + (p100 - p000)*w[0][i];
vector edgex2 = p010 + (p110 - p010)*w[1][i];
vector edgex3 = p011 + (p111 - p011)*w[2][i];
vector edgex4 = p001 + (p101 - p001)*w[3][i];
vector edgey1 = p000 + (p010 - p000)*w[4][j];
vector edgey2 = p100 + (p110 - p100)*w[5][j];
vector edgey3 = p101 + (p111 - p101)*w[6][j];
vector edgey4 = p001 + (p011 - p001)*w[7][j];
vector edgez1 = p000 + (p001 - p000)*w[8][k];
vector edgez2 = p100 + (p101 - p100)*w[9][k];
vector edgez3 = p110 + (p111 - p110)*w[10][k];
vector edgez4 = p010 + (p011 - p010)*w[11][k];
// calculate the importance factors for all edges
// x - direction
scalar impx1 =
(
(1.0 - w[0][i])*(1.0 - w[4][j])*(1.0 - w[8][k])
+ w[0][i]*(1.0 - w[5][j])*(1.0 - w[9][k])
);
scalar impx2 =
(
(1.0 - w[1][i])*w[4][j]*(1.0 - w[11][k])
+ w[1][i]*w[5][j]*(1.0 - w[10][k])
);
scalar impx3 =
(
(1.0 - w[2][i])*w[7][j]*w[11][k]
+ w[2][i]*w[6][j]*w[10][k]
);
scalar impx4 =
(
(1.0 - w[3][i])*(1.0 - w[7][j])*w[8][k]
+ w[3][i]*(1.0 - w[6][j])*w[9][k]
);
scalar magImpx = impx1 + impx2 + impx3 + impx4;
impx1 /= magImpx;
impx2 /= magImpx;
impx3 /= magImpx;
impx4 /= magImpx;
// y - direction
scalar impy1 =
(
(1.0 - w[4][j])*(1.0 - w[0][i])*(1.0 - w[8][k])
+ w[4][j]*(1.0 - w[1][i])*(1.0 - w[11][k])
);
scalar impy2 =
(
(1.0 - w[5][j])*w[0][i]*(1.0 - w[9][k])
+ w[5][j]*w[1][i]*(1.0 - w[10][k])
);
scalar impy3 =
(
(1.0 - w[6][j])*w[3][i]*w[9][k]
+ w[6][j]*w[2][i]*w[10][k]
);
scalar impy4 =
(
(1.0 - w[7][j])*(1.0 - w[3][i])*w[8][k]
+ w[7][j]*(1.0 - w[2][i])*w[11][k]
);
scalar magImpy = impy1 + impy2 + impy3 + impy4;
impy1 /= magImpy;
impy2 /= magImpy;
impy3 /= magImpy;
impy4 /= magImpy;
// z - direction
scalar impz1 =
(
(1.0 - w[8][k])*(1.0 - w[0][i])*(1.0 - w[4][j])
+ w[8][k]*(1.0 - w[3][i])*(1.0 - w[7][j])
);
scalar impz2 =
(
(1.0 - w[9][k])*w[0][i]*(1.0 - w[5][j])
+ w[9][k]*w[3][i]*(1.0 - w[6][j])
);
scalar impz3 =
(
(1.0 - w[10][k])*w[1][i]*w[5][j]
+ w[10][k]*w[2][i]*w[6][j]
);
scalar impz4 =
(
(1.0 - w[11][k])*(1.0 - w[1][i])*w[4][j]
+ w[11][k]*(1.0 - w[2][i])*w[7][j]
);
scalar magImpz = impz1 + impz2 + impz3 + impz4;
impz1 /= magImpz;
impz2 /= magImpz;
impz3 /= magImpz;
impz4 /= magImpz;
// calculate the correction vectors
vector corx1 = impx1*(p[0][i] - edgex1);
vector corx2 = impx2*(p[1][i] - edgex2);
vector corx3 = impx3*(p[2][i] - edgex3);
vector corx4 = impx4*(p[3][i] - edgex4);
vector cory1 = impy1*(p[4][j] - edgey1);
vector cory2 = impy2*(p[5][j] - edgey2);
vector cory3 = impy3*(p[6][j] - edgey3);
vector cory4 = impy4*(p[7][j] - edgey4);
vector corz1 = impz1*(p[8][k] - edgez1);
vector corz2 = impz2*(p[9][k] - edgez2);
vector corz3 = impz3*(p[10][k] - edgez3);
vector corz4 = impz4*(p[11][k] - edgez4);
// multiply by the importance factor
// x - direction
edgex1 *= impx1;
edgex2 *= impx2;
edgex3 *= impx3;
edgex4 *= impx4;
// y - direction
edgey1 *= impy1;
edgey2 *= impy2;
edgey3 *= impy3;
edgey4 *= impy4;
// z - direction
edgez1 *= impz1;
edgez2 *= impz2;
edgez3 *= impz3;
edgez4 *= impz4;
// add the contributions
vertices_[vertexNo] = edgex1 + edgex2 + edgex3 + edgex4;
vertices_[vertexNo] += edgey1 + edgey2 + edgey3 + edgey4;
vertices_[vertexNo] += edgez1 + edgez2 + edgez3 + edgez4;
vertices_[vertexNo] /= 3.0;
vertices_[vertexNo] += corx1 + corx2 + corx3 + corx4;
vertices_[vertexNo] += cory1 + cory2 + cory3 + cory4;
vertices_[vertexNo] += corz1 + corz2 + corz3 + corz4;
}
}
}
}
// ************************************************************************* //

View File

@ -1,145 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check the blockMesh topology
void Foam::blockMesh::checkBlockMesh(const polyMesh& bm)
{
Info<< nl << "Check block mesh topology" << endl;
bool blockMeshOK = true;
const pointField& points = bm.points();
const faceList& faces = bm.faces();
const cellList& cells = bm.cells();
const polyPatchList& patches = bm.boundaryMesh();
label nBoundaryFaces=0;
forAll(cells, celli)
{
nBoundaryFaces += cells[celli].nFaces();
}
nBoundaryFaces -= 2*bm.nInternalFaces();
label nDefinedBoundaryFaces=0;
forAll(patches, patchi)
{
nDefinedBoundaryFaces += patches[patchi].size();
}
Info<< nl << tab << "Basic statistics" << endl;
Info<< tab << tab << "Number of internal faces : "
<< bm.nInternalFaces() << endl;
Info<< tab << tab << "Number of boundary faces : "
<< nBoundaryFaces << endl;
Info<< tab << tab << "Number of defined boundary faces : "
<< nDefinedBoundaryFaces << endl;
Info<< tab << tab << "Number of undefined boundary faces : "
<< nBoundaryFaces - nDefinedBoundaryFaces << endl;
if ((nBoundaryFaces - nDefinedBoundaryFaces) > 0)
{
Info<< tab << tab << tab
<< "(Warning : only leave undefined the front and back planes "
<< "of 2D planar geometries!)" << endl;
}
Info<< nl << tab << "Checking patch -> block consistency" << endl;
forAll(patches, patchi)
{
const faceList& Patch = patches[patchi];
forAll(Patch, patchFacei)
{
const face& patchFace = Patch[patchFacei];
bool patchFaceOK = false;
forAll(cells, celli)
{
const labelList& cellFaces = cells[celli];
forAll(cellFaces, cellFacei)
{
if (patchFace == faces[cellFaces[cellFacei]])
{
patchFaceOK = true;
if
(
(
patchFace.normal(points)
& faces[cellFaces[cellFacei]].normal(points)
) < 0.0
)
{
Info<< tab << tab
<< "Face " << patchFacei
<< " of patch " << patchi
<< " (" << patches[patchi].name() << ")"
<< " points inwards"
<< endl;
blockMeshOK = false;
}
}
}
}
if (!patchFaceOK)
{
Info<< tab << tab
<< "Face " << patchFacei
<< " of patch " << patchi
<< " (" << patches[patchi].name() << ")"
<< " does not match any block faces" << endl;
blockMeshOK = false;
}
}
}
if (!blockMeshOK)
{
FatalErrorIn("blockMesh::checkBlockMesh(const polyMesh& bm)")
<< "Block mesh topology incorrect, stopping mesh generation!"
<< exit(FatalError);
}
}
// ************************************************************************* //

View File

@ -1,60 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::blockMesh::createBlockOffsets()
{
Info<< nl << "Creating block offsets" << endl;
blockMesh& blocks = *this;
nPoints_ = blocks[0].points().size();
nCells_ = blocks[0].cells().size();
labelList BlockOffsets(blocks.size());
BlockOffsets[0] = 0;
label blockLabel;
for (blockLabel=1; blockLabel<blocks.size(); blockLabel++)
{
nPoints_ += blocks[blockLabel].points().size();
nCells_ += blocks[blockLabel].cells().size();
BlockOffsets[blockLabel]
= BlockOffsets[blockLabel-1]
+ blocks[blockLabel-1].points().size();
}
return BlockOffsets;
}
// ************************************************************************* //

View File

@ -1,74 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "error.H"
#include "blockMesh.H"
#include "cellModeller.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::cellShapeList Foam::blockMesh::createCells()
{
Info<< nl << "Creating cells" << endl;
PtrList<cellShape> cells(nCells_);
blockMesh& blocks = *this;
const cellModel& hex = *(cellModeller::lookup("hex"));
label cellLabel = 0;
forAll(blocks, blockLabel)
{
const labelListList& blockCells = blocks[blockLabel].cells();
forAll(blockCells, blockCellLabel)
{
labelList cellPoints(blockCells[blockCellLabel].size());
forAll(cellPoints, cellPointLabel)
{
cellPoints[cellPointLabel] =
mergeList_
[
blockCells[blockCellLabel][cellPointLabel]
+ blockOffsets_[blockLabel]
];
}
// Construct collapsed cell and all to list
cells.set(cellLabel, new cellShape(hex, cellPoints, true));
cellLabel++;
}
}
return cells;
}
// ************************************************************************* //

View File

@ -1,559 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::labelList Foam::blockMesh::createMergeList()
{
Info<< nl << "Creating merge list " << flush;
labelList MergeList(nPoints_, -1);
blockMesh& blocks = *this;
const pointField& blockPoints = topology().points();
const cellList& blockCells = topology().cells();
const faceList& blockFaces = topology().faces();
const labelList& faceOwnerBlocks = topology().faceOwner();
// For efficiency, create merge pairs in the first pass
labelListListList glueMergePairs(blockFaces.size());
const labelList& faceNeighbourBlocks = topology().faceNeighbour();
forAll(blockFaces, blockFaceLabel)
{
label blockPlabel = faceOwnerBlocks[blockFaceLabel];
const pointField& blockPpoints = blocks[blockPlabel].points();
const labelList& blockPfaces = blockCells[blockPlabel];
bool foundFace = false;
label blockPfaceLabel;
for
(
blockPfaceLabel = 0;
blockPfaceLabel < blockPfaces.size();
blockPfaceLabel++
)
{
if
(
blockFaces[blockPfaces[blockPfaceLabel]]
== blockFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
if (!foundFace)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Cannot find merge face for block " << blockPlabel
<< exit(FatalError);
};
const labelListList& blockPfaceFaces =
blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
labelListList& curPairs = glueMergePairs[blockFaceLabel];
curPairs.setSize(blockPfaceFaces.size());
// Calculate sqr of the merge tolerance as 1/10th of the min sqr
// point to point distance on the block face.
// At the same time merge collated points on the block's faces
// (removes boundary poles etc.)
// Collated points detected by initally taking a constant factor of
// the size of the block.
boundBox bb(blockCells[blockPlabel].points(blockFaces, blockPoints));
const scalar mergeSqrDist = SMALL*magSqr(bb.span());
// This is an N^2 algorithm
scalar sqrMergeTol = GREAT;
forAll(blockPfaceFaces, blockPfaceFaceLabel)
{
const labelList& blockPfaceFacePoints
= blockPfaceFaces[blockPfaceFaceLabel];
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel2)
{
if (blockPfaceFacePointLabel != blockPfaceFacePointLabel2)
{
scalar magSqrDist = magSqr
(
blockPpoints[blockPfaceFacePoints
[blockPfaceFacePointLabel]]
- blockPpoints[blockPfaceFacePoints
[blockPfaceFacePointLabel2]]
);
if (magSqrDist < mergeSqrDist)
{
label PpointLabel =
blockPfaceFacePoints[blockPfaceFacePointLabel]
+ blockOffsets_[blockPlabel];
label PpointLabel2 =
blockPfaceFacePoints[blockPfaceFacePointLabel2]
+ blockOffsets_[blockPlabel];
label minPP2 = min(PpointLabel, PpointLabel2);
if (MergeList[PpointLabel] != -1)
{
minPP2 = min(minPP2, MergeList[PpointLabel]);
}
if (MergeList[PpointLabel2] != -1)
{
minPP2 = min(minPP2, MergeList[PpointLabel2]);
}
MergeList[PpointLabel] = MergeList[PpointLabel2]
= minPP2;
}
else
{
sqrMergeTol = min(sqrMergeTol, magSqrDist);
}
}
}
}
}
sqrMergeTol /= 10.0;
if (topology().isInternalFace(blockFaceLabel))
{
label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
const pointField& blockNpoints = blocks[blockNlabel].points();
const labelList& blockNfaces = blockCells[blockNlabel];
foundFace = false;
label blockNfaceLabel;
for
(
blockNfaceLabel = 0;
blockNfaceLabel < blockNfaces.size();
blockNfaceLabel++
)
{
if
(
blockFaces[blockNfaces[blockNfaceLabel]]
== blockFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
if (!foundFace)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Cannot find merge face for block " << blockNlabel
<< exit(FatalError);
};
const labelListList& blockNfaceFaces =
blocks[blockNlabel].boundaryPatches()[blockNfaceLabel];
if (blockPfaceFaces.size() != blockNfaceFaces.size())
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Inconsistent number of faces between block pair "
<< blockPlabel << " and " << blockNlabel
<< exit(FatalError);
}
bool found = false;
// N-squared point search over all points of all faces of
// master block over all point of all faces of slave block
forAll(blockPfaceFaces, blockPfaceFaceLabel)
{
const labelList& blockPfaceFacePoints
= blockPfaceFaces[blockPfaceFaceLabel];
labelList& cp = curPairs[blockPfaceFaceLabel];
cp.setSize(blockPfaceFacePoints.size());
cp = -1;
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
found = false;
forAll(blockNfaceFaces, blockNfaceFaceLabel)
{
const labelList& blockNfaceFacePoints
= blockNfaceFaces[blockNfaceFaceLabel];
forAll(blockNfaceFacePoints, blockNfaceFacePointLabel)
{
if
(
magSqr
(
blockPpoints
[blockPfaceFacePoints[blockPfaceFacePointLabel]]
- blockNpoints
[blockNfaceFacePoints[blockNfaceFacePointLabel]]
) < sqrMergeTol
)
{
// Found a new pair
found = true;
cp[blockPfaceFacePointLabel] =
blockNfaceFacePoints[blockNfaceFacePointLabel];
label PpointLabel =
blockPfaceFacePoints[blockPfaceFacePointLabel]
+ blockOffsets_[blockPlabel];
label NpointLabel =
blockNfaceFacePoints[blockNfaceFacePointLabel]
+ blockOffsets_[blockNlabel];
label minPN = min(PpointLabel, NpointLabel);
if (MergeList[PpointLabel] != -1)
{
minPN = min(minPN, MergeList[PpointLabel]);
}
if (MergeList[NpointLabel] != -1)
{
minPN = min(minPN, MergeList[NpointLabel]);
}
MergeList[PpointLabel] = MergeList[NpointLabel]
= minPN;
}
}
}
}
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
if (cp[blockPfaceFacePointLabel] == -1)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Inconsistent point locations between block pair "
<< blockPlabel << " and " << blockNlabel << nl
<< " probably due to inconsistent grading."
<< exit(FatalError);
}
}
}
}
}
const faceList::subList blockInternalFaces
(
blockFaces,
topology().nInternalFaces()
);
bool changedPointMerge = false;
label nPasses = 0;
do
{
changedPointMerge = false;
nPasses++;
forAll(blockInternalFaces, blockFaceLabel)
{
label blockPlabel = faceOwnerBlocks[blockFaceLabel];
label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
const labelList& blockPfaces = blockCells[blockPlabel];
const labelList& blockNfaces = blockCells[blockNlabel];
const labelListList& curPairs = glueMergePairs[blockFaceLabel];
bool foundFace = false;
label blockPfaceLabel;
for
(
blockPfaceLabel = 0;
blockPfaceLabel < blockPfaces.size();
blockPfaceLabel++
)
{
if
(
blockFaces[blockPfaces[blockPfaceLabel]]
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
foundFace = false;
label blockNfaceLabel;
for
(
blockNfaceLabel = 0;
blockNfaceLabel < blockNfaces.size();
blockNfaceLabel++
)
{
if
(
blockFaces[blockNfaces[blockNfaceLabel]]
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
const labelListList& blockPfaceFaces =
blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
forAll(blockPfaceFaces, blockPfaceFaceLabel)
{
const labelList& blockPfaceFacePoints
= blockPfaceFaces[blockPfaceFaceLabel];
const labelList& cp = curPairs[blockPfaceFaceLabel];
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
label PpointLabel =
blockPfaceFacePoints[blockPfaceFacePointLabel]
+ blockOffsets_[blockPlabel];
label NpointLabel =
cp[blockPfaceFacePointLabel]
+ blockOffsets_[blockNlabel];
if
(
MergeList[PpointLabel]
!= MergeList[NpointLabel]
)
{
changedPointMerge = true;
MergeList[PpointLabel]
= MergeList[NpointLabel]
= min
(
MergeList[PpointLabel],
MergeList[NpointLabel]
);
}
}
}
}
Info << "." << flush;
if (nPasses > 100)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Point merging failed after max number of passes."
<< abort(FatalError);
}
}
while (changedPointMerge);
Info << endl;
forAll(blockInternalFaces, blockFaceLabel)
{
label blockPlabel = faceOwnerBlocks[blockFaceLabel];
label blockNlabel = faceNeighbourBlocks[blockFaceLabel];
const labelList& blockPfaces = blockCells[blockPlabel];
const labelList& blockNfaces = blockCells[blockNlabel];
const pointField& blockPpoints = blocks[blockPlabel].points();
const pointField& blockNpoints = blocks[blockNlabel].points();
bool foundFace = false;
label blockPfaceLabel;
for
(
blockPfaceLabel = 0;
blockPfaceLabel < blockPfaces.size();
blockPfaceLabel++
)
{
if
(
blockFaces[blockPfaces[blockPfaceLabel]]
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
if (!foundFace)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Cannot find merge face for block " << blockPlabel
<< exit(FatalError);
};
foundFace = false;
label blockNfaceLabel;
for
(
blockNfaceLabel = 0;
blockNfaceLabel < blockNfaces.size();
blockNfaceLabel++
)
{
if
(
blockFaces[blockNfaces[blockNfaceLabel]]
== blockInternalFaces[blockFaceLabel]
)
{
foundFace = true;
break;
}
}
if (!foundFace)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Cannot find merge face for block " << blockNlabel
<< exit(FatalError);
};
const labelListList& blockPfaceFaces =
blocks[blockPlabel].boundaryPatches()[blockPfaceLabel];
const labelListList& blockNfaceFaces =
blocks[blockNlabel].boundaryPatches()[blockNfaceLabel];
forAll(blockPfaceFaces, blockPfaceFaceLabel)
{
const labelList& blockPfaceFacePoints
= blockPfaceFaces[blockPfaceFaceLabel];
forAll(blockPfaceFacePoints, blockPfaceFacePointLabel)
{
label PpointLabel =
blockPfaceFacePoints[blockPfaceFacePointLabel]
+ blockOffsets_[blockPlabel];
if (MergeList[PpointLabel] == -1)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "Unable to merge point "
<< blockPfaceFacePointLabel
<< ' ' << blockPpoints[blockPfaceFacePointLabel]
<< " of face "
<< blockPfaceLabel
<< " of block "
<< blockPlabel
<< exit(FatalError);
}
}
}
forAll(blockNfaceFaces, blockNfaceFaceLabel)
{
const labelList& blockNfaceFacePoints
= blockNfaceFaces[blockNfaceFaceLabel];
forAll(blockNfaceFacePoints, blockNfaceFacePointLabel)
{
label NpointLabel =
blockNfaceFacePoints[blockNfaceFacePointLabel]
+ blockOffsets_[blockNlabel];
if (MergeList[NpointLabel] == -1)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "unable to merge point "
<< blockNfaceFacePointLabel
<< ' ' << blockNpoints[blockNfaceFacePointLabel]
<< " of face "
<< blockNfaceLabel
<< " of block "
<< blockNlabel
<< exit(FatalError);
}
}
}
}
// sort merge list to return new point label (in new shorter list)
// given old point label
label newPointLabel = 0;
forAll(MergeList, pointLabel)
{
if (MergeList[pointLabel] > pointLabel)
{
FatalErrorIn("blockMesh::createMergeList()")
<< "ouch" << exit(FatalError);
}
if
(
(MergeList[pointLabel] == -1)
|| MergeList[pointLabel] == pointLabel
)
{
MergeList[pointLabel] = newPointLabel;
newPointLabel++;
}
else
{
MergeList[pointLabel] = MergeList[MergeList[pointLabel]];
}
}
nPoints_ = newPointLabel;
return MergeList;
}
// ************************************************************************* //

View File

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::faceList Foam::blockMesh::createPatchFaces
(
const polyPatch& patchTopologyFaces
)
{
blockMesh& blocks = *this;
labelList blockLabels = patchTopologyFaces.polyPatch::faceCells();
label nFaces=0;
forAll(patchTopologyFaces, patchTopologyFaceLabel)
{
label blockLabel = blockLabels[patchTopologyFaceLabel];
faceList blockFaces
(
blocks[blockLabel].blockDef().blockShape().faces()
);
forAll(blockFaces, blockFaceLabel)
{
if
(
blockFaces[blockFaceLabel]
== patchTopologyFaces[patchTopologyFaceLabel]
)
{
nFaces +=
blocks[blockLabel].boundaryPatches()[blockFaceLabel].size();
}
}
}
faceList patchFaces(nFaces);
face quadFace(4);
label faceLabel = 0;
forAll(patchTopologyFaces, patchTopologyFaceLabel)
{
label blockLabel = blockLabels[patchTopologyFaceLabel];
faceList blockFaces
(
blocks[blockLabel].blockDef().blockShape().faces()
);
forAll(blockFaces, blockFaceLabel)
{
if
(
blockFaces[blockFaceLabel]
== patchTopologyFaces[patchTopologyFaceLabel]
)
{
const labelListList& blockPatchFaces =
blocks[blockLabel].boundaryPatches()[blockFaceLabel];
forAll(blockPatchFaces, blockFaceLabel)
{
// Lookup the face points
// and collapse duplicate point labels
quadFace[0] =
mergeList_
[
blockPatchFaces[blockFaceLabel][0]
+ blockOffsets_[blockLabel]
];
label nUnique = 1;
for
(
label facePointLabel = 1;
facePointLabel < 4;
facePointLabel++
)
{
quadFace[nUnique] =
mergeList_
[
blockPatchFaces[blockFaceLabel][facePointLabel]
+ blockOffsets_[blockLabel]
];
if (quadFace[nUnique] != quadFace[nUnique-1])
{
nUnique++;
}
}
if (quadFace[nUnique-1] == quadFace[0])
{
nUnique--;
}
if (nUnique == 4)
{
patchFaces[faceLabel++] = quadFace;
}
else if (nUnique == 3)
{
patchFaces[faceLabel++] = face
(
labelList::subList(quadFace, 3)
);
}
// else the face has collapsed to an edge or point
}
}
}
}
patchFaces.setSize(faceLabel);
return patchFaces;
}
Foam::faceListList Foam::blockMesh::createPatches()
{
Info<< "\nCreating patches\n";
const polyPatchList& patchTopologies = topology().boundaryMesh();
faceListList patches(patchTopologies.size());
forAll(patchTopologies, patchLabel)
{
patches[patchLabel] =
createPatchFaces(patchTopologies[patchLabel]);
}
return patches;
}
// ************************************************************************* //

View File

@ -1,71 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockMesh.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::pointField Foam::blockMesh::createPoints(const dictionary& dict)
{
blockMesh& blocks = *this;
scalar scaleFactor = 1.0;
// optional 'convertToMeters' (or 'scale'?)
if (!dict.readIfPresent("convertToMeters", scaleFactor))
{
dict.readIfPresent("scale", scaleFactor);
}
Info<< nl << "Creating points with scale " << scaleFactor << endl;
pointField points(nPoints_);
forAll(blocks, blockLabel)
{
const pointField& blockPoints = blocks[blockLabel].points();
forAll(blockPoints, blockPointLabel)
{
points
[
mergeList_
[
blockPointLabel
+ blockOffsets_[blockLabel]
]
] = scaleFactor * blockPoints[blockPointLabel];
}
}
return points;
}
// ************************************************************************* //

View File

@ -1,656 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "blockMesh.H"
#include "Time.H"
#include "preservePatchTypes.H"
#include "emptyPolyPatch.H"
#include "cyclicPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool Foam::blockMesh::blockLabelsOK
(
const label blockLabel,
const pointField& points,
const cellShape& blockShape
)
{
bool ok = true;
forAll(blockShape, blockI)
{
if (blockShape[blockI] < 0)
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::blockLabelsOK"
"(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)"
) << "block " << blockLabel
<< " point label " << blockShape[blockI]
<< " less than zero" << endl;
}
else if (blockShape[blockI] >= points.size())
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::blockLabelsOK"
"(const label blockLabel, const pointField& points, "
"const cellShape& blockShape)"
) << "block " << blockLabel
<< " point label " << blockShape[blockI]
<< " larger than " << points.size() - 1
<< " the largest defined point label" << endl;
}
}
return ok;
}
bool Foam::blockMesh::patchLabelsOK
(
const label patchLabel,
const pointField& points,
const faceList& patchFaces
)
{
bool ok = true;
forAll(patchFaces, faceI)
{
const labelList& f = patchFaces[faceI];
forAll(f, fp)
{
if (f[fp] < 0)
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::patchLabelsOK(...)"
) << "patch " << patchLabel
<< " face " << faceI
<< " point label " << f[fp]
<< " less than zero" << endl;
}
else if (f[fp] >= points.size())
{
ok = false;
WarningIn
(
"bool Foam::blockMesh::patchLabelsOK(...)"
) << "patch " << patchLabel
<< " face " << faceI
<< " point label " << f[fp]
<< " larger than " << points.size() - 1
<< " the largest defined point label" << endl;
}
}
}
return ok;
}
bool Foam::blockMesh::readPatches
(
const dictionary& meshDescription,
const pointField& tmpBlockPoints,
faceListList& tmpBlocksPatches,
wordList& patchNames,
wordList& patchTypes,
wordList& nbrPatchNames
)
{
bool topologyOK = true;
ITstream& patchStream(meshDescription.lookup("patches"));
// read number of patches in mesh
label nPatches = 0;
token firstToken(patchStream);
if (firstToken.isLabel())
{
nPatches = firstToken.labelToken();
tmpBlocksPatches.setSize(nPatches);
patchNames.setSize(nPatches);
patchTypes.setSize(nPatches);
nbrPatchNames.setSize(nPatches);
}
else
{
patchStream.putBack(firstToken);
}
// Read beginning of blocks
patchStream.readBegin("patches");
nPatches = 0;
token lastToken(patchStream);
while
(
!(
lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST
)
)
{
if (tmpBlocksPatches.size() <= nPatches)
{
tmpBlocksPatches.setSize(nPatches + 1);
patchNames.setSize(nPatches + 1);
patchTypes.setSize(nPatches + 1);
nbrPatchNames.setSize(nPatches + 1);
}
patchStream.putBack(lastToken);
patchStream
>> patchTypes[nPatches]
>> patchNames[nPatches];
// Read optional neighbour patch name
if (patchTypes[nPatches] == cyclicPolyPatch::typeName)
{
patchStream >> lastToken;
if (lastToken.isWord())
{
nbrPatchNames[nPatches] = lastToken.wordToken();
}
else
{
patchStream.putBack(lastToken);
}
}
// Read patch faces
patchStream >> tmpBlocksPatches[nPatches];
// Catch multiple patches asap.
for (label i = 0; i < nPatches; i++)
{
if (patchNames[nPatches] == patchNames[i])
{
FatalErrorIn
(
"blockMesh::createTopology(IOdictionary&)"
) << "Duplicate patch " << patchNames[nPatches]
<< " at line " << patchStream.lineNumber()
<< ". Exiting !" << nl
<< exit(FatalError);
}
}
topologyOK = topologyOK && patchLabelsOK
(
nPatches,
tmpBlockPoints,
tmpBlocksPatches[nPatches]
);
nPatches++;
// Split old style cyclics
if (patchTypes[nPatches-1] == cyclicPolyPatch::typeName)
{
if (nbrPatchNames[nPatches] == word::null)
{
word halfA = patchNames[nPatches-1] + "_half0";
word halfB = patchNames[nPatches-1] + "_half1";
WarningIn("blockMesh::createTopology(IOdictionary&)")
<< "Old-style cyclic definition."
<< " Splitting patch "
<< patchNames[nPatches-1] << " into two halves "
<< halfA << " and " << halfB << endl
<< " Alternatively use new syntax "
<< " cyclic <name> <neighbourname> <faces>" << endl;
// Add extra patch
if (tmpBlocksPatches.size() <= nPatches)
{
tmpBlocksPatches.setSize(nPatches + 1);
patchNames.setSize(nPatches + 1);
patchTypes.setSize(nPatches + 1);
nbrPatchNames.setSize(nPatches + 1);
}
patchNames[nPatches-1] = halfA;
nbrPatchNames[nPatches-1] = halfB;
patchTypes[nPatches] = patchTypes[nPatches-1];
patchNames[nPatches] = halfB;
nbrPatchNames[nPatches] = halfA;
// Split faces
if ((tmpBlocksPatches[nPatches-1].size() % 2) != 0)
{
FatalErrorIn
(
"blockMesh::createTopology(IOdictionary&)"
) << "Size of cyclic faces is not a multiple of 2 :"
<< tmpBlocksPatches[nPatches-1]
<< exit(FatalError);
}
label sz = tmpBlocksPatches[nPatches-1].size()/2;
faceList unsplitFaces(tmpBlocksPatches[nPatches-1], true);
tmpBlocksPatches[nPatches-1] = faceList
(
SubList<face>(unsplitFaces, sz)
);
tmpBlocksPatches[nPatches] = faceList
(
SubList<face>(unsplitFaces, sz, sz)
);
nPatches++;
}
}
patchStream >> lastToken;
}
patchStream.putBack(lastToken);
// Read end of blocks
patchStream.readEnd("patches");
return topologyOK;
}
bool Foam::blockMesh::readBoundary
(
const dictionary& meshDescription,
const pointField& tmpBlockPoints,
faceListList& tmpBlocksPatches,
PtrList<dictionary>& patchDicts
)
{
bool topologyOK = true;
// Read like boundary file
const PtrList<entry> patchesInfo
(
meshDescription.lookup("boundary")
);
tmpBlocksPatches.setSize(patchesInfo.size());
patchDicts.setSize(patchesInfo.size());
forAll(tmpBlocksPatches, patchI)
{
const entry& patchInfo = patchesInfo[patchI];
// Construct dictionary and add name
patchDicts.set(patchI, new dictionary(patchInfo.dict()));
patchDicts[patchI].set("name", patchInfo.keyword());
// Read block faces
patchDicts[patchI].lookup("faces") >> tmpBlocksPatches[patchI];
topologyOK = topologyOK && patchLabelsOK
(
patchI,
tmpBlockPoints,
tmpBlocksPatches[patchI]
);
}
return topologyOK;
}
void Foam::blockMesh::createCellShapes
(
const pointField& tmpBlockPoints,
PtrList<cellShape>& tmpBlockCells
)
{
const blockMesh& blocks = *this;
tmpBlockCells.setSize(blocks.size());
forAll(blocks, blockLabel)
{
tmpBlockCells.set
(
blockLabel,
new cellShape(blocks[blockLabel].blockDef().blockShape())
);
if (tmpBlockCells[blockLabel].mag(tmpBlockPoints) < 0.0)
{
WarningIn
(
"blockMesh::createTopology(IOdictionary&)"
) << "negative volume block : " << blockLabel
<< ", probably defined inside-out" << endl;
}
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& meshDescription)
{
bool topologyOK = true;
blockMesh& blocks = *this;
word defaultPatchName = "defaultFaces";
word defaultPatchType = emptyPolyPatch::typeName;
// get names/types for the unassigned patch faces
// this is a bit heavy handed (and ugly), but there is currently
// no easy way to rename polyMesh patches subsequently
if (const dictionary* dictPtr = meshDescription.subDictPtr("defaultPatch"))
{
dictPtr->readIfPresent("name", defaultPatchName);
dictPtr->readIfPresent("type", defaultPatchType);
}
Info<< nl << "Creating blockCorners" << endl;
// create blockCorners
pointField tmpBlockPoints(meshDescription.lookup("vertices"));
if (meshDescription.found("edges"))
{
// read number of non-linear edges in mesh
Info<< nl << "Creating curved edges" << endl;
ITstream& edgesStream(meshDescription.lookup("edges"));
label nEdges = 0;
token firstToken(edgesStream);
if (firstToken.isLabel())
{
nEdges = firstToken.labelToken();
edges_.setSize(nEdges);
}
else
{
edgesStream.putBack(firstToken);
}
// Read beginning of edges
edgesStream.readBegin("edges");
nEdges = 0;
token lastToken(edgesStream);
while
(
!(
lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST
)
)
{
if (edges_.size() <= nEdges)
{
edges_.setSize(nEdges + 1);
}
edgesStream.putBack(lastToken);
edges_.set
(
nEdges,
curvedEdge::New(tmpBlockPoints, edgesStream)
);
nEdges++;
edgesStream >> lastToken;
}
edgesStream.putBack(lastToken);
// Read end of edges
edgesStream.readEnd("edges");
}
else
{
Info<< nl << "There are no non-linear edges" << endl;
}
Info<< nl << "Creating blocks" << endl;
{
ITstream& blockDescriptorStream(meshDescription.lookup("blocks"));
// read number of blocks in mesh
label nBlocks = 0;
token firstToken(blockDescriptorStream);
if (firstToken.isLabel())
{
nBlocks = firstToken.labelToken();
blocks.setSize(nBlocks);
}
else
{
blockDescriptorStream.putBack(firstToken);
}
// Read beginning of blocks
blockDescriptorStream.readBegin("blocks");
nBlocks = 0;
token lastToken(blockDescriptorStream);
while
(
!(
lastToken.isPunctuation()
&& lastToken.pToken() == token::END_LIST
)
)
{
if (blocks.size() <= nBlocks)
{
blocks.setSize(nBlocks + 1);
}
blockDescriptorStream.putBack(lastToken);
blocks.set
(
nBlocks,
new block
(
blockDescriptor
(
tmpBlockPoints,
edges_,
blockDescriptorStream
)
)
);
topologyOK = topologyOK && blockLabelsOK
(
nBlocks,
tmpBlockPoints,
blocks[nBlocks].blockDef().blockShape()
);
nBlocks++;
blockDescriptorStream >> lastToken;
}
blockDescriptorStream.putBack(lastToken);
// Read end of blocks
blockDescriptorStream.readEnd("blocks");
}
polyMesh* blockMeshPtr = NULL;
Info<< nl << "Creating patches" << endl;
if (meshDescription.found("patches"))
{
Info<< nl << "Reading patches section" << endl;
faceListList tmpBlocksPatches;
wordList patchNames;
wordList patchTypes;
wordList nbrPatchNames;
topologyOK = topologyOK && readPatches
(
meshDescription,
tmpBlockPoints,
tmpBlocksPatches,
patchNames,
patchTypes,
nbrPatchNames
);
if (!topologyOK)
{
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
<< "Cannot create mesh due to errors in topology, exiting !"
<< nl << exit(FatalError);
}
Info<< nl << "Creating block mesh topology" << endl;
PtrList<cellShape> tmpBlockCells(blocks.size());
createCellShapes(tmpBlockPoints, tmpBlockCells);
Info<< nl << "Reading physicalType from existing boundary file" << endl;
wordList patchPhysicalTypes(tmpBlocksPatches.size());
preservePatchTypes
(
meshDescription.time(),
meshDescription.time().constant(),
polyMesh::meshSubDir,
patchNames,
patchTypes,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
);
blockMeshPtr = new polyMesh
(
IOobject
(
"blockMesh",
meshDescription.time().constant(),
meshDescription.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove(tmpBlockPoints),
tmpBlockCells,
tmpBlocksPatches,
patchNames,
patchTypes,
defaultPatchName,
defaultPatchType,
patchPhysicalTypes
);
}
else if (meshDescription.found("boundary"))
{
faceListList tmpBlocksPatches;
PtrList<dictionary> patchDicts;
topologyOK = topologyOK && readBoundary
(
meshDescription,
tmpBlockPoints,
tmpBlocksPatches,
patchDicts
);
if (!topologyOK)
{
FatalErrorIn("blockMesh::createTopology(IOdictionary&)")
<< "Cannot create mesh due to errors in topology, exiting !"
<< nl << exit(FatalError);
}
Info<< nl << "Creating block mesh topology" << endl;
PtrList<cellShape> tmpBlockCells(blocks.size());
createCellShapes(tmpBlockPoints, tmpBlockCells);
blockMeshPtr = new polyMesh
(
IOobject
(
"blockMesh",
meshDescription.time().constant(),
meshDescription.time(),
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove(tmpBlockPoints),
tmpBlockCells,
tmpBlocksPatches,
patchDicts,
defaultPatchName,
defaultPatchType
);
}
checkBlockMesh(*blockMeshPtr);
return blockMeshPtr;
}
// ************************************************************************* //

View File

@ -1,55 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
InClass
Foam::curvedEdgeList
Description
\*---------------------------------------------------------------------------*/
#ifndef curvedEdgeList_H
#define curvedEdgeList_H
#include "curvedEdge.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
typedef PtrList<curvedEdge> curvedEdgeList;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,158 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
BSpline : cubic spline going through all the knots
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "BSpline.H"
#include "simpleMatrix.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
pointField BSpline::findKnots
(
const pointField& allknots,
const vector& fstend,
const vector& sndend
)
{
label newnKnots(allknots.size() + 2);
label NKnots(allknots.size());
pointField newknots(newnKnots);
// set up 1/6 and 2/3 which are the matrix elements throughout most
// of the matrix
register scalar oneSixth = 1.0/6.0;
register scalar twoThird = 2.0/3.0;
simpleMatrix<vector> M(newnKnots);
// set up the matrix
M[0][0] = -0.5*scalar(NKnots - 1);
M[0][2] = 0.5*scalar(NKnots - 1);
for (register label i=1; i<newnKnots-1; i++)
{
M[i][i-1] = oneSixth;
M[i][i] = twoThird;
M[i][i+1] = oneSixth;
}
M[newnKnots - 1][newnKnots - 3] = -0.5*scalar(NKnots - 1);
M[newnKnots - 1][newnKnots - 1] = 0.5*scalar(NKnots - 1);
// set up the vector
for (label i=1; i<=NKnots; i++)
{
M.source()[i] = allknots[i-1];
}
// set the gradients at the two ends
if (mag(fstend)<1e-8)
{
// set to the default : forward differences on the end knots
M.source()[0] = allknots[1] - allknots[0];
M.source()[0] /= mag(M.source()[0]);
M.source()[NKnots+1] = M.source()[NKnots-1] - M.source()[NKnots];
M.source()[NKnots+1] /= mag(M.source()[NKnots+1]);
}
else
{
// set to the gradient vectors provided
M.source()[0] = fstend/mag(fstend);
M.source()[NKnots+1] = sndend/mag(sndend);
}
// invert the equation to find the control knots
newknots = M.solve();
return newknots;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
BSpline::BSpline(const pointField& Knots)
:
spline(findKnots(Knots))
{}
// Construct from components
BSpline::BSpline
(
const pointField& Knots,
const vector& fstend,
const vector& sndend
)
:
spline(findKnots(Knots, fstend, sndend))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the real position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector BSpline::realPosition(scalar mu)
{
return spline::position(mu);
}
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector BSpline::position(const scalar mu) const
{
return spline::position((1.0/(nKnots() - 1))*(1.0 + mu*(nKnots() - 3)));
}
//- Return the length of the curve
scalar BSpline::length() const
{
notImplemented("BSpline::length() const");
return 1.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,105 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::BSpline
Description
BSpline : cubic spline going through all the knots
SourceFiles
BSpline.C
\*---------------------------------------------------------------------------*/
#ifndef BSpline_H
#define BSpline_H
#include "spline.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class BSpline Declaration
\*---------------------------------------------------------------------------*/
class BSpline
:
public spline
{
// Private member functions
scalar remap(const scalar&);
pointField findKnots
(
const pointField&,
const vector& fstend = vector::zero,
const vector& sndend = vector::zero
);
public:
// Constructors
//- Construct from components
BSpline(const pointField& knots);
//- Construct from components
BSpline
(
const pointField& knots,
const vector& fstend,
const vector& sndend
);
// Member Functions
//- Return the real position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector realPosition(scalar lambda);
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar lambda) const;
//- Return the length of the curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,171 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
arcEdge class : defines the arcEdge of a circle in terms of 3 points on its
circumference
\*---------------------------------------------------------------------------*/
#include "arcEdge.H"
#include "mathematicalConstants.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(arcEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
addToRunTimeSelectionTable(curvedEdge, arcEdge, Istream);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::cylindricalCS Foam::arcEdge::calcAngle()
{
vector a = p2_ - p1_;
vector b = p3_ - p1_;
// find centre of arcEdge
scalar asqr = a & a;
scalar bsqr = b & b;
scalar adotb = a & b;
scalar denom = asqr*bsqr - adotb*adotb;
if (mag(denom) < VSMALL)
{
FatalErrorIn("cylindricalCS arcEdge::calcAngle()")
<< "Invalid arc definition - are the points co-linear? Denom ="
<< denom
<< abort(FatalError);
}
scalar fact = 0.5*(bsqr - adotb)/denom;
vector centre = 0.5*a + fact*((a ^ b) ^ a);
centre += p1_;
// find position vectors w.r.t. the arcEdge centre
vector r1(p1_ - centre);
vector r2(p2_ - centre);
vector r3(p3_ - centre);
// find angles
scalar tmp = (r3&r1)/(mag(r3)*mag(r1));
angle_ = acos(tmp)*180.0/mathematicalConstant::pi;
// check if the vectors define an exterior or an interior arcEdge
if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) angle_ = 360 - angle_;
vector tempAxis(0.0,0.0,0.0);
if (angle_ <= 180.0)
{
tempAxis = r1 ^ r3;
if (mag(tempAxis)/(mag(r1)*mag(r3)) < 0.001) tempAxis = r1 ^ r2;
}
else
{
tempAxis = r3 ^ r1;
}
radius_ = mag(r3);
// set up and return the local coordinate system
return cylindricalCS("tmpCS", centre, tempAxis, r1);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::arcEdge::arcEdge
(
const pointField& points,
const label start,
const label end,
const vector& P2
)
:
curvedEdge(points, start, end),
p1_(points_[start_]),
p2_(P2),
p3_(points_[end_]),
cs_(calcAngle())
{}
// Construct from Istream
Foam::arcEdge::arcEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
p1_(points_[start_]),
p2_(is),
p3_(points_[end_]),
cs_(calcAngle())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::arcEdge::position(const scalar lambda) const
{
if (lambda < 0 || lambda > 1)
{
FatalErrorIn("arcEdge::position(const scalar lambda) const")
<< "Parameter out of range, lambda = " << lambda
<< abort(FatalError);
}
if (lambda < SMALL)
{
return p1_;
}
else if (lambda > 1-SMALL)
{
return p3_;
}
else
{
return cs_.globalPosition(vector(radius_, lambda*angle_, 0.0));
}
}
//- Return the length of the curve
Foam::scalar Foam::arcEdge::length() const
{
return angle_*radius_*mathematicalConstant::pi/180.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -1,109 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::arcEdge
Description
arcEdge class : defines the arcEdge of a circle in terms of 3 points on its
circumference
SourceFiles
arcEdge.C
\*---------------------------------------------------------------------------*/
#ifndef arcEdge_H
#define arcEdge_H
#include "curvedEdge.H"
#include "cylindricalCS.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class arcEdge Declaration
\*---------------------------------------------------------------------------*/
class arcEdge
:
public curvedEdge
{
// Private data
vector p1_, p2_, p3_;
scalar angle_;
scalar radius_;
cylindricalCS cs_;
cylindricalCS calcAngle();
public:
//- Runtime type information
TypeName("arc");
// Constructors
//- Construct from components
arcEdge
(
const pointField& points,
const label start, const label end,
const vector&
);
//- Construct from Istream setting pointsList
arcEdge(const pointField& points, Istream&);
// Destructor
virtual ~arcEdge(){}
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the length of the curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,166 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
library functions that will define a curvedEdge in space
parameterised for 0<lambda<1 from the beginning
point to the end point.
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "curvedEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(curvedEdge, 0);
defineRunTimeSelectionTable(curvedEdge, Istream);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
curvedEdge::curvedEdge
(
const pointField& points,
const label start,
const label end
)
:
points_(points),
start_(start),
end_(end)
{}
// Construct from Istream
curvedEdge::curvedEdge(const pointField& points, Istream& is)
:
points_(points),
start_(readLabel(is)),
end_(readLabel(is))
{}
// Copy construct
curvedEdge::curvedEdge(const curvedEdge& c)
:
points_(c.points_),
start_(c.start_),
end_(c.end_)
{}
//- Clone function
autoPtr<curvedEdge> curvedEdge::clone() const
{
notImplemented("curvedEdge::clone() const");
return autoPtr<curvedEdge>(NULL);
}
//- New function which constructs and returns pointer to a curvedEdge
autoPtr<curvedEdge> curvedEdge::New(const pointField& points, Istream& is)
{
if (debug)
{
Info<< "curvedEdge::New(const pointField&, Istream&) : "
<< "constructing curvedEdge"
<< endl;
}
word curvedEdgeType(is);
IstreamConstructorTable::iterator cstrIter =
IstreamConstructorTablePtr_
->find(curvedEdgeType);
if (cstrIter == IstreamConstructorTablePtr_->end())
{
FatalErrorIn("curvedEdge::New(const pointField&, Istream&)")
<< "Unknown curvedEdge type " << curvedEdgeType << endl << endl
<< "Valid curvedEdge types are" << endl
<< IstreamConstructorTablePtr_->toc()
<< abort(FatalError);
}
return autoPtr<curvedEdge>(cstrIter()(points, is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the complete knotList by adding the start and end points to the
// given list
pointField knotlist
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
)
{
label listsize(otherknots.size() + 2);
pointField tmp(listsize);
tmp[0] = points[start];
for (register label i=1; i<listsize-1; i++)
{
tmp[i] = otherknots[i-1];
}
tmp[listsize-1] = points[end];
return tmp;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
void curvedEdge::operator=(const curvedEdge&)
{
notImplemented("void curvedEdge::operator=(const curvedEdge&)");
}
Ostream& operator<<(Ostream& os, const curvedEdge& p)
{
os << p.start_ << tab << p.end_ << endl;
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,173 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::curvedEdge
Description
curvedEdges : library functions that will define a curvedEdge in space
parameterised for 0<lambda<1 from the beginning point to the end point.
This file contains the abstract base class curvedEdge.
SourceFiles
curvedEdge.C
\*---------------------------------------------------------------------------*/
#ifndef curvedEdges_H
#define curvedEdges_H
#include "pointField.H"
#include "typeInfo.H"
#include "HashTable.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class curvedEdge Declaration
\*---------------------------------------------------------------------------*/
class curvedEdge
{
protected:
// Protected data
const pointField& points_;
const label start_, end_;
public:
//- Runtime type information
TypeName("curvedEdge");
// Declare run-time constructor selection tables
declareRunTimeSelectionTable
(
autoPtr,
curvedEdge,
Istream,
(
const pointField& points,
Istream& is
),
(points, is)
);
// Constructors
//- Construct from components
curvedEdge
(
const pointField& points,
const label start,
const label end
);
//- Construct from Istream setting pointsList
curvedEdge(const pointField&, Istream&);
//- Copy construct
curvedEdge(const curvedEdge&);
//- Clone function
virtual autoPtr<curvedEdge> clone() const;
//- New function which constructs and returns pointer to a curvedEdge
static autoPtr<curvedEdge> New(const pointField&, Istream&);
// Destructor
virtual ~curvedEdge(){}
// Member Functions
//- Return label of start point
label start() const
{
return start_;
}
//- Return label of end point
label end() const
{
return end_;
}
//- Compare the given start and end points with those of this curve
bool compare(const label start, const label end) const
{
return
(
(start_ == start && end_ == end)
|| (start_ == end && end_ == start)
);
}
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
virtual vector position(const scalar) const = 0;
//- Return the length of the curve
virtual scalar length() const = 0;
// Member operators
void operator=(const curvedEdge&);
// Ostream operator
friend Ostream& operator<<(Ostream&, const curvedEdge&);
};
//- Return the complete knotList by adding the start and end points to the
// given list
pointField knotlist
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
lineDivide class : divides a line into segments
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "lineDivide.H"
#include "curvedEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
lineDivide::lineDivide(const curvedEdge& bc, const label n, const scalar xratio)
:
points_(n + 1),
divisions_(n + 1),
noPoints_(n)
{
scalar np(n);
scalar lambda(0.0);
if (xratio == 1.0)
{
scalar y(1.0/np);
for (label i=0; i<=noPoints_; i++)
{
lambda = scalar(i)/np;
points_[i] = bc.position(lambda);
divisions_[i] = y*i;
}
}
else
{
points_[0] = bc.position(0.0);
divisions_[0] = 0.0;
scalar xrpower = 1.0;
for (label i=1; i<=noPoints_; i++)
{
lambda = (1.0 - pow(xratio, i))/(1.0 - pow(xratio, np));
points_[i] = bc.position(lambda);
divisions_[i] = lambda;
xrpower *= xratio;
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const pointField& lineDivide::points() const
{
return points_;
}
const scalarList& lineDivide::lambdaDivisions() const
{
return divisions_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,88 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::lineDivide
Description
lineDivide class : divides a line into segments
SourceFiles
lineDivide.C
\*---------------------------------------------------------------------------*/
#ifndef lineDivide_H
#define lineDivide_H
#include "pointField.H"
#include "scalarList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class curvedEdge;
/*---------------------------------------------------------------------------*\
Class lineDivide Declaration
\*---------------------------------------------------------------------------*/
class lineDivide
{
// Private data
pointField points_;
scalarList divisions_;
label noPoints_;
public:
// Constructors
//- Construct from components
lineDivide(const curvedEdge&, const label, const scalar = 1.0);
// Member Functions
//- Return the points
const pointField& points() const;
//- Return the list of lambda values
const scalarList& lambdaDivisions() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,100 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
line class : defines a straight line between the start point and the
end point
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "lineEdge.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(lineEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<lineEdge>
addLineEdgeIstreamConstructorToTable_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
lineEdge::lineEdge
(
const pointField& points,
const label start,
const label end
)
:
curvedEdge(points, start, end),
startPoint_(points_[start_]),
direction_(points_[end_] - points_[start_])
{}
// Construct from Istream
lineEdge::lineEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
startPoint_(points_[start_]),
direction_(points_[end_] - points_[start_])
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vector lineEdge::position(const scalar lambda) const
{
if (lambda < 0 || lambda > 1)
{
FatalErrorIn("lineEdge::position(const scalar)")
<< "Parameter out of range, lambda = " << lambda
<< abort(FatalError);
}
return startPoint_ + lambda*direction_;
}
//- Return the length of the curve
scalar lineEdge::length() const
{
return mag(direction_);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,137 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
polyLineEdge class : defines a curvedEdge in terms of a series of
straight line segments
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// calcDistances generates the distances_ lookup table (cumulative
// distance along the line) from the individual vectors to the points
void polyLine::calcDistances()
{
distances_[0] = 0.0;
for (label i=1; i<distances_.size(); i++)
{
distances_[i] =
mag(controlPoints_[i] - controlPoints_[i-1])
+ distances_[i-1];
}
lineLength_ = distances_[distances_.size()-1];
for (label i=1; i<distances_.size(); i++)
{
distances_[i] /= lineLength_;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
polyLine::polyLine(const pointField& ps)
:
controlPoints_(ps),
distances_(ps.size())
{
if (ps.size())
{
calcDistances();
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
vector polyLine::position(const scalar lambda) const
{
// check range of lambda
if (lambda < 0 || lambda > 1)
{
FatalErrorIn("polyLine::position(const scalar)")
<< "Parameter out of range, "
<< "lambda = " << lambda
<< abort(FatalError);
}
// Quick calc of endpoints
if (lambda < SMALL)
{
return controlPoints_[0];
}
else if (lambda > 1 - SMALL)
{
return controlPoints_[controlPoints_.size()-1];
}
// search table of cumulative distance to find which linesegment we
// are on
label i(0);
do
{
i++;
} while (distances_[i] < lambda);
i--; // we overshot!
// construct position vector
scalar offsetDist =
(lambda - distances_[i])
/(distances_[i+1] - distances_[i]);
vector offsetV = controlPoints_[i+1] - controlPoints_[i];
return controlPoints_[i] + offsetDist*offsetV;
}
scalar polyLine::length() const
{
return lineLength_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,97 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::polyLine
Description
polyLine class : defines a curvedEdge in terms of a series of straight
line segments. This is the basic polyLine class which implements
just the line (no topology : its not derived from curvedEdge)
SourceFiles
polyLine.C
\*---------------------------------------------------------------------------*/
#ifndef polyLine_H
#define polyLine_H
#include "pointField.H"
#include "scalarList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class polyLine Declaration
\*---------------------------------------------------------------------------*/
class polyLine
{
protected:
// Protected data
pointField controlPoints_;
scalarList distances_;
scalar lineLength_;
// Protected member functions
void calcDistances();
public:
// Constructors
//- Construct from components
polyLine(const pointField& ps);
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the length of the curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::polyLineEdge
Description
polyLineEdge class : defines a curvedEdge in terms of a series of straight
line segments. This is the public face of polyLine
SourceFiles
polyLineEdge.C
\*---------------------------------------------------------------------------*/
#ifndef polyLineEdge_H
#define polyLineEdge_H
#include "curvedEdge.H"
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class polyLineEdge Declaration
\*---------------------------------------------------------------------------*/
class polyLineEdge
:
public curvedEdge,
public polyLine
{
public:
// Static data members
TypeName("polyLine");
// Constructors
//- Construct from components
polyLineEdge
(
const pointField& ps,
const label start,
const label end,
const pointField& otherpoints
);
//- Construct from Istream
polyLineEdge(const pointField& ps, Istream&);
// Destructor
virtual ~polyLineEdge(){}
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar lambda) const;
//- Return the length of the curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,150 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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 "polySplineEdge.H"
#include "BSpline.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(polySplineEdge, 0);
// Add the curvedEdge constructor functions to the hash tables
addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// intervening : returns a list of the points making up the polyLineEdge
// which describes the spline. nbetweenKnots is the number of points
// placed between each knot : this ensures that the knot locations
// are retained as a subset of the polyLine points.
// note that the points are evenly spaced in the parameter mu, not
// in real space
Foam::pointField Foam::polySplineEdge::intervening
(
const pointField& otherknots,
const label nbetweenKnots,
const vector& fstend,
const vector& sndend
)
{
BSpline spl(knotlist(points_, start_, end_, otherknots), fstend, sndend);
label nSize(nsize(otherknots.size(), nbetweenKnots));
pointField ans(nSize);
label N = spl.nKnots();
scalar init = 1.0/(N - 1);
scalar interval = (N - scalar(3))/N;
interval /= otherknots.size() + 1;
interval /= nbetweenKnots + 1;
ans[0] = points_[start_];
register scalar index(init);
for (register label i=1; i<nSize-1; i++)
{
index += interval;
ans[i] = spl.realPosition(index);
}
ans[nSize-1] = points_[end_];
return ans;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::polySplineEdge::polySplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots,
const label nInterKnots
)
:
curvedEdge(points, start, end),
polyLine
(
intervening
(
otherknots,
nInterKnots,
vector::zero,
vector::zero
)
),
otherKnots_(otherknots)
{}
Foam::polySplineEdge::polySplineEdge
(
const pointField& points,
Istream& is
)
:
curvedEdge(points, is),
polyLine(pointField(0)),
otherKnots_(is)
{
label nInterKnots(20);
vector fstend(is);
vector sndend(is);
controlPoints_.setSize(nsize(otherKnots_.size(), nInterKnots));
distances_.setSize(controlPoints_.size());
controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend);
calcDistances();
Info<< polyLine::controlPoints_ << endl;
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::vector Foam::polySplineEdge::position(const scalar mu) const
{
return polyLine::position(mu);
}
Foam::scalar Foam::polySplineEdge::length() const
{
return polyLine::length();
}
// ************************************************************************* //

View File

@ -1,122 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::polySplineEdge
Description
polySplineEdge class : representation of a spline via a polyLine
SourceFiles
polySplineEdge.C
\*---------------------------------------------------------------------------*/
#ifndef polySplineEdge_H
#define polySplineEdge_H
#include "curvedEdge.H"
#include "polyLine.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class polySplineEdge Declaration
\*---------------------------------------------------------------------------*/
class polySplineEdge
:
public curvedEdge,
public polyLine
{
// Private data
pointField otherKnots_;
// Private member functions
pointField intervening
(
const pointField& otherknots,
const label nbetweenKnots,
const vector&, const vector&
);
label nsize(const label otherknotsSize, const label nbetweenKnots)
{
return otherknotsSize*(1 + nbetweenKnots) + nbetweenKnots + 2;
}
public:
//- Runtime type information
TypeName("polySpline");
// Constructors
//- Construct from components
polySplineEdge
(
const pointField& ps,
const label start,
const label end,
const pointField& otherknots,
const label nInterKnots = 20
);
//- Construct from Istream setting pointsList
polySplineEdge(const pointField& points, Istream& is);
// Destructor
virtual ~polySplineEdge(){}
// Member Functions
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar mu) const;
//- Return the length of the curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,106 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
simpleSplineEdge : the actual access class for Bspline
\*---------------------------------------------------------------------------*/
#include "simpleSplineEdge.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(simpleSplineEdge, 0);
addToRunTimeSelectionTable(curvedEdge, simpleSplineEdge, Istream);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
simpleSplineEdge::simpleSplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots
)
:
curvedEdge(points, start, end),
BSpline(knotlist(points, start, end, otherknots))
{}
// Construct from components
simpleSplineEdge::simpleSplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots,
const vector& fstend,
const vector& sndend
)
:
curvedEdge(points, start, end),
BSpline(knotlist(points, start, end, otherknots), fstend, sndend)
{}
// Construct from Istream
simpleSplineEdge::simpleSplineEdge(const pointField& points, Istream& is)
:
curvedEdge(points, is),
BSpline(knotlist(points, start_, end_, pointField(is)))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the position of a point on the simple spline curve given by
// the parameter 0 <= lambda <= 1
vector simpleSplineEdge::position(const scalar mu) const
{
return BSpline::position(mu);
}
//- Return the length of the simple spline curve
scalar simpleSplineEdge::length() const
{
notImplemented("simpleSplineEdge::length() const");
return 1.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,113 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::simpleSplineEdge
Description
simpleSplineEdge : the actual access class for Bspline
SourceFiles
simpleSplineEdge.C
\*---------------------------------------------------------------------------*/
#ifndef simpleSplineEdge_H
#define simpleSplineEdge_H
#include "curvedEdge.H"
#include "BSpline.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class simpleSplineEdge Declaration
\*---------------------------------------------------------------------------*/
class simpleSplineEdge
:
public curvedEdge,
public BSpline
{
public:
//- Runtime type information
TypeName("simpleSpline");
// Constructors
//- Construct from components
simpleSplineEdge
(
const pointField& ps,
const label start,
const label end,
const pointField& otherknots
);
//- Construct from components
simpleSplineEdge
(
const pointField& points,
const label start,
const label end,
const pointField& otherknots,
const vector& fstend,
const vector& sndend
);
//- Construct from Istream setting pointsList
simpleSplineEdge(const pointField&, Istream&);
// Destructor
virtual ~simpleSplineEdge(){}
// Member Functions
//- Return the position of a point on the simple spline curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar mu) const;
//- Return the length of the simple spline curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,117 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
spline class : define a basic spline on nKnots knots - this
does not go anywhere near these knots (will act as a base type for
various splines that will have real uses)
\*---------------------------------------------------------------------------*/
#include "spline.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
spline::spline(const pointField& a)
:
knots_(a)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// function B : this is the blending function for constructing the
// spline
scalar spline::B(const scalar& tau) const
{
scalar value = 0.0;
if (tau>=2.0 || tau<=-2.0)
{
value = 0.0;
}
else if (tau<=-1.0)
{
value = pow((2.0 + tau),3.0)/6.0;
}
else if (tau<=0.0)
{
value = (4.0 - 6.0*tau*tau - 3.0*tau*tau*tau)/6.0;
}
else if (tau<=1.0)
{
value = (4.0 - 6.0*tau*tau + 3.0*tau*tau*tau)/6.0;
}
else if (tau<=2.0)
{
value = pow((2.0 - tau),3.0)/6.0;
}
else
{
FatalErrorIn("spline::B(const scalar&)")
<< "How the hell did we get here???, "
<< "tau = " << tau
<< abort(FatalError);
}
return value;
}
// position : returns the position along the spline corresponding to the
// variable mu1
vector spline::position(const scalar mu1) const
{
vector tmp(vector::zero);
for (register label i=0; i<knots_.size(); i++)
{
tmp += B((knots_.size() - 1)*mu1 - i)*knots_[i];
}
return tmp;
}
//- Return the length of the spline curve
scalar spline::length() const
{
notImplemented("spline::length() const");
return 1.0;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,102 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::spline
Description
spline class : define a basic spline on nKnots knots - this
does not go anywhere near these knots (will act as a base type for
various splines that will have real uses)
SourceFiles
spline.C
\*---------------------------------------------------------------------------*/
#ifndef spline_H
#define spline_H
#include "pointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class spline Declaration
\*---------------------------------------------------------------------------*/
class spline
{
// Private data
//- The knots defining the spline
pointField knots_;
// Private member functions
//- Blending function for constructing spline
scalar B(const scalar&) const;
public:
// Constructors
//- Construct from components
spline(const pointField&);
// Member Functions
// Access
//- Return the number of knots in the spline
label nKnots() const
{
return knots_.size();
}
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the length of the spline curve
scalar length() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,146 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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
Description
from the list of curved edges creates a list
of edges that are not curved. It is assumed
that all other edges are straight lines
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "blockDescriptor.H"
#include "lineEdge.H"
#include "lineDivide.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar calcGexp(const scalar expRatio, const label dim)
{
if (dim == 1)
{
return 0.0;
}
else
{
return pow(expRatio, 1.0/(dim - 1));
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void blockDescriptor::setEdge(label edgeI, label start, label end, label dim)
{
// for all edges check the list of curved edges. If the edge is curved,
// add it to the list. If the edge is not found, create is as a line
bool found = false;
// set reference to the list of labels defining the block
const labelList& blockLabels = blockShape_;
// set reference to global list of points
const pointField blockPoints = blockShape_.points(blockMeshPoints_);
// x1
found = false;
forAll (curvedEdges_, nCEI)
{
if (curvedEdges_[nCEI].compare(blockLabels[start], blockLabels[end]))
{
found = true;
// check the orientation:
// if the starting point of the curve is the same as the starting
// point of the edge, do the parametrisation and pick up the points
if (blockLabels[start] == curvedEdges_[nCEI].start())
{
// calculate the geometric expension factor out of the
// expansion ratio
scalar gExp = calcGexp(expand_[edgeI], dim);
// divide the line
lineDivide divEdge(curvedEdges_[nCEI], dim, gExp);
edgePoints_[edgeI] = divEdge.points();
edgeWeights_[edgeI] = divEdge.lambdaDivisions();
}
else
{
// the curve has got the opposite orientation
scalar gExp = calcGexp(expand_[edgeI], dim);
// divide the line
lineDivide divEdge(curvedEdges_[nCEI], dim, 1.0/(gExp+SMALL));
pointField p = divEdge.points();
scalarList d = divEdge.lambdaDivisions();
edgePoints_[edgeI].setSize(p.size());
edgeWeights_[edgeI].setSize(d.size());
label pMax = p.size() - 1;
forAll (p, pI)
{
edgePoints_[edgeI][pI] = p[pMax - pI];
edgeWeights_[edgeI][pI] = 1.0 - d[pMax - pI];
}
}
break;
}
}
if (!found)
{
// edge is a straight line
scalar gExp = calcGexp(expand_[edgeI], dim);
// divide the line
lineDivide divEdge
(
lineEdge(blockPoints, start, end),
dim,
gExp
);
edgePoints_[edgeI] = divEdge.points();
edgeWeights_[edgeI] = divEdge.lambdaDivisions();
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,10 +1,14 @@
EXE_INC = \
-IextrudedMesh \
-IextrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lsurfMesh \
-lmeshTools \
-ldynamicMesh \
-lextrudeModel

View File

@ -36,13 +36,14 @@ Description
#include "Time.H"
#include "dimensionedTypes.H"
#include "IFstream.H"
#include "faceMesh.H"
#include "polyTopoChange.H"
#include "polyTopoChanger.H"
#include "edgeCollapser.H"
#include "mathematicalConstants.H"
#include "globalMeshData.H"
#include "perfectInterface.H"
#include "addPatchCellLayer.H"
#include "fvMesh.H"
#include "MeshedSurfaces.H"
#include "extrudedMesh.H"
#include "extrudeModel.H"
@ -50,14 +51,165 @@ Description
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
enum ExtrudeMode
{
MESH,
PATCH,
SURFACE
};
template<>
const char* NamedEnum<ExtrudeMode, 3>::names[] =
{
"mesh",
"patch",
"surface"
};
static const NamedEnum<ExtrudeMode, 3> ExtrudeModeNames;
void createDummyFvMeshFiles(const polyMesh& mesh, const word& regionName)
{
// Create dummy system/fv*
{
IOobject io
(
"fvSchemes",
mesh.time().system(),
regionName,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
Info<< "Testing:" << io.objectPath() << endl;
if (!io.headerOk())
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
dictionary divDict;
dummyDict.add("divSchemes", divDict);
dictionary gradDict;
dummyDict.add("gradSchemes", gradDict);
dictionary laplDict;
dummyDict.add("laplacianSchemes", laplDict);
IOdictionary(io, dummyDict).regIOobject::write();
}
}
{
IOobject io
(
"fvSolution",
mesh.time().system(),
regionName,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
);
if (!io.headerOk())
{
Info<< "Writing dummy " << regionName/io.name() << endl;
dictionary dummyDict;
IOdictionary(io, dummyDict).regIOobject::write();
}
}
}
label findPatchID(const polyBoundaryMesh& patches, const word& name)
{
label patchID = patches.findPatchID(name);
if (patchID == -1)
{
FatalErrorIn("findPatchID(const polyBoundaryMesh&, const word&)")
<< "Cannot find patch " << name
<< " in the source mesh.\n"
<< "Valid patch names are " << patches.names()
<< exit(FatalError);
}
return patchID;
}
labelList patchFaces(const polyBoundaryMesh& patches, const wordList& names)
{
label n = 0;
forAll(names, i)
{
const polyPatch& pp = patches[findPatchID(patches, names[i])];
n += pp.size();
}
labelList faceLabels(n);
n = 0;
forAll(names, i)
{
const polyPatch& pp = patches[findPatchID(patches, names[i])];
forAll(pp, j)
{
faceLabels[n++] = pp.start()+j;
}
}
return faceLabels;
}
void updateFaceLabels(const mapPolyMesh& map, labelList& faceLabels)
{
const labelList& reverseMap = map.reverseFaceMap();
labelList newFaceLabels(faceLabels.size());
label newI = 0;
forAll(faceLabels, i)
{
label oldFaceI = faceLabels[i];
if (reverseMap[oldFaceI] >= 0)
{
newFaceLabels[newI++] = reverseMap[oldFaceI];
}
}
newFaceLabels.setSize(newI);
faceLabels.transfer(newFaceLabels);
}
// Main program:
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTimeExtruded.H"
autoPtr<extrudedMesh> meshPtr(NULL);
// Get optional regionName
word regionName;
word regionDir;
if (args.optionReadIfPresent("region", regionName))
{
regionDir = regionName;
Info<< "Create mesh " << regionName << " for time = "
<< runTimeExtruded.timeName() << nl << endl;
}
else
{
regionName = fvMesh::defaultRegion;
Info<< "Create mesh for time = "
<< runTimeExtruded.timeName() << nl << endl;
}
IOdictionary dict
(
@ -65,26 +217,57 @@ int main(int argc, char *argv[])
(
"extrudeProperties",
runTimeExtruded.constant(),
regionDir,
runTimeExtruded,
IOobject::MUST_READ
)
);
// Point generator
autoPtr<extrudeModel> model(extrudeModel::New(dict));
const word sourceType(dict.lookup("constructFrom"));
// Whether to flip normals
const Switch flipNormals(dict.lookup("flipNormals"));
autoPtr<faceMesh> fMesh;
// What to extrude
const ExtrudeMode mode = ExtrudeModeNames.read
(
dict.lookup("constructFrom")
);
if (sourceType == "patch")
// Generated mesh (one of either)
autoPtr<fvMesh> meshFromMesh;
autoPtr<polyMesh> meshFromSurface;
// Faces on front and back for stitching (in case of mergeFaces)
word frontPatchName;
labelList frontPatchFaces;
word backPatchName;
labelList backPatchFaces;
if (mode == PATCH || mode == MESH)
{
if (flipNormals)
{
FatalErrorIn(args.executable())
<< "Flipping normals not supported for extrusions from patch."
<< exit(FatalError);
}
fileName sourceCasePath(dict.lookup("sourceCase"));
sourceCasePath.expand();
fileName sourceRootDir = sourceCasePath.path();
fileName sourceCaseDir = sourceCasePath.name();
word patchName(dict.lookup("sourcePatch"));
wordList sourcePatches;
dict.lookup("sourcePatches") >> sourcePatches;
Info<< "Extruding patch " << patchName
if (sourcePatches.size() == 1)
{
frontPatchName = sourcePatches[0];
}
Info<< "Extruding patches " << sourcePatches
<< " on mesh " << sourceCasePath << nl
<< endl;
@ -94,31 +277,183 @@ int main(int argc, char *argv[])
sourceRootDir,
sourceCaseDir
);
#include "createPolyMesh.H"
#include "createMesh.H"
label patchID = mesh.boundaryMesh().findPatchID(patchName);
const polyBoundaryMesh& patches = mesh.boundaryMesh();
if (patchID == -1)
// Topo change container. Either copy an existing mesh or start
// with empty storage (number of patches only needed for checking)
autoPtr<polyTopoChange> meshMod
(
(
mode == MESH
? new polyTopoChange(mesh)
: new polyTopoChange(patches.size())
)
);
// Extrusion engine. Either adding to existing mesh or
// creating separate mesh.
addPatchCellLayer layerExtrude(mesh, (mode == MESH));
indirectPrimitivePatch extrudePatch
(
IndirectList<face>
(
mesh.faces(),
patchFaces(patches, sourcePatches)
),
mesh.points()
);
// Only used for addPatchCellLayer into new mesh
labelList exposedPatchIDs;
if (mode == PATCH)
{
FatalErrorIn(args.executable())
<< "Cannot find patch " << patchName
<< " in the source mesh.\n"
<< "Valid patch names are " << mesh.boundaryMesh().names()
<< exit(FatalError);
dict.lookup("exposedPatchName") >> backPatchName;
exposedPatchIDs.setSize
(
extrudePatch.size(),
findPatchID(patches, backPatchName)
);
}
const polyPatch& pp = mesh.boundaryMesh()[patchID];
fMesh.reset(new faceMesh(pp.localFaces(), pp.localPoints()));
pointField layer0Points(extrudePatch.nPoints());
pointField displacement(extrudePatch.nPoints());
forAll(displacement, pointI)
{
fileName surfName(runTime.path()/patchName + ".sMesh");
Info<< "Writing patch as surfaceMesh to "
<< surfName << nl << endl;
OFstream os(surfName);
os << fMesh() << nl;
const vector& patchNormal = extrudePatch.pointNormals()[pointI];
// layer0 point
layer0Points[pointI] = model()
(
extrudePatch.localPoints()[pointI],
patchNormal,
0
);
// layerN point
point extrudePt = model()
(
extrudePatch.localPoints()[pointI],
patchNormal,
model().nLayers()
);
displacement[pointI] = extrudePt - layer0Points[pointI];
}
if (flipNormals)
{
Info<< "Flipping faces." << nl << endl;
displacement = -displacement;
}
// Check if wedge (has layer0 different from original patch points)
// If so move the mesh to starting position.
if (gMax(mag(layer0Points-extrudePatch.localPoints())) > SMALL)
{
Info<< "Moving mesh to layer0 points since differ from original"
<< " points - this can happen for wedge extrusions." << nl
<< endl;
pointField newPoints(mesh.points());
forAll(extrudePatch.meshPoints(), i)
{
newPoints[extrudePatch.meshPoints()[i]] = layer0Points[i];
}
mesh.movePoints(newPoints);
}
// Layers per face
labelList nFaceLayers(extrudePatch.size(), model().nLayers());
// Layers per point
labelList nPointLayers(extrudePatch.nPoints(), model().nLayers());
// Displacement for first layer
vectorField firstLayerDisp = displacement*model().sumThickness(1);
// Expansion ratio not used.
scalarField ratio(extrudePatch.nPoints(), 1.0);
layerExtrude.setRefinement
(
ratio, // expansion ratio
extrudePatch, // patch faces to extrude
exposedPatchIDs, // if new mesh: patches for exposed faces
nFaceLayers,
nPointLayers,
firstLayerDisp,
meshMod()
);
// Reset points according to extrusion model
forAll(layerExtrude.addedPoints(), pointI)
{
const labelList& pPoints = layerExtrude.addedPoints()[pointI];
forAll(pPoints, pPointI)
{
label meshPointI = pPoints[pPointI];
point modelPt
(
model()
(
extrudePatch.localPoints()[pointI],
extrudePatch.pointNormals()[pointI],
pPointI+1 // layer
)
);
const_cast<DynamicList<point>&>
(
meshMod().points()
)[meshPointI] = modelPt;
}
}
// Store faces on front and exposed patch (if mode=patch there are
// only added faces so cannot used map to old faces)
const labelListList& layerFaces = layerExtrude.layerFaces();
backPatchFaces.setSize(layerFaces.size());
frontPatchFaces.setSize(layerFaces.size());
forAll(backPatchFaces, i)
{
backPatchFaces[i] = layerFaces[i][0];
frontPatchFaces[i] = layerFaces[i][layerFaces[i].size()-1];
}
// Create dummy fvSchemes, fvSolution
createDummyFvMeshFiles(mesh, regionDir);
// Create actual mesh from polyTopoChange container
autoPtr<mapPolyMesh> map = meshMod().makeMesh
(
meshFromMesh,
IOobject
(
regionName,
runTimeExtruded.constant(),
runTimeExtruded,
IOobject::NO_READ,
IOobject::AUTO_WRITE,
false
),
mesh
);
// Calculate face labels for front and back.
frontPatchFaces = renumber
(
map().reverseFaceMap(),
frontPatchFaces
);
backPatchFaces = renumber
(
map().reverseFaceMap(),
backPatchFaces
);
}
else if (sourceType == "surface")
else
{
// Read from surface
fileName surfName(dict.lookup("surface"));
@ -126,52 +461,62 @@ int main(int argc, char *argv[])
Info<< "Extruding surfaceMesh read from file " << surfName << nl
<< endl;
IFstream is(surfName);
MeshedSurface<face> fMesh(surfName);
fMesh.reset(new faceMesh(is));
Info<< "Read patch from file " << surfName << nl
<< endl;
}
else
{
FatalErrorIn(args.executable())
<< "Illegal 'constructFrom' specification. Should either be "
<< "patch or surface." << exit(FatalError);
}
Switch flipNormals(dict.lookup("flipNormals"));
if (flipNormals)
{
Info<< "Flipping faces." << nl << endl;
faceList faces(fMesh().size());
forAll(faces, i)
if (flipNormals)
{
faces[i] = fMesh()[i].reverseFace();
Info<< "Flipping faces." << nl << endl;
faceList& faces = const_cast<faceList&>(fMesh.faces());
forAll(faces, i)
{
faces[i] = fMesh[i].reverseFace();
}
}
fMesh.reset(new faceMesh(faces, fMesh().localPoints()));
Info<< "Extruding surface with :" << nl
<< " points : " << fMesh.points().size() << nl
<< " faces : " << fMesh.size() << nl
<< " normals[0] : " << fMesh.faceNormals()[0]
<< nl
<< endl;
meshFromSurface.reset
(
new extrudedMesh
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh,
model()
)
);
// Get the faces on front and back
frontPatchName = "originalPatch";
frontPatchFaces = patchFaces
(
meshFromSurface().boundaryMesh(),
wordList(1, frontPatchName)
);
backPatchName = "otherSide";
backPatchFaces = patchFaces
(
meshFromSurface().boundaryMesh(),
wordList(1, backPatchName)
);
}
Info<< "Extruding patch with :" << nl
<< " points : " << fMesh().points().size() << nl
<< " faces : " << fMesh().size() << nl
<< " normals[0] : " << fMesh().faceNormals()[0]
<< nl
<< endl;
extrudedMesh mesh
polyMesh& mesh =
(
IOobject
(
extrudedMesh::defaultRegion,
runTimeExtruded.constant(),
runTimeExtruded
),
fMesh(),
model()
meshFromMesh.valid()
? meshFromMesh()
: meshFromSurface()
);
@ -184,17 +529,6 @@ int main(int argc, char *argv[])
<< "Merge distance : " << mergeDim << nl
<< endl;
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const label origPatchID = patches.findPatchID("originalPatch");
const label otherPatchID = patches.findPatchID("otherSide");
if (origPatchID == -1 || otherPatchID == -1)
{
FatalErrorIn(args.executable())
<< "Cannot find patch originalPatch or otherSide." << nl
<< "Valid patches are " << patches.names() << exit(FatalError);
}
// Collapse edges
// ~~~~~~~~~~~~~~
@ -237,6 +571,10 @@ int main(int argc, char *argv[])
// Update fields
mesh.updateMesh(map);
// Update stored data
updateFaceLabels(map(), frontPatchFaces);
updateFaceLabels(map(), backPatchFaces);
// Move mesh (if inflation used)
if (map().hasMotionPoints())
{
@ -252,22 +590,33 @@ int main(int argc, char *argv[])
Switch mergeFaces(dict.lookup("mergeFaces"));
if (mergeFaces)
{
if (mode == MESH)
{
FatalErrorIn(args.executable())
<< "Cannot stitch front and back of extrusion since"
<< " in 'mesh' mode (extrusion appended to mesh)."
<< exit(FatalError);
}
Info<< "Assuming full 360 degree axisymmetric case;"
<< " stitching faces on patches "
<< patches[origPatchID].name() << " and "
<< patches[otherPatchID].name() << " together ..." << nl << endl;
<< frontPatchName << " and "
<< backPatchName << " together ..." << nl << endl;
if (frontPatchFaces.size() != backPatchFaces.size())
{
FatalErrorIn(args.executable())
<< "Differing number of faces on front ("
<< frontPatchFaces.size() << ") and back ("
<< backPatchFaces.size() << ")"
<< exit(FatalError);
}
polyTopoChanger stitcher(mesh);
stitcher.setSize(1);
// Make list of masterPatch faces
labelList isf(patches[origPatchID].size());
forAll (isf, i)
{
isf[i] = patches[origPatchID].start() + i;
}
const word cutZoneName("originalCutFaceZone");
List<faceZone*> fz
@ -276,8 +625,8 @@ int main(int argc, char *argv[])
new faceZone
(
cutZoneName,
isf,
boolList(isf.size(), false),
frontPatchFaces,
boolList(frontPatchFaces.size(), false),
0,
mesh.faceZones()
)
@ -286,26 +635,58 @@ int main(int argc, char *argv[])
mesh.addZones(List<pointZone*>(0), fz, List<cellZone*>(0));
// Add the perfect interface mesh modifier
stitcher.set
perfectInterface perfectStitcher
(
"couple",
0,
new perfectInterface
(
"couple",
0,
stitcher,
cutZoneName,
patches[origPatchID].name(),
patches[otherPatchID].name()
)
stitcher,
cutZoneName,
word::null, // dummy patch name
word::null // dummy patch name
);
// Execute all polyMeshModifiers
autoPtr<mapPolyMesh> morphMap = stitcher.changeMesh(true);
// Topo change container
polyTopoChange meshMod(mesh);
mesh.movePoints(morphMap->preMotionPoints());
perfectStitcher.setRefinement
(
indirectPrimitivePatch
(
IndirectList<face>
(
mesh.faces(),
frontPatchFaces
),
mesh.points()
),
indirectPrimitivePatch
(
IndirectList<face>
(
mesh.faces(),
backPatchFaces
),
mesh.points()
),
meshMod
);
// Construct new mesh from polyTopoChange.
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
// Update fields
mesh.updateMesh(map);
// Move mesh (if inflation used)
if (map().hasMotionPoints())
{
mesh.movePoints(map().preMotionPoints());
}
}
mesh.setInstance(runTimeExtruded.constant());
Info<< "Writing mesh to " << mesh.objectPath() << nl << endl;
if (!mesh.write())
{
FatalErrorIn(args.executable()) << "Failed writing mesh"

View File

@ -1,6 +1,7 @@
extrudeModel/extrudeModel.C
extrudeModel/newExtrudeModel.C
linearNormal/linearNormal.C
linearDirection/linearDirection.C
linearRadial/linearRadial.C
sigmaRadial/sigmaRadial.C
wedge/wedge.C

View File

@ -43,6 +43,7 @@ Foam::extrudeModel::extrudeModel
)
:
nLayers_(readLabel(dict.lookup("nLayers"))),
expansionRatio_(readScalar(dict.lookup("expansionRatio"))),
dict_(dict),
coeffDict_(dict.subDict(modelType + "Coeffs"))
{}
@ -62,5 +63,28 @@ Foam::label Foam::extrudeModel::nLayers() const
}
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

@ -58,6 +58,8 @@ protected:
const label nLayers_;
const scalar expansionRatio_;
const dictionary& dict_;
const dictionary& coeffDict_;
@ -113,9 +115,15 @@ public:
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,

View File

@ -47,7 +47,7 @@ Foam::autoPtr<Foam::extrudeModel> Foam::extrudeModel::New
<< extrudeModelType
<< ", constructor not in hash table" << nl << nl
<< " Valid extrudeModel types are :" << nl
<< dictionaryConstructorTablePtr_->toc() << nl
<< dictionaryConstructorTablePtr_->sortedToc() << nl
<< exit(FatalError);
}

View File

@ -22,71 +22,69 @@ License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
\*---------------------------------------------------------------------------*/
#include "error.H"
#include "polyLineEdge.H"
#include "linearDirection.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(polyLineEdge, 0);
defineTypeNameAndDebug(linearDirection, 0);
// Add the curvedEdge constructor functions to the hash tables
curvedEdge::addIstreamConstructorToTable<polyLineEdge>
addPolyLineEdgeIstreamConstructorToTable_;
addToRunTimeSelectionTable(extrudeModel, linearDirection, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
polyLineEdge::polyLineEdge
(
const pointField& ps,
const label start,
const label end,
const pointField& otherpoints
)
linearDirection::linearDirection(const dictionary& dict)
:
curvedEdge(ps, start, end),
polyLine(knotlist(ps,start,end,otherpoints))
{}
// Construct from Istream
polyLineEdge::polyLineEdge(const pointField& ps, Istream& is)
:
curvedEdge(ps, is),
polyLine(knotlist(ps, start_, end_, pointField(is)))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector polyLineEdge::position(const scalar lambda) const
extrudeModel(typeName, dict),
direction_(coeffDict_.lookup("direction")),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{
return polyLine::position(lambda);
direction_ /= mag(direction_);
if (thickness_ <= 0)
{
FatalErrorIn("linearDirection(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
//- Return the length of the curve
scalar polyLineEdge::length() const
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
linearDirection::~linearDirection()
{}
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
point linearDirection::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
return polyLine::lineLength_;
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*direction_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,74 +23,72 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::lineEdge
Foam::extrudeModels::linearDirection
Description
lineEdge class : defines a straight line between the start point and the
end point
SourceFiles
lineEdge.C
Extrudes by transforming points in a specified direction by a given distance
\*---------------------------------------------------------------------------*/
#ifndef lineEdge_H
#define lineEdge_H
#ifndef linearDirection_H
#define linearDirection_H
#include "curvedEdge.H"
#include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class lineEdge Declaration
Class linearDirection Declaration
\*---------------------------------------------------------------------------*/
class lineEdge
class linearDirection
:
public curvedEdge
public extrudeModel
{
// Private data
vector startPoint_;
//- Extrude direction
vector direction_;
//- layer thickness
scalar thickness_;
public:
//- Runtime type information
TypeName("line");
TypeName("linearDirection");
// Constructors
//- Construct from components
lineEdge(const pointField& points, const label start, const label end);
//- Construct from Istream setting pointsList
lineEdge(const pointField& points, Istream&);
//- Construct from dictionary
linearDirection(const dictionary& dict);
// Destructor
virtual ~lineEdge(){}
//- Destructor
~linearDirection();
// Member Functions
// Member Operators
//- Return the position of a point on the curve given by
// the parameter 0 <= lambda <= 1
vector position(const scalar) const;
//- Return the length of the curve
scalar length() const;
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -98,3 +96,4 @@ public:
#endif
// ************************************************************************* //

View File

@ -72,7 +72,8 @@ point linearNormal::operator()
const label layer
) const
{
scalar d = thickness_*layer/nLayers_;
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*surfaceNormal;
}

View File

@ -64,7 +64,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary
linearNormal(const dictionary& dict);

View File

@ -67,8 +67,7 @@ point linearRadial::operator()
scalar rs = mag(surfacePoint);
vector rsHat = surfacePoint/rs;
scalar delta = (R_ - rs)/nLayers_;
scalar r = rs + layer*delta;
scalar r = rs + (R_ - rs)*sumThickness(layer);
return r*rsHat;
}

View File

@ -61,7 +61,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary
linearRadial(const dictionary& dict);

View File

@ -49,7 +49,13 @@ sigmaRadial::sigmaRadial(const dictionary& 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 * * * * * * * * * * * * * * * //

View File

@ -63,7 +63,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary
sigmaRadial(const dictionary& dict);

View File

@ -26,7 +26,7 @@ License
#include "wedge.H"
#include "addToRunTimeSelectionTable.H"
#include "mathematicalConstants.H"
#include "unitConversion.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -51,8 +51,7 @@ wedge::wedge(const dictionary& dict)
axis_(coeffDict_.lookup("axis")),
angle_
(
readScalar(coeffDict_.lookup("angle"))
*mathematicalConstant::pi/180.0
degToRad(readScalar(coeffDict_.lookup("angle")))
)
{}
@ -88,8 +87,8 @@ point wedge::operator()
}
else
{
//sliceAngle = angle_*(layer + 1)/nLayers_;
sliceAngle = angle_*layer/nLayers_;
//sliceAngle = angle_*layer/nLayers_;
sliceAngle = angle_*sumThickness(layer);
}
// Find projection onto axis (or rather decompose surfacePoint

View File

@ -77,7 +77,7 @@ public:
// Constructors
//- Construct from components
//- Construct from dictionary
wedge(const dictionary& dict);

View File

@ -14,29 +14,36 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Where to get surface from: either from surface ('surface') or
// from (flipped) patch of existing case ('patch')
constructFrom patch; //surface;
// What to extrude:
// patch : from patch of another case ('sourceCase')
// mesh : as above but with original case included
// surface : from externally read surface
//constructFrom mesh;
constructFrom patch;
//constructFrom surface;
// If construct from patch/mesh:
sourceCase "../cavity";
sourcePatches (movingWall);
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName movingWall;
// If construct from surface:
surface "movingWall.stl";
// If construct from (flipped) patch
sourceCase "$FOAM_RUN/icoFoam/cavity";
sourcePatch movingWall;
// Flip surface normals before usage.
flipNormals false;
// If construct from surface
surface "movingWall.sMesh";
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces true;
//- Linear extrusion in point-normal direction
//extrudeModel linearNormal;
//- Linear extrusion in specified direction
//extrudeModel linearDirection;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
extrudeModel wedge;
@ -46,11 +53,13 @@ extrudeModel wedge;
//- Extrudes into sphere with grading according to pressure (atmospherics)
//extrudeModel sigmaRadial;
nLayers 20;
nLayers 10;
expansionRatio 1.0; //0.9;
wedgeCoeffs
{
axisPt (0 0.1 0);
axisPt (0 0.1 -0.05);
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
@ -60,6 +69,12 @@ linearNormalCoeffs
thickness 0.05;
}
linearDirectionCoeffs
{
direction (0 1 0);
thickness 0.05;
}
linearRadialCoeffs
{
R 0.1;
@ -73,5 +88,10 @@ sigmaRadialCoeffs
}
// Do front and back need to be merged? Usually only makes sense for 360
// degree wedges.
mergeFaces false; //true;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,114 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 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::faceMesh
Description
Storage for surface mesh i.e. points and faces.
SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef faceMesh_H
#define faceMesh_H
#include "PrimitivePatch.H"
#include "faceList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class faceMesh Declaration
\*---------------------------------------------------------------------------*/
class faceMesh
:
public PrimitivePatch<face, List, pointField>
{
// Private member functions
PrimitivePatch<face, List, pointField> read(Istream& is)
{
pointField points(is);
faceList faces(is);
return PrimitivePatch<face, Foam::List, pointField>(faces, points);
}
public:
// Constructors
//- Construct from components
faceMesh(const faceList& faces, const pointField& points)
:
PrimitivePatch<face, Foam::List, pointField>(faces, points)
{}
//- Construct from Istream
faceMesh(Istream& is)
:
PrimitivePatch<face, Foam::List, pointField>(read(is))
{}
// Member Functions
void flip()
{
forAll(*this, i)
{
face& f = operator[](i);
f = f.reverseFace();
}
clearOut();
}
// IOstream Operators
friend Ostream& operator<<(Ostream& os, const faceMesh& fm)
{
return os
<< fm.points()
<< token::NL
<< static_cast<PrimitivePatch<face, Foam::List, pointField> >
(fm);
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,7 +1,7 @@
EXE_INC = \
/* -g -DFULLDEBUG -O0 */ \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/autoMesh/lnInclude \
-I$(LIB_SRC)/mesh/autoMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \

View File

@ -203,8 +203,8 @@ int main(int argc, char *argv[])
IOobject
(
"abc", // dummy name
//mesh.time().constant(), // instance
mesh.time().findInstance("triSurface", word::null),// instance
mesh.time().constant(), // instance
//mesh.time().findInstance("triSurface", word::null),// instance
"triSurface", // local
mesh.time(), // registry
IOobject::MUST_READ,
@ -363,6 +363,8 @@ int main(int argc, char *argv[])
if (wantRefine)
{
cpuTime timer;
autoRefineDriver refineDriver
(
meshRefiner,
@ -387,10 +389,15 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Mesh refined in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}
if (wantSnap)
{
cpuTime timer;
autoSnapDriver snapDriver
(
meshRefiner,
@ -413,10 +420,15 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Mesh snapped in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}
if (wantLayers)
{
cpuTime timer;
autoLayerDriver layerDriver(meshRefiner);
// Layer addition parameters
@ -442,6 +454,9 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Layers added in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}

View File

@ -280,11 +280,14 @@ addLayersControls
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations
// Overall max number of layer addition iterations. The mesher will exit
// if it reaches this number of iterations; possibly with an illegal
// mesh.
nLayerIter 50;
// Max number of iterations after which relaxed meshQuality controls
// get used.
// get used. Up to nRelaxIter it uses the settings in meshQualityControls,
// after nRelaxIter it uses the values in meshQualityControls::relaxed.
nRelaxedIter 20;
}