void PackUnix::writePackHeader(OutputFile *fo) { unsigned char buf[32]; memset(buf, 0, sizeof(buf)); const int hsize = ph.getPackHeaderSize(); assert((unsigned)hsize <= sizeof(buf)); // note: magic constants are always le32 set_le32(buf+0, UPX_MAGIC_LE32); set_le32(buf+4, UPX_MAGIC2_LE32); checkPatch(NULL, 0, 0, 0); // reset patchPackHeader(buf, hsize); checkPatch(NULL, 0, 0, 0); // reset fo->write(buf, hsize); }
int main(int argc, char *argv[]) { Foam::argList::noParallel(); # include "addRegionOption.H" Foam::argList::validArgs.append("masterPatch"); Foam::argList::validArgs.append("slavePatch"); Foam::argList::validOptions.insert("partial", ""); Foam::argList::validOptions.insert("perfect", ""); Foam::argList::validOptions.insert("overwrite", ""); # include "setRootCase.H" # include "createTime.H" runTime.functionObjects().off(); # include "createNamedMesh.H" const word oldInstance = mesh.pointsInstance(); word masterPatchName(args.additionalArgs()[0]); word slavePatchName(args.additionalArgs()[1]); bool partialCover = args.optionFound("partial"); bool perfectCover = args.optionFound("perfect"); bool overwrite = args.optionFound("overwrite"); if (partialCover && perfectCover) { FatalErrorIn(args.executable()) << "Cannot both supply partial and perfect." << endl << "Use perfect match option if the patches perfectly align" << " (both vertex positions and face centres)" << endl << exit(FatalError); } const word mergePatchName(masterPatchName + slavePatchName); const word cutZoneName(mergePatchName + "CutFaceZone"); slidingInterface::typeOfMatch tom = slidingInterface::INTEGRAL; if (partialCover) { Info<< "Coupling partially overlapping patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting internal faces will be in faceZone " << cutZoneName << nl << "Any uncovered faces will remain in their patch" << endl; tom = slidingInterface::PARTIAL; } else if (perfectCover) { Info<< "Coupling perfectly aligned patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting (internal) faces will be in faceZone " << cutZoneName << nl << nl << "Note: both patches need to align perfectly." << nl << "Both the vertex" << " positions and the face centres need to align to within" << nl << "a tolerance given by the minimum edge length on the patch" << endl; } else { Info<< "Coupling patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting (internal) faces will be in faceZone " << cutZoneName << nl << nl << "Note: the overall area covered by both patches should be" << " identical (\"integral\" interface)." << endl << "If this is not the case use the -partial option" << nl << endl; } // Check for non-empty master and slave patches checkPatch(mesh.boundaryMesh(), masterPatchName); checkPatch(mesh.boundaryMesh(), slavePatchName); // Create and add face zones and mesh modifiers // Master patch const polyPatch& masterPatch = mesh.boundaryMesh() [ mesh.boundaryMesh().findPatchID(masterPatchName) ]; // Make list of masterPatch faces labelList isf(masterPatch.size()); forAll (isf, i) { isf[i] = masterPatch.start() + i; }
int main(int argc, char *argv[]) { argList::addNote ( "merge the faces on the specified patches (if geometrically possible)\n" "so the faces become internal" ); argList::noParallel(); #include "addOverwriteOption.H" #include "addRegionOption.H" argList::validArgs.append("masterPatch"); argList::validArgs.append("slavePatch"); argList::addBoolOption ( "partial", "couple partially overlapping patches" ); argList::addBoolOption ( "perfect", "couple perfectly aligned patches" ); argList::addOption ( "toleranceDict", "file", "dictionary file with tolerances" ); #include "setRootCase.H" #include "createTime.H" runTime.functionObjects().off(); #include "createNamedMesh.H" const word oldInstance = mesh.pointsInstance(); const word masterPatchName = args[1]; const word slavePatchName = args[2]; const bool partialCover = args.optionFound("partial"); const bool perfectCover = args.optionFound("perfect"); const bool overwrite = args.optionFound("overwrite"); if (partialCover && perfectCover) { FatalErrorIn(args.executable()) << "Cannot supply both partial and perfect." << endl << "Use perfect match option if the patches perfectly align" << " (both vertex positions and face centres)" << endl << exit(FatalError); } const word mergePatchName(masterPatchName + slavePatchName); const word cutZoneName(mergePatchName + "CutFaceZone"); slidingInterface::typeOfMatch tom = slidingInterface::INTEGRAL; if (partialCover) { Info<< "Coupling partially overlapping patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting internal faces will be in faceZone " << cutZoneName << nl << "Any uncovered faces will remain in their patch" << endl; tom = slidingInterface::PARTIAL; } else if (perfectCover) { Info<< "Coupling perfectly aligned patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting (internal) faces will be in faceZone " << cutZoneName << nl << nl << "Note: both patches need to align perfectly." << nl << "Both the vertex" << " positions and the face centres need to align to within" << nl << "a tolerance given by the minimum edge length on the patch" << endl; } else { Info<< "Coupling patches " << masterPatchName << " and " << slavePatchName << nl << "Resulting (internal) faces will be in faceZone " << cutZoneName << nl << nl << "Note: the overall area covered by both patches should be" << " identical (\"integral\" interface)." << endl << "If this is not the case use the -partial option" << nl << endl; } // set up the tolerances for the sliding mesh dictionary slidingTolerances; if (args.options().found("toleranceDict")) { IOdictionary toleranceFile ( IOobject ( args.options()["toleranceDict"], runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ); slidingTolerances += toleranceFile; } // Check for non-empty master and slave patches checkPatch(mesh.boundaryMesh(), masterPatchName); checkPatch(mesh.boundaryMesh(), slavePatchName); // Create and add face zones and mesh modifiers // Master patch const polyPatch& masterPatch = mesh.boundaryMesh()[masterPatchName]; // Make list of masterPatch faces labelList isf(masterPatch.size()); forAll(isf, i) { isf[i] = masterPatch.start() + i; }