Merge branch 'master' of github.com:OpenFOAM/OpenFOAM-2.3.x

This commit is contained in:
andy 2014-10-16 08:58:04 +01:00
commit f722953ed7
38 changed files with 956 additions and 367 deletions

View file

@ -19,16 +19,7 @@
).fvmDiv(phi, alpha1)
);
solve
(
alpha1Eqn
- fv::gaussLaplacianScheme<scalar, scalar>
(
mesh,
linear<scalar>(mesh),
fv::uncorrectedSnGrad<scalar>(mesh)
).fvmLaplacian(fvc::interpolate(turbulence->nut()), alpha1)
);
solve(alpha1Eqn);
Info<< "Phase-1 volume fraction = "
<< alpha1.weightedAverage(mesh.Vsc()).value()
@ -42,6 +33,7 @@
if (alphaApplyPrevCorr && tphiAlphaCorr0.valid())
{
Info<< "Applying the previous iteration correction flux" << endl;
#ifdef LTSSOLVE
MULES::LTScorrect
(

View file

@ -50,7 +50,6 @@
// Apply the diffusion term separately to allow implicit solution
// and boundedness of the explicit advection
if (!MULESCorr)
{
fvScalarMatrix alpha1Eqn
(

View file

@ -323,6 +323,9 @@ addLayersControls
// - overall thickness and firstLayerThickness
// - overall thickness and finalLayerThickness
// - overall thickness and expansionRatio
//
// Note: the mode thus selected is global, i.e. one cannot override the
// mode on a per-patch basis (only the values can be overridden)
// Expansion factor for layer mesh
expansionRatio 1.0;

View file

@ -636,7 +636,7 @@ int main(int argc, char *argv[])
faces,
"zone",
scalarFaceZone,
true
false // face based data
);
}

View file

@ -503,6 +503,7 @@ $(mapPolyMesh)/faceMapper/faceMapper.C
$(mapPolyMesh)/cellMapper/cellMapper.C
$(mapPolyMesh)/mapDistribute/mapDistribute.C
$(mapPolyMesh)/mapDistribute/mapDistributePolyMesh.C
$(mapPolyMesh)/mapDistribute/IOmapDistribute.C
$(mapPolyMesh)/mapAddedPolyMesh.C
PrimitivePatch = $(primitiveMesh)/PrimitivePatch

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -48,7 +48,7 @@ defineTypeNameAndDebug(IOobject, 0);
// "foo/bar/" ERROR - no name
// "foo/xxx/bar" ("foo", "xxx", "bar")
// "foo/xxx/yyy/bar" ("foo", "xxx/yyy", "bar")
bool Foam::IOobject::IOobject::fileNameComponents
bool Foam::IOobject::fileNameComponents
(
const fileName& path,
fileName& instance,

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -128,7 +128,7 @@ Foam::OSstream& Foam::error::operator()
}
Foam::error::operator OSstream&()
Foam::error::operator Foam::OSstream&()
{
if (!messageStreamPtr_->good())
{
@ -142,7 +142,7 @@ Foam::error::operator OSstream&()
}
Foam::error::operator dictionary() const
Foam::error::operator Foam::dictionary() const
{
dictionary errDict;

View file

@ -0,0 +1,159 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "IOmapDistribute.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
namespace Foam
{
defineTypeNameAndDebug(IOmapDistribute, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::IOmapDistribute::IOmapDistribute(const IOobject& io)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
<< "IOmapDistribute " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOmapDistribute does not support automatic rereading."
<< endl;
}
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
Foam::IOmapDistribute::IOmapDistribute
(
const IOobject& io,
const mapDistribute& map
)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
<< "IOmapDistribute " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOmapDistribute does not support automatic rereading."
<< endl;
}
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
else
{
mapDistribute::operator=(map);
}
}
Foam::IOmapDistribute::IOmapDistribute
(
const IOobject& io,
const Xfer<mapDistribute>& map
)
:
regIOobject(io)
{
// Temporary warning
if (io.readOpt() == IOobject::MUST_READ_IF_MODIFIED)
{
WarningIn("IOmapDistribute::IOmapDistribute(const IOobject&)")
<< "IOmapDistribute " << name()
<< " constructed with IOobject::MUST_READ_IF_MODIFIED"
" but IOmapDistribute does not support automatic rereading."
<< endl;
}
mapDistribute::transfer(map());
if
(
(
io.readOpt() == IOobject::MUST_READ
|| io.readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
|| (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk())
)
{
readStream(typeName) >> *this;
close();
}
}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOmapDistribute::~IOmapDistribute()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::IOmapDistribute::readData(Istream& is)
{
return (is >> *this).good();
}
bool Foam::IOmapDistribute::writeData(Ostream& os) const
{
return (os << *this).good();
}
// ************************************************************************* //

View file

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::IOmapDistribute
Description
IOmapDistribute is derived from mapDistribute and
IOobject to give the mapDistribute
automatic IO functionality via the objectRegistry.
SourceFiles
IOmapDistribute.C
\*---------------------------------------------------------------------------*/
#ifndef IOmapDistribute_H
#define IOmapDistribute_H
#include "mapDistribute.H"
#include "regIOobject.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class IOmapDistribute Declaration
\*---------------------------------------------------------------------------*/
class IOmapDistribute
:
public regIOobject,
public mapDistribute
{
public:
//- Runtime type information
TypeName("mapDistribute");
// Constructors
//- Construct given an IOobject
IOmapDistribute(const IOobject&);
//- Construct given an IOobject and mapDistribute
IOmapDistribute(const IOobject&, const mapDistribute&);
//- Construct by transferring the mapDistribute contents
IOmapDistribute(const IOobject&, const Xfer<mapDistribute>&);
//- Destructor
virtual ~IOmapDistribute();
// Member functions
//- ReadData function required for regIOobject read operation
virtual bool readData(Istream&);
//- WriteData function required for regIOobject write operation
virtual bool writeData(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1341,4 +1341,31 @@ void Foam::mapDistribute::operator=(const mapDistribute& rhs)
}
// * * * * * * * * * * * * * * Istream Operator * * * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, mapDistribute& map)
{
is.fatalCheck("operator>>(Istream&, mapDistribute&)");
is >> map.constructSize_ >> map.subMap_ >> map.constructMap_
>> map.transformElements_ >> map.transformStart_;
return is;
}
// * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const mapDistribute& map)
{
os << map.constructSize_ << token::NL
<< map.subMap_ << token::NL
<< map.constructMap_ << token::NL
<< map.transformElements_ << token::NL
<< map.transformStart_ << token::NL;
return os;
}
// ************************************************************************* //

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -676,6 +676,15 @@ public:
void operator=(const mapDistribute&);
// IOstream operators
//- Read dictionary from Istream
friend Istream& operator>>(Istream&, mapDistribute&);
//- Write dictionary to Ostream
friend Ostream& operator<<(Ostream&, const mapDistribute&);
};

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -45,9 +45,6 @@ Foam::PatchTools::pointNormals
const PrimitivePatch<Face, FaceList, PointField, PointType>& p
)
{
// Assume patch is smaller than the globalData().coupledPatch() (?) so
// loop over patch meshPoints.
const globalMeshData& globalData = mesh.globalData();
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
const Map<label>& coupledPatchMP = coupledPatch.meshPointMap();
@ -56,6 +53,108 @@ Foam::PatchTools::pointNormals
globalData.globalTransforms();
// Combine normals. Note: do on all master points. Cannot just use
// patch points since the master point does not have to be on the
// patch!
pointField coupledPointNormals(map.constructSize(), vector::zero);
{
// Collect local pointFaces (sized on patch points only)
List<List<point> > pointFaceNormals(map.constructSize());
forAll(p.meshPoints(), patchPointI)
{
label meshPointI = p.meshPoints()[patchPointI];
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
if (fnd != coupledPatchMP.end())
{
label coupledPointI = fnd();
List<point>& pNormals = pointFaceNormals[coupledPointI];
const labelList& pFaces = p.pointFaces()[patchPointI];
pNormals.setSize(pFaces.size());
forAll(pFaces, i)
{
pNormals[i] = p.faceNormals()[pFaces[i]];
}
}
}
// Pull remote data into local slots
map.distribute
(
transforms,
pointFaceNormals,
mapDistribute::transform()
);
// Combine all face normals (-local, -remote,untransformed,
// -remote,transformed)
const labelListList& slaves = globalData.globalPointSlaves();
const labelListList& transformedSlaves =
globalData.globalPointTransformedSlaves();
forAll(slaves, coupledPointI)
{
const labelList& slaveSlots = slaves[coupledPointI];
const labelList& transformedSlaveSlots =
transformedSlaves[coupledPointI];
point& n = coupledPointNormals[coupledPointI];
// Local entries
const List<point>& local = pointFaceNormals[coupledPointI];
label nFaces =
local.size()
+ slaveSlots.size()
+ transformedSlaveSlots.size();
n = sum(local);
// Add any remote face normals
forAll(slaveSlots, i)
{
n += sum(pointFaceNormals[slaveSlots[i]]);
}
forAll(transformedSlaveSlots, i)
{
n += sum(pointFaceNormals[transformedSlaveSlots[i]]);
}
if (nFaces >= 1)
{
n /= mag(n)+VSMALL;
}
// Put back into slave slots
forAll(slaveSlots, i)
{
coupledPointNormals[slaveSlots[i]] = n;
}
forAll(transformedSlaveSlots, i)
{
coupledPointNormals[transformedSlaveSlots[i]] = n;
}
}
// Send back
map.reverseDistribute
(
transforms,
coupledPointNormals.size(),
coupledPointNormals,
mapDistribute::transform()
);
}
// 1. Start off with local normals (note:without calculating pointNormals
// to avoid them being stored)
@ -78,99 +177,7 @@ Foam::PatchTools::pointNormals
}
// Collect local pointFaces
List<List<point> > pointFaceNormals(map.constructSize());
forAll(p.meshPoints(), patchPointI)
{
label meshPointI = p.meshPoints()[patchPointI];
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
if (fnd != coupledPatchMP.end())
{
label coupledPointI = fnd();
List<point>& pNormals = pointFaceNormals[coupledPointI];
const labelList& pFaces = p.pointFaces()[patchPointI];
pNormals.setSize(pFaces.size());
forAll(pFaces, i)
{
pNormals[i] = p.faceNormals()[pFaces[i]];
}
}
}
// Pull remote data into local slots
map.distribute
(
transforms,
pointFaceNormals,
mapDistribute::transform()
);
// Combine normals
const labelListList& slaves = globalData.globalPointSlaves();
const labelListList& transformedSlaves =
globalData.globalPointTransformedSlaves();
pointField coupledPointNormals(map.constructSize(), vector::zero);
forAll(p.meshPoints(), patchPointI)
{
label meshPointI = p.meshPoints()[patchPointI];
Map<label>::const_iterator fnd = coupledPatchMP.find(meshPointI);
if (fnd != coupledPatchMP.end())
{
label coupledPointI = fnd();
const labelList& slaveSlots =
slaves[coupledPointI];
const labelList& transformedSlaveSlots =
transformedSlaves[coupledPointI];
label nFaces = slaveSlots.size()+transformedSlaveSlots.size();
if (nFaces > 0)
{
// Combine
point& n = coupledPointNormals[coupledPointI];
n += sum(pointFaceNormals[coupledPointI]);
forAll(slaveSlots, i)
{
n += sum(pointFaceNormals[slaveSlots[i]]);
}
forAll(transformedSlaveSlots, i)
{
n += sum(pointFaceNormals[transformedSlaveSlots[i]]);
}
n /= mag(n)+VSMALL;
// Put back into slave slots
forAll(slaveSlots, i)
{
coupledPointNormals[slaveSlots[i]] = n;
}
forAll(transformedSlaveSlots, i)
{
coupledPointNormals[transformedSlaveSlots[i]] = n;
}
}
}
}
// Send back
map.reverseDistribute
(
transforms,
coupledPointNormals.size(),
coupledPointNormals,
mapDistribute::transform()
);
// Override patch normals
// 2. Override patch normals on coupled points
forAll(p.meshPoints(), patchPointI)
{
label meshPointI = p.meshPoints()[patchPointI];

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -372,7 +372,7 @@ Foam::triad Foam::triad::sortxyz() const
Foam::triad::operator quaternion() const
Foam::triad::operator Foam::quaternion() const
{
tensor R;

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -528,6 +528,16 @@ void Foam::motionSmootherAlgo::setDisplacement
}
// Combine any coupled points
syncTools::syncPointList
(
mesh,
displacement,
maxMagEqOp(), // combine op
vector::zero // null value
);
// Adapt the fixedValue bc's (i.e. copy internal point data to
// boundaryField for all affected patches)
setDisplacementPatchFields(patchIDs, displacement);

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -107,6 +107,7 @@ void Foam::MULES::correct
psiMax, psiMin,
nLimiterIter
);
correct(rDeltaT, rho, psi, phi, phiCorr, Sp, Su);
}
@ -172,6 +173,13 @@ void Foam::MULES::limiterCorr
const fvMesh& mesh = psi.mesh();
const dictionary& MULEScontrols = mesh.solverDict(psi.name());
scalar extremaCoeff
(
MULEScontrols.lookupOrDefault<scalar>("extremaCoeff", 0.0)
);
const labelUList& owner = mesh.owner();
const labelUList& neighb = mesh.neighbour();
tmp<volScalarField::DimensionedInternalField> tVsc = mesh.Vsc();
@ -283,8 +291,8 @@ void Foam::MULES::limiterCorr
}
}
psiMaxn = min(psiMaxn, psiMax);
psiMinn = max(psiMinn, psiMin);
psiMaxn = min(psiMaxn + extremaCoeff*(psiMax - psiMin), psiMax);
psiMinn = max(psiMinn - extremaCoeff*(psiMax - psiMin), psiMin);
// scalar smooth = 0.5;
// psiMaxn = min((1.0 - smooth)*psiIf + smooth*psiMaxn, psiMax);

View file

@ -334,8 +334,14 @@ bool Foam::KinematicParcel<ParcelType>::move
p.stepFraction() = newStepFraction;
bool calcParcel = true;
if (!tracking && td.cloud().solution().steadyState())
{
calcParcel = false;
}
// Avoid problems with extremely small timesteps
if (dt > ROOTVSMALL)
if ((dt > ROOTVSMALL) && calcParcel)
{
// Update cell based properties
p.setCellValues(td, dt, cellI);

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -54,7 +54,7 @@ Foam::scalar Foam::SaffmanMeiLiftForce<CloudType>::SaffmanMeiLiftForce::Cl
Cld = 6.46*0.0524*sqrt(beta*Re);
}
return 3.0/(mathematical::twoPi*sqrt(Rew))*Cld;
return 3.0/(mathematical::twoPi*sqrt(Rew + ROOTVSMALL))*Cld;
}

View file

@ -2,7 +2,7 @@ autoHexMesh = autoHexMesh
autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver
$(autoHexMeshDriver)/autoLayerDriver.C
$(autoHexMeshDriver)/autoLayerDriverShrink.C
/* $(autoHexMeshDriver)/autoLayerDriverShrink.C */
$(autoHexMeshDriver)/autoSnapDriver.C
$(autoHexMeshDriver)/autoSnapDriverFeature.C
$(autoHexMeshDriver)/autoRefineDriver.C

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,7 +29,6 @@ Description
SourceFiles
autoLayerDriver.C
autoLayerDriverShrink.C
\*---------------------------------------------------------------------------*/

View file

@ -1292,7 +1292,15 @@ void Foam::autoSnapDriver::detectNearSurfaces
}
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh));
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
meshPoints
)
);
label nOverride = 0;
// 1. All points to non-interface surfaces
@ -1405,7 +1413,7 @@ void Foam::autoSnapDriver::detectNearSurfaces
}
}
if (override && isMasterPoint[meshPoints[pointI]])
if (override && isPatchMasterPoint[pointI])
{
nOverride++;
}
@ -1543,7 +1551,7 @@ void Foam::autoSnapDriver::detectNearSurfaces
}
}
if (override && isMasterPoint[meshPoints[pointI]])
if (override && isPatchMasterPoint[pointI])
{
nOverride++;
}
@ -1758,16 +1766,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurface
}
{
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
pp.meshPoints()
)
);
scalarField magDisp(mag(patchDisp));
Info<< "Wanted displacement : average:"
<< meshRefinement::gAverage
(
mesh,
syncTools::getMasterPoints(mesh),
pp.meshPoints(),
magDisp
)
<< meshRefinement::gAverage(isPatchMasterPoint, magDisp)
<< " min:" << gMin(magDisp)
<< " max:" << gMax(magDisp) << endl;
}

View file

@ -126,7 +126,7 @@ bool Foam::autoSnapDriver::isFeaturePoint
void Foam::autoSnapDriver::smoothAndConstrain
(
const PackedBoolList& isMasterEdge,
const PackedBoolList& isPatchMasterEdge,
const indirectPrimitivePatch& pp,
const labelList& meshEdges,
const List<pointConstraint>& constraints,
@ -168,7 +168,7 @@ void Foam::autoSnapDriver::smoothAndConstrain
{
label edgeI = pEdges[i];
if (isMasterEdge[meshEdges[edgeI]])
if (isPatchMasterEdge[edgeI])
{
label nbrPointI = edges[edgeI].otherVertex(pointI);
if (constraints[nbrPointI].first() >= nConstraints)
@ -3231,20 +3231,24 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
patchConstraints
);
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh));
//const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh));
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh,
pp.meshPoints()
)
);
{
vector avgPatchDisp = meshRefinement::gAverage
(
mesh,
isMasterPoint,
pp.meshPoints(),
isPatchMasterPoint,
patchDisp
);
vector avgPatchAttr = meshRefinement::gAverage
(
mesh,
isMasterPoint,
pp.meshPoints(),
isPatchMasterPoint,
patchAttraction
);
@ -3280,8 +3284,6 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
// Count
{
const labelList& meshPoints = pp.meshPoints();
label nMasterPoints = 0;
label nPlanar = 0;
label nEdge = 0;
@ -3289,7 +3291,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
forAll(patchConstraints, pointI)
{
if (isMasterPoint[meshPoints[pointI]])
if (isPatchMasterPoint[pointI])
{
nMasterPoints++;
@ -3337,7 +3339,19 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
if (featureAttract < 1-0.001)
{
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh));
//const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh));
const labelList meshEdges
(
pp.meshEdges(mesh.edges(), mesh.pointEdges())
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh,
meshEdges
)
);
const vectorField pointNormals
(
@ -3347,17 +3361,13 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
pp
)
);
const labelList meshEdges
(
pp.meshEdges(mesh.edges(), mesh.pointEdges())
);
// 1. Smoothed all displacement
vectorField smoothedPatchDisp = patchDisp;
smoothAndConstrain
(
isMasterEdge,
isPatchMasterEdge,
pp,
meshEdges,
patchConstraints,
@ -3370,7 +3380,7 @@ Foam::vectorField Foam::autoSnapDriver::calcNearestSurfaceFeature
tangPatchDisp -= (pointNormals & patchDisp) * pointNormals;
smoothAndConstrain
(
isMasterEdge,
isPatchMasterEdge,
pp,
meshEdges,
patchConstraints,

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,7 +49,6 @@ Foam::externalDisplacementMeshMover::externalDisplacementMeshMover
{}
// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
Foam::autoPtr<Foam::externalDisplacementMeshMover>

View file

@ -129,9 +129,8 @@ Foam::medialAxisMeshMover::getPatch
void Foam::medialAxisMeshMover::smoothPatchNormals
(
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isPatchMasterEdge,
pointField& normals
) const
{
@ -142,13 +141,12 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
// Get smoothly varying internal normals field.
Info<< typeName << " : Smoothing normals ..." << endl;
scalarField edgeWeights(meshEdges.size());
scalarField edgeWeights(edges.size());
scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights
(
mesh(),
isMasterEdge,
meshEdges,
isPatchMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -162,8 +160,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
meshRefinement::weightedSum
(
mesh(),
isMasterEdge,
meshEdges,
isPatchMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -177,9 +174,7 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
{
scalar resid = meshRefinement::gAverage
(
mesh(),
isMasterPoint,
meshPoints,
isPatchMasterPoint,
mag(normals-average)()
);
Info<< " Iteration " << iter << " residual " << resid << endl;
@ -201,8 +196,8 @@ void Foam::medialAxisMeshMover::smoothPatchNormals
void Foam::medialAxisMeshMover::smoothNormals
(
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const PackedBoolList& isMeshMasterPoint,
const PackedBoolList& isMeshMasterEdge,
const labelList& fixedPoints,
pointVectorField& normals
) const
@ -229,18 +224,16 @@ void Foam::medialAxisMeshMover::smoothNormals
// Correspondence between local edges/points and mesh edges/points
const labelList meshEdges(identity(mesh().nEdges()));
const labelList meshPoints(identity(mesh().nPoints()));
// Calculate inverse sum of weights
scalarField edgeWeights(meshEdges.size());
scalarField edgeWeights(mesh().nEdges());
scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights
(
mesh(),
isMasterEdge,
meshEdges,
isMeshMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -253,8 +246,7 @@ void Foam::medialAxisMeshMover::smoothNormals
meshRefinement::weightedSum
(
mesh(),
isMasterEdge,
meshEdges,
isMeshMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -268,8 +260,7 @@ void Foam::medialAxisMeshMover::smoothNormals
{
scalar resid = meshRefinement::gAverage
(
mesh(),
isMasterPoint,
isMeshMasterPoint,
mag(normals-average)()
);
Info<< " Iteration " << iter << " residual " << resid << endl;
@ -411,9 +402,9 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
// Predetermine mesh edges
// ~~~~~~~~~~~~~~~~~~~~~~~
// Precalulate master point/edge (only relevant for shared points/edges)
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh()));
// Precalulate (mesh) master point/edge (only relevant for shared pts/edges)
const PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMeshMasterEdge(syncTools::getMasterEdges(mesh()));
// Precalculate meshEdge per pp edge
const labelList meshEdges
(
@ -424,6 +415,23 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
)
);
// Precalulate (patch) master point/edge
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh(),
meshPoints
)
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh(),
meshEdges
)
);
// Determine pointNormal
// ~~~~~~~~~~~~~~~~~~~~~
@ -434,9 +442,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
smoothPatchNormals
(
nSmoothSurfaceNormals,
isMasterPoint,
isMasterEdge,
meshEdges,
isPatchMasterPoint,
isPatchMasterEdge,
pointNormals
);
@ -795,8 +802,8 @@ void Foam::medialAxisMeshMover::update(const dictionary& coeffDict)
smoothNormals
(
nSmoothNormals,
isMasterPoint,
isMasterEdge,
isMeshMasterPoint,
isMeshMasterEdge,
meshPoints,
dispVec_
);
@ -999,9 +1006,8 @@ void Foam::medialAxisMeshMover::syncPatchDisplacement
void Foam::medialAxisMeshMover::minSmoothField
(
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isPatchMasterEdge,
const scalarField& fieldMin,
scalarField& field
) const
@ -1010,13 +1016,12 @@ void Foam::medialAxisMeshMover::minSmoothField
const edgeList& edges = pp.edges();
const labelList& meshPoints = pp.meshPoints();
scalarField edgeWeights(meshEdges.size());
scalarField edgeWeights(edges.size());
scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights
(
mesh(),
isMasterEdge,
meshEdges,
isPatchMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -1032,8 +1037,7 @@ void Foam::medialAxisMeshMover::minSmoothField
meshRefinement::weightedSum
(
mesh(),
isMasterEdge,
meshEdges,
isPatchMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -1064,9 +1068,7 @@ void Foam::medialAxisMeshMover::minSmoothField
{
scalar resid = meshRefinement::gAverage
(
mesh(),
isMasterPoint,
meshPoints,
isPatchMasterPoint,
mag(field-average)()
);
Info<< " Iteration " << iter << " residual " << resid << endl;
@ -1080,7 +1082,7 @@ void Foam::medialAxisMeshMover::
handleFeatureAngleLayerTerminations
(
const scalar minCos,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isPatchMasterPoint,
const labelList& meshEdges,
List<autoLayerDriver::extrudeMode>& extrudeStatus,
pointField& patchDisp,
@ -1122,7 +1124,6 @@ handleFeatureAngleLayerTerminations
const labelListList& edgeFaces = pp.edgeFaces();
const vectorField& faceNormals = pp.faceNormals();
const labelList& meshPoints = pp.meshPoints();
forAll(edgeFaces, edgeI)
{
@ -1183,14 +1184,14 @@ handleFeatureAngleLayerTerminations
{
if (unmarkExtrusion(v0, patchDisp, extrudeStatus))
{
if (isMasterPoint[meshPoints[v0]])
if (isPatchMasterPoint[v0])
{
nPointCounter++;
}
}
if (unmarkExtrusion(v1, patchDisp, extrudeStatus))
{
if (isMasterPoint[meshPoints[v1]])
if (isPatchMasterPoint[v1])
{
nPointCounter++;
}
@ -1213,8 +1214,8 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
(
const scalar minCosLayerTermination,
const bool detectExtrusionIsland,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const PackedBoolList& isPatchMasterPoint,
const PackedBoolList& isPatchMasterEdge,
const labelList& meshEdges,
const scalarField& minThickness,
List<autoLayerDriver::extrudeMode>& extrudeStatus,
@ -1223,13 +1224,32 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
{
const indirectPrimitivePatch& pp = adaptPatchPtr_();
const labelListList& pointFaces = pp.pointFaces();
const labelList& meshPoints = pp.meshPoints();
Info<< typeName << " : Removing isolated regions ..." << endl;
// Keep count of number of points unextruded
label nPointCounter = 0;
autoPtr<OBJstream> str;
if (debug)
{
str.reset
(
new OBJstream
(
mesh().time().path()
/ "islandExcludePoints_"
+ mesh().time().timeName()
+ ".obj"
)
);
Info<< typeName
<< " : Writing points surrounded by non-extruded points to "
<< str().name() << endl;
}
while (true)
{
// Stop layer growth where mesh wraps around edge with a
@ -1237,7 +1257,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
handleFeatureAngleLayerTerminations
(
minCosLayerTermination,
isMasterPoint,
isPatchMasterPoint,
meshEdges,
extrudeStatus,
@ -1353,7 +1373,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
syncTools::syncPointList
(
mesh(),
pp.meshPoints(),
meshPoints,
keptPoints,
orEqOp<bool>(),
false // null value
@ -1369,6 +1389,11 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
{
nPointCounter++;
nChanged++;
if (str.valid())
{
str().write(pp.points()[meshPoints[patchPointI]]);
}
}
}
}
@ -1390,7 +1415,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
forAll(edges, edgeI)
{
if (isMasterEdge.get(meshEdges[edgeI]) == 1)
if (isPatchMasterEdge[edgeI])
{
const edge& e = edges[edgeI];
@ -1411,7 +1436,7 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
syncTools::syncPointList
(
mesh(),
pp.meshPoints(),
meshPoints,
isolatedPoint,
plusEqOp<label>(),
label(0) // null value
@ -1458,6 +1483,11 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
)
{
nPointCounter++;
if (str.valid())
{
str().write(pp.points()[meshPoints[f[fp]]]);
}
}
}
}
@ -1474,25 +1504,23 @@ void Foam::medialAxisMeshMover::findIsolatedRegions
void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
(
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const PackedBoolList& isMeshMasterPoint,
const PackedBoolList& isMeshMasterEdge,
vectorField& displacement
) const
{
const edgeList& edges = mesh().edges();
// Correspondence between local edges/points and mesh edges/points
const labelList meshEdges(identity(mesh().nEdges()));
const labelList meshPoints(identity(mesh().nPoints()));
// Calculate inverse sum of weights
scalarField edgeWeights(meshEdges.size());
scalarField edgeWeights(mesh().nEdges());
scalarField invSumWeight(meshPoints.size());
meshRefinement::calculateEdgeWeights
(
mesh(),
isMasterEdge,
meshEdges,
isMeshMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -1512,8 +1540,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
meshRefinement::weightedSum
(
mesh(),
isMasterEdge,
meshEdges,
isMeshMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -1533,8 +1560,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
meshRefinement::weightedSum
(
mesh(),
isMasterEdge,
meshEdges,
isMeshMasterEdge,
meshPoints,
edges,
edgeWeights,
@ -1558,8 +1584,7 @@ void Foam::medialAxisMeshMover::smoothLambdaMuDisplacement
{
scalar resid = meshRefinement::gAverage
(
mesh(),
isMasterPoint,
isMeshMasterPoint,
mag(displacement-average)()
);
Info<< " Iteration " << iter << " residual " << resid << endl;
@ -1735,8 +1760,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
// Precalulate master points/edge (only relevant for shared points/edges)
const PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMasterEdge(syncTools::getMasterEdges(mesh()));
const PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh()));
const PackedBoolList isMeshMasterEdge(syncTools::getMasterEdges(mesh()));
// Precalculate meshEdge per pp edge
const labelList meshEdges
(
@ -1747,6 +1772,24 @@ void Foam::medialAxisMeshMover::calculateDisplacement
)
);
// Precalulate (patch) master point/edge
const PackedBoolList isPatchMasterPoint
(
meshRefinement::getMasterPoints
(
mesh(),
meshPoints
)
);
const PackedBoolList isPatchMasterEdge
(
meshRefinement::getMasterEdges
(
mesh(),
meshEdges
)
);
scalarField thickness(patchDisp.size());
@ -1846,7 +1889,7 @@ void Foam::medialAxisMeshMover::calculateDisplacement
patchDisp[patchPointI] = thickness[patchPointI]*n;
if (isMasterPoint[pointI])
if (isPatchMasterPoint[patchPointI])
{
numThicknessRatioExclude++;
}
@ -1885,8 +1928,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
minCosLayerTermination,
detectExtrusionIsland,
isMasterPoint,
isMasterEdge,
isPatchMasterPoint,
isPatchMasterEdge,
meshEdges,
minThickness,
@ -1908,9 +1951,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
minSmoothField
(
nSmoothPatchThickness,
isMasterPoint,
isMasterEdge,
meshEdges,
isPatchMasterPoint,
isPatchMasterEdge,
minThickness,
thickness
@ -1991,8 +2033,8 @@ void Foam::medialAxisMeshMover::calculateDisplacement
smoothLambdaMuDisplacement
(
nSmoothDisplacement,
isMasterPoint,
isMasterEdge,
isMeshMasterPoint,
isMeshMasterEdge,
displacement
);
}

View file

@ -117,7 +117,6 @@ class medialAxisMeshMover
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
pointField& normals
) const;
@ -175,7 +174,6 @@ class medialAxisMeshMover
const label nSmoothDisp,
const PackedBoolList& isMasterPoint,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const scalarField& fieldMin,
scalarField& field
) const;

View file

@ -1954,7 +1954,6 @@ void Foam::meshRefinement::calculateEdgeWeights
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
scalarField& edgeWeights,
@ -1964,7 +1963,7 @@ void Foam::meshRefinement::calculateEdgeWeights
const pointField& pts = mesh.points();
// Calculate edgeWeights and inverse sum of edge weights
edgeWeights.setSize(meshEdges.size());
edgeWeights.setSize(isMasterEdge.size());
invSumWeight.setSize(meshPoints.size());
forAll(edges, edgeI)
@ -1987,7 +1986,6 @@ void Foam::meshRefinement::calculateEdgeWeights
(
mesh,
isMasterEdge,
meshEdges,
meshPoints,
edges,
edgeWeights,
@ -2639,8 +2637,82 @@ bool Foam::meshRefinement::write() const
}
Foam::PackedBoolList Foam::meshRefinement::getMasterPoints
(
const polyMesh& mesh,
const labelList& meshPoints
)
{
const globalIndex globalPoints(meshPoints.size());
labelList myPoints(meshPoints.size());
forAll(meshPoints, pointI)
{
myPoints[pointI] = globalPoints.toGlobal(pointI);
}
syncTools::syncPointList
(
mesh,
meshPoints,
myPoints,
minEqOp<label>(),
labelMax
);
PackedBoolList isPatchMasterPoint(meshPoints.size());
forAll(meshPoints, pointI)
{
if (myPoints[pointI] == globalPoints.toGlobal(pointI))
{
isPatchMasterPoint[pointI] = true;
}
}
return isPatchMasterPoint;
}
Foam::PackedBoolList Foam::meshRefinement::getMasterEdges
(
const polyMesh& mesh,
const labelList& meshEdges
)
{
const globalIndex globalEdges(meshEdges.size());
labelList myEdges(meshEdges.size());
forAll(meshEdges, edgeI)
{
myEdges[edgeI] = globalEdges.toGlobal(edgeI);
}
syncTools::syncEdgeList
(
mesh,
meshEdges,
myEdges,
minEqOp<label>(),
labelMax
);
PackedBoolList isMasterEdge(meshEdges.size());
forAll(meshEdges, edgeI)
{
if (myEdges[edgeI] == globalEdges.toGlobal(edgeI))
{
isMasterEdge[edgeI] = true;
}
}
return isMasterEdge;
}
void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
const
const
{
const globalMeshData& pData = mesh_.globalData();
@ -2664,11 +2736,11 @@ void Foam::meshRefinement::printMeshInfo(const bool debug, const string& msg)
}
}
PackedBoolList isMasterPoint(syncTools::getMasterPoints(mesh_));
PackedBoolList isMeshMasterPoint(syncTools::getMasterPoints(mesh_));
label nMasterPoints = 0;
forAll(isMasterPoint, i)
forAll(isMeshMasterPoint, i)
{
if (isMasterPoint[i])
if (isMeshMasterPoint[i])
{
nMasterPoints++;
}

View file

@ -733,7 +733,6 @@ public:
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
scalarField& edgeWeights,
@ -747,7 +746,6 @@ public:
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
const scalarField& edgeWeights,
@ -1069,6 +1067,22 @@ public:
const UList<T>& data
);
//- Determine master point for subset of points. If coupled
// chooses only one
static PackedBoolList getMasterPoints
(
const polyMesh& mesh,
const labelList& meshPoints
);
//- Determine master edge for subset of edges. If coupled
// chooses only one
static PackedBoolList getMasterEdges
(
const polyMesh& mesh,
const labelList& meshEdges
);
//- Print some mesh stats.
void printMeshInfo(const bool, const string&) const;
@ -1100,22 +1114,10 @@ public:
template<class T>
static T gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const UList<T>& values
);
//- Helper: calculate average over selected elements
template<class T>
static T gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const labelList& meshPoints,
const UList<T>& values
);
//- Get/set write level
static writeType writeLevel();
static void writeLevel(const writeType);

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -57,7 +57,6 @@ template<class T> void Foam::meshRefinement::updateList
template<class T>
T Foam::meshRefinement::gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const UList<T>& values
)
@ -68,7 +67,6 @@ T Foam::meshRefinement::gAverage
(
"meshRefinement::gAverage\n"
"(\n"
" const polyMesh&,\n"
" const PackedBoolList& isMasterElem,\n"
" const UList<T>& values\n"
")\n"
@ -104,58 +102,6 @@ T Foam::meshRefinement::gAverage
}
template<class T>
T Foam::meshRefinement::gAverage
(
const polyMesh& mesh,
const PackedBoolList& isMasterElem,
const labelList& meshElems,
const UList<T>& values
)
{
if (values.size() != meshElems.size())
{
FatalErrorIn
(
"meshRefinement::gAverage\n"
"(\n"
" const polyMesh&,\n"
" const labelList&,\n"
" const PackedBoolList& isMasterElem,\n"
" const UList<T>& values\n"
")\n"
) << "Number of elements in list " << values.size()
<< " does not correspond to number of elements in meshElems "
<< meshElems.size()
<< exit(FatalError);
}
T sum = pTraits<T>::zero;
label n = 0;
forAll(values, i)
{
if (isMasterElem[meshElems[i]])
{
sum += values[i];
n++;
}
}
reduce(sum, sumOp<T>());
reduce(n, sumOp<label>());
if (n > 0)
{
return sum/n;
}
else
{
return pTraits<T>::max;
}
}
// Compare two lists over all boundary faces
template<class T>
void Foam::meshRefinement::testSyncBoundaryFaceList
@ -343,7 +289,6 @@ void Foam::meshRefinement::weightedSum
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
const scalarField& edgeWeights,
@ -353,15 +298,13 @@ void Foam::meshRefinement::weightedSum
{
if
(
mesh.nEdges() != isMasterEdge.size()
|| edges.size() != meshEdges.size()
edges.size() != isMasterEdge.size()
|| edges.size() != edgeWeights.size()
|| meshPoints.size() != pointData.size()
)
{
FatalErrorIn("medialAxisMeshMover::weightedSum(..)")
<< "Inconsistent sizes for edge or point data:"
<< " meshEdges:" << meshEdges.size()
<< " isMasterEdge:" << isMasterEdge.size()
<< " edgeWeights:" << edgeWeights.size()
<< " edges:" << edges.size()
@ -375,7 +318,7 @@ void Foam::meshRefinement::weightedSum
forAll(edges, edgeI)
{
if (isMasterEdge.get(meshEdges[edgeI]) == 1)
if (isMasterEdge[edgeI])
{
const edge& e = edges[edgeI];

View file

@ -41,6 +41,7 @@ License
#include "triPointRef.H"
#include "syncTools.H"
#include "treeDataCell.H"
#include "DynamicField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -52,14 +53,15 @@ namespace Foam
const char* Foam::NamedEnum
<
Foam::mappedPatchBase::sampleMode,
5
6
>::names[] =
{
"nearestCell",
"nearestPatchFace",
"nearestPatchFaceAMI",
"nearestPatchPoint",
"nearestFace"
"nearestFace",
"nearestOnlyCell"
};
template<>
@ -76,7 +78,7 @@ namespace Foam
}
const Foam::NamedEnum<Foam::mappedPatchBase::sampleMode, 5>
const Foam::NamedEnum<Foam::mappedPatchBase::sampleMode, 6>
Foam::mappedPatchBase::sampleModeNames_;
const Foam::NamedEnum<Foam::mappedPatchBase::offsetMode, 3>
@ -187,6 +189,7 @@ void Foam::mappedPatchBase::collectSamples
// for samples being found in two processors.
void Foam::mappedPatchBase::findSamples
(
const sampleMode mode,
const pointField& samples,
labelList& sampleProcs,
labelList& sampleIndices,
@ -199,7 +202,7 @@ void Foam::mappedPatchBase::findSamples
// All the info for nearest. Construct to miss
List<nearInfo> nearest(samples.size());
switch (mode_)
switch (mode)
{
case NEARESTCELL:
{
@ -210,7 +213,7 @@ void Foam::mappedPatchBase::findSamples
"mappedPatchBase::findSamples(const pointField&,"
" labelList&, labelList&, pointField&) const"
) << "No need to supply a patch name when in "
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
<< sampleModeNames_[mode] << " mode." << exit(FatalError);
}
//- Note: face-diagonal decomposition
@ -244,6 +247,36 @@ void Foam::mappedPatchBase::findSamples
break;
}
case NEARESTONLYCELL:
{
if (samplePatch_.size() && samplePatch_ != "none")
{
FatalErrorIn
(
"mappedPatchBase::findSamples(const pointField&,"
" labelList&, labelList&, pointField&) const"
) << "No need to supply a patch name when in "
<< sampleModeNames_[mode] << " mode." << exit(FatalError);
}
//- Note: face-diagonal decomposition
const indexedOctree<Foam::treeDataCell>& tree = mesh.cellTree();
forAll(samples, sampleI)
{
const point& sample = samples[sampleI];
nearest[sampleI].first() = tree.findNearest(sample, sqr(GREAT));
nearest[sampleI].second().first() = magSqr
(
nearest[sampleI].first().hitPoint()
-sample
);
nearest[sampleI].second().second() = Pstream::myProcNo();
}
break;
}
case NEARESTPATCHFACE:
{
Random rndGen(123456);
@ -398,7 +431,7 @@ void Foam::mappedPatchBase::findSamples
"mappedPatchBase::findSamples(const pointField&,"
" labelList&, labelList&, pointField&) const"
) << "No need to supply a patch name when in "
<< sampleModeNames_[mode_] << " mode." << exit(FatalError);
<< sampleModeNames_[mode] << " mode." << exit(FatalError);
}
//- Note: face-diagonal decomposition
@ -565,7 +598,7 @@ void Foam::mappedPatchBase::calcMapping() const
labelList sampleProcs;
labelList sampleIndices;
pointField sampleLocations;
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
findSamples(mode_, samples, sampleProcs, sampleIndices, sampleLocations);
// Check for samples that were not found. This will only happen for
// NEARESTCELL since finds cell containing a location
@ -607,32 +640,36 @@ void Foam::mappedPatchBase::calcMapping() const
hasWarned = true;
}
// Reset the samples that cannot be found to the cell centres.
pointField patchCc;
{
List<pointField> globalCc(Pstream::nProcs());
globalCc[Pstream::myProcNo()] = patch_.faceCellCentres();
Pstream::gatherList(globalCc);
Pstream::scatterList(globalCc);
patchCc = ListListOps::combine<pointField>
(
globalCc,
accessOp<pointField>()
);
}
// Collect the samples that cannot be found
DynamicList<label> subMap;
DynamicField<point> subSamples;
forAll(sampleProcs, sampleI)
{
if (sampleProcs[sampleI] == -1)
{
// Reset to cell centres
samples[sampleI] = patchCc[sampleI];
subMap.append(sampleI);
subSamples.append(samples[sampleI]);
}
}
// And re-search. Note: could be optimised to only search missing
// points.
findSamples(samples, sampleProcs, sampleIndices, sampleLocations);
// And re-search for pure nearest (should not fail)
labelList subSampleProcs;
labelList subSampleIndices;
pointField subSampleLocations;
findSamples
(
NEARESTONLYCELL,
subSamples,
subSampleProcs,
subSampleIndices,
subSampleLocations
);
// Insert
UIndirectList<label>(sampleProcs, subMap) = subSampleProcs;
UIndirectList<label>(sampleIndices, subMap) = subSampleIndices;
UIndirectList<point>(sampleLocations, subMap) = subSampleLocations;
}
}

View file

@ -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) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,6 +34,8 @@ Description
// What to sample:
// - nearestCell : sample cell containing point
// - nearestOnlyCell : nearest sample cell (even if not containing
// point)
// - nearestPatchFace : nearest face on selected patch
// - nearestPatchFaceAMI : nearest face on selected patch
- patches need not conform
@ -107,11 +109,12 @@ public:
//- Mesh items to sample
enum sampleMode
{
NEARESTCELL, // nearest cell
NEARESTCELL, // nearest cell containing sample
NEARESTPATCHFACE, // nearest face on selected patch
NEARESTPATCHFACEAMI, // nearest patch face + AMI interpolation
NEARESTPATCHPOINT, // nearest point on selected patch
NEARESTFACE // nearest face
NEARESTFACE, // nearest face
NEARESTONLYCELL // nearest cell (even if not containing cell)
};
//- How to project face centres
@ -122,7 +125,7 @@ public:
NORMAL // use face normal + distance
};
static const NamedEnum<sampleMode, 5> sampleModeNames_;
static const NamedEnum<sampleMode, 6> sampleModeNames_;
static const NamedEnum<offsetMode, 3> offsetModeNames_;
@ -255,6 +258,7 @@ protected:
//- Find cells/faces containing samples
void findSamples
(
const sampleMode mode, // search mode
const pointField&,
labelList& sampleProcs, // processor containing sample
labelList& sampleIndices, // local index of cell/face

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -700,4 +700,38 @@ Foam::label Foam::edgeIntersections::removeDegenerates
}
void Foam::edgeIntersections::replace
(
const edgeIntersections& subInfo,
const labelList& edgeMap,
const labelList& faceMap
)
{
forAll(subInfo, subI)
{
const List<pointIndexHit>& subHits = subInfo[subI];
const labelList& subClass = subInfo.classification()[subI];
label edgeI = edgeMap[subI];
List<pointIndexHit>& intersections = operator[](edgeI);
labelList& intersectionTypes = classification_[edgeI];
intersections.setSize(subHits.size());
intersectionTypes.setSize(subHits.size());
forAll(subHits, i)
{
const pointIndexHit& subHit = subHits[i];
intersections[i] = pointIndexHit
(
subHit.hit(),
subHit.rawPoint(),
faceMap[subHit.index()]
);
intersectionTypes[i] = subClass[i];
}
}
}
// ************************************************************************* //

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -197,6 +197,15 @@ public:
const scalarField& surf1PointTol,
pointField& points1
);
//- Replace edge intersection for a subset (given as edge map and
// face map - for face indices stored in pointIndexHit.index())
void replace
(
const edgeIntersections&,
const labelList& edgeMap,
const labelList& faceMap
);
};

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -61,7 +61,8 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
ptf.emissivity_,
mapper
),
TName_(ptf.TName_)
{}
@ -136,7 +137,8 @@ void Foam::MarshakRadiationFvPatchScalarField::autoMap
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
mixedFvPatchScalarField::autoMap(m);
radiationCoupledBase::autoMap(m);
}
@ -147,6 +149,7 @@ void Foam::MarshakRadiationFvPatchScalarField::rmap
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
radiationCoupledBase::rmap(ptf, addr);
}

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -63,7 +63,8 @@ MarshakRadiationFixedTemperatureFvPatchScalarField
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
ptf.emissivity_,
mapper
),
Trad_(ptf.Trad_, mapper)
{}
@ -136,6 +137,7 @@ void Foam::MarshakRadiationFixedTemperatureFvPatchScalarField::autoMap
)
{
mixedFvPatchScalarField::autoMap(m);
radiationCoupledBase::autoMap(m);
Trad_.autoMap(m);
}
@ -147,7 +149,7 @@ void Foam::MarshakRadiationFixedTemperatureFvPatchScalarField::rmap
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
radiationCoupledBase::rmap(ptf, addr);
const MarshakRadiationFixedTemperatureFvPatchScalarField& mrptf =
refCast<const MarshakRadiationFixedTemperatureFvPatchScalarField>(ptf);

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,6 +32,13 @@ License
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(radiationCoupledBase, 0);
}
namespace Foam
{
template<>
@ -66,6 +73,20 @@ Foam::radiationCoupledBase::radiationCoupledBase
{}
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
const word& calculationType,
const scalarField& emissivity,
const fvPatchFieldMapper& mapper
)
:
patch_(patch),
method_(emissivityMethodTypeNames_[calculationType]),
emissivity_(emissivity, mapper)
{}
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
@ -125,6 +146,12 @@ Foam::radiationCoupledBase::radiationCoupledBase
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * //
Foam::radiationCoupledBase::~radiationCoupledBase()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::scalarField Foam::radiationCoupledBase::emissivity() const
@ -189,6 +216,28 @@ Foam::scalarField Foam::radiationCoupledBase::emissivity() const
}
void Foam::radiationCoupledBase::autoMap
(
const fvPatchFieldMapper& m
)
{
emissivity_.autoMap(m);
}
void Foam::radiationCoupledBase::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
const radiationCoupledBase& mrptf =
refCast<const radiationCoupledBase>(ptf);
emissivity_.rmap(mrptf.emissivity_, addr);
}
void Foam::radiationCoupledBase::write(Ostream& os) const
{
os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -42,6 +42,7 @@ SourceFiles
#include "scalarField.H"
#include "NamedEnum.H"
#include "fvPatch.H"
#include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -89,6 +90,10 @@ protected:
public:
//- Runtime type information
TypeName("radiationCoupledBase");
// Constructors
//- Construct from patch, emissivity mode and emissivity
@ -99,6 +104,15 @@ public:
const scalarField& emissivity
);
//- Construct from patch, emissivity mode and emissivity and mapper
radiationCoupledBase
(
const fvPatch& patch,
const word& calculationMethod,
const scalarField& emissivity,
const fvPatchFieldMapper& mapper
);
//- Construct from patch and dictionary
radiationCoupledBase
(
@ -107,17 +121,39 @@ public:
);
//- Destructor
virtual ~radiationCoupledBase();
// Member functions
//- Method to obtain emissivity
word emissivityMethod() const
{
return emissivityMethodTypeNames_[method_];
}
// Access
//- Method to obtain emissivity
word emissivityMethod() const
{
return emissivityMethodTypeNames_[method_];
}
//- Calculate corresponding emissivity field
scalarField emissivity() const;
//- Calculate corresponding emissivity field
scalarField emissivity() const;
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
//- Write
void write(Ostream&) const;

View file

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -201,8 +201,8 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::transferData
{
const Field<scalar>& magSf = magSfs[procI];
const Field<scalar>& value = values[procI];
const Field& qDot = qDots[procI];
const Field& htc = htcs[procI];
const Field<scalar>& qDot = qDots[procI];
const Field<scalar>& htc = htcs[procI];
forAll(magSf, faceI)
{

View file

@ -69,6 +69,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
q_(p.size(), 0.0),
h_(p.size(), 0.0),
Ta_(p.size(), 0.0),
QrName_("undefined-Qr"),
thicknessLayers_(),
kappaLayers_()
{
@ -93,6 +94,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
q_(ptf.q_, mapper),
h_(ptf.h_, mapper),
Ta_(ptf.Ta_, mapper),
QrName_(ptf.QrName_),
thicknessLayers_(ptf.thicknessLayers_),
kappaLayers_(ptf.kappaLayers_)
{}
@ -112,6 +114,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
q_(p.size(), 0.0),
h_(p.size(), 0.0),
Ta_(p.size(), 0.0),
QrName_(dict.lookupOrDefault<word>("Qr", "none")),
thicknessLayers_(),
kappaLayers_()
{
@ -181,6 +184,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_),
QrName_(tppsf.QrName_),
thicknessLayers_(tppsf.thicknessLayers_),
kappaLayers_(tppsf.kappaLayers_)
{}
@ -199,6 +203,7 @@ externalWallHeatFluxTemperatureFvPatchScalarField
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_),
QrName_(tppsf.QrName_),
thicknessLayers_(tppsf.thicknessLayers_),
kappaLayers_(tppsf.kappaLayers_)
{}
@ -245,6 +250,12 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
const scalarField Tp(*this);
scalarField hp(patch().size(), 0.0);
scalarField Qr(Tp.size(), 0.0);
if (QrName_ != "none")
{
Qr = patch().lookupPatchField<volScalarField, scalar>(QrName_);
}
switch (mode_)
{
case fixedHeatFlux:
@ -281,15 +292,17 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
if (mode_ == fixedHeatFlux)
{
refGrad() = q_/kappa(Tp);
refGrad() = (q_ + Qr)/kappa(Tp);
refValue() = 0.0;
valueFraction() = 0.0;
}
else if (mode_ == fixedHeatTransferCoeff)
{
Qr /= Tp;
refGrad() = 0.0;
refValue() = Ta_;
valueFraction() = hp/(hp + kappa(Tp)*patch().deltaCoeffs());
refValue() = hp*Ta_/(hp - Qr);
valueFraction() =
(hp - Qr)/((hp - Qr) + kappa(Tp)*patch().deltaCoeffs());
}
mixedFvPatchScalarField::updateCoeffs();
@ -318,9 +331,11 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write
{
mixedFvPatchScalarField::write(os);
temperatureCoupledBase::write(os);
os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
switch (mode_)
{
case fixedHeatFlux:
{
q_.writeEntry("q", os);

View file

@ -60,6 +60,7 @@ Description
thicknessLayers | list of thicknesses per layer [m] | yes |
kappaLayers | list of thermal conductivites per layer [W/m/K] | yes |
kappaName | name of thermal conductivity field | yes |
QrName | name of the radiative field | no | no
\endtable
Example of the boundary condition specification:
@ -75,6 +76,7 @@ Description
kappaLayers (1 2 3 4)
value uniform 300.0;
kappaName none;
QrName none;
}
\endverbatim
@ -137,6 +139,9 @@ private:
//- Ambient temperature / [K]
scalarField Ta_;
//- Name of the radiative heat flux
const word QrName_;
//- Thickness of layers
scalarList thicknessLayers_;