mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Adding BCC and FCC intial position methods to produce truncated
octahedron and rhombic dodecahedron cells when dualised.
This commit is contained in:
@ -19,6 +19,8 @@ $(cellSiseFunctions)/linearSpatial/linearSpatial.C
|
||||
|
||||
initialPointsMethod/initialPointsMethod/initialPointsMethod.C
|
||||
initialPointsMethod/uniformGrid/uniformGrid.C
|
||||
initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C
|
||||
initialPointsMethod/faceCentredCubic/faceCentredCubic.C
|
||||
initialPointsMethod/pointFile/pointFile.C
|
||||
initialPointsMethod/densityWeightedStochastic/densityWeightedStochastic.C
|
||||
|
||||
|
||||
@ -0,0 +1,156 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-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 "bodyCentredCubic.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(bodyCentredCubic, 0);
|
||||
addToRunTimeSelectionTable(initialPointsMethod, bodyCentredCubic, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
bodyCentredCubic::bodyCentredCubic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
)
|
||||
:
|
||||
initialPointsMethod(typeName, initialPointsDict, cvMesh),
|
||||
initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))),
|
||||
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
|
||||
randomPerturbationCoeff_
|
||||
(
|
||||
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::vector<Vb::Point> bodyCentredCubic::initialPoints() const
|
||||
{
|
||||
const boundBox& bb = cvMesh_.geometryToConformTo().bounds();
|
||||
|
||||
scalar x0 = bb.min().x();
|
||||
scalar xR = bb.max().x() - x0;
|
||||
int ni = int(xR/initialCellSize_) + 1;
|
||||
|
||||
scalar y0 = bb.min().y();
|
||||
scalar yR = bb.max().y() - y0;
|
||||
int nj = int(yR/initialCellSize_) + 1;
|
||||
|
||||
scalar z0 = bb.min().z();
|
||||
scalar zR = bb.max().z() - z0;
|
||||
int nk = int(zR/initialCellSize_) + 1;
|
||||
|
||||
vector delta(xR/ni, yR/nj, zR/nk);
|
||||
|
||||
delta *= pow((1.0/2.0),-(1.0/3.0));
|
||||
|
||||
Random rndGen(1735621);
|
||||
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
|
||||
|
||||
std::vector<Vb::Point> initialPoints;
|
||||
|
||||
List<bool> isSurfacePoint(2*nk, false);
|
||||
|
||||
for (int i = 0; i < ni; i++)
|
||||
{
|
||||
for (int j = 0; j < nj; j++)
|
||||
{
|
||||
// Generating, testing and adding points one line at a time to
|
||||
// reduce the memory requirement for cases with bounding boxes that
|
||||
// are very large in comparison to the volume to be filled
|
||||
|
||||
label pI = 0;
|
||||
|
||||
pointField points(2*nk);
|
||||
|
||||
for (int k = 0; k < nk; k++)
|
||||
{
|
||||
point pA
|
||||
(
|
||||
x0 + i*delta.x(),
|
||||
y0 + j*delta.y(),
|
||||
z0 + k*delta.z()
|
||||
);
|
||||
|
||||
point pB = pA + 0.5*delta;
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
pA.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
pA.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
pA.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = pA;
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
pB.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
pB.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
pB.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = pB;
|
||||
}
|
||||
|
||||
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
|
||||
(
|
||||
points,
|
||||
minimumSurfaceDistanceCoeffSqr_
|
||||
*sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint))
|
||||
);
|
||||
|
||||
forAll(insidePoints, i)
|
||||
{
|
||||
if (insidePoints[i])
|
||||
{
|
||||
const point& p(points[i]);
|
||||
|
||||
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return initialPoints;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,107 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-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::bodyCentredCubic
|
||||
|
||||
Description
|
||||
Generate a BCC lattice of points inside the surfaces to be
|
||||
conformed to of the conformalVoronoiMesh
|
||||
|
||||
SourceFiles
|
||||
bodyCentredCubic.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef bodyCentredCubic_H
|
||||
#define bodyCentredCubic_H
|
||||
|
||||
#include "Switch.H"
|
||||
#include "Random.H"
|
||||
#include "initialPointsMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class bodyCentredCubic Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class bodyCentredCubic
|
||||
:
|
||||
public initialPointsMethod
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- The initial cell spacing
|
||||
scalar initialCellSize_;
|
||||
|
||||
//- Should the initial positions be randomised
|
||||
Switch randomiseInitialGrid_;
|
||||
|
||||
//- Randomise the initial positions by fraction of the initialCellSize_
|
||||
scalar randomPerturbationCoeff_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("bodyCentredCubic");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
bodyCentredCubic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~bodyCentredCubic()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the initial points for the conformalVoronoiMesh
|
||||
virtual std::vector<Vb::Point> initialPoints() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,193 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-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 "faceCentredCubic.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(faceCentredCubic, 0);
|
||||
addToRunTimeSelectionTable(initialPointsMethod, faceCentredCubic, dictionary);
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
faceCentredCubic::faceCentredCubic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
)
|
||||
:
|
||||
initialPointsMethod(typeName, initialPointsDict, cvMesh),
|
||||
initialCellSize_(readScalar(detailsDict().lookup("initialCellSize"))),
|
||||
randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")),
|
||||
randomPerturbationCoeff_
|
||||
(
|
||||
readScalar(detailsDict().lookup("randomPerturbationCoeff"))
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
std::vector<Vb::Point> faceCentredCubic::initialPoints() const
|
||||
{
|
||||
const boundBox& bb = cvMesh_.geometryToConformTo().bounds();
|
||||
|
||||
scalar x0 = bb.min().x();
|
||||
scalar xR = bb.max().x() - x0;
|
||||
int ni = int(xR/initialCellSize_) + 1;
|
||||
|
||||
scalar y0 = bb.min().y();
|
||||
scalar yR = bb.max().y() - y0;
|
||||
int nj = int(yR/initialCellSize_) + 1;
|
||||
|
||||
scalar z0 = bb.min().z();
|
||||
scalar zR = bb.max().z() - z0;
|
||||
int nk = int(zR/initialCellSize_) + 1;
|
||||
|
||||
vector delta(xR/ni, yR/nj, zR/nk);
|
||||
|
||||
delta *= pow((1.0/4.0),-(1.0/3.0));
|
||||
|
||||
Random rndGen(1735621);
|
||||
scalar pert = randomPerturbationCoeff_*cmptMin(delta);
|
||||
|
||||
std::vector<Vb::Point> initialPoints;
|
||||
|
||||
List<bool> isSurfacePoint(4*nk, false);
|
||||
|
||||
for (int i = 0; i < ni; i++)
|
||||
{
|
||||
for (int j = 0; j < nj; j++)
|
||||
{
|
||||
// Generating, testing and adding points one line at a time to
|
||||
// reduce the memory requirement for cases with bounding boxes that
|
||||
// are very large in comparison to the volume to be filled
|
||||
|
||||
label pI = 0;
|
||||
|
||||
pointField points(4*nk);
|
||||
|
||||
for (int k = 0; k < nk; k++)
|
||||
{
|
||||
point p
|
||||
(
|
||||
x0 + i*delta.x(),
|
||||
y0 + j*delta.y(),
|
||||
z0 + k*delta.z()
|
||||
);
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
|
||||
p = point
|
||||
(
|
||||
x0 + i*delta.x(),
|
||||
y0 + (j + 0.5)*delta.y(),
|
||||
z0 + (k + 0.5)*delta.z()
|
||||
);
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
|
||||
p = point
|
||||
(
|
||||
x0 + (i + 0.5)*delta.x(),
|
||||
y0 + j*delta.y(),
|
||||
z0 + (k + 0.5)*delta.z()
|
||||
);
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
|
||||
p = point
|
||||
(
|
||||
x0 + (i + 0.5)*delta.x(),
|
||||
y0 + (j + 0.5)*delta.y(),
|
||||
z0 + k*delta.z()
|
||||
);
|
||||
|
||||
if (randomiseInitialGrid_)
|
||||
{
|
||||
p.x() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.y() += pert*(rndGen.scalar01() - 0.5);
|
||||
p.z() += pert*(rndGen.scalar01() - 0.5);
|
||||
}
|
||||
|
||||
points[pI++] = p;
|
||||
}
|
||||
|
||||
Field<bool> insidePoints = cvMesh_.geometryToConformTo().wellInside
|
||||
(
|
||||
points,
|
||||
minimumSurfaceDistanceCoeffSqr_
|
||||
*sqr(cvMesh_.cellSizeControl().cellSize(points, isSurfacePoint))
|
||||
);
|
||||
|
||||
forAll(insidePoints, i)
|
||||
{
|
||||
if (insidePoints[i])
|
||||
{
|
||||
const point& p(points[i]);
|
||||
|
||||
initialPoints.push_back(Vb::Point(p.x(), p.y(), p.z()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return initialPoints;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,107 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2009-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::faceCentredCubic
|
||||
|
||||
Description
|
||||
Generate an FCC lattice of points inside the surfaces to be
|
||||
conformed to of the conformalVoronoiMesh
|
||||
|
||||
SourceFiles
|
||||
faceCentredCubic.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faceCentredCubic_H
|
||||
#define faceCentredCubic_H
|
||||
|
||||
#include "Switch.H"
|
||||
#include "Random.H"
|
||||
#include "initialPointsMethod.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faceCentredCubic Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faceCentredCubic
|
||||
:
|
||||
public initialPointsMethod
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- The initial cell spacing
|
||||
scalar initialCellSize_;
|
||||
|
||||
//- Should the initial positions be randomised
|
||||
Switch randomiseInitialGrid_;
|
||||
|
||||
//- Randomise the initial positions by fraction of the initialCellSize_
|
||||
scalar randomPerturbationCoeff_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("faceCentredCubic");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faceCentredCubic
|
||||
(
|
||||
const dictionary& initialPointsDict,
|
||||
const conformalVoronoiMesh& cvMesh
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~faceCentredCubic()
|
||||
{}
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Return the initial points for the conformalVoronoiMesh
|
||||
virtual std::vector<Vb::Point> initialPoints() const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -68,6 +68,7 @@ private:
|
||||
//- Randomise the initial positions by fraction of the initialCellSize_
|
||||
scalar randomPerturbationCoeff_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
|
||||
Reference in New Issue
Block a user