Commit 77753021 authored by sergio's avatar sergio
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents ba870ef7 073770dd
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
. $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments
. $WM_PROJECT_DIR/wmake/scripts/have_fftw
#------------------------------------------------------------------------------
if have_fftw
then
wmake
wmake $targetType
else
echo "==> skip dnsFoam solver (no FFTW)"
fi
......
......@@ -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);
{
......
......@@ -123,12 +123,6 @@ Foam::functionObjects::fieldMinMax::fieldMinMax
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::functionObjects::fieldMinMax::~fieldMinMax()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::functionObjects::fieldMinMax::read(const dictionary& dict)
......
......@@ -156,6 +156,14 @@ protected:
//- No copy assignment
void operator=(const fieldMinMax&) = delete;
//- Calculate the field min/max for a given field type
template<class Type>
void calcMinMaxFieldType
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const word& outputFieldName
);
//- Calculate the field min/max
template<class Type>
void calcMinMaxFields
......@@ -183,7 +191,7 @@ public:
//- Destructor
virtual ~fieldMinMax();
virtual ~fieldMinMax() = default;
// Member Functions
......
......@@ -110,6 +110,126 @@ void Foam::functionObjects::fieldMinMax::output
}
template<class Type>
void Foam::functionObjects::fieldMinMax::calcMinMaxFieldType
(
const GeometricField<Type, fvPatchField, volMesh>& field,
const word& outputFieldName
)
{
const label proci = Pstream::myProcNo();
// Find min internal field value info
List<Type> minVs(Pstream::nProcs());
labelList minCells(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(field);
if (minProci != -1)
{
minVs[proci] = field[minProci];
minCells[proci] = minProci;
minCs[proci] = mesh_.C()[minProci];
}
else
{
minVs[proci] = pTraits<Type>::max;
minCells[proci] = -1;
minCs[proci] = vector::max;
}
// Find max internal field value info
List<Type> maxVs(Pstream::nProcs());
labelList maxCells(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(field);
if (maxProci != -1)
{
maxVs[proci] = field[maxProci];
maxCells[proci] = maxProci;
maxCs[proci] = mesh_.C()[maxProci];
}
else
{
maxVs[proci] = pTraits<Type>::min;
maxCells[proci] = -1;
maxCs[proci] = vector::max;
}
// Find min and max boundary field info
const auto& fieldBoundary = field.boundaryField();
const auto& CfBoundary = mesh_.C().boundaryField();
forAll(fieldBoundary, patchi)
{
const Field<Type>& fp = fieldBoundary[patchi];
if (fp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
const labelList& faceCells =
fieldBoundary[patchi].patch().faceCells();
label minPi = findMin(fp);
if (fp[minPi] < minVs[proci])
{
minVs[proci] = fp[minPi];
minCells[proci] = faceCells[minPi];
minCs[proci] = Cfp[minPi];
}
label maxPi = findMax(fp);
if (fp[maxPi] > maxVs[proci])
{
maxVs[proci] = fp[maxPi];
maxCells[proci] = faceCells[maxPi];
maxCs[proci] = Cfp[maxPi];
}
}
}
// Collect info from all processors and output
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCells);
Pstream::scatterList(minCells);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCells);
Pstream::scatterList(maxCells);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
label mini = findMin(minVs);
const Type& minValue = minVs[mini];
const label minCell = minCells[mini];
const vector& minC = minCs[mini];
label maxi = findMax(maxVs);
const Type& maxValue = maxVs[maxi];
const label maxCell = maxCells[maxi];
const vector& maxC = maxCs[maxi];
output
(
field.name(),
outputFieldName,
minCell,
maxCell,
minC,
maxC,
mini,
maxi,
minValue,
maxValue
);
}
template<class Type>
void Foam::functionObjects::fieldMinMax::calcMinMaxFields
(
......@@ -121,191 +241,22 @@ void Foam::functionObjects::fieldMinMax::calcMinMaxFields
if (obr_.foundObject<fieldType>(fieldName))
{
const label proci = Pstream::myProcNo();
const fieldType& field = lookupObject<fieldType>(fieldName);
const volVectorField::Boundary& CfBoundary =
mesh_.C().boundaryField();
switch (mode)
{
case mdMag:
{
const volScalarField magField(mag(field));
const volScalarField::Boundary& magFieldBoundary =
magField.boundaryField();
scalarList minVs(Pstream::nProcs());
labelList minCells(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(magField);
minVs[proci] = magField[minProci];
minCells[proci] = minProci;
minCs[proci] = mesh_.C()[minProci];
scalarList maxVs(Pstream::nProcs());
labelList maxCells(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(magField);
maxVs[proci] = magField[maxProci];
maxCells[proci] = maxProci;
maxCs[proci] = mesh_.C()[maxProci];
forAll(magFieldBoundary, patchi)
{
const scalarField& mfp = magFieldBoundary[patchi];
if (mfp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
const labelList& faceCells =
magFieldBoundary[patchi].patch().faceCells();
label minPi = findMin(mfp);
if (mfp[minPi] < minVs[proci])
{
minVs[proci] = mfp[minPi];
minCells[proci] = faceCells[minPi];
minCs[proci] = Cfp[minPi];
}
label maxPi = findMax(mfp);
if (mfp[maxPi] > maxVs[proci])
{
maxVs[proci] = mfp[maxPi];
maxCells[proci] = faceCells[maxPi];
maxCs[proci] = Cfp[maxPi];
}
}
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCells);
Pstream::scatterList(minCells);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCells);
Pstream::scatterList(maxCells);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
label mini = findMin(minVs);
scalar minValue = minVs[mini];
const label minCell = minCells[mini];
const vector& minC = minCs[mini];
label maxi = findMax(maxVs);
scalar maxValue = maxVs[maxi];
const label maxCell = maxCells[maxi];
const vector& maxC = maxCs[maxi];
output
calcMinMaxFieldType<scalar>
(
fieldName,
word("mag(" + fieldName + ")"),
minCell,
maxCell,
minC,
maxC,
mini,
maxi,
minValue,
maxValue
mag(field),
word("mag(" + fieldName + ")")
);
break;
}
case mdCmpt:
{
const typename fieldType::Boundary&
fieldBoundary = field.boundaryField();
List<Type> minVs(Pstream::nProcs());
labelList minCells(Pstream::nProcs());
List<vector> minCs(Pstream::nProcs());
label minProci = findMin(field);
minVs[proci] = field[minProci];
minCells[proci] = minProci;
minCs[proci] = mesh_.C()[minProci];
List<Type> maxVs(Pstream::nProcs());
labelList maxCells(Pstream::nProcs());
List<vector> maxCs(Pstream::nProcs());
label maxProci = findMax(field);
maxVs[proci] = field[maxProci];
maxCells[proci] = maxProci;
maxCs[proci] = mesh_.C()[maxProci];
forAll(fieldBoundary, patchi)
{
const Field<Type>& fp = fieldBoundary[patchi];
if (fp.size())
{
const vectorField& Cfp = CfBoundary[patchi];
const labelList& faceCells =
fieldBoundary[patchi].patch().faceCells();
label minPi = findMin(fp);
if (fp[minPi] < minVs[proci])
{
minVs[proci] = fp[minPi];
minCells[proci] = faceCells[minPi];
minCs[proci] = Cfp[minPi];
}
label maxPi = findMax(fp);
if (fp[maxPi] > maxVs[proci])
{
maxVs[proci] = fp[maxPi];
maxCells[proci] = faceCells[maxPi];
maxCs[proci] = Cfp[maxPi];
}
}
}
Pstream::gatherList(minVs);
Pstream::scatterList(minVs);
Pstream::gatherList(minCells);
Pstream::scatterList(minCells);
Pstream::gatherList(minCs);
Pstream::scatterList(minCs);
Pstream::gatherList(maxVs);
Pstream::scatterList(maxVs);
Pstream::gatherList(maxCells);
Pstream::scatterList(maxCells);
Pstream::gatherList(maxCs);
Pstream::scatterList(maxCs);
label mini = findMin(minVs);
Type minValue = minVs[mini];
const label minCell = minCells[mini];
const vector& minC = minCs[mini];
label maxi = findMax(maxVs);
Type maxValue = maxVs[maxi];
const label maxCell = maxCells[maxi];
const vector& maxC = maxCs[maxi];
output
(
fieldName,
fieldName,
minCell,
maxCell,
minC,
maxC,
mini,
maxi,
minValue,
maxValue
);
calcMinMaxFieldType(field, fieldName);
break;
}
default:
......
......@@ -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