Commit c0460d30 authored by mattijs's avatar mattijs
Browse files

Merge remote-tracking branch 'Customer-VWG/wp3-directional-refinement' into develop

parents 66275158 8855fdeb
......@@ -306,6 +306,35 @@ castellatedMeshControls
// // - cellLevel will include any directional refinement
// // (i.e. it will be the maximum of all three directions)
//}
//wakeBox
//{
// mode inside;
// // Dummy base level
// levels ((10000 0));
//
// // Optional directional refinement (after all other refinement)
// // Directional refinement
// // for all cells according to 'mode' ('inside' or 'outside';
// // 'distance' not supported) and within certain range. E.g.
// // - for all cells with level 2-5
// // - do one split in x direction
// levelIncrement (2 5 (1 0 0));
//
// // Note
// // - ignores 'levels' and gap* settings.
// // - the cellLevel/pointLevels files are no longer consistent
// // with the mesh, the resulting mesh is no longer compatible
// // with e.g. dynamic refinement/unrefinement.
// // - cellLevel will include any directional refinement
// // (i.e. it will be the maximum of all three directions)
//
// // Optional directional expansion-ratio smoothing (after all
// // refinement). This will try to smooth out edge/cell size jumps
// // Specify smoothing direction and number of iterations
// nSmoothExpansion 100;
// smoothDirection (1 0 0);
//}
}
......
......@@ -3148,7 +3148,6 @@ Foam::labelList Foam::hexRef8::consistentSlowRefinement2
bitSet refineCell(mesh_.nCells(), newCellsToRefine);
const bitSet savedRefineCell(refineCell);
label nChanged = faceConsistentRefinement(true, cellLevel_, refineCell);
{
......
......@@ -1053,7 +1053,6 @@ public:
const scalar maxLoadUnbalance
);
//- Calculate list of cells to directionally refine
labelList directionalRefineCandidates
(
......
......@@ -595,6 +595,9 @@ Foam::shellSurfaces::shellSurfaces
distances_.setSize(shellI);
levels_.setSize(shellI);
dirLevels_.setSize(shellI);
smoothDirection_.setSize(shellI);
nSmoothExpansion_.setSize(shellI);
nSmoothPosition_.setSize(shellI);
extendedGapLevel_.setSize(shellI);
extendedGapMode_.setSize(shellI);
......@@ -671,6 +674,19 @@ Foam::shellSurfaces::shellSurfaces
}
}
// Directional smoothing
// ~~~~~~~~~~~~~~~~~~~~~
nSmoothExpansion_[shellI] = 0;
nSmoothPosition_[shellI] = 0;
smoothDirection_[shellI] =
dict.lookupOrDefault("smoothDirection", vector::zero);
if (smoothDirection_[shellI] != vector::zero)
{
dict.lookup("nSmoothExpansion") >> nSmoothExpansion_[shellI];
dict.lookup("nSmoothPosition") >> nSmoothPosition_[shellI];
}
// Gap specification
......@@ -797,6 +813,24 @@ Foam::labelPairList Foam::shellSurfaces::directionalSelectLevel() const
}
const Foam::labelList& Foam::shellSurfaces::nSmoothExpansion() const
{
return nSmoothExpansion_;
}
const Foam::vectorField& Foam::shellSurfaces::smoothDirection() const
{
return smoothDirection_;
}
const Foam::labelList& Foam::shellSurfaces::nSmoothPosition() const
{
return nSmoothPosition_;
}
void Foam::shellSurfaces::findHigherLevel
(
const pointField& pt,
......
......@@ -86,8 +86,20 @@ private:
//- Per shell per distance the refinement level
labelListList levels_;
//- Per shell any additional directional refinement
List<Tuple2<labelPair,labelVector>> dirLevels_;
// Directional
//- Per shell any additional directional refinement
List<Tuple2<labelPair,labelVector>> dirLevels_;
//- Per shell the smoothing direction
vectorField smoothDirection_;
//- Per shell the directional smoothing iterations
labelList nSmoothExpansion_;
//- Per shell the positional smoothing iterations
labelList nSmoothPosition_;
// Gap level refinement
......@@ -231,6 +243,15 @@ public:
const direction dir,
labelList& shell
) const;
//- Per shell the smoothing direction
const vectorField& smoothDirection() const;
//- Per shell the directional smoothing iterations
const labelList& nSmoothExpansion() const;
//- Per shell the positional smoothing iterations
const labelList& nSmoothPosition() const;
};
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -22,87 +22,128 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::pointData
Foam::PointIntegrateData
Description
Variant of pointEdgePoint with some transported additional data.
WIP - should be templated on data like wallDistData.
Passive vector v_ is not a coordinate (so no enterDomain/leaveDomain
transformation needed)
Integrate along selected edges using PointEdgeWave.
SourceFiles
pointDataI.H
pointData.C
PointIntegrateDataI.H
\*---------------------------------------------------------------------------*/
#ifndef pointData_H
#define pointData_H
#include "pointEdgePoint.H"
#ifndef PointIntegrateData_H
#define PointIntegrateData_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
class pointData;
Istream& operator>>(Istream&, pointData&);
Ostream& operator<<(Ostream&, const pointData&);
// Forward declaration of classes
class Istream;
class Ostream;
template<class DataType>
class PointIntegrateData;
// Forward declaration of friend functions and operators
template<class DataType>
Ostream& operator<<(Ostream&, const PointIntegrateData<DataType>&);
template<class DataType>
Istream& operator>>(Istream&, PointIntegrateData<DataType>&);
/*---------------------------------------------------------------------------*\
Class pointData Declaration
Class PointIntegrateData declaration
\*---------------------------------------------------------------------------*/
class pointData
:
public pointEdgePoint
template<class DataType>
class PointIntegrateData
{
private:
// Private data
//- Additional information.
scalar s_;
//- Valid flag
bool valid_;
//- Integrated data
DataType data_;
//- Additional information.
vector v_;
public:
//- Class used to pass extra data
class trackingData
{
public:
UList<DataType>& edgeData_;
trackingData(UList<DataType>& edgeData)
:
edgeData_(edgeData)
{}
};
// Constructors
//- Construct null
inline pointData();
//- Construct from origin, distance
inline pointData
(
const point& origin,
const scalar distSqr,
const scalar s,
const vector& v
);
inline PointIntegrateData();
//- Construct as copy
inline pointData(const pointData&);
//- Construct from data
inline PointIntegrateData(const DataType& data);
// Member Functions
// Access
inline scalar s() const;
//- Const access the data
inline const DataType& data() const
{
return data_;
};
// Needed by PointEdgeWave
inline const vector& v() const;
//- Check whether original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Check for identical geometrical data. Used for cyclics checking.
template<class TrackingData>
inline bool sameGeometry
(
const PointIntegrateData<DataType>&,
const scalar tol,
TrackingData& td
) const;
//- Convert origin to relative vector to leaving point
// (= point coordinate)
template<class TrackingData>
inline void leaveDomain
(
const polyPatch& patch,
const label patchPointi,
const point& pos,
TrackingData& td
);
// Needed by meshWave
//- Convert relative origin to absolute by adding entering point
template<class TrackingData>
inline void enterDomain
(
const polyPatch& patch,
const label patchPointi,
const point& pos,
TrackingData& td
);
//- Apply rotation matrix to origin
//- Apply rotation matrix to the data
template<class TrackingData>
inline void transform
(
......@@ -115,9 +156,9 @@ public:
inline bool updatePoint
(
const polyMesh& mesh,
const label pointi,
const label pointI,
const label edgeI,
const pointData& edgeInfo,
const PointIntegrateData<DataType>& edgeInfo,
const scalar tol,
TrackingData& td
);
......@@ -128,8 +169,8 @@ public:
inline bool updatePoint
(
const polyMesh& mesh,
const label pointi,
const pointData& newPointInfo,
const label pointI,
const PointIntegrateData<DataType>& newPointInfo,
const scalar tol,
TrackingData& td
);
......@@ -139,7 +180,7 @@ public:
template<class TrackingData>
inline bool updatePoint
(
const pointData& newPointInfo,
const PointIntegrateData<DataType>& newPointInfo,
const scalar tol,
TrackingData& td
);
......@@ -150,33 +191,57 @@ public:
(
const polyMesh& mesh,
const label edgeI,
const label pointi,
const pointData& pointInfo,
const label pointI,
const PointIntegrateData<DataType>& pointInfo,
const scalar tol,
TrackingData& td
);
//- Same (like operator==)
template<class TrackingData>
inline bool equal
(
const PointIntegrateData<DataType>&,
TrackingData& td
) const;
// Member Operators
// Needed for List IO
inline bool operator==(const pointData&) const;
inline bool operator!=(const pointData&) const;
inline bool operator==(const PointIntegrateData<DataType>&) const;
inline bool operator!=(const PointIntegrateData<DataType>&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const pointData&);
friend Istream& operator>>(Istream&, pointData&);
friend Ostream& operator<< <DataType>
(
Ostream&,
const PointIntegrateData<DataType>&
);
friend Istream& operator>> <DataType>
(
Istream&,
PointIntegrateData<DataType>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Data associated with PointIntegrateData types is contiguous
//- Data associated with pointData as contiguous as pointEdgePoint
template<>
inline bool contiguous<pointData>()
inline bool contiguous<PointIntegrateData<scalar>>()
{
return contiguous<pointEdgePoint>();
return true;
}
template<>
inline bool contiguous<PointIntegrateData<vector>>()
{
return true;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -184,7 +249,7 @@ inline bool contiguous<pointData>()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointDataI.H"
#include "PointIntegrateDataI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -28,92 +28,103 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
inline Foam::pointData::pointData()
template<class DataType>
inline Foam::PointIntegrateData<DataType>::PointIntegrateData()
:
pointEdgePoint(),
s_(GREAT),
v_(point::max)
valid_(false)
{}
// Construct from origin, distance
inline Foam::pointData::pointData
template<class DataType>
inline Foam::PointIntegrateData<DataType>::PointIntegrateData
(
const point& origin,
const scalar distSqr,
const scalar s,
const vector& v
const DataType& data
)
:
pointEdgePoint(origin, distSqr),
s_(s),
v_(v)
{}
// Construct as copy
inline Foam::pointData::pointData(const pointData& wpt)
:
pointEdgePoint(wpt),
s_(wpt.s()),
v_(wpt.v())
valid_(true),
data_(data)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline Foam::scalar Foam::pointData::s() const
template<class DataType>
template<class TrackingData>
inline bool Foam::PointIntegrateData<DataType>::valid(TrackingData& td) const
{
return s_;
return valid_;
}
inline const Foam::vector& Foam::pointData::v() const
template<class DataType>
template<class TrackingData>
inline bool Foam::PointIntegrateData<DataType>::sameGeometry
(
const PointIntegrateData<DataType>&,
const scalar tol,
TrackingData& td
) const
{
return v_;
return true;
}
template<class DataType>
template<class TrackingData>
inline void Foam::PointIntegrateData<DataType>::leaveDomain
(
const polyPatch& patch,
const label patchPointi,
const point& pos,
TrackingData& td
)
{}
template<class DataType>
template<class TrackingData>
inline void Foam::pointData::transform
inline void Foam::PointIntegrateData<DataType>::enterDomain
(
const polyPatch& patch,
const label patchPointi,
const point& pos,
TrackingData& td
)
{}
template<class DataType>
template<class TrackingData>
inline void Foam::PointIntegrateData<DataType>::transform
(
const tensor& rotTensor,
TrackingData& td
)
{
pointEdgePoint::transform(rotTensor, td);
v_ = Foam::transform(rotTensor, v_);
this->data_ = Foam::transform(rotTensor, this->data_);
}
// Update this with information from connected edge
template<class DataType>
template<class TrackingData>
inline bool Foam::pointData::updatePoint
inline bool Foam::PointIntegrateData<DataType>::updatePoint
(
const polyMesh& mesh,
const label pointi,
const label pointI,
const label edgeI,
const pointData& edgeInfo,
const PointIntegrateData<DataType>& edgeInfo,
const scalar tol,
TrackingData& td
)
{
if
(
pointEdgePoint::updatePoint
(
mesh,
pointi,
edgeI,
edgeInfo,
tol,
td
)
)
// Update point from an edge
if (!valid_)
{
s_ = edgeInfo.s_;
v_ = edgeInfo.v_;
if (!edgeInfo.valid_)
{
FatalErrorInFunction<< "edgeInfo:" << edgeInfo << exit(FatalError);
}
this->operator=(edgeInfo);
return true;
}
else
......@@ -122,31 +133,27 @@ inline bool Foam::pointData::updatePoint
}
}