diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C index b1bcf33d82..be4fffa8df 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMesh.C @@ -132,456 +132,12 @@ Notes: #include "surfaceFields.H" #include "pointFields.H" //#include "ReadFields.H" - +#include "fvMeshTools.H" using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -//template -//void addPatchFields(const fvMesh& mesh, const word& patchFieldType) -//{ -// HashTable flds -// ( -// mesh.objectRegistry::lookupClass() -// ); -// -// forAllConstIter(typename HashTable, flds, iter) -// { -// const GeoField& fld = *iter(); -// -// typename GeoField::GeometricBoundaryField& bfld = -// const_cast -// ( -// fld.boundaryField() -// ); -// -// label sz = bfld.size(); -// -// for (label i = 0; i < sz; i++) -// { -// bfld.set -// ( -// i, -// bfld.clone(GeoField::PatchFieldType::New -// ( -// patchFieldType, -// fld.mesh().boundary()[sz], -// fld.dimensionedInternalField() -// ) -// ); -// -// -// -// Pout<< "fld:" << fld.name() << " had " << sz << " patches." << endl; -// Pout<< "fld before:" << fld << endl; -// Pout<< "adding on patch:" << fld.mesh().boundary()[sz].name() << endl; -// -// bfld.setSize(sz+1); -// bfld.set -// ( -// sz, -// GeoField::PatchFieldType::New -// ( -// patchFieldType, -// fld.mesh().boundary()[sz], -// fld.dimensionedInternalField() -// ) -// ); -// -// bfld[sz].operator=(pTraits::zero); -// -// Pout<< "fld:" << fld.name() << " now " << bfld.size() << " patches." -// << endl; -// -// const typename GeoField::PatchFieldType& pfld = bfld[sz]; -// Pout<< "pfld:" << pfld << endl; -// -// -// Pout<< "fld value:" << fld << endl; -// } -//} - - -// Remove last patch field -template -void trimPatchFields(fvMesh& mesh, const label nPatches) -{ - HashTable flds - ( - mesh.objectRegistry::lookupClass() - ); - - forAllConstIter(typename HashTable, flds, iter) - { - const GeoField& fld = *iter(); - - const_cast - ( - fld.boundaryField() - ).setSize(nPatches); - } -} - - -// Reorder patch field -template -void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew) -{ - HashTable flds - ( - mesh.objectRegistry::lookupClass() - ); - - forAllConstIter(typename HashTable, flds, iter) - { - const GeoField& fld = *iter(); - - typename GeoField::GeometricBoundaryField& bfld = - const_cast - ( - fld.boundaryField() - ); - - bfld.reorder(oldToNew); - } -} - - -//void addCalculatedPatchFields(const fvMesh& mesh) -//{ -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// -// // Surface fields -// -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// -// // Point fields -// -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -//} -// -// -//void addAllPatchFields(fvMesh& mesh, const label insertPatchI) -//{ -// polyBoundaryMesh& polyPatches = -// const_cast(mesh.boundaryMesh()); -// fvBoundaryMesh& fvPatches = const_cast(mesh.boundary()); -// -// label sz = polyPatches.size(); -// -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// -// // Surface fields -// -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// addPatchFields -// ( -// mesh, -// calculatedFvPatchField::typeName -// ); -// -// // Create reordering list -// // patches before insert position stay as is -// labelList oldToNew(sz); -// for (label i = 0; i < insertPatchI; i++) -// { -// oldToNew[i] = i; -// } -// // patches after insert position move one up -// for (label i = insertPatchI; i < sz-1; i++) -// { -// oldToNew[i] = i+1; -// } -// // appended patch gets moved to insert position -// oldToNew[sz-1] = insertPatchI; -// -// // Shuffle into place -// polyPatches.reorder(oldToNew); -// fvPatches.reorder(oldToNew); -// -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -// reorderPatchFields(mesh, oldToNew); -//} - - -//// Adds patch if not yet there. Returns patchID. -//template -//label addPatch(fvMesh& mesh, const word& patchName, const dictionary& dict) -//{ -// polyBoundaryMesh& polyPatches = -// const_cast(mesh.boundaryMesh()); -// -// label patchI = polyPatches.findPatchID(patchName); -// if (patchI != -1) -// { -// if (isA(polyPatches[patchI])) -// { -// // Already there -// return patchI; -// } -// else -// { -// FatalErrorIn("addPatch(fvMesh&, const word&)") -// << "Already have patch " << patchName -// << " but of type " << PatchType::typeName -// << exit(FatalError); -// } -// } -// -// -// label insertPatchI = polyPatches.size(); -// label startFaceI = mesh.nFaces(); -// -// forAll(polyPatches, patchI) -// { -// const polyPatch& pp = polyPatches[patchI]; -// -// if (isA(pp)) -// { -// insertPatchI = patchI; -// startFaceI = pp.start(); -// break; -// } -// } -// -// dictionary patchDict(dict); -// patchDict.set("type", PatchType::typeName); -// patchDict.set("nFaces", 0); -// patchDict.set("startFace", startFaceI); -// -// -// // Below is all quite a hack. Feel free to change once there is a better -// // mechanism to insert and reorder patches. -// -// // Clear local fields and e.g. polyMesh parallelInfo. -// mesh.clearOut(); -// -// label sz = polyPatches.size(); -// -// fvBoundaryMesh& fvPatches = const_cast(mesh.boundary()); -// -// // Add polyPatch at the end -// polyPatches.setSize(sz+1); -// polyPatches.set -// ( -// sz, -// polyPatch::New -// ( -// patchName, -// patchDict, -// insertPatchI, -// polyPatches -// ) -// ); -// fvPatches.setSize(sz+1); -// fvPatches.set -// ( -// sz, -// fvPatch::New -// ( -// polyPatches[sz], // point to newly added polyPatch -// mesh.boundary() -// ) -// ); -// -// addAllPatchFields(mesh, insertPatchI); -// -// return insertPatchI; -//} -// -// -//template -//label addPatch(fvMesh& mesh, const word& patchName) -//{ -//Pout<< "addPatch:" << patchName << endl; -// -// polyBoundaryMesh& polyPatches = -// const_cast(mesh.boundaryMesh()); -// -// label patchI = polyPatches.findPatchID(patchName); -// if (patchI != -1) -// { -// if (isA(polyPatches[patchI])) -// { -// // Already there -// return patchI; -// } -// else -// { -// FatalErrorIn("addPatch(fvMesh&, const word&)") -// << "Already have patch " << patchName -// << " but of type " << PatchType::typeName -// << exit(FatalError); -// } -// } -// -// -// label insertPatchI = polyPatches.size(); -// label startFaceI = mesh.nFaces(); -// -// forAll(polyPatches, patchI) -// { -// const polyPatch& pp = polyPatches[patchI]; -// -// if (isA(pp)) -// { -// insertPatchI = patchI; -// startFaceI = pp.start(); -// break; -// } -// } -// -// // Below is all quite a hack. Feel free to change once there is a better -// // mechanism to insert and reorder patches. -// -// // Clear local fields and e.g. polyMesh parallelInfo. -// mesh.clearOut(); -// -// label sz = polyPatches.size(); -// -// fvBoundaryMesh& fvPatches = const_cast(mesh.boundary()); -// -// // Add polyPatch at the end -// polyPatches.setSize(sz+1); -// polyPatches.set -// ( -// sz, -// polyPatch::New -// ( -// PatchType::typeName, -// patchName, -// 0, // size -// startFaceI, -// insertPatchI, -// polyPatches -// ) -// ); -// fvPatches.setSize(sz+1); -// fvPatches.set -// ( -// sz, -// fvPatch::New -// ( -// polyPatches[sz], // point to newly added polyPatch -// mesh.boundary() -// ) -// ); -// -// addAllPatchFields(mesh, insertPatchI); -// -// return insertPatchI; -//} - - label findPatchID(const List& newPatches, const word& name) { forAll(newPatches, i) @@ -712,53 +268,6 @@ label addPatch } -// Reorder and delete patches. -void reorderPatches -( - fvMesh& mesh, - const labelList& oldToNew, - const label nNewPatches -) -{ - polyBoundaryMesh& polyPatches = - const_cast(mesh.boundaryMesh()); - fvBoundaryMesh& fvPatches = const_cast(mesh.boundary()); - - // Shuffle into place - polyPatches.reorder(oldToNew); - fvPatches.reorder(oldToNew); - - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - reorderPatchFields(mesh, oldToNew); - - // Remove last. - polyPatches.setSize(nNewPatches); - fvPatches.setSize(nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); - trimPatchFields(mesh, nNewPatches); -} - - // Remove zero-sized patches void deleteEmptyPatches(fvMesh& mesh) { @@ -837,7 +346,7 @@ void deleteEmptyPatches(fvMesh& mesh) } } - reorderPatches(mesh, oldToNew, usedI); + fvMeshTools::reorderPatches(mesh, oldToNew, usedI, true); } @@ -1805,18 +1314,26 @@ int main(int argc, char *argv[]) mappedPatchBase::sampleModeNames_[dict.lookup("sampleMode")]; const Switch oneD(dict.lookup("oneD")); + Switch oneDNonManifoldEdges(false); + word oneDPatchType(emptyPolyPatch::typeName); + if (oneD) + { + oneDNonManifoldEdges = dict.lookupOrDefault("nonManifold", false); + dict.lookup("oneDPolyPatchType") >> oneDPatchType; + } + const Switch adaptMesh(dict.lookup("adaptMesh")); if (hasZones) { - Pout<< "Extruding zones " << zoneNames + Info<< "Extruding zones " << zoneNames << " on mesh " << regionName << " into shell mesh " << shellRegionName << endl; } else { - Pout<< "Extruding faceSets " << zoneNames + Info<< "Extruding faceSets " << zoneNames << " on mesh " << regionName << " into shell mesh " << shellRegionName << endl; @@ -1832,6 +1349,26 @@ int main(int argc, char *argv[]) } + if (oneD) + { + if (oneDNonManifoldEdges) + { + Info<< "Extruding as 1D columns with sides in patch type " + << oneDPatchType + << " and connected points (except on non-manifold areas)." + << endl; + } + else + { + Info<< "Extruding as 1D columns with sides in patch type " + << oneDPatchType + << " and duplicated points (overlapping volumes)." + << endl; + } + } + + + //// Read objects in time directory //IOobjectList objects(mesh, runTime.timeName()); @@ -1894,7 +1431,7 @@ int main(int argc, char *argv[]) { meshInstance = oldInstance; } - Pout<< "Writing meshes to " << meshInstance << nl << endl; + Info<< "Writing meshes to " << meshInstance << nl << endl; const polyBoundaryMesh& patches = mesh.boundaryMesh(); @@ -2130,7 +1667,7 @@ int main(int argc, char *argv[]) const labelListList& edgeFaces = extrudePatch.edgeFaces(); - Pout<< "extrudePatch :" + Info<< "extrudePatch :" << " faces:" << extrudePatch.size() << " points:" << extrudePatch.nPoints() << " edges:" << extrudePatch.nEdges() @@ -2325,7 +1862,7 @@ int main(int argc, char *argv[]) ( mesh, zoneNames, - (oneD ? dict.lookup("oneDPolyPatchType") : word::null), + (oneD ? oneDPatchType : word::null), regionPatches, zoneSidePatch @@ -2416,10 +1953,18 @@ int main(int argc, char *argv[]) { ePatches[i] = zoneSidePatch[zoneID[eFaces[i]]]; } - //- Set nonManifoldEdge[edgeI] for non-manifold edges only - // The other option is to have non-manifold edges everywhere - // and generate space overlapping columns of cells. - if (eFaces.size() != 2) + + if (oneDNonManifoldEdges) + { + //- Set nonManifoldEdge[edgeI] for non-manifold edges only + // The other option is to have non-manifold edges everywhere + // and generate space overlapping columns of cells. + if (eFaces.size() != 2) + { + nonManifoldEdge[edgeI] = 1; + } + } + else { nonManifoldEdge[edgeI] = 1; } @@ -2834,7 +2379,7 @@ int main(int argc, char *argv[]) "point to patch point addressing"; - Pout<< "Writing mesh " << regionMesh.name() + Info<< "Writing mesh " << regionMesh.name() << " to " << regionMesh.facesInstance() << nl << endl; @@ -3013,7 +2558,7 @@ int main(int argc, char *argv[]) // Remove any unused patches deleteEmptyPatches(mesh); - Pout<< "Writing mesh " << mesh.name() + Info<< "Writing mesh " << mesh.name() << " to " << mesh.facesInstance() << nl << endl; diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMeshDict b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMeshDict index a768615f85..ffa2db8b19 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMeshDict +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/extrudeToRegionMeshDict @@ -40,11 +40,20 @@ adaptMesh true; // Sample mode for inter-region communication sampleMode nearestPatchFace; -// Extrude 1D-columns of cells? -oneD false; -// If oneD is true. Specify which boundary is wanted between the layers -//oneDPolyPatchType empty; //wedge +// 1 D extrusion +// ~~~~~~~~~~~~~ + + // Extrude 1D-columns of cells? This by default duplicates points so can + // have overlapping columns (i.e. non space filling) + oneD false; + + //- If oneD: specify which boundary is wanted between the layers + //oneDPolyPatchType empty; //wedge + + //- If oneD: specify whether to duplicate points (i.e. disconnect 1D + // columns) or only on non-manifold extrusion areas. Default is false. + // nonManifold true; //- Extrusion model to use. The only logical choice is linearNormal? diff --git a/applications/utilities/mesh/manipulation/createBaffles/Make/files b/applications/utilities/mesh/manipulation/createBaffles/Make/files index 4d4c0ea538..734f2bce76 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/Make/files +++ b/applications/utilities/mesh/manipulation/createBaffles/Make/files @@ -1,3 +1,7 @@ +faceSelection/faceSelection.C +faceSelection/faceZoneSelection.C +faceSelection/searchableSurfaceSelection.C + createBaffles.C EXE = $(FOAM_APPBIN)/createBaffles diff --git a/applications/utilities/mesh/manipulation/createBaffles/Make/options b/applications/utilities/mesh/manipulation/createBaffles/Make/options index f7e0c60fed..3c8db28129 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/Make/options +++ b/applications/utilities/mesh/manipulation/createBaffles/Make/options @@ -1,4 +1,5 @@ EXE_INC = \ + -IfaceSelection \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 6fb57aa027..c2e2a06ebb 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -26,25 +26,26 @@ Description mergeOrSplitBaffles. Note: if any coupled patch face is selected for baffling the opposite - member has to be selected for baffling as well. Note that this - is the same as repatching. This was added only for convenience so - you don't have to filter coupled boundary out of your set. + member has to be selected for baffling as well. + + - if the patch already exists will not override it nor its fields + - if the patch does not exist it will be created together with 'calculated' + patchfields unless the field is mentioned in the patchFields section. \*---------------------------------------------------------------------------*/ -#include "syncTools.H" #include "argList.H" #include "Time.H" -#include "faceSet.H" #include "polyTopoChange.H" #include "polyModifyFace.H" #include "polyAddFace.H" #include "ReadFields.H" #include "volFields.H" #include "surfaceFields.H" -#include "ZoneIDs.H" #include "fvMeshMapper.H" -#include "SetPatchFields.H" +#include "faceSelection.H" + +#include "fvMeshTools.H" using namespace Foam; @@ -107,21 +108,6 @@ void modifyOrAddFace } -label findPatchID(const polyMesh& mesh, const word& name) -{ - const label patchI = mesh.boundaryMesh().findPatchID(name); - - if (patchI == -1) - { - FatalErrorIn("findPatchID(const polyMesh&, const word&)") - << "Cannot find patch " << name << endl - << "Valid patches are " << mesh.boundaryMesh().names() - << exit(FatalError); - } - return patchI; -} - - // Main program: int main(int argc, char *argv[]) @@ -129,102 +115,84 @@ int main(int argc, char *argv[]) argList::addNote ( "Makes internal faces into boundary faces.\n" - "Does not duplicate points, unlike mergeOrSplitBaffles." + "Does not duplicate points." ); #include "addOverwriteOption.H" - #include "addRegionOption.H" - - argList::validArgs.append("faceZone"); - argList::validArgs.append("(masterPatch slavePatch)"); argList::addOption ( - "additionalPatches", - "((master2 slave2) .. (masterN slaveN))" + "dict", + "file", + "specify alternative dictionary for the createBaffles description" ); - argList::addBoolOption - ( - "internalFacesOnly", - "do not convert boundary faces" - ); - argList::addBoolOption - ( - "updateFields", - "update fields to include new patches:" - " NOTE: updated field values may need to be edited" - ); - + #include "addRegionOption.H" #include "setRootCase.H" #include "createTime.H" runTime.functionObjects().off(); #include "createNamedMesh.H" + + const bool overwrite = args.optionFound("overwrite"); + const word oldInstance = mesh.pointsInstance(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - const faceZoneMesh& faceZones = mesh.faceZones(); - - // Faces to baffle - faceZoneID zoneID(args.additionalArgs()[0], faceZones); - - Info<< "Converting faces on zone " << zoneID.name() - << " into baffles." << nl << endl; - - if (zoneID.index() == -1) - { - FatalErrorIn(args.executable()) << "Cannot find faceZone " - << zoneID.name() << endl - << "Valid zones are " << faceZones.names() - << exit(FatalError); - } - - const faceZone& fZone = faceZones[zoneID.index()]; - - Info<< "Found " << returnReduce(fZone.size(), sumOp