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

This commit is contained in:
sergio
2018-04-06 08:52:23 -07:00
17 changed files with 78 additions and 61 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -2560,6 +2560,11 @@ Foam::labelBits Foam::indexedOctree<Type>::findNode
template<class Type> template<class Type>
Foam::label Foam::indexedOctree<Type>::findInside(const point& sample) const Foam::label Foam::indexedOctree<Type>::findInside(const point& sample) const
{ {
if (nodes_.empty())
{
return -1;
}
labelBits index = findNode(0, sample); labelBits index = findNode(0, sample);
const node& nod = nodes_[getNode(index)]; const node& nod = nodes_[getNode(index)];
@ -2592,6 +2597,11 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
const point& sample const point& sample
) const ) const
{ {
if (nodes_.empty())
{
return emptyList<label>();
}
labelBits index = findNode(0, sample); labelBits index = findNode(0, sample);
const node& nod = nodes_[getNode(index)]; const node& nod = nodes_[getNode(index)];
@ -2603,10 +2613,8 @@ const Foam::labelList& Foam::indexedOctree<Type>::findIndices
{ {
return contents_[getContent(contentIndex)]; return contents_[getContent(contentIndex)];
} }
else
{ return emptyList<label>();
return emptyList<label>();
}
} }
@ -2688,18 +2696,21 @@ void Foam::indexedOctree<Type>::findNear
CompareOp& cop CompareOp& cop
) const ) const
{ {
findNear if (!nodes_.empty())
( {
nearDist, findNear
true, (
*this, nearDist,
nodePlusOctant(0, 0), true,
bb(), *this,
tree2, nodePlusOctant(0, 0),
nodePlusOctant(0, 0), bb(),
tree2.bb(), tree2,
cop nodePlusOctant(0, 0),
); tree2.bb(),
cop
);
}
} }
@ -2711,6 +2722,11 @@ void Foam::indexedOctree<Type>::print
const label nodeI const label nodeI
) const ) const
{ {
if (nodes_.empty())
{
return;
}
const node& nod = nodes_[nodeI]; const node& nod = nodes_[nodeI];
const treeBoundBox& bb = nod.bb_; const treeBoundBox& bb = nod.bb_;

View File

@ -58,6 +58,8 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"), temperatureCoupledBase(patch(), "undefined", "undefined", "undefined-K"),
mode_(fixedHeatFlux), mode_(fixedHeatFlux),
Q_(0), Q_(0),
q_(),
h_(),
Ta_(), Ta_(),
relaxation_(1), relaxation_(1),
emissivity_(0), emissivity_(0),
@ -84,7 +86,9 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), dict), temperatureCoupledBase(patch(), dict),
mode_(operationModeNames.lookup("mode", dict)), mode_(operationModeNames.lookup("mode", dict)),
Q_(0), Q_(0),
Ta_(Function1<scalar>::New("Ta", dict)), q_(),
h_(),
Ta_(),
relaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)), relaxation_(dict.lookupOrDefault<scalar>("relaxation", 1)),
emissivity_(dict.lookupOrDefault<scalar>("emissivity", 0)), emissivity_(dict.lookupOrDefault<scalar>("emissivity", 0)),
qrRelaxation_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)), qrRelaxation_(dict.lookupOrDefault<scalar>("qrRelaxation", 1)),
@ -109,6 +113,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
case fixedHeatTransferCoeff: case fixedHeatTransferCoeff:
{ {
h_ = scalarField("h", dict, p.size()); h_ = scalarField("h", dict, p.size());
Ta_ = Function1<scalar>::New("Ta", dict);
if (dict.found("thicknessLayers")) if (dict.found("thicknessLayers"))
{ {
@ -175,12 +180,12 @@ externalWallHeatFluxTemperatureFvPatchScalarField
temperatureCoupledBase(patch(), ptf), temperatureCoupledBase(patch(), ptf),
mode_(ptf.mode_), mode_(ptf.mode_),
Q_(ptf.Q_), Q_(ptf.Q_),
q_(ptf.q_, mapper), q_(),
h_(ptf.h_, mapper), h_(),
Ta_(ptf.Ta_, false), Ta_(ptf.Ta_, false),
relaxation_(ptf.relaxation_), relaxation_(ptf.relaxation_),
emissivity_(ptf.emissivity_), emissivity_(ptf.emissivity_),
qrPrevious_(ptf.qrPrevious_, mapper), qrPrevious_(),
qrRelaxation_(ptf.qrRelaxation_), qrRelaxation_(ptf.qrRelaxation_),
qrName_(ptf.qrName_), qrName_(ptf.qrName_),
thicknessLayers_(ptf.thicknessLayers_), thicknessLayers_(ptf.thicknessLayers_),
@ -194,12 +199,14 @@ externalWallHeatFluxTemperatureFvPatchScalarField
} }
case fixedHeatFlux: case fixedHeatFlux:
{ {
q_.setSize(mapper.size());
q_.map(ptf.q_, mapper); q_.map(ptf.q_, mapper);
break; break;
} }
case fixedHeatTransferCoeff: case fixedHeatTransferCoeff:
{ {
h_.setSize(mapper.size());
h_.map(ptf.h_, mapper); h_.map(ptf.h_, mapper);
break; break;

View File

@ -615,8 +615,8 @@ void Foam::isoAdvection::limitFluxes()
const scalar aTol = 1.0e-12; // Note: tolerances const scalar aTol = 1.0e-12; // Note: tolerances
const scalar maxAlphaMinus1 = 1; // max(alphaNew - 1); const scalar maxAlphaMinus1 = 1; // max(alphaNew - 1);
const scalar minAlpha = -1; // min(alphaNew); const scalar minAlpha = -1; // min(alphaNew);
const label nUndershoots = 20; // sum(neg(alphaNew + aTol)); const label nUndershoots = 20; // sum(neg0(alphaNew + aTol));
const label nOvershoots = 20; // sum(pos(alphaNew - 1 - aTol)); const label nOvershoots = 20; // sum(pos0(alphaNew - 1 - aTol));
cellIsBounded_ = false; cellIsBounded_ = false;
// Loop number of bounding steps // Loop number of bounding steps
@ -682,8 +682,8 @@ void Foam::isoAdvection::limitFluxes()
scalarField alphaNew(alpha1In_ - fvc::surfaceIntegrate(dVf_)()); scalarField alphaNew(alpha1In_ - fvc::surfaceIntegrate(dVf_)());
label maxAlphaMinus1 = max(alphaNew - 1); label maxAlphaMinus1 = max(alphaNew - 1);
scalar minAlpha = min(alphaNew); scalar minAlpha = min(alphaNew);
label nUndershoots = sum(neg(alphaNew + aTol)); label nUndershoots = sum(neg0(alphaNew + aTol));
label nOvershoots = sum(pos(alphaNew - 1 - aTol)); label nOvershoots = sum(pos0(alphaNew - 1 - aTol));
Info<< "After bounding number " << n + 1 << " of time " Info<< "After bounding number " << n + 1 << " of time "
<< mesh_.time().value() << ":" << endl; << mesh_.time().value() << ":" << endl;
Info<< "nOvershoots = " << nOvershoots << " with max(alphaNew-1) = " Info<< "nOvershoots = " << nOvershoots << " with max(alphaNew-1) = "
@ -792,7 +792,7 @@ void Foam::isoAdvection::boundFromAbove
fluidToPassOn*mag(phi[fi]*dt)/dVftot; fluidToPassOn*mag(phi[fi]*dt)/dVftot;
nFacesToPassFluidThrough += nFacesToPassFluidThrough +=
pos(dVfmax[fi] - fluidToPassThroughFace); pos0(dVfmax[fi] - fluidToPassThroughFace);
fluidToPassThroughFace = fluidToPassThroughFace =
min(fluidToPassThroughFace, dVfmax[fi]); min(fluidToPassThroughFace, dVfmax[fi]);
@ -1014,9 +1014,9 @@ void Foam::isoAdvection::applyBruteForceBounding()
{ {
alpha1_ = alpha1_ =
alpha1_ alpha1_
*pos(alpha1_ - snapAlphaTol) *pos0(alpha1_ - snapAlphaTol)
*neg(alpha1_ - (1.0 - snapAlphaTol)) *neg0(alpha1_ - (1.0 - snapAlphaTol))
+ pos(alpha1_ - (1.0 - snapAlphaTol)); + pos0(alpha1_ - (1.0 - snapAlphaTol));
alpha1Changed = true; alpha1Changed = true;
} }

View File

@ -362,7 +362,7 @@ Foam::scalar Foam::isoCutFace::timeIntegratedArea
{ {
// If all face cuttings were in the past and cell is filling up (Un0>0) // If all face cuttings were in the past and cell is filling up (Un0>0)
// then face must be full during whole time interval // then face must be full during whole time interval
tIntArea = magSf*dt*pos(Un0); tIntArea = magSf*dt*pos0(Un0);
return tIntArea; return tIntArea;
} }
@ -373,7 +373,7 @@ Foam::scalar Foam::isoCutFace::timeIntegratedArea
// If all cuttings are in the future but non of them within [0,dt] then // If all cuttings are in the future but non of them within [0,dt] then
// if cell is filling up (Un0 > 0) face must be empty during whole time // if cell is filling up (Un0 > 0) face must be empty during whole time
// interval // interval
tIntArea = magSf*dt*(1 - pos(Un0)); tIntArea = magSf*dt*(1 - pos0(Un0));
return tIntArea; return tIntArea;
} }
@ -398,7 +398,7 @@ Foam::scalar Foam::isoCutFace::timeIntegratedArea
// If Un0 > 0 cell is filling up and it must initially be empty. // If Un0 > 0 cell is filling up and it must initially be empty.
// If Un0 < 0 cell must initially be full(y immersed in fluid A). // If Un0 < 0 cell must initially be full(y immersed in fluid A).
time = firstTime; time = firstTime;
initialArea = magSf*(1.0 - pos(Un0)); initialArea = magSf*(1.0 - pos0(Un0));
tIntArea = initialArea*time; tIntArea = initialArea*time;
cutPoints(fPts, pTimes, time, FIIL); cutPoints(fPts, pTimes, time, FIIL);
} }
@ -470,7 +470,7 @@ Foam::scalar Foam::isoCutFace::timeIntegratedArea
{ {
// FIIL will leave the face at lastTime and face will be fully in fluid // FIIL will leave the face at lastTime and face will be fully in fluid
// A or fluid B in the time interval from lastTime to dt. // A or fluid B in the time interval from lastTime to dt.
tIntArea += magSf*(dt - lastTime)*pos(Un0); tIntArea += magSf*(dt - lastTime)*pos0(Un0);
} }
return tIntArea; return tIntArea;

View File

@ -47,10 +47,6 @@ const char* Foam::distributionModels::binned::header =
void Foam::distributionModels::binned::initialise() void Foam::distributionModels::binned::initialise()
{ {
const label nSample(xy_.size()); const label nSample(xy_.size());
forAll(xy_, bini)
{
xy_[bini][1] /= scalar(nSample);
}
// Convert values to integral values // Convert values to integral values
for (label bini = 1; bini < nSample; ++bini) for (label bini = 1; bini < nSample; ++bini)
@ -58,6 +54,13 @@ void Foam::distributionModels::binned::initialise()
xy_[bini][1] += xy_[bini - 1][1]; xy_[bini][1] += xy_[bini - 1][1];
} }
// Normalise
scalar sumProb = xy_.last()[1];
forAll(xy_, bini)
{
xy_[bini][1] /= sumProb;
}
// Calculate the mean value // Calculate the mean value
label bini = 0; label bini = 0;
forAll(xy_, i) forAll(xy_, i)
@ -188,16 +191,7 @@ Foam::scalar Foam::distributionModels::binned::sample() const
{ {
if (xy_[i][1] > y) if (xy_[i][1] > y)
{ {
scalar d1 = y - xy_[i][1]; return xy_[i][0];
scalar d2 = xy_[i+1][1] - y;
if (d1 < d2)
{
return xy_[i][0];
}
else
{
return xy_[i+1][0];
}
} }
} }

View File

@ -312,7 +312,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
const pointField& pointLst = surf.points(); const pointField& pointLst = surf.points();
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().size() surf.surfZones().size()
? surf.surfZones() ? surf.surfZones()
@ -393,7 +393,7 @@ void Foam::fileFormats::AC3DsurfaceFormat<Face>::write
if (zoneLst.size() <= 1) if (zoneLst.size() <= 1)
{ {
const List<surfZone>& zones = const surfZoneList zones =
( (
zoneLst.size() zoneLst.size()
? zoneLst ? zoneLst

View File

@ -169,7 +169,7 @@ void Foam::fileFormats::FLMAsurfaceFormat<Face>::write
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
// for no zones, suppress the group name // for no zones, suppress the group name
const List<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst, word::null) ? surfaceFormatsCore::oneZone(faceLst, word::null)

View File

@ -253,7 +253,7 @@ void Foam::fileFormats::GTSsurfaceFormat<Face>::write
const UList<point>& pointLst = surf.points(); const UList<point>& pointLst = surf.points();
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().size() surf.surfZones().size()
? surf.surfZones() ? surf.surfZones()

View File

@ -420,7 +420,7 @@ void Foam::fileFormats::NASsurfaceFormat<Face>::write
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
// for no zones, suppress the group name // for no zones, suppress the group name
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst, "") ? surfaceFormatsCore::oneZone(faceLst, "")

View File

@ -217,7 +217,7 @@ void Foam::fileFormats::OBJsurfaceFormat<Face>::write
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
// for no zones, suppress the group name // for no zones, suppress the group name
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst, "") ? surfaceFormatsCore::oneZone(faceLst, "")

View File

@ -41,7 +41,7 @@ void Foam::fileFormats::SMESHsurfaceFormat<Face>::write
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)

View File

@ -241,7 +241,7 @@ void Foam::fileFormats::STARCDsurfaceFormat<Face>::write
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)

View File

@ -215,7 +215,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeAscii
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)
@ -269,7 +269,7 @@ void Foam::fileFormats::STLsurfaceFormat<Face>::writeBinary
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().size() > 1 surf.surfZones().size() > 1
? surf.surfZones() ? surf.surfZones()

View File

@ -161,7 +161,7 @@ void Foam::fileFormats::TRIsurfaceFormat<Face>::write
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)

View File

@ -265,7 +265,7 @@ void Foam::fileFormats::VTKsurfaceFormat<Face>::write
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)

View File

@ -118,7 +118,7 @@ void Foam::fileFormats::VTPsurfaceFormat<Face>::write
const UList<Face>& faceLst = surf.surfFaces(); const UList<Face>& faceLst = surf.surfFaces();
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
const List<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst) ? surfaceFormatsCore::oneZone(faceLst)

View File

@ -41,7 +41,7 @@ void Foam::fileFormats::X3DsurfaceFormat<Face>::write
const UList<label>& faceMap = surf.faceMap(); const UList<label>& faceMap = surf.faceMap();
// for no zones, suppress the group name // for no zones, suppress the group name
const UList<surfZone>& zones = const surfZoneList zones =
( (
surf.surfZones().empty() surf.surfZones().empty()
? surfaceFormatsCore::oneZone(faceLst, word::null) ? surfaceFormatsCore::oneZone(faceLst, word::null)