mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Updating utilities based on internal development line
This commit is contained in:
@ -34,7 +34,8 @@ Description
|
||||
NOTE: To avoid exposing wrong fields values faceSets should include
|
||||
faces contained in the blockedCells cellset.
|
||||
|
||||
- coupledFaces reads coupledFacesSet to introduces mixe-coupled baffles
|
||||
- coupledFaces reads coupledFacesSet to introduces mixed-coupled
|
||||
duplicate baffles
|
||||
|
||||
Subsets out the blocked cells and splits the blockedFaces and updates
|
||||
fields.
|
||||
|
||||
@ -17,7 +17,8 @@ FoamFile
|
||||
//- Per faceSet the patch the faces should go into blocked baffles
|
||||
blockedFaces ((blockedFacesSet blockedFaces));
|
||||
|
||||
//- Per faceSet the patch the faces should go into coupled baffles
|
||||
//- Per faceSet the duplicate baffles to generate (one 'normal', wall baffle,
|
||||
// one cyclic baffle). For use with active baffle boundary conditions.
|
||||
coupledFaces
|
||||
{
|
||||
coupledFacesSet
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -525,7 +525,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
Info<< "Created zone " << name
|
||||
<< " at index " << zoneID
|
||||
<< " with " << n << " faces" << endl;
|
||||
<< " with " << returnReduce(n, sumOp<label>()) << " faces" << endl;
|
||||
|
||||
mesh.faceZones().set
|
||||
(
|
||||
|
||||
@ -512,6 +512,11 @@ int main(int argc, char *argv[])
|
||||
#include "addOverwriteOption.H"
|
||||
#include "addRegionOption.H"
|
||||
#include "addDictOption.H"
|
||||
Foam::argList::addBoolOption
|
||||
(
|
||||
"writeObj",
|
||||
"write obj files showing the cyclic matching process"
|
||||
);
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
@ -523,12 +528,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
#include "createNamedPolyMesh.H"
|
||||
|
||||
const bool writeObj = args.optionFound("writeObj");
|
||||
|
||||
const word oldInstance = mesh.pointsInstance();
|
||||
|
||||
const word dictName("createPatchDict");
|
||||
#include "setSystemMeshDictionaryIO.H"
|
||||
|
||||
Info<< "Reading " << dictName << nl << endl;
|
||||
Info<< "Reading " << dictIO.instance()/dictIO.name() << nl << endl;
|
||||
|
||||
IOdictionary dict(dictIO);
|
||||
|
||||
@ -542,7 +548,10 @@ int main(int argc, char *argv[])
|
||||
patches.checkParallelSync(true);
|
||||
|
||||
|
||||
dumpCyclicMatch("initial_", mesh);
|
||||
if (writeObj)
|
||||
{
|
||||
dumpCyclicMatch("initial_", mesh);
|
||||
}
|
||||
|
||||
// Read patch construct info from dictionary
|
||||
PtrList<dictionary> patchSources(dict.lookup("patches"));
|
||||
@ -761,7 +770,10 @@ int main(int argc, char *argv[])
|
||||
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, true);
|
||||
mesh.movePoints(map().preMotionPoints());
|
||||
|
||||
dumpCyclicMatch("coupled_", mesh);
|
||||
if (writeObj)
|
||||
{
|
||||
dumpCyclicMatch("coupled_", mesh);
|
||||
}
|
||||
|
||||
// Synchronise points.
|
||||
if (!pointSync)
|
||||
@ -872,7 +884,10 @@ int main(int argc, char *argv[])
|
||||
filterPatches(mesh, addedPatchNames);
|
||||
|
||||
|
||||
dumpCyclicMatch("final_", mesh);
|
||||
if (writeObj)
|
||||
{
|
||||
dumpCyclicMatch("final_", mesh);
|
||||
}
|
||||
|
||||
|
||||
// Set the precision of the points data to 10
|
||||
|
||||
@ -96,6 +96,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing points into directory " << points.path() << nl << endl;
|
||||
points.write();
|
||||
|
||||
Info<< nl << "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -62,7 +62,6 @@ int main(int argc, char *argv[])
|
||||
"merge two meshes"
|
||||
);
|
||||
|
||||
argList::noParallel();
|
||||
#include "addOverwriteOption.H"
|
||||
|
||||
argList::validArgs.append("masterCase");
|
||||
@ -97,6 +96,18 @@ int main(int argc, char *argv[])
|
||||
word addRegion = polyMesh::defaultRegion;
|
||||
args.optionReadIfPresent("addRegion", addRegion);
|
||||
|
||||
// Since we don't use argList processor directory detection, add it to
|
||||
// the casename ourselves so it triggers the logic inside TimePath.
|
||||
const fileName& cName = args.caseName();
|
||||
std::string::size_type pos = cName.find("processor");
|
||||
if (pos != string::npos && pos != 0)
|
||||
{
|
||||
fileName processorName = cName.substr(pos, cName.size()-pos);
|
||||
masterCase += '/' + processorName;
|
||||
addCase += '/' + processorName;
|
||||
}
|
||||
|
||||
|
||||
getRootCase(masterCase);
|
||||
getRootCase(addCase);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -243,8 +243,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
|
||||
// Mirror boundary faces patch by patch
|
||||
|
||||
wordList newPatchTypes(boundary().size());
|
||||
wordList newPatchNames(boundary().size());
|
||||
|
||||
labelList newToOldPatch(boundary().size(), -1);
|
||||
|
||||
labelList newPatchSizes(boundary().size(), -1);
|
||||
labelList newPatchStarts(boundary().size(), -1);
|
||||
label nNewPatches = 0;
|
||||
@ -303,8 +304,8 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
// If patch exists, grab the name and type of the original patch
|
||||
if (nNewFaces > newPatchStarts[nNewPatches])
|
||||
{
|
||||
newPatchTypes[nNewPatches] = boundaryMesh()[patchI].type();
|
||||
newPatchNames[nNewPatches] = boundaryMesh()[patchI].name();
|
||||
newToOldPatch[nNewPatches] = patchI;
|
||||
|
||||
newPatchSizes[nNewPatches] =
|
||||
nNewFaces - newPatchStarts[nNewPatches];
|
||||
|
||||
@ -316,8 +317,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
newFaces.setSize(nNewFaces);
|
||||
Info<< " New faces: " << nNewFaces << endl;
|
||||
|
||||
newPatchTypes.setSize(nNewPatches);
|
||||
newPatchNames.setSize(nNewPatches);
|
||||
newToOldPatch.setSize(nNewPatches);
|
||||
newPatchSizes.setSize(nNewPatches);
|
||||
newPatchStarts.setSize(nNewPatches);
|
||||
|
||||
@ -377,18 +377,16 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
|
||||
fvMesh& pMesh = *mirrorMeshPtr_;
|
||||
|
||||
// Add the boundary patches
|
||||
List<polyPatch*> p(newPatchTypes.size());
|
||||
List<polyPatch*> p(newPatchSizes.size());
|
||||
|
||||
forAll(p, patchI)
|
||||
{
|
||||
p[patchI] = polyPatch::New
|
||||
p[patchI] = boundaryMesh()[newToOldPatch[patchI]].clone
|
||||
(
|
||||
newPatchTypes[patchI],
|
||||
newPatchNames[patchI],
|
||||
newPatchSizes[patchI],
|
||||
newPatchStarts[patchI],
|
||||
pMesh.boundaryMesh(),
|
||||
patchI,
|
||||
pMesh.boundaryMesh()
|
||||
newPatchSizes[patchI],
|
||||
newPatchStarts[patchI]
|
||||
).ptr();
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing mirrored mesh" << endl;
|
||||
mesh.mirrorMesh().write();
|
||||
|
||||
Info<< "End" << endl;
|
||||
Info<< "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anispulation |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -46,6 +46,9 @@ Description
|
||||
#include "zeroGradientFvPatchFields.H"
|
||||
#include "CuthillMcKeeRenumber.H"
|
||||
#include "fvMeshSubset.H"
|
||||
#include "cellSet.H"
|
||||
#include "faceSet.H"
|
||||
#include "pointSet.H"
|
||||
|
||||
#ifdef FOAM_USE_ZOLTAN
|
||||
#include "zoltanRenumber.H"
|
||||
@ -634,6 +637,12 @@ int main(int argc, char *argv[])
|
||||
"calculate the rms of the frontwidth"
|
||||
);
|
||||
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
|
||||
|
||||
// Force linker to include zoltan symbols. This section is only needed since
|
||||
// Zoltan is a static library
|
||||
#ifdef FOAM_USE_ZOLTAN
|
||||
@ -641,9 +650,6 @@ int main(int argc, char *argv[])
|
||||
(void)zoltanRenumber::typeName;
|
||||
#endif
|
||||
|
||||
#include "setRootCase.H"
|
||||
#include "createTime.H"
|
||||
runTime.functionObjects().off();
|
||||
|
||||
// Get times list
|
||||
instantList Times = runTime.times();
|
||||
@ -700,6 +706,7 @@ int main(int argc, char *argv[])
|
||||
bool writeMaps = false;
|
||||
bool orderPoints = false;
|
||||
label blockSize = 0;
|
||||
bool renumberSets = true;
|
||||
|
||||
// Construct renumberMethod
|
||||
autoPtr<IOdictionary> renumberDictPtr;
|
||||
@ -760,6 +767,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing renumber maps (new to old) to polyMesh." << nl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
renumberSets = renumberDict.lookupOrDefault("renumberSets", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -861,6 +870,71 @@ int main(int argc, char *argv[])
|
||||
PtrList<surfaceTensorField> stFlds;
|
||||
ReadFields(mesh, objects, stFlds);
|
||||
|
||||
// Read point fields.
|
||||
|
||||
PtrList<pointScalarField> psFlds;
|
||||
ReadFields(pointMesh::New(mesh), objects, psFlds);
|
||||
|
||||
PtrList<pointVectorField> pvFlds;
|
||||
ReadFields(pointMesh::New(mesh), objects, pvFlds);
|
||||
|
||||
PtrList<pointSphericalTensorField> pstFlds;
|
||||
ReadFields(pointMesh::New(mesh), objects, pstFlds);
|
||||
|
||||
PtrList<pointSymmTensorField> psymtFlds;
|
||||
ReadFields(pointMesh::New(mesh), objects, psymtFlds);
|
||||
|
||||
PtrList<pointTensorField> ptFlds;
|
||||
ReadFields(pointMesh::New(mesh), objects, ptFlds);
|
||||
|
||||
// Read sets
|
||||
PtrList<cellSet> cellSets;
|
||||
PtrList<faceSet> faceSets;
|
||||
PtrList<pointSet> pointSets;
|
||||
if (renumberSets)
|
||||
{
|
||||
// Read sets
|
||||
IOobjectList objects(mesh, mesh.facesInstance(), "polyMesh/sets");
|
||||
{
|
||||
IOobjectList cSets(objects.lookupClass(cellSet::typeName));
|
||||
if (cSets.size())
|
||||
{
|
||||
Info<< "Reading cellSets:" << endl;
|
||||
forAllConstIter(IOobjectList, cSets, iter)
|
||||
{
|
||||
cellSets.append(new cellSet(*iter()));
|
||||
Info<< " " << cellSets.last().name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList fSets(objects.lookupClass(faceSet::typeName));
|
||||
if (fSets.size())
|
||||
{
|
||||
Info<< "Reading faceSets:" << endl;
|
||||
forAllConstIter(IOobjectList, fSets, iter)
|
||||
{
|
||||
faceSets.append(new faceSet(*iter()));
|
||||
Info<< " " << faceSets.last().name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
IOobjectList pSets(objects.lookupClass(pointSet::typeName));
|
||||
if (pSets.size())
|
||||
{
|
||||
Info<< "Reading pointSets:" << endl;
|
||||
forAllConstIter(IOobjectList, pSets, iter)
|
||||
{
|
||||
pointSets.append(new pointSet(*iter()));
|
||||
Info<< " " << pointSets.last().name() << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Info<< endl;
|
||||
|
||||
// From renumbering:
|
||||
@ -1055,7 +1129,6 @@ int main(int argc, char *argv[])
|
||||
mesh.updateMesh(map);
|
||||
|
||||
// Update proc maps
|
||||
if (cellProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
cellProcAddressing.headerOk()
|
||||
@ -1070,7 +1143,6 @@ int main(int argc, char *argv[])
|
||||
UIndirectList<label>(cellProcAddressing, map().cellMap())
|
||||
);
|
||||
}
|
||||
if (faceProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
faceProcAddressing.headerOk()
|
||||
@ -1101,7 +1173,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pointProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
pointProcAddressing.headerOk()
|
||||
@ -1226,46 +1297,79 @@ int main(int argc, char *argv[])
|
||||
|
||||
mesh.write();
|
||||
if (cellProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
cellProcAddressing.headerOk()
|
||||
&& cellProcAddressing.size() == mesh.nCells()
|
||||
)
|
||||
{
|
||||
cellProcAddressing.instance() = mesh.facesInstance();
|
||||
cellProcAddressing.write();
|
||||
if (cellProcAddressing.size() == mesh.nCells())
|
||||
{
|
||||
cellProcAddressing.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
// procAddressing no longer valid. Delete it.
|
||||
const fileName fName(cellProcAddressing.filePath());
|
||||
if (fName.size())
|
||||
{
|
||||
Info<< "Deleting inconsistent processor cell decomposition"
|
||||
<< " map " << fName << endl;
|
||||
rm(fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (faceProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
faceProcAddressing.headerOk()
|
||||
&& faceProcAddressing.size() == mesh.nFaces()
|
||||
)
|
||||
{
|
||||
faceProcAddressing.instance() = mesh.facesInstance();
|
||||
faceProcAddressing.write();
|
||||
}
|
||||
if (pointProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
pointProcAddressing.headerOk()
|
||||
&& pointProcAddressing.size() == mesh.nPoints()
|
||||
)
|
||||
{
|
||||
pointProcAddressing.instance() = mesh.facesInstance();
|
||||
pointProcAddressing.write();
|
||||
}
|
||||
if (boundaryProcAddressing.headerOk())
|
||||
if
|
||||
(
|
||||
boundaryProcAddressing.headerOk()
|
||||
&& boundaryProcAddressing.size() == mesh.boundaryMesh().size()
|
||||
)
|
||||
{
|
||||
boundaryProcAddressing.instance() = mesh.facesInstance();
|
||||
boundaryProcAddressing.write();
|
||||
if (faceProcAddressing.size() == mesh.nFaces())
|
||||
{
|
||||
faceProcAddressing.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
const fileName fName(faceProcAddressing.filePath());
|
||||
if (fName.size())
|
||||
{
|
||||
Info<< "Deleting inconsistent processor face decomposition"
|
||||
<< " map " << fName << endl;
|
||||
rm(fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pointProcAddressing.headerOk())
|
||||
{
|
||||
pointProcAddressing.instance() = mesh.facesInstance();
|
||||
if (pointProcAddressing.size() == mesh.nPoints())
|
||||
{
|
||||
pointProcAddressing.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
const fileName fName(pointProcAddressing.filePath());
|
||||
if (fName.size())
|
||||
{
|
||||
Info<< "Deleting inconsistent processor point decomposition"
|
||||
<< " map " << fName << endl;
|
||||
rm(fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (boundaryProcAddressing.headerOk())
|
||||
{
|
||||
boundaryProcAddressing.instance() = mesh.facesInstance();
|
||||
if (boundaryProcAddressing.size() == mesh.boundaryMesh().size())
|
||||
{
|
||||
boundaryProcAddressing.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
const fileName fName(boundaryProcAddressing.filePath());
|
||||
if (fName.size())
|
||||
{
|
||||
Info<< "Deleting inconsistent processor patch decomposition"
|
||||
<< " map " << fName << endl;
|
||||
rm(fName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (writeMaps)
|
||||
{
|
||||
@ -1331,6 +1435,28 @@ int main(int argc, char *argv[])
|
||||
).write();
|
||||
}
|
||||
|
||||
if (renumberSets)
|
||||
{
|
||||
forAll(cellSets, i)
|
||||
{
|
||||
cellSets[i].updateMesh(map());
|
||||
cellSets[i].instance() = mesh.facesInstance();
|
||||
cellSets[i].write();
|
||||
}
|
||||
forAll(faceSets, i)
|
||||
{
|
||||
faceSets[i].updateMesh(map());
|
||||
faceSets[i].instance() = mesh.facesInstance();
|
||||
faceSets[i].write();
|
||||
}
|
||||
forAll(pointSets, i)
|
||||
{
|
||||
pointSets[i].updateMesh(map());
|
||||
pointSets[i].instance() = mesh.facesInstance();
|
||||
pointSets[i].write();
|
||||
}
|
||||
}
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
return 0;
|
||||
|
||||
@ -34,6 +34,8 @@ sortCoupledFaceCells false;
|
||||
// Optional entry: sort points into internal and boundary points
|
||||
//orderPoints false;
|
||||
|
||||
// Optional: suppress renumbering cellSets,faceSets,pointSets
|
||||
//renumberSets false;
|
||||
|
||||
|
||||
method CuthillMcKee;
|
||||
|
||||
@ -287,7 +287,8 @@ int main(int argc, char *argv[])
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
Info<< nl << "end" << endl;
|
||||
Info<< nl << "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -499,7 +499,7 @@ int main(int argc, char *argv[])
|
||||
// Write fields
|
||||
runTime.write();
|
||||
|
||||
Info<< nl << "end" << endl;
|
||||
Info<< nl << "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -41,11 +41,86 @@ Description
|
||||
#include "cellSet.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "volFields.H"
|
||||
#include "topoDistanceData.H"
|
||||
#include "FaceCellWave.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
labelList nearestPatch(const polyMesh& mesh, const labelList& patchIDs)
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
|
||||
|
||||
// Count number of faces in exposedPatchIDs
|
||||
label nFaces = 0;
|
||||
forAll(patchIDs, i)
|
||||
{
|
||||
const polyPatch& pp = pbm[patchIDs[i]];
|
||||
nFaces += pp.size();
|
||||
}
|
||||
|
||||
// Field on cells and faces.
|
||||
List<topoDistanceData> cellData(mesh.nCells());
|
||||
List<topoDistanceData> faceData(mesh.nFaces());
|
||||
|
||||
// Start of changes
|
||||
labelList patchFaces(nFaces);
|
||||
List<topoDistanceData> patchData(nFaces);
|
||||
nFaces = 0;
|
||||
forAll(patchIDs, i)
|
||||
{
|
||||
label patchI = patchIDs[i];
|
||||
const polyPatch& pp = pbm[patchI];
|
||||
|
||||
forAll(pp, i)
|
||||
{
|
||||
patchFaces[nFaces] = pp.start()+i;
|
||||
patchData[nFaces] = topoDistanceData(patchI, 0);
|
||||
nFaces++;
|
||||
}
|
||||
}
|
||||
|
||||
// Propagate information inwards
|
||||
FaceCellWave<topoDistanceData> deltaCalc
|
||||
(
|
||||
mesh,
|
||||
patchFaces,
|
||||
patchData,
|
||||
faceData,
|
||||
cellData,
|
||||
mesh.globalData().nTotalCells()+1
|
||||
);
|
||||
|
||||
// And extract
|
||||
|
||||
labelList nearest(mesh.nFaces());
|
||||
|
||||
bool haveWarned = false;
|
||||
forAll(faceData, faceI)
|
||||
{
|
||||
if (!faceData[faceI].valid(deltaCalc.data()))
|
||||
{
|
||||
if (!haveWarned)
|
||||
{
|
||||
WarningIn("meshRefinement::nearestPatch(..)")
|
||||
<< "Did not visit some faces, e.g. face " << faceI
|
||||
<< " at " << mesh.faceCentres()[faceI] << endl
|
||||
<< "Using patch " << patchIDs[0] << " as nearest"
|
||||
<< endl;
|
||||
haveWarned = true;
|
||||
}
|
||||
nearest[faceI] = patchIDs[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
nearest[faceI] = faceData[faceI].data();
|
||||
}
|
||||
}
|
||||
|
||||
return nearest;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetVolFields
|
||||
@ -150,6 +225,40 @@ void subsetPointFields
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void subsetDimensionedFields
|
||||
(
|
||||
const fvMeshSubset& subsetter,
|
||||
const wordList& fieldNames,
|
||||
PtrList<DimensionedField<Type, volMesh> >& subFields
|
||||
)
|
||||
{
|
||||
const fvMesh& baseMesh = subsetter.baseMesh();
|
||||
|
||||
forAll(fieldNames, i)
|
||||
{
|
||||
const word& fieldName = fieldNames[i];
|
||||
|
||||
Info<< "Subsetting field " << fieldName << endl;
|
||||
|
||||
DimensionedField<Type, volMesh> fld
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
fieldName,
|
||||
baseMesh.time().timeName(),
|
||||
baseMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
baseMesh
|
||||
);
|
||||
|
||||
subFields.set(i, subsetter.interpolate(fld));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -169,6 +278,13 @@ int main(int argc, char *argv[])
|
||||
"'oldInternalFaces'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"patches",
|
||||
"names",
|
||||
"add exposed internal faces to nearest of specified patches"
|
||||
" instead of to 'oldInternalFaces'"
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"resultTime",
|
||||
"time",
|
||||
@ -207,15 +323,19 @@ int main(int argc, char *argv[])
|
||||
// Create mesh subsetting engine
|
||||
fvMeshSubset subsetter(mesh);
|
||||
|
||||
label patchI = -1;
|
||||
labelList exposedPatchIDs;
|
||||
|
||||
if (args.optionFound("patch"))
|
||||
{
|
||||
const word patchName = args["patch"];
|
||||
|
||||
patchI = mesh.boundaryMesh().findPatchID(patchName);
|
||||
exposedPatchIDs = labelList
|
||||
(
|
||||
1,
|
||||
mesh.boundaryMesh().findPatchID(patchName)
|
||||
);
|
||||
|
||||
if (patchI == -1)
|
||||
if (exposedPatchIDs[0] == -1)
|
||||
{
|
||||
FatalErrorIn(args.executable()) << "Illegal patch " << patchName
|
||||
<< nl << "Valid patches are " << mesh.boundaryMesh().names()
|
||||
@ -225,17 +345,53 @@ int main(int argc, char *argv[])
|
||||
Info<< "Adding exposed internal faces to patch " << patchName << endl
|
||||
<< endl;
|
||||
}
|
||||
else if (args.optionFound("patches"))
|
||||
{
|
||||
const wordReList patchNames(args.optionRead<wordReList>("patches"));
|
||||
|
||||
exposedPatchIDs = mesh.boundaryMesh().patchSet(patchNames).sortedToc();
|
||||
|
||||
Info<< "Adding exposed internal faces to nearest of patches "
|
||||
<< patchNames << endl << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Adding exposed internal faces to a patch called"
|
||||
<< " \"oldInternalFaces\" (created if necessary)" << endl
|
||||
<< endl;
|
||||
exposedPatchIDs = labelList(1, label(-1));
|
||||
}
|
||||
|
||||
|
||||
cellSet currentSet(mesh, setName);
|
||||
|
||||
subsetter.setLargeCellSubset(currentSet, patchI, true);
|
||||
if (exposedPatchIDs.size() == 1)
|
||||
{
|
||||
subsetter.setLargeCellSubset(currentSet, exposedPatchIDs[0], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Find per face the nearest patch
|
||||
labelList nearestExposedPatch(nearestPatch(mesh, exposedPatchIDs));
|
||||
|
||||
labelList region(mesh.nCells(), 0);
|
||||
forAllConstIter(cellSet, currentSet, iter)
|
||||
{
|
||||
region[iter.key()] = 1;
|
||||
}
|
||||
|
||||
labelList exposedFaces(subsetter.getExposedFaces(region, 1, true));
|
||||
subsetter.setLargeCellSubset
|
||||
(
|
||||
region,
|
||||
1,
|
||||
exposedFaces,
|
||||
UIndirectList<label>(nearestExposedPatch, exposedFaces)(),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
|
||||
@ -361,6 +517,42 @@ int main(int argc, char *argv[])
|
||||
subsetPointFields(subsetter, pMesh, pointTensorNames, pointTensorFlds);
|
||||
|
||||
|
||||
// Read dimensioned fields and subset
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
typedef volScalarField::DimensionedInternalField dimScalType;
|
||||
wordList scalarDimNames(objects.names(dimScalType::typeName));
|
||||
PtrList<dimScalType> scalarDimFlds(scalarDimNames.size());
|
||||
subsetDimensionedFields(subsetter, scalarDimNames, scalarDimFlds);
|
||||
|
||||
typedef volVectorField::DimensionedInternalField dimVecType;
|
||||
wordList vectorDimNames(objects.names(dimVecType::typeName));
|
||||
PtrList<dimVecType> vectorDimFlds(vectorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, vectorDimNames, vectorDimFlds);
|
||||
|
||||
typedef volSphericalTensorField::DimensionedInternalField dimSphereType;
|
||||
wordList sphericalTensorDimNames(objects.names(dimSphereType::typeName));
|
||||
PtrList<dimSphereType> sphericalTensorDimFlds
|
||||
(
|
||||
sphericalTensorDimNames.size()
|
||||
);
|
||||
subsetDimensionedFields
|
||||
(
|
||||
subsetter,
|
||||
sphericalTensorDimNames,
|
||||
sphericalTensorDimFlds
|
||||
);
|
||||
|
||||
typedef volSymmTensorField::DimensionedInternalField dimSymmTensorType;
|
||||
wordList symmTensorDimNames(objects.names(dimSymmTensorType::typeName));
|
||||
PtrList<dimSymmTensorType> symmTensorDimFlds(symmTensorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, symmTensorDimNames, symmTensorDimFlds);
|
||||
|
||||
typedef volTensorField::DimensionedInternalField dimTensorType;
|
||||
wordList tensorDimNames(objects.names(dimTensorType::typeName));
|
||||
PtrList<dimTensorType> tensorDimFlds(tensorDimNames.size());
|
||||
subsetDimensionedFields(subsetter, tensorDimNames, tensorDimFlds);
|
||||
|
||||
|
||||
// Write mesh and fields to new time
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
@ -461,6 +653,33 @@ int main(int argc, char *argv[])
|
||||
pointTensorFlds[i].write();
|
||||
}
|
||||
|
||||
// DimensionedFields
|
||||
forAll(scalarDimFlds, i)
|
||||
{
|
||||
scalarDimFlds[i].rename(scalarDimNames[i]);
|
||||
scalarDimFlds[i].write();
|
||||
}
|
||||
forAll(vectorDimFlds, i)
|
||||
{
|
||||
vectorDimFlds[i].rename(vectorDimNames[i]);
|
||||
vectorDimFlds[i].write();
|
||||
}
|
||||
forAll(sphericalTensorDimFlds, i)
|
||||
{
|
||||
sphericalTensorDimFlds[i].rename(sphericalTensorDimNames[i]);
|
||||
sphericalTensorDimFlds[i].write();
|
||||
}
|
||||
forAll(symmTensorDimFlds, i)
|
||||
{
|
||||
symmTensorDimFlds[i].rename(symmTensorDimNames[i]);
|
||||
symmTensorDimFlds[i].write();
|
||||
}
|
||||
forAll(tensorDimFlds, i)
|
||||
{
|
||||
tensorDimFlds[i].rename(tensorDimNames[i]);
|
||||
tensorDimFlds[i].write();
|
||||
}
|
||||
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
|
||||
|
||||
@ -372,19 +372,22 @@ FoamFile
|
||||
// // is the master side)
|
||||
// }
|
||||
//
|
||||
// // Select based on surface. Orientation from normals on surface
|
||||
// // Select based on faceSet, using supplied normal to determine orientation
|
||||
// source setAndNormalToFaceZone;
|
||||
// sourceInfo
|
||||
// {
|
||||
// name fz0;
|
||||
// type faceZoneSet;
|
||||
// action new;
|
||||
// source searchableSurfaceToFaceZone;
|
||||
// sourceInfo
|
||||
// {
|
||||
// surface searchableSphere;
|
||||
// centre (0.05 0.05 0.005);
|
||||
// radius 0.025;
|
||||
// //name sphere.stl; // Optional name if surface triSurfaceMesh
|
||||
// }
|
||||
// faceSet f0; // name of faceSet
|
||||
// normal (1 0 0); // normal orientation
|
||||
// }
|
||||
//
|
||||
// // Select based on surface. Orientation from normals on surface
|
||||
// source searchableSurfaceToFaceZone;
|
||||
// sourceInfo
|
||||
// {
|
||||
// surface searchableSphere;
|
||||
// centre (0.05 0.05 0.005);
|
||||
// radius 0.025;
|
||||
// //name sphere.stl; // Optional name if surface triSurfaceMesh
|
||||
// }
|
||||
//
|
||||
//
|
||||
@ -413,7 +416,7 @@ actions
|
||||
name c0;
|
||||
type cellSet;
|
||||
action new;
|
||||
source labelToCell;
|
||||
source labelToCell;
|
||||
sourceInfo
|
||||
{
|
||||
value (12 13 56);
|
||||
|
||||
@ -308,6 +308,8 @@ int main(int argc, char *argv[])
|
||||
Info<< "Writing points into directory " << points.path() << nl << endl;
|
||||
points.write();
|
||||
|
||||
Info<< nl << "End" << nl << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user