COMP: resolve conflict

This commit is contained in:
andy
2010-12-17 18:19:04 +00:00
81 changed files with 1115 additions and 1179 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -133,6 +133,7 @@ Usage
#include "syncTools.H"
#include "cyclicPolyPatch.H"
#include "nonuniformTransformCyclicPolyPatch.H"
#include "extrudeModel.H"
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
// the face extruded from the edge has a valid normal with its coupled
// equivalent.
@ -846,14 +814,14 @@ void constrainCoupledNormals
(
mesh,
edgeNormals0,
minEqVectorOp(),
maxMagSqrEqOp<vector>(),
vector::zero // nullValue
);
syncTools::syncEdgeList
(
mesh,
edgeNormals1,
minEqVectorOp(),
maxMagSqrEqOp<vector>(),
vector::zero // nullValue
);
@ -951,14 +919,9 @@ tmp<pointField> calcOffset
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("shellRegion");
argList::validArgs.append("faceZones");
argList::validArgs.append("thickness");
Foam::argList::addBoolOption
argList::addNote
(
"oneD",
"generate columns of 1D cells"
"Create region mesh by extruding a faceZone"
);
#include "addRegionOption.H"
@ -966,19 +929,34 @@ int main(int argc, char *argv[])
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
const word oldInstance = mesh.pointsInstance();
word shellRegionName = args.additionalArgs()[0];
const wordList zoneNames(IStringStream(args.additionalArgs()[1])());
scalar thickness = readScalar(IStringStream(args.additionalArgs()[2])());
const word oldInstance = mesh.pointsInstance();
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
<< " on mesh " << regionName
<< " into shell mesh " << shellRegionName
<< " of thickness " << thickness << nl
<< endl;
if (shellRegionName == regionName)
@ -1081,7 +1059,6 @@ int main(int argc, char *argv[])
);
// Check whether the zone is internal or external faces to determine
// what patch type to insert. Cannot be mixed
// 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
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vectorField regionNormals(regionPoints.size(), vector::zero);
vectorField regionCentres(regionPoints.size(), vector::zero);
labelList nRegionFaces(regionPoints.size(), 0);
forAll(pointRegions, faceI)
{
@ -1446,9 +1425,15 @@ int main(int argc, char *argv[])
{
label region = pointRegions[faceI][fp];
regionNormals[region] += extrudePatch.faceNormals()[faceI];
regionCentres[region] += extrudePatch.faceCentres()[faceI];
nRegionFaces[region]++;
}
}
regionNormals /= mag(regionNormals);
forAll(regionCentres, regionI)
{
regionCentres[regionI] /= nRegionFaces[regionI];
}
// 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
if (false)
{
OFstream str(runTime.path()/"regionNormals.obj");
label vertI = 0;
scalar thickness = model().sumThickness(1);
forAll(pointRegions, 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
// ~~~~~~~~~~~~~~~~~
@ -1500,7 +1498,9 @@ int main(int argc, char *argv[])
extruder.setRefinement
(
thickness*regionNormals,
firstDisp, // first displacement
model().expansionRatio(),
model().nLayers(), // nLayers
extrudeTopPatchID,
extrudeBottomPatchID,
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);
}
// 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
(
const polyMesh& mesh,
@ -854,7 +837,7 @@ int main(int argc, char *argv[])
(
mesh,
newPoints,
nearestEqOp(),
minMagSqrEqOp<vector>(),
point(GREAT, GREAT, GREAT)
);

View File

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

View File

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

View File

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

View File

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

View File

@ -33,9 +33,6 @@ Description
#include "argList.H"
#include "ListOps.H"
#include "face.H"
#include "tetPointRef.H"
#include "triFaceList.H"
#include "triSurface.H"
#include "OFstream.H"
#include "meshTools.H"
@ -43,242 +40,12 @@ Description
#include "transform.H"
#include "IOmanip.H"
#include "Pair.H"
#include "momentOfInertia.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
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[])
{
argList::addNote
@ -321,40 +88,17 @@ int main(int argc, char *argv[])
triSurface surf(surfFileName);
triFaceList faces(surf.size());
forAll(surf, i)
{
faces[i] = triFace(surf[i]);
}
scalar m = 0.0;
vector cM = vector::zero;
tensor J = tensor::zero;
if (args.optionFound("shellProperties"))
{
massPropertiesShell
(
surf.points(),
faces,
density,
m,
cM,
J
);
momentOfInertia::massPropertiesShell(surf, density, m, cM, J);
}
else
{
massPropertiesSolid
(
surf.points(),
faces,
density,
m,
cM,
J
);
momentOfInertia::massPropertiesSolid(surf, density, m, cM, J);
}
if (m < 0)
@ -583,7 +327,7 @@ int main(int argc, char *argv[])
showTransform = false;
}
Info<< nl << setprecision(10)
Info<< nl << setprecision(12)
<< "Density: " << density << nl
<< "Mass: " << m << nl
<< "Centre of mass: " << cM << nl
@ -615,7 +359,7 @@ int main(int argc, char *argv[])
if (calcAroundRefPt)
{
Info<< nl << "Inertia tensor relative to " << refPt << ": " << nl
<< applyParallelAxisTheorem(m, cM, J, refPt)
<< momentOfInertia::applyParallelAxisTheorem(m, cM, J, refPt)
<< endl;
}