diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake deleted file mode 100755 index 008c5cf8c4..0000000000 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -# Build optional components (eg, may depend on third-party libraries) -set -x - -# if the library exists, assume there are headers too -if [ -e $FOAM_LIBBIN/libccmio.so ] -then - wmake ccm26ToFoam -fi - -# end diff --git a/applications/utilities/mesh/conversion/Optional/AllwmakeOptional b/applications/utilities/mesh/conversion/Optional/AllwmakeOptional new file mode 100755 index 0000000000..95f041dd61 --- /dev/null +++ b/applications/utilities/mesh/conversion/Optional/AllwmakeOptional @@ -0,0 +1,19 @@ +#!/bin/sh +# Build optional components (eg, may depend on third-party libraries) +set -x + +# build libccmio if required +if [ ! -e $FOAM_LIBBIN/libccmio.so ] +then +( + cd $WM_THIRD_PARTY_DIR && ./AllwmakeLibccmio +) +fi + +# if the library built okay, the headers must exist too +if [ -e $FOAM_LIBBIN/libccmio.so ] +then + wmake ccm26ToFoam +fi + +# end diff --git a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/Make/options b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/Make/options index d10f04194a..e87c735e37 100644 --- a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/Make/options +++ b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/Make/options @@ -1,8 +1,8 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(THIRD_PARTY)/libccmio \ - -I$(THIRD_PARTY)/libccmio/lnInclude + -I${WM_THIRD_PARTY_DIR}/libccmio-2.6.1 \ + -I${WM_THIRD_PARTY_DIR}/libccmio-2.6.1/lnInclude EXE_LIBS = \ -lfiniteVolume \ diff --git a/applications/utilities/mesh/manipulation/setsToZones/setsToZones.C b/applications/utilities/mesh/manipulation/setsToZones/setsToZones.C index 8356e97aab..e826cd9dd3 100644 --- a/applications/utilities/mesh/manipulation/setsToZones/setsToZones.C +++ b/applications/utilities/mesh/manipulation/setsToZones/setsToZones.C @@ -88,9 +88,9 @@ int main(int argc, char *argv[]) polyMesh::meshSubDir/"sets" ); - Pout<< "Seached : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets" + Pout<< "Searched : " << mesh.pointsInstance()/polyMesh::meshSubDir/"sets" << nl - << "Found : " << objects.names() << nl + << "Found : " << objects.names() << nl << endl; @@ -108,8 +108,10 @@ int main(int argc, char *argv[]) // Not in memory. Load it. pointSet set(*iter()); - if (mesh.pointZones().findZoneID(set.name()) == -1) + label zoneID = mesh.pointZones().findZoneID(set.name()); + if (zoneID == -1) { + Info<< "Adding set " << set.name() << " as a pointZone." << endl; label sz = mesh.pointZones().size(); mesh.pointZones().setSize(sz+1); mesh.pointZones().set @@ -125,6 +127,13 @@ int main(int argc, char *argv[]) ); mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE; } + else + { + Info<< "Overwriting contents of existing pointZone " << zoneID + << " with that of set " << set.name() << "." << endl; + mesh.pointZones()[zoneID] = set.toc(); + mesh.pointZones().writeOpt() = IOobject::AUTO_WRITE; + } } @@ -142,8 +151,10 @@ int main(int argc, char *argv[]) // Not in memory. Load it. cellSet set(*iter()); - if (mesh.cellZones().findZoneID(set.name()) == -1) + label zoneID = mesh.cellZones().findZoneID(set.name()); + if (zoneID == -1) { + Info<< "Adding set " << set.name() << " as a cellZone." << endl; label sz = mesh.cellZones().size(); mesh.cellZones().setSize(sz+1); mesh.cellZones().set @@ -159,6 +170,13 @@ int main(int argc, char *argv[]) ); mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE; } + else + { + Info<< "Overwriting contents of existing cellZone " << zoneID + << " with that of set " << set.name() << "." << endl; + mesh.cellZones()[zoneID] = set.toc(); + mesh.cellZones().writeOpt() = IOobject::AUTO_WRITE; + } } @@ -262,8 +280,10 @@ int main(int argc, char *argv[]) } } - if (mesh.faceZones().findZoneID(set.name()) == -1) + label zoneID = mesh.faceZones().findZoneID(set.name()); + if (zoneID == -1) { + Info<< "Adding set " << set.name() << " as a faceZone." << endl; label sz = mesh.faceZones().size(); mesh.faceZones().setSize(sz+1); mesh.faceZones().set @@ -280,6 +300,17 @@ int main(int argc, char *argv[]) ); mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE; } + else + { + Info<< "Overwriting contents of existing faceZone " << zoneID + << " with that of set " << set.name() << "." << endl; + mesh.faceZones()[zoneID].resetAddressing + ( + addressing.shrink(), + flipMap.shrink() + ); + mesh.faceZones().writeOpt() = IOobject::AUTO_WRITE; + } } Pout<< "Writing mesh." << endl; diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index aea2a4af28..706b6dc58f 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -1,11 +1,11 @@ EXE_INC = \ -I$(LIB_SRC)/decompositionAgglomeration/decompositionMethods/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/lagrangian/basic/lnInclude + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude EXE_LIBS = \ -lfiniteVolume \ -ldecompositionMethods \ -llagrangian \ - -lmeshTools \ - + -lmeshTools diff --git a/applications/utilities/parallelProcessing/decomposePar/distributeCells.C b/applications/utilities/parallelProcessing/decomposePar/distributeCells.C index 8477a7d087..ef7a613a11 100644 --- a/applications/utilities/parallelProcessing/decomposePar/distributeCells.C +++ b/applications/utilities/parallelProcessing/decomposePar/distributeCells.C @@ -28,6 +28,8 @@ License #include "decompositionMethod.H" #include "cpuTime.H" #include "cyclicPolyPatch.H" +#include "cellSet.H" +#include "regionSplit.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -127,117 +129,34 @@ void domainDecomposition::distributeCells() } else { - - - // Work the faces whose neighbours need to be kept together into an - // agglomeration. - - // Per cell the region/agglomeration it is in - labelList cellToRegion(nCells(), -1); - - // Current region - label regionI = 0; - - labelHashSet freeRegions; + // Faces where owner and neighbour are not 'connected' (= all except + // sameProcFaces) + boolList blockedFace(nFaces(), true); forAllConstIter(labelHashSet, sameProcFaces, iter) { - label patchI = boundaryMesh().whichPatch(iter.key()); - - label own = faceOwner()[iter.key()]; - label nei = -1; - - if (patchI == -1) - { - nei = faceNeighbour()[iter.key()]; - } - else if (isA(boundaryMesh()[patchI])) - { - const cyclicPolyPatch& pp = - refCast(boundaryMesh()[patchI]); - - nei = faceOwner()[pp.transformGlobalFace(iter.key())]; - } - - if (nei != -1) - { - label ownRegion = cellToRegion[own]; - label neiRegion = cellToRegion[nei]; - - if (ownRegion == -1 && neiRegion == -1) - { - // Allocate new agglomeration - cellToRegion[own] = regionI; - cellToRegion[nei] = regionI; - regionI++; - } - else if (ownRegion != -1) - { - // Owner already part of agglomeration. Add nei to it. - cellToRegion[nei] = ownRegion; - } - else if (neiRegion != -1) - { - // nei already part of agglomeration. Add own to it. - cellToRegion[own] = neiRegion; - } - else if (ownRegion < neiRegion) - { - // Renumber neiRegion - forAll(cellToRegion, cellI) - { - if (cellToRegion[cellI] == neiRegion) - { - cellToRegion[cellI] = ownRegion; - } - } - freeRegions.insert(neiRegion); - } - else if (ownRegion > neiRegion) - { - // Renumber ownRegion - forAll(cellToRegion, cellI) - { - if (cellToRegion[cellI] == ownRegion) - { - cellToRegion[cellI] = neiRegion; - } - } - freeRegions.insert(ownRegion); - } - } + blockedFace[iter.key()] = false; } + // Connect coupled boundary faces + const polyBoundaryMesh& patches = boundaryMesh(); - // Do all other cells - forAll(cellToRegion, cellI) + forAll(patches, patchI) { - if (cellToRegion[cellI] == -1) + const polyPatch& pp = patches[patchI]; + + if (pp.coupled()) { - cellToRegion[cellI] = regionI++; - } - } - - - // Compact out freeRegions - // ~~~~~~~~~~~~~~~~~~~~~~~ - - { - labelList compactRegion(regionI, -1); - - regionI = 0; - - forAll(compactRegion, i) - { - if (!freeRegions.found(compactRegion[i])) + forAll(pp, i) { - compactRegion[i] = regionI++; + blockedFace[pp.start()+i] = false; } } - - inplaceRenumber(compactRegion, cellToRegion); } + // Determine global regions, separated by blockedFaces + regionSplit globalRegion(*this, blockedFace); + // Determine region cell centres // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -249,11 +168,11 @@ void domainDecomposition::distributeCells() const point greatPoint(GREAT, GREAT, GREAT); - pointField regionCentres(regionI, greatPoint); + pointField regionCentres(globalRegion.nRegions(), greatPoint); - forAll(cellToRegion, cellI) + forAll(globalRegion, cellI) { - label regionI = cellToRegion[cellI]; + label regionI = globalRegion[cellI]; if (regionCentres[regionI] == greatPoint) { @@ -261,10 +180,9 @@ void domainDecomposition::distributeCells() } } - // Do decomposition on agglomeration // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - cellToProc_ = decomposePtr().decompose(cellToRegion, regionCentres); + cellToProc_ = decomposePtr().decompose(globalRegion, regionCentres); } Info<< "\nFinished decomposition in " diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files index 44c513a079..d4c28fa64c 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/Make/files @@ -2,5 +2,7 @@ itoa.C ensightMesh.C ensightParticlePositions.C foamToEnsight.C +ensightWriteBinary.C EXE = $(FOAM_APPBIN)/foamToEnsight +//EXE = $(FOAM_USER_APPBIN)/foamToEnsight diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H index 37299fc2f3..e6e46c8f86 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/checkMeshMoving.H @@ -1,4 +1,5 @@ bool meshMoving = true; + if (Times.size() > 2) { for(label n2=2; n2 2) } else { -meshMoving = false; + meshMoving = false; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C index f600a765e6..4561a0b077 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C @@ -29,8 +29,8 @@ License #include "volFields.H" #include "OFstream.H" #include "IOmanip.H" - #include "itoa.H" +#include "ensightWriteBinary.H" using namespace Foam; @@ -40,7 +40,14 @@ void writeData(const scalarField& sf, OFstream& ensightFile) { forAll(sf, i) { - ensightFile << setw(12) << float(sf[i]) << nl; + if (mag( sf[i] ) >= scalar(floatScalarVSMALL)) + { + ensightFile << setw(12) << sf[i] << nl; + } + else + { + ensightFile << setw(12) << scalar(0) << nl; + } } } @@ -54,7 +61,7 @@ scalarField map ) { scalarField mf(map.size()); - + forAll(map, i) { mf[i] = component(vf[map[i]], cmpt); @@ -74,7 +81,7 @@ scalarField map ) { scalarField mf(map1.size() + map2.size()); - + forAll(map1, i) { mf[i] = component(vf[map1[i]], cmpt); @@ -131,6 +138,47 @@ void writeAllData } +template +void writeAllDataBinary +( + const char* key, + const Field& vf, + const labelList& prims, + const label nPrims, + std::ofstream& ensightFile +) +{ + if (nPrims) + { + if (Pstream::master()) + { + writeEnsDataBinary(key,ensightFile); + + for (direction cmpt=0; cmpt::nComponents; cmpt++) + { + writeEnsDataBinary(map(vf, prims, cmpt), ensightFile); + + for (int slave=1; slave::nComponents; cmpt++) + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< map(vf, prims, cmpt); + } + } + } +} + + + template void writeAllFaceData ( @@ -177,6 +225,52 @@ void writeAllFaceData } +template +void writeAllFaceDataBinary +( + const char* key, + const labelList& prims, + const label nPrims, + const Field& pf, + const labelList& patchProcessors, + std::ofstream& ensightFile +) +{ + if (nPrims) + { + if (Pstream::master()) + { + writeEnsDataBinary(key,ensightFile); + + for (direction cmpt=0; cmpt::nComponents; cmpt++) + { + writeEnsDataBinary(map(pf, prims, cmpt), ensightFile); + + forAll (patchProcessors, i) + { + if (patchProcessors[i] != 0) + { + label slave = patchProcessors[i]; + IPstream fromSlave(Pstream::scheduled, slave); + scalarField pf(fromSlave); + + writeEnsDataBinary(pf, ensightFile); + } + } + } + } + else + { + for (direction cmpt=0; cmpt::nComponents; cmpt++) + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< map(pf, prims, cmpt); + } + } + } +} + + template bool writePatchField ( @@ -193,7 +287,7 @@ bool writePatchField { if (Pstream::master()) { - ensightFile + ensightFile << "part" << nl << setw(10) << ensightPatchi << nl; } @@ -237,6 +331,65 @@ bool writePatchField } +template +bool writePatchFieldBinary +( + const Foam::Field& pf, + const Foam::label patchi, + const Foam::label ensightPatchi, + const Foam::faceSets& boundaryFaceSet, + const Foam::ensightMesh::nFacePrims& nfp, + const Foam::labelList& patchProcessors, + std::ofstream& ensightFile +) +{ + if (nfp.nTris || nfp.nQuads || nfp.nPolys) + { + if (Pstream::master()) + { + writeEnsDataBinary("part",ensightFile); + writeEnsDataBinary(ensightPatchi,ensightFile); + } + + writeAllFaceDataBinary + ( + "tria3", + boundaryFaceSet.tris, + nfp.nTris, + pf, + patchProcessors, + ensightFile + ); + + writeAllFaceDataBinary + ( + "quad4", + boundaryFaceSet.quads, + nfp.nQuads, + pf, + patchProcessors, + ensightFile + ); + + writeAllFaceDataBinary + ( + "nsided", + boundaryFaceSet.polys, + nfp.nPolys, + pf, + patchProcessors, + ensightFile + ); + + return true; + } + else + { + return false; + } +} + + template void writePatchField ( @@ -293,7 +446,7 @@ void writePatchField ensightCaseFile.setf(ios_base::left); ensightCaseFile - << pTraits::typeName + << pTraits::typeName << " per element: 1 " << setw(15) << pfName << (' ' + prepend + "***." + pfName).c_str() @@ -353,9 +506,8 @@ void writePatchField } } - template -void ensightField +void ensightFieldAscii ( const Foam::IOobject& fieldObject, const Foam::ensightMesh& eMesh, @@ -413,14 +565,14 @@ void ensightField ensightCaseFile.setf(ios_base::left); ensightCaseFile - << pTraits::typeName + << pTraits::typeName << " per element: 1 " << setw(15) << vf.name() << (' ' + prepend + "***." + vf.name()).c_str() << nl; } - ensightFile + ensightFile << pTraits::typeName << nl << "part" << nl << setw(10) << 1 << nl; @@ -501,7 +653,7 @@ void ensightField { ensightPatchi++; } - + } else if (Pstream::master()) { @@ -534,4 +686,213 @@ void ensightField } +template +void ensightFieldBinary +( + const Foam::IOobject& fieldObject, + const Foam::ensightMesh& eMesh, + const Foam::fileName& postProcPath, + const Foam::word& prepend, + const Foam::label timeIndex, + Foam::Ostream& ensightCaseFile +) +{ + Info<< "Converting field (binary) " << fieldObject.name() << endl; + + word timeFile = prepend + itoa(timeIndex); + + const fvMesh& mesh = eMesh.mesh; + //const Time& runTime = mesh.time(); + + const cellSets& meshCellSets = eMesh.meshCellSets; + const List& boundaryFaceSets = eMesh.boundaryFaceSets; + const HashTable& allPatchNames = eMesh.allPatchNames; + const HashTable