Merge commit 'OpenCFD/master' into olesenm

This commit is contained in:
Mark Olesen
2010-02-08 15:01:48 +01:00
49 changed files with 290168 additions and 701 deletions

View File

@ -55,7 +55,7 @@ int main(int argc, char *argv[])
#include "initContinuityErrs.H" #include "initContinuityErrs.H"
while (runTime.run()) while (runTime.loop())
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
@ -81,8 +81,6 @@ int main(int argc, char *argv[])
#include "convergenceCheck.H" #include "convergenceCheck.H"
} }
runTime++;
runTime.write(); runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"

View File

@ -46,9 +46,6 @@ Usage
@param -fields \n @param -fields \n
Use existing geometry decomposition and convert fields only. Use existing geometry decomposition and convert fields only.
@param -filterPatches \n
Remove empty patches when decomposing the geometry.
@param -force \n @param -force \n
Remove any existing @a processor subdirectories before decomposing the Remove any existing @a processor subdirectories before decomposing the
geometry. geometry.
@ -99,11 +96,6 @@ int main(int argc, char *argv[])
"use existing geometry decomposition and convert fields only" "use existing geometry decomposition and convert fields only"
); );
argList::addBoolOption argList::addBoolOption
(
"filterPatches",
"remove empty patches when decomposing the geometry"
);
argList::addBoolOption
( (
"force", "force",
"remove existing processor*/ subdirs before decomposing the geometry" "remove existing processor*/ subdirs before decomposing the geometry"
@ -128,7 +120,6 @@ int main(int argc, char *argv[])
bool writeCellDist = args.optionFound("cellDist"); bool writeCellDist = args.optionFound("cellDist");
bool copyUniform = args.optionFound("copyUniform"); bool copyUniform = args.optionFound("copyUniform");
bool decomposeFieldsOnly = args.optionFound("fields"); bool decomposeFieldsOnly = args.optionFound("fields");
bool filterPatches = args.optionFound("filterPatches");
bool forceOverwrite = args.optionFound("force"); bool forceOverwrite = args.optionFound("force");
bool ifRequiredDecomposition = args.optionFound("ifRequired"); bool ifRequiredDecomposition = args.optionFound("ifRequired");
@ -249,7 +240,7 @@ int main(int argc, char *argv[])
// Decompose the mesh // Decompose the mesh
if (!decomposeFieldsOnly) if (!decomposeFieldsOnly)
{ {
mesh.decomposeMesh(filterPatches); mesh.decomposeMesh();
mesh.writeDecomposition(); mesh.writeDecomposition();

View File

@ -69,6 +69,24 @@ void Foam::domainDecomposition::mark
Foam::domainDecomposition::domainDecomposition(const IOobject& io) Foam::domainDecomposition::domainDecomposition(const IOobject& io)
: :
fvMesh(io), fvMesh(io),
facesInstancePointsPtr_
(
pointsInstance() != facesInstance()
? new pointIOField
(
IOobject
(
"points",
facesInstance(),
polyMesh::meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
: NULL
),
decompositionDict_ decompositionDict_
( (
IOobject IOobject
@ -86,7 +104,6 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
procPointAddressing_(nProcs_), procPointAddressing_(nProcs_),
procFaceAddressing_(nProcs_), procFaceAddressing_(nProcs_),
procCellAddressing_(nProcs_), procCellAddressing_(nProcs_),
procBoundaryAddressing_(nProcs_),
procPatchSize_(nProcs_), procPatchSize_(nProcs_),
procPatchStartIndex_(nProcs_), procPatchStartIndex_(nProcs_),
procNeighbourProcessors_(nProcs_), procNeighbourProcessors_(nProcs_),
@ -263,24 +280,67 @@ bool Foam::domainDecomposition::writeDecomposition()
"system", "system",
"constant" "constant"
); );
processorDb.setTime(time());
// create the mesh // create the mesh. Two situations:
polyMesh procMesh // - points and faces come from the same time ('instance'). The mesh
// will get constructed in the same instance.
// - points come from a different time (moving mesh cases).
// It will read the points belonging to the faces instance and
// construct the procMesh with it which then gets handled as above.
// (so with 'old' geometry).
// Only at writing time will it additionally write the current
// points.
autoPtr<polyMesh> procMeshPtr;
if (facesInstancePointsPtr_.valid())
{
// Construct mesh from facesInstance.
pointField facesInstancePoints
(
facesInstancePointsPtr_(),
curPointLabels
);
procMeshPtr.reset
(
new polyMesh
( (
IOobject IOobject
( (
this->polyMesh::name(), // region name of undecomposed mesh this->polyMesh::name(), // region of undecomposed mesh
pointsInstance(), facesInstance(),
processorDb
),
xferMove(facesInstancePoints),
xferMove(procFaces),
xferMove(procCells)
)
);
}
else
{
procMeshPtr.reset
(
new polyMesh
(
IOobject
(
this->polyMesh::name(), // region of undecomposed mesh
facesInstance(),
processorDb processorDb
), ),
xferMove(procPoints), xferMove(procPoints),
xferMove(procFaces), xferMove(procFaces),
xferMove(procCells) xferMove(procCells)
)
); );
}
polyMesh& procMesh = procMeshPtr();
// Create processor boundary patches // Create processor boundary patches
const labelList& curBoundaryAddressing = procBoundaryAddressing_[procI];
const labelList& curPatchSizes = procPatchSize_[procI]; const labelList& curPatchSizes = procPatchSize_[procI];
const labelList& curPatchStarts = procPatchStartIndex_[procI]; const labelList& curPatchStarts = procPatchStartIndex_[procI];
@ -309,8 +369,7 @@ bool Foam::domainDecomposition::writeDecomposition()
{ {
// Get the face labels consistent with the field mapping // Get the face labels consistent with the field mapping
// (reuse the patch field mappers) // (reuse the patch field mappers)
const polyPatch& meshPatch = const polyPatch& meshPatch = meshPatches[patchi];
meshPatches[curBoundaryAddressing[patchi]];
fvFieldDecomposer::patchFieldDecomposer patchMapper fvFieldDecomposer::patchFieldDecomposer patchMapper
( (
@ -324,8 +383,7 @@ bool Foam::domainDecomposition::writeDecomposition()
); );
// Map existing patches // Map existing patches
procPatches[nPatches] = procPatches[nPatches] = meshPatch.clone
meshPatches[curBoundaryAddressing[patchi]].clone
( (
procMesh.boundaryMesh(), procMesh.boundaryMesh(),
nPatches, nPatches,
@ -589,6 +647,26 @@ bool Foam::domainDecomposition::writeDecomposition()
procMesh.write(); procMesh.write();
// Write points if pointsInstance differing from facesInstance
if (facesInstancePointsPtr_.valid())
{
pointIOField pointsInstancePoints
(
IOobject
(
"points",
pointsInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove(procPoints)
);
pointsInstancePoints.write();
}
Info<< endl Info<< endl
<< "Processor " << procI << nl << "Processor " << procI << nl
<< " Number of cells = " << procMesh.nCells() << " Number of cells = " << procMesh.nCells()
@ -678,6 +756,16 @@ bool Foam::domainDecomposition::writeDecomposition()
); );
cellProcAddressing.write(); cellProcAddressing.write();
// Write patch map for backwards compatibility.
// (= identity map for original patches, -1 for processor patches)
label nMeshPatches = curPatchSizes.size();
labelList procBoundaryAddressing(identity(nMeshPatches));
procBoundaryAddressing.setSize
(
nMeshPatches+curProcessorPatchSizes.size(),
-1
);
labelIOList boundaryProcAddressing labelIOList boundaryProcAddressing
( (
IOobject IOobject
@ -689,7 +777,7 @@ bool Foam::domainDecomposition::writeDecomposition()
IOobject::NO_READ, IOobject::NO_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
), ),
procBoundaryAddressing_[procI] procBoundaryAddressing
); );
boundaryProcAddressing.write(); boundaryProcAddressing.write();
} }

View File

@ -55,6 +55,9 @@ class domainDecomposition
{ {
// Private data // Private data
//- Optional: points at the facesInstance
autoPtr<pointIOField> facesInstancePointsPtr_;
//- Mesh decomposition control dictionary //- Mesh decomposition control dictionary
IOdictionary decompositionDict_; IOdictionary decompositionDict_;
@ -83,9 +86,6 @@ class domainDecomposition
//- Labels of cells for each processor //- Labels of cells for each processor
labelListList procCellAddressing_; labelListList procCellAddressing_;
//- Original patch index for every processor patch
labelListList procBoundaryAddressing_;
//- Sizes for processor mesh patches //- Sizes for processor mesh patches
// Excludes inter-processor boundaries // Excludes inter-processor boundaries
labelListList procPatchSize_; labelListList procPatchSize_;
@ -149,8 +149,8 @@ public:
return distributed_; return distributed_;
} }
//- Decompose mesh. Optionally remove zero-sized patches. //- Decompose mesh.
void decomposeMesh(const bool filterEmptyPatches); void decomposeMesh();
//- Write decomposition //- Write decomposition
bool writeDecomposition(); bool writeDecomposition();

View File

@ -40,7 +40,7 @@ Description
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches) void Foam::domainDecomposition::decomposeMesh()
{ {
// Decide which cell goes to which processor // Decide which cell goes to which processor
distributeCells(); distributeCells();
@ -598,64 +598,6 @@ void Foam::domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
} }
} }
Info<< "\nCalculating processor boundary addressing" << endl;
// For every patch of processor boundary, find the index of the original
// patch. Mis-alignment is caused by the fact that patches with zero size
// are omitted. For processor patches, set index to -1.
// At the same time, filter the procPatchSize_ and procPatchStartIndex_
// lists to exclude zero-size patches
forAll(procPatchSize_, procI)
{
// Make a local copy of old lists
const labelList oldPatchSizes = procPatchSize_[procI];
const labelList oldPatchStarts = procPatchStartIndex_[procI];
labelList& curPatchSizes = procPatchSize_[procI];
labelList& curPatchStarts = procPatchStartIndex_[procI];
const labelList& curProcessorPatchSizes =
procProcessorPatchSize_[procI];
labelList& curBoundaryAddressing = procBoundaryAddressing_[procI];
curBoundaryAddressing.setSize
(
oldPatchSizes.size()
+ curProcessorPatchSizes.size()
);
label nPatches = 0;
forAll(oldPatchSizes, patchi)
{
if (!filterEmptyPatches || oldPatchSizes[patchi] > 0)
{
curBoundaryAddressing[nPatches] = patchi;
curPatchSizes[nPatches] = oldPatchSizes[patchi];
curPatchStarts[nPatches] = oldPatchStarts[patchi];
nPatches++;
}
}
// reset to the size of live patches
curPatchSizes.setSize(nPatches);
curPatchStarts.setSize(nPatches);
forAll(curProcessorPatchSizes, procPatchI)
{
curBoundaryAddressing[nPatches] = -1;
nPatches++;
}
curBoundaryAddressing.setSize(nPatches);
}
Info<< "\nDistributing points to processors" << endl; Info<< "\nDistributing points to processors" << endl;
// For every processor, loop through the list of faces for the processor. // For every processor, loop through the list of faces for the processor.
// For every face, loop through the list of points and mark the point as // For every face, loop through the list of points and mark the point as

View File

@ -35,6 +35,10 @@ License
#include "IOmanip.H" #include "IOmanip.H"
#include "itoa.H" #include "itoa.H"
#include "ensightWriteBinary.H" #include "ensightWriteBinary.H"
#include "globalIndex.H"
#include "PackedBoolList.H"
#include "mapDistribute.H"
#include <fstream> #include <fstream>
// * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Functions * * * * * * * * * * * * * * //
@ -106,7 +110,8 @@ Foam::ensightMesh::ensightMesh
{ {
allPatchNames_ = wordList::subList allPatchNames_ = wordList::subList
( (
mesh_.boundaryMesh().names(), mesh_.boundary().size() mesh_.boundaryMesh().names(),
mesh_.boundary().size()
- mesh_.globalData().processorPatches().size() - mesh_.globalData().processorPatches().size()
); );
@ -295,6 +300,114 @@ Foam::ensightMesh::~ensightMesh()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::globalIndex Foam::ensightMesh::mergeMeshPoints
(
labelList& pointToGlobal,
pointField& uniquePoints
) const
{
const globalMeshData& globalData = mesh_.globalData();
const indirectPrimitivePatch& coupledPatch = globalData.coupledPatch();
const labelListList& globalPointSlaves =
globalData.globalPointSlaves();
const mapDistribute& globalPointSlavesMap =
globalData.globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
PackedBoolList isMaster(mesh_.nPoints(), 1);
forAll(globalPointSlaves, pointI)
{
const labelList& slavePoints = globalPointSlaves[pointI];
if (slavePoints.size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[coupledPatch.meshPoints()[pointI]] = 0;
}
}
label myUniquePoints =
mesh_.nPoints()
- coupledPatch.nPoints()
+ nCoupledMaster;
//Pout<< "Points :" << nl
// << " mesh : " << mesh_.nPoints() << nl
// << " of which coupled : " << coupledPatch.nPoints() << nl
// << " of which master : " << nCoupledMaster << nl
// << endl;
// 2. Create global indexing for unique points.
globalIndex globalPoints(myUniquePoints);
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(mesh_.nPoints());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, meshPointI)
{
if (isMaster[meshPointI])
{
pointToGlobal[meshPointI] = globalPoints.toGlobal(nMaster);
uniquePoints[nMaster] = mesh_.points()[meshPointI];
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(globalPointSlavesMap.constructSize(), -1);
forAll(globalPointSlaves, pointI)
{
const labelList& slaves = globalPointSlaves[pointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
label meshPointI = coupledPatch.meshPoints()[pointI];
masterToGlobal[pointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = masterToGlobal[pointI];
}
}
}
// Send back
globalPointSlavesMap.reverseDistribute
(
coupledPatch.nPoints(),
masterToGlobal
);
// On slave copy master index into overall map.
forAll(globalPointSlaves, pointI)
{
const labelList& slaves = globalPointSlaves[pointI];
if (slaves.size() == 0)
{
label meshPointI = coupledPatch.meshPoints()[pointI];
pointToGlobal[meshPointI] = masterToGlobal[pointI];
}
}
}
return globalPoints;
}
void Foam::ensightMesh::writePoints void Foam::ensightMesh::writePoints
( (
const scalarField& pointsComponent, const scalarField& pointsComponent,
@ -311,7 +424,8 @@ void Foam::ensightMesh::writePoints
Foam::cellShapeList Foam::ensightMesh::map Foam::cellShapeList Foam::ensightMesh::map
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& prims const labelList& prims,
const labelList& pointToGlobal
) const ) const
{ {
cellShapeList mcsl(prims.size()); cellShapeList mcsl(prims.size());
@ -319,6 +433,7 @@ Foam::cellShapeList Foam::ensightMesh::map
forAll(prims, i) forAll(prims, i)
{ {
mcsl[i] = cellShapes[prims[i]]; mcsl[i] = cellShapes[prims[i]];
inplaceRenumber(pointToGlobal, mcsl[i]);
} }
return mcsl; return mcsl;
@ -329,7 +444,8 @@ Foam::cellShapeList Foam::ensightMesh::map
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& hexes, const labelList& hexes,
const labelList& wedges const labelList& wedges,
const labelList& pointToGlobal
) const ) const
{ {
cellShapeList mcsl(hexes.size() + wedges.size()); cellShapeList mcsl(hexes.size() + wedges.size());
@ -337,6 +453,7 @@ Foam::cellShapeList Foam::ensightMesh::map
forAll(hexes, i) forAll(hexes, i)
{ {
mcsl[i] = cellShapes[hexes[i]]; mcsl[i] = cellShapes[hexes[i]];
inplaceRenumber(pointToGlobal, mcsl[i]);
} }
label offset = hexes.size(); label offset = hexes.size();
@ -358,6 +475,7 @@ Foam::cellShapeList Foam::ensightMesh::map
hexLabels[7] = cellPoints[5]; hexLabels[7] = cellPoints[5];
mcsl[i + offset] = cellShape(hex, hexLabels); mcsl[i + offset] = cellShape(hex, hexLabels);
inplaceRenumber(pointToGlobal, mcsl[i + offset]);
} }
return mcsl; return mcsl;
@ -367,19 +485,18 @@ Foam::cellShapeList Foam::ensightMesh::map
void Foam::ensightMesh::writePrims void Foam::ensightMesh::writePrims
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const label pointOffset,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const ) const
{ {
label po = pointOffset + 1;
forAll(cellShapes, i) forAll(cellShapes, i)
{ {
const cellShape& cellPoints = cellShapes[i]; const cellShape& cellPoints = cellShapes[i];
forAll(cellPoints, pointI) forAll(cellPoints, pointI)
{ {
ensightGeometryFile<< setw(10) << cellPoints[pointI] + po; ensightGeometryFile
<< setw(10)
<< cellPoints[pointI] + 1;
} }
ensightGeometryFile << nl; ensightGeometryFile << nl;
} }
@ -389,12 +506,9 @@ void Foam::ensightMesh::writePrims
void Foam::ensightMesh::writePrimsBinary void Foam::ensightMesh::writePrimsBinary
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const label pointOffset,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const ) const
{ {
label po = pointOffset + 1;
// Create a temp int array // Create a temp int array
int numElem; int numElem;
@ -414,7 +528,7 @@ void Foam::ensightMesh::writePrimsBinary
forAll(cellPoints, pointI) forAll(cellPoints, pointI)
{ {
temp[n] = cellPoints[pointI] + po; temp[n] = cellPoints[pointI] + 1;
n++; n++;
} }
} }
@ -469,12 +583,9 @@ void Foam::ensightMesh::writePolysPoints
const labelList& polys, const labelList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const label pointOffset,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const ) const
{ {
label po = pointOffset + 1;
forAll(polys, i) forAll(polys, i)
{ {
const labelList& cf = cellFaces[polys[i]]; const labelList& cf = cellFaces[polys[i]];
@ -485,7 +596,7 @@ void Foam::ensightMesh::writePolysPoints
forAll(f, pointI) forAll(f, pointI)
{ {
ensightGeometryFile << setw(10) << f[pointI] + po; ensightGeometryFile << setw(10) << f[pointI] + 1;
} }
ensightGeometryFile << nl; ensightGeometryFile << nl;
} }
@ -495,14 +606,19 @@ void Foam::ensightMesh::writePolysPoints
void Foam::ensightMesh::writeAllPolys void Foam::ensightMesh::writeAllPolys
( (
const labelList& pointOffsets, const labelList& pointToGlobal,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const ) const
{ {
if (meshCellSets_.nPolys) if (meshCellSets_.nPolys)
{ {
const cellList& cellFaces = mesh_.cells(); const cellList& cellFaces = mesh_.cells();
const faceList& faces = mesh_.faces(); // Renumber faces to use global point numbers
faceList faces(mesh_.faces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
if (Pstream::master()) if (Pstream::master())
{ {
@ -541,6 +657,7 @@ void Foam::ensightMesh::writeAllPolys
toMaster<< meshCellSets_.polys << cellFaces; toMaster<< meshCellSets_.polys << cellFaces;
} }
// Number of points for each face of the above list // Number of points for each face of the above list
if (Pstream::master()) if (Pstream::master())
{ {
@ -584,7 +701,6 @@ void Foam::ensightMesh::writeAllPolys
meshCellSets_.polys, meshCellSets_.polys,
cellFaces, cellFaces,
faces, faces,
0,
ensightGeometryFile ensightGeometryFile
); );
// Slaves // Slaves
@ -600,7 +716,6 @@ void Foam::ensightMesh::writeAllPolys
polys, polys,
cellFaces, cellFaces,
faces, faces,
pointOffsets[slave-1],
ensightGeometryFile ensightGeometryFile
); );
} }
@ -661,12 +776,9 @@ void Foam::ensightMesh::writePolysPointsBinary
const labelList& polys, const labelList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const label pointOffset,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const ) const
{ {
label po = pointOffset + 1;
forAll(polys, i) forAll(polys, i)
{ {
const labelList& cf = cellFaces[polys[i]]; const labelList& cf = cellFaces[polys[i]];
@ -677,7 +789,7 @@ void Foam::ensightMesh::writePolysPointsBinary
forAll(f, pointI) forAll(f, pointI)
{ {
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile); writeEnsDataBinary(f[pointI] + 1,ensightGeometryFile);
} }
} }
} }
@ -686,14 +798,19 @@ void Foam::ensightMesh::writePolysPointsBinary
void Foam::ensightMesh::writeAllPolysBinary void Foam::ensightMesh::writeAllPolysBinary
( (
const labelList& pointOffsets, const labelList& pointToGlobal,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const ) const
{ {
if (meshCellSets_.nPolys) if (meshCellSets_.nPolys)
{ {
const cellList& cellFaces = mesh_.cells(); const cellList& cellFaces = mesh_.cells();
const faceList& faces = mesh_.faces(); // Renumber faces to use global point numbers
faceList faces(mesh_.faces());
forAll(faces, i)
{
inplaceRenumber(pointToGlobal, faces[i]);
}
if (Pstream::master()) if (Pstream::master())
{ {
@ -775,7 +892,6 @@ void Foam::ensightMesh::writeAllPolysBinary
meshCellSets_.polys, meshCellSets_.polys,
cellFaces, cellFaces,
faces, faces,
0,
ensightGeometryFile ensightGeometryFile
); );
// Slaves // Slaves
@ -791,7 +907,6 @@ void Foam::ensightMesh::writeAllPolysBinary
polys, polys,
cellFaces, cellFaces,
faces, faces,
pointOffsets[slave-1],
ensightGeometryFile ensightGeometryFile
); );
} }
@ -810,7 +925,6 @@ void Foam::ensightMesh::writeAllPrims
const char* key, const char* key,
const label nPrims, const label nPrims,
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& pointOffsets,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const ) const
{ {
@ -820,19 +934,14 @@ void Foam::ensightMesh::writeAllPrims
{ {
ensightGeometryFile << key << nl << setw(10) << nPrims << nl; ensightGeometryFile << key << nl << setw(10) << nPrims << nl;
writePrims(cellShapes, 0, ensightGeometryFile); writePrims(cellShapes, ensightGeometryFile);
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
IPstream fromSlave(Pstream::scheduled, slave); IPstream fromSlave(Pstream::scheduled, slave);
cellShapeList cellShapes(fromSlave); cellShapeList cellShapes(fromSlave);
writePrims writePrims(cellShapes, ensightGeometryFile);
(
cellShapes,
pointOffsets[slave-1],
ensightGeometryFile
);
} }
} }
else else
@ -849,7 +958,6 @@ void Foam::ensightMesh::writeAllPrimsBinary
const char* key, const char* key,
const label nPrims, const label nPrims,
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& pointOffsets,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const ) const
{ {
@ -860,19 +968,14 @@ void Foam::ensightMesh::writeAllPrimsBinary
writeEnsDataBinary(key,ensightGeometryFile); writeEnsDataBinary(key,ensightGeometryFile);
writeEnsDataBinary(nPrims,ensightGeometryFile); writeEnsDataBinary(nPrims,ensightGeometryFile);
writePrimsBinary(cellShapes, 0, ensightGeometryFile); writePrimsBinary(cellShapes, ensightGeometryFile);
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
IPstream fromSlave(Pstream::scheduled, slave); IPstream fromSlave(Pstream::scheduled, slave);
cellShapeList cellShapes(fromSlave); cellShapeList cellShapes(fromSlave);
writePrimsBinary writePrimsBinary(cellShapes, ensightGeometryFile);
(
cellShapes,
pointOffsets[slave-1],
ensightGeometryFile
);
} }
} }
else else
@ -926,34 +1029,13 @@ void Foam::ensightMesh::writeFacePrimsBinary
forAll(patchFace, pointI) forAll(patchFace, pointI)
{ {
writeEnsDataBinary writeEnsDataBinary(patchFace[pointI] + po, ensightGeometryFile);
(
patchFace[pointI] + po,
ensightGeometryFile
);
} }
} }
} }
} }
Foam::faceList Foam::ensightMesh::map
(
const faceList& patchFaces,
const labelList& prims
) const
{
faceList ppf(prims.size());
forAll(prims, i)
{
ppf[i] = patchFaces[prims[i]];
}
return ppf;
}
void Foam::ensightMesh::writeAllFacePrims void Foam::ensightMesh::writeAllFacePrims
( (
const char* key, const char* key,
@ -975,7 +1057,7 @@ void Foam::ensightMesh::writeAllFacePrims
{ {
writeFacePrims writeFacePrims
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
0, 0,
ensightGeometryFile ensightGeometryFile
); );
@ -1001,7 +1083,7 @@ void Foam::ensightMesh::writeAllFacePrims
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
} }
} }
@ -1015,8 +1097,7 @@ void Foam::ensightMesh::writeNSidedNPointsPerFace
{ {
forAll(patchFaces, i) forAll(patchFaces, i)
{ {
ensightGeometryFile ensightGeometryFile << setw(10) << patchFaces[i].size() << nl;
<< setw(10) << patchFaces[i].size() << nl;
} }
} }
@ -1028,12 +1109,7 @@ void Foam::ensightMesh::writeNSidedPoints
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const ) const
{ {
writeFacePrims writeFacePrims(patchFaces, pointOffset, ensightGeometryFile);
(
patchFaces,
pointOffset,
ensightGeometryFile
);
} }
@ -1062,7 +1138,7 @@ void Foam::ensightMesh::writeAllNSided
{ {
writeNSidedNPointsPerFace writeNSidedNPointsPerFace
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
ensightGeometryFile ensightGeometryFile
); );
} }
@ -1086,7 +1162,7 @@ void Foam::ensightMesh::writeAllNSided
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
// List of points id for each face // List of points id for each face
@ -1096,7 +1172,7 @@ void Foam::ensightMesh::writeAllNSided
{ {
writeNSidedPoints writeNSidedPoints
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
0, 0,
ensightGeometryFile ensightGeometryFile
); );
@ -1122,7 +1198,7 @@ void Foam::ensightMesh::writeAllNSided
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
} }
} }
@ -1186,7 +1262,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
{ {
writeNSidedNPointsPerFaceBinary writeNSidedNPointsPerFaceBinary
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
ensightGeometryFile ensightGeometryFile
); );
} }
@ -1210,7 +1286,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
// List of points id for each face // List of points id for each face
@ -1220,7 +1296,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
{ {
writeNSidedPointsBinary writeNSidedPointsBinary
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
0, 0,
ensightGeometryFile ensightGeometryFile
); );
@ -1246,7 +1322,7 @@ void Foam::ensightMesh::writeAllNSidedBinary
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
} }
} }
@ -1274,7 +1350,7 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
{ {
writeFacePrimsBinary writeFacePrimsBinary
( (
map(patchFaces, prims), UIndirectList<face>(patchFaces, prims)(),
0, 0,
ensightGeometryFile ensightGeometryFile
); );
@ -1300,7 +1376,7 @@ void Foam::ensightMesh::writeAllFacePrimsBinary
else if (&prims != NULL) else if (&prims != NULL)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< map(patchFaces, prims); toMaster<< UIndirectList<face>(patchFaces, prims);
} }
} }
} }
@ -1334,9 +1410,22 @@ void Foam::ensightMesh::writeAscii
) const ) const
{ {
const Time& runTime = mesh_.time(); const Time& runTime = mesh_.time();
const pointField& points = mesh_.points(); //const pointField& points = mesh_.points();
const cellShapeList& cellShapes = mesh_.cellShapes(); const cellShapeList& cellShapes = mesh_.cellShapes();
// Find global point numbering
labelList pointToGlobal;
pointField uniquePoints;
globalIndex globalPoints
(
mergeMeshPoints
(
pointToGlobal,
uniquePoints
)
);
word timeFile = prepend; word timeFile = prepend;
if (timeIndex == 0) if (timeIndex == 0)
@ -1382,12 +1471,9 @@ void Foam::ensightMesh::writeAscii
<< "element id assign" << nl; << "element id assign" << nl;
} }
labelList pointOffsets(Pstream::nProcs(), 0);
if (patchNames_.empty()) if (patchNames_.empty())
{ {
label nPoints = points.size(); label nPoints = globalPoints.size();
Pstream::gather(nPoints, sumOp<label>());
if (Pstream::master()) if (Pstream::master())
{ {
@ -1401,17 +1487,13 @@ void Foam::ensightMesh::writeAscii
for (direction d=0; d<vector::nComponents; d++) for (direction d=0; d<vector::nComponents; d++)
{ {
writePoints(points.component(d), ensightGeometryFile); writePoints(uniquePoints.component(d), ensightGeometryFile);
pointOffsets[0] = points.size();
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
IPstream fromSlave(Pstream::scheduled, slave); IPstream fromSlave(Pstream::scheduled, slave);
scalarField pointsComponent(fromSlave); scalarField pointsComponent(fromSlave);
writePoints(pointsComponent, ensightGeometryFile); writePoints(pointsComponent, ensightGeometryFile);
pointOffsets[slave] =
pointOffsets[slave-1]
+ pointsComponent.size();
} }
} }
} }
@ -1420,16 +1502,22 @@ void Foam::ensightMesh::writeAscii
for (direction d=0; d<vector::nComponents; d++) for (direction d=0; d<vector::nComponents; d++)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< points.component(d); toMaster<< uniquePoints.component(d);
} }
} }
writeAllPrims writeAllPrims
( (
"hexa8", "hexa8",
meshCellSets_.nHexesWedges, meshCellSets_.nHexesWedges,
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges), map // Rewrite cellShapes to global numbering
pointOffsets, (
cellShapes,
meshCellSets_.hexes,
meshCellSets_.wedges,
pointToGlobal
),
ensightGeometryFile ensightGeometryFile
); );
@ -1437,8 +1525,7 @@ void Foam::ensightMesh::writeAscii
( (
"penta6", "penta6",
meshCellSets_.nPrisms, meshCellSets_.nPrisms,
map(cellShapes, meshCellSets_.prisms), map(cellShapes, meshCellSets_.prisms, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
@ -1446,8 +1533,7 @@ void Foam::ensightMesh::writeAscii
( (
"pyramid5", "pyramid5",
meshCellSets_.nPyrs, meshCellSets_.nPyrs,
map(cellShapes, meshCellSets_.pyrs), map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
@ -1455,14 +1541,13 @@ void Foam::ensightMesh::writeAscii
( (
"tetra4", "tetra4",
meshCellSets_.nTets, meshCellSets_.nTets,
map(cellShapes, meshCellSets_.tets), map(cellShapes, meshCellSets_.tets, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
writeAllPolys writeAllPolys
( (
pointOffsets, pointToGlobal,
ensightGeometryFile ensightGeometryFile
); );
} }
@ -1498,14 +1583,14 @@ void Foam::ensightMesh::writeAscii
patchFacesPtr = &(p.localFaces()); patchFacesPtr = &(p.localFaces());
} }
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
const labelList& tris = *trisPtr; const labelList& tris = *trisPtr;
const labelList& quads = *quadsPtr; const labelList& quads = *quadsPtr;
const labelList& polys = *polysPtr; const labelList& polys = *polysPtr;
const pointField& patchPoints = *patchPointsPtr; const pointField& patchPoints = *patchPointsPtr;
const faceList& patchFaces = *patchFacesPtr; const faceList& patchFaces = *patchFacesPtr;
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
labelList patchPointOffsets(Pstream::nProcs(), 0); labelList patchPointOffsets(Pstream::nProcs(), 0);
if (Pstream::master()) if (Pstream::master())
@ -1627,10 +1712,21 @@ void Foam::ensightMesh::writeBinary
Ostream& ensightCaseFile Ostream& ensightCaseFile
) const ) const
{ {
//const Time& runTime = mesh.time();
const pointField& points = mesh_.points();
const cellShapeList& cellShapes = mesh_.cellShapes(); const cellShapeList& cellShapes = mesh_.cellShapes();
// Find global point numbering
labelList pointToGlobal;
pointField uniquePoints;
globalIndex globalPoints
(
mergeMeshPoints
(
pointToGlobal,
uniquePoints
)
);
word timeFile = prepend; word timeFile = prepend;
if (timeIndex == 0) if (timeIndex == 0)
@ -1668,12 +1764,10 @@ void Foam::ensightMesh::writeBinary
writeEnsDataBinary("element id assign", ensightGeometryFile); writeEnsDataBinary("element id assign", ensightGeometryFile);
} }
labelList pointOffsets(Pstream::nProcs(), 0);
if (patchNames_.empty()) if (patchNames_.empty())
{ {
label nPoints = points.size(); label nPoints = globalPoints.size();
Pstream::gather(nPoints, sumOp<label>());
if (Pstream::master()) if (Pstream::master())
{ {
@ -1685,19 +1779,17 @@ void Foam::ensightMesh::writeBinary
for (direction d=0; d<vector::nComponents; d++) for (direction d=0; d<vector::nComponents; d++)
{ {
//writePointsBinary(points.component(d), ensightGeometryFile); writeEnsDataBinary
writeEnsDataBinary(points.component(d), ensightGeometryFile); (
pointOffsets[0] = points.size(); uniquePoints.component(d),
ensightGeometryFile
);
for (int slave=1; slave<Pstream::nProcs(); slave++) for (int slave=1; slave<Pstream::nProcs(); slave++)
{ {
IPstream fromSlave(Pstream::scheduled, slave); IPstream fromSlave(Pstream::scheduled, slave);
scalarField pointsComponent(fromSlave); scalarField pointsComponent(fromSlave);
//writePointsBinary(pointsComponent, ensightGeometryFile);
writeEnsDataBinary(pointsComponent, ensightGeometryFile); writeEnsDataBinary(pointsComponent, ensightGeometryFile);
pointOffsets[slave] =
pointOffsets[slave-1]
+ pointsComponent.size();
} }
} }
} }
@ -1706,7 +1798,7 @@ void Foam::ensightMesh::writeBinary
for (direction d=0; d<vector::nComponents; d++) for (direction d=0; d<vector::nComponents; d++)
{ {
OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
toMaster<< points.component(d); toMaster<< uniquePoints.component(d);
} }
} }
@ -1714,8 +1806,13 @@ void Foam::ensightMesh::writeBinary
( (
"hexa8", "hexa8",
meshCellSets_.nHexesWedges, meshCellSets_.nHexesWedges,
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges), map // Rewrite cellShapes to global numbering
pointOffsets, (
cellShapes,
meshCellSets_.hexes,
meshCellSets_.wedges,
pointToGlobal
),
ensightGeometryFile ensightGeometryFile
); );
@ -1723,8 +1820,7 @@ void Foam::ensightMesh::writeBinary
( (
"penta6", "penta6",
meshCellSets_.nPrisms, meshCellSets_.nPrisms,
map(cellShapes, meshCellSets_.prisms), map(cellShapes, meshCellSets_.prisms, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
@ -1732,8 +1828,7 @@ void Foam::ensightMesh::writeBinary
( (
"pyramid5", "pyramid5",
meshCellSets_.nPyrs, meshCellSets_.nPyrs,
map(cellShapes, meshCellSets_.pyrs), map(cellShapes, meshCellSets_.pyrs, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
@ -1741,17 +1836,15 @@ void Foam::ensightMesh::writeBinary
( (
"tetra4", "tetra4",
meshCellSets_.nTets, meshCellSets_.nTets,
map(cellShapes, meshCellSets_.tets), map(cellShapes, meshCellSets_.tets, pointToGlobal),
pointOffsets,
ensightGeometryFile ensightGeometryFile
); );
writeAllPolysBinary writeAllPolysBinary
( (
pointOffsets, pointToGlobal,
ensightGeometryFile ensightGeometryFile
); );
} }
label ensightPatchI = patchPartOffset_; label ensightPatchI = patchPartOffset_;
@ -1786,14 +1879,14 @@ void Foam::ensightMesh::writeBinary
patchFacesPtr = &(p.localFaces()); patchFacesPtr = &(p.localFaces());
} }
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
const labelList& tris = *trisPtr; const labelList& tris = *trisPtr;
const labelList& quads = *quadsPtr; const labelList& quads = *quadsPtr;
const labelList& polys = *polysPtr; const labelList& polys = *polysPtr;
const pointField& patchPoints = *patchPointsPtr; const pointField& patchPoints = *patchPointsPtr;
const faceList& patchFaces = *patchFacesPtr; const faceList& patchFaces = *patchFacesPtr;
if (nfp.nTris || nfp.nQuads || nfp.nPolys)
{
labelList patchPointOffsets(Pstream::nProcs(), 0); labelList patchPointOffsets(Pstream::nProcs(), 0);
if (Pstream::master()) if (Pstream::master())

View File

@ -42,6 +42,7 @@ SourceFiles
#include "fvMesh.H" #include "fvMesh.H"
#include "OFstream.H" #include "OFstream.H"
#include <fstream> #include <fstream>
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -110,6 +111,16 @@ private:
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const ensightMesh&); void operator=(const ensightMesh&);
//- Construct map from mesh points to merged points.
// pointToGlobal : from mesh point to global point
// uniquePoints : my set of unique points
globalIndex mergeMeshPoints
(
labelList& pointToGlobal,
pointField& uniquePoints
) const;
void writePoints void writePoints
( (
const scalarField& pointsComponent, const scalarField& pointsComponent,
@ -119,20 +130,21 @@ private:
cellShapeList map cellShapeList map
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& prims const labelList& prims,
const labelList& pointToGlobal
) const; ) const;
cellShapeList map cellShapeList map
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& hexes, const labelList& hexes,
const labelList& wedges const labelList& wedges,
const labelList& pointToGlobal
) const; ) const;
void writePrims void writePrims
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const label pointOffset,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const; ) const;
@ -156,13 +168,12 @@ private:
const labelList& polys, const labelList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const label pointOffset,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const; ) const;
void writeAllPolys void writeAllPolys
( (
const labelList& pointOffsets, const labelList& pointToGlobal,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const; ) const;
@ -171,7 +182,6 @@ private:
const char* key, const char* key,
const label nPrims, const label nPrims,
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& pointOffsets,
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const; ) const;
@ -182,12 +192,6 @@ private:
OFstream& ensightGeometryFile OFstream& ensightGeometryFile
) const; ) const;
faceList map
(
const faceList& patchFaces,
const labelList& prims
) const;
void writeAllFacePrims void writeAllFacePrims
( (
const char* key, const char* key,
@ -241,7 +245,6 @@ private:
void writePrimsBinary void writePrimsBinary
( (
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const label pointOffset,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const; ) const;
@ -250,7 +253,6 @@ private:
const char* key, const char* key,
const label nPrims, const label nPrims,
const cellShapeList& cellShapes, const cellShapeList& cellShapes,
const labelList& pointOffsets,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const; ) const;
@ -274,13 +276,12 @@ private:
const labelList& polys, const labelList& polys,
const cellList& cellFaces, const cellList& cellFaces,
const faceList& faces, const faceList& faces,
const label pointOffset,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const; ) const;
void writeAllPolysBinary void writeAllPolysBinary
( (
const labelList& pointOffsets, const labelList& pointToGlobal,
std::ofstream& ensightGeometryFile std::ofstream& ensightGeometryFile
) const; ) const;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -41,6 +41,9 @@ Description
#include "OFstream.H" #include "OFstream.H"
#include "meshTools.H" #include "meshTools.H"
#include "Random.H" #include "Random.H"
#include "transform.H"
#include "IOmanip.H"
#include "Pair.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -355,6 +358,12 @@ int main(int argc, char *argv[])
); );
} }
if (m < 0)
{
WarningIn(args.executable() + "::main")
<< "Negative mass detected" << endl;
}
vector eVal = eigenValues(J); vector eVal = eigenValues(J);
tensor eVec = eigenVectors(J); tensor eVec = eigenVectors(J);
@ -380,19 +389,221 @@ int main(int argc, char *argv[])
pertI++; pertI++;
} }
Info<< nl bool showTransform = true;
<< "Density = " << density << nl
<< "Mass = " << m << nl if
<< "Centre of mass = " << cM << nl (
<< "Inertia tensor around centre of mass = " << J << nl (mag(eVec.x() ^ eVec.y()) > (1.0 - SMALL))
<< "eigenValues (principal moments) = " << eVal << nl && (mag(eVec.y() ^ eVec.z()) > (1.0 - SMALL))
<< "eigenVectors (principal axes) = " && (mag(eVec.z() ^ eVec.x()) > (1.0 - SMALL))
<< eVec.x() << ' ' << eVec.y() << ' ' << eVec.z() )
{
// Make the eigenvectors a right handed orthogonal triplet
eVec.z() *= sign((eVec.x() ^ eVec.y()) & eVec.z());
// Finding the most natural transformation. Using Lists
// rather than tensors to allow indexed permutation.
// Cartesian basis vectors - right handed orthogonal triplet
List<vector> cartesian(3);
cartesian[0] = vector(1, 0, 0);
cartesian[1] = vector(0, 1, 0);
cartesian[2] = vector(0, 0, 1);
// Principal axis basis vectors - right handed orthogonal
// triplet
List<vector> principal(3);
principal[0] = eVec.x();
principal[1] = eVec.y();
principal[2] = eVec.z();
scalar maxMagDotProduct = -GREAT;
// Matching axis indices, first: cartesian, second:principal
Pair<label> match(-1, -1);
forAll(cartesian, cI)
{
forAll(principal, pI)
{
scalar magDotProduct = mag(cartesian[cI] & principal[pI]);
if (magDotProduct > maxMagDotProduct)
{
maxMagDotProduct = magDotProduct;
match.first() = cI;
match.second() = pI;
}
}
}
scalar sense = sign
(
cartesian[match.first()] & principal[match.second()]
);
if (sense < 0)
{
// Invert the best match direction and swap the order of
// the other two vectors
List<vector> tPrincipal = principal;
tPrincipal[match.second()] *= -1;
tPrincipal[(match.second() + 1) % 3] =
principal[(match.second() + 2) % 3];
tPrincipal[(match.second() + 2) % 3] =
principal[(match.second() + 1) % 3];
principal = tPrincipal;
vector tEVal = eVal;
tEVal[(match.second() + 1) % 3] = eVal[(match.second() + 2) % 3];
tEVal[(match.second() + 2) % 3] = eVal[(match.second() + 1) % 3];
eVal = tEVal;
}
label permutationDelta = match.second() - match.first();
if (permutationDelta != 0)
{
// Add 3 to the permutationDelta to avoid negative indices
permutationDelta += 3;
List<vector> tPrincipal = principal;
vector tEVal = eVal;
for (label i = 0; i < 3; i++)
{
tPrincipal[i] = principal[(i + permutationDelta) % 3];
tEVal[i] = eVal[(i + permutationDelta) % 3];
}
principal = tPrincipal;
eVal = tEVal;
}
label matchedAlready = match.first();
match =Pair<label>(-1, -1);
maxMagDotProduct = -GREAT;
forAll(cartesian, cI)
{
if (cI == matchedAlready)
{
continue;
}
forAll(principal, pI)
{
if (pI == matchedAlready)
{
continue;
}
scalar magDotProduct = mag(cartesian[cI] & principal[pI]);
if (magDotProduct > maxMagDotProduct)
{
maxMagDotProduct = magDotProduct;
match.first() = cI;
match.second() = pI;
}
}
}
sense = sign
(
cartesian[match.first()] & principal[match.second()]
);
if (sense < 0 || (match.second() - match.first()) != 0)
{
principal[match.second()] *= -1;
List<vector> tPrincipal = principal;
tPrincipal[(matchedAlready + 1) % 3] =
principal[(matchedAlready + 2) % 3]*-sense;
tPrincipal[(matchedAlready + 2) % 3] =
principal[(matchedAlready + 1) % 3]*-sense;
principal = tPrincipal;
vector tEVal = eVal;
tEVal[(matchedAlready + 1) % 3] = eVal[(matchedAlready + 2) % 3];
tEVal[(matchedAlready + 2) % 3] = eVal[(matchedAlready + 1) % 3];
eVal = tEVal;
}
eVec.x() = principal[0];
eVec.y() = principal[1];
eVec.z() = principal[2];
// {
// tensor R = rotationTensor(vector(1, 0, 0), eVec.x());
// R = rotationTensor(R & vector(0, 1, 0), eVec.y()) & R;
// Info<< "R = " << nl << R << endl;
// Info<< "R - eVec.T() " << R - eVec.T() << endl;
// }
}
else
{
WarningIn(args.executable() + "::main")
<< "Non-unique eigenvectors, cannot compute transformation "
<< "from Cartesian axes" << endl;
showTransform = false;
}
Info<< nl << setprecision(10)
<< "Density: " << density << nl
<< "Mass: " << m << nl
<< "Centre of mass: " << cM << nl
<< "Inertia tensor around centre of mass: " << nl << J << nl
<< "eigenValues (principal moments): " << eVal << nl
<< "eigenVectors (principal axes): " << nl
<< eVec.x() << nl << eVec.y() << nl << eVec.z() << endl;
if (showTransform)
{
Info<< "Transform tensor from reference state (Q). " << nl
<< "Rotation tensor required to transform "
"from the body reference frame to the global "
"reference frame, i.e.:" << nl
<< "globalVector = Q & bodyLocalVector"
<< nl << eVec.T()
<< endl; << endl;
}
if (calcAroundRefPt) if (calcAroundRefPt)
{ {
Info << "Inertia tensor relative to " << refPt << " = " Info << "Inertia tensor relative to " << refPt << ": "
<< applyParallelAxisTheorem(m, cM, J, refPt) << applyParallelAxisTheorem(m, cM, J, refPt)
<< endl; << endl;
} }

View File

@ -676,6 +676,10 @@ Foam::Time& Foam::Time::operator++()
deltaT0_ = deltaTSave_; deltaT0_ = deltaTSave_;
deltaTSave_ = deltaT_; deltaTSave_ = deltaT_;
// Save old time name
const word oldTimeName = dimensionedScalar::name();
setTime(value() + deltaT_, timeIndex_ + 1); setTime(value() + deltaT_, timeIndex_ + 1);
if (!subCycling_) if (!subCycling_)
@ -685,7 +689,30 @@ Foam::Time& Foam::Time::operator++()
{ {
setTime(0.0, timeIndex_); setTime(0.0, timeIndex_);
} }
}
// Check that new time representation differs from old one
if (dimensionedScalar::name() == oldTimeName)
{
int oldPrecision = precision_;
do
{
precision_++;
setTime(value(), timeIndex());
}
while (precision_ < 100 && dimensionedScalar::name() == oldTimeName);
WarningIn("Time::operator++()")
<< "Increased the timePrecision from " << oldPrecision
<< " to " << precision_
<< " to distinguish between timeNames at time " << value()
<< endl;
}
if (!subCycling_)
{
switch (writeControl_) switch (writeControl_)
{ {
case wcTimeStep: case wcTimeStep:

View File

@ -410,33 +410,30 @@ Foam::label Foam::globalMeshData::countCoincidentFaces
} }
void Foam::globalMeshData::calcGlobalPointSlaves() const void Foam::globalMeshData::calcGlobalPointSlaves
(
const globalPoints& globalData,
autoPtr<globalIndex>& globalIndicesPtr,
autoPtr<labelListList>& globalPointSlavesPtr,
autoPtr<mapDistribute>& globalPointSlavesMapPtr
) const
{ {
if (debug)
{
Pout<< "globalMeshData::calcGlobalPointSlaves() :"
<< " calculating coupled master to slave point addressing."
<< endl;
}
// Calculate connected points for master points
globalPoints globalData(mesh_, coupledPatch(), true);
const Map<label>& meshToProcPoint = globalData.meshToProcPoint();
// Create global numbering for coupled points // Create global numbering for coupled points
globalPointNumberingPtr_.reset globalIndicesPtr.reset
( (
new globalIndex(globalData.globalIndices()) new globalIndex(globalData.globalIndices())
); );
const globalIndex& globalIndices = globalPointNumberingPtr_(); const globalIndex& globalIndices = globalIndicesPtr();
// Create master to slave addressing. Empty for slave points. // Create master to slave addressing. Empty for slave points.
globalPointSlavesPtr_.reset globalPointSlavesPtr.reset
( (
new labelListList(coupledPatch().nPoints()) new labelListList(coupledPatch().nPoints())
); );
labelListList& globalPointSlaves = globalPointSlavesPtr_(); labelListList& globalPointSlaves = globalPointSlavesPtr();
const Map<label>& meshToProcPoint = globalData.meshToProcPoint();
forAllConstIter(Map<label>, meshToProcPoint, iter) forAllConstIter(Map<label>, meshToProcPoint, iter)
{ {
@ -465,7 +462,7 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
// Changes globalPointSlaves to be indices into compact data // Changes globalPointSlaves to be indices into compact data
List<Map<label> > compactMap(Pstream::nProcs()); List<Map<label> > compactMap(Pstream::nProcs());
globalPointSlavesMapPtr_.reset globalPointSlavesMapPtr.reset
( (
new mapDistribute new mapDistribute
( (
@ -477,41 +474,50 @@ void Foam::globalMeshData::calcGlobalPointSlaves() const
if (debug) if (debug)
{ {
Pout<< "globalMeshData::calcGlobalPointSlaves() :" Pout<< "globalMeshData::calcGlobalPointSlaves(..) :"
<< " coupled points:" << coupledPatch().nPoints() << " coupled points:" << coupledPatch().nPoints()
<< " additional remote points:" << " additional remote points:"
<< globalPointSlavesMapPtr_().constructSize() << globalPointSlavesMapPtr().constructSize()
- coupledPatch().nPoints() - coupledPatch().nPoints()
<< endl; << endl;
} }
} }
void Foam::globalMeshData::calcGlobalEdgeSlaves() const void Foam::globalMeshData::calcGlobalPointSlaves() const
{ {
if (debug) if (debug)
{ {
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :" Pout<< "globalMeshData::calcGlobalPointSlaves() :"
<< " calculating coupled master to slave edge addressing." << " calculating coupled master to collocated"
<< " slave point addressing."
<< endl; << endl;
} }
const labelListList& globalPointSlaves = this->globalPointSlaves(); // Calculate collocated connected points for master points.
const mapDistribute& globalPointSlavesMap = this->globalPointSlavesMap(); globalPoints collocatedGlobalData(mesh_, coupledPatch(), true, false);
// - Send across connected edges (in global edge addressing) calcGlobalPointSlaves
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
globalEdgeNumberingPtr_.reset
( (
new globalIndex(coupledPatch().nEdges()) collocatedGlobalData,
globalPointNumberingPtr_,
globalPointSlavesPtr_,
globalPointSlavesMapPtr_
); );
const globalIndex& globalIndices = globalEdgeNumberingPtr_(); }
void Foam::globalMeshData::calcGlobalEdgeSlaves
(
const labelListList& pointSlaves,
const mapDistribute& pointSlavesMap,
const globalIndex& globalEdgeIndices,
autoPtr<labelListList>& globalEdgeSlavesPtr,
autoPtr<mapDistribute>& globalEdgeSlavesMapPtr
) const
{
// Coupled point to global coupled edges. // Coupled point to global coupled edges.
labelListList globalPointEdges(globalPointSlavesMap.constructSize()); labelListList globalPointEdges(pointSlavesMap.constructSize());
// Create local version // Create local version
const labelListList& pointEdges = coupledPatch().pointEdges(); const labelListList& pointEdges = coupledPatch().pointEdges();
@ -522,12 +528,12 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
globalPEdges.setSize(pEdges.size()); globalPEdges.setSize(pEdges.size());
forAll(pEdges, i) forAll(pEdges, i)
{ {
globalPEdges[i] = globalIndices.toGlobal(pEdges[i]); globalPEdges[i] = globalEdgeIndices.toGlobal(pEdges[i]);
} }
} }
// Pull slave data to master // Pull slave data to master
globalPointSlavesMap.distribute(globalPointEdges); pointSlavesMap.distribute(globalPointEdges);
// Now check on master if any of my edges are also on slave. // Now check on master if any of my edges are also on slave.
// This assumes that if slaves have a coupled edge it is also on // This assumes that if slaves have a coupled edge it is also on
@ -538,14 +544,14 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
const edgeList& edges = coupledPatch().edges(); const edgeList& edges = coupledPatch().edges();
// Create master to slave addressing. Empty for slave edges. // Create master to slave addressing. Empty for slave edges.
globalEdgeSlavesPtr_.reset(new labelListList(edges.size())); globalEdgeSlavesPtr.reset(new labelListList(edges.size()));
labelListList& globalEdgeSlaves = globalEdgeSlavesPtr_(); labelListList& globalEdgeSlaves = globalEdgeSlavesPtr();
forAll(edges, edgeI) forAll(edges, edgeI)
{ {
const edge& e = edges[edgeI]; const edge& e = edges[edgeI];
const labelList& slaves0 = globalPointSlaves[e[0]]; const labelList& slaves0 = pointSlaves[e[0]];
const labelList& slaves1 = globalPointSlaves[e[1]]; const labelList& slaves1 = pointSlaves[e[1]];
// Check for edges that are in both slaves0 and slaves1. // Check for edges that are in both slaves0 and slaves1.
pointEdgeSet.clear(); pointEdgeSet.clear();
@ -576,11 +582,11 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
// Construct map // Construct map
List<Map<label> > compactMap(Pstream::nProcs()); List<Map<label> > compactMap(Pstream::nProcs());
globalEdgeSlavesMapPtr_.reset globalEdgeSlavesMapPtr.reset
( (
new mapDistribute new mapDistribute
( (
globalIndices, globalEdgeIndices,
globalEdgeSlaves, globalEdgeSlaves,
compactMap compactMap
) )
@ -591,12 +597,39 @@ void Foam::globalMeshData::calcGlobalEdgeSlaves() const
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :" Pout<< "globalMeshData::calcGlobalEdgeSlaves() :"
<< " coupled edge:" << edges.size() << " coupled edge:" << edges.size()
<< " additional remote edges:" << " additional remote edges:"
<< globalEdgeSlavesMapPtr_().constructSize() - edges.size() << globalEdgeSlavesMapPtr().constructSize() - edges.size()
<< endl; << endl;
} }
} }
void Foam::globalMeshData::calcGlobalEdgeSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeSlaves() :"
<< " calculating coupled master to collocated slave"
<< " edge addressing." << endl;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const globalIndex& globalIndices = globalEdgeNumbering();
calcGlobalEdgeSlaves
(
globalPointSlaves(),
globalPointSlavesMap(),
globalIndices,
globalEdgeSlavesPtr_,
globalEdgeSlavesMapPtr_
);
}
// Calculate uncoupled boundary faces (without calculating // Calculate uncoupled boundary faces (without calculating
// primitiveMesh::pointFaces()) // primitiveMesh::pointFaces())
void Foam::globalMeshData::calcPointBoundaryFaces void Foam::globalMeshData::calcPointBoundaryFaces
@ -961,6 +994,55 @@ void Foam::globalMeshData::calcGlobalPointBoundaryCells() const
} }
void Foam::globalMeshData::calcGlobalPointAllSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalPointAllSlaves() :"
<< " calculating coupled master to slave point addressing."
<< endl;
}
// Calculate collocated&non-collocated connected points for master points.
globalPoints allGlobalData(mesh_, coupledPatch(), true, true);
calcGlobalPointSlaves
(
allGlobalData,
globalPointAllNumberingPtr_,
globalPointAllSlavesPtr_,
globalPointAllSlavesMapPtr_
);
}
void Foam::globalMeshData::calcGlobalEdgeAllSlaves() const
{
if (debug)
{
Pout<< "globalMeshData::calcGlobalEdgeAllSlaves() :"
<< " calculating coupled master to slave edge addressing."
<< endl;
}
// - Send across connected edges (in global edge addressing)
// - Check on receiving side whether edge has same slave edge
// on both endpoints.
// Create global numbering for coupled edges
const globalIndex& globalIndices = globalEdgeNumbering();
calcGlobalEdgeSlaves
(
globalPointAllSlaves(),
globalPointAllSlavesMap(),
globalIndices,
globalEdgeAllSlavesPtr_,
globalEdgeAllSlavesMapPtr_
);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from polyMesh // Construct from polyMesh
@ -1057,6 +1139,17 @@ void Foam::globalMeshData::clearOut()
globalBoundaryCellNumberingPtr_.clear(); globalBoundaryCellNumberingPtr_.clear();
globalPointBoundaryCellsPtr_.clear(); globalPointBoundaryCellsPtr_.clear();
globalPointBoundaryCellsMapPtr_.clear(); globalPointBoundaryCellsMapPtr_.clear();
//- Non-collocated
// Point
globalPointAllNumberingPtr_.clear();
globalPointAllSlavesPtr_.clear();
globalPointAllSlavesMapPtr_.clear();
// Edge
globalEdgeAllSlavesPtr_.clear();
globalEdgeAllSlavesMapPtr_.clear();
} }
@ -1212,7 +1305,7 @@ Foam::pointField Foam::globalMeshData::geometricSharedPoints() const
labelList pMap; labelList pMap;
pointField mergedPoints; pointField mergedPoints;
mergePoints Foam::mergePoints
( (
sharedPoints, // coordinates to merge sharedPoints, // coordinates to merge
tolDim, // tolerance tolDim, // tolerance
@ -1350,7 +1443,10 @@ const Foam::globalIndex& Foam::globalMeshData::globalEdgeNumbering() const
{ {
if (!globalEdgeNumberingPtr_.valid()) if (!globalEdgeNumberingPtr_.valid())
{ {
calcGlobalEdgeSlaves(); globalEdgeNumberingPtr_.reset
(
new globalIndex(coupledPatch().nEdges())
);
} }
return globalEdgeNumberingPtr_(); return globalEdgeNumberingPtr_();
} }
@ -1452,6 +1548,293 @@ const
} }
// Non-collocated coupled point/edge addressing
const Foam::globalIndex& Foam::globalMeshData::globalPointAllNumbering() const
{
if (!globalPointAllNumberingPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllNumberingPtr_();
}
const Foam::labelListList& Foam::globalMeshData::globalPointAllSlaves() const
{
if (!globalPointAllSlavesPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllSlavesPtr_();
}
const Foam::mapDistribute& Foam::globalMeshData::globalPointAllSlavesMap() const
{
if (!globalPointAllSlavesMapPtr_.valid())
{
calcGlobalPointAllSlaves();
}
return globalPointAllSlavesMapPtr_();
}
const Foam::labelListList& Foam::globalMeshData::globalEdgeAllSlaves() const
{
if (!globalEdgeAllSlavesPtr_.valid())
{
calcGlobalEdgeAllSlaves();
}
return globalEdgeAllSlavesPtr_();
}
const Foam::mapDistribute& Foam::globalMeshData::globalEdgeAllSlavesMap() const
{
if (!globalEdgeAllSlavesMapPtr_.valid())
{
calcGlobalEdgeAllSlaves();
}
return globalEdgeAllSlavesMapPtr_();
}
Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
(
labelList& pointToGlobal,
labelList& uniquePoints
) const
{
const indirectPrimitivePatch& cpp = coupledPatch();
const labelListList& pointSlaves = globalPointSlaves();
const mapDistribute& pointSlavesMap = globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
PackedBoolList isMaster(mesh_.nPoints(), 1);
forAll(pointSlaves, pointI)
{
const labelList& slavePoints = pointSlaves[pointI];
if (slavePoints.size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[cpp.meshPoints()[pointI]] = 0;
}
}
label myUniquePoints = mesh_.nPoints() - cpp.nPoints() + nCoupledMaster;
//Pout<< "Points :" << nl
// << " mesh : " << mesh_.nPoints() << nl
// << " of which coupled : " << cpp.nPoints() << nl
// << " of which master : " << nCoupledMaster << nl
// << endl;
// 2. Create global indexing for unique points.
autoPtr<globalIndex> globalPointsPtr(new globalIndex(myUniquePoints));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(mesh_.nPoints());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, meshPointI)
{
if (isMaster[meshPointI])
{
pointToGlobal[meshPointI] = globalPointsPtr().toGlobal(nMaster);
uniquePoints[nMaster] = meshPointI;
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
forAll(pointSlaves, pointI)
{
const labelList& slaves = pointSlaves[pointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
label meshPointI = cpp.meshPoints()[pointI];
masterToGlobal[pointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = masterToGlobal[pointI];
}
}
}
// Send back
pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
// On slave copy master index into overal map.
forAll(pointSlaves, pointI)
{
const labelList& slaves = pointSlaves[pointI];
if (slaves.size() == 0)
{
label meshPointI = cpp.meshPoints()[pointI];
pointToGlobal[meshPointI] = masterToGlobal[pointI];
}
}
}
return globalPointsPtr;
}
Foam::autoPtr<Foam::globalIndex> Foam::globalMeshData::mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
labelList& pointToGlobal,
labelList& uniquePoints
) const
{
const indirectPrimitivePatch& cpp = coupledPatch();
const labelListList& pointSlaves = globalPointSlaves();
const mapDistribute& pointSlavesMap = globalPointSlavesMap();
// 1. Count number of masters on my processor.
label nCoupledMaster = 0;
label nCoupledSlave = 0;
PackedBoolList isMaster(meshPoints.size(), 1);
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find(meshPointI);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
if (pointSlaves[coupledPointI].size() > 0)
{
nCoupledMaster++;
}
else
{
isMaster[localPointI] = 0;
nCoupledSlave++;
}
}
}
label myUniquePoints = meshPoints.size() + nCoupledMaster - nCoupledSlave;
Pout<< "Points :" << nl
<< " patch : " << meshPoints.size() << nl
<< " of which coupled : " << nCoupledMaster+nCoupledSlave << nl
<< " of which master : " << nCoupledMaster << nl
<< " of which slave : " << nCoupledSlave << nl
<< endl;
// 2. Create global indexing for unique points.
autoPtr<globalIndex> globalPointsPtr(new globalIndex(myUniquePoints));
// 3. Assign global point numbers. Keep slaves unset.
pointToGlobal.setSize(meshPoints.size());
pointToGlobal = -1;
uniquePoints.setSize(myUniquePoints);
label nMaster = 0;
forAll(isMaster, localPointI)
{
if (isMaster[localPointI])
{
pointToGlobal[localPointI] = globalPointsPtr().toGlobal(nMaster);
uniquePoints[nMaster] = localPointI;
nMaster++;
}
}
// 4. Push global index for coupled points to slaves.
{
labelList masterToGlobal(pointSlavesMap.constructSize(), -1);
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find
(
meshPointI
);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
const labelList& slaves = pointSlaves[coupledPointI];
if (slaves.size() > 0)
{
// Duplicate master globalpoint into slave slots
masterToGlobal[coupledPointI] = pointToGlobal[meshPointI];
forAll(slaves, i)
{
masterToGlobal[slaves[i]] = pointToGlobal[meshPointI];
}
}
}
}
// Send back
pointSlavesMap.reverseDistribute(cpp.nPoints(), masterToGlobal);
// On slave copy master index into overal map.
forAll(meshPoints, localPointI)
{
label meshPointI = meshPoints[localPointI];
Map<label>::const_iterator iter = cpp.meshPointMap().find
(
meshPointI
);
if (iter != cpp.meshPointMap().end())
{
// My localPointI is a coupled point.
label coupledPointI = iter();
const labelList& slaves = pointSlaves[coupledPointI];
if (slaves.size() == 0)
{
pointToGlobal[meshPointI] = masterToGlobal[coupledPointI];
}
}
}
}
return globalPointsPtr;
}
void Foam::globalMeshData::movePoints(const pointField& newPoints) void Foam::globalMeshData::movePoints(const pointField& newPoints)
{ {
// Topology does not change and we don't store any geometry so nothing // Topology does not change and we don't store any geometry so nothing
@ -1482,8 +1865,9 @@ void Foam::globalMeshData::updateMesh()
// Option 1. Topological // Option 1. Topological
{ {
// Calculate all shared points. This does all the hard work. // Calculate all shared points (excluded points that are only
globalPoints parallelPoints(mesh_, false); // on two coupled patches). This does all the hard work.
globalPoints parallelPoints(mesh_, false, true);
// Copy data out. // Copy data out.
nGlobalPoints_ = parallelPoints.nGlobalPoints(); nGlobalPoints_ = parallelPoints.nGlobalPoints();
@ -1505,6 +1889,16 @@ void Foam::globalMeshData::updateMesh()
// sharedEdgeAddr_ = parallelPoints.sharedEdgeAddr(); // sharedEdgeAddr_ = parallelPoints.sharedEdgeAddr();
//} //}
if (debug)
{
Pout<< "globalMeshData : nGlobalPoints_:" << nGlobalPoints_ << nl
<< "globalMeshData : sharedPointLabels_:"
<< sharedPointLabels_.size() << nl
<< "globalMeshData : sharedPointAddr_:"
<< sharedPointAddr_.size() << endl;
}
// Total number of faces. Start off from all faces. Remove coincident // Total number of faces. Start off from all faces. Remove coincident
// processor faces (on highest numbered processor) before summing. // processor faces (on highest numbered processor) before summing.
nTotalFaces_ = mesh_.nFaces(); nTotalFaces_ = mesh_.nFaces();

View File

@ -31,7 +31,7 @@ Description
Requires: Requires:
- all processor patches to have correct ordering. - all processor patches to have correct ordering.
- all processorPatches to have their transforms set ('makeTransforms') - all processorPatches to have their transforms set.
The shared point addressing is quite interesting. It gives on each processor The shared point addressing is quite interesting. It gives on each processor
the vertices that cannot be set using a normal swap on processor patches. the vertices that cannot be set using a normal swap on processor patches.
@ -67,14 +67,12 @@ Description
SourceFiles SourceFiles
globalMeshData.C globalMeshData.C
globalMeshDataMorph.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#ifndef globalMeshData_H #ifndef globalMeshData_H
#define globalMeshData_H #define globalMeshData_H
//#include "polyMesh.H"
#include "Switch.H" #include "Switch.H"
#include "processorTopology.H" #include "processorTopology.H"
#include "labelPair.H" #include "labelPair.H"
@ -95,6 +93,7 @@ class globalIndex;
class polyMesh; class polyMesh;
class mapDistribute; class mapDistribute;
template<class T> class EdgeMap; template<class T> class EdgeMap;
class globalPoints;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class globalMeshData Declaration Class globalMeshData Declaration
@ -201,31 +200,36 @@ class globalMeshData
// Coupled point addressing // Coupled point addressing
// This is addressing from coupled point to coupled points,faces,cells // This is addressing from coupled point to coupled points/faces/cells.
// Two variants:
// - collocated (so not physically separated)
// - also separated
// This is a full schedule so includes points only used by two // This is a full schedule so includes points only used by two
// coupled patches. // coupled patches.
mutable autoPtr<indirectPrimitivePatch> coupledPatchPtr_; mutable autoPtr<indirectPrimitivePatch> coupledPatchPtr_;
// Coupled point to coupled points // Collocated
// Coupled point to collocated coupled points
mutable autoPtr<globalIndex> globalPointNumberingPtr_; mutable autoPtr<globalIndex> globalPointNumberingPtr_;
mutable autoPtr<labelListList> globalPointSlavesPtr_; mutable autoPtr<labelListList> globalPointSlavesPtr_;
mutable autoPtr<mapDistribute> globalPointSlavesMapPtr_; mutable autoPtr<mapDistribute> globalPointSlavesMapPtr_;
// Coupled edge to coupled edges // Coupled edge to collocated coupled edges
mutable autoPtr<globalIndex> globalEdgeNumberingPtr_; mutable autoPtr<globalIndex> globalEdgeNumberingPtr_;
mutable autoPtr<labelListList> globalEdgeSlavesPtr_; mutable autoPtr<labelListList> globalEdgeSlavesPtr_;
mutable autoPtr<mapDistribute> globalEdgeSlavesMapPtr_; mutable autoPtr<mapDistribute> globalEdgeSlavesMapPtr_;
// Coupled point to boundary faces // Coupled point to collocated boundary faces
mutable autoPtr<globalIndex> globalBoundaryFaceNumberingPtr_; mutable autoPtr<globalIndex> globalBoundaryFaceNumberingPtr_;
mutable autoPtr<labelListList> globalPointBoundaryFacesPtr_; mutable autoPtr<labelListList> globalPointBoundaryFacesPtr_;
mutable autoPtr<mapDistribute> globalPointBoundaryFacesMapPtr_; mutable autoPtr<mapDistribute> globalPointBoundaryFacesMapPtr_;
// Coupled point to boundary cells // Coupled point to collocated boundary cells
mutable autoPtr<labelList> boundaryCellsPtr_; mutable autoPtr<labelList> boundaryCellsPtr_;
mutable autoPtr<globalIndex> globalBoundaryCellNumberingPtr_; mutable autoPtr<globalIndex> globalBoundaryCellNumberingPtr_;
@ -233,6 +237,21 @@ class globalMeshData
mutable autoPtr<mapDistribute> globalPointBoundaryCellsMapPtr_; mutable autoPtr<mapDistribute> globalPointBoundaryCellsMapPtr_;
// Non-collocated as well
// Coupled point to all coupled points
mutable autoPtr<globalIndex> globalPointAllNumberingPtr_;
mutable autoPtr<labelListList> globalPointAllSlavesPtr_;
mutable autoPtr<mapDistribute> globalPointAllSlavesMapPtr_;
// Coupled edge to all coupled edges (same numbering as
// collocated coupled edges)
mutable autoPtr<labelListList> globalEdgeAllSlavesPtr_;
mutable autoPtr<mapDistribute> globalEdgeAllSlavesMapPtr_;
// Private Member Functions // Private Member Functions
//- Set up processor patch addressing //- Set up processor patch addressing
@ -256,9 +275,28 @@ class globalMeshData
const vectorField& separationDist const vectorField& separationDist
); );
//- Calculate global point addressing.
void calcGlobalPointSlaves
(
const globalPoints&,
autoPtr<globalIndex>&,
autoPtr<labelListList>&,
autoPtr<mapDistribute>&
) const;
//- Calculate global point addressing. //- Calculate global point addressing.
void calcGlobalPointSlaves() const; void calcGlobalPointSlaves() const;
//- Calculate global edge addressing.
void calcGlobalEdgeSlaves
(
const labelListList&,
const mapDistribute&,
const globalIndex&,
autoPtr<labelListList>&,
autoPtr<mapDistribute>&
) const;
//- Calculate global edge addressing. //- Calculate global edge addressing.
void calcGlobalEdgeSlaves() const; void calcGlobalEdgeSlaves() const;
@ -272,6 +310,15 @@ class globalMeshData
void calcGlobalPointBoundaryCells() const; void calcGlobalPointBoundaryCells() const;
// Non-collocated
//- Calculate global point addressing.
void calcGlobalPointAllSlaves() const;
//- Calculate global edge addressing.
void calcGlobalEdgeAllSlaves() const;
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
globalMeshData(const globalMeshData&); globalMeshData(const globalMeshData&);
@ -449,8 +496,8 @@ public:
//- Return patch of all coupled faces //- Return patch of all coupled faces
const indirectPrimitivePatch& coupledPatch() const; const indirectPrimitivePatch& coupledPatch() const;
// Coupled point to coupled points. Coupled points are points on // Coupled point to collocated coupled points. Coupled points are
// any coupled patch. // points on any coupled patch.
//- Numbering of coupled points is according to coupledPatch. //- Numbering of coupled points is according to coupledPatch.
const globalIndex& globalPointNumbering() const; const globalIndex& globalPointNumbering() const;
@ -484,6 +531,45 @@ public:
const mapDistribute& globalPointBoundaryCellsMap() const; const mapDistribute& globalPointBoundaryCellsMap() const;
// Collocated & non-collocated
// Coupled point to all coupled points (collocated and
// non-collocated).
const globalIndex& globalPointAllNumbering()const;
const labelListList& globalPointAllSlaves() const;
const mapDistribute& globalPointAllSlavesMap() const;
// Coupled edge to all coupled edges (same numbering as
// collocated)
const labelListList& globalEdgeAllSlaves() const;
const mapDistribute& globalEdgeAllSlavesMap() const;
// Other
//- Helper for merging mesh point data. Determines
// - my unique indices
// - global numbering over all unique indices
// - the global number for all local points (so this will
// be local for my unique points)
autoPtr<globalIndex> mergePoints
(
labelList& pointToGlobal,
labelList& uniquePoints
) const;
//- Helper for merging patch point data. Takes maps from
// local points to/from mesh
autoPtr<globalIndex> mergePoints
(
const labelList& meshPoints,
const Map<label>& meshPointMap,
labelList& pointToGlobal,
labelList& uniquePoints
) const;
// Edit // Edit
//- Update for moving points. //- Update for moving points.

File diff suppressed because it is too large Load Diff

View File

@ -67,8 +67,8 @@ Description
At this point one will have complete point-point connectivity for all At this point one will have complete point-point connectivity for all
points on processor patches. Now points on processor patches. Now
- remove point equivalences of size 2. These are just normal points - (optional)remove point equivalences of size 2. These are
shared between two neighbouring procPatches. just normal points shared between two neighbouring procPatches.
- collect on each processor points for which it is the master - collect on each processor points for which it is the master
- request number of sharedPointLabels from the Pstream::master. - request number of sharedPointLabels from the Pstream::master.
@ -98,10 +98,10 @@ SourceFiles
#include "DynamicList.H" #include "DynamicList.H"
#include "Map.H" #include "Map.H"
#include "primitivePatch.H" #include "primitivePatch.H"
#include "className.H"
#include "edgeList.H" #include "edgeList.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "indirectPrimitivePatch.H" #include "indirectPrimitivePatch.H"
#include "PackedBoolList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -112,6 +112,8 @@ namespace Foam
class polyMesh; class polyMesh;
class polyBoundaryMesh; class polyBoundaryMesh;
class cyclicPolyPatch; class cyclicPolyPatch;
class polyPatch;
class coupledPolyPatch;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class globalPoints Declaration Class globalPoints Declaration
@ -119,7 +121,15 @@ class cyclicPolyPatch;
class globalPoints class globalPoints
{ {
// Private classes // Static data members
//- Offset to add to points (in globalIndices) originating from
// collocated coupled points.
static const label fromCollocated;
//- Distance to check whether points/faces are collocated.
static const scalar mergeDist;
// Private data // Private data
@ -152,13 +162,53 @@ class globalPoints
// Private Member Functions // Private Member Functions
//- Is identity transform?
static bool noTransform(const tensor&, const scalar mergeDist);
//- Return per face collocated status
static PackedBoolList collocatedFaces
(
const coupledPolyPatch&,
const scalar mergeDist
);
//- Return per point collocated status
static PackedBoolList collocatedPoints
(
const coupledPolyPatch&,
const scalar mergeDist
);
// Wrappers around global point numbering to add collocated bit
//- Convert into globalIndices and add collocated bit
label toGlobal(const label, const bool isCollocated) const;
//- Is collocated bit set
bool isCollocated(const label globalI) const;
//- Remove collocated bit
label removeCollocated(const label globalI) const;
//- (remove collocated bit and) check if originates from local proc
bool isLocal(const label globalI) const;
//- (remove collocated bit and) get originating processor
label whichProcID(const label globalI) const;
//- (remove collocated bit and) convert to local number on processor
label toLocal(const label procI, const label globalI) const;
//- (remove collocated bit and) convert to local number on
// Pstream::myProcNo
label toLocal(const label globalI) const;
//- Count all points on processorPatches. Is all points for which //- Count all points on processorPatches. Is all points for which
// information is collected. // information is collected.
static label countPatchPoints(const polyBoundaryMesh&); static label countPatchPoints(const polyBoundaryMesh&);
////- Get all faces on coupled patches
//static labelListl coupledFaces(const polyBoundaryMesh&);
//- Add information about patchPointI in relative indices to send //- Add information about patchPointI in relative indices to send
// buffers (patchFaces, indexInFace etc.) // buffers (patchFaces, indexInFace etc.)
static void addToSend static void addToSend
@ -197,9 +247,17 @@ class globalPoints
bool storeInfo bool storeInfo
( (
const labelList& nbrInfo, const labelList& nbrInfo,
const label localPointI const label localPointI,
const bool isCollocated
); );
void printProcPoints
(
const labelList& patchToMeshPoint,
const labelList& pointInfo,
Ostream& os
) const;
//- Initialize procPoints_ to my patch points. allPoints = true: //- Initialize procPoints_ to my patch points. allPoints = true:
// seed with all patch points, = false: only boundaryPoints(). // seed with all patch points, = false: only boundaryPoints().
void initOwnPoints void initOwnPoints
@ -212,6 +270,7 @@ class globalPoints
//- Send subset of procPoints to neighbours //- Send subset of procPoints to neighbours
void sendPatchPoints void sendPatchPoints
( (
const bool mergeSeparated,
const Map<label>&, const Map<label>&,
PstreamBuffers&, PstreamBuffers&,
const labelHashSet& const labelHashSet&
@ -220,6 +279,7 @@ class globalPoints
//- Receive neighbour points and merge into my procPoints. //- Receive neighbour points and merge into my procPoints.
void receivePatchPoints void receivePatchPoints
( (
const bool mergeSeparated,
const Map<label>&, const Map<label>&,
PstreamBuffers&, PstreamBuffers&,
labelHashSet& labelHashSet&
@ -230,20 +290,31 @@ class globalPoints
void remove(const labelList& patchToMeshPoint, const Map<label>&); void remove(const labelList& patchToMeshPoint, const Map<label>&);
//- Compact out unused elements of procPoints. //- Compact out unused elements of procPoints.
void compact(); void compact(const labelList& patchToMeshPoint);
//- Get indices of point for which I am master (lowest numbered proc) //- Get indices of point for which I am master (lowest numbered proc)
labelList getMasterPoints(const labelList& patchToMeshPoint) const; labelList getMasterPoints(const labelList& patchToMeshPoint) const;
//- Send subset of shared points to neighbours //- Send subset of shared points to neighbours
void sendSharedPoints(PstreamBuffers&, const labelList&) const; void sendSharedPoints
(
const bool mergeSeparated,
PstreamBuffers&,
const DynamicList<label>&
) const;
//- Take over any local shared points
void extendSharedPoints(const Map<label>&, DynamicList<label>&);
//- Receive shared points and update subset. //- Receive shared points and update subset.
void receiveSharedPoints void receiveSharedPoints
( (
const Map<label>&, const bool mergeSeparated,
const Map<label>& meshToPatchPoint,
const Map<label>& meshToShared,
PstreamBuffers&, PstreamBuffers&,
labelList& DynamicList<label>&
); );
//- Should move into cyclicPolyPatch ordering problem //- Should move into cyclicPolyPatch ordering problem
@ -255,7 +326,8 @@ class globalPoints
( (
const Map<label>&, const Map<label>&,
const labelList&, const labelList&,
const bool keepAllPoints const bool keepAllPoints,
const bool mergeSeparated
); );
//- Disallow default bitwise copy construct //- Disallow default bitwise copy construct
@ -276,7 +348,15 @@ public:
//- Construct from mesh. //- Construct from mesh.
// keepAllPoints = false : filter out points that are on two // keepAllPoints = false : filter out points that are on two
// neighbouring coupled patches (so can be swapped) // neighbouring coupled patches (so can be swapped)
globalPoints(const polyMesh& mesh, const bool keepAllPoints); // mergeSeparated:
// true : merge coupled points across separated patches.
// false : do not merge across coupled separated patches.
globalPoints
(
const polyMesh& mesh,
const bool keepAllPoints,
const bool mergeSeparated
);
//- Construct from mesh and patch of coupled faces. Difference with //- Construct from mesh and patch of coupled faces. Difference with
// construct from mesh only is that this stores the meshToProcPoint, // construct from mesh only is that this stores the meshToProcPoint,
@ -286,7 +366,8 @@ public:
( (
const polyMesh& mesh, const polyMesh& mesh,
const indirectPrimitivePatch& coupledPatch, const indirectPrimitivePatch& coupledPatch,
const bool keepAllPoints const bool keepAllPoints,
const bool mergeSeparated
); );

View File

@ -206,6 +206,15 @@ void Foam::processorPolyPatch::calcGeometry(PstreamBuffers& pBufs)
} }
else if (mag(magSf - nbrMagSf)/avSf > coupledPolyPatch::matchTol) else if (mag(magSf - nbrMagSf)/avSf > coupledPolyPatch::matchTol)
{ {
fileName nm
(
boundaryMesh().mesh().time().path()
/name()+"_faces.obj"
);
Pout<< "processorPolyPatch::order : Writing my " << size()
<< " faces to OBJ file " << nm << endl;
writeOBJ(nm, *this, points());
FatalErrorIn FatalErrorIn
( (
"processorPolyPatch::calcGeometry()" "processorPolyPatch::calcGeometry()"

View File

@ -61,7 +61,33 @@ Foam::displacementFvMotionSolver::displacementFvMotionSolver
) )
) )
) )
{} {
if (points0_.size() != mesh.nPoints())
{
FatalErrorIn
(
"displacementFvMotionSolver::displacementFvMotionSolver\n"
"(\n"
" const polyMesh&,\n"
" Istream&\n"
")"
) << "Number of points in mesh " << mesh.nPoints()
<< " differs from number of points " << points0_.size()
<< " read from file "
<<
IOobject
(
"points",
mesh.time().constant(),
polyMesh::meshSubDir,
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
).filePath()
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //

View File

@ -114,6 +114,32 @@ sixDoFRigidBodyDisplacementPointPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void sixDoFRigidBodyDisplacementPointPatchVectorField::autoMap
(
const pointPatchFieldMapper& m
)
{
fixedValuePointPatchField<vector>::autoMap(m);
p0_.autoMap(m);
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::rmap
(
const pointPatchField<vector>& ptf,
const labelList& addr
)
{
const sixDoFRigidBodyDisplacementPointPatchVectorField& sDoFptf =
refCast<const sixDoFRigidBodyDisplacementPointPatchVectorField>(ptf);
fixedValuePointPatchField<vector>::rmap(sDoFptf, addr);
p0_.rmap(sDoFptf.p0_, addr);
}
void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs() void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
{ {
if (this->updated()) if (this->updated())
@ -160,26 +186,6 @@ void sixDoFRigidBodyDisplacementPointPatchVectorField::updateCoeffs()
t.deltaTValue() t.deltaTValue()
); );
// ----------------------------------------
// vector rotationAxis(0, 1, 0);
// vector torque
// (
// (
// (fm.second().first() + fm.second().second())
// & rotationAxis
// )
// *rotationAxis
// );
// motion_.updateForce
// (
// vector::zero, // Force no centre of mass motion
// torque, // Only rotation allowed around the unit rotationAxis
// t.deltaTValue()
// );
// ----------------------------------------
Field<vector>::operator=(motion_.currentPosition(p0_) - p0_); Field<vector>::operator=(motion_.currentPosition(p0_) - p0_);
fixedValuePointPatchField<vector>::updateCoeffs(); fixedValuePointPatchField<vector>::updateCoeffs();

View File

@ -135,6 +135,22 @@ public:
// Member functions // Member functions
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const pointPatchFieldMapper&
);
//- Reverse map the given pointPatchField onto this pointPatchField
virtual void rmap
(
const pointPatchField<vector>&,
const labelList&
);
// Evaluation functions // Evaluation functions
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field

View File

@ -30,10 +30,20 @@ License
void Foam::sixDoFRigidBodyMotion::applyRestraints() void Foam::sixDoFRigidBodyMotion::applyRestraints()
{ {
if (restraints_.empty())
{
return;
}
if (Pstream::master()) if (Pstream::master())
{ {
forAll(restraints_, rI) forAll(restraints_, rI)
{ {
if (report_)
{
Info<< "Restraint " << restraintNames_[rI];
}
// restraint position // restraint position
point rP = vector::zero; point rP = vector::zero;
@ -57,9 +67,14 @@ void Foam::sixDoFRigidBodyMotion::applyRestraints()
void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT) void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
{ {
if (constraints_.empty())
{
return;
}
if (Pstream::master()) if (Pstream::master())
{ {
label iter = 0; label iteration = 0;
bool allConverged = true; bool allConverged = true;
@ -75,6 +90,11 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
forAll(constraints_, cI) forAll(constraints_, cI)
{ {
if (report_)
{
Info<< "Constraint " << constraintNames_[cI];
}
// constraint position // constraint position
point cP = vector::zero; point cP = vector::zero;
@ -104,9 +124,9 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
cMA += cM + ((cP - centreOfMass()) ^ cF); cMA += cM + ((cP - centreOfMass()) ^ cF);
} }
} while(++iter < maxConstraintIters_ && !allConverged); } while(++iteration < maxConstraintIterations_ && !allConverged);
if (iter >= maxConstraintIters_) if (iteration >= maxConstraintIterations_)
{ {
FatalErrorIn FatalErrorIn
( (
@ -114,13 +134,15 @@ void Foam::sixDoFRigidBodyMotion::applyConstraints(scalar deltaT)
"(scalar deltaT)" "(scalar deltaT)"
) )
<< nl << "Maximum number of sixDoFRigidBodyMotion constraint " << nl << "Maximum number of sixDoFRigidBodyMotion constraint "
<< "iterations (" << maxConstraintIters_ << ") exceeded." << nl << "iterations ("
<< maxConstraintIterations_
<< ") exceeded." << nl
<< exit(FatalError); << exit(FatalError);
} }
else if (report_) else if (report_)
{ {
Info<< "sixDoFRigidBodyMotion constraints converged in " Info<< "sixDoFRigidBodyMotion constraints converged in "
<< iter << " iterations" << iteration << " iterations"
<< nl << "Constraint force: " << cFA << nl << nl << "Constraint force: " << cFA << nl
<< "Constraint moment: " << cMA << "Constraint moment: " << cMA
<< endl; << endl;
@ -143,8 +165,10 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion()
: :
motionState_(), motionState_(),
restraints_(), restraints_(),
restraintNames_(),
constraints_(), constraints_(),
maxConstraintIters_(0), constraintNames_(),
maxConstraintIterations_(0),
refCentreOfMass_(vector::zero), refCentreOfMass_(vector::zero),
momentOfInertia_(diagTensor::one*VSMALL), momentOfInertia_(diagTensor::one*VSMALL),
mass_(VSMALL), mass_(VSMALL),
@ -176,8 +200,10 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
tau tau
), ),
restraints_(), restraints_(),
restraintNames_(),
constraints_(), constraints_(),
maxConstraintIters_(0), constraintNames_(),
maxConstraintIterations_(0),
refCentreOfMass_(refCentreOfMass), refCentreOfMass_(refCentreOfMass),
momentOfInertia_(momentOfInertia), momentOfInertia_(momentOfInertia),
mass_(mass), mass_(mass),
@ -189,8 +215,10 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion(const dictionary& dict)
: :
motionState_(dict), motionState_(dict),
restraints_(), restraints_(),
restraintNames_(),
constraints_(), constraints_(),
maxConstraintIters_(0), constraintNames_(),
maxConstraintIterations_(0),
refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())), refCentreOfMass_(dict.lookupOrDefault("refCentreOfMass", centreOfMass())),
momentOfInertia_(dict.lookup("momentOfInertia")), momentOfInertia_(dict.lookup("momentOfInertia")),
mass_(readScalar(dict.lookup("mass"))), mass_(readScalar(dict.lookup("mass"))),
@ -209,8 +237,10 @@ Foam::sixDoFRigidBodyMotion::sixDoFRigidBodyMotion
: :
motionState_(sDoFRBM.motionState()), motionState_(sDoFRBM.motionState()),
restraints_(sDoFRBM.restraints()), restraints_(sDoFRBM.restraints()),
restraintNames_(sDoFRBM.restraintNames()),
constraints_(sDoFRBM.constraints()), constraints_(sDoFRBM.constraints()),
maxConstraintIters_(sDoFRBM.maxConstraintIters()), constraintNames_(sDoFRBM.constraintNames()),
maxConstraintIterations_(sDoFRBM.maxConstraintIterations()),
refCentreOfMass_(sDoFRBM.refCentreOfMass()), refCentreOfMass_(sDoFRBM.refCentreOfMass()),
momentOfInertia_(sDoFRBM.momentOfInertia()), momentOfInertia_(sDoFRBM.momentOfInertia()),
mass_(sDoFRBM.mass()), mass_(sDoFRBM.mass()),
@ -239,23 +269,29 @@ void Foam::sixDoFRigidBodyMotion::addRestraints
restraints_.setSize(restraintDict.size()); restraints_.setSize(restraintDict.size());
restraintNames_.setSize(restraintDict.size());
forAllConstIter(IDLList<entry>, restraintDict, iter) forAllConstIter(IDLList<entry>, restraintDict, iter)
{ {
if (iter().isDict()) if (iter().isDict())
{ {
Info<< "Adding restraint: " << iter().keyword() << endl; // Info<< "Adding restraint: " << iter().keyword() << endl;
restraints_.set restraints_.set
( (
i, i,
sixDoFRigidBodyMotionRestraint::New(iter().dict()) sixDoFRigidBodyMotionRestraint::New(iter().dict())
); );
}
restraintNames_[i] = iter().keyword();
i++; i++;
} }
}
restraints_.setSize(i); restraints_.setSize(i);
restraintNames_.setSize(i);
} }
} }
@ -273,25 +309,33 @@ void Foam::sixDoFRigidBodyMotion::addConstraints
constraints_.setSize(constraintDict.size()); constraints_.setSize(constraintDict.size());
constraintNames_.setSize(constraintDict.size());
forAllConstIter(IDLList<entry>, constraintDict, iter) forAllConstIter(IDLList<entry>, constraintDict, iter)
{ {
if (iter().isDict()) if (iter().isDict())
{ {
Info<< "Adding constraint: " << iter().keyword() << endl; // Info<< "Adding constraint: " << iter().keyword() << endl;
constraints_.set constraints_.set
( (
i++, i,
sixDoFRigidBodyMotionConstraint::New(iter().dict()) sixDoFRigidBodyMotionConstraint::New(iter().dict())
); );
constraintNames_[i] = iter().keyword();
i++;
} }
} }
constraints_.setSize(i); constraints_.setSize(i);
if (constraints_.size()) constraintNames_.setSize(i);
if (!constraints_.empty())
{ {
maxConstraintIters_ = readLabel maxConstraintIterations_ = readLabel
( (
constraintDict.lookup("maxIterations") constraintDict.lookup("maxIterations")
); );

View File

@ -91,12 +91,18 @@ class sixDoFRigidBodyMotion
//- Restraints on the motion //- Restraints on the motion
PtrList<sixDoFRigidBodyMotionRestraint> restraints_; PtrList<sixDoFRigidBodyMotionRestraint> restraints_;
//- Names of the restraints
wordList restraintNames_;
//- Constaints on the motion //- Constaints on the motion
PtrList<sixDoFRigidBodyMotionConstraint> constraints_; PtrList<sixDoFRigidBodyMotionConstraint> constraints_;
//- Names of the constraints
wordList constraintNames_;
//- Maximum number of iterations allowed to attempt to obey //- Maximum number of iterations allowed to attempt to obey
// constraints // constraints
label maxConstraintIters_; label maxConstraintIterations_;
//- Centre of mass of reference state //- Centre of mass of reference state
point refCentreOfMass_; point refCentreOfMass_;
@ -146,13 +152,19 @@ class sixDoFRigidBodyMotion
inline const PtrList<sixDoFRigidBodyMotionRestraint>& inline const PtrList<sixDoFRigidBodyMotionRestraint>&
restraints() const; restraints() const;
//- Return access to the restraintNames
inline const wordList& restraintNames() const;
//- Return access to the constraints //- Return access to the constraints
inline const PtrList<sixDoFRigidBodyMotionConstraint>& inline const PtrList<sixDoFRigidBodyMotionConstraint>&
constraints() const; constraints() const;
//- Return access to the constraintNames
inline const wordList& constraintNames() const;
//- Return access to the maximum allowed number of //- Return access to the maximum allowed number of
// constraint iterations // constraint iterations
inline label maxConstraintIters() const; inline label maxConstraintIterations() const;
//- Return access to the centre of mass //- Return access to the centre of mass
inline const point& refCentreOfMass() const; inline const point& refCentreOfMass() const;

View File

@ -123,8 +123,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::constrain
if (motion.report()) if (motion.report())
{ {
Info<< "Constraint " << this->name() Info<< " angle " << theta
<< " angle " << theta
<< " force " << constraintForceIncrement << " force " << constraintForceIncrement
<< " moment " << constraintMomentIncrement; << " moment " << constraintMomentIncrement;
@ -175,4 +174,14 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionConstraints::fixedAxis::write
(
Ostream& os
) const
{
os.writeKeyword("axis")
<< fixedAxis_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -111,6 +111,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff); virtual bool read(const dictionary& sDoFRBMCCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -109,8 +109,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::constrain
if (motion.report()) if (motion.report())
{ {
Info<< "Constraint " << this->name() Info<< " error " << error
<< " error << " << error
<< " force " << constraintForceIncrement << " force " << constraintForceIncrement
<< " moment " << constraintMomentIncrement; << " moment " << constraintMomentIncrement;
@ -163,4 +162,17 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedLine::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionConstraints::fixedLine::write
(
Ostream& os
) const
{
os.writeKeyword("refPoint")
<< refPt_ << token::END_STATEMENT << nl;
os.writeKeyword("direction")
<< dir_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -112,6 +112,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff); virtual bool read(const dictionary& sDoFRBMCCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -150,8 +150,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::constrain
if (motion.report()) if (motion.report())
{ {
Info<< "Constraint " << this->name() Info<< " max angle " << maxTheta
<< " max angle " << maxTheta
<< " force " << constraintForceIncrement << " force " << constraintForceIncrement
<< " moment " << constraintMomentIncrement; << " moment " << constraintMomentIncrement;
@ -198,4 +197,14 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionConstraints::fixedOrientation::write
(
Ostream& os
) const
{
os.writeKeyword("fixedOrientation")
<< fixedOrientation_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -112,6 +112,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff); virtual bool read(const dictionary& sDoFRBMCCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -109,8 +109,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::constrain
if (motion.report()) if (motion.report())
{ {
Info<< "Constraint " << this->name() Info<< " error " << error
<< " error " << error
<< " force " << constraintForceIncrement << " force " << constraintForceIncrement
<< " moment " << constraintMomentIncrement; << " moment " << constraintMomentIncrement;
@ -146,4 +145,17 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionConstraints::fixedPlane::write
(
Ostream& os
) const
{
os.writeKeyword("refPoint")
<< fixedPlane_.refPoint() << token::END_STATEMENT << nl;
os.writeKeyword("normal")
<< fixedPlane_.normal() << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -110,6 +110,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff); virtual bool read(const dictionary& sDoFRBMCCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -118,8 +118,7 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::constrain
if (motion.report()) if (motion.report())
{ {
Info<< "Constraint " << this->name() Info<< " error " << error
<< " error " << error
<< " force " << constraintForceIncrement << " force " << constraintForceIncrement
<< " moment " << constraintMomentIncrement; << " moment " << constraintMomentIncrement;
@ -151,4 +150,14 @@ bool Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionConstraints::fixedPoint::write
(
Ostream& os
) const
{
os.writeKeyword("fixedPoint")
<< fixedPoint_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -111,6 +111,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCCoeff); virtual bool read(const dictionary& sDoFRBMCCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -34,8 +34,8 @@ Foam::sixDoFRigidBodyMotionConstraint::New(const dictionary& sDoFRBMCDict)
word sixDoFRigidBodyMotionConstraintTypeName = word sixDoFRigidBodyMotionConstraintTypeName =
sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint"); sDoFRBMCDict.lookup("sixDoFRigidBodyMotionConstraint");
Info<< "Selecting sixDoFRigidBodyMotionConstraint function " // Info<< "Selecting sixDoFRigidBodyMotionConstraint function "
<< sixDoFRigidBodyMotionConstraintTypeName << endl; // << sixDoFRigidBodyMotionConstraintTypeName << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find dictionaryConstructorTablePtr_->find

View File

@ -39,7 +39,6 @@ Foam::sixDoFRigidBodyMotionConstraint::sixDoFRigidBodyMotionConstraint
const dictionary& sDoFRBMCDict const dictionary& sDoFRBMCDict
) )
: :
name_(fileName(sDoFRBMCDict.name().name()).components(token::COLON).last()),
sDoFRBMCCoeffs_ sDoFRBMCCoeffs_
( (
sDoFRBMCDict.subDict sDoFRBMCDict.subDict
@ -83,4 +82,13 @@ bool Foam::sixDoFRigidBodyMotionConstraint::read
} }
void Foam::sixDoFRigidBodyMotionConstraint::write(Ostream& os) const
{
os.writeKeyword("tolerance")
<< tolerance_ << token::END_STATEMENT << nl;
os.writeKeyword("relaxationFactor")
<< relaxationFactor_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -70,9 +70,6 @@ protected:
// Protected data // Protected data
//- Name of the constraint in dictionary
word name_;
//- Constraint model specific coefficient dictionary //- Constraint model specific coefficient dictionary
dictionary sDoFRBMCCoeffs_; dictionary sDoFRBMCCoeffs_;
@ -145,16 +142,10 @@ public:
) const = 0; ) const = 0;
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMCDict) = 0; virtual bool read(const dictionary& sDoFRBMCDict);
// Access // Access
//- Return access to the name of the restraint
inline const word& name() const
{
return name_;
}
// Return access to sDoFRBMCCoeffs // Return access to sDoFRBMCCoeffs
inline const dictionary& coeffDict() const inline const dictionary& coeffDict() const
{ {
@ -172,6 +163,9 @@ public:
{ {
return relaxationFactor_; return relaxationFactor_;
} }
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -107,6 +107,12 @@ Foam::sixDoFRigidBodyMotion::restraints() const
} }
inline const Foam::wordList& Foam::sixDoFRigidBodyMotion::restraintNames() const
{
return restraintNames_;
}
inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionConstraint>& inline const Foam::PtrList<Foam::sixDoFRigidBodyMotionConstraint>&
Foam::sixDoFRigidBodyMotion::constraints() const Foam::sixDoFRigidBodyMotion::constraints() const
{ {
@ -114,9 +120,16 @@ Foam::sixDoFRigidBodyMotion::constraints() const
} }
inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIters() const inline const Foam::wordList&
Foam::sixDoFRigidBodyMotion::constraintNames() const
{ {
return maxConstraintIters_; return constraintNames_;
}
inline Foam::label Foam::sixDoFRigidBodyMotion::maxConstraintIterations() const
{
return maxConstraintIterations_;
} }

View File

@ -42,68 +42,67 @@ void Foam::sixDoFRigidBodyMotion::write(Ostream& os) const
os.writeKeyword("report") os.writeKeyword("report")
<< report_ << token::END_STATEMENT << nl; << report_ << token::END_STATEMENT << nl;
if (restraints_.size()) if (!restraints_.empty())
{ {
dictionary restraintsDict; os << indent << "restraints" << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
forAll(restraints_, rI) forAll(restraints_, rI)
{ {
word restraintType = restraints_[rI].type(); word restraintType = restraints_[rI].type();
dictionary restraintDict; os << indent << restraintNames_[rI] << nl
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
restraintDict.add("sixDoFRigidBodyMotionRestraint", restraintType); os.writeKeyword("sixDoFRigidBodyMotionRestraint")
<< restraintType << token::END_STATEMENT << nl;
restraintDict.add os.writeKeyword(word(restraintType + "Coeffs")) << nl;
(
word(restraintType + "Coeffs"), restraints_[rI].coeffDict()
);
restraintsDict.add(restraints_[rI].name(), restraintDict); os << indent << token::BEGIN_BLOCK << nl << incrIndent;
restraints_[rI].write(os);
os << decrIndent << indent << token::END_BLOCK << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
} }
os.writeKeyword("restraints") << restraintsDict; os << decrIndent << indent << token::END_BLOCK << nl;
} }
if (constraints_.size()) if (!constraints_.empty())
{ {
dictionary constraintsDict; os << indent << "constraints" << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
constraintsDict.add("maxIterations", maxConstraintIters_); os.writeKeyword("maxIterations")
<< maxConstraintIterations_ << token::END_STATEMENT << nl;
forAll(constraints_, rI) forAll(constraints_, rI)
{ {
word constraintType = constraints_[rI].type(); word constraintType = constraints_[rI].type();
dictionary constraintDict; os << indent << constraintNames_[rI] << nl
<< indent << token::BEGIN_BLOCK << incrIndent << endl;
constraintDict.add os.writeKeyword("sixDoFRigidBodyMotionConstraint")
( << constraintType << token::END_STATEMENT << nl;
"sixDoFRigidBodyMotionConstraint",
constraintType
);
constraintDict.add constraints_[rI].sixDoFRigidBodyMotionConstraint::write(os);
(
"tolerance",
constraints_[rI].tolerance()
);
constraintDict.add os.writeKeyword(word(constraintType + "Coeffs")) << nl;
(
"relaxationFactor",
constraints_[rI].relaxationFactor()
);
constraintDict.add os << indent << token::BEGIN_BLOCK << nl << incrIndent;
(
word(constraintType + "Coeffs"), constraints_[rI].coeffDict()
);
constraintsDict.add(constraints_[rI].name(), constraintDict); constraints_[rI].write(os);
os << decrIndent << indent << token::END_BLOCK << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
} }
os.writeKeyword("constraints") << constraintsDict; os << decrIndent << indent << token::END_BLOCK << nl;
} }
} }

View File

@ -136,8 +136,7 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain
if (motion.report()) if (motion.report())
{ {
Info<< "Restraint " << this->name() Info<< " angle " << theta
<< " angle " << theta
<< " force " << restraintForce << " force " << restraintForce
<< " moment " << restraintMoment << " moment " << restraintMoment
<< endl; << endl;
@ -199,4 +198,23 @@ bool Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::write
(
Ostream& os
) const
{
os.writeKeyword("referenceOrientation")
<< refQ_ << token::END_STATEMENT << nl;
os.writeKeyword("axis")
<< axis_ << token::END_STATEMENT << nl;
os.writeKeyword("stiffness")
<< stiffness_ << token::END_STATEMENT << nl;
os.writeKeyword("damping")
<< damping_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -114,6 +114,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRCoeff); virtual bool read(const dictionary& sDoFRBMRCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -96,8 +96,7 @@ void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::restrain
if (motion.report()) if (motion.report())
{ {
Info<< "Restraint " << this->name() Info<< " spring length " << magR
<< " spring length " << magR
<< " force " << restraintForce << " force " << restraintForce
<< " moment " << restraintMoment << " moment " << restraintMoment
<< endl; << endl;
@ -125,4 +124,26 @@ bool Foam::sixDoFRigidBodyMotionRestraints::linearSpring::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionRestraints::linearSpring::write
(
Ostream& os
) const
{
os.writeKeyword("anchor")
<< anchor_ << token::END_STATEMENT << nl;
os.writeKeyword("refAttachmentPt")
<< refAttachmentPt_ << token::END_STATEMENT << nl;
os.writeKeyword("stiffness")
<< stiffness_ << token::END_STATEMENT << nl;
os.writeKeyword("damping")
<< damping_ << token::END_STATEMENT << nl;
os.writeKeyword("restLength")
<< restLength_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -117,6 +117,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRCoeff); virtual bool read(const dictionary& sDoFRBMRCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -34,8 +34,8 @@ Foam::sixDoFRigidBodyMotionRestraint::New(const dictionary& sDoFRBMRDict)
word sixDoFRigidBodyMotionRestraintTypeName = word sixDoFRigidBodyMotionRestraintTypeName =
sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint"); sDoFRBMRDict.lookup("sixDoFRigidBodyMotionRestraint");
Info<< "Selecting sixDoFRigidBodyMotionRestraint function " // Info<< "Selecting sixDoFRigidBodyMotionRestraint function "
<< sixDoFRigidBodyMotionRestraintTypeName << endl; // << sixDoFRigidBodyMotionRestraintTypeName << endl;
dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find dictionaryConstructorTablePtr_->find

View File

@ -39,7 +39,6 @@ Foam::sixDoFRigidBodyMotionRestraint::sixDoFRigidBodyMotionRestraint
const dictionary& sDoFRBMRDict const dictionary& sDoFRBMRDict
) )
: :
name_(fileName(sDoFRBMRDict.name().name()).components(token::COLON).last()),
sDoFRBMRCoeffs_ sDoFRBMRCoeffs_
( (
sDoFRBMRDict.subDict sDoFRBMRDict.subDict

View File

@ -70,9 +70,6 @@ protected:
// Protected data // Protected data
//- Name of the constraint in dictionary
word name_;
//- Restraint model specific coefficient dictionary //- Restraint model specific coefficient dictionary
dictionary sDoFRBMRCoeffs_; dictionary sDoFRBMRCoeffs_;
@ -134,21 +131,18 @@ public:
) const = 0; ) const = 0;
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRDict) = 0; virtual bool read(const dictionary& sDoFRBMRDict);
// Access // Access
//- Return access to the name of the restraint
inline const word& name() const
{
return name_;
}
// Return access to sDoFRBMRCoeffs // Return access to sDoFRBMRCoeffs
inline const dictionary& coeffDict() const inline const dictionary& coeffDict() const
{ {
return sDoFRBMRCoeffs_; return sDoFRBMRCoeffs_;
} }
//- Write
virtual void write(Ostream&) const = 0;
}; };

View File

@ -113,8 +113,7 @@ Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::restrain
if (motion.report()) if (motion.report())
{ {
Info<< "Restraint " << this->name() Info<< " force " << restraintForce
<< " force " << restraintForce
<< " moment " << restraintMoment << " moment " << restraintMoment
<< endl; << endl;
} }
@ -153,4 +152,19 @@ bool Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionRestraints::sphericalAngularSpring::write
(
Ostream& os
) const
{
os.writeKeyword("referenceOrientation")
<< refQ_ << token::END_STATEMENT << nl;
os.writeKeyword("stiffness") << stiffness_ << token::END_STATEMENT << nl;
os.writeKeyword("damping") << damping_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -111,6 +111,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRCoeff); virtual bool read(const dictionary& sDoFRBMRCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -136,8 +136,7 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain
if (motion.report()) if (motion.report())
{ {
Info<< "Restraint " << this->name() Info<< " angle " << theta
<< " angle " << theta
<< " force " << restraintForce << " force " << restraintForce
<< " moment " << restraintMoment << " moment " << restraintMoment
<< endl; << endl;
@ -223,4 +222,34 @@ bool Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::read
return true; return true;
} }
void Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::write
(
Ostream& os
) const
{
os.writeKeyword("referenceOrientation")
<< refQ_ << token::END_STATEMENT << nl;
os.writeKeyword("axis")
<< axis_ << token::END_STATEMENT << nl;
moment_.write(os);
os.writeKeyword("angleFormat");
if (convertToDegrees_)
{
os << "degrees" << token::END_STATEMENT << nl;
}
else
{
os << "radians" << token::END_STATEMENT << nl;
}
os.writeKeyword("damping")
<< damping_ << token::END_STATEMENT << nl;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -121,6 +121,9 @@ public:
//- Update properties from given dictionary //- Update properties from given dictionary
virtual bool read(const dictionary& sDoFRBMRCoeff); virtual bool read(const dictionary& sDoFRBMRCoeff);
//- Write
virtual void write(Ostream&) const;
}; };

View File

@ -35,7 +35,7 @@ boundaryField
{ {
type sixDoFRigidBodyDisplacement; type sixDoFRigidBodyDisplacement;
centreOfMass (0.5 0.5 0.5); centreOfMass (0.5 0.5 0.5);
momentOfInertia (0.08622222 0.8622222 0.144); momentOfInertia (0.08622222 0.08622222 0.144);
mass 9.6; mass 9.6;
rhoInf 1; // for forces calculation rhoInf 1; // for forces calculation
// See sixDoFRigidBodyMotionState // See sixDoFRigidBodyMotionState