Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
Henry
2010-12-20 16:38:13 +00:00
142 changed files with 2244 additions and 2294 deletions

View File

@ -184,6 +184,8 @@
+ =setSet=: allows time range (e.g. 0:100) in combination with -batch argument + =setSet=: allows time range (e.g. 0:100) in combination with -batch argument
to execute the commands for multiple times. to execute the commands for multiple times.
* Post-processing * Post-processing
+ =paraFoam=, =foamToVTK=: full support for polyhedral cell type in recent
Paraview versions.
+ =foamToEnsight=: parallel continuous data. new =-nodeValues= option to generate and output nodal + =foamToEnsight=: parallel continuous data. new =-nodeValues= option to generate and output nodal
field data. field data.
+ =singleCellMesh=: new utility to convert mesh and fields to a single cell + =singleCellMesh=: new utility to convert mesh and fields to a single cell

View File

@ -218,7 +218,7 @@ void Foam::kineticTheoryModel::solve(const volTensorField& gradUat)
// The solution is higly unstable close to the packing limit. // The solution is higly unstable close to the packing limit.
gs0_ = radialModel_->g0 gs0_ = radialModel_->g0
( (
min(max(alpha_, 1e-6), alphaMax_ - 0.01), min(max(alpha_, scalar(1e-6)), alphaMax_ - 0.01),
alphaMax_ alphaMax_
); );
@ -255,7 +255,7 @@ void Foam::kineticTheoryModel::solve(const volTensorField& gradUat)
volScalarField J1 = 3.0*betaPrim; volScalarField J1 = 3.0*betaPrim;
volScalarField J2 = volScalarField J2 =
0.25*sqr(betaPrim)*da_*sqr(Ur) 0.25*sqr(betaPrim)*da_*sqr(Ur)
/(max(alpha_, 1e-6)*rhoa_*sqrtPi*(ThetaSqrt + TsmallSqrt)); /(max(alpha_, scalar(1e-6))*rhoa_*sqrtPi*(ThetaSqrt + TsmallSqrt));
// bulk viscosity p. 45 (Lun et al. 1984). // bulk viscosity p. 45 (Lun et al. 1984).
lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0+e_)*ThetaSqrt/sqrtPi; lambda_ = (4.0/3.0)*sqr(alpha_)*rhoa_*da_*gs0_*(1.0+e_)*ThetaSqrt/sqrtPi;
@ -309,7 +309,11 @@ void Foam::kineticTheoryModel::solve(const volTensorField& gradUat)
volScalarField t1 = K1*alpha_ + rhoa_; volScalarField t1 = K1*alpha_ + rhoa_;
volScalarField l1 = -t1*trD; volScalarField l1 = -t1*trD;
volScalarField l2 = sqr(t1)*tr2D; volScalarField l2 = sqr(t1)*tr2D;
volScalarField l3 = 4.0*K4*max(alpha_, 1e-6)*(2.0*K3*trD2 + K2*tr2D); volScalarField l3 =
4.0
*K4
*max(alpha_, scalar(1e-6))
*(2.0*K3*trD2 + K2*tr2D);
Theta_ = sqr((l1 + sqrt(l2 + l3))/(2.0*(alpha_ + 1.0e-4)*K4)); Theta_ = sqr((l1 + sqrt(l2 + l3))/(2.0*(alpha_ + 1.0e-4)*K4));
} }

View File

@ -1,5 +1,6 @@
EXE_INC = \ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lmeshTools -lmeshTools

View File

@ -26,180 +26,38 @@ Application
Description Description
Calculates the inertia tensor and principal axes and moments of a Calculates the inertia tensor and principal axes and moments of a
test face and tetrahedron. test face, tetrahedron and mesh.
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "ListOps.H" #include "ListOps.H"
#include "face.H" #include "face.H"
#include "tetPointRef.H" #include "tetPointRef.H"
#include "triFaceList.H" #include "triFaceList.H"
#include "OFstream.H" #include "OFstream.H"
#include "meshTools.H" #include "meshTools.H"
#include "momentOfInertia.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam; using namespace Foam;
void massPropertiesSolid
(
const pointField& pts,
const triFaceList triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
// Reimplemented from: Wm4PolyhedralMassProperties.cpp
// File Version: 4.10.0 (2009/11/18)
// Geometric Tools, LC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Boost Software License - Version 1.0 - August 17th, 2003
// Permission is hereby granted, free of charge, to any person or
// organization obtaining a copy of the software and accompanying
// documentation covered by this license (the "Software") to use,
// reproduce, display, distribute, execute, and transmit the
// Software, and to prepare derivative works of the Software, and
// to permit third-parties to whom the Software is furnished to do
// so, all subject to the following:
// The copyright notices in the Software and this entire
// statement, including the above license grant, this restriction
// and the following disclaimer, must be included in all copies of
// the Software, in whole or in part, and all derivative works of
// the Software, unless such copies or derivative works are solely
// in the form of machine-executable object code generated by a
// source language processor.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
// NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
// ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
// OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
const scalar r6 = 1.0/6.0;
const scalar r24 = 1.0/24.0;
const scalar r60 = 1.0/60.0;
const scalar r120 = 1.0/120.0;
// order: 1, x, y, z, x^2, y^2, z^2, xy, yz, zx
scalarField integrals(10, 0.0);
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
// vertices of triangle i
vector v0 = pts[tri[0]];
vector v1 = pts[tri[1]];
vector v2 = pts[tri[2]];
// cross product of edges
vector eA = v1 - v0;
vector eB = v2 - v0;
vector n = eA ^ eB;
// compute integral terms
scalar tmp0, tmp1, tmp2;
scalar f1x, f2x, f3x, g0x, g1x, g2x;
tmp0 = v0.x() + v1.x();
f1x = tmp0 + v2.x();
tmp1 = v0.x()*v0.x();
tmp2 = tmp1 + v1.x()*tmp0;
f2x = tmp2 + v2.x()*f1x;
f3x = v0.x()*tmp1 + v1.x()*tmp2 + v2.x()*f2x;
g0x = f2x + v0.x()*(f1x + v0.x());
g1x = f2x + v1.x()*(f1x + v1.x());
g2x = f2x + v2.x()*(f1x + v2.x());
scalar f1y, f2y, f3y, g0y, g1y, g2y;
tmp0 = v0.y() + v1.y();
f1y = tmp0 + v2.y();
tmp1 = v0.y()*v0.y();
tmp2 = tmp1 + v1.y()*tmp0;
f2y = tmp2 + v2.y()*f1y;
f3y = v0.y()*tmp1 + v1.y()*tmp2 + v2.y()*f2y;
g0y = f2y + v0.y()*(f1y + v0.y());
g1y = f2y + v1.y()*(f1y + v1.y());
g2y = f2y + v2.y()*(f1y + v2.y());
scalar f1z, f2z, f3z, g0z, g1z, g2z;
tmp0 = v0.z() + v1.z();
f1z = tmp0 + v2.z();
tmp1 = v0.z()*v0.z();
tmp2 = tmp1 + v1.z()*tmp0;
f2z = tmp2 + v2.z()*f1z;
f3z = v0.z()*tmp1 + v1.z()*tmp2 + v2.z()*f2z;
g0z = f2z + v0.z()*(f1z + v0.z());
g1z = f2z + v1.z()*(f1z + v1.z());
g2z = f2z + v2.z()*(f1z + v2.z());
// update integrals
integrals[0] += n.x()*f1x;
integrals[1] += n.x()*f2x;
integrals[2] += n.y()*f2y;
integrals[3] += n.z()*f2z;
integrals[4] += n.x()*f3x;
integrals[5] += n.y()*f3y;
integrals[6] += n.z()*f3z;
integrals[7] += n.x()*(v0.y()*g0x + v1.y()*g1x + v2.y()*g2x);
integrals[8] += n.y()*(v0.z()*g0y + v1.z()*g1y + v2.z()*g2y);
integrals[9] += n.z()*(v0.x()*g0z + v1.x()*g1z + v2.x()*g2z);
}
integrals[0] *= r6;
integrals[1] *= r24;
integrals[2] *= r24;
integrals[3] *= r24;
integrals[4] *= r60;
integrals[5] *= r60;
integrals[6] *= r60;
integrals[7] *= r120;
integrals[8] *= r120;
integrals[9] *= r120;
// mass
mass = integrals[0];
// center of mass
cM = vector(integrals[1], integrals[2], integrals[3])/mass;
// inertia relative to origin
J.xx() = integrals[5] + integrals[6];
J.xy() = -integrals[7];
J.xz() = -integrals[9];
J.yx() = J.xy();
J.yy() = integrals[4] + integrals[6];
J.yz() = -integrals[8];
J.zx() = J.xz();
J.zy() = J.yz();
J.zz() = integrals[4] + integrals[5];
// inertia relative to center of mass
J -= mass*((cM & cM)*I - cM*cM);
// Apply density
mass *= density;
J *= density;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addOption
(
"cell",
"label",
"cell to use for inertia calculation, defaults to 0"
);
#include "setRootCase.H"
#include "createTime.H"
#include "createPolyMesh.H"
scalar density = 1.0; scalar density = 1.0;
{ {
@ -286,16 +144,7 @@ int main(int argc, char *argv[])
vector cM = vector::zero; vector cM = vector::zero;
tensor J = tensor::zero; tensor J = tensor::zero;
massPropertiesSolid momentOfInertia::massPropertiesSolid(pts, tetFaces, density, m, cM, J);
(
pts,
tetFaces,
density,
m,
cM,
J
);
vector eVal = eigenValues(J); vector eVal = eigenValues(J);
@ -344,7 +193,50 @@ int main(int argc, char *argv[])
{ {
str << "l " << nPts + 1 << ' ' << i + 1 << endl; str << "l " << nPts + 1 << ' ' << i + 1 << endl;
} }
}
{
const label cellI = args.optionLookupOrDefault("cell", 0);
tensorField mI = momentOfInertia::meshInertia(mesh);
tensor& J = mI[cellI];
vector eVal = eigenValues(J);
Info<< nl
<< "Inertia tensor of cell " << cellI << " " << J << nl
<< "eigenValues (principal moments) " << eVal << endl;
J /= cmptMax(eVal);
tensor eVec = eigenVectors(J);
Info<< "eigenVectors (principal axes, from normalised inertia) " << eVec
<< endl;
OFstream str("cell_" + name(cellI) + "_inertia.obj");
Info<< nl << "Writing scaled principal axes of cell " << cellI << " to "
<< str.name() << endl;
const point& cC = mesh.cellCentres()[cellI];
scalar scale = mag
(
(cC - mesh.faceCentres()[mesh.cells()[cellI][0]])
/eVal.component(findMin(eVal))
);
meshTools::writeOBJ(str, cC);
meshTools::writeOBJ(str, cC + scale*eVal.x()*eVec.x());
meshTools::writeOBJ(str, cC + scale*eVal.y()*eVec.y());
meshTools::writeOBJ(str, cC + scale*eVal.z()*eVec.z());
for (label i = 1; i < 4; i++)
{
str << "l " << 1 << ' ' << i + 1 << endl;
}
} }
Info<< nl << "End" << nl << endl; Info<< nl << "End" << nl << endl;

View File

@ -3,6 +3,7 @@ cd ${0%/*} || exit 1 # run from this directory
set -x set -x
wclean libso extrudeModel wclean libso extrudeModel
wclean wclean extrudeMesh
wclean extrudeToRegionMesh
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -3,6 +3,8 @@ cd ${0%/*} || exit 1 # run from this directory
set -x set -x
wmake libso extrudeModel wmake libso extrudeModel
wmake wmake extrudeMesh
wmake extrudeToRegionMesh
# ----------------------------------------------------------------- end-of-file # ----------------------------------------------------------------- end-of-file

View File

@ -1,6 +1,6 @@
EXE_INC = \ EXE_INC = \
-IextrudedMesh \ -IextrudedMesh \
-IextrudeModel/lnInclude \ -I../extrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \

View File

@ -214,9 +214,8 @@ int main(int argc, char *argv[])
( (
IOobject IOobject
( (
"extrudeProperties", "extrudeMeshDict",
runTimeExtruded.constant(), runTimeExtruded.system(),
regionDir,
runTimeExtruded, runTimeExtruded,
IOobject::MUST_READ_IF_MODIFIED IOobject::MUST_READ_IF_MODIFIED
) )

View File

@ -10,7 +10,7 @@ FoamFile
version 2.0; version 2.0;
format ascii; format ascii;
class dictionary; class dictionary;
object extrudeProperties; object extrudeMeshDict;
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -71,7 +71,7 @@ public:
//- Destructor //- Destructor
~linearDirection(); virtual ~linearDirection();
// Member Operators // Member Operators

View File

@ -68,7 +68,7 @@ public:
//- Destructor //- Destructor
~linearNormal(); virtual ~linearNormal();
// Member Operators // Member Operators

View File

@ -66,7 +66,7 @@ public:
//- Destructor //- Destructor
~linearRadial(); virtual ~linearRadial();
// Member Operators // Member Operators

View File

@ -67,7 +67,7 @@ public:
//-Destructor //-Destructor
~sigmaRadial(); virtual ~sigmaRadial();
// Member Operators // Member Operators

View File

@ -80,8 +80,8 @@ public:
wedge(const dictionary& dict); wedge(const dictionary& dict);
//- Destrcuctor //- Destructor
~wedge(); virtual ~wedge();
// Member Operators // Member Operators

View File

@ -1,9 +1,11 @@
EXE_INC = \ EXE_INC = \
-I../extrudeModel/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude -I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lextrudeModel \
-lfiniteVolume \ -lfiniteVolume \
-lmeshTools \ -lmeshTools \
-ldynamicMesh -ldynamicMesh

View File

@ -93,7 +93,7 @@ void Foam::createShellMesh::calcPointRegions
label fp2 = findIndex(f2, pointI); label fp2 = findIndex(f2, pointI);
label& region = pointRegions[face2][fp2]; label& region = pointRegions[face2][fp2];
if (region != -1) if (region != -1)
{ {
FatalErrorIn FatalErrorIn
( (
"createShellMesh::calcPointRegions(..)" "createShellMesh::calcPointRegions(..)"
@ -185,18 +185,20 @@ Foam::createShellMesh::createShellMesh
void Foam::createShellMesh::setRefinement void Foam::createShellMesh::setRefinement
( (
const pointField& thickness, const pointField& firstLayerDisp,
const scalar expansionRatio,
const label nLayers,
const labelList& topPatchID, const labelList& topPatchID,
const labelList& bottomPatchID, const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches, const labelListList& extrudeEdgePatches,
polyTopoChange& meshMod polyTopoChange& meshMod
) )
{ {
if (thickness.size() != regionPoints_.size()) if (firstLayerDisp.size() != regionPoints_.size())
{ {
FatalErrorIn("createShellMesh::setRefinement(..)") FatalErrorIn("createShellMesh::setRefinement(..)")
<< "nRegions:" << regionPoints_.size() << "nRegions:" << regionPoints_.size()
<< " thickness:" << thickness.size() << " firstLayerDisp:" << firstLayerDisp.size()
<< exit(FatalError); << exit(FatalError);
} }
@ -224,30 +226,36 @@ void Foam::createShellMesh::setRefinement
// From cell to patch (trivial) // From cell to patch (trivial)
DynamicList<label> cellToFaceMap(patch_.size()); DynamicList<label> cellToFaceMap(nLayers*patch_.size());
// From face to patch+turning index // From face to patch+turning index
DynamicList<label> faceToFaceMap(2*patch_.size()+patch_.nEdges()); DynamicList<label> faceToFaceMap
(
(nLayers+1)*(patch_.size()+patch_.nEdges())
);
// From face to patch edge index // From face to patch edge index
DynamicList<label> faceToEdgeMap(patch_.nEdges()+patch_.nEdges()); DynamicList<label> faceToEdgeMap(nLayers*(patch_.nEdges()+patch_.nEdges()));
// From point to patch point index // From point to patch point index
DynamicList<label> pointToPointMap(2*patch_.nPoints()); DynamicList<label> pointToPointMap((nLayers+1)*patch_.nPoints());
// Introduce new cell for every face // Introduce new cell for every face
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelList addedCells(patch_.size()); labelList addedCells(nLayers*patch_.size());
forAll(patch_, faceI) forAll(patch_, faceI)
{ {
addedCells[faceI] = meshMod.addCell for (label layerI = 0; layerI < nLayers; layerI++)
( {
-1, // masterPointID addedCells[nLayers*faceI+layerI] = meshMod.addCell
-1, // masterEdgeID (
-1, // masterFaceID -1, // masterPointID
cellToFaceMap.size(), // masterCellID -1, // masterEdgeID
-1 // zoneID -1, // masterFaceID
); cellToFaceMap.size(), // masterCellID
cellToFaceMap.append(faceI); -1 // zoneID
);
cellToFaceMap.append(faceI);
}
} }
@ -261,7 +269,7 @@ void Foam::createShellMesh::setRefinement
meshMod.addPoint meshMod.addPoint
( (
patch_.localPoints()[pointI], // point patch_.localPoints()[pointI], // point
pointToPointMap.size(), // masterPointID pointToPointMap.size(), // masterPointID
-1, // zoneID -1, // zoneID
true // inCell true // inCell
); );
@ -277,25 +285,28 @@ void Foam::createShellMesh::setRefinement
// Introduce new points (one for every region) // Introduce new points (one for every region)
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
labelList addedPoints(regionPoints_.size()); labelList addedPoints(nLayers*regionPoints_.size());
forAll(regionPoints_, regionI) forAll(regionPoints_, regionI)
{ {
label pointI = regionPoints_[regionI]; label pointI = regionPoints_[regionI];
point extrudedPt = patch_.localPoints()[pointI] + thickness[regionI];
addedPoints[regionI] = meshMod.addPoint point pt = patch_.localPoints()[pointI];
( point disp = firstLayerDisp[regionI];
extrudedPt, // point for (label layerI = 0; layerI < nLayers; layerI++)
pointToPointMap.size(), // masterPointID - used only addressing {
-1, // zoneID pt += disp;
true // inCell
);
pointToPointMap.append(pointI);
//Pout<< "Added top point " << addedPoints[regionI] addedPoints[nLayers*regionI+layerI] = meshMod.addPoint
// << " at " << extrudedPt (
// << " from point " << pointI pt, // point
// << endl; pointToPointMap.size(), // masterPointID - used only addressing
-1, // zoneID
true // inCell
);
pointToPointMap.append(pointI);
disp *= expansionRatio;
}
} }
@ -305,61 +316,84 @@ void Foam::createShellMesh::setRefinement
meshMod.addFace meshMod.addFace
( (
patch_.localFaces()[faceI].reverseFace(),// vertices patch_.localFaces()[faceI].reverseFace(),// vertices
addedCells[faceI], // own addedCells[nLayers*faceI], // own
-1, // nei -1, // nei
-1, // masterPointID -1, // masterPointID
-1, // masterEdgeID -1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI faceToFaceMap.size(), // masterFaceID : current faceI
true, // flipFaceFlux true, // flipFaceFlux
bottomPatchID[faceI],// patchID bottomPatchID[faceI], // patchID
-1, // zoneID -1, // zoneID
false // zoneFlip false // zoneFlip
); );
faceToFaceMap.append(-faceI-1); // points to flipped original face faceToFaceMap.append(-faceI-1); // points to flipped original face
faceToEdgeMap.append(-1); faceToEdgeMap.append(-1);
//const face newF(patch_.localFaces()[faceI].reverseFace());
//Pout<< "Added bottom face " //Pout<< "Added bottom face "
// << patch_.localFaces()[faceI].reverseFace() // << newF
// << " coords:" << UIndirectList<point>(meshMod.points(), newF)
// << " own " << addedCells[faceI] // << " own " << addedCells[faceI]
// << " patch:" << bottomPatchID[faceI]
// << " at " << patch_.faceCentres()[faceI] // << " at " << patch_.faceCentres()[faceI]
// << endl; // << endl;
} }
// Add face on top // Add inbetween faces and face on top
forAll(patch_.localFaces(), faceI) forAll(patch_.localFaces(), faceI)
{ {
// Get face in original ordering // Get face in original ordering
const face& f = patch_.localFaces()[faceI]; const face& f = patch_.localFaces()[faceI];
// Pick up point based on region
face newF(f.size()); face newF(f.size());
forAll(f, fp)
for (label layerI = 0; layerI < nLayers; layerI++)
{ {
label region = pointRegions_[faceI][fp]; // Pick up point based on region and layer
newF[fp] = addedPoints[region]; forAll(f, fp)
{
label region = pointRegions_[faceI][fp];
newF[fp] = addedPoints[region*nLayers+layerI];
}
label own = addedCells[faceI*nLayers+layerI];
label nei;
label patchI;
if (layerI == nLayers-1)
{
nei = -1;
patchI = topPatchID[faceI];
}
else
{
nei = addedCells[faceI*nLayers+layerI+1];
patchI = -1;
}
meshMod.addFace
(
newF, // vertices
own, // own
nei, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI
false, // flipFaceFlux
patchI, // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(faceI+1); // unflipped
faceToEdgeMap.append(-1);
//Pout<< "Added inbetween face " << newF
// << " coords:" << UIndirectList<point>(meshMod.points(), newF)
// << " at layer " << layerI
// << " own " << own
// << " nei " << nei
// << " at " << patch_.faceCentres()[faceI]
// << endl;
} }
meshMod.addFace
(
newF, // vertices
addedCells[faceI], // own
-1, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID : current faceI
false, // flipFaceFlux
topPatchID[faceI], // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(faceI+1); // unflipped
faceToEdgeMap.append(-1);
//Pout<< "Added top face " << newF
// << " own " << addedCells[faceI]
// << " at " << patch_.faceCentres()[faceI]
// << endl;
} }
@ -376,8 +410,7 @@ void Foam::createShellMesh::setRefinement
if (ePatches.size() == 0) if (ePatches.size() == 0)
{ {
// internal face. // Internal face
if (eFaces.size() != 2) if (eFaces.size() != 2)
{ {
FatalErrorIn("createShellMesh::setRefinement(..)") FatalErrorIn("createShellMesh::setRefinement(..)")
@ -385,61 +418,6 @@ void Foam::createShellMesh::setRefinement
<< " not internal but does not have side-patches defined." << " not internal but does not have side-patches defined."
<< exit(FatalError); << exit(FatalError);
} }
// Extrude
// Make face pointing in to eFaces[0] so out of new master face
const face& f = patch_.localFaces()[eFaces[0]];
const edge& e = patch_.edges()[edgeI];
label fp0 = findIndex(f, e[0]);
label fp1 = f.fcIndex(fp0);
if (f[fp1] != e[1])
{
fp1 = fp0;
fp0 = f.rcIndex(fp1);
}
face newF(4);
newF[0] = f[fp0];
newF[1] = f[fp1];
newF[2] = addedPoints[pointRegions_[eFaces[0]][fp1]];
newF[3] = addedPoints[pointRegions_[eFaces[0]][fp0]];
label minCellI = addedCells[eFaces[0]];
label maxCellI = addedCells[eFaces[1]];
if (minCellI > maxCellI)
{
// Swap
Swap(minCellI, maxCellI);
newF = newF.reverseFace();
}
//Pout<< "for internal edge:" << e
// << " at:" << patch_.localPoints()[e[0]]
// << patch_.localPoints()[e[1]]
// << " adding face:" << newF
// << " from f:" << f
// << " inbetween " << minCellI << " and " << maxCellI << endl;
// newF already outwards pointing.
meshMod.addFace
(
newF, // vertices
minCellI, // own
maxCellI, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID
false, // flipFaceFlux
-1, // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(0);
faceToEdgeMap.append(edgeI);
} }
else else
{ {
@ -451,52 +429,91 @@ void Foam::createShellMesh::setRefinement
<< " but only " << ePatches.size() << " but only " << ePatches.size()
<< " boundary faces defined." << exit(FatalError); << " boundary faces defined." << exit(FatalError);
} }
}
// Extrude eFaces[0]
label minFaceI = eFaces[0];
// Make face pointing in to eFaces[0] so out of new master face // Make face pointing in to eFaces[0] so out of new master face
const face& f = patch_.localFaces()[minFaceI]; const face& f = patch_.localFaces()[eFaces[0]];
const edge& e = patch_.edges()[edgeI];
const edge& e = patch_.edges()[edgeI]; label fp0 = findIndex(f, e[0]);
label fp0 = findIndex(f, e[0]); label fp1 = f.fcIndex(fp0);
label fp1 = f.fcIndex(fp0);
if (f[fp1] != e[1]) if (f[fp1] != e[1])
{
fp1 = fp0;
fp0 = f.rcIndex(fp1);
}
face newF(4);
for (label layerI = 0; layerI < nLayers; layerI++)
{
label region0 = pointRegions_[eFaces[0]][fp0];
label region1 = pointRegions_[eFaces[0]][fp1];
if (layerI == 0)
{ {
fp1 = fp0; newF[0] = f[fp0];
fp0 = f.rcIndex(fp1); newF[1] = f[fp1];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
else
{
newF[0] = addedPoints[nLayers*region0+layerI-1];
newF[1] = addedPoints[nLayers*region1+layerI-1];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
} }
face newF(4); label minCellI = addedCells[nLayers*eFaces[0]+layerI];
newF[0] = f[fp0]; label maxCellI;
newF[1] = f[fp1]; label patchI;
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]]; if (ePatches.size() == 0)
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]]; {
maxCellI = addedCells[nLayers*eFaces[1]+layerI];
if (minCellI > maxCellI)
{
// Swap
Swap(minCellI, maxCellI);
newF = newF.reverseFace();
}
patchI = -1;
}
else
{
maxCellI = -1;
patchI = ePatches[0];
}
//{
//Pout<< "for external edge:" << e // Pout<< "Adding from face:" << patch_.faceCentres()[eFaces[0]]
// << " at:" << patch_.localPoints()[e[0]] // << " from edge:"
// << patch_.localPoints()[e[1]] // << patch_.localPoints()[f[fp0]]
// << " adding first patch face:" << newF // << patch_.localPoints()[f[fp1]]
// << " from:" << f // << " at layer:" << layerI
// << " into patch:" << ePatches[0] // << " with new points:" << newF
// << " own:" << addedCells[minFaceI] // << " locations:"
// << endl; // << UIndirectList<point>(meshMod.points(), newF)
// << " own:" << minCellI
// << " nei:" << maxCellI
// << endl;
//}
// newF already outwards pointing. // newF already outwards pointing.
meshMod.addFace meshMod.addFace
( (
newF, // vertices newF, // vertices
addedCells[minFaceI], // own minCellI, // own
-1, // nei maxCellI, // nei
-1, // masterPointID -1, // masterPointID
-1, // masterEdgeID -1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID faceToFaceMap.size(), // masterFaceID
false, // flipFaceFlux false, // flipFaceFlux
ePatches[0], // patchID patchI, // patchID
-1, // zoneID -1, // zoneID
false // zoneFlip false // zoneFlip
); );
@ -532,35 +549,57 @@ void Foam::createShellMesh::setRefinement
} }
face newF(4); face newF(4);
newF[0] = f[fp0]; for (label layerI = 0; layerI < nLayers; layerI++)
newF[1] = f[fp1]; {
newF[2] = addedPoints[pointRegions_[minFaceI][fp1]]; label region0 = pointRegions_[minFaceI][fp0];
newF[3] = addedPoints[pointRegions_[minFaceI][fp0]]; label region1 = pointRegions_[minFaceI][fp1];
//Pout<< "for external edge:" << e if (layerI == 0)
// << " at:" << patch_.localPoints()[e[0]] {
// << patch_.localPoints()[e[1]] newF[0] = f[fp0];
// << " adding patch face:" << newF newF[1] = f[fp1];
// << " from:" << f newF[2] = addedPoints[nLayers*region1+layerI];
// << " into patch:" << ePatches[i] newF[3] = addedPoints[nLayers*region0+layerI];
// << endl; }
else
{
newF[0] = addedPoints[nLayers*region0+layerI-1];
newF[1] = addedPoints[nLayers*region1+layerI-1];
newF[2] = addedPoints[nLayers*region1+layerI];
newF[3] = addedPoints[nLayers*region0+layerI];
}
// newF already outwards pointing. ////if (ePatches.size() == 0)
meshMod.addFace //{
( // Pout<< "Adding from MULTI face:"
newF, // vertices // << patch_.faceCentres()[minFaceI]
addedCells[minFaceI], // own // << " from edge:"
-1, // nei // << patch_.localPoints()[f[fp0]]
-1, // masterPointID // << patch_.localPoints()[f[fp1]]
-1, // masterEdgeID // << " at layer:" << layerI
faceToFaceMap.size(), // masterFaceID // << " with new points:" << newF
false, // flipFaceFlux // << " locations:"
ePatches[i], // patchID // << UIndirectList<point>(meshMod.points(), newF)
-1, // zoneID // << endl;
false // zoneFlip //}
);
faceToFaceMap.append(0); // newF already outwards pointing.
faceToEdgeMap.append(edgeI); meshMod.addFace
(
newF, // vertices
addedCells[nLayers*minFaceI+layerI], // own
-1, // nei
-1, // masterPointID
-1, // masterEdgeID
faceToFaceMap.size(), // masterFaceID
false, // flipFaceFlux
ePatches[i], // patchID
-1, // zoneID
false // zoneFlip
);
faceToFaceMap.append(0);
faceToEdgeMap.append(edgeI);
}
} }
} }
} }

View File

@ -109,7 +109,8 @@ public:
// Access // Access
//- From region cell to patch face //- From region cell to patch face. Consecutively added so
// cell at layerI is at patchFaceI*nLayers+layerI
const labelList& cellToFaceMap() const const labelList& cellToFaceMap() const
{ {
return cellToFaceMap_; return cellToFaceMap_;
@ -120,7 +121,7 @@ public:
// be in top patch // be in top patch
// < 0 : face in opposite orientation as patch face. face will // < 0 : face in opposite orientation as patch face. face will
// be in bottom patch // be in bottom patch
// = 0 : for all side faces // = 0 : for all side and internal faces
const labelList& faceToFaceMap() const const labelList& faceToFaceMap() const
{ {
return faceToFaceMap_; return faceToFaceMap_;
@ -153,7 +154,9 @@ public:
//- Play commands into polyTopoChange to create layer mesh. //- Play commands into polyTopoChange to create layer mesh.
void setRefinement void setRefinement
( (
const pointField& thickness, const pointField& firstLayerThickness,
const scalar expansionRatio,
const label nLayers,
const labelList& topPatchID, const labelList& topPatchID,
const labelList& bottomPatchID, const labelList& bottomPatchID,
const labelListList& extrudeEdgePatches, const labelListList& extrudeEdgePatches,

View File

@ -133,6 +133,7 @@ Usage
#include "syncTools.H" #include "syncTools.H"
#include "cyclicPolyPatch.H" #include "cyclicPolyPatch.H"
#include "nonuniformTransformCyclicPolyPatch.H" #include "nonuniformTransformCyclicPolyPatch.H"
#include "extrudeModel.H"
using namespace Foam; using namespace Foam;
@ -689,39 +690,6 @@ void countExtrudePatches
} }
// Lexical ordering for vectors.
bool lessThan(const point& x, const point& y)
{
for (direction dir = 0; dir < point::nComponents; dir++)
{
if (x[dir] < y[dir]) return true;
if (x[dir] > y[dir]) return false;
}
return false;
}
// Combine vectors
class minEqVectorOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (y != vector::zero)
{
if (x == vector::zero)
{
x = y;
}
else if (lessThan(y, x))
{
x = y;
}
}
}
};
// Constrain&sync normals on points that are on coupled patches to make sure // Constrain&sync normals on points that are on coupled patches to make sure
// the face extruded from the edge has a valid normal with its coupled // the face extruded from the edge has a valid normal with its coupled
// equivalent. // equivalent.
@ -846,14 +814,14 @@ void constrainCoupledNormals
( (
mesh, mesh,
edgeNormals0, edgeNormals0,
minEqVectorOp(), maxMagSqrEqOp<vector>(),
vector::zero // nullValue vector::zero // nullValue
); );
syncTools::syncEdgeList syncTools::syncEdgeList
( (
mesh, mesh,
edgeNormals1, edgeNormals1,
minEqVectorOp(), maxMagSqrEqOp<vector>(),
vector::zero // nullValue vector::zero // nullValue
); );
@ -951,14 +919,9 @@ tmp<pointField> calcOffset
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::noParallel(); argList::noParallel();
argList::validArgs.append("shellRegion"); argList::addNote
argList::validArgs.append("faceZones");
argList::validArgs.append("thickness");
Foam::argList::addBoolOption
( (
"oneD", "Create region mesh by extruding a faceZone"
"generate columns of 1D cells"
); );
#include "addRegionOption.H" #include "addRegionOption.H"
@ -966,19 +929,34 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "createNamedMesh.H" #include "createNamedMesh.H"
const word oldInstance = mesh.pointsInstance();
word shellRegionName = args.additionalArgs()[0]; const word oldInstance = mesh.pointsInstance();
const wordList zoneNames(IStringStream(args.additionalArgs()[1])());
scalar thickness = readScalar(IStringStream(args.additionalArgs()[2])());
bool overwrite = args.optionFound("overwrite"); bool overwrite = args.optionFound("overwrite");
bool oneD = args.optionFound("oneD");
IOdictionary dict
(
IOobject
(
"extrudeToRegionMeshDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED
)
);
// Point generator
autoPtr<extrudeModel> model(extrudeModel::New(dict));
// Region
const word shellRegionName(dict.lookup("region"));
const wordList zoneNames(dict.lookup("faceZones"));
const Switch oneD(dict.lookup("oneD"));
Info<< "Extruding zones " << zoneNames Info<< "Extruding zones " << zoneNames
<< " on mesh " << regionName << " on mesh " << regionName
<< " into shell mesh " << shellRegionName << " into shell mesh " << shellRegionName
<< " of thickness " << thickness << nl
<< endl; << endl;
if (shellRegionName == regionName) if (shellRegionName == regionName)
@ -1081,7 +1059,6 @@ int main(int argc, char *argv[])
); );
// Check whether the zone is internal or external faces to determine // Check whether the zone is internal or external faces to determine
// what patch type to insert. Cannot be mixed // what patch type to insert. Cannot be mixed
// since then how to couple? - directMapped only valid for a whole patch. // since then how to couple? - directMapped only valid for a whole patch.
@ -1437,6 +1414,8 @@ int main(int argc, char *argv[])
// Calculate a normal per region // Calculate a normal per region
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vectorField regionNormals(regionPoints.size(), vector::zero); vectorField regionNormals(regionPoints.size(), vector::zero);
vectorField regionCentres(regionPoints.size(), vector::zero);
labelList nRegionFaces(regionPoints.size(), 0);
forAll(pointRegions, faceI) forAll(pointRegions, faceI)
{ {
@ -1446,9 +1425,15 @@ int main(int argc, char *argv[])
{ {
label region = pointRegions[faceI][fp]; label region = pointRegions[faceI][fp];
regionNormals[region] += extrudePatch.faceNormals()[faceI]; regionNormals[region] += extrudePatch.faceNormals()[faceI];
regionCentres[region] += extrudePatch.faceCentres()[faceI];
nRegionFaces[region]++;
} }
} }
regionNormals /= mag(regionNormals); regionNormals /= mag(regionNormals);
forAll(regionCentres, regionI)
{
regionCentres[regionI] /= nRegionFaces[regionI];
}
// Constrain&sync normals on points that are on coupled patches. // Constrain&sync normals on points that are on coupled patches.
@ -1463,10 +1448,13 @@ int main(int argc, char *argv[])
); );
// For debugging: dump hedgehog plot of normals // For debugging: dump hedgehog plot of normals
if (false)
{ {
OFstream str(runTime.path()/"regionNormals.obj"); OFstream str(runTime.path()/"regionNormals.obj");
label vertI = 0; label vertI = 0;
scalar thickness = model().sumThickness(1);
forAll(pointRegions, faceI) forAll(pointRegions, faceI)
{ {
const face& f = extrudeFaces[faceI]; const face& f = extrudeFaces[faceI];
@ -1486,6 +1474,16 @@ int main(int argc, char *argv[])
} }
// Use model to create displacements of first layer
vectorField firstDisp(regionNormals.size());
forAll(firstDisp, regionI)
{
const point& regionPt = regionCentres[regionI];
const vector& n = regionNormals[regionI];
firstDisp[regionI] = model()(regionPt, n, 1) - regionPt;
}
// Create a new mesh // Create a new mesh
// ~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~
@ -1500,7 +1498,9 @@ int main(int argc, char *argv[])
extruder.setRefinement extruder.setRefinement
( (
thickness*regionNormals, firstDisp, // first displacement
model().expansionRatio(),
model().nLayers(), // nLayers
extrudeTopPatchID, extrudeTopPatchID,
extrudeBottomPatchID, extrudeBottomPatchID,
extrudeEdgePatches, extrudeEdgePatches,

View File

@ -0,0 +1,78 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object extrudeToRegionMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Name of region to create
region liquidFilm;
// faceZones to extrude
faceZones (f0);
// Extrude 1D-columns of cells?
oneD false;
//- Extrusion model to use. The only logical choice is linearNormal?
//- Linear extrusion in normal direction
extrudeModel linearNormal;
//- Linear extrusion in specified direction
//extrudeModel linearDirection;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
// extrudeModel wedge;
//- Extrudes into sphere around (0 0 0)
//extrudeModel linearRadial;
//- Extrudes into sphere with grading according to pressure (atmospherics)
//extrudeModel sigmaRadial;
nLayers 10;
expansionRatio 0.9;
linearNormalCoeffs
{
thickness 0.05;
}
wedgeCoeffs
{
axisPt (0 0.1 -0.05);
axis (-1 0 0);
angle 360; // For nLayers=1 assume symmetry so angle/2 on each side
}
linearDirectionCoeffs
{
direction (0 1 0);
thickness 0.05;
}
linearRadialCoeffs
{
R 0.1;
}
sigmaRadialCoeffs
{
RTbyg 1;
pRef 1;
pStrat 1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -55,23 +55,6 @@ namespace Foam
defineTemplateTypeNameAndDebug(IOPtrList<dictionary>, 0); defineTemplateTypeNameAndDebug(IOPtrList<dictionary>, 0);
} }
// Combine operator to synchronise points. We choose point nearest to origin so
// we can use e.g. great,great,great as null value.
class nearestEqOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (magSqr(y) < magSqr(x))
{
x = y;
}
}
};
void changePatchID void changePatchID
( (
const polyMesh& mesh, const polyMesh& mesh,
@ -854,7 +837,7 @@ int main(int argc, char *argv[])
( (
mesh, mesh,
newPoints, newPoints,
nearestEqOp(), minMagSqrEqOp<vector>(),
point(GREAT, GREAT, GREAT) point(GREAT, GREAT, GREAT)
); );

View File

@ -561,10 +561,6 @@ int main(int argc, char *argv[])
mkDir(args.path()); mkDir(args.path());
} }
// Switch timeStamp checking to one which does not do any
// parallel sync for same reason
regIOobject::fileModificationChecking = regIOobject::timeStamp;
# include "createTime.H" # include "createTime.H"

View File

@ -36,12 +36,12 @@ using namespace Foam;
template<class Type> template<class Type>
void ensightCloudField void ensightCloudField
( (
const Foam::IOobject& fieldObject, const IOobject& fieldObject,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const Foam::word& cloudName, const word& cloudName,
Foam::Ostream& ensightCaseFile, Ostream& ensightCaseFile,
const bool dataExists const bool dataExists
) )
{ {

View File

@ -42,13 +42,13 @@ SourceFiles
template<class Type> template<class Type>
void ensightCloudField void ensightCloudField
( (
const Foam::IOobject& fieldObject, const IOobject& fieldObject,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const Foam::word& timeFile, const word& timeFile,
const Foam::word& cloudName, const word& cloudName,
Foam::Ostream& ensightCaseFile, Ostream& ensightCaseFile,
const bool dataExists const bool dataExists
); );

View File

@ -105,11 +105,11 @@ void writeField
template<class Type> template<class Type>
bool writePatchField bool writePatchField
( (
const Foam::Field<Type>& pf, const Field<Type>& pf,
const Foam::label patchi, const label patchi,
const Foam::label ensightPatchI, const label ensightPatchI,
const Foam::faceSets& boundaryFaceSet, const faceSets& boundaryFaceSet,
const Foam::ensightMesh::nFacePrimitives& nfp, const ensightMesh::nFacePrimitives& nfp,
ensightStream& ensightFile ensightStream& ensightFile
) )
{ {
@ -153,15 +153,15 @@ bool writePatchField
template<class Type> template<class Type>
void writePatchField void writePatchField
( (
const Foam::word& fieldName, const word& fieldName,
const Foam::Field<Type>& pf, const Field<Type>& pf,
const Foam::word& patchName, const word& patchName,
const Foam::ensightMesh& eMesh, const ensightMesh& eMesh,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const bool binary, const bool binary,
Foam::Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
const Time& runTime = eMesh.mesh().time(); const Time& runTime = eMesh.mesh().time();
@ -271,12 +271,12 @@ template<class Type>
void ensightField void ensightField
( (
const GeometricField<Type, fvPatchField, volMesh>& vf, const GeometricField<Type, fvPatchField, volMesh>& vf,
const Foam::ensightMesh& eMesh, const ensightMesh& eMesh,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const bool binary, const bool binary,
Foam::Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
Info<< "Converting field " << vf.name() << endl; Info<< "Converting field " << vf.name() << endl;
@ -500,12 +500,12 @@ template<class Type>
void ensightPointField void ensightPointField
( (
const GeometricField<Type, pointPatchField, pointMesh>& pf, const GeometricField<Type, pointPatchField, pointMesh>& pf,
const Foam::ensightMesh& eMesh, const ensightMesh& eMesh,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const bool binary, const bool binary,
Foam::Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
Info<< "Converting field " << pf.name() << endl; Info<< "Converting field " << pf.name() << endl;
@ -679,14 +679,14 @@ void ensightPointField
template<class Type> template<class Type>
void ensightField void ensightField
( (
const Foam::IOobject& fieldObject, const IOobject& fieldObject,
const Foam::ensightMesh& eMesh, const ensightMesh& eMesh,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& prepend, const word& prepend,
const Foam::label timeIndex, const label timeIndex,
const bool binary, const bool binary,
const bool nodeValues, const bool nodeValues,
Foam::Ostream& ensightCaseFile Ostream& ensightCaseFile
) )
{ {
// Read field // Read field

View File

@ -37,10 +37,10 @@ using namespace Foam;
void ensightParticlePositions void ensightParticlePositions
( (
const Foam::fvMesh& mesh, const fvMesh& mesh,
const Foam::fileName& postProcPath, const fileName& postProcPath,
const Foam::word& timeFile, const word& timeFile,
const Foam::word& cloudName, const word& cloudName,
const bool dataExists const bool dataExists
) )
{ {

View File

@ -212,7 +212,7 @@ int main(int argc, char *argv[])
// write bounding box corners // write bounding box corners
if (args.optionFound("blockMesh")) if (args.optionFound("blockMesh"))
{ {
pointField cornerPts = boundBox(surf.points()).corners(); pointField cornerPts = boundBox(surf.points()).points();
Info<<"// blockMeshDict info" << nl; Info<<"// blockMeshDict info" << nl;

View File

@ -33,9 +33,6 @@ Description
#include "argList.H" #include "argList.H"
#include "ListOps.H" #include "ListOps.H"
#include "face.H"
#include "tetPointRef.H"
#include "triFaceList.H"
#include "triSurface.H" #include "triSurface.H"
#include "OFstream.H" #include "OFstream.H"
#include "meshTools.H" #include "meshTools.H"
@ -43,242 +40,12 @@ Description
#include "transform.H" #include "transform.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "Pair.H" #include "Pair.H"
#include "momentOfInertia.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
using namespace Foam; using namespace Foam;
void massPropertiesSolid
(
const pointField& pts,
const triFaceList& triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
// Reimplemented from: Wm4PolyhedralMassProperties.cpp
// File Version: 4.10.0 (2009/11/18)
// Geometric Tools, LC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Boost Software License - Version 1.0 - August 17th, 2003
// Permission is hereby granted, free of charge, to any person or
// organization obtaining a copy of the software and accompanying
// documentation covered by this license (the "Software") to use,
// reproduce, display, distribute, execute, and transmit the
// Software, and to prepare derivative works of the Software, and
// to permit third-parties to whom the Software is furnished to do
// so, all subject to the following:
// The copyright notices in the Software and this entire
// statement, including the above license grant, this restriction
// and the following disclaimer, must be included in all copies of
// the Software, in whole or in part, and all derivative works of
// the Software, unless such copies or derivative works are solely
// in the form of machine-executable object code generated by a
// source language processor.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
// NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
// ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
// OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
const scalar r6 = 1.0/6.0;
const scalar r24 = 1.0/24.0;
const scalar r60 = 1.0/60.0;
const scalar r120 = 1.0/120.0;
// order: 1, x, y, z, x^2, y^2, z^2, xy, yz, zx
scalarField integrals(10, 0.0);
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
// vertices of triangle i
vector v0 = pts[tri[0]];
vector v1 = pts[tri[1]];
vector v2 = pts[tri[2]];
// cross product of edges
vector eA = v1 - v0;
vector eB = v2 - v0;
vector n = eA ^ eB;
// compute integral terms
scalar tmp0, tmp1, tmp2;
scalar f1x, f2x, f3x, g0x, g1x, g2x;
tmp0 = v0.x() + v1.x();
f1x = tmp0 + v2.x();
tmp1 = v0.x()*v0.x();
tmp2 = tmp1 + v1.x()*tmp0;
f2x = tmp2 + v2.x()*f1x;
f3x = v0.x()*tmp1 + v1.x()*tmp2 + v2.x()*f2x;
g0x = f2x + v0.x()*(f1x + v0.x());
g1x = f2x + v1.x()*(f1x + v1.x());
g2x = f2x + v2.x()*(f1x + v2.x());
scalar f1y, f2y, f3y, g0y, g1y, g2y;
tmp0 = v0.y() + v1.y();
f1y = tmp0 + v2.y();
tmp1 = v0.y()*v0.y();
tmp2 = tmp1 + v1.y()*tmp0;
f2y = tmp2 + v2.y()*f1y;
f3y = v0.y()*tmp1 + v1.y()*tmp2 + v2.y()*f2y;
g0y = f2y + v0.y()*(f1y + v0.y());
g1y = f2y + v1.y()*(f1y + v1.y());
g2y = f2y + v2.y()*(f1y + v2.y());
scalar f1z, f2z, f3z, g0z, g1z, g2z;
tmp0 = v0.z() + v1.z();
f1z = tmp0 + v2.z();
tmp1 = v0.z()*v0.z();
tmp2 = tmp1 + v1.z()*tmp0;
f2z = tmp2 + v2.z()*f1z;
f3z = v0.z()*tmp1 + v1.z()*tmp2 + v2.z()*f2z;
g0z = f2z + v0.z()*(f1z + v0.z());
g1z = f2z + v1.z()*(f1z + v1.z());
g2z = f2z + v2.z()*(f1z + v2.z());
// update integrals
integrals[0] += n.x()*f1x;
integrals[1] += n.x()*f2x;
integrals[2] += n.y()*f2y;
integrals[3] += n.z()*f2z;
integrals[4] += n.x()*f3x;
integrals[5] += n.y()*f3y;
integrals[6] += n.z()*f3z;
integrals[7] += n.x()*(v0.y()*g0x + v1.y()*g1x + v2.y()*g2x);
integrals[8] += n.y()*(v0.z()*g0y + v1.z()*g1y + v2.z()*g2y);
integrals[9] += n.z()*(v0.x()*g0z + v1.x()*g1z + v2.x()*g2z);
}
integrals[0] *= r6;
integrals[1] *= r24;
integrals[2] *= r24;
integrals[3] *= r24;
integrals[4] *= r60;
integrals[5] *= r60;
integrals[6] *= r60;
integrals[7] *= r120;
integrals[8] *= r120;
integrals[9] *= r120;
// mass
mass = integrals[0];
// center of mass
cM = vector(integrals[1], integrals[2], integrals[3])/mass;
// inertia relative to origin
J.xx() = integrals[5] + integrals[6];
J.xy() = -integrals[7];
J.xz() = -integrals[9];
J.yx() = J.xy();
J.yy() = integrals[4] + integrals[6];
J.yz() = -integrals[8];
J.zx() = J.xz();
J.zy() = J.yz();
J.zz() = integrals[4] + integrals[5];
// inertia relative to center of mass
J -= mass*((cM & cM)*I - cM*cM);
// Apply density
mass *= density;
J *= density;
}
void massPropertiesShell
(
const pointField& pts,
const triFaceList& triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
// Reset properties for accumulation
mass = 0.0;
cM = vector::zero;
J = tensor::zero;
// Find centre of mass
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
triPointRef t
(
pts[tri[0]],
pts[tri[1]],
pts[tri[2]]
);
scalar triMag = t.mag();
cM += triMag*t.centre();
mass += triMag;
}
cM /= mass;
mass *= density;
// Find inertia around centre of mass
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
J += triPointRef
(
pts[tri[0]],
pts[tri[1]],
pts[tri[2]]
).inertia(cM, density);
}
}
tensor applyParallelAxisTheorem
(
scalar m,
const vector& cM,
const tensor& J,
const vector& refPt
)
{
// The displacement vector (refPt = cM) is the displacement of the
// new reference point from the centre of mass of the body that
// the inertia tensor applies to.
vector d = (refPt - cM);
return J + m*((d & d)*I - d*d);
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
argList::addNote argList::addNote
@ -321,40 +88,17 @@ int main(int argc, char *argv[])
triSurface surf(surfFileName); triSurface surf(surfFileName);
triFaceList faces(surf.size());
forAll(surf, i)
{
faces[i] = triFace(surf[i]);
}
scalar m = 0.0; scalar m = 0.0;
vector cM = vector::zero; vector cM = vector::zero;
tensor J = tensor::zero; tensor J = tensor::zero;
if (args.optionFound("shellProperties")) if (args.optionFound("shellProperties"))
{ {
massPropertiesShell momentOfInertia::massPropertiesShell(surf, density, m, cM, J);
(
surf.points(),
faces,
density,
m,
cM,
J
);
} }
else else
{ {
massPropertiesSolid momentOfInertia::massPropertiesSolid(surf, density, m, cM, J);
(
surf.points(),
faces,
density,
m,
cM,
J
);
} }
if (m < 0) if (m < 0)
@ -583,7 +327,7 @@ int main(int argc, char *argv[])
showTransform = false; showTransform = false;
} }
Info<< nl << setprecision(10) Info<< nl << setprecision(12)
<< "Density: " << density << nl << "Density: " << density << nl
<< "Mass: " << m << nl << "Mass: " << m << nl
<< "Centre of mass: " << cM << nl << "Centre of mass: " << cM << nl
@ -615,7 +359,7 @@ int main(int argc, char *argv[])
if (calcAroundRefPt) if (calcAroundRefPt)
{ {
Info<< nl << "Inertia tensor relative to " << refPt << ": " << nl Info<< nl << "Inertia tensor relative to " << refPt << ": " << nl
<< applyParallelAxisTheorem(m, cM, J, refPt) << momentOfInertia::applyParallelAxisTheorem(m, cM, J, refPt)
<< endl; << endl;
} }

View File

@ -593,6 +593,7 @@ DebugSwitches
muSgsSpalartAllmarasWallFunction 0; muSgsSpalartAllmarasWallFunction 0;
multiDirRefinement 0; multiDirRefinement 0;
multiHoleInjector 0; multiHoleInjector 0;
multiLevel 1;
multivariateSelection 0; multivariateSelection 0;
mutRoughWallFunction 0; mutRoughWallFunction 0;
mutSpalartAllmarasStandardRoughWallFunction 0; mutSpalartAllmarasStandardRoughWallFunction 0;

View File

@ -40,8 +40,7 @@ const Foam::scalar
Foam::FaceCellWave<Type, TrackingData>::geomTol_ = 1e-6; Foam::FaceCellWave<Type, TrackingData>::geomTol_ = 1e-6;
template <class Type, class TrackingData> template <class Type, class TrackingData>
const Foam::scalar Foam::scalar Foam::FaceCellWave<Type, TrackingData>::propagationTol_ = 0.01;
Foam::FaceCellWave<Type, TrackingData>::propagationTol_ = 0.01;
template <class Type, class TrackingData> template <class Type, class TrackingData>
Foam::label Foam::FaceCellWave<Type, TrackingData>::dummyTrackData_ = 12345; Foam::label Foam::FaceCellWave<Type, TrackingData>::dummyTrackData_ = 12345;
@ -516,8 +515,8 @@ void Foam::FaceCellWave<Type, TrackingData>::handleProcPatches()
refCast<const processorPolyPatch>(patch); refCast<const processorPolyPatch>(patch);
// Allocate buffers // Allocate buffers
labelList receiveFaces(patch.size()); labelList receiveFaces;
List<Type> receiveFacesInfo(patch.size()); List<Type> receiveFacesInfo;
{ {
UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs); UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
@ -675,8 +674,7 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
hasCyclicPatches_(hasCyclicPatch()), hasCyclicPatches_(hasCyclicPatch()),
nEvals_(0), nEvals_(0),
nUnvisitedCells_(mesh_.nCells()), nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces()), nUnvisitedFaces_(mesh_.nFaces())
iter_(0)
{} {}
@ -707,16 +705,15 @@ Foam::FaceCellWave<Type, TrackingData>::FaceCellWave
hasCyclicPatches_(hasCyclicPatch()), hasCyclicPatches_(hasCyclicPatch()),
nEvals_(0), nEvals_(0),
nUnvisitedCells_(mesh_.nCells()), nUnvisitedCells_(mesh_.nCells()),
nUnvisitedFaces_(mesh_.nFaces()), nUnvisitedFaces_(mesh_.nFaces())
iter_(0)
{ {
// Copy initial changed faces data // Copy initial changed faces data
setFaceInfo(changedFaces, changedFacesInfo); setFaceInfo(changedFaces, changedFacesInfo);
// Iterate until nothing changes // Iterate until nothing changes
iterate(maxIter); label iter = iterate(maxIter);
if ((maxIter > 0) && (iter_ >= maxIter)) if ((maxIter > 0) && (iter >= maxIter))
{ {
FatalErrorIn FatalErrorIn
( (
@ -796,7 +793,7 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::faceToCell()
); );
} }
// Neighbour. Hack for check if face has neighbour. // Neighbour.
if (faceI < nInternalFaces) if (faceI < nInternalFaces)
{ {
cellI = neighbour[faceI]; cellI = neighbour[faceI];
@ -927,11 +924,13 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
handleProcPatches(); handleProcPatches();
} }
while (iter_ < maxIter) label iter = 0;
while (iter < maxIter)
{ {
if (debug) if (debug)
{ {
Pout<< " Iteration " << iter_ << endl; Pout<< " Iteration " << iter << endl;
} }
nEvals_ = 0; nEvals_ = 0;
@ -963,10 +962,11 @@ Foam::label Foam::FaceCellWave<Type, TrackingData>::iterate(const label maxIter)
break; break;
} }
++iter_; ++iter;
} }
return nUnvisitedCells_; return iter;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -114,9 +114,6 @@ class FaceCellWave
label nUnvisitedCells_; label nUnvisitedCells_;
label nUnvisitedFaces_; label nUnvisitedFaces_;
//- Iteration counter
label iter_;
// Private Member Functions // Private Member Functions
@ -232,7 +229,7 @@ class FaceCellWave
// Private static data // Private static data
static const scalar geomTol_; static const scalar geomTol_;
static const scalar propagationTol_; static scalar propagationTol_;
//- Used as default trackdata value to satisfy default template //- Used as default trackdata value to satisfy default template
// argument. // argument.
@ -340,8 +337,8 @@ public:
// counted double) // counted double)
label cellToFace(); label cellToFace();
//- Iterate until no changes or maxIter reached. Returns number of //- Iterate until no changes or maxIter reached. Returns actual
// unset cells (see getUnsetCells) // number of iterations.
label iterate(const label maxIter); label iterate(const label maxIter);
}; };

View File

@ -134,8 +134,8 @@ public:
return calc_.data(); return calc_.data();
} }
//- Iterate until no changes or maxIter reached. Returns number of //- Iterate until no changes or maxIter reached. Returns actual
// unset cells (see getUnsetCells) // number of iterations.
label iterate(const label maxIter) label iterate(const label maxIter)
{ {
return calc_.iterate(maxIter); return calc_.iterate(maxIter);

View File

@ -66,6 +66,10 @@ void Foam::IOdictionary::readFile(const bool masterOnly)
: Pstream::treeCommunication() : Pstream::treeCommunication()
); );
// Master reads headerclassname from file. Make sure this gets
// transfered as well as contents.
Pstream::scatter(comms, const_cast<word&>(headerClassName()));
Pstream::scatter(comms, note());
// Get my communication order // Get my communication order
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];

View File

@ -201,6 +201,11 @@ bool Foam::regIOobject::read()
: Pstream::treeCommunication() : Pstream::treeCommunication()
); );
// Master reads headerclassname from file. Make sure this gets
// transfered as well as contents.
Pstream::scatter(comms, const_cast<word&>(headerClassName()));
Pstream::scatter(comms, note());
// Get my communication order // Get my communication order
const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()];

View File

@ -284,10 +284,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue to >= minLimit // adjust lookupValue to >= minLimit
while (lookupValue < minLimit) scalar span = maxLimit-minLimit;
{ lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
lookupValue += maxLimit;
}
break; break;
} }
} }
@ -325,10 +323,8 @@ Type Foam::interpolationTable<Type>::rateOfChange(const scalar value) const
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue <= maxLimit // adjust lookupValue <= maxLimit
while (lookupValue > maxLimit) scalar span = maxLimit-minLimit;
{ lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
lookupValue -= maxLimit;
}
break; break;
} }
} }
@ -540,11 +536,9 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
} }
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue to >= minLimin // adjust lookupValue to >= minLimit
while (lookupValue < minLimit) scalar span = maxLimit-minLimit;
{ lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
lookupValue += maxLimit;
}
break; break;
} }
} }
@ -582,10 +576,8 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
case interpolationTable::REPEAT: case interpolationTable::REPEAT:
{ {
// adjust lookupValue <= maxLimit // adjust lookupValue <= maxLimit
while (lookupValue > maxLimit) scalar span = maxLimit-minLimit;
{ lookupValue = fmod(lookupValue-minLimit, span) + minLimit;
lookupValue -= maxLimit;
}
break; break;
} }
} }

View File

@ -84,7 +84,11 @@ Foam::solution::solution
dictName, dictName,
obr.time().system(), obr.time().system(),
obr, obr,
IOobject::MUST_READ_IF_MODIFIED, (
obr.readOpt() == IOobject::MUST_READ
? IOobject::MUST_READ_IF_MODIFIED
: obr.readOpt()
),
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
@ -94,7 +98,14 @@ Foam::solution::solution
defaultRelaxationFactor_(0), defaultRelaxationFactor_(0),
solvers_(ITstream("solvers", tokenList())()) solvers_(ITstream("solvers", tokenList())())
{ {
read(solutionDict()); if
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
read(solutionDict());
}
} }

View File

@ -111,7 +111,7 @@ Foam::boundBox::boundBox(Istream& is)
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
Foam::tmp<Foam::pointField> Foam::boundBox::corners() const Foam::tmp<Foam::pointField> Foam::boundBox::points() const
{ {
tmp<pointField> tPts = tmp<pointField>(new pointField(8)); tmp<pointField> tPts = tmp<pointField>(new pointField(8));
pointField& pt = tPts(); pointField& pt = tPts();

View File

@ -177,7 +177,7 @@ public:
} }
//- Return corner points in an order corresponding to a 'hex' cell //- Return corner points in an order corresponding to a 'hex' cell
tmp<pointField> corners() const; tmp<pointField> points() const;
// Query // Query

View File

@ -41,6 +41,7 @@ SourceFiles
#include "tetPointRef.H" #include "tetPointRef.H"
#include "triPointRef.H" #include "triPointRef.H"
#include "polyMesh.H" #include "polyMesh.H"
#include "triFace.H"
#include "face.H" #include "face.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -146,6 +147,10 @@ public:
// mesh face for this tet from the supplied mesh // mesh face for this tet from the supplied mesh
inline triPointRef faceTri(const polyMesh& mesh) const; inline triPointRef faceTri(const polyMesh& mesh) const;
//- Return the point indices corresponding to the tri on the mesh
// face for this tet from the supplied mesh
inline triFace faceTriIs(const polyMesh& mesh) const;
//- Return the geometry corresponding to the tri on the //- Return the geometry corresponding to the tri on the
// mesh face for this tet from the supplied mesh using // mesh face for this tet from the supplied mesh using
// the old position // the old position

View File

@ -122,6 +122,21 @@ Foam::triPointRef Foam::tetIndices::faceTri(const polyMesh& mesh) const
} }
Foam::triFace Foam::tetIndices::faceTriIs(const polyMesh& mesh) const
{
const faceList& pFaces = mesh.faces();
const Foam::face& f = pFaces[faceI_];
return triFace
(
f[faceBasePtI_],
f[facePtAI_],
f[facePtBI_]
);
}
Foam::triPointRef Foam::tetIndices::oldFaceTri(const polyMesh& mesh) const Foam::triPointRef Foam::tetIndices::oldFaceTri(const polyMesh& mesh) const
{ {
const pointField& oldPPts = mesh.oldPoints(); const pointField& oldPPts = mesh.oldPoints();

View File

@ -273,6 +273,30 @@ void Foam::cyclicPolyPatch::calcTransforms
half1Normals, half1Normals,
half0Tols half0Tols
); );
if (transform_ == ROTATIONAL && !parallel() && forwardT().size() > 1)
{
const_cast<tensorField&>(forwardT()).setSize(1);
const_cast<tensorField&>(reverseT()).setSize(1);
const_cast<boolList&>(collocated()).setSize(1);
WarningIn
(
"cyclicPolyPatch::calcTransforms\n"
" (\n"
" const primitivePatch&,\n"
" const UList<point>&,\n"
" const UList<point>&,\n"
" const UList<point>&,\n"
" const UList<point>&\n"
" )"
) << "For patch " << name()
<< " calculated non-uniform transform tensor even though"
<< " the transform type is " << transformTypeNames[transform_]
<< ". Setting the transformation tensor to be a uniform"
<< " rotation."
<< endl;
}
} }
} }
@ -851,22 +875,6 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledPoints() const
str<< "l " << vertI-1 << ' ' << vertI << nl; str<< "l " << vertI-1 << ' ' << vertI << nl;
} }
} }
// Remove any addressing calculated for the coupled edges calculation
const_cast<primitivePatch&>
(
static_cast<const primitivePatch&>
(
*this
)
).clearOut();
const_cast<primitivePatch&>
(
static_cast<const primitivePatch&>
(
neighbPatch()
)
).clearOut();
} }
return *coupledPointsPtr_; return *coupledPointsPtr_;
} }
@ -1006,22 +1014,6 @@ const Foam::edgeList& Foam::cyclicPolyPatch::coupledEdges() const
str<< "l " << vertI-1 << ' ' << vertI << nl; str<< "l " << vertI-1 << ' ' << vertI << nl;
} }
} }
// Remove any addressing calculated for the coupled edges calculation
const_cast<primitivePatch&>
(
static_cast<const primitivePatch&>
(
*this
)
).clearOut();
const_cast<primitivePatch&>
(
static_cast<const primitivePatch&>
(
neighbPatch
)
).clearOut();
} }
return *coupledEdgesPtr_; return *coupledEdgesPtr_;
} }

View File

@ -409,6 +409,7 @@ void Foam::processorPolyPatch::updateMesh(PstreamBuffers& pBufs)
} }
// Remove any addressing used for shared points/edges calculation // Remove any addressing used for shared points/edges calculation
// since mostly not needed.
primitivePatch::clearOut(); primitivePatch::clearOut();
} }
} }

View File

@ -174,8 +174,6 @@ void Foam::processorCyclicPolyPatch::calcGeometry(PstreamBuffers& pBufs)
// Update underlying cyclic // Update underlying cyclic
coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch()); coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
Pout<< "updating geometry on refered patch:" << pp.name() << endl;
pp.calcGeometry pp.calcGeometry
( (
*this, *this,

View File

@ -156,29 +156,12 @@ inline Point tetrahedron<Point, PointRef>::circumCentre() const
if (Foam::mag(denom) < ROOTVSMALL) if (Foam::mag(denom) < ROOTVSMALL)
{ {
// Degenerate tet. Use test of the individual triangles. WarningIn("Point tetrahedron<Point, PointRef>::circumCentre() const")
{ << "Degenerate tetrahedron:" << nl << *this << nl
point triCentre = triPointRef(a_, b_, c_).circumCentre(); <<"Returning centre instead of circumCentre."
if (magSqr(d_ - triCentre) < magSqr(a_ - triCentre)) << endl;
{
return triCentre; return centre();
}
}
{
point triCentre = triPointRef(a_, b_, d_).circumCentre();
if (magSqr(c_ - triCentre) < magSqr(a_ - triCentre))
{
return triCentre;
}
}
{
point triCentre = triPointRef(a_, c_, d_).circumCentre();
if (magSqr(b_ - triCentre) < magSqr(a_ - triCentre))
{
return triCentre;
}
}
return triPointRef(b_, c_, d_).circumCentre();
} }
return a_ + 0.5*(a + num/denom); return a_ + 0.5*(a + num/denom);
@ -188,16 +171,43 @@ inline Point tetrahedron<Point, PointRef>::circumCentre() const
template<class Point, class PointRef> template<class Point, class PointRef>
inline scalar tetrahedron<Point, PointRef>::circumRadius() const inline scalar tetrahedron<Point, PointRef>::circumRadius() const
{ {
return Foam::mag(a_ - circumCentre()); vector a = b_ - a_;
vector b = c_ - a_;
vector c = d_ - a_;
scalar lambda = magSqr(c) - (a & c);
scalar mu = magSqr(b) - (a & b);
vector ba = b ^ a;
vector ca = c ^ a;
vector num = lambda*ba - mu*ca;
scalar denom = (c & ba);
if (Foam::mag(denom) < ROOTVSMALL)
{
WarningIn("Point tetrahedron<Point, PointRef>::circumCentre() const")
<< "Degenerate tetrahedron:" << nl << *this << nl
<< "Returning GREAT for circumRadius."
<< endl;
return GREAT;
}
return Foam::mag(0.5*(a + num/denom));
} }
template<class Point, class PointRef> template<class Point, class PointRef>
inline scalar tetrahedron<Point, PointRef>::quality() const inline scalar tetrahedron<Point, PointRef>::quality() const
{ {
// Note: 8/(9*sqrt(3)) = 0.5132002393 return
mag()
return mag()/(0.5132002393*pow3(min(circumRadius(), GREAT)) + ROOTVSMALL); /(
8.0/(9.0*sqrt(3.0))
*pow3(min(circumRadius(), GREAT))
+ ROOTVSMALL
);
} }
@ -266,7 +276,8 @@ scalar tetrahedron<Point, PointRef>::barycentric
"const point& pt" "const point& pt"
") const" ") const"
) )
<< "Degenerate tetrahedron - returning 1/4 barycentric coordinates." << "Degenerate tetrahedron:" << nl << *this << nl
<< "Returning 1/4 barycentric coordinates."
<< endl; << endl;
bary = List<scalar>(4, 0.25); bary = List<scalar>(4, 0.25);

View File

@ -109,9 +109,9 @@ inline vector triangle<Point, PointRef>::normal() const
template<class Point, class PointRef> template<class Point, class PointRef>
inline Point triangle<Point, PointRef>::circumCentre() const inline Point triangle<Point, PointRef>::circumCentre() const
{ {
scalar d1 = (c_ - a_)&(b_ - a_); scalar d1 = (c_ - a_) & (b_ - a_);
scalar d2 = -(c_ - b_)&(b_ - a_); scalar d2 = -(c_ - b_) & (b_ - a_);
scalar d3 = (c_ - a_)&(c_ - b_); scalar d3 = (c_ - a_) & (c_ - b_);
scalar c1 = d2*d3; scalar c1 = d2*d3;
scalar c2 = d3*d1; scalar c2 = d3*d1;
@ -119,6 +119,16 @@ inline Point triangle<Point, PointRef>::circumCentre() const
scalar c = c1 + c2 + c3; scalar c = c1 + c2 + c3;
if (Foam::mag(c) < ROOTVSMALL)
{
WarningIn("Point triangle<Point, PointRef>::circumCentre() const")
<< "Degenerate triangle:" << nl << *this << nl
<< "Returning centre instead of circumCentre."
<< endl;
return centre();
}
return return
( (
((c2 + c3)*a_ + (c3 + c1)*b_ + (c1 + c2)*c_)/(2*c) ((c2 + c3)*a_ + (c3 + c1)*b_ + (c1 + c2)*c_)/(2*c)
@ -129,14 +139,19 @@ inline Point triangle<Point, PointRef>::circumCentre() const
template<class Point, class PointRef> template<class Point, class PointRef>
inline scalar triangle<Point, PointRef>::circumRadius() const inline scalar triangle<Point, PointRef>::circumRadius() const
{ {
scalar d1 = (c_ - a_) & (b_ - a_); scalar d1 = (c_ - a_) & (b_ - a_);
scalar d2 = - (c_ - b_) & (b_ - a_); scalar d2 = -(c_ - b_) & (b_ - a_);
scalar d3 = (c_ - a_) & (c_ - b_); scalar d3 = (c_ - a_) & (c_ - b_);
scalar denom = d2*d3 + d3*d1 + d1*d2; scalar denom = d2*d3 + d3*d1 + d1*d2;
if (Foam::mag(denom) < VSMALL) if (Foam::mag(denom) < VSMALL)
{ {
WarningIn("scalar triangle<Point, PointRef>::circumRadius() const")
<< "Degenerate triangle:" << nl << *this << nl
<< "Returning GREAT for circumRadius."
<< endl;
return GREAT; return GREAT;
} }
else else
@ -151,16 +166,7 @@ inline scalar triangle<Point, PointRef>::circumRadius() const
template<class Point, class PointRef> template<class Point, class PointRef>
inline scalar triangle<Point, PointRef>::quality() const inline scalar triangle<Point, PointRef>::quality() const
{ {
// Note: 3*sqr(3)/(4*pi) = 0.4134966716 return mag()/(Foam::sqr(circumRadius())*3.0*sqrt(3.0)/4.0 + VSMALL);
return
mag()
/ (
constant::mathematical::pi
*Foam::sqr(circumRadius())
*0.4134966716
+ VSMALL
);
} }
@ -264,7 +270,8 @@ scalar triangle<Point, PointRef>::barycentric
"const point& pt" "const point& pt"
") const" ") const"
) )
<< "Degenerate triangle - returning 1/3 barycentric coordinates." << "Degenerate triangle:" << nl << *this << nl
<< "Returning 1/3 barycentric coordinates."
<< endl; << endl;
bary = List<scalar>(3, 1.0/3.0); bary = List<scalar>(3, 1.0/3.0);
@ -490,7 +497,7 @@ pointHit triangle<Point, PointRef>::nearestPointClassify
) const ) const
{ {
// Adapted from: // Adapted from:
// Real-time collision detection, Christer Ericson, 2005, 136-142 // Real-time collision detection, Christer Ericson, 2005, p136-142
// Check if P in vertex region outside A // Check if P in vertex region outside A
vector ab = b_ - a_; vector ab = b_ - a_;
@ -528,6 +535,27 @@ pointHit triangle<Point, PointRef>::nearestPointClassify
if (vc <= 0.0 && d1 >= 0.0 && d3 <= 0.0) if (vc <= 0.0 && d1 >= 0.0 && d3 <= 0.0)
{ {
if ((d1 - d3) < ROOTVSMALL)
{
WarningIn
(
"pointHit triangle<Point, PointRef>::nearestPointClassify"
"("
"const point& p,"
"label& nearType,"
"label& nearLabel"
") const"
)
<< "Degenerate triangle:" << nl << *this << nl
<< "d1, d3: " << d1 << ", " << d3 << endl;
// For d1 = d3, a_ and b_ are likely coincident.
nearType = POINT;
nearLabel = 0;
return pointHit(false, a_, Foam::mag(a_ - p), true);
}
// barycentric coordinates (1-v, v, 0) // barycentric coordinates (1-v, v, 0)
scalar v = d1/(d1 - d3); scalar v = d1/(d1 - d3);
@ -556,6 +584,27 @@ pointHit triangle<Point, PointRef>::nearestPointClassify
if (vb <= 0.0 && d2 >= 0.0 && d6 <= 0.0) if (vb <= 0.0 && d2 >= 0.0 && d6 <= 0.0)
{ {
if ((d2 - d6) < ROOTVSMALL)
{
WarningIn
(
"pointHit triangle<Point, PointRef>::nearestPointClassify"
"("
"const point& p,"
"label& nearType,"
"label& nearLabel"
") const"
)
<< "Degenerate triangle:" << nl << *this << nl
<< "d2, d6: " << d2 << ", " << d6 << endl;
// For d2 = d6, a_ and c_ are likely coincident.
nearType = POINT;
nearLabel = 0;
return pointHit(false, a_, Foam::mag(a_ - p), true);
}
// barycentric coordinates (1-w, 0, w) // barycentric coordinates (1-w, 0, w)
scalar w = d2/(d2 - d6); scalar w = d2/(d2 - d6);
@ -570,6 +619,28 @@ pointHit triangle<Point, PointRef>::nearestPointClassify
if (va <= 0.0 && (d4 - d3) >= 0.0 && (d5 - d6) >= 0.0) if (va <= 0.0 && (d4 - d3) >= 0.0 && (d5 - d6) >= 0.0)
{ {
if (((d4 - d3) + (d5 - d6)) < ROOTVSMALL)
{
WarningIn
(
"pointHit triangle<Point, PointRef>::nearestPointClassify"
"("
"const point& p,"
"label& nearType,"
"label& nearLabel"
") const"
)
<< "Degenerate triangle:" << nl << *this << nl
<< "(d4 - d3), (d6 - d5): " << (d4 - d3) << ", " << (d6 - d5)
<< endl;
// For (d4 - d3) = (d6 - d5), b_ and c_ are likely coincident.
nearType = POINT;
nearLabel = 1;
return pointHit(false, b_, Foam::mag(b_ - p), true);
}
// barycentric coordinates (0, 1-w, w) // barycentric coordinates (0, 1-w, w)
scalar w = (d4 - d3)/((d4 - d3) + (d5 - d6)); scalar w = (d4 - d3)/((d4 - d3) + (d5 - d6));
@ -581,6 +652,28 @@ pointHit triangle<Point, PointRef>::nearestPointClassify
// P inside face region. Compute Q through its barycentric // P inside face region. Compute Q through its barycentric
// coordinates (u, v, w) // coordinates (u, v, w)
if ((va + vb + vc) < ROOTVSMALL)
{
WarningIn
(
"pointHit triangle<Point, PointRef>::nearestPointClassify"
"("
"const point& p,"
"label& nearType,"
"label& nearLabel"
") const"
)
<< "Degenerate triangle:" << nl << *this << nl
<< "va, vb, vc: " << va << ", " << vb << ", " << vc
<< endl;
point nearPt = centre();
nearType = NONE,
nearLabel = -1;
return pointHit(true, nearPt, Foam::mag(nearPt - p), false);
}
scalar denom = 1.0/(va + vb + vc); scalar denom = 1.0/(va + vb + vc);
scalar v = vb * denom; scalar v = vb * denom;
scalar w = vc * denom; scalar w = vc * denom;

View File

@ -76,6 +76,8 @@ EqOp(eqMag, x = mag(y))
EqOp(plusEqMagSqr, x += magSqr(y)) EqOp(plusEqMagSqr, x += magSqr(y))
EqOp(maxEq, x = max(x, y)) EqOp(maxEq, x = max(x, y))
EqOp(minEq, x = min(x, y)) EqOp(minEq, x = min(x, y))
EqOp(minMagSqrEq, x = (magSqr(x)<=magSqr(y) ? x : y))
EqOp(maxMagSqrEq, x = (magSqr(x)>=magSqr(y) ? x : y))
EqOp(andEq, x = (x && y)) EqOp(andEq, x = (x && y))
EqOp(orEq, x = (x || y)) EqOp(orEq, x = (x || y))

View File

@ -48,9 +48,11 @@ inline tensor rotationTensor
const vector& n2 const vector& n2
) )
{ {
const scalar s = n1 & n2;
const vector n3 = n1 ^ n2;
return return
(n1 & n2)*I s*I
+ (1 - (n1 & n2))*sqr(n1 ^ n2)/(magSqr(n1 ^ n2) + VSMALL) + (1 - s)*sqr(n3)/(magSqr(n3) + VSMALL)
+ (n2*n1 - n1*n2); + (n2*n1 - n1*n2);
} }

View File

@ -163,21 +163,19 @@ tmp<scalarField> advectiveFvPatchField<Type>::advectionSpeed() const
const surfaceScalarField& phi = const surfaceScalarField& phi =
this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_); this->db().objectRegistry::lookupObject<surfaceScalarField>(phiName_);
fvsPatchField<scalar> phip = this->patch().lookupPatchField fvsPatchField<scalar> phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea) if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{ {
const fvPatchScalarField& rhop = this->patch().lookupPatchField const fvPatchScalarField& rhop =
( this->patch().template lookupPatchField<volScalarField, scalar>
rhoName_, (
reinterpret_cast<const volScalarField*>(0), rhoName_
reinterpret_cast<const scalar*>(0) );
);
return phip/(rhop*this->patch().magSf()); return phip/(rhop*this->patch().magSf());
} }

View File

@ -25,15 +25,10 @@ License
#include "inletOutletFvPatchField.H" #include "inletOutletFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -49,7 +44,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf, const inletOutletFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -63,7 +58,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
@ -93,7 +88,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf const inletOutletFvPatchField<Type>& ptf
) )
@ -104,7 +99,7 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
template<class Type> template<class Type>
inletOutletFvPatchField<Type>::inletOutletFvPatchField Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
( (
const inletOutletFvPatchField<Type>& ptf, const inletOutletFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -118,19 +113,18 @@ inletOutletFvPatchField<Type>::inletOutletFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::updateCoeffs() void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
{ {
if (this->updated()) if (this->updated())
{ {
return; return;
} }
const Field<scalar>& phip = this->patch().lookupPatchField const Field<scalar>& phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
this->valueFraction() = 1.0 - pos(phip); this->valueFraction() = 1.0 - pos(phip);
@ -139,7 +133,7 @@ void inletOutletFvPatchField<Type>::updateCoeffs()
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::write(Ostream& os) const void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
if (phiName_ != "phi") if (phiName_ != "phi")
@ -154,7 +148,7 @@ void inletOutletFvPatchField<Type>::write(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Type> template<class Type>
void inletOutletFvPatchField<Type>::operator= void Foam::inletOutletFvPatchField<Type>::operator=
( (
const fvPatchField<Type>& ptf const fvPatchField<Type>& ptf
) )
@ -167,8 +161,4 @@ void inletOutletFvPatchField<Type>::operator=
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -56,6 +56,7 @@ protected:
// Protected data // Protected data
//- Name of flux field
word phiName_; word phiName_;

View File

@ -25,21 +25,17 @@ License
#include "outletInletFvPatchField.H" #include "outletInletFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(p, iF) mixedFvPatchField<Type>(p, iF),
phiName_("phi")
{ {
this->refValue() = *this; this->refValue() = *this;
this->refGrad() = pTraits<Type>::zero; this->refGrad() = pTraits<Type>::zero;
@ -48,7 +44,7 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf, const outletInletFvPatchField<Type>& ptf,
const fvPatch& p, const fvPatch& p,
@ -56,19 +52,21 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
mixedFvPatchField<Type>(ptf, p, iF, mapper) mixedFvPatchField<Type>(ptf, p, iF, mapper),
phiName_(ptf.phiName_)
{} {}
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF) mixedFvPatchField<Type>(p, iF),
phiName_(dict.lookupOrDefault<word>("phi", "phi"))
{ {
this->refValue() = Field<Type>("outletValue", dict, p.size()); this->refValue() = Field<Type>("outletValue", dict, p.size());
@ -90,42 +88,43 @@ outletInletFvPatchField<Type>::outletInletFvPatchField
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf const outletInletFvPatchField<Type>& ptf
) )
: :
mixedFvPatchField<Type>(ptf) mixedFvPatchField<Type>(ptf),
phiName_(ptf.phiName_)
{} {}
template<class Type> template<class Type>
outletInletFvPatchField<Type>::outletInletFvPatchField Foam::outletInletFvPatchField<Type>::outletInletFvPatchField
( (
const outletInletFvPatchField<Type>& ptf, const outletInletFvPatchField<Type>& ptf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
) )
: :
mixedFvPatchField<Type>(ptf, iF) mixedFvPatchField<Type>(ptf, iF),
phiName_(ptf.phiName_)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
void outletInletFvPatchField<Type>::updateCoeffs() void Foam::outletInletFvPatchField<Type>::updateCoeffs()
{ {
if (this->updated()) if (this->updated())
{ {
return; return;
} }
const fvsPatchField<scalar>& phip = this->patch().lookupPatchField const fvsPatchField<scalar>& phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
"phi", (
reinterpret_cast<const surfaceScalarField*>(0), phiName_
reinterpret_cast<const scalar*>(0) );
);
this->valueFraction() = pos(phip); this->valueFraction() = pos(phip);
@ -134,16 +133,16 @@ void outletInletFvPatchField<Type>::updateCoeffs()
template<class Type> template<class Type>
void outletInletFvPatchField<Type>::write(Ostream& os) const void Foam::outletInletFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
if (phiName_ != "phi")
{
os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
}
this->refValue().writeEntry("outletValue", os); this->refValue().writeEntry("outletValue", os);
this->writeEntry("value", os); this->writeEntry("value", os);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -52,6 +52,14 @@ class outletInletFvPatchField
public mixedFvPatchField<Type> public mixedFvPatchField<Type>
{ {
protected:
// Protected data
//- Name of flux field
word phiName_;
public: public:
//- Runtime type information //- Runtime type information

View File

@ -2,7 +2,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) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -129,7 +129,6 @@ selfContainedDirectMappedFixedValueFvPatchField
{} {}
template<class Type> template<class Type>
selfContainedDirectMappedFixedValueFvPatchField<Type>:: selfContainedDirectMappedFixedValueFvPatchField<Type>::
selfContainedDirectMappedFixedValueFvPatchField selfContainedDirectMappedFixedValueFvPatchField

View File

@ -2,7 +2,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) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,7 +48,7 @@ namespace Foam
{ {
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class selfContainedDirectMappedFixedValueFvPatch Declaration Class selfContainedDirectMappedFixedValueFvPatchField Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template<class Type> template<class Type>
@ -75,6 +75,7 @@ class selfContainedDirectMappedFixedValueFvPatchField
mutable autoPtr<interpolation<Type> > interpolator_; mutable autoPtr<interpolation<Type> > interpolator_;
// Private Member Functions // Private Member Functions
//- Field to sample. Either on my or nbr mesh //- Field to sample. Either on my or nbr mesh
@ -83,6 +84,7 @@ class selfContainedDirectMappedFixedValueFvPatchField
//- Access the interpolation method //- Access the interpolation method
const interpolation<Type>& interpolator() const; const interpolation<Type>& interpolator() const;
public: public:
//- Runtime type information //- Runtime type information
@ -186,6 +188,7 @@ public:
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Write //- Write
virtual void write(Ostream&) const; virtual void write(Ostream&) const;
}; };

View File

@ -2,7 +2,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) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,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) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -2,7 +2,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) 1991-2010 OpenCFD Ltd. \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License

View File

@ -31,15 +31,10 @@ License
#include "CrankNicholsonDdtScheme.H" #include "CrankNicholsonDdtScheme.H"
#include "backwardDdtScheme.H" #include "backwardDdtScheme.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -52,7 +47,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptf, const waveTransmissiveFvPatchField& ptf,
const fvPatch& p, const fvPatch& p,
@ -67,7 +62,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const fvPatch& p, const fvPatch& p,
const DimensionedField<Type, volMesh>& iF, const DimensionedField<Type, volMesh>& iF,
@ -81,7 +76,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptpsf const waveTransmissiveFvPatchField& ptpsf
) )
@ -93,7 +88,7 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
template<class Type> template<class Type>
waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField Foam::waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
( (
const waveTransmissiveFvPatchField& ptpsf, const waveTransmissiveFvPatchField& ptpsf,
const DimensionedField<Type, volMesh>& iF const DimensionedField<Type, volMesh>& iF
@ -108,35 +103,32 @@ waveTransmissiveFvPatchField<Type>::waveTransmissiveFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type> template<class Type>
tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const Foam::tmp<Foam::scalarField>
Foam::waveTransmissiveFvPatchField<Type>::advectionSpeed() const
{ {
// Lookup the velocity and compressibility of the patch // Lookup the velocity and compressibility of the patch
const fvPatchField<scalar>& psip = this->patch().lookupPatchField const fvPatchField<scalar>& psip =
( this->patch().template lookupPatchField<volScalarField, scalar>
psiName_, (
reinterpret_cast<const volScalarField*>(0), psiName_
reinterpret_cast<const scalar*>(0) );
);
const surfaceScalarField& phi = const surfaceScalarField& phi =
this->db().objectRegistry::lookupObject<surfaceScalarField> this->db().template lookupObject<surfaceScalarField>(this->phiName_);
(this->phiName_);
fvsPatchField<scalar> phip = this->patch().lookupPatchField fvsPatchField<scalar> phip =
( this->patch().template lookupPatchField<surfaceScalarField, scalar>
this->phiName_, (
reinterpret_cast<const surfaceScalarField*>(0), this->phiName_
reinterpret_cast<const scalar*>(0) );
);
if (phi.dimensions() == dimDensity*dimVelocity*dimArea) if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
{ {
const fvPatchScalarField& rhop = this->patch().lookupPatchField const fvPatchScalarField& rhop =
( this->patch().template lookupPatchField<volScalarField, scalar>
this->rhoName_, (
reinterpret_cast<const volScalarField*>(0), this->rhoName_
reinterpret_cast<const scalar*>(0) );
);
phip /= rhop; phip /= rhop;
} }
@ -149,7 +141,7 @@ tmp<scalarField> waveTransmissiveFvPatchField<Type>::advectionSpeed() const
template<class Type> template<class Type>
void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const void Foam::waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
@ -165,6 +157,7 @@ void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
{ {
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl; os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
} }
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl; os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
if (this->lInf_ > SMALL) if (this->lInf_ > SMALL)
@ -179,8 +172,4 @@ void waveTransmissiveFvPatchField<Type>::write(Ostream& os) const
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* // // ************************************************************************* //

View File

@ -256,7 +256,11 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
"fvSchemes", "fvSchemes",
obr.time().system(), obr.time().system(),
obr, obr,
IOobject::MUST_READ_IF_MODIFIED, (
obr.readOpt() == IOobject::MUST_READ
? IOobject::MUST_READ_IF_MODIFIED
: obr.readOpt()
),
IOobject::NO_WRITE IOobject::NO_WRITE
) )
), ),
@ -364,7 +368,14 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr)
// persistent settings across reads is incorrect // persistent settings across reads is incorrect
clear(); clear();
read(schemesDict()); if
(
readOpt() == IOobject::MUST_READ
|| readOpt() == IOobject::MUST_READ_IF_MODIFIED
)
{
read(schemesDict());
}
} }

View File

@ -37,11 +37,7 @@ SourceFiles
#define pointEdgeStructuredWalk_H #define pointEdgeStructuredWalk_H
#include "point.H" #include "point.H"
#include "label.H"
#include "scalar.H"
#include "tensor.H" #include "tensor.H"
#include "pTraits.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -75,10 +71,12 @@ class pointEdgeStructuredWalk
// Private Member Functions // Private Member Functions
//- Evaluate distance to point. //- Evaluate distance to point.
template<class TrackingData>
inline bool update inline bool update
( (
const pointEdgeStructuredWalk& w2, const pointEdgeStructuredWalk& w2,
const scalar tol const scalar tol,
TrackingData& td
); );
public: public:
@ -111,80 +109,105 @@ public:
// Needed by meshWave // Needed by meshWave
//- Check whether still contains original (invalid) value. //- Check whether origin has been changed at all or
inline bool valid() const; // still contains original (invalid) value.
template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Check for identical geometrical data. Used for cyclics checking. //- Check for identical geometrical data. Used for cyclics checking.
template<class TrackingData>
inline bool sameGeometry inline bool sameGeometry
( (
const pointEdgeStructuredWalk&, const pointEdgeStructuredWalk&,
const scalar tol const scalar tol,
TrackingData& td
) const; ) const;
//- Convert origin to relative vector to leaving point //- Convert origin to relative vector to leaving point
// (= point coordinate) // (= point coordinate)
template<class TrackingData>
inline void leaveDomain inline void leaveDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& pos const point& pos,
TrackingData& td
); );
//- Convert relative origin to absolute by adding entering point //- Convert relative origin to absolute by adding entering point
template<class TrackingData>
inline void enterDomain inline void enterDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& pos const point& pos,
TrackingData& td
); );
//- Apply rotation matrix to origin //- Apply rotation matrix to origin
inline void transform(const tensor& rotTensor); template<class TrackingData>
inline void transform
(
const tensor& rotTensor,
TrackingData& td
);
//- Influence of edge on point //- Influence of edge on point
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointEdgeStructuredWalk& edgeInfo, const pointEdgeStructuredWalk& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// Merge new and old info. // Merge new and old info.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointEdgeStructuredWalk& newPointInfo, const pointEdgeStructuredWalk& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// No information about current position whatsoever. // No information about current position whatsoever.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const pointEdgeStructuredWalk& newPointInfo, const pointEdgeStructuredWalk& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of point on edge. //- Influence of point on edge.
template<class TrackingData>
inline bool updateEdge inline bool updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointEdgeStructuredWalk& pointInfo, const pointEdgeStructuredWalk& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const pointEdgeStructuredWalk&, TrackingData&)
const;
// Member Operators // Member Operators
//Note: Used to determine whether to call update. //Note: Used to determine whether to call update.
inline bool operator==(const pointEdgeStructuredWalk&) const; inline bool operator==(const pointEdgeStructuredWalk&) const;
inline bool operator!=(const pointEdgeStructuredWalk&) const; inline bool operator!=(const pointEdgeStructuredWalk&) const;

View File

@ -29,13 +29,15 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2. // Update this with w2.
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::update inline bool Foam::pointEdgeStructuredWalk::update
( (
const pointEdgeStructuredWalk& w2, const pointEdgeStructuredWalk& w2,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
if (!valid()) if (!valid(td))
{ {
// current not yet set. Walked from w2 to here (=point0) // current not yet set. Walked from w2 to here (=point0)
dist_ = w2.dist_ + mag(point0_-w2.previousPoint_); dist_ = w2.dist_ + mag(point0_-w2.previousPoint_);
@ -105,17 +107,20 @@ inline const Foam::vector& Foam::pointEdgeStructuredWalk::data() const
} }
inline bool Foam::pointEdgeStructuredWalk::valid() const template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::valid(TrackingData& td) const
{ {
return previousPoint_ != vector::max; return previousPoint_ != vector::max;
} }
// Checks for cyclic points // Checks for cyclic points
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::sameGeometry inline bool Foam::pointEdgeStructuredWalk::sameGeometry
( (
const pointEdgeStructuredWalk& w2, const pointEdgeStructuredWalk& w2,
const scalar tol const scalar tol,
TrackingData& td
) const ) const
{ {
scalar diff = Foam::mag(dist() - w2.dist()); scalar diff = Foam::mag(dist() - w2.dist());
@ -138,18 +143,25 @@ inline bool Foam::pointEdgeStructuredWalk::sameGeometry
} }
template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::leaveDomain inline void Foam::pointEdgeStructuredWalk::leaveDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& coord const point& coord,
TrackingData& td
) )
{ {
previousPoint_ -= coord; previousPoint_ -= coord;
} }
inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor) template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::transform
(
const tensor& rotTensor,
TrackingData& td
)
{ {
previousPoint_ = Foam::transform(rotTensor, previousPoint_); previousPoint_ = Foam::transform(rotTensor, previousPoint_);
} }
@ -157,11 +169,13 @@ inline void Foam::pointEdgeStructuredWalk::transform(const tensor& rotTensor)
// Update absolute geometric quantities. Note that distance (dist_) // Update absolute geometric quantities. Note that distance (dist_)
// is not affected by leaving/entering domain. // is not affected by leaving/entering domain.
template<class TrackingData>
inline void Foam::pointEdgeStructuredWalk::enterDomain inline void Foam::pointEdgeStructuredWalk::enterDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& coord const point& coord,
TrackingData& td
) )
{ {
// back to absolute form // back to absolute form
@ -170,18 +184,20 @@ inline void Foam::pointEdgeStructuredWalk::enterDomain
// Update this with information from connected edge // Update this with information from connected edge
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint inline bool Foam::pointEdgeStructuredWalk::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointEdgeStructuredWalk& edgeInfo, const pointEdgeStructuredWalk& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
if (inZone()) if (inZone())
{ {
return update(edgeInfo, tol); return update(edgeInfo, tol, td);
} }
else else
{ {
@ -191,17 +207,19 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint
// Update this with new information on same point // Update this with new information on same point
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint inline bool Foam::pointEdgeStructuredWalk::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointEdgeStructuredWalk& newPointInfo, const pointEdgeStructuredWalk& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
if (inZone()) if (inZone())
{ {
return update(newPointInfo, tol); return update(newPointInfo, tol, td);
} }
else else
{ {
@ -211,29 +229,33 @@ inline bool Foam::pointEdgeStructuredWalk::updatePoint
// Update this with new information on same point. No extra information. // Update this with new information on same point. No extra information.
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updatePoint inline bool Foam::pointEdgeStructuredWalk::updatePoint
( (
const pointEdgeStructuredWalk& newPointInfo, const pointEdgeStructuredWalk& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return update(newPointInfo, tol); return update(newPointInfo, tol, td);
} }
// Update this with information from connected point // Update this with information from connected point
template<class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::updateEdge inline bool Foam::pointEdgeStructuredWalk::updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointEdgeStructuredWalk& pointInfo, const pointEdgeStructuredWalk& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
if (inZone()) if (inZone())
{ {
return update(pointInfo, tol); return update(pointInfo, tol, td);
} }
else else
{ {
@ -242,6 +264,17 @@ inline bool Foam::pointEdgeStructuredWalk::updateEdge
} }
template <class TrackingData>
inline bool Foam::pointEdgeStructuredWalk::equal
(
const pointEdgeStructuredWalk& rhs,
TrackingData& td
) const
{
return operator==(rhs);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::pointEdgeStructuredWalk::operator== inline bool Foam::pointEdgeStructuredWalk::operator==

View File

@ -91,6 +91,9 @@ void Foam::inversePointDistanceDiffusivity::correct()
List<pointEdgePoint> pointWallDist(mesh.nPoints()); List<pointEdgePoint> pointWallDist(mesh.nPoints());
List<pointEdgePoint> edgeWallDist(mesh.nEdges()); List<pointEdgePoint> edgeWallDist(mesh.nEdges());
int dummyTrackData = 0;
{ {
// Seeds // Seeds
List<pointEdgePoint> seedInfo(nPatchEdges); List<pointEdgePoint> seedInfo(nPatchEdges);
@ -108,7 +111,7 @@ void Foam::inversePointDistanceDiffusivity::correct()
{ {
label pointI = meshPoints[i]; label pointI = meshPoints[i];
if (!pointWallDist[pointI].valid()) if (!pointWallDist[pointI].valid(dummyTrackData))
{ {
// Not yet seeded // Not yet seeded
seedInfo[nPatchEdges] = pointEdgePoint seedInfo[nPatchEdges] = pointEdgePoint
@ -135,7 +138,8 @@ void Foam::inversePointDistanceDiffusivity::correct()
pointWallDist, pointWallDist,
edgeWallDist, edgeWallDist,
mesh.globalData().nTotalPoints() // max iterations mesh.globalData().nTotalPoints(),// max iterations
dummyTrackData
); );
} }

View File

@ -86,7 +86,8 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
// referred cells that they interact with. // referred cells that they interact with.
PackedBoolList cellInRangeOfCoupledPatch(mesh_.nCells(), false); PackedBoolList cellInRangeOfCoupledPatch(mesh_.nCells(), false);
// IAndT: index and transform // IAndT: index (=local cell index) and transform (from
// globalIndexAndTransform)
DynamicList<labelPair> cellIAndTToExchange; DynamicList<labelPair> cellIAndTToExchange;
DynamicList<treeBoundBox> cellBbsToExchange; DynamicList<treeBoundBox> cellBbsToExchange;
@ -179,7 +180,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
treeBoundBox tempTransformedBb treeBoundBox tempTransformedBb
( (
transform.invTransform(cellBbsToExchange[bbI].corners()) transform.invTransform(cellBbsToExchange[bbI].points())
); );
treeBoundBox extendedBb treeBoundBox extendedBb
@ -396,7 +397,7 @@ void Foam::InteractionLists<ParticleType>::buildInteractionLists()
treeBoundBox tempTransformedBb treeBoundBox tempTransformedBb
( (
transform.invTransform(wallFaceBbsToExchange[bbI].corners()) transform.invTransform(wallFaceBbsToExchange[bbI].points())
); );
treeBoundBox extendedBb treeBoundBox extendedBb
@ -701,7 +702,7 @@ void Foam::InteractionLists<ParticleType>::findExtendedProcBbsInRange
( (
transform.transform transform.transform
( (
allExtendedProcBbs[procI].corners() allExtendedProcBbs[procI].points()
) )
); );
@ -748,7 +749,7 @@ void Foam::InteractionLists<ParticleType>::findExtendedProcBbsInRange
( (
transform.transform transform.transform
( (
allExtendedProcBbs[procI].corners() allExtendedProcBbs[procI].points()
) )
); );
@ -791,7 +792,7 @@ void Foam::InteractionLists<ParticleType>::findExtendedProcBbsInRange
( (
transform.transform transform.transform
( (
allExtendedProcBbs[procI].corners() allExtendedProcBbs[procI].points()
) )
); );

View File

@ -371,10 +371,21 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
{ {
// Apply tracking correction towards tet centre // Apply tracking correction towards tet centre
if (debug)
{
Pout<< "tracking rescue using tetCentre from " << position();
}
position_ += position_ +=
Cloud<ParticleType>::trackingCorrectionTol Cloud<ParticleType>::trackingCorrectionTol
*(tet.centre() - position_); *(tet.centre() - position_);
if (debug)
{
Pout<< " to " << position() << " due to "
<< (tet.centre() - position_) << endl;
}
cloud_.trackingRescue(); cloud_.trackingRescue();
return trackFraction; return trackFraction;
@ -639,6 +650,12 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
tetPointRef tet = currentTet(); tetPointRef tet = currentTet();
if (debug)
{
Pout<< "tracking rescue for lambdaMin:" << lambdaMin
<< "from " << position();
}
position_ += position_ +=
Cloud<ParticleType>::trackingCorrectionTol Cloud<ParticleType>::trackingCorrectionTol
*(tet.centre() - position_); *(tet.centre() - position_);
@ -692,6 +709,11 @@ Foam::scalar Foam::Particle<ParticleType>::trackToFace
} }
} }
if (debug)
{
Pout<< " to " << position() << endl;
}
cloud_.trackingRescue(); cloud_.trackingRescue();
} }

View File

@ -159,11 +159,6 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -324,11 +319,6 @@ Foam::label Foam::autoLayerDriver::mergePatchFacesUndo
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
// Renumber restore maps // Renumber restore maps
@ -396,11 +386,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRemovePoints
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -454,11 +439,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::autoLayerDriver::doRestorePoints
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));
@ -3100,10 +3080,7 @@ void Foam::autoLayerDriver::addLayers
//?neccesary? Update fields //?neccesary? Update fields
newMesh.updateMesh(map); newMesh.updateMesh(map);
if (meshRefiner_.overwrite()) newMesh.setInstance(meshRefiner_.timeName());
{
newMesh.setInstance(meshRefiner_.oldInstance());
}
// Update numbering on addLayer: // Update numbering on addLayer:
// - cell/point labels to be newMesh. // - cell/point labels to be newMesh.
@ -3229,11 +3206,6 @@ void Foam::autoLayerDriver::addLayers
mesh.clearOut(); mesh.clearOut();
} }
if (meshRefiner_.overwrite())
{
mesh.setInstance(meshRefiner_.oldInstance());
}
meshRefiner_.updateMesh(map, labelList(0)); meshRefiner_.updateMesh(map, labelList(0));

View File

@ -756,6 +756,9 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
// Distance to wall // Distance to wall
List<pointData> pointWallDist(mesh.nPoints()); List<pointData> pointWallDist(mesh.nPoints());
// Dummy additional info for PointEdgeWave
int dummyTrackData = 0;
// 1. Calculate distance to points where displacement is specified. // 1. Calculate distance to points where displacement is specified.
{ {
@ -783,7 +786,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
wallInfo, wallInfo,
pointWallDist, pointWallDist,
edgeWallDist, edgeWallDist,
mesh.globalData().nTotalPoints() // max iterations mesh.globalData().nTotalPoints(), // max iterations
dummyTrackData
); );
} }
@ -813,7 +817,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
{ {
label pointI = e[ep]; label pointI = e[ep];
if (!pointMedialDist[pointI].valid()) if (!pointMedialDist[pointI].valid(dummyTrackData))
{ {
maxPoints.append(pointI); maxPoints.append(pointI);
maxInfo.append maxInfo.append
@ -857,7 +861,7 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
{ {
label pointI = meshPoints[i]; label pointI = meshPoints[i];
if (!pointMedialDist[pointI].valid()) if (!pointMedialDist[pointI].valid(dummyTrackData))
{ {
maxPoints.append(pointI); maxPoints.append(pointI);
maxInfo.append maxInfo.append
@ -888,7 +892,8 @@ void Foam::autoLayerDriver::medialAxisSmoothingInfo
pointMedialDist, pointMedialDist,
edgeMedialDist, edgeMedialDist,
mesh.globalData().nTotalPoints() // max iterations mesh.globalData().nTotalPoints(), // max iterations
dummyTrackData
); );
// Extract medial axis distance as pointScalarField // Extract medial axis distance as pointScalarField

View File

@ -32,19 +32,20 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const pointData& wDist)
if (os.format() == IOstream::ASCII) if (os.format() == IOstream::ASCII)
{ {
return os return os
<< wDist.origin() << token::SPACE << wDist.distSqr() << static_cast<const pointEdgePoint&>(wDist)
<< token::SPACE << wDist.s() << token::SPACE << wDist.v(); << token::SPACE << wDist.s() << token::SPACE << wDist.v();
} }
else else
{ {
return os return os
<< wDist.origin() << wDist.distSqr() << wDist.s() << wDist.v(); << static_cast<const pointEdgePoint&>(wDist)
<< wDist.s() << wDist.v();
} }
} }
Foam::Istream& Foam::operator>>(Istream& is, pointData& wDist) Foam::Istream& Foam::operator>>(Istream& is, pointData& wDist)
{ {
return is >> wDist.origin_ >> wDist.distSqr_ >> wDist.s_ >> wDist.v_; return is >> static_cast<pointEdgePoint&>(wDist) >> wDist.s_ >> wDist.v_;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -25,10 +25,10 @@ Class
Foam::pointData Foam::pointData
Description Description
Holds information regarding nearest wall point. Used in pointEdgeWave. Variant of pointEdgePoint with some transported additional data.
(so not standard meshWave) WIP - should be templated on data like wallDistData.
Passive vector v_ is not a coordinate (so no enterDomain/leaveDomain
To be used in wall distance calculation. transformation needed)
SourceFiles SourceFiles
pointDataI.H pointDataI.H
@ -39,9 +39,10 @@ SourceFiles
#ifndef pointData_H #ifndef pointData_H
#define pointData_H #define pointData_H
#include "point.H" #include "pointEdgePoint.H"
#include "label.H" //#include "point.H"
#include "tensor.H" //#include "label.H"
//#include "tensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,51 +50,22 @@ SourceFiles
namespace Foam namespace Foam
{ {
// Class forward declarations
class polyPatch;
class polyMesh;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class pointData Declaration Class pointData Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
class pointData class pointData
:
public pointEdgePoint
{ {
// Private data // Private data
//- position of nearest wall center
point origin_;
//- normal distance (squared) from point to origin
scalar distSqr_;
//- additional information. //- additional information.
scalar s_; scalar s_;
//- additional information. //- additional information.
vector v_; vector v_;
// Private Member Functions
//- Evaluate distance to point. Update distSqr, origin from whomever
// is nearer pt. Return true if w2 is closer to point,
// false otherwise.
inline bool update
(
const point&,
const pointData& w2,
const scalar tol
);
//- Combine current with w2. Update distSqr, origin if w2 has smaller
// quantities and returns true.
inline bool update
(
const pointData& w2,
const scalar tol
);
public: public:
// Constructors // Constructors
@ -118,10 +90,6 @@ public:
// Access // Access
inline const point& origin() const;
inline scalar distSqr() const;
inline scalar s() const; inline scalar s() const;
inline const vector& v() const; inline const vector& v() const;
@ -129,81 +97,60 @@ public:
// Needed by meshWave // Needed by meshWave
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
inline bool valid() const;
//- Check for identical geometrical data. Used for cyclics checking.
inline bool sameGeometry(const pointData&, const scalar tol)
const;
//- Convert origin to relative vector to leaving point
// (= point coordinate)
inline void leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
);
//- Convert relative origin to absolute by adding entering point
inline void enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
);
//- Apply rotation matrix to origin //- Apply rotation matrix to origin
inline void transform(const tensor& rotTensor); template<class TrackingData>
inline void transform
(
const tensor& rotTensor,
TrackingData& td
);
//- Influence of edge on point //- Influence of edge on point
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointData& edgeInfo, const pointData& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// Merge new and old info. // Merge new and old info.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointData& newPointInfo, const pointData& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// No information about current position whatsoever. // No information about current position whatsoever.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const pointData& newPointInfo, const pointData& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of point on edge. //- Influence of point on edge.
template<class TrackingData>
inline bool updateEdge inline bool updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointData& pointInfo, const pointData& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
// Member Operators
//Note: Used to determine whether to call update.
inline bool operator==(const pointData&) const;
inline bool operator!=(const pointData&) const;
// IOstream Operators // IOstream Operators
friend Ostream& operator<<(Ostream&, const pointData&); friend Ostream& operator<<(Ostream&, const pointData&);

View File

@ -26,118 +26,12 @@ License
#include "polyMesh.H" #include "polyMesh.H"
#include "transform.H" #include "transform.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2 if w2 nearer to pt.
inline bool Foam::pointData::update
(
const point& pt,
const pointData& w2,
const scalar tol
)
{
scalar dist2 = magSqr(pt - w2.origin());
if (!valid())
{
distSqr_ = dist2;
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
// if (v_ != w2.v())
// {
// return false;
// }
scalar diff = distSqr_ - dist2;
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = dist2;
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
}
// Update this with w2 (information on same point)
inline bool Foam::pointData::update
(
const pointData& w2,
const scalar tol
)
{
if (!valid())
{
// current not yet set so use any value
distSqr_ = w2.distSqr();
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
// if (v_ != w2.v())
// {
// return false;
// }
scalar diff = distSqr_ - w2.distSqr();
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = w2.distSqr();
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor // Null constructor
inline Foam::pointData::pointData() inline Foam::pointData::pointData()
: :
origin_(point::max), pointEdgePoint(),
distSqr_(GREAT),
s_(GREAT), s_(GREAT),
v_(point::max) v_(point::max)
{} {}
@ -152,8 +46,7 @@ inline Foam::pointData::pointData
const vector& v const vector& v
) )
: :
origin_(origin), pointEdgePoint(origin, distSqr),
distSqr_(distSqr),
s_(s), s_(s),
v_(v) v_(v)
{} {}
@ -162,8 +55,7 @@ inline Foam::pointData::pointData
// Construct as copy // Construct as copy
inline Foam::pointData::pointData(const pointData& wpt) inline Foam::pointData::pointData(const pointData& wpt)
: :
origin_(wpt.origin()), pointEdgePoint(wpt),
distSqr_(wpt.distSqr()),
s_(wpt.s()), s_(wpt.s()),
v_(wpt.v()) v_(wpt.v())
{} {}
@ -171,18 +63,6 @@ inline Foam::pointData::pointData(const pointData& wpt)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::point& Foam::pointData::origin() const
{
return origin_;
}
inline Foam::scalar Foam::pointData::distSqr() const
{
return distSqr_;
}
inline Foam::scalar Foam::pointData::s() const inline Foam::scalar Foam::pointData::s() const
{ {
return s_; return s_;
@ -195,157 +75,143 @@ inline const Foam::vector& Foam::pointData::v() const
} }
inline bool Foam::pointData::valid() const template <class TrackingData>
{ inline void Foam::pointData::transform
return origin_ != point::max;
}
// Checks for cyclic points
inline bool Foam::pointData::sameGeometry
( (
const pointData& w2, const tensor& rotTensor,
const scalar tol TrackingData& td
) const
{
scalar diff = Foam::mag(distSqr() - w2.distSqr());
if (diff < SMALL)
{
return true;
}
else
{
if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
{
return true;
}
else
{
return false;
}
}
}
inline void Foam::pointData::leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
) )
{ {
origin_ -= coord; pointEdgePoint::transform(rotTensor, td);
} v_ = Foam::transform(rotTensor, v_);
inline void Foam::pointData::transform(const tensor& rotTensor)
{
origin_ = Foam::transform(rotTensor, origin_);
}
// Update absolute geometric quantities. Note that distance (distSqr_)
// is not affected by leaving/entering domain.
inline void Foam::pointData::enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
)
{
// back to absolute form
origin_ += coord;
} }
// Update this with information from connected edge // Update this with information from connected edge
template <class TrackingData>
inline bool Foam::pointData::updatePoint inline bool Foam::pointData::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointData& edgeInfo, const pointData& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return if
update (
pointEdgePoint::updatePoint
( (
mesh.points()[pointI], mesh,
pointI,
edgeI,
edgeInfo, edgeInfo,
tol tol,
); td
)
)
{
s_ = edgeInfo.s_;
v_ = edgeInfo.v_;
return true;
} }
else
{
return false;
}
}
// Update this with new information on same point // Update this with new information on same point
template <class TrackingData>
inline bool Foam::pointData::updatePoint inline bool Foam::pointData::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointData& newPointInfo, const pointData& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return if
update (
pointEdgePoint::updatePoint
( (
mesh.points()[pointI], mesh,
pointI,
newPointInfo, newPointInfo,
tol tol,
); td
)
)
{
s_ = newPointInfo.s_;
v_ = newPointInfo.v_;
return true;
}
else
{
return false;
}
} }
// Update this with new information on same point. No extra information. // Update this with new information on same point. No extra information.
template <class TrackingData>
inline bool Foam::pointData::updatePoint inline bool Foam::pointData::updatePoint
( (
const pointData& newPointInfo, const pointData& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return update(newPointInfo, tol); if (pointEdgePoint::updatePoint(newPointInfo, tol, td))
{
s_ = newPointInfo.s_;
v_ = newPointInfo.v_;
return true;
}
else
{
return false;
}
} }
// Update this with information from connected point // Update this with information from connected point
template <class TrackingData>
inline bool Foam::pointData::updateEdge inline bool Foam::pointData::updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointData& pointInfo, const pointData& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
const pointField& points = mesh.points(); if
(
const edge& e = mesh.edges()[edgeI]; pointEdgePoint::updateEdge
const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
return
update
( (
edgeMid, mesh,
edgeI,
pointI,
pointInfo, pointInfo,
tol tol,
); td
} )
)
{
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // s_ = pointInfo.s_;
v_ = pointInfo.v_;
inline bool Foam::pointData::operator==(const pointData& rhs) const return true;
{ }
return origin() == rhs.origin(); else
} {
return false;
}
inline bool Foam::pointData::operator!=(const pointData& rhs) const
{
return !(*this == rhs);
} }

View File

@ -481,11 +481,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::doRemoveCells
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite_)
{
mesh_.setInstance(oldInstance_);
}
// Update local mesh data // Update local mesh data
cellRemover.updateMesh(map); cellRemover.updateMesh(map);
@ -1903,9 +1898,14 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map)
pointMap.clear(); pointMap.clear();
} }
} }
// If necessary reset the instance
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
} }
// Update local data for a mesh change
void Foam::meshRefinement::updateMesh void Foam::meshRefinement::updateMesh
( (
const mapPolyMesh& map, const mapPolyMesh& map,
@ -2027,6 +2027,10 @@ void Foam::meshRefinement::updateMesh
data.transfer(newFaceData); data.transfer(newFaceData);
} }
} }
// If necessary reset the instance
mesh_.setInstance(timeName());
setInstance(mesh_.facesInstance());
} }
@ -2137,7 +2141,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject IOobject
( (
"cellLevel", "cellLevel",
timeName(), mesh_.time().timeName(),// Dump to current time, not to mesh inst
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::AUTO_WRITE, IOobject::AUTO_WRITE,
@ -2165,7 +2169,7 @@ void Foam::meshRefinement::dumpRefinementLevel() const
IOobject IOobject
( (
"pointLevel", "pointLevel",
timeName(), mesh_.time().timeName(),// Dump to current time, not to mesh inst
mesh_, mesh_,
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE, IOobject::NO_WRITE,

View File

@ -517,11 +517,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::createBaffles
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
//- Redo the intersections on the newly create baffle faces. Note that //- Redo the intersections on the newly create baffle faces. Note that
// this changes also the cell centre positions. // this changes also the cell centre positions.
faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles); faceSet baffledFacesSet(mesh_, "baffledFacesSet", 2*nBaffles);
@ -965,11 +960,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeBaffles
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Recalculate intersections on merged faces since // Update intersections. Recalculate intersections on merged faces since
// this seems to give problems? Note: should not be nessecary since // this seems to give problems? Note: should not be nessecary since
// baffles preserve intersections from when they were created. // baffles preserve intersections from when they were created.
@ -2249,11 +2239,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::dupNonManifoldPoints()
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersections. Is mapping only (no faces created, positions stay // Update intersections. Is mapping only (no faces created, positions stay
// same) so no need to recalculate intersections. // same) so no need to recalculate intersections.
updateMesh(map, labelList(0)); updateMesh(map, labelList(0));
@ -2783,11 +2768,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::zonify
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Print some stats (note: zones are synchronised) // Print some stats (note: zones are synchronised)
if (mesh_.cellZones().size() > 0) if (mesh_.cellZones().size() > 0)
{ {

View File

@ -103,11 +103,6 @@ Foam::label Foam::meshRefinement::mergePatchFaces
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
faceCombiner.updateMesh(map); faceCombiner.updateMesh(map);
// Get the kept faces that need to be recalculated. // Get the kept faces that need to be recalculated.
@ -203,11 +198,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
pointRemover.updateMesh(map); pointRemover.updateMesh(map);
// Get the kept faces that need to be recalculated. // Get the kept faces that need to be recalculated.

View File

@ -1236,11 +1236,6 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::refine
mesh_.clearOut(); mesh_.clearOut();
} }
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
// Update intersection info // Update intersection info
updateMesh(map, getChangedFaces(map, cellsToRefine)); updateMesh(map, getChangedFaces(map, cellsToRefine));

View File

@ -127,6 +127,7 @@ $(cellZoneSources)/setToCellZone/setToCellZone.C
pointZoneSources = sets/pointZoneSources pointZoneSources = sets/pointZoneSources
$(pointZoneSources)/setToPointZone/setToPointZone.C $(pointZoneSources)/setToPointZone/setToPointZone.C
momentOfInertia/momentOfInertia.C
surfaceSets/surfaceSets.C surfaceSets/surfaceSets.C

View File

@ -32,36 +32,25 @@ License
#include "PstreamCombineReduceOps.H" #include "PstreamCombineReduceOps.H"
#include "debug.H" #include "debug.H"
#include "typeInfo.H" #include "typeInfo.H"
#include "globalMeshData.H"
#include "pointFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template <class Type> template <class Type, class TrackingData>
Foam::scalar Foam::PointEdgeWave<Type>::propagationTol_ = 0.01; Foam::scalar Foam::PointEdgeWave<Type, TrackingData>::propagationTol_ = 0.01;
template <class Type, class TrackingData>
// Offset labelList. Used for transferring from one cyclic half to the other. Foam::label Foam::PointEdgeWave<Type, TrackingData>::dummyTrackData_ = 12345;
template <class Type>
void Foam::PointEdgeWave<Type>::offset(const label val, labelList& elems)
{
forAll(elems, i)
{
elems[i] += val;
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Gets point-point correspondence. Is
// - list of halfA points (in cyclic patch points)
// - list of halfB points (can overlap with A!)
// - for every patchPoint its corresponding point
// Handle leaving domain. Implementation referred to Type // Handle leaving domain. Implementation referred to Type
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::leaveDomain void Foam::PointEdgeWave<Type, TrackingData>::leaveDomain
( (
const polyPatch& meshPatch, const polyPatch& patch,
const primitivePatch& patch,
const labelList& patchPointLabels, const labelList& patchPointLabels,
List<Type>& pointInfo List<Type>& pointInfo
) const ) const
@ -74,17 +63,16 @@ void Foam::PointEdgeWave<Type>::leaveDomain
const point& pt = patch.points()[meshPoints[patchPointI]]; const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].leaveDomain(meshPatch, patchPointI, pt); pointInfo[i].leaveDomain(patch, patchPointI, pt, td_);
} }
} }
// Handle entering domain. Implementation referred to Type // Handle entering domain. Implementation referred to Type
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::enterDomain void Foam::PointEdgeWave<Type, TrackingData>::enterDomain
( (
const polyPatch& meshPatch, const polyPatch& patch,
const primitivePatch& patch,
const labelList& patchPointLabels, const labelList& patchPointLabels,
List<Type>& pointInfo List<Type>& pointInfo
) const ) const
@ -97,15 +85,16 @@ void Foam::PointEdgeWave<Type>::enterDomain
const point& pt = patch.points()[meshPoints[patchPointI]]; const point& pt = patch.points()[meshPoints[patchPointI]];
pointInfo[i].enterDomain(meshPatch, patchPointI, pt); pointInfo[i].enterDomain(patch, patchPointI, pt, td_);
} }
} }
// Transform. Implementation referred to Type // Transform. Implementation referred to Type
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::transform void Foam::PointEdgeWave<Type, TrackingData>::transform
( (
const polyPatch& patch,
const tensorField& rotTensor, const tensorField& rotTensor,
List<Type>& pointInfo List<Type>& pointInfo
) const ) const
@ -116,19 +105,22 @@ void Foam::PointEdgeWave<Type>::transform
forAll(pointInfo, i) forAll(pointInfo, i)
{ {
pointInfo[i].transform(T); pointInfo[i].transform(T, td_);
} }
} }
else else
{ {
FatalErrorIn FatalErrorIn
( (
"PointEdgeWave<Type>::transform(const tensorField&, List<Type>&)" "PointEdgeWave<Type, TrackingData>::transform"
) << "Parallel cyclics not supported" << abort(FatalError); "(const tensorField&, List<Type>&)"
) << "Non-uniform transformation on patch " << patch.name()
<< " not supported for point fields"
<< abort(FatalError);
forAll(pointInfo, i) forAll(pointInfo, i)
{ {
pointInfo[i].transform(rotTensor[i]); pointInfo[i].transform(rotTensor[i], td_);
} }
} }
} }
@ -139,19 +131,18 @@ void Foam::PointEdgeWave<Type>::transform
// Updates: // Updates:
// - changedPoint_, changedPoints_, nChangedPoints_, // - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_ // - statistics: nEvals_, nUnvisitedPoints_
template <class Type> template <class Type, class TrackingData>
bool Foam::PointEdgeWave<Type>::updatePoint bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
( (
const label pointI, const label pointI,
const label neighbourEdgeI, const label neighbourEdgeI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& pointInfo Type& pointInfo
) )
{ {
nEvals_++; nEvals_++;
bool wasValid = pointInfo.valid(); bool wasValid = pointInfo.valid(td_);
bool propagate = bool propagate =
pointInfo.updatePoint pointInfo.updatePoint
@ -160,7 +151,8 @@ bool Foam::PointEdgeWave<Type>::updatePoint
pointI, pointI,
neighbourEdgeI, neighbourEdgeI,
neighbourInfo, neighbourInfo,
tol propagationTol_,
td_
); );
if (propagate) if (propagate)
@ -172,7 +164,7 @@ bool Foam::PointEdgeWave<Type>::updatePoint
} }
} }
if (!wasValid && pointInfo.valid()) if (!wasValid && pointInfo.valid(td_))
{ {
--nUnvisitedPoints_; --nUnvisitedPoints_;
} }
@ -186,18 +178,17 @@ bool Foam::PointEdgeWave<Type>::updatePoint
// Updates: // Updates:
// - changedPoint_, changedPoints_, nChangedPoints_, // - changedPoint_, changedPoints_, nChangedPoints_,
// - statistics: nEvals_, nUnvisitedPoints_ // - statistics: nEvals_, nUnvisitedPoints_
template <class Type> template <class Type, class TrackingData>
bool Foam::PointEdgeWave<Type>::updatePoint bool Foam::PointEdgeWave<Type, TrackingData>::updatePoint
( (
const label pointI, const label pointI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& pointInfo Type& pointInfo
) )
{ {
nEvals_++; nEvals_++;
bool wasValid = pointInfo.valid(); bool wasValid = pointInfo.valid(td_);
bool propagate = bool propagate =
pointInfo.updatePoint pointInfo.updatePoint
@ -205,7 +196,8 @@ bool Foam::PointEdgeWave<Type>::updatePoint
mesh_, mesh_,
pointI, pointI,
neighbourInfo, neighbourInfo,
tol propagationTol_,
td_
); );
if (propagate) if (propagate)
@ -217,7 +209,7 @@ bool Foam::PointEdgeWave<Type>::updatePoint
} }
} }
if (!wasValid && pointInfo.valid()) if (!wasValid && pointInfo.valid(td_))
{ {
--nUnvisitedPoints_; --nUnvisitedPoints_;
} }
@ -231,19 +223,18 @@ bool Foam::PointEdgeWave<Type>::updatePoint
// Updates: // Updates:
// - changedEdge_, changedEdges_, nChangedEdges_, // - changedEdge_, changedEdges_, nChangedEdges_,
// - statistics: nEvals_, nUnvisitedEdge_ // - statistics: nEvals_, nUnvisitedEdge_
template <class Type> template <class Type, class TrackingData>
bool Foam::PointEdgeWave<Type>::updateEdge bool Foam::PointEdgeWave<Type, TrackingData>::updateEdge
( (
const label edgeI, const label edgeI,
const label neighbourPointI, const label neighbourPointI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& edgeInfo Type& edgeInfo
) )
{ {
nEvals_++; nEvals_++;
bool wasValid = edgeInfo.valid(); bool wasValid = edgeInfo.valid(td_);
bool propagate = bool propagate =
edgeInfo.updateEdge edgeInfo.updateEdge
@ -252,7 +243,8 @@ bool Foam::PointEdgeWave<Type>::updateEdge
edgeI, edgeI,
neighbourPointI, neighbourPointI,
neighbourInfo, neighbourInfo,
tol propagationTol_,
td_
); );
if (propagate) if (propagate)
@ -264,7 +256,7 @@ bool Foam::PointEdgeWave<Type>::updateEdge
} }
} }
if (!wasValid && edgeInfo.valid()) if (!wasValid && edgeInfo.valid(td_))
{ {
--nUnvisitedEdges_; --nUnvisitedEdges_;
} }
@ -274,9 +266,9 @@ bool Foam::PointEdgeWave<Type>::updateEdge
// Check if patches of given type name are present // Check if patches of given type name are present
template <class Type> template <class Type, class TrackingData>
template <class PatchType> template <class PatchType>
Foam::label Foam::PointEdgeWave<Type>::countPatchType() const Foam::label Foam::PointEdgeWave<Type, TrackingData>::countPatchType() const
{ {
label nPatches = 0; label nPatches = 0;
@ -291,199 +283,110 @@ Foam::label Foam::PointEdgeWave<Type>::countPatchType() const
} }
// Collect changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::getChangedPatchPoints
(
const primitivePatch& patch,
DynamicList<Type>& patchInfo,
DynamicList<label>& patchPoints,
DynamicList<label>& owner,
DynamicList<label>& ownerIndex
) const
{
const labelList& meshPoints = patch.meshPoints();
const faceList& localFaces = patch.localFaces();
const labelListList& pointFaces = patch.pointFaces();
forAll(meshPoints, patchPointI)
{
label meshPointI = meshPoints[patchPointI];
if (changedPoint_[meshPointI])
{
patchInfo.append(allPointInfo_[meshPointI]);
patchPoints.append(patchPointI);
label patchFaceI = pointFaces[patchPointI][0];
const face& f = localFaces[patchFaceI];
label index = findIndex(f, patchPointI);
owner.append(patchFaceI);
ownerIndex.append(index);
}
}
patchInfo.shrink();
patchPoints.shrink();
owner.shrink();
ownerIndex.shrink();
}
// Update overall for changed patch points
template <class Type>
void Foam::PointEdgeWave<Type>::updateFromPatchInfo
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& owner,
const labelList& ownerIndex,
List<Type>& patchInfo
)
{
const faceList& localFaces = patch.localFaces();
const labelList& meshPoints = patch.meshPoints();
// Get patch and mesh points.
labelList changedPatchPoints(patchInfo.size());
labelList changedMeshPoints(patchInfo.size());
forAll(owner, i)
{
label faceI = owner[i];
const face& f = localFaces[faceI];
label index = (f.size() - ownerIndex[i]) % f.size();
changedPatchPoints[i] = f[index];
changedMeshPoints[i] = meshPoints[f[index]];
}
// Adapt for entering domain
enterDomain(meshPatch, patch, changedPatchPoints, patchInfo);
// Merge received info
forAll(patchInfo, i)
{
updatePoint
(
changedMeshPoints[i],
patchInfo[i],
propagationTol_,
allPointInfo_[changedMeshPoints[i]]
);
}
}
// Transfer all the information to/from neighbouring processors // Transfer all the information to/from neighbouring processors
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::handleProcPatches() void Foam::PointEdgeWave<Type, TrackingData>::handleProcPatches()
{ {
// 1. Send all point info on processor patches. Send as // 1. Send all point info on processor patches.
// face label + offset in face.
forAll(mesh_.boundaryMesh(), patchI) PstreamBuffers pBufs(Pstream::nonBlocking);
DynamicList<Type> patchInfo;
DynamicList<label> thisPoints;
DynamicList<label> nbrPoints;
forAll(mesh_.globalData().processorPatches(), i)
{ {
const polyPatch& patch = mesh_.boundaryMesh()[patchI]; label patchI = mesh_.globalData().processorPatches()[i];
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
if (isA<processorPolyPatch>(patch)) patchInfo.clear();
patchInfo.reserve(procPatch.nPoints());
thisPoints.clear();
thisPoints.reserve(procPatch.nPoints());
nbrPoints.clear();
nbrPoints.reserve(procPatch.nPoints());
// Get all changed points in reverse order
const labelList& neighbPoints = procPatch.neighbPoints();
forAll(neighbPoints, thisPointI)
{ {
// Get all changed points in relative addressing label meshPointI = procPatch.meshPoints()[thisPointI];
if (changedPoint_[meshPointI])
DynamicList<Type> patchInfo(patch.nPoints());
DynamicList<label> patchPoints(patch.nPoints());
DynamicList<label> owner(patch.nPoints());
DynamicList<label> ownerIndex(patch.nPoints());
getChangedPatchPoints
(
patch,
patchInfo,
patchPoints,
owner,
ownerIndex
);
// Adapt for leaving domain
leaveDomain(patch, patch, patchPoints, patchInfo);
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(patch);
if (debug)
{ {
Pout<< "Processor patch " << patchI << ' ' << patch.name() patchInfo.append(allPointInfo_[meshPointI]);
<< " communicating with " << procPatch.neighbProcNo() thisPoints.append(thisPointI);
<< " Sending:" << patchInfo.size() << endl; nbrPoints.append(neighbPoints[thisPointI]);
}
{
OPstream toNeighbour
(
Pstream::blocking,
procPatch.neighbProcNo()
);
toNeighbour << owner << ownerIndex << patchInfo;
} }
} }
// Adapt for leaving domain
leaveDomain(procPatch, thisPoints, patchInfo);
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Sending:" << patchInfo.size() << endl;
}
UOPstream toNeighbour(procPatch.neighbProcNo(), pBufs);
toNeighbour << nbrPoints << patchInfo;
} }
pBufs.finishedSends();
// //
// 2. Receive all point info on processor patches. // 2. Receive all point info on processor patches.
// //
forAll(mesh_.boundaryMesh(), patchI) forAll(mesh_.globalData().processorPatches(), i)
{ {
const polyPatch& patch = mesh_.boundaryMesh()[patchI]; label patchI = mesh_.globalData().processorPatches()[i];
const processorPolyPatch& procPatch =
refCast<const processorPolyPatch>(mesh_.boundaryMesh()[patchI]);
List<Type> patchInfo;
labelList patchPoints;
if (isA<processorPolyPatch>(patch))
{ {
const processorPolyPatch& procPatch = UIPstream fromNeighbour(procPatch.neighbProcNo(), pBufs);
refCast<const processorPolyPatch>(patch); fromNeighbour >> patchPoints >> patchInfo;
}
List<Type> patchInfo; if (debug)
labelList owner; {
labelList ownerIndex; Pout<< "Processor patch " << patchI << ' ' << procPatch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Received:" << patchInfo.size() << endl;
}
// Apply transform to received data for non-parallel planes
if (!procPatch.parallel())
{
transform(procPatch, procPatch.forwardT(), patchInfo);
}
// Adapt for entering domain
enterDomain(procPatch, patchPoints, patchInfo);
// Merge received info
const labelList& meshPoints = procPatch.meshPoints();
forAll(patchInfo, i)
{
label meshPointI = meshPoints[patchPoints[i]];
if (!allPointInfo_[meshPointI].equal(patchInfo[i], td_))
{ {
IPstream fromNeighbour updatePoint
( (
Pstream::blocking, meshPointI,
procPatch.neighbProcNo() patchInfo[i],
allPointInfo_[meshPointI]
); );
fromNeighbour >> owner >> ownerIndex >> patchInfo;
} }
if (debug)
{
Pout<< "Processor patch " << patchI << ' ' << patch.name()
<< " communicating with " << procPatch.neighbProcNo()
<< " Received:" << patchInfo.size() << endl;
}
// Apply transform to received data for non-parallel planes
if (!procPatch.parallel())
{
transform(procPatch.forwardT(), patchInfo);
}
updateFromPatchInfo
(
patch,
patch,
owner,
ownerIndex,
patchInfo
);
} }
} }
@ -508,20 +411,21 @@ void Foam::PointEdgeWave<Type>::handleProcPatches()
// Combine on master. Reduce operator has to handle a list and call // Combine on master. Reduce operator has to handle a list and call
// Type.updatePoint for all elements // Type.updatePoint for all elements
combineReduce(sharedData, listUpdateOp<Type>()); combineReduce(sharedData, listUpdateOp<Type>(propagationTol_, td_));
forAll(pd.sharedPointLabels(), i) forAll(pd.sharedPointLabels(), i)
{ {
label meshPointI = pd.sharedPointLabels()[i]; label meshPointI = pd.sharedPointLabels()[i];
// Retrieve my entries from the shared points // Retrieve my entries from the shared points.
if (sharedData[pd.sharedPointAddr()[i]].valid()) const Type& nbrInfo = sharedData[pd.sharedPointAddr()[i]];
if (!allPointInfo_[meshPointI].equal(nbrInfo, td_))
{ {
updatePoint updatePoint
( (
meshPointI, meshPointI,
sharedData[pd.sharedPointAddr()[i]], nbrInfo,
propagationTol_,
allPointInfo_[meshPointI] allPointInfo_[meshPointI]
); );
} }
@ -529,11 +433,14 @@ void Foam::PointEdgeWave<Type>::handleProcPatches()
} }
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::handleCyclicPatches() void Foam::PointEdgeWave<Type, TrackingData>::handleCyclicPatches()
{ {
// 1. Send all point info on cyclic patches. Send as // 1. Send all point info on cyclic patches.
// face label + offset in face.
DynamicList<Type> nbrInfo;
DynamicList<label> nbrPoints;
DynamicList<label> thisPoints;
forAll(mesh_.boundaryMesh(), patchI) forAll(mesh_.boundaryMesh(), patchI)
{ {
@ -544,31 +451,44 @@ void Foam::PointEdgeWave<Type>::handleCyclicPatches()
const cyclicPolyPatch& cycPatch = const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patch); refCast<const cyclicPolyPatch>(patch);
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch(); nbrInfo.clear();
nbrInfo.reserve(cycPatch.nPoints());
nbrPoints.clear();
nbrPoints.reserve(cycPatch.nPoints());
thisPoints.clear();
thisPoints.reserve(cycPatch.nPoints());
DynamicList<Type> nbrInfo(nbrPatch.nPoints()); // Collect nbrPatch points that have changed
DynamicList<label> nbrPoints(nbrPatch.nPoints()); {
DynamicList<label> nbrOwner(nbrPatch.nPoints()); const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
DynamicList<label> nbrIndex(nbrPatch.nPoints()); const edgeList& pairs = cycPatch.coupledPoints();
const labelList& meshPoints = nbrPatch.meshPoints();
getChangedPatchPoints forAll(pairs, pairI)
( {
nbrPatch, label thisPointI = pairs[pairI][0];
nbrInfo, label nbrPointI = pairs[pairI][1];
nbrPoints, label meshPointI = meshPoints[nbrPointI];
nbrOwner,
nbrIndex if (changedPoint_[meshPointI])
); {
nbrInfo.append(allPointInfo_[meshPointI]);
nbrPoints.append(nbrPointI);
thisPoints.append(thisPointI);
}
}
// nbr : adapt for leaving domain
leaveDomain(nbrPatch, nbrPoints, nbrInfo);
}
// nbr : adapt for leaving domain
leaveDomain(nbrPatch, nbrPatch, nbrPoints, nbrInfo);
// Apply rotation for non-parallel planes // Apply rotation for non-parallel planes
if (!cycPatch.parallel()) if (!cycPatch.parallel())
{ {
// received data from half1 // received data from half1
transform(cycPatch.forwardT(), nbrInfo); transform(cycPatch, cycPatch.forwardT(), nbrInfo);
} }
if (debug) if (debug)
@ -578,19 +498,24 @@ void Foam::PointEdgeWave<Type>::handleCyclicPatches()
<< endl; << endl;
} }
// Half1: update with data from halfB // Adapt for entering domain
updateFromPatchInfo enterDomain(cycPatch, thisPoints, nbrInfo);
(
cycPatch,
cycPatch,
nbrOwner,
nbrIndex,
nbrInfo
);
if (debug) // Merge received info
const labelList& meshPoints = cycPatch.meshPoints();
forAll(nbrInfo, i)
{ {
//checkCyclic(patch); label meshPointI = meshPoints[thisPoints[i]];
if (!allPointInfo_[meshPointI].equal(nbrInfo[i], td_))
{
updatePoint
(
meshPointI,
nbrInfo[i],
allPointInfo_[meshPointI]
);
}
} }
} }
} }
@ -601,22 +526,24 @@ void Foam::PointEdgeWave<Type>::handleCyclicPatches()
// Iterate, propagating changedPointsInfo across mesh, until no change (or // Iterate, propagating changedPointsInfo across mesh, until no change (or
// maxIter reached). Initial point values specified. // maxIter reached). Initial point values specified.
template <class Type> template <class Type, class TrackingData>
Foam::PointEdgeWave<Type>::PointEdgeWave Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
( (
const polyMesh& mesh, const polyMesh& mesh,
const labelList& changedPoints, const labelList& changedPoints,
const List<Type>& changedPointsInfo, const List<Type>& changedPointsInfo,
List<Type>& allPointInfo, UList<Type>& allPointInfo,
List<Type>& allEdgeInfo, UList<Type>& allEdgeInfo,
const label maxIter const label maxIter,
TrackingData& td
) )
: :
mesh_(mesh), mesh_(mesh),
allPointInfo_(allPointInfo), allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo), allEdgeInfo_(allEdgeInfo),
td_(td),
changedPoint_(mesh_.nPoints(), false), changedPoint_(mesh_.nPoints(), false),
changedPoints_(mesh_.nPoints()), changedPoints_(mesh_.nPoints()),
nChangedPoints_(0), nChangedPoints_(0),
@ -632,7 +559,7 @@ Foam::PointEdgeWave<Type>::PointEdgeWave
{ {
FatalErrorIn FatalErrorIn
( (
"PointEdgeWave<Type>::PointEdgeWave" "PointEdgeWave<Type, TrackingData>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>," "(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)" " List<Type>&, List<Type>&, const label maxIter)"
) << "size of pointInfo work array is not equal to the number" ) << "size of pointInfo work array is not equal to the number"
@ -645,7 +572,7 @@ Foam::PointEdgeWave<Type>::PointEdgeWave
{ {
FatalErrorIn FatalErrorIn
( (
"PointEdgeWave<Type>::PointEdgeWave" "PointEdgeWave<Type, TrackingData>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>," "(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)" " List<Type>&, List<Type>&, const label maxIter)"
) << "size of edgeInfo work array is not equal to the number" ) << "size of edgeInfo work array is not equal to the number"
@ -671,7 +598,7 @@ Foam::PointEdgeWave<Type>::PointEdgeWave
{ {
FatalErrorIn FatalErrorIn
( (
"PointEdgeWave<Type>::PointEdgeWave" "PointEdgeWave<Type, TrackingData>::PointEdgeWave"
"(const polyMesh&, const labelList&, const List<Type>," "(const polyMesh&, const labelList&, const List<Type>,"
" List<Type>&, List<Type>&, const label maxIter)" " List<Type>&, List<Type>&, const label maxIter)"
) << "Maximum number of iterations reached. Increase maxIter." << endl ) << "Maximum number of iterations reached. Increase maxIter." << endl
@ -683,17 +610,19 @@ Foam::PointEdgeWave<Type>::PointEdgeWave
} }
template <class Type> template <class Type, class TrackingData>
Foam::PointEdgeWave<Type>::PointEdgeWave Foam::PointEdgeWave<Type, TrackingData>::PointEdgeWave
( (
const polyMesh& mesh, const polyMesh& mesh,
List<Type>& allPointInfo, UList<Type>& allPointInfo,
List<Type>& allEdgeInfo UList<Type>& allEdgeInfo,
TrackingData& td
) )
: :
mesh_(mesh), mesh_(mesh),
allPointInfo_(allPointInfo), allPointInfo_(allPointInfo),
allEdgeInfo_(allEdgeInfo), allEdgeInfo_(allEdgeInfo),
td_(td),
changedPoint_(mesh_.nPoints(), false), changedPoint_(mesh_.nPoints(), false),
changedPoints_(mesh_.nPoints()), changedPoints_(mesh_.nPoints()),
nChangedPoints_(0), nChangedPoints_(0),
@ -709,31 +638,31 @@ Foam::PointEdgeWave<Type>::PointEdgeWave
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template <class Type> template <class Type, class TrackingData>
Foam::PointEdgeWave<Type>::~PointEdgeWave() Foam::PointEdgeWave<Type, TrackingData>::~PointEdgeWave()
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type> template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type>::getUnsetPoints() const Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetPoints() const
{ {
return nUnvisitedPoints_; return nUnvisitedPoints_;
} }
template <class Type> template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type>::getUnsetEdges() const Foam::label Foam::PointEdgeWave<Type, TrackingData>::getUnsetEdges() const
{ {
return nUnvisitedEdges_; return nUnvisitedEdges_;
} }
// Copy point information into member data // Copy point information into member data
template <class Type> template <class Type, class TrackingData>
void Foam::PointEdgeWave<Type>::setPointInfo void Foam::PointEdgeWave<Type, TrackingData>::setPointInfo
( (
const labelList& changedPoints, const labelList& changedPoints,
const List<Type>& changedPointsInfo const List<Type>& changedPointsInfo
@ -743,13 +672,13 @@ void Foam::PointEdgeWave<Type>::setPointInfo
{ {
label pointI = changedPoints[changedPointI]; label pointI = changedPoints[changedPointI];
bool wasValid = allPointInfo_[pointI].valid(); bool wasValid = allPointInfo_[pointI].valid(td_);
// Copy info for pointI // Copy info for pointI
allPointInfo_[pointI] = changedPointsInfo[changedPointI]; allPointInfo_[pointI] = changedPointsInfo[changedPointI];
// Maintain count of unset points // Maintain count of unset points
if (!wasValid && allPointInfo_[pointI].valid()) if (!wasValid && allPointInfo_[pointI].valid(td_))
{ {
--nUnvisitedPoints_; --nUnvisitedPoints_;
} }
@ -766,8 +695,8 @@ void Foam::PointEdgeWave<Type>::setPointInfo
// Propagate information from edge to point. Return number of points changed. // Propagate information from edge to point. Return number of points changed.
template <class Type> template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type>::edgeToPoint() Foam::label Foam::PointEdgeWave<Type, TrackingData>::edgeToPoint()
{ {
for for
( (
@ -780,7 +709,7 @@ Foam::label Foam::PointEdgeWave<Type>::edgeToPoint()
if (!changedEdge_[edgeI]) if (!changedEdge_[edgeI])
{ {
FatalErrorIn("PointEdgeWave<Type>::edgeToPoint()") FatalErrorIn("PointEdgeWave<Type, TrackingData>::edgeToPoint()")
<< "edge " << edgeI << "edge " << edgeI
<< " not marked as having been changed" << nl << " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same" << "This might be caused by multiple occurences of the same"
@ -797,14 +726,13 @@ Foam::label Foam::PointEdgeWave<Type>::edgeToPoint()
{ {
Type& currentWallInfo = allPointInfo_[e[eI]]; Type& currentWallInfo = allPointInfo_[e[eI]];
if (currentWallInfo != neighbourWallInfo) if (!currentWallInfo.equal(neighbourWallInfo, td_))
{ {
updatePoint updatePoint
( (
e[eI], e[eI],
edgeI, edgeI,
neighbourWallInfo, neighbourWallInfo,
propagationTol_,
currentWallInfo currentWallInfo
); );
} }
@ -843,8 +771,8 @@ Foam::label Foam::PointEdgeWave<Type>::edgeToPoint()
// Propagate information from point to edge. Return number of edges changed. // Propagate information from point to edge. Return number of edges changed.
template <class Type> template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type>::pointToEdge() Foam::label Foam::PointEdgeWave<Type, TrackingData>::pointToEdge()
{ {
const labelListList& pointEdges = mesh_.pointEdges(); const labelListList& pointEdges = mesh_.pointEdges();
@ -859,7 +787,7 @@ Foam::label Foam::PointEdgeWave<Type>::pointToEdge()
if (!changedPoint_[pointI]) if (!changedPoint_[pointI])
{ {
FatalErrorIn("PointEdgeWave<Type>::pointToEdge()") FatalErrorIn("PointEdgeWave<Type, TrackingData>::pointToEdge()")
<< "Point " << pointI << "Point " << pointI
<< " not marked as having been changed" << nl << " not marked as having been changed" << nl
<< "This might be caused by multiple occurences of the same" << "This might be caused by multiple occurences of the same"
@ -877,14 +805,13 @@ Foam::label Foam::PointEdgeWave<Type>::pointToEdge()
Type& currentWallInfo = allEdgeInfo_[edgeI]; Type& currentWallInfo = allEdgeInfo_[edgeI];
if (currentWallInfo != neighbourWallInfo) if (!currentWallInfo.equal(neighbourWallInfo, td_))
{ {
updateEdge updateEdge
( (
edgeI, edgeI,
pointI, pointI,
neighbourWallInfo, neighbourWallInfo,
propagationTol_,
currentWallInfo currentWallInfo
); );
} }
@ -912,8 +839,11 @@ Foam::label Foam::PointEdgeWave<Type>::pointToEdge()
// Iterate // Iterate
template <class Type> template <class Type, class TrackingData>
Foam::label Foam::PointEdgeWave<Type>::iterate(const label maxIter) Foam::label Foam::PointEdgeWave<Type, TrackingData>::iterate
(
const label maxIter
)
{ {
if (nCyclicPatches_ > 0) if (nCyclicPatches_ > 0)
{ {
@ -975,4 +905,5 @@ Foam::label Foam::PointEdgeWave<Type>::iterate(const label maxIter)
return iter; return iter;
} }
// ************************************************************************* // // ************************************************************************* //

View File

@ -58,13 +58,9 @@ SourceFiles
#ifndef PointEdgeWave_H #ifndef PointEdgeWave_H
#define PointEdgeWave_H #define PointEdgeWave_H
#include "label.H"
#include "boolList.H" #include "boolList.H"
#include "scalarField.H" #include "scalarField.H"
#include "pointFields.H" #include "tensorField.H"
#include "tensor.H"
#include "primitivePatch.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -73,7 +69,7 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
class polyMesh; class polyMesh;
class polyPatch;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class PointEdgeWaveName Declaration Class PointEdgeWaveName Declaration
@ -86,7 +82,7 @@ TemplateName(PointEdgeWave);
Class PointEdgeWave Declaration Class PointEdgeWave Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
template <class Type> template <class Type, class TrackingData = int>
class PointEdgeWave class PointEdgeWave
: :
public PointEdgeWaveName public PointEdgeWaveName
@ -98,6 +94,10 @@ class PointEdgeWave
// up to Type implementation) // up to Type implementation)
static scalar propagationTol_; static scalar propagationTol_;
//- Used as default trackdata value to satisfy default template
// argument.
static label dummyTrackData_;
// Private data // Private data
@ -105,10 +105,13 @@ class PointEdgeWave
const polyMesh& mesh_; const polyMesh& mesh_;
//- Wall information for all points //- Wall information for all points
List<Type>& allPointInfo_; UList<Type>& allPointInfo_;
//- Information on all mesh edges //- Information on all mesh edges
List<Type>& allEdgeInfo_; UList<Type>& allEdgeInfo_;
//- Additional data to be passed into container
TrackingData& td_;
//- Has point changed //- Has point changed
boolList changedPoint_; boolList changedPoint_;
@ -127,9 +130,6 @@ class PointEdgeWave
//- Number of cyclic patches //- Number of cyclic patches
label nCyclicPatches_; label nCyclicPatches_;
//- For every cyclic patch two primitivePatches
PtrList<primitivePatch> cycHalves_;
//- Number of evaluations //- Number of evaluations
label nEvals_; label nEvals_;
@ -140,15 +140,10 @@ class PointEdgeWave
// Private Member Functions // Private Member Functions
//- Add value to all elements of labelList
static void offset(const label val, labelList& elems);
//- Adapt pointInfo for leaving domain //- Adapt pointInfo for leaving domain
void leaveDomain void leaveDomain
( (
const polyPatch& meshPatch, const polyPatch&,
const primitivePatch& patch,
const List<label>& patchPointLabels, const List<label>& patchPointLabels,
List<Type>& pointInfo List<Type>& pointInfo
) const; ) const;
@ -156,8 +151,7 @@ class PointEdgeWave
//- Adapt pointInfo for entering domain //- Adapt pointInfo for entering domain
void enterDomain void enterDomain
( (
const polyPatch& meshPatch, const polyPatch&,
const primitivePatch& patch,
const List<label>& patchPointLabels, const List<label>& patchPointLabels,
List<Type>& pointInfo List<Type>& pointInfo
) const; ) const;
@ -165,6 +159,7 @@ class PointEdgeWave
//- Transform. Implementation referred to Type //- Transform. Implementation referred to Type
void transform void transform
( (
const polyPatch& patch,
const tensorField& rotTensor, const tensorField& rotTensor,
List<Type>& pointInfo List<Type>& pointInfo
) const; ) const;
@ -176,7 +171,6 @@ class PointEdgeWave
const label pointI, const label pointI,
const label neighbourEdgeI, const label neighbourEdgeI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& pointInfo Type& pointInfo
); );
@ -186,7 +180,6 @@ class PointEdgeWave
( (
const label pointI, const label pointI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& pointInfo Type& pointInfo
); );
@ -197,7 +190,6 @@ class PointEdgeWave
const label edgeI, const label edgeI,
const label neighbourPointI, const label neighbourPointI,
const Type& neighbourInfo, const Type& neighbourInfo,
const scalar tol,
Type& edgeInfo Type& edgeInfo
); );
@ -207,26 +199,6 @@ class PointEdgeWave
template <class PatchType> template <class PatchType>
label countPatchType() const; label countPatchType() const;
//- Get info on patch points
void getChangedPatchPoints
(
const primitivePatch& patch,
DynamicList<Type>& patchInfo,
DynamicList<label>& patchPoints,
DynamicList<label>& owner,
DynamicList<label>& ownerIndex
) const;
//- Merge data from patch into overall data
void updateFromPatchInfo
(
const polyPatch& meshPatch,
const primitivePatch& patch,
const labelList& owner,
const labelList& ownerIndex,
List<Type>& patchInfo
);
//- Merge data from across processor boundaries //- Merge data from across processor boundaries
void handleProcPatches(); void handleProcPatches();
@ -270,9 +242,10 @@ public:
const polyMesh& mesh, const polyMesh& mesh,
const labelList& initialPoints, const labelList& initialPoints,
const List<Type>& initialPointsInfo, const List<Type>& initialPointsInfo,
List<Type>& allPointInfo, UList<Type>& allPointInfo,
List<Type>& allEdgeInfo, UList<Type>& allEdgeInfo,
const label maxIter const label maxIter,
TrackingData& td = dummyTrackData_
); );
//- Construct from mesh. Use setPointInfo and iterate() to do //- Construct from mesh. Use setPointInfo and iterate() to do
@ -280,8 +253,9 @@ public:
PointEdgeWave PointEdgeWave
( (
const polyMesh& mesh, const polyMesh& mesh,
List<Type>& allPointInfo, UList<Type>& allPointInfo,
List<Type>& allEdgeInfo UList<Type>& allEdgeInfo,
TrackingData& td = dummyTrackData_
); );
@ -291,18 +265,24 @@ public:
// Member Functions // Member Functions
//- Get allPointInfo //- Access allPointInfo
const List<Type>& allPointInfo() const UList<Type>& allPointInfo() const
{ {
return allPointInfo_; return allPointInfo_;
} }
//- Get allEdgeInfo //- Access allEdgeInfo
const List<Type>& allEdgeInfo() const UList<Type>& allEdgeInfo() const
{ {
return allEdgeInfo_; return allEdgeInfo_;
} }
//- Additional data to be passed into container
const TrackingData& data() const
{
return td_;
}
//- Get number of unvisited edges, i.e. edges that were not (yet) //- Get number of unvisited edges, i.e. edges that were not (yet)
// reached from walking across mesh. This can happen from // reached from walking across mesh. This can happen from
// - not enough iterations done // - not enough iterations done
@ -340,19 +320,29 @@ public:
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
//- List update operation //- List update operation
template <class Type> template <class Type, class TrackingData = int>
class listUpdateOp class listUpdateOp
{ {
//- Additional data to be passed into container
const scalar tol_;
TrackingData& td_;
public: public:
listUpdateOp(const scalar tol, TrackingData& td)
:
tol_(tol),
td_(td)
{}
void operator()(List<Type>& x, const List<Type>& y) const void operator()(List<Type>& x, const List<Type>& y) const
{ {
forAll(x, i) forAll(x, i)
{ {
if (y[i].valid()) if (y[i].valid(td_))
{ {
x[i].updatePoint(y[i], PointEdgeWave<Type>::propagationTol()); x[i].updatePoint(y[i], tol_, td_);
} }
} }
} }

View File

@ -73,19 +73,23 @@ class pointEdgePoint
//- Evaluate distance to point. Update distSqr, origin from whomever //- Evaluate distance to point. Update distSqr, origin from whomever
// is nearer pt. Return true if w2 is closer to point, // is nearer pt. Return true if w2 is closer to point,
// false otherwise. // false otherwise.
template<class TrackingData>
inline bool update inline bool update
( (
const point&, const point&,
const pointEdgePoint& w2, const pointEdgePoint& w2,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Combine current with w2. Update distSqr, origin if w2 has smaller //- Combine current with w2. Update distSqr, origin if w2 has smaller
// quantities and returns true. // quantities and returns true.
template<class TrackingData>
inline bool update inline bool update
( (
const pointEdgePoint& w2, const pointEdgePoint& w2,
const scalar tol const scalar tol,
TrackingData& td
); );
@ -97,7 +101,7 @@ public:
inline pointEdgePoint(); inline pointEdgePoint();
//- Construct from origin, distance //- Construct from origin, distance
inline pointEdgePoint(const point& origin, const scalar distSqr); inline pointEdgePoint(const point&, const scalar);
//- Construct as copy //- Construct as copy
inline pointEdgePoint(const pointEdgePoint&); inline pointEdgePoint(const pointEdgePoint&);
@ -116,76 +120,102 @@ public:
//- Check whether origin has been changed at all or //- Check whether origin has been changed at all or
// still contains original (invalid) value. // still contains original (invalid) value.
inline bool valid() const; template<class TrackingData>
inline bool valid(TrackingData& td) const;
//- Check for identical geometrical data. Used for cyclics checking. //- Check for identical geometrical data. Used for cyclics checking.
inline bool sameGeometry(const pointEdgePoint&, const scalar tol) template<class TrackingData>
const; inline bool sameGeometry
(
const pointEdgePoint&,
const scalar tol,
TrackingData& td
) const;
//- Convert origin to relative vector to leaving point //- Convert origin to relative vector to leaving point
// (= point coordinate) // (= point coordinate)
template<class TrackingData>
inline void leaveDomain inline void leaveDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& pos const point& pos,
TrackingData& td
); );
//- Convert relative origin to absolute by adding entering point //- Convert relative origin to absolute by adding entering point
template<class TrackingData>
inline void enterDomain inline void enterDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& pos const point& pos,
TrackingData& td
); );
//- Apply rotation matrix to origin //- Apply rotation matrix to origin
inline void transform(const tensor& rotTensor); template<class TrackingData>
inline void transform
(
const tensor& rotTensor,
TrackingData& td
);
//- Influence of edge on point //- Influence of edge on point
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointEdgePoint& edgeInfo, const pointEdgePoint& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// Merge new and old info. // Merge new and old info.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointEdgePoint& newPointInfo, const pointEdgePoint& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of different value on same point. //- Influence of different value on same point.
// No information about current position whatsoever. // No information about current position whatsoever.
template<class TrackingData>
inline bool updatePoint inline bool updatePoint
( (
const pointEdgePoint& newPointInfo, const pointEdgePoint& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Influence of point on edge. //- Influence of point on edge.
template<class TrackingData>
inline bool updateEdge inline bool updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointEdgePoint& pointInfo, const pointEdgePoint& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
); );
//- Same (like operator==)
template<class TrackingData>
inline bool equal(const pointEdgePoint&, TrackingData& td) const;
// Member Operators // Member Operators
//Note: Used to determine whether to call update. // Needed for List IO
inline bool operator==(const pointEdgePoint&) const; inline bool operator==(const pointEdgePoint&) const;
inline bool operator!=(const pointEdgePoint&) const; inline bool operator!=(const pointEdgePoint&) const;

View File

@ -29,16 +29,18 @@ License
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2 if w2 nearer to pt. // Update this with w2 if w2 nearer to pt.
template<class TrackingData>
inline bool Foam::pointEdgePoint::update inline bool Foam::pointEdgePoint::update
( (
const point& pt, const point& pt,
const pointEdgePoint& w2, const pointEdgePoint& w2,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
scalar dist2 = magSqr(pt - w2.origin()); scalar dist2 = magSqr(pt - w2.origin());
if (!valid()) if (!valid(td))
{ {
// current not yet set so use any value // current not yet set so use any value
distSqr_ = dist2; distSqr_ = dist2;
@ -72,13 +74,15 @@ inline bool Foam::pointEdgePoint::update
// Update this with w2 (information on same point) // Update this with w2 (information on same point)
template<class TrackingData>
inline bool Foam::pointEdgePoint::update inline bool Foam::pointEdgePoint::update
( (
const pointEdgePoint& w2, const pointEdgePoint& w2,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
if (!valid()) if (!valid(td))
{ {
// current not yet set so use any value // current not yet set so use any value
distSqr_ = w2.distSqr(); distSqr_ = w2.distSqr();
@ -155,17 +159,20 @@ inline Foam::scalar Foam::pointEdgePoint::distSqr() const
} }
inline bool Foam::pointEdgePoint::valid() const template<class TrackingData>
inline bool Foam::pointEdgePoint::valid(TrackingData& td) const
{ {
return origin_ != point::max; return origin_ != point::max;
} }
// Checks for cyclic points // Checks for cyclic points
template<class TrackingData>
inline bool Foam::pointEdgePoint::sameGeometry inline bool Foam::pointEdgePoint::sameGeometry
( (
const pointEdgePoint& w2, const pointEdgePoint& w2,
const scalar tol const scalar tol,
TrackingData& td
) const ) const
{ {
scalar diff = Foam::mag(distSqr() - w2.distSqr()); scalar diff = Foam::mag(distSqr() - w2.distSqr());
@ -188,18 +195,25 @@ inline bool Foam::pointEdgePoint::sameGeometry
} }
template<class TrackingData>
inline void Foam::pointEdgePoint::leaveDomain inline void Foam::pointEdgePoint::leaveDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& coord const point& coord,
TrackingData& td
) )
{ {
origin_ -= coord; origin_ -= coord;
} }
inline void Foam::pointEdgePoint::transform(const tensor& rotTensor) template<class TrackingData>
inline void Foam::pointEdgePoint::transform
(
const tensor& rotTensor,
TrackingData& td
)
{ {
origin_ = Foam::transform(rotTensor, origin_); origin_ = Foam::transform(rotTensor, origin_);
} }
@ -207,11 +221,13 @@ inline void Foam::pointEdgePoint::transform(const tensor& rotTensor)
// Update absolute geometric quantities. Note that distance (distSqr_) // Update absolute geometric quantities. Note that distance (distSqr_)
// is not affected by leaving/entering domain. // is not affected by leaving/entering domain.
template<class TrackingData>
inline void Foam::pointEdgePoint::enterDomain inline void Foam::pointEdgePoint::enterDomain
( (
const polyPatch& patch, const polyPatch& patch,
const label patchPointI, const label patchPointI,
const point& coord const point& coord,
TrackingData& td
) )
{ {
// back to absolute form // back to absolute form
@ -220,78 +236,74 @@ inline void Foam::pointEdgePoint::enterDomain
// Update this with information from connected edge // Update this with information from connected edge
template<class TrackingData>
inline bool Foam::pointEdgePoint::updatePoint inline bool Foam::pointEdgePoint::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const label edgeI, const label edgeI,
const pointEdgePoint& edgeInfo, const pointEdgePoint& edgeInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return return update(mesh.points()[pointI], edgeInfo, tol, td);
update
(
mesh.points()[pointI],
edgeInfo,
tol
);
} }
// Update this with new information on same point // Update this with new information on same point
template<class TrackingData>
inline bool Foam::pointEdgePoint::updatePoint inline bool Foam::pointEdgePoint::updatePoint
( (
const polyMesh& mesh, const polyMesh& mesh,
const label pointI, const label pointI,
const pointEdgePoint& newPointInfo, const pointEdgePoint& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return return update(mesh.points()[pointI], newPointInfo, tol, td);
update
(
mesh.points()[pointI],
newPointInfo,
tol
);
} }
// Update this with new information on same point. No extra information. // Update this with new information on same point. No extra information.
template<class TrackingData>
inline bool Foam::pointEdgePoint::updatePoint inline bool Foam::pointEdgePoint::updatePoint
( (
const pointEdgePoint& newPointInfo, const pointEdgePoint& newPointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
return update(newPointInfo, tol); return update(newPointInfo, tol, td);
} }
// Update this with information from connected point // Update this with information from connected point
template<class TrackingData>
inline bool Foam::pointEdgePoint::updateEdge inline bool Foam::pointEdgePoint::updateEdge
( (
const polyMesh& mesh, const polyMesh& mesh,
const label edgeI, const label edgeI,
const label pointI, const label pointI,
const pointEdgePoint& pointInfo, const pointEdgePoint& pointInfo,
const scalar tol const scalar tol,
TrackingData& td
) )
{ {
const pointField& points = mesh.points();
const edge& e = mesh.edges()[edgeI]; const edge& e = mesh.edges()[edgeI];
return update(e.centre(mesh.points()), pointInfo, tol, td);
}
const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
return template <class TrackingData>
update inline bool Foam::pointEdgePoint::equal
( (
edgeMid, const pointEdgePoint& rhs,
pointInfo, TrackingData& td
tol ) const
); {
return operator==(rhs);
} }

View File

@ -21,382 +21,328 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class \*---------------------------------------------------------------------------*/
momentOfInertia
Description
Reimplementation of volInt.c by Brian Mirtich.
* mirtich@cs.berkeley.edu *
* http://www.cs.berkeley.edu/~mirtich *
-------------------------------------------------------------------------------
*/
#include "momentOfInertia.H" #include "momentOfInertia.H"
//#include "pyramidPointFaceRef.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
//Foam::tensor Foam::momentOfInertia void Foam::momentOfInertia::massPropertiesSolid
//(
// const pointField& points,
// const faceList& faces,
// const cell& cFaces,
// const point& cc
//)
//{
// tensor t(tensor::zero);
//
// forAll(cFaces, i)
// {
// const face& f = faces[cFaces[i]];
//
// scalar pyrVol = pyramidPointFaceRef(f, cc).mag(points);
//
// vector pyrCentre = pyramidPointFaceRef(f, cc).centre(points);
//
// vector d = pyrCentre - cc;
//
// t.xx() += pyrVol*(sqr(d.y()) + sqr(d.z()));
// t.yy() += pyrVol*(sqr(d.x()) + sqr(d.z()));
// t.zz() += pyrVol*(sqr(d.x()) + sqr(d.y()));
//
// t.xy() -= pyrVol*d.x()*d.y();
// t.xz() -= pyrVol*d.x()*d.z();
// t.yz() -= pyrVol*d.y()*d.z();
// }
//
// // Symmetric
// t.yx() = t.xy();
// t.zx() = t.xz();
// t.zy() = t.yz();
//
// return t;
//}
#define sqr(x) ((x)*(x))
#define pow3(x) ((x)*(x)*(x))
// compute various integrations over projection of face
void Foam::compProjectionIntegrals
( (
const pointField& points, const pointField& pts,
const face& f, const triFaceList& triFaces,
const direction A, scalar density,
const direction B, scalar& mass,
vector& cM,
scalar& P1,
scalar& Pa,
scalar& Pb,
scalar& Paa,
scalar& Pab,
scalar& Pbb,
scalar& Paaa,
scalar& Paab,
scalar& Pabb,
scalar& Pbbb
)
{
P1 = Pa = Pb = Paa = Pab = Pbb = Paaa = Paab = Pabb = Pbbb = 0.0;
forAll(f, i)
{
scalar a0 = points[f[i]][A];
scalar b0 = points[f[i]][B];
scalar a1 = points[f[(i+1) % f.size()]][A];
scalar b1 = points[f[(i+1) % f.size()]][B];
scalar da = a1 - a0;
scalar db = b1 - b0;
scalar a0_2 = a0 * a0;
scalar a0_3 = a0_2 * a0;
scalar a0_4 = a0_3 * a0;
scalar b0_2 = b0 * b0;
scalar b0_3 = b0_2 * b0;
scalar b0_4 = b0_3 * b0;
scalar a1_2 = a1 * a1;
scalar a1_3 = a1_2 * a1;
scalar b1_2 = b1 * b1;
scalar b1_3 = b1_2 * b1;
scalar C1 = a1 + a0;
scalar Ca = a1*C1 + a0_2;
scalar Caa = a1*Ca + a0_3;
scalar Caaa = a1*Caa + a0_4;
scalar Cb = b1*(b1 + b0) + b0_2;
scalar Cbb = b1*Cb + b0_3;
scalar Cbbb = b1*Cbb + b0_4;
scalar Cab = 3*a1_2 + 2*a1*a0 + a0_2;
scalar Kab = a1_2 + 2*a1*a0 + 3*a0_2;
scalar Caab = a0*Cab + 4*a1_3;
scalar Kaab = a1*Kab + 4*a0_3;
scalar Cabb = 4*b1_3 + 3*b1_2*b0 + 2*b1*b0_2 + b0_3;
scalar Kabb = b1_3 + 2*b1_2*b0 + 3*b1*b0_2 + 4*b0_3;
P1 += db*C1;
Pa += db*Ca;
Paa += db*Caa;
Paaa += db*Caaa;
Pb += da*Cb;
Pbb += da*Cbb;
Pbbb += da*Cbbb;
Pab += db*(b1*Cab + b0*Kab);
Paab += db*(b1*Caab + b0*Kaab);
Pabb += da*(a1*Cabb + a0*Kabb);
}
P1 /= 2.0;
Pa /= 6.0;
Paa /= 12.0;
Paaa /= 20.0;
Pb /= -6.0;
Pbb /= -12.0;
Pbbb /= -20.0;
Pab /= 24.0;
Paab /= 60.0;
Pabb /= -60.0;
}
void Foam::compFaceIntegrals
(
const pointField& points,
const face& f,
const vector& n,
const scalar w,
const direction A,
const direction B,
const direction C,
scalar& Fa,
scalar& Fb,
scalar& Fc,
scalar& Faa,
scalar& Fbb,
scalar& Fcc,
scalar& Faaa,
scalar& Fbbb,
scalar& Fccc,
scalar& Faab,
scalar& Fbbc,
scalar& Fcca
)
{
scalar P1, Pa, Pb, Paa, Pab, Pbb, Paaa, Paab, Pabb, Pbbb;
compProjectionIntegrals
(
points,
f,
A,
B,
P1,
Pa,
Pb,
Paa,
Pab,
Pbb,
Paaa,
Paab,
Pabb,
Pbbb
);
scalar k1 = 1 / n[C];
scalar k2 = k1 * k1;
scalar k3 = k2 * k1;
scalar k4 = k3 * k1;
Fa = k1 * Pa;
Fb = k1 * Pb;
Fc = -k2 * (n[A]*Pa + n[B]*Pb + w*P1);
Faa = k1 * Paa;
Fbb = k1 * Pbb;
Fcc = k3 * (sqr(n[A])*Paa + 2*n[A]*n[B]*Pab + sqr(n[B])*Pbb
+ w*(2*(n[A]*Pa + n[B]*Pb) + w*P1));
Faaa = k1 * Paaa;
Fbbb = k1 * Pbbb;
Fccc = -k4 * (pow3(n[A])*Paaa + 3*sqr(n[A])*n[B]*Paab
+ 3*n[A]*sqr(n[B])*Pabb + pow3(n[B])*Pbbb
+ 3*w*(sqr(n[A])*Paa + 2*n[A]*n[B]*Pab + sqr(n[B])*Pbb)
+ w*w*(3*(n[A]*Pa + n[B]*Pb) + w*P1));
Faab = k1 * Paab;
Fbbc = -k2 * (n[A]*Pabb + n[B]*Pbbb + w*Pbb);
Fcca = k3 * (sqr(n[A])*Paaa + 2*n[A]*n[B]*Paab + sqr(n[B])*Pabb
+ w*(2*(n[A]*Paa + n[B]*Pab) + w*Pa));
}
void Foam::compVolumeIntegrals
(
const pointField& points,
const faceList& faces,
const cell& cFaces,
const vectorField& fNorm,
const scalarField& fW,
scalar& T0,
vector& T1,
vector& T2,
vector& TP
)
{
T0 = 0;
T1 = vector::zero;
T2 = vector::zero;
TP = vector::zero;
forAll(cFaces, i)
{
const vector& n = fNorm[i];
scalar nx = mag(n[0]);
scalar ny = mag(n[1]);
scalar nz = mag(n[2]);
direction A, B, C;
if (nx > ny && nx > nz)
{
C = 0;
}
else
{
C = (ny > nz) ? 1 : 2;
}
A = (C + 1) % 3;
B = (A + 1) % 3;
scalar Fa, Fb, Fc, Faa, Fbb, Fcc, Faaa, Fbbb, Fccc, Faab, Fbbc, Fcca;
compFaceIntegrals
(
points,
faces[cFaces[i]],
n,
fW[i],
A,
B,
C,
Fa,
Fb,
Fc,
Faa,
Fbb,
Fcc,
Faaa,
Fbbb,
Fccc,
Faab,
Fbbc,
Fcca
);
T0 += n[0] * ((A == 0) ? Fa : ((B == 0) ? Fb : Fc));
T1[A] += n[A] * Faa;
T1[B] += n[B] * Fbb;
T1[C] += n[C] * Fcc;
T2[A] += n[A] * Faaa;
T2[B] += n[B] * Fbbb;
T2[C] += n[C] * Fccc;
TP[A] += n[A] * Faab;
TP[B] += n[B] * Fbbc;
TP[C] += n[C] * Fcca;
}
T1 /= 2;
T2 /= 3;
TP /= 2;
}
// Calculate
// - r: centre of mass
// - J: inertia around origin (point 0,0,0)
void Foam::momentOfIntertia
(
const pointField& points,
const faceList& faces,
const cell& cFaces,
point& r,
tensor& J tensor& J
) )
{ {
// Face normals // Reimplemented from: Wm4PolyhedralMassProperties.cpp
vectorField fNorm(cFaces.size()); // File Version: 4.10.0 (2009/11/18)
scalarField fW(cFaces.size());
forAll(cFaces, i) // Geometric Tools, LC
// Copyright (c) 1998-2010
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
// http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
// Boost Software License - Version 1.0 - August 17th, 2003
// Permission is hereby granted, free of charge, to any person or
// organization obtaining a copy of the software and accompanying
// documentation covered by this license (the "Software") to use,
// reproduce, display, distribute, execute, and transmit the
// Software, and to prepare derivative works of the Software, and
// to permit third-parties to whom the Software is furnished to do
// so, all subject to the following:
// The copyright notices in the Software and this entire
// statement, including the above license grant, this restriction
// and the following disclaimer, must be included in all copies of
// the Software, in whole or in part, and all derivative works of
// the Software, unless such copies or derivative works are solely
// in the form of machine-executable object code generated by a
// source language processor.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
// NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
// ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR
// OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
const scalar r6 = 1.0/6.0;
const scalar r24 = 1.0/24.0;
const scalar r60 = 1.0/60.0;
const scalar r120 = 1.0/120.0;
// order: 1, x, y, z, x^2, y^2, z^2, xy, yz, zx
scalarField integrals(10, 0.0);
forAll(triFaces, i)
{ {
label faceI = cFaces[i]; const triFace& tri(triFaces[i]);
const face& f = faces[faceI]; // vertices of triangle i
vector v0 = pts[tri[0]];
vector v1 = pts[tri[1]];
vector v2 = pts[tri[2]];
fNorm[i] = f.normal(points); // cross product of edges
fNorm[i] /= mag(fNorm[i]) + VSMALL; vector eA = v1 - v0;
vector eB = v2 - v0;
vector n = eA ^ eB;
fW[i] = - (fNorm[i] & points[f[0]]); // compute integral terms
scalar tmp0, tmp1, tmp2;
scalar f1x, f2x, f3x, g0x, g1x, g2x;
tmp0 = v0.x() + v1.x();
f1x = tmp0 + v2.x();
tmp1 = v0.x()*v0.x();
tmp2 = tmp1 + v1.x()*tmp0;
f2x = tmp2 + v2.x()*f1x;
f3x = v0.x()*tmp1 + v1.x()*tmp2 + v2.x()*f2x;
g0x = f2x + v0.x()*(f1x + v0.x());
g1x = f2x + v1.x()*(f1x + v1.x());
g2x = f2x + v2.x()*(f1x + v2.x());
scalar f1y, f2y, f3y, g0y, g1y, g2y;
tmp0 = v0.y() + v1.y();
f1y = tmp0 + v2.y();
tmp1 = v0.y()*v0.y();
tmp2 = tmp1 + v1.y()*tmp0;
f2y = tmp2 + v2.y()*f1y;
f3y = v0.y()*tmp1 + v1.y()*tmp2 + v2.y()*f2y;
g0y = f2y + v0.y()*(f1y + v0.y());
g1y = f2y + v1.y()*(f1y + v1.y());
g2y = f2y + v2.y()*(f1y + v2.y());
scalar f1z, f2z, f3z, g0z, g1z, g2z;
tmp0 = v0.z() + v1.z();
f1z = tmp0 + v2.z();
tmp1 = v0.z()*v0.z();
tmp2 = tmp1 + v1.z()*tmp0;
f2z = tmp2 + v2.z()*f1z;
f3z = v0.z()*tmp1 + v1.z()*tmp2 + v2.z()*f2z;
g0z = f2z + v0.z()*(f1z + v0.z());
g1z = f2z + v1.z()*(f1z + v1.z());
g2z = f2z + v2.z()*(f1z + v2.z());
// update integrals
integrals[0] += n.x()*f1x;
integrals[1] += n.x()*f2x;
integrals[2] += n.y()*f2y;
integrals[3] += n.z()*f2z;
integrals[4] += n.x()*f3x;
integrals[5] += n.y()*f3y;
integrals[6] += n.z()*f3z;
integrals[7] += n.x()*(v0.y()*g0x + v1.y()*g1x + v2.y()*g2x);
integrals[8] += n.y()*(v0.z()*g0y + v1.z()*g1y + v2.z()*g2y);
integrals[9] += n.z()*(v0.x()*g0z + v1.x()*g1z + v2.x()*g2z);
} }
integrals[0] *= r6;
integrals[1] *= r24;
integrals[2] *= r24;
integrals[3] *= r24;
integrals[4] *= r60;
integrals[5] *= r60;
integrals[6] *= r60;
integrals[7] *= r120;
integrals[8] *= r120;
integrals[9] *= r120;
scalar T0; // mass
vector T1, T2, TP; mass = integrals[0];
compVolumeIntegrals // center of mass
( cM = vector(integrals[1], integrals[2], integrals[3])/mass;
points,
faces,
cFaces,
fNorm,
fW,
T0, // inertia relative to origin
T1, J.xx() = integrals[5] + integrals[6];
T2, J.xy() = -integrals[7];
TP J.xz() = -integrals[9];
); J.yx() = J.xy();
J.yy() = integrals[4] + integrals[6];
J.yz() = -integrals[8];
J.zx() = J.xz();
J.zy() = J.yz();
J.zz() = integrals[4] + integrals[5];
const scalar density = 1.0; /* assume unit density */ // inertia relative to center of mass
J -= mass*((cM & cM)*I - cM*cM);
scalar mass = density * T0; // Apply density
mass *= density;
/* compute center of mass */ J *= density;
r = T1 / T0;
/* compute inertia tensor */
J.xx() = density * (T2[1] + T2[2]);
J.yy() = density * (T2[2] + T2[0]);
J.zz() = density * (T2[0] + T2[1]);
J.xy() = J.yx() = - density * TP[0];
J.yz() = J.zy() = - density * TP[1];
J.zx() = J.xz() = - density * TP[2];
///* translate inertia tensor to center of mass */
//J[XX] -= mass * (r[1]*r[1] + r[2]*r[2]);
//J[YY] -= mass * (r[2]*r[2] + r[0]*r[0]);
//J[ZZ] -= mass * (r[0]*r[0] + r[1]*r[1]);
//J[XY] = J[YX] += mass * r[0] * r[1];
//J[YZ] = J[ZY] += mass * r[1] * r[2];
//J[ZX] = J[XZ] += mass * r[2] * r[0];
} }
void Foam::momentOfInertia::massPropertiesShell
(
const pointField& pts,
const triFaceList& triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
// Reset properties for accumulation
mass = 0.0;
cM = vector::zero;
J = tensor::zero;
// Find centre of mass
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
triPointRef t
(
pts[tri[0]],
pts[tri[1]],
pts[tri[2]]
);
scalar triMag = t.mag();
cM += triMag*t.centre();
mass += triMag;
}
cM /= mass;
mass *= density;
// Find inertia around centre of mass
forAll(triFaces, i)
{
const triFace& tri(triFaces[i]);
J += triPointRef
(
pts[tri[0]],
pts[tri[1]],
pts[tri[2]]
).inertia(cM, density);
}
}
void Foam::momentOfInertia::massPropertiesSolid
(
const triSurface& surf,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
triFaceList faces(surf.size());
forAll(surf, i)
{
faces[i] = triFace(surf[i]);
}
massPropertiesSolid(surf.points(), faces, density, mass, cM, J);
}
void Foam::momentOfInertia::massPropertiesShell
(
const triSurface& surf,
scalar density,
scalar& mass,
vector& cM,
tensor& J
)
{
triFaceList faces(surf.size());
forAll(surf, i)
{
faces[i] = triFace(surf[i]);
}
massPropertiesShell(surf.points(), faces, density, mass, cM, J);
}
Foam::tensor Foam::momentOfInertia::applyParallelAxisTheorem
(
scalar mass,
const vector& cM,
const tensor& J,
const vector& refPt
)
{
// The displacement vector (refPt = cM) is the displacement of the
// new reference point from the centre of mass of the body that
// the inertia tensor applies to.
vector d = (refPt - cM);
return J + mass*((d & d)*I - d*d);
}
Foam::tmp<Foam::tensorField> Foam::momentOfInertia::meshInertia
(
const polyMesh& mesh
)
{
tmp<tensorField> tTf = tmp<tensorField>(new tensorField(mesh.nCells()));
tensorField& tf = tTf();
forAll(tf, cI)
{
tf[cI] = meshInertia(mesh, cI);
}
return tTf;
}
Foam::tensor Foam::momentOfInertia::meshInertia
(
const polyMesh& mesh,
label cellI
)
{
List<tetIndices> cellTets = polyMeshTetDecomposition::cellTetIndices
(
mesh,
cellI
);
triFaceList faces(cellTets.size());
forAll(cellTets, cTI)
{
faces[cTI] = cellTets[cTI].faceTriIs(mesh);
}
scalar m = 0.0;
vector cM = vector::zero;
tensor J = tensor::zero;
massPropertiesSolid(mesh.points(), faces, 1.0, m, cM, J);
return J;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -25,6 +25,9 @@ Class
momentOfInertia momentOfInertia
Description Description
Calculates the inertia tensor and principal axes and moments of a
polyhedra/cells/triSurfaces. Inertia can either be of the solid body or
of a thin shell.
SourceFiles SourceFiles
momentOfInertia.H momentOfInertia.H
@ -34,34 +37,86 @@ SourceFiles
#ifndef momentOfInertia_H #ifndef momentOfInertia_H
#define momentOfInertia_H #define momentOfInertia_H
#include "tensor.H" #include "tetPointRef.H"
#include "primitiveMesh.H" #include "triFaceList.H"
#include "triSurface.H"
#include "polyMesh.H"
#include "polyMeshTetDecomposition.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
////- Moment of inertia around cell centre for single cell. /*---------------------------------------------------------------------------*\
//tensor momentOfInertia Class momentOfInertia Declaration
//( \*---------------------------------------------------------------------------*/
// const pointField&,
// const faceList&, class momentOfInertia
// const cell&, {
// const point& cc
//); public:
static void massPropertiesSolid
(
const pointField& pts,
const triFaceList& triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
);
static void massPropertiesShell
(
const pointField& pts,
const triFaceList& triFaces,
scalar density,
scalar& mass,
vector& cM,
tensor& J
);
static void massPropertiesSolid
(
const triSurface& surf,
scalar density,
scalar& mass,
vector& cM,
tensor& J
);
static void massPropertiesShell
(
const triSurface& surf,
scalar density,
scalar& mass,
vector& cM,
tensor& J
);
static tensor applyParallelAxisTheorem
(
scalar mass,
const vector& cM,
const tensor& J,
const vector& refPt
);
// Calculate the inertia tensor for all cells in the mesh
static tmp<tensorField> meshInertia
(
const polyMesh& mesh
);
// Calculate the inertia tensor the given cell
static tensor meshInertia
(
const polyMesh& mesh,
label cellI
);
};
// Calculate
// - centre of mass
// - inertia tensor around (0,0,0)
void momentOfIntertia
(
const pointField&,
const faceList&,
const cell&,
point& r,
tensor& Jorigin
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -192,15 +192,19 @@ Foam::treeBoundBox::treeBoundBox(Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::pointField Foam::treeBoundBox::points() const Foam::tmp<Foam::pointField> Foam::treeBoundBox::points() const
{ {
pointField points(8); tmp<pointField> tPts = tmp<pointField>(new pointField(8));
pointField& points = tPts();
forAll(points, octant) forAll(points, octant)
{ {
points[octant] = corner(octant); points[octant] = corner(octant);
} }
return points;
return tPts;
} }

View File

@ -191,7 +191,7 @@ public:
inline scalar typDim() const; inline scalar typDim() const;
//- vertex coordinates. In octant coding. //- vertex coordinates. In octant coding.
pointField points() const; tmp<pointField> points() const;
// Check // Check

View File

@ -45,6 +45,7 @@ Foam::scalar Foam::streamLineParticle::calcSubCycleDeltaT
) const ) const
{ {
streamLineParticle testParticle(*this); streamLineParticle testParticle(*this);
bool oldKeepParticle = td.keepParticle; bool oldKeepParticle = td.keepParticle;
bool oldSwitchProcessor = td.switchProcessor; bool oldSwitchProcessor = td.switchProcessor;
scalar fraction = testParticle.trackToFace(position()+dt*U, td); scalar fraction = testParticle.trackToFace(position()+dt*U, td);
@ -196,9 +197,7 @@ bool Foam::streamLineParticle::move
// Cross cell in steps: // Cross cell in steps:
// - at subiter 0 calculate dt to cross cell in nSubCycle steps // - at subiter 0 calculate dt to cross cell in nSubCycle steps
// - at the last subiter do all of the remaining track // - at the last subiter do all of the remaining track
// - do a few more subiters than nSubCycle since velocity might for (label subIter = 0; subIter < td.nSubCycle_; subIter++)
// be decreasing
for (label subIter = 0; subIter < 2*td.nSubCycle_; subIter++)
{ {
--lifeTime_; --lifeTime_;
@ -217,14 +216,14 @@ bool Foam::streamLineParticle::move
// Adapt dt to cross cell in a few steps // Adapt dt to cross cell in a few steps
dt = calcSubCycleDeltaT(td, dt, U); dt = calcSubCycleDeltaT(td, dt, U);
} }
else if (subIter == td.nSubCycle_-1) else if (subIter == td.nSubCycle_ - 1)
{ {
// Do full step on last subcycle // Do full step on last subcycle
dt = min(dtMax, tEnd); dt = min(dtMax, tEnd);
} }
scalar fraction = trackToFace(position()+dt*U, td); scalar fraction = trackToFace(position() + dt*U, td);
dt *= fraction; dt *= fraction;
tEnd -= dt; tEnd -= dt;
@ -236,7 +235,13 @@ bool Foam::streamLineParticle::move
lifeTime_ = 0; lifeTime_ = 0;
} }
if (!td.keepParticle || td.switchProcessor || lifeTime_ == 0) if
(
face() != -1
|| !td.keepParticle
|| td.switchProcessor
|| lifeTime_ == 0
)
{ {
break; break;
} }

Some files were not shown because too many files have changed in this diff Show More