Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-dev-OpenCFD into develop

Conflicts:
	src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C
This commit is contained in:
mattijs
2015-11-19 10:40:51 +00:00
610 changed files with 62276 additions and 14131 deletions

View File

@ -45,6 +45,8 @@ Description
int main(int argc, char *argv[])
{
argList::noParallel();
#include "setRootCase.H"
#include "createTime.H"

View File

@ -1,6 +0,0 @@
/home/dm2/henry/OpenFOAM/OpenFOAM-dev/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam
Making dependency list for source file reactingMultiphaseEulerFoam.C
clang++ -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-c++11-extensions -O3 -DNoRepository -ftemplate-depth-100 -ImultiphaseSystem/lnInclude -I../phaseSystems/lnInclude -I../interfacialModels/lnInclude -I../interfacialCompositionModels/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/thermophysicalModels/basic/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/transportModels/compressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/compressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/phaseCompressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/finiteVolume/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/fvOptions/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/meshTools/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/sampling/lnInclude -IlnInclude -I. -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/OpenFOAM/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/OSspecific/POSIX/lnInclude -fPIC -c reactingMultiphaseEulerFoam.C -o /home/dm2/henry/OpenFOAM/OpenFOAM-dev/platforms/linux64ClangDPInt32Opt/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/reactingMultiphaseEulerFoam.o
clang++ -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-c++11-extensions -O3 -DNoRepository -ftemplate-depth-100 -ImultiphaseSystem/lnInclude -I../phaseSystems/lnInclude -I../interfacialModels/lnInclude -I../interfacialCompositionModels/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/thermophysicalModels/basic/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/transportModels/compressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/turbulenceModels/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/compressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/TurbulenceModels/phaseCompressible/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/finiteVolume/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/fvOptions/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/meshTools/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/sampling/lnInclude -IlnInclude -I. -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/OpenFOAM/lnInclude -I/home/dm2/henry/OpenFOAM/OpenFOAM-dev/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed /home/dm2/henry/OpenFOAM/OpenFOAM-dev/platforms/linux64ClangDPInt32Opt/applications/solvers/multiphase/reactingEulerFoam/reactingMultiphaseEulerFoam/reactingMultiphaseEulerFoam.o -L/home/dm2/henry/OpenFOAM/OpenFOAM-dev/platforms/linux64ClangDPInt32Opt/lib \
-lreactingPhaseSystem -lreactingMultiphaseSystem -lreactingEulerianInterfacialModels -lreactingEulerianInterfacialCompositionModels -lmultiphaseReactingTurbulenceModels -lfiniteVolume -lfvOptions -lmeshTools -lsampling -lOpenFOAM -ldl \
-lm -o /home/dm2/henry/OpenFOAM/OpenFOAM-dev/platforms/linux64ClangDPInt32Opt/bin/reactingMultiphaseEulerFoam

View File

@ -128,7 +128,7 @@ int main(int argc, char *argv[])
}
}
#include "write.H"
runTime.write();
Info<< "ExecutionTime = "
<< runTime.elapsedCpuTime()

View File

@ -1,17 +0,0 @@
if (runTime.outputTime())
{
volVectorField Ur
(
IOobject
(
"Ur",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
U1 - U2
);
runTime.write();
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -493,21 +493,30 @@ int main(int argc, char *argv[])
// new patchID to neighbour processor)
// - number of new patches (nPatches)
labelList sidePatchID;
labelList edgePatchID;
labelList edgeZoneID;
boolList edgeFlip;
labelList inflateFaceID;
label nPatches;
Map<label> nbrProcToPatch;
Map<label> patchToNbrProc;
addPatchCellLayer::calcSidePatch
addPatchCellLayer::calcExtrudeInfo
(
true, // for internal edges get zone info from any face
mesh,
globalFaces,
edgeGlobalFaces,
extrudePatch,
sidePatchID,
edgePatchID,
nPatches,
nbrProcToPatch,
patchToNbrProc
patchToNbrProc,
edgeZoneID,
edgeFlip,
inflateFaceID
);
@ -659,7 +668,12 @@ int main(int argc, char *argv[])
ratio, // expansion ratio
extrudePatch, // patch faces to extrude
sidePatchID, // if boundary edge: patch to use
edgePatchID, // if boundary edge: patch for extruded face
edgeZoneID, // optional zone for extruded face
edgeFlip,
inflateFaceID, // mesh face that zone/patch info is from
exposedPatchID, // if new mesh: patches for exposed faces
nFaceLayers,
nPointLayers,

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1075,6 +1075,26 @@ int main(int argc, char *argv[])
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
// Optionally read limit shells
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const dictionary limitDict(refineDict.subOrEmptyDict("limitRegions"));
if (!limitDict.empty())
{
Info<< "Reading limit shells." << endl;
}
shellSurfaces limitShells(allGeometry, limitDict);
if (!limitDict.empty())
{
Info<< "Read refinement shells in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
}
// Read feature meshes
// ~~~~~~~~~~~~~~~~~~~
@ -1105,7 +1125,8 @@ int main(int argc, char *argv[])
overwrite, // overwrite mesh files?
surfaces, // for surface intersection refinement
features, // for feature edges/point based refinement
shells // for volume (inside/outside) refinement
shells, // for volume (inside/outside) refinement
limitShells // limit of volume refinement
);
Info<< "Calculated surface intersections in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
@ -1121,6 +1142,38 @@ int main(int argc, char *argv[])
);
// Refinement parameters
const refinementParameters refineParams(refineDict);
// Snap parameters
const snapParameters snapParams(snapDict);
// Add all the cellZones and faceZones
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// 1. cellZones relating to surface (faceZones added later)
const labelList namedSurfaces
(
surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones())
);
labelList surfaceToCellZone = surfaceZonesInfo::addCellZonesToMesh
(
surfaces.surfZones(),
namedSurfaces,
mesh
);
// 2. cellZones relating to locations
refineParams.addCellZonesToMesh(mesh);
// Add all the surface regions as patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -1128,6 +1181,8 @@ int main(int argc, char *argv[])
// (faceZone surfaces)
labelList globalToMasterPatch;
labelList globalToSlavePatch;
{
Info<< nl
<< "Adding patches for surface regions" << nl
@ -1148,6 +1203,7 @@ int main(int argc, char *argv[])
const labelList& surfaceGeometry = surfaces.surfaces();
const PtrList<dictionary>& surfacePatchInfo = surfaces.patchInfo();
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
forAll(surfaceGeometry, surfI)
{
@ -1157,7 +1213,9 @@ int main(int argc, char *argv[])
Info<< surfaces.names()[surfI] << ':' << nl << nl;
if (surfaces.surfZones()[surfI].faceZoneName().empty())
const word& fzName = surfaces.surfZones()[surfI].faceZoneName();
if (fzName.empty())
{
// 'Normal' surface
forAll(regNames, i)
@ -1188,7 +1246,7 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left)
<< setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type()
<< setw(20) << pbm[patchI].type()
<< setw(30) << regNames[i] << nl;
globalToMasterPatch[globalRegionI] = patchI;
@ -1228,7 +1286,7 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left)
<< setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type()
<< setw(20) << pbm[patchI].type()
<< setw(30) << regNames[i] << nl;
globalToMasterPatch[globalRegionI] = patchI;
@ -1260,12 +1318,27 @@ int main(int argc, char *argv[])
Info<< setf(ios_base::left)
<< setw(6) << patchI
<< setw(20) << mesh.boundaryMesh()[patchI].type()
<< setw(20) << pbm[patchI].type()
<< setw(30) << slaveName << nl;
globalToSlavePatch[globalRegionI] = patchI;
}
}
// For now: have single faceZone per surface. Use first
// region in surface for patch for zoneing
if (regNames.size())
{
label globalRegionI = surfaces.globalRegion(surfI, 0);
meshRefiner.addFaceZone
(
fzName,
pbm[globalToMasterPatch[globalRegionI]].name(),
pbm[globalToSlavePatch[globalRegionI]].name(),
surfaces.surfZones()[surfI].faceType()
);
}
}
Info<< nl;
@ -1275,10 +1348,85 @@ int main(int argc, char *argv[])
}
// Add all information for all the remaining faceZones
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HashTable<Pair<word> > faceZoneToPatches;
forAll(mesh.faceZones(), zoneI)
{
const word& fzName = mesh.faceZones()[zoneI].name();
label mpI, spI;
surfaceZonesInfo::faceZoneType fzType;
bool hasInfo = meshRefiner.getFaceZoneInfo(fzName, mpI, spI, fzType);
if (!hasInfo)
{
// faceZone does not originate from a surface but presumably
// from a cellZone pair instead
string::size_type i = fzName.find("_to_");
if (i != string::npos)
{
word cz0 = fzName.substr(0, i);
word cz1 = fzName.substr(i+4, fzName.size()-i+4);
word slaveName(cz1 + "_to_" + cz0);
faceZoneToPatches.insert(fzName, Pair<word>(fzName, slaveName));
}
else
{
// Add as fzName + fzName_slave
const word slaveName = fzName + "_slave";
faceZoneToPatches.insert(fzName, Pair<word>(fzName, slaveName));
}
}
}
if (faceZoneToPatches.size())
{
autoRefineDriver::addFaceZones
(
meshRefiner,
refineParams,
faceZoneToPatches
);
}
// Re-do intersections on meshed boundaries since they use an extrapolated
// other side
{
const labelList adaptPatchIDs(meshRefiner.meshedPatches());
const polyBoundaryMesh& pbm = mesh.boundaryMesh();
label nFaces = 0;
forAll(adaptPatchIDs, i)
{
nFaces += pbm[adaptPatchIDs[i]].size();
}
labelList faceLabels(nFaces);
nFaces = 0;
forAll(adaptPatchIDs, i)
{
const polyPatch& pp = pbm[adaptPatchIDs[i]];
forAll(pp, i)
{
faceLabels[nFaces++] = pp.start()+i;
}
}
meshRefiner.updateIntersections(faceLabels);
}
// Parallel
// ~~~~~~~~
// Decomposition
// Construct decomposition engine. Note: cannot use decompositionModel
// MeshObject since we're clearing out the mesh inside the mesh generation.
autoPtr<decompositionMethod> decomposerPtr
(
decompositionMethod::New
@ -1312,14 +1460,17 @@ int main(int argc, char *argv[])
const Switch wantSnap(meshDict.lookup("snap"));
const Switch wantLayers(meshDict.lookup("addLayers"));
// Refinement parameters
const refinementParameters refineParams(refineDict);
const Switch mergePatchFaces
(
meshDict.lookupOrDefault("mergePatchFaces", true)
);
// Snap parameters
const snapParameters snapParams(snapDict);
// Layer addition parameters
const layerParameters layerParams(layerDict, mesh.boundaryMesh());
if (!mergePatchFaces)
{
Info<< "Not merging patch-faces of cell to preserve"
<< " (split)hex cell shape."
<< nl << endl;
}
if (wantRefine)
@ -1348,6 +1499,7 @@ int main(int argc, char *argv[])
refineParams,
snapParams,
refineParams.handleSnapProblems(),
mergePatchFaces, // merge co-planar faces
motionDict
);
@ -1387,6 +1539,7 @@ int main(int argc, char *argv[])
(
snapDict,
motionDict,
mergePatchFaces,
curvature,
planarAngle,
snapParams
@ -1408,6 +1561,9 @@ int main(int argc, char *argv[])
{
cpuTime timer;
// Layer addition parameters
const layerParameters layerParams(layerDict, mesh.boundaryMesh());
autoLayerDriver layerDriver
(
meshRefiner,
@ -1433,6 +1589,7 @@ int main(int argc, char *argv[])
layerDict,
motionDict,
layerParams,
mergePatchFaces,
preBalance,
decomposer,
distributor

View File

@ -71,6 +71,11 @@ geometry
}
};
// Optional: avoid patch-face merging. Allows mesh to be used for
// refinement/unrefinement
//mergePatchFaces off; // default on
// Settings for the castellatedMesh generation.
castellatedMeshControls
{
@ -90,10 +95,10 @@ castellatedMeshControls
// actually be a lot less.
maxGlobalCells 2000000;
// The surface refinement loop might spend lots of iterations refining just a
// few cells. This setting will cause refinement to stop if <= minimumRefine
// are selected for refinement. Note: it will at least do one iteration
// (unless the number of cells to refine is 0)
// The surface refinement loop might spend lots of iterations refining just
// a few cells. This setting will cause refinement to stop if
// <= minimumRefine cells are selected for refinement. Note: it will
// at least do one iteration (unless the number of cells to refine is 0)
minRefinementCells 0;
// Allow a certain level of imbalance during refining
@ -177,7 +182,7 @@ castellatedMeshControls
// how to select the cells that are in the cellZone
// (inside / outside / specified insidePoint)
// The orientation of the faceZone is
// - if on cellZone(s) : point out of (maximum) cellZone
// - if on cellZone(s) : point out of (minimum) cellZone
// - if freestanding : oriented according to surface
//faceZone sphere;
@ -239,26 +244,96 @@ castellatedMeshControls
}
//sphere.stl
//{
// mode distance;
// levels ((1.0 5) (2.0 3));
// mode inside;
// levels ((1.0 4));
// // Optional override of uniform refinement level such
// // that in small gaps we're getting more cells.
// // The specification is
// // - numGapCells : minimum number of cells in the gap
// // - minLevel : min refinement level at which to kick in
// // - maxLevel : upper refinement level
// // All three settings can be overridden on a surface by
// // surface basis in the refinementSurfaces section.
// gapLevel (<numGapCells> <minLevel> <maxlevel>);
//}
}
// Limit refinement in geometric region
limitRegions
{
}
// Mesh selection
// ~~~~~~~~~~~~~~
// After refinement patches get added for all refinementSurfaces and
// all cells intersecting the surfaces get put into these patches. The
// section reachable from the locationInMesh is kept.
// section reachable from the location(s)InMesh is kept.
// NOTE: This point should never be on a face, always inside a cell, even
// after refinement.
locationInMesh (5 0.28 0.43);
//
// There are two different ways of specifying the regions to keep:
// 1. a single locationInMesh. All the 'zoned' surfaces are marked as such
// in the refinementSurfaces with the faceZone and cellZone keywords.
//
// or
//
// 2. multiple locationsInMesh, with per location the name of the cellZone.
// This uses walking to determine zones and automatically creates
// faceZones on the outside of cellZones.
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
// Ad 1. Specify a single location and how to treat faces inbetween
// cellZones
locationInMesh (5 0.28 0.43);
// Whether any faceZones (as specified in the refinementSurfaces)
// are only on the boundary of corresponding cellZones or also allow
// free-standing zone faces. Not used if there are no faceZones.
allowFreeStandingZoneFaces true;
// 2. Specify multiple locations with optional cellZones for the
// regions. faceZones are automatically constructed from the
// names of the cellZones: <cellZoneA> _to_ <cellZoneB>
// where the cellZoneA is the lowest numbered cellZone (non-cellZone
// cells are in a special region called "none" which is always
// last).
locationsInMesh
(
((-0.09 -0.039 -0.049) bottomAir) // cellZone 0
((-0.09 0.009 -0.049) topAir) // cellZone 1
((-0.09 0.001 -0.049) leftSolid) // cellZone 2
((0.02 0.001 -0.049) rightSolid) // cellZone 3
((-0.001 -0.039 0.0015) heater) // cellZone 4
);
// Per synthesised faceZone name the faceType and type of baffles to
// create
faceZoneControls
{
bottomAir_to_heater
{
// Optional specification of patch type (default is wall). No
// constraint types (cyclic, symmetry) etc. are allowed.
patchInfo
{
type patch;
inGroups (patchPatches);
}
faceType baffle;
}
}
// Optional locations that should not be reachable from
// location(s)InMesh
locationsOutsideMesh ((100 100 100));
// Optional: do not remove cells likely to give snapping problems
// handleSnapProblems false;
@ -266,6 +341,10 @@ castellatedMeshControls
// Optional: switch off topological test for cells to-be-squashed
// and use geometric test instead
//useTopologicalSnapDetection false;
// Optional: do not refine surface cells with opposite faces of
// differing refinement levels
//interfaceRefine false;
}
// Settings for the snapping.
@ -275,6 +354,11 @@ snapControls
// to surface
nSmoothPatch 3;
// Optional: number of smoothing iterations for internal points on
// refinement interfaces. This will reduce non-orthogonality on
// refinement interfaces.
//nSmoothInternal $nSmoothPatch;
// Maximum relative distance for points to be attracted by surface.
// True distance is this factor times local maximum edge length.
// Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance)
@ -287,6 +371,11 @@ snapControls
// before upon reaching a correct mesh.
nRelaxIter 5;
// (wip) disable snapping to opposite near surfaces (revert to 22x
// behaviour)
// detectNearSurfacesSnap false;
// Feature snapping
// Number of feature edge snapping iterations.
@ -305,8 +394,28 @@ snapControls
multiRegionFeatureSnap false;
// wip: disable snapping to opposite near surfaces (revert to 22x behaviour)
// detectNearSurfacesSnap false;
//- When to run face splitting (never at first iteration, always
// at last iteration). Is interval. Default -1 (disabled)
//nFaceSplitInterval 5;
// (wip) Optional for explicit feature snapping:
//- Detect baffle edges. Default is true.
//detectBaffles false;
//- Erase attraction close to feature point. Default is false.
//releasePoints true;
//- Walk along feature edges, adding missing ones. Default is true.
//stringFeatures false;
//- If diagonal attraction also attract other face points. Default is
// false
//avoidDiagonal true;
//- When splitting what concave faces to leave intact. Default is 45
// degrees.
//concaveAngle 30;
//- When splitting the minimum area ratio of faces. If face split
// causes ratio of area less than this do not split. Default is 0.3
//minAreaRatio 0.3;
}
// Settings for the layer addition.
@ -350,10 +459,10 @@ addLayersControls
// cannot be above minThickness do not add layer.
// If relativeSizes this is relative to undistorted size of cell
// outside layer..
minThickness 0.25;
minThickness 0.1;
// Per final patch (so not geometry!) the layer information
// Per final patch or faceZone (so not geometry!) the layer information
// Note: This behaviour changed after 21x. Any non-mentioned patches
// now slide unless:
// - nSurfaceLayers is explicitly mentioned to be 0.
@ -397,6 +506,10 @@ addLayersControls
// are perpendicular
featureAngle 130;
// When to merge patch faces. Default is featureAngle. Useful when
// featureAngle is large.
//mergePatchFacesAngle 45;
// Stop layer growth on highly warped cells
maxFaceThicknessRatio 0.5;
@ -433,8 +546,10 @@ addLayersControls
// default is 0.
//nSmoothDisplacement 90;
// (wip)Optional: do not extrude a point if none of the surrounding points is
// not extruded. Default is false.
// (wip)Optional: do not extrude any point where
// (false) : all surrounding faces are not fully extruded
// (true) : all surrounding points are not extruded
// Default is false.
//detectExtrusionIsland true;
@ -449,7 +564,8 @@ addLayersControls
// before upon reaching a correct mesh.
nRelaxIter 5;
// Create buffer region for new layer terminations
// Create buffer region for new layer terminations, i.e. gradually
// step down number of layers. Set to <0 to terminate layer in one go.
nBufferCellsNoExtrude 0;
// Overall max number of layer addition iterations. The mesher will

View File

@ -493,12 +493,15 @@ Foam::label Foam::checkGeometry(const polyMesh& mesh, const bool allGeometry)
// Min length
scalar minDistSqr = magSqr(1e-6 * globalBb.span());
// Non-empty directions
// Geometric directions
const Vector<label> validDirs = (mesh.geometricD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty, non-wedge) directions " << validDirs << endl;
Info<< " Mesh has " << mesh.nGeometricD()
<< " geometric (non-empty/wedge) directions " << validDirs << endl;
// Solution directions
const Vector<label> solDirs = (mesh.solutionD() + Vector<label>::one)/2;
Info<< " Mesh (non-empty) directions " << solDirs << endl;
Info<< " Mesh has " << mesh.nSolutionD()
<< " solution (non-empty) directions " << solDirs << endl;
if (mesh.nGeometricD() < 3)
{

View File

@ -133,7 +133,11 @@ int main(int argc, char *argv[])
{
Info<< "Time = " << runTime.timeName() << endl;
mesh.update();
for (int i = 0; i<2; i++)
{
mesh.update();
}
mesh.checkMesh(true);
if (checkAMI)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -202,6 +202,7 @@ void subsetSurfaceFields
(
const fvMesh& mesh,
const fvMesh& subMesh,
const labelList& cellMap,
const labelList& faceMap,
const labelHashSet& addedPatches
)
@ -225,6 +226,7 @@ void subsetSurfaceFields
fld,
subMesh,
patchMap,
cellMap,
faceMap
)
);
@ -830,6 +832,7 @@ void createAndWriteRegion
(
mesh,
newMesh(),
map().cellMap(),
map().faceMap(),
addedPatches
);
@ -837,6 +840,7 @@ void createAndWriteRegion
(
mesh,
newMesh(),
map().cellMap(),
map().faceMap(),
addedPatches
);
@ -844,6 +848,7 @@ void createAndWriteRegion
(
mesh,
newMesh(),
map().cellMap(),
map().faceMap(),
addedPatches
);
@ -851,6 +856,7 @@ void createAndWriteRegion
(
mesh,
newMesh(),
map().cellMap(),
map().faceMap(),
addedPatches
);
@ -858,6 +864,7 @@ void createAndWriteRegion
(
mesh,
newMesh(),
map().cellMap(),
map().faceMap(),
addedPatches
);

View File

@ -2,6 +2,7 @@ EXE_INC = \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
@ -12,5 +13,6 @@ EXE_LIBS = \
-lgenericPatchFields \
-ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp \
-llagrangian \
-ldynamicMesh \
-lmeshTools \
-lregionModels

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -96,6 +96,7 @@ Usage
#include "fvFieldDecomposer.H"
#include "pointFieldDecomposer.H"
#include "lagrangianFieldDecomposer.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -142,6 +143,12 @@ int main(int argc, char *argv[])
);
argList::noParallel();
Foam::argList::addOption
(
"decomposeParDict",
"file",
"read decomposePar dictionary from specified location"
);
#include "addRegionOption.H"
argList::addBoolOption
(
@ -199,6 +206,17 @@ int main(int argc, char *argv[])
instantList times = timeSelector::selectIfPresent(runTime, args);
// Allow override of decomposeParDict location
fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile))
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
wordList regionNames;
wordList regionDirs;
if (allRegions)
@ -260,21 +278,27 @@ int main(int argc, char *argv[])
++nProcs;
}
// get requested numberOfSubdomains
// get requested numberOfSubdomains. Note: have no mesh yet so
// cannot use decompositionModel::New
const label nDomains = readLabel
(
IOdictionary
(
IOobject
decompositionModel::selectIO
(
"decomposeParDict",
runTime.time().system(),
regionDir, // use region if non-standard
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
IOobject
(
"decomposeParDict",
runTime.time().system(),
regionDir, // use region if non-standard
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
),
decompDictFile
)
).lookup("numberOfSubdomains")
);
@ -288,8 +312,7 @@ int main(int argc, char *argv[])
<< nProcs << " domains"
<< nl
<< "instead of " << nDomains
<< " domains as specified in decomposeParDict"
<< nl
<< " domains as specified in decomposeParDict" << nl
<< exit(FatalError);
}
}
@ -351,7 +374,8 @@ int main(int argc, char *argv[])
IOobject::NO_READ,
IOobject::NO_WRITE,
false
)
),
decompDictFile
);
// Decompose the mesh
@ -447,15 +471,15 @@ int main(int argc, char *argv[])
// Construct the vol fields
// ~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<volScalarField> volScalarFields;
readFields(mesh, objects, volScalarFields);
readFields(mesh, objects, volScalarFields, false);
PtrList<volVectorField> volVectorFields;
readFields(mesh, objects, volVectorFields);
readFields(mesh, objects, volVectorFields, false);
PtrList<volSphericalTensorField> volSphericalTensorFields;
readFields(mesh, objects, volSphericalTensorFields);
readFields(mesh, objects, volSphericalTensorFields, false);
PtrList<volSymmTensorField> volSymmTensorFields;
readFields(mesh, objects, volSymmTensorFields);
readFields(mesh, objects, volSymmTensorFields, false);
PtrList<volTensorField> volTensorFields;
readFields(mesh, objects, volTensorFields);
readFields(mesh, objects, volTensorFields, false);
// Construct the dimensioned fields
@ -476,15 +500,15 @@ int main(int argc, char *argv[])
// Construct the surface fields
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PtrList<surfaceScalarField> surfaceScalarFields;
readFields(mesh, objects, surfaceScalarFields);
readFields(mesh, objects, surfaceScalarFields, false);
PtrList<surfaceVectorField> surfaceVectorFields;
readFields(mesh, objects, surfaceVectorFields);
readFields(mesh, objects, surfaceVectorFields, false);
PtrList<surfaceSphericalTensorField> surfaceSphericalTensorFields;
readFields(mesh, objects, surfaceSphericalTensorFields);
readFields(mesh, objects, surfaceSphericalTensorFields, false);
PtrList<surfaceSymmTensorField> surfaceSymmTensorFields;
readFields(mesh, objects, surfaceSymmTensorFields);
readFields(mesh, objects, surfaceSymmTensorFields, false);
PtrList<surfaceTensorField> surfaceTensorFields;
readFields(mesh, objects, surfaceTensorFields);
readFields(mesh, objects, surfaceTensorFields, false);
// Construct the point fields
@ -492,15 +516,15 @@ int main(int argc, char *argv[])
const pointMesh& pMesh = pointMesh::New(mesh);
PtrList<pointScalarField> pointScalarFields;
readFields(pMesh, objects, pointScalarFields);
readFields(pMesh, objects, pointScalarFields, false);
PtrList<pointVectorField> pointVectorFields;
readFields(pMesh, objects, pointVectorFields);
readFields(pMesh, objects, pointVectorFields, false);
PtrList<pointSphericalTensorField> pointSphericalTensorFields;
readFields(pMesh, objects, pointSphericalTensorFields);
readFields(pMesh, objects, pointSphericalTensorFields, false);
PtrList<pointSymmTensorField> pointSymmTensorFields;
readFields(pMesh, objects, pointSymmTensorFields);
readFields(pMesh, objects, pointSymmTensorFields, false);
PtrList<pointTensorField> pointTensorFields;
readFields(pMesh, objects, pointTensorFields);
readFields(pMesh, objects, pointTensorFields, false);
// Construct the Lagrangian fields
@ -820,16 +844,6 @@ int main(int argc, char *argv[])
processorDb.setTime(runTime);
// remove files remnants that can cause horrible problems
// - mut and nut are used to mark the new turbulence models,
// their existence prevents old models from being upgraded
{
fileName timeDir(processorDb.path()/processorDb.timeName());
rm(timeDir/"mut");
rm(timeDir/"nut");
}
// read the mesh
if (!procMeshList.set(procI))
{

View File

@ -17,11 +17,61 @@ FoamFile
numberOfSubdomains 2;
// Optional decomposition constraints
//constraints
//{
// preserveBaffles
// {
// //- Keep owner and neighbour of baffles on same processor (i.e.
// // keep it detectable as a baffle). Baffles are two boundary face
// // sharing the same points
// type preserveBaffles;
// }
// preserveFaceZones
// {
// //- Keep owner and neighbour on same processor for faces in zones
// type preserveFaceZones;
// zones (".*");
// }
// preservePatches
// {
// //- Keep owner and neighbour on same processor for faces in patches
// // (only makes sense for cyclic patches. Not suitable for e.g.
// // cyclicAMI since these are not coupled on the patch level. Use
// // singleProcessorFaceSets for those)
// type preservePatches;
// patches (".*");
// }
// singleProcessorFaceSets
// {
// //- Keep all of faceSet on a single processor. This puts all cells
// // connected with a point, edge or face on the same processor.
// // (just having face connected cells might not guarantee a balanced
// // decomposition)
// // The processor can be -1 (the decompositionMethod chooses the
// // processor for a good load balance) or explicitly provided (upsets
// // balance)
// type singleProcessorFaceSets;
// singleProcessorFaceSets ((f1 -1));
// }
// refinementHistory
// {
// //- Decompose cells such that all cell originating from single cell
// // end up on same processor
// type refinementHistory;
// }
//}
// Deprecated form of specifying decomposition constraints:
//- Keep owner and neighbour on same processor for faces in zones:
// preserveFaceZones (heater solid1 solid3);
//- Keep owner and neighbour on same processor for faces in patches:
// (makes sense only for cyclic patches)
// (makes sense only for cyclic patches. Not suitable for e.g. cyclicAMI
// since these are not coupled on the patch level. Use
// singleProcessorFaceSets for those)
//preservePatches (cyclic_half0 cyclic_half1);
//- Keep all of faceSet on a single processor. This puts all cells
@ -32,12 +82,13 @@ numberOfSubdomains 2;
// for a good load balance) or explicitly provided (upsets balance).
//singleProcessorFaceSets ((f0 -1));
//- Keep owner and neighbour of baffles on same processor (i.e. keep it
// detectable as a baffle). Baffles are two boundary face sharing the
// same points.
//preserveBaffles true;
//- Use the volScalarField named here as a weight for each cell in the
// decomposition. For example, use a particle population field to decompose
// for a balanced number of particles in a lagrangian simulation.

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,14 +31,14 @@ License
#include "fvMesh.H"
#include "OSspecific.H"
#include "Map.H"
#include "globalMeshData.H"
#include "DynamicList.H"
#include "fvFieldDecomposer.H"
#include "IOobjectList.H"
#include "cellSet.H"
#include "faceSet.H"
#include "pointSet.H"
#include "uniformDimensionedFields.H"
#include "decompositionModel.H"
#include "hexRef8Data.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
@ -69,7 +69,12 @@ void Foam::domainDecomposition::mark
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::domainDecomposition::domainDecomposition(const IOobject& io)
// from components
Foam::domainDecomposition::domainDecomposition
(
const IOobject& io,
const fileName& decompDictFile
)
:
fvMesh(io),
facesInstancePointsPtr_
@ -90,18 +95,18 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
)
: NULL
),
decompositionDict_
decompDictFile_(decompDictFile),
nProcs_
(
IOobject
readInt
(
"decomposeParDict",
time().system(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
decompositionModel::New
(
*this,
decompDictFile
).lookup("numberOfSubdomains")
)
),
nProcs_(readInt(decompositionDict_.lookup("numberOfSubdomains"))),
distributed_(false),
cellToProc_(nCells()),
procPointAddressing_(nProcs_),
@ -115,7 +120,11 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io)
procProcessorPatchSubPatchIDs_(nProcs_),
procProcessorPatchSubPatchStarts_(nProcs_)
{
decompositionDict_.readIfPresent("distributed", distributed_);
decompositionModel::New
(
*this,
decompDictFile
).readIfPresent("distributed", distributed_);
}
@ -195,57 +204,20 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
}
autoPtr<labelIOList> cellLevelPtr;
{
IOobject io
// Load refinement data (if any)
hexRef8Data baseMeshData
(
IOobject
(
"cellLevel",
"dummy",
facesInstance(),
polyMesh::meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.headerOk())
{
Info<< "Reading hexRef8 data : " << io.name() << endl;
cellLevelPtr.reset(new labelIOList(io));
}
}
autoPtr<labelIOList> pointLevelPtr;
{
IOobject io
(
"pointLevel",
facesInstance(),
polyMesh::meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.headerOk())
{
Info<< "Reading hexRef8 data : " << io.name() << endl;
pointLevelPtr.reset(new labelIOList(io));
}
}
autoPtr<uniformDimensionedScalarField> level0EdgePtr;
{
IOobject io
(
"level0Edge",
facesInstance(),
polyMesh::meshSubDir,
*this,
IOobject::MUST_READ,
IOobject::NO_WRITE
);
if (io.headerOk())
{
Info<< "Reading hexRef8 data : " << io.name() << endl;
level0EdgePtr.reset(new uniformDimensionedScalarField(io));
}
}
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
);
@ -816,8 +788,8 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
}
}
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
// Set the precision of the points data to be min 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
procMesh.write();
@ -887,64 +859,23 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
}
// hexRef8 data
if (cellLevelPtr.valid())
{
labelIOList
// Optional hexRef8 data
hexRef8Data
(
IOobject
(
IOobject
(
cellLevelPtr().name(),
facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
UIndirectList<label>
(
cellLevelPtr(),
procCellAddressing_[procI]
)()
).write();
}
if (pointLevelPtr.valid())
{
labelIOList
(
IOobject
(
pointLevelPtr().name(),
facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
UIndirectList<label>
(
pointLevelPtr(),
procPointAddressing_[procI]
)()
).write();
}
if (level0EdgePtr.valid())
{
uniformDimensionedScalarField
(
IOobject
(
level0EdgePtr().name(),
facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
level0EdgePtr()
).write();
}
"dummy",
facesInstance(),
polyMesh::meshSubDir,
procMesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
baseMeshData,
procCellAddressing_[procI],
procPointAddressing_[procI]
).write();
// Statistics

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -61,8 +61,8 @@ class domainDecomposition
//- Optional: points at the facesInstance
autoPtr<pointIOField> facesInstancePointsPtr_;
//- Mesh decomposition control dictionary
IOdictionary decompositionDict_;
//- Optional non-standard file for decomposeParDict
const fileName decompDictFile_;
//- Number of processors in decomposition
label nProcs_;
@ -159,8 +159,13 @@ public:
// Constructors
//- Construct from IOobject
domainDecomposition(const IOobject& io);
//- Construct from IOobjects (for mesh and optional non-standard
// decomposeParDict location)
domainDecomposition
(
const IOobject& io,
const fileName& decompDictFile = ""
);
//- Destructor

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -30,6 +30,7 @@ License
#include "regionSplit.H"
#include "Tuple2.H"
#include "faceSet.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -39,15 +40,17 @@ void Foam::domainDecomposition::distributeCells()
cpuTime decompositionTime;
autoPtr<decompositionMethod> decomposePtr = decompositionMethod::New
const decompositionModel& method = decompositionModel::New
(
decompositionDict_
*this,
decompDictFile_
);
scalarField cellWeights;
if (decompositionDict_.found("weightField"))
if (method.found("weightField"))
{
word weightName = decompositionDict_.lookup("weightField");
word weightName = method.lookup("weightField");
volScalarField weights
(
@ -64,7 +67,7 @@ void Foam::domainDecomposition::distributeCells()
cellWeights = weights.internalField();
}
cellToProc_ = decomposePtr().decompose(*this, cellWeights);
cellToProc_ = method.decomposer().decompose(*this, cellWeights);
Info<< "\nFinished decomposition in "
<< decompositionTime.elapsedCpuTime()

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -23,10 +23,48 @@ License
\*---------------------------------------------------------------------------*/
#include "GeometricField.H"
#include "readFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::readFields
(
const typename GeoMesh::Mesh& mesh,
const IOobjectList& objects,
PtrList<GeometricField<Type, PatchField, GeoMesh> >& fields,
const bool readOldTime
)
{
typedef GeometricField<Type, PatchField, GeoMesh> GeoField;
// Search list of objects for fields of type GeomField
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Remove the cellDist field
IOobjectList::iterator celDistIter = fieldObjects.find("cellDist");
if (celDistIter != fieldObjects.end())
{
fieldObjects.erase(celDistIter);
}
// Get sorted set of names (different processors might read objects in
// different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.setSize(masterNames.size());
forAll(masterNames, i)
{
const IOobject& io = *fieldObjects[masterNames[i]];
fields.set(i, new GeoField(io, mesh, readOldTime));
}
}
template<class Mesh, class GeoField>
void Foam::readFields
(
@ -38,24 +76,21 @@ void Foam::readFields
// Search list of objects for fields of type GeomField
IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName));
// Remove the cellDist field
IOobjectList::iterator celDistIter = fieldObjects.find("cellDist");
if (celDistIter != fieldObjects.end())
{
fieldObjects.erase(celDistIter);
}
// Construct the fields
fields.setSize(fieldObjects.size());
label fieldI = 0;
forAllIter(IOobjectList, fieldObjects, iter)
// Get sorted set of names (different processors might read objects in
// different order)
const wordList masterNames(fieldObjects.sortedNames());
// Construct the fields
fields.setSize(masterNames.size());
forAll(masterNames, i)
{
fields.set
(
fieldI++,
new GeoField(*iter(), mesh)
);
const IOobject& io = *fieldObjects[masterNames[i]];
fields.set(i, new GeoField(io, mesh));
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,6 +41,16 @@ SourceFiles
namespace Foam
{
// Read the fields and hold on the pointer list
template<class Type, template<class> class PatchField, class GeoMesh>
void readFields
(
const typename GeoMesh::Mesh& mesh,
const IOobjectList& objects,
PtrList<GeometricField<Type, PatchField, GeoMesh> >& fields,
const bool readOldTime
);
// Read the fields and hold on the pointer list
template<class Mesh, class GeoField>
void readFields

View File

@ -1,6 +1,7 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
@ -9,6 +10,7 @@ EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-llagrangian \
-ldynamicMesh \
-lmeshTools \
-lreconstruct \
-lregionModels

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,6 +45,8 @@ Description
#include "faceSet.H"
#include "pointSet.H"
#include "hexRef8Data.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool haveAllTimes
@ -865,6 +867,78 @@ int main(int argc, char *argv[])
pointSets[i].write();
}
}
// Reconstruct refinement data
{
PtrList<hexRef8Data> procData(procMeshes.meshes().size());
forAll(procMeshes.meshes(), procI)
{
const fvMesh& procMesh = procMeshes.meshes()[procI];
procData.set
(
procI,
new hexRef8Data
(
IOobject
(
"dummy",
procMesh.time().timeName(),
polyMesh::meshSubDir,
procMesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
)
)
);
}
// Combine individual parts
const PtrList<labelIOList>& cellAddr =
procMeshes.cellProcAddressing();
UPtrList<const labelList> cellMaps(cellAddr.size());
forAll(cellAddr, i)
{
cellMaps.set(i, &cellAddr[i]);
}
const PtrList<labelIOList>& pointAddr =
procMeshes.pointProcAddressing();
UPtrList<const labelList> pointMaps(pointAddr.size());
forAll(pointAddr, i)
{
pointMaps.set(i, &pointAddr[i]);
}
UPtrList<const hexRef8Data> procRefs(procData.size());
forAll(procData, i)
{
procRefs.set(i, &procData[i]);
}
hexRef8Data
(
IOobject
(
"dummy",
mesh.time().timeName(),
polyMesh::meshSubDir,
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
cellMaps,
pointMaps,
procRefs
).write();
}
}
}
@ -882,7 +956,7 @@ int main(int argc, char *argv[])
}
}
Info<< "End.\n" << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -899,7 +899,7 @@ int main(int argc, char *argv[])
}
Info<< "End.\n" << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -1,3 +1,5 @@
parLagrangianRedistributor.C
parFvFieldReconstructor.C
loadOrCreateMesh.C
redistributePar.C

View File

@ -1,13 +1,17 @@
EXE_INC = \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lgenericPatchFields \
-ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \
-ldecompose \
-lmeshTools \
-llagrangian \
-ldynamicMesh

View File

@ -0,0 +1,131 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::distributedUnallocatedDirectFieldMapper
Description
FieldMapper with direct mapping from remote quantities.
\*---------------------------------------------------------------------------*/
#ifndef distributedUnallocatedDirectFieldMapper_H
#define distributedUnallocatedDirectFieldMapper_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class distributedUnallocatedDirectFieldMapper Declaration
\*---------------------------------------------------------------------------*/
class distributedUnallocatedDirectFieldMapper
:
public FieldMapper
{
const labelUList& directAddressing_;
const mapDistributeBase& distMap_;
bool hasUnmapped_;
public:
// Constructors
//- Construct given addressing
distributedUnallocatedDirectFieldMapper
(
const labelUList& directAddressing,
const mapDistributeBase& distMap
)
:
directAddressing_(directAddressing),
distMap_(distMap),
hasUnmapped_(false)
{
if
(
notNull(directAddressing_)
&& directAddressing_.size()
&& min(directAddressing_) < 0
)
{
hasUnmapped_ = true;
}
}
//- Destructor
virtual ~distributedUnallocatedDirectFieldMapper()
{}
// Member Functions
virtual label size() const
{
return
(
notNull(directAddressing_)
? directAddressing_.size()
: distMap_.constructSize()
);
}
virtual bool direct() const
{
return true;
}
virtual bool distributed() const
{
return true;
}
virtual const mapDistributeBase& distributeMap() const
{
return distMap_;
}
virtual bool hasUnmapped() const
{
return hasUnmapped_;
}
virtual const labelUList& directAddressing() const
{
return directAddressing_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -22,15 +22,15 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::weightedFvPatchFieldMapper
Foam::distributedUnallocatedDirectFvPatchFieldMapper
Description
FieldMapper with weighted mapping.
FieldMapper with direct mapping from remote quantities.
\*---------------------------------------------------------------------------*/
#ifndef weightedFvPatchFieldMapper_H
#define weightedFvPatchFieldMapper_H
#ifndef distributedUnallocatedDirectFvPatchFieldMapper_H
#define distributedUnallocatedDirectFvPatchFieldMapper_H
#include "fvPatchFieldMapper.H"
@ -40,16 +40,16 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class weightedFvPatchFieldMapper Declaration
Class distributedUnallocatedDirectFvPatchFieldMapper Declaration
\*---------------------------------------------------------------------------*/
class weightedFvPatchFieldMapper
class distributedUnallocatedDirectFvPatchFieldMapper
:
public fvPatchFieldMapper
{
const labelListList& addressing_;
const labelUList& directAddressing_;
const scalarListList& weights_;
const mapDistributeBase& distMap_;
bool hasUnmapped_;
@ -58,27 +58,29 @@ public:
// Constructors
//- Construct given addressing
weightedFvPatchFieldMapper
distributedUnallocatedDirectFvPatchFieldMapper
(
const labelListList& addressing,
const scalarListList& weights
const labelUList& directAddressing,
const mapDistributeBase& distMap
)
:
addressing_(addressing),
weights_(weights),
directAddressing_(directAddressing),
distMap_(distMap),
hasUnmapped_(false)
{
forAll(addressing_, i)
if
(
notNull(directAddressing_)
&& directAddressing_.size()
&& min(directAddressing_) < 0
)
{
if (addressing_[i].size() == 0)
{
hasUnmapped_ = true;
}
hasUnmapped_ = true;
}
}
//- Destructor
virtual ~weightedFvPatchFieldMapper()
virtual ~distributedUnallocatedDirectFvPatchFieldMapper()
{}
@ -86,12 +88,27 @@ public:
virtual label size() const
{
return addressing().size();
return
(
notNull(directAddressing_)
? directAddressing_.size()
: distMap_.constructSize()
);
}
virtual bool direct() const
{
return false;
return true;
}
virtual bool distributed() const
{
return true;
}
virtual const mapDistributeBase& distributeMap() const
{
return distMap_;
}
virtual bool hasUnmapped() const
@ -99,16 +116,10 @@ public:
return hasUnmapped_;
}
virtual const labelListList& addressing() const
virtual const labelUList& directAddressing() const
{
return addressing_;
return directAddressing_;
}
virtual const scalarListList& weights() const
{
return weights_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,14 +27,15 @@ License
#include "processorPolyPatch.H"
#include "processorCyclicPolyPatch.H"
#include "Time.H"
#include "IOPtrList.H"
//#include "IOPtrList.H"
#include "polyBoundaryMeshEntries.H"
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
namespace Foam
{
defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
}
//namespace Foam
//{
// defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
//}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,6 +47,9 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
const IOobject& io
)
{
// Region name
// ~~~~~~~~~~~
fileName meshSubDir;
if (io.name() == polyMesh::defaultRegion)
@ -58,24 +62,52 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
}
// Scatter master patches
// Patch types
// ~~~~~~~~~~~
// Read and scatter master patches (without reading master mesh!)
PtrList<entry> patchEntries;
if (Pstream::master())
{
// Read PtrList of dictionary as dictionary.
const word oldTypeName = IOPtrList<entry>::typeName;
const_cast<word&>(IOPtrList<entry>::typeName) = word::null;
IOPtrList<entry> dictList
//// Read PtrList of dictionary as dictionary.
//const word oldTypeName = IOPtrList<entry>::typeName;
//const_cast<word&>(IOPtrList<entry>::typeName) = word::null;
//IOPtrList<entry> dictList
//(
// IOobject
// (
// "boundary",
// io.time().findInstance
// (
// meshSubDir,
// "boundary",
// IOobject::MUST_READ
// ),
// meshSubDir,
// io.db(),
// IOobject::MUST_READ,
// IOobject::NO_WRITE,
// false
// )
//);
//const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
//// Fake type back to what was in field
//const_cast<word&>(dictList.type()) = dictList.headerClassName();
//
//patchEntries.transfer(dictList);
const fileName facesInstance = io.time().findInstance
(
meshSubDir,
"faces",
IOobject::MUST_READ
);
patchEntries = polyBoundaryMeshEntries
(
IOobject
(
"boundary",
io.time().findInstance
(
meshSubDir,
"boundary",
IOobject::MUST_READ
),
facesInstance,
meshSubDir,
io.db(),
IOobject::MUST_READ,
@ -83,11 +115,6 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
false
)
);
const_cast<word&>(IOPtrList<entry>::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(dictList.type()) = dictList.headerClassName();
patchEntries.transfer(dictList);
// Send patches
for
@ -110,8 +137,16 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
// Dummy meshes
// ~~~~~~~~~~~~
// Check who has a mesh
const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
//const bool haveMesh = isDir(io.time().path()/io.instance()/meshSubDir);
const bool haveMesh = isFile
(
io.time().path()/io.instance()/meshSubDir/"faces"
);
if (!haveMesh)
{
@ -164,6 +199,7 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
patches.setSize(nPatches);
dummyMesh.addFvPatches(patches, false); // no parallel comms
// Add some dummy zones so upon reading it does not read them
// from the undecomposed case. Should be done as extra argument to
// regIOobject::readStream?
@ -202,6 +238,9 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
)
);
dummyMesh.addZones(pz, fz, cz);
dummyMesh.pointZones().clear();
dummyMesh.faceZones().clear();
dummyMesh.cellZones().clear();
//Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath()
// << endl;
dummyMesh.write();
@ -209,11 +248,19 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
Pstream::parRun() = oldParRun;
}
// Read mesh
// ~~~~~~~~~
// Now all processors have a (possibly zero size) mesh so read in
// parallel
//Pout<< "Reading mesh from " << io.objectPath() << endl;
autoPtr<fvMesh> meshPtr(new fvMesh(io));
fvMesh& mesh = meshPtr();
// Sync patches
// ~~~~~~~~~~~~
@ -327,17 +374,17 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
}
if (!haveMesh)
{
// We created a dummy mesh file above. Delete it.
const fileName meshFiles = io.time().path()/io.instance()/meshSubDir;
//Pout<< "Removing dummy mesh " << meshFiles << endl;
mesh.removeFiles();
rmDir(meshFiles);
}
// if (!haveMesh)
// {
// // We created a dummy mesh file above. Delete it.
// const fileName meshFiles = io.time().path()/io.instance()/meshSubDir;
// //Pout<< "Removing dummy mesh " << meshFiles << endl;
// mesh.removeFiles();
// rmDir(meshFiles);
// }
//
// Force recreation of globalMeshData.
mesh.clearOut();
// mesh.clearOut();
mesh.globalData();

View File

@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "parFvFieldReconstructor.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::parFvFieldReconstructor::createPatchFaceMaps()
{
const fvBoundaryMesh& fvb = procMesh_.boundary();
patchFaceMaps_.setSize(fvb.size());
forAll(fvb, patchI)
{
if (!isA<processorFvPatch>(fvb[patchI]))
{
// Create map for patch faces only
// Mark all used elements (i.e. destination patch faces)
boolList faceIsUsed(distMap_.faceMap().constructSize(), false);
const polyPatch& basePatch = baseMesh_.boundaryMesh()[patchI];
forAll(basePatch, i)
{
faceIsUsed[basePatch.start()+i] = true;
}
// Copy face map
patchFaceMaps_.set
(
patchI,
new mapDistributeBase(distMap_.faceMap())
);
// Compact out unused elements
labelList oldToNewSub;
labelList oldToNewConstruct;
patchFaceMaps_[patchI].compact
(
faceIsUsed,
procMesh_.nFaces(), // maximum index of subMap
oldToNewSub,
oldToNewConstruct,
UPstream::msgType()
);
//Pout<< "patchMap:" << patchFaceMaps_[patchI] << endl;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parFvFieldReconstructor::parFvFieldReconstructor
(
fvMesh& baseMesh,
const fvMesh& procMesh,
const mapDistributePolyMesh& distMap,
const bool isWriteProc
)
:
baseMesh_(baseMesh),
procMesh_(procMesh),
distMap_(distMap),
isWriteProc_(isWriteProc)
{
createPatchFaceMaps();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::parFvFieldReconstructor::reconstructPoints()
{
// Reconstruct the points for moving mesh cases and write
// them out
distributedUnallocatedDirectFieldMapper mapper
(
labelUList::null(),
distMap_.pointMap()
);
pointField basePoints(procMesh_.points(), mapper);
baseMesh_.movePoints(basePoints);
if (Pstream::master())
{
baseMesh_.write();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::parFvFieldReconstructor
Description
Finite volume reconstructor for volume and surface fields.
Runs in parallel. Reconstructs from procMesh to baseMesh. baseMesh
is non-zero cells on processor0 only.
SourceFiles
parFvFieldReconstructor.C
parFvFieldReconstructorReconstructFields.C
\*---------------------------------------------------------------------------*/
#ifndef parFvFieldReconstructor_H
#define parFvFieldReconstructor_H
#include "PtrList.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapDistributePolyMesh;
class mapDistributeBase;
class IOobjectList;
/*---------------------------------------------------------------------------*\
Class parFvFieldReconstructor Declaration
\*---------------------------------------------------------------------------*/
class parFvFieldReconstructor
{
// Private data
//- Reconstructed mesh reference
fvMesh& baseMesh_;
//- Processor mesh reference
const fvMesh& procMesh_;
//- Distribution map reference
const mapDistributePolyMesh& distMap_;
//- Do I need to to write (usually master only)
const bool isWriteProc_;
//- Patch mappers
PtrList<mapDistributeBase> patchFaceMaps_;
// Private Member Functions
//- Construct per-patch addressing
void createPatchFaceMaps();
//- Disallow default bitwise copy construct
parFvFieldReconstructor(const parFvFieldReconstructor&);
//- Disallow default bitwise assignment
void operator=(const parFvFieldReconstructor&);
public:
// Constructors
//- Construct from components
parFvFieldReconstructor
(
fvMesh& baseMesh,
const fvMesh& procMesh,
const mapDistributePolyMesh& distMap,
const bool isWriteProc
);
// Member Functions
//- Reconstruct volume internal field
template<class Type>
tmp<DimensionedField<Type, volMesh> >
reconstructFvVolumeInternalField
(
const DimensionedField<Type, volMesh>&
) const;
//- Read and reconstruct volume internal field
template<class Type>
tmp<DimensionedField<Type, volMesh> >
reconstructFvVolumeInternalField(const IOobject& fieldIoObject) const;
//- Reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
reconstructFvVolumeField
(
const GeometricField<Type, fvPatchField, volMesh>& fld
) const;
//- Read and reconstruct volume field
template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh> >
reconstructFvVolumeField(const IOobject& fieldIoObject) const;
//- Reconstruct surface field
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
reconstructFvSurfaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>&
) const;
//- Read and reconstruct surface field
template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
reconstructFvSurfaceField(const IOobject& fieldIoObject) const;
//- Read, reconstruct and write all/selected volume internal fields
template<class Type>
void reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const;
//- Read, reconstruct and write all/selected volume fields
template<class Type>
void reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const;
//- Read, reconstruct and write all/selected surface fields
template<class Type>
void reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const;
//- Helper: reconstruct and write mesh points
// (note: should be moved to something like processorMeshes class)
void reconstructPoints();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "parFvFieldReconstructorReconstructFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,543 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "parFvFieldReconstructor.H"
#include "Time.H"
#include "PtrList.H"
#include "fvPatchFields.H"
#include "emptyFvPatch.H"
#include "emptyFvPatchField.H"
#include "emptyFvsPatchField.H"
#include "IOobjectList.H"
#include "mapDistributePolyMesh.H"
#include "processorFvPatch.H"
#include "directFvPatchFieldMapper.H"
#include "distributedUnallocatedDirectFieldMapper.H"
#include "distributedUnallocatedDirectFvPatchFieldMapper.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
(
const DimensionedField<Type, volMesh>& fld
) const
{
distributedUnallocatedDirectFieldMapper mapper
(
labelUList::null(),
distMap_.cellMap()
);
Field<Type> internalField(fld, mapper);
// Construct a volField
IOobject baseIO
(
fld.name(),
baseMesh_.time().timeName(),
fld.local(),
baseMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
);
return tmp<DimensionedField<Type, volMesh> >
(
new DimensionedField<Type, volMesh>
(
baseIO,
baseMesh_,
fld.dimensions(),
internalField
)
);
}
template<class Type>
Foam::tmp<Foam::DimensionedField<Type, Foam::volMesh> >
Foam::parFvFieldReconstructor::reconstructFvVolumeInternalField
(
const IOobject& fieldIoObject
) const
{
// Read the field
DimensionedField<Type, volMesh> fld
(
fieldIoObject,
procMesh_
);
// Distribute onto baseMesh
return reconstructFvVolumeInternalField(fld);
}
// Reconstruct a field onto the baseMesh
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::parFvFieldReconstructor::reconstructFvVolumeField
(
const GeometricField<Type, fvPatchField, volMesh>& fld
) const
{
// Create the internalField by remote mapping
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
distributedUnallocatedDirectFieldMapper mapper
(
labelUList::null(),
distMap_.cellMap()
);
Field<Type> internalField(fld.internalField(), mapper);
// Create the patchFields by remote mapping
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Note: patchFields still on mesh, not baseMesh
PtrList<fvPatchField<Type> > patchFields(fld.mesh().boundary().size());
const typename GeometricField
<
Type,
fvPatchField,
volMesh
>::GeometricBoundaryField& bfld = fld.boundaryField();
forAll(bfld, patchI)
{
if (patchFaceMaps_.set(patchI))
{
// Clone local patch field
patchFields.set(patchI, bfld[patchI].clone());
distributedUnallocatedDirectFvPatchFieldMapper mapper
(
labelUList::null(),
patchFaceMaps_[patchI]
);
// Map into local copy
patchFields[patchI].autoMap(mapper);
}
}
PtrList<fvPatchField<Type> > basePatchFields
(
baseMesh_.boundary().size()
);
// Clone the patchFields onto the base patches. This is just to reset
// the reference to the patch, size and content stay the same.
forAll(patchFields, patchI)
{
if (patchFields.set(patchI))
{
const fvPatch& basePatch = baseMesh_.boundary()[patchI];
const fvPatchField<Type>& pfld = patchFields[patchI];
labelList dummyMap(identity(pfld.size()));
directFvPatchFieldMapper dummyMapper(dummyMap);
basePatchFields.set
(
patchI,
fvPatchField<Type>::New
(
pfld,
basePatch,
DimensionedField<Type, volMesh>::null(),
dummyMapper
)
);
}
}
// Add some empty patches on remaining patches (tbd.probably processor
// patches)
forAll(basePatchFields, patchI)
{
if (patchI >= patchFields.size() || !patchFields.set(patchI))
{
basePatchFields.set
(
patchI,
fvPatchField<Type>::New
(
emptyFvPatchField<Type>::typeName,
baseMesh_.boundary()[patchI],
DimensionedField<Type, volMesh>::null()
)
);
}
}
// Construct a volField
IOobject baseIO
(
fld.name(),
baseMesh_.time().timeName(),
fld.local(),
baseMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
);
return tmp<GeometricField<Type, fvPatchField, volMesh> >
(
new GeometricField<Type, fvPatchField, volMesh>
(
baseIO,
baseMesh_,
fld.dimensions(),
internalField,
basePatchFields
)
);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh> >
Foam::parFvFieldReconstructor::reconstructFvVolumeField
(
const IOobject& fieldIoObject
) const
{
// Read the field
GeometricField<Type, fvPatchField, volMesh> fld
(
fieldIoObject,
procMesh_
);
// Distribute onto baseMesh
return reconstructFvVolumeField(fld);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::parFvFieldReconstructor::reconstructFvSurfaceField
(
const GeometricField<Type, fvsPatchField, surfaceMesh>& fld
) const
{
// Create the internalField by remote mapping
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
distributedUnallocatedDirectFieldMapper mapper
(
labelUList::null(),
distMap_.faceMap()
);
// Create flat field of internalField + all patch fields
Field<Type> flatFld(fld.mesh().nFaces(), pTraits<Type>::zero);
SubList<Type>(flatFld, fld.internalField().size()).assign
(
fld.internalField()
);
forAll(fld.boundaryField(), patchI)
{
const fvsPatchField<Type>& fvp = fld.boundaryField()[patchI];
SubList<Type>(flatFld, fvp.size(), fvp.patch().start()).assign(fvp);
}
// Map all faces
Field<Type> internalField(flatFld, mapper);
// Trim to internal faces (note: could also have special mapper)
internalField.setSize
(
min
(
internalField.size(),
baseMesh_.nInternalFaces()
)
);
// Create the patchFields by remote mapping
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Note: patchFields still on mesh, not baseMesh
PtrList<fvsPatchField<Type> > patchFields(fld.mesh().boundary().size());
const typename GeometricField
<
Type,
fvsPatchField,
surfaceMesh
>::GeometricBoundaryField& bfld = fld.boundaryField();
forAll(bfld, patchI)
{
if (patchFaceMaps_.set(patchI))
{
// Clone local patch field
patchFields.set(patchI, bfld[patchI].clone());
distributedUnallocatedDirectFvPatchFieldMapper mapper
(
labelUList::null(),
patchFaceMaps_[patchI]
);
// Map into local copy
patchFields[patchI].autoMap(mapper);
}
}
PtrList<fvsPatchField<Type> > basePatchFields
(
baseMesh_.boundary().size()
);
// Clone the patchFields onto the base patches. This is just to reset
// the reference to the patch, size and content stay the same.
forAll(patchFields, patchI)
{
if (patchFields.set(patchI))
{
const fvPatch& basePatch = baseMesh_.boundary()[patchI];
const fvsPatchField<Type>& pfld = patchFields[patchI];
labelList dummyMap(identity(pfld.size()));
directFvPatchFieldMapper dummyMapper(dummyMap);
basePatchFields.set
(
patchI,
fvsPatchField<Type>::New
(
pfld,
basePatch,
DimensionedField<Type, surfaceMesh>::null(),
dummyMapper
)
);
}
}
// Add some empty patches on remaining patches (tbd.probably processor
// patches)
forAll(basePatchFields, patchI)
{
if (patchI >= patchFields.size() || !patchFields.set(patchI))
{
basePatchFields.set
(
patchI,
fvsPatchField<Type>::New
(
emptyFvsPatchField<Type>::typeName,
baseMesh_.boundary()[patchI],
DimensionedField<Type, surfaceMesh>::null()
)
);
}
}
// Construct a volField
IOobject baseIO
(
fld.name(),
baseMesh_.time().timeName(),
fld.local(),
baseMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
);
return tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
(
new GeometricField<Type, fvsPatchField, surfaceMesh>
(
baseIO,
baseMesh_,
fld.dimensions(),
internalField,
basePatchFields
)
);
}
template<class Type>
Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> >
Foam::parFvFieldReconstructor::reconstructFvSurfaceField
(
const IOobject& fieldIoObject
) const
{
// Read the field
GeometricField<Type, fvsPatchField, surfaceMesh> fld
(
fieldIoObject,
procMesh_
);
return reconstructFvSurfaceField(fld);
}
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeInternalFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const
{
const word& fieldClassName = DimensionedField<Type, volMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
forAllConstIter(IOobjectList, fields, fieldIter)
{
if
(
selectedFields.empty()
|| selectedFields.found(fieldIter()->name())
)
{
Info<< " " << fieldIter()->name() << endl;
tmp<DimensionedField<Type, volMesh> > tfld
(
reconstructFvVolumeInternalField<Type>(*fieldIter())
);
if (isWriteProc_)
{
tfld().write();
}
}
}
Info<< endl;
}
}
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvVolumeFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const
{
const word& fieldClassName =
GeometricField<Type, fvPatchField, volMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
forAllConstIter(IOobjectList, fields, fieldIter)
{
const word& name = fieldIter()->name();
if
(
(selectedFields.empty() || selectedFields.found(name))
&& name != "cellDist"
)
{
Info<< " " << name << endl;
tmp<GeometricField<Type, fvPatchField, volMesh> > tfld
(
reconstructFvVolumeField<Type>(*fieldIter())
);
if (isWriteProc_)
{
tfld().write();
}
}
}
Info<< endl;
}
}
template<class Type>
void Foam::parFvFieldReconstructor::reconstructFvSurfaceFields
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const
{
const word& fieldClassName =
GeometricField<Type, fvsPatchField, surfaceMesh>::typeName;
IOobjectList fields = objects.lookupClass(fieldClassName);
if (fields.size())
{
Info<< " Reconstructing " << fieldClassName << "s\n" << endl;
forAllConstIter(IOobjectList, fields, fieldIter)
{
if
(
selectedFields.empty()
|| selectedFields.found(fieldIter()->name())
)
{
Info<< " " << fieldIter()->name() << endl;
tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tfld
(
reconstructFvSurfaceField<Type>(*fieldIter())
);
if (isWriteProc_)
{
tfld().write();
}
}
}
Info<< endl;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,321 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ListOps.H"
#include "parLagrangianRedistributor.H"
#include "passiveParticleCloud.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::parLagrangianRedistributor::parLagrangianRedistributor
(
const fvMesh& srcMesh,
const fvMesh& tgtMesh,
const label nSrcCells,
const mapDistributePolyMesh& distMap
)
:
srcMesh_(srcMesh),
tgtMesh_(tgtMesh),
distMap_(distMap)
{
const mapDistribute& cellMap = distMap_.cellMap();
// Get destination processors and cells
destinationProcID_ = labelList(tgtMesh_.nCells(), Pstream::myProcNo());
cellMap.reverseDistribute(nSrcCells, destinationProcID_);
destinationCell_ = identity(tgtMesh_.nCells());
cellMap.reverseDistribute(nSrcCells, destinationCell_);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Find all clouds (on all processors) and for each cloud all the objects.
// Result will be synchronised on all processors
void Foam::parLagrangianRedistributor::findClouds
(
const fvMesh& mesh,
wordList& cloudNames,
List<wordList>& objectNames
)
{
fileNameList localCloudDirs
(
readDir
(
mesh.time().timePath()
/ mesh.dbDir()
/ cloud::prefix,
fileName::DIRECTORY
)
);
cloudNames.setSize(localCloudDirs.size());
forAll(localCloudDirs, i)
{
cloudNames[i] = localCloudDirs[i];
}
// Synchronise cloud names
Pstream::combineGather(cloudNames, ListUniqueEqOp<word>());
Pstream::combineScatter(cloudNames);
objectNames.setSize(cloudNames.size());
forAll(localCloudDirs, i)
{
// Do local scan for valid cloud objects
IOobjectList sprayObjs
(
mesh,
mesh.time().timeName(),
cloud::prefix/localCloudDirs[i]
);
if (sprayObjs.lookup(word("positions")))
{
// One of the objects is positions so must be valid cloud
label cloudI = findIndex(cloudNames, localCloudDirs[i]);
objectNames[cloudI].setSize(sprayObjs.size());
label objectI = 0;
forAllConstIter(IOobjectList, sprayObjs, iter)
{
const word& name = iter.key();
if (name != "positions")
{
objectNames[cloudI][objectI++] = name;
}
}
objectNames[cloudI].setSize(objectI);
}
}
// Synchronise objectNames
forAll(objectNames, cloudI)
{
Pstream::combineGather(objectNames[cloudI], ListUniqueEqOp<word>());
Pstream::combineScatter(objectNames[cloudI]);
}
}
Foam::autoPtr<Foam::mapDistributeBase>
Foam::parLagrangianRedistributor::redistributeLagrangianPositions
(
passiveParticleCloud& lpi
) const
{
//Debug(lpi.size());
labelListList subMap;
// Allocate transfer buffers
PstreamBuffers pBufs(Pstream::nonBlocking);
{
// List of lists of particles to be transfered for all of the
// neighbour processors
List<IDLList<passiveParticle> > particleTransferLists
(
Pstream::nProcs()
);
// Per particle the destination processor
labelList destProc(lpi.size());
label particleI = 0;
forAllIter(passiveParticleCloud, lpi, iter)
{
passiveParticle& ppi = iter();
label destProcI = destinationProcID_[ppi.cell()];
label destCellI = destinationCell_[ppi.cell()];
ppi.cell() = destCellI;
destProc[particleI++] = destProcI;
//Pout<< "Sending particle:" << ppi << " to processor " << destProcI
// << " to cell " << destCellI << endl;
particleTransferLists[destProcI].append(lpi.remove(&ppi));
}
// Per processor the indices of the particles to send
subMap = invertOneToMany(Pstream::nProcs(), destProc);
// Stream into send buffers
forAll(particleTransferLists, procI)
{
//Pout<< "To proc " << procI << " sending "
// << particleTransferLists[procI] << endl;
if (particleTransferLists[procI].size())
{
UOPstream particleStream(procI, pBufs);
particleStream << particleTransferLists[procI];
}
}
}
// Start sending. Sets number of bytes transferred
labelListList allNTrans(Pstream::nProcs());
pBufs.finishedSends(allNTrans);
{
// Temporarily rename original cloud so we can construct a new one
// (to distribute the positions) without getting a duplicate
// registration warning
const word cloudName = lpi.name();
lpi.rename(cloudName + "_old");
// New cloud on tgtMesh
passiveParticleCloud lagrangianPositions
(
tgtMesh_,
cloudName,
IDLList<passiveParticle>()
);
// Retrieve from receive buffers
forAll(allNTrans, procI)
{
label nRec = allNTrans[procI][Pstream::myProcNo()];
//Pout<< "From processor " << procI << " receiving bytes " << nRec
// << endl;
if (nRec)
{
UIPstream particleStream(procI, pBufs);
IDLList<passiveParticle> newParticles
(
particleStream,
passiveParticle::iNew(tgtMesh_)
);
forAllIter
(
IDLList<passiveParticle>,
newParticles,
newpIter
)
{
passiveParticle& newp = newpIter();
lagrangianPositions.addParticle(newParticles.remove(&newp));
}
}
}
//OFstream::debug = 1;
//Debug(lagrangianPositions.size());
IOPosition<passiveParticleCloud>(lagrangianPositions).write();
//OFstream::debug = 0;
// Restore cloud name
lpi.rename(cloudName);
}
// Work the send indices (subMap) into a mapDistributeBase
labelListList sizes(Pstream::nProcs());
labelList& nsTransPs = sizes[Pstream::myProcNo()];
nsTransPs.setSize(Pstream::nProcs());
forAll(subMap, sendProcI)
{
nsTransPs[sendProcI] = subMap[sendProcI].size();
}
// Send sizes across. Note: blocks.
combineReduce(sizes, Pstream::listEq());
labelListList constructMap(Pstream::nProcs());
label constructSize = 0;
forAll(constructMap, procI)
{
label nRecv = sizes[procI][UPstream::myProcNo()];
labelList& map = constructMap[procI];
map.setSize(nRecv);
forAll(map, i)
{
map[i] = constructSize++;
}
}
// Construct map
return autoPtr<mapDistributeBase>
(
new mapDistributeBase
(
constructSize,
subMap.xfer(),
constructMap.xfer()
)
);
}
Foam::autoPtr<Foam::mapDistributeBase>
Foam::parLagrangianRedistributor::redistributeLagrangianPositions
(
const word& cloudName
) const
{
(void)srcMesh_.tetBasePtIs();
(void)tgtMesh_.tetBasePtIs();
// Temporarily: override master-only checking
regIOobject::fileCheckTypes oldCheckType =
regIOobject::fileModificationChecking;
if (oldCheckType == regIOobject::timeStampMaster)
{
regIOobject::fileModificationChecking = regIOobject::timeStamp;
}
else if (oldCheckType == regIOobject::inotifyMaster)
{
regIOobject::fileModificationChecking = regIOobject::inotify;
}
// Load cloud and send particle
passiveParticleCloud lpi(srcMesh_, cloudName, false);
regIOobject::fileModificationChecking = oldCheckType;
return redistributeLagrangianPositions(lpi);
}
// ************************************************************************* //

View File

@ -0,0 +1,186 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::parLagrangianRedistributor
Description
Lagrangian field redistributor.
Runs in parallel. Redistributes from fromMesh to toMesh.
SourceFiles
parLagrangianRedistributor.C
parLagrangianRedistributorRedistributeFields.C
\*---------------------------------------------------------------------------*/
#ifndef parLagrangianRedistributor_H
#define parLagrangianRedistributor_H
#include "PtrList.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class mapDistributePolyMesh;
class mapDistributeBase;
class IOobjectList;
class passiveParticleCloud;
/*---------------------------------------------------------------------------*\
Class parLagrangianRedistributor Declaration
\*---------------------------------------------------------------------------*/
class parLagrangianRedistributor
{
// Private data
//- Source mesh reference
const fvMesh& srcMesh_;
//- Destination mesh reference
const fvMesh& tgtMesh_;
//- Distribution map reference
const mapDistributePolyMesh& distMap_;
//- For every src cell the target processor
labelList destinationProcID_;
//- For every src cell the target cell
labelList destinationCell_;
// Private Member Functions
//- Disallow default bitwise copy construct
parLagrangianRedistributor(const parLagrangianRedistributor&);
//- Disallow default bitwise assignment
void operator=(const parLagrangianRedistributor&);
public:
// Constructors
//- Construct from components
parLagrangianRedistributor
(
const fvMesh& srcMesh,
const fvMesh& tgtMesh,
const label nOldCells,
const mapDistributePolyMesh& distMap
);
// Member Functions
//- Find all clouds (on all processors) and for each cloud all
// the objects. Result will be synchronised on all processors
static void findClouds
(
const fvMesh&,
wordList& cloudNames,
List<wordList>& objectNames
);
//- Redistribute and write lagrangian positions
autoPtr<mapDistributeBase> redistributeLagrangianPositions
(
passiveParticleCloud& cloud
) const;
//- Read, redistribute and write lagrangian positions
autoPtr<mapDistributeBase> redistributeLagrangianPositions
(
const word& cloudName
) const;
//- Pick up any fields of a given type
template<class Type>
static wordList filterObjects
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
);
//- Read, redistribute and write all/selected lagrangian fields
template<class Type>
void redistributeLagrangianFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const;
//- Read, redistribute and write all/selected lagrangian fieldFields
template<class Type>
void redistributeLagrangianFieldFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const;
//- Read and store all fields of a cloud
template<class Container>
static void readLagrangianFields
(
const passiveParticleCloud& cloud,
const IOobjectList& objects,
const HashSet<word>& selectedFields
);
//- Redistribute and write stored lagrangian fields
template<class Container>
void redistributeStoredLagrangianFields
(
const mapDistributeBase& map,
passiveParticleCloud& cloud
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "parLagrangianRedistributorRedistributeFields.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,320 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "parLagrangianRedistributor.H"
#include "Time.H"
#include "IOobjectList.H"
#include "mapDistributePolyMesh.H"
#include "cloud.H"
#include "CompactIOField.H"
#include "passiveParticleCloud.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Container>
Foam::wordList Foam::parLagrangianRedistributor::filterObjects
(
const IOobjectList& objects,
const HashSet<word>& selectedFields
)
{
const word fieldClassName(Container::typeName);
// Parallel synchronise
wordList fieldNames(objects.names(fieldClassName));
Pstream::combineGather(fieldNames, ListUniqueEqOp<word>());
Pstream::combineScatter(fieldNames);
if (!selectedFields.empty())
{
DynamicList<word> selectedNames(fieldNames.size());
forAll(fieldNames, i)
{
if (selectedFields.found(fieldNames[i]))
{
selectedNames.append(fieldNames[i]);
}
}
fieldNames.transfer(selectedNames);
}
return fieldNames;
}
template<class Type>
void Foam::parLagrangianRedistributor::redistributeLagrangianFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const
{
const wordList objectNames
(
filterObjects<IOField<Type> >
(
objects,
selectedFields
)
);
if (objectNames.size())
{
const word fieldClassName(IOField<Type>::typeName);
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
forAll(objectNames, i)
{
Info<< " " << objectNames[i] << endl;
// Read if present
IOField<Type> field
(
IOobject
(
objectNames[i],
srcMesh_.time().timeName(),
cloud::prefix/cloudName,
srcMesh_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
),
0
);
map.distribute(field);
if (field.size())
{
IOField<Type>
(
IOobject
(
objectNames[i],
tgtMesh_.time().timeName(),
cloud::prefix/cloudName,
tgtMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove<Field<Type> >(field)
).write();
}
}
Info<< endl;
}
}
template<class Type>
void Foam::parLagrangianRedistributor::redistributeLagrangianFieldFields
(
const mapDistributeBase& map,
const word& cloudName,
const IOobjectList& objects,
const HashSet<word>& selectedFields
) const
{
wordList objectNames
(
filterObjects<CompactIOField<Field<Type>, Type> >
(
objects,
selectedFields
)
);
// Append IOField names
{
const wordList ioFieldNames
(
filterObjects<IOField<Field<Type> > >
(
objects,
selectedFields
)
);
objectNames.append(ioFieldNames);
}
if (objectNames.size())
{
const word fieldClassName(CompactIOField<Field<Type>, Type>::typeName);
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
forAll(objectNames, i)
{
Info<< " " << objectNames[i] << endl;
// Read if present
CompactIOField<Field<Type>, Type > field
(
IOobject
(
objectNames[i],
srcMesh_.time().timeName(),
cloud::prefix/cloudName,
srcMesh_,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false
),
0
);
// Distribute
map.distribute(field);
// Write
if (field.size())
{
CompactIOField<Field<Type>, Type>
(
IOobject
(
objectNames[i],
tgtMesh_.time().timeName(),
cloud::prefix/cloudName,
tgtMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove<Field<Field<Type> > >(field)
).write();
}
}
}
}
template<class Container>
void Foam::parLagrangianRedistributor::readLagrangianFields
(
const passiveParticleCloud& cloud,
const IOobjectList& objects,
const HashSet<word>& selectedFields
)
{
const wordList objectNames
(
filterObjects<Container>
(
objects,
selectedFields
)
);
if (objectNames.size())
{
const word fieldClassName(Container::typeName);
Info<< " Reading lagrangian "
<< fieldClassName << "s\n" << endl;
forAll(objectNames, i)
{
Info<< " " << objectNames[i] << endl;
// Read if present
Container* fieldPtr = new Container
(
IOobject
(
objectNames[i],
cloud.time().timeName(),
cloud,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
0
);
fieldPtr->store();
}
}
}
template<class Container>
void Foam::parLagrangianRedistributor::redistributeStoredLagrangianFields
(
const mapDistributeBase& map,
passiveParticleCloud& cloud
) const
{
HashTable<Container*> fields
(
cloud.lookupClass<Container >()
);
if (fields.size())
{
const word fieldClassName(Container::typeName);
Info<< " Redistributing lagrangian "
<< fieldClassName << "s\n" << endl;
forAllIter(typename HashTable<Container*>, fields, iter)
{
Container& field = *iter();
Info<< " " << field.name() << endl;
map.distribute(field);
if (field.size())
{
Container
(
IOobject
(
field.name(),
tgtMesh_.time().timeName(),
cloud::prefix/cloud.name(),
tgtMesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
xferMove<Field<typename Container::value_type> >(field)
).write();
}
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,112 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::unmappedPassiveParticleCloud
Description
passiveParticleCloud but with autoMap and writing disabled. Only used
for its objectRegistry to store lagrangian fields
SourceFiles
unmappedPassiveParticleCloud.C
\*---------------------------------------------------------------------------*/
#ifndef unmappedPassiveParticleCloud_H
#define unmappedPassiveParticleCloud_H
#include "passiveParticleCloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class unmappedPassiveParticleCloud Declaration
\*---------------------------------------------------------------------------*/
class unmappedPassiveParticleCloud
:
public passiveParticleCloud
{
public:
// Constructors
//- Construct given mesh
unmappedPassiveParticleCloud
(
const polyMesh& mesh,
const word& cloudName = "defaultCloud",
bool readFields = true
)
:
passiveParticleCloud(mesh, cloudName, readFields)
{}
//- Construct from mesh, cloud name, and a list of particles
unmappedPassiveParticleCloud
(
const polyMesh& mesh,
const word& cloudName,
const IDLList<passiveParticle>& particles
)
:
passiveParticleCloud(mesh, cloudName, particles)
{}
//- Destructor
virtual ~unmappedPassiveParticleCloud()
{}
//- Switch off remapping of cells of particles when
// mesh topology changes
virtual void autoMap(const mapPolyMesh&)
{}
//- Switch off writing the objects
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
return true;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,12 +1,14 @@
EXE_INC = \
/* -DFULLDEBUG -g -O0 */ \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-ldynamicMesh \
-lmeshTools \
-lsampling \
-lgenericPatchFields \

View File

@ -2,12 +2,14 @@ EXE_INC = \
-I$(WM_THIRD_PARTY_DIR)/tecio/tecsrc/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-llagrangian \
-lfiniteVolume \
-ldynamicMesh \
-lgenericPatchFields \
-lmeshTools \
-L$(FOAM_EXT_LIBBIN) -ltecio

View File

@ -1,10 +1,12 @@
EXE_INC = \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-ldynamicMesh \
-llagrangian \
-lgenericPatchFields \
-lmeshTools

View File

@ -3,6 +3,7 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I../../vtkPV4Readers/lnInclude \
-I../PV4FoamReader \
@ -15,6 +16,7 @@ EXE_INC = \
LIB_LIBS = \
-lmeshTools \
-lfiniteVolume \
-ldynamicMesh \
-lgenericPatchFields \
-llagrangian \
-L$(FOAM_LIBBIN) -lvtkPV4Readers \

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,7 +41,8 @@ void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh::interpolationMethod& mapMethod,
const word& mapMethod,
const word& AMIMapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
@ -50,7 +51,7 @@ void mapConsistentMesh
Info<< nl << "Consistently creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMesh interp(meshSource, meshTarget, mapMethod);
meshToMesh interp(meshSource, meshTarget, mapMethod, AMIMapMethod);
if (subtract)
{
@ -79,7 +80,8 @@ void mapSubMesh
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const meshToMesh::interpolationMethod& mapMethod,
const word& mapMethod,
const word& AMIMapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
@ -93,6 +95,7 @@ void mapSubMesh
meshSource,
meshTarget,
mapMethod,
AMIMapMethod,
patchMap,
cuttingPatches
);
@ -184,7 +187,14 @@ int main(int argc, char *argv[])
(
"mapMethod",
"word",
"specify the mapping method"
"specify the mapping method "
"(direct|mapNearest|cellVolumeWeight|correctedCellVolumeWeight)"
);
argList::addOption
(
"patchMapMethod",
"word",
"specify the patch mapping method (direct|mapNearest|faceAreaWeight)"
);
argList::addBoolOption
(
@ -231,15 +241,46 @@ int main(int argc, char *argv[])
const bool consistent = args.optionFound("consistent");
meshToMesh::interpolationMethod mapMethod =
meshToMesh::imCellVolumeWeight;
if (args.optionFound("mapMethod"))
word mapMethod = meshToMesh::interpolationMethodNames_
[
meshToMesh::imCellVolumeWeight
];
if (args.optionReadIfPresent("mapMethod", mapMethod))
{
mapMethod = meshToMesh::interpolationMethodNames_[args["mapMethod"]];
Info<< "Mapping method: " << mapMethod << endl;
}
Info<< "Mapping method: "
<< meshToMesh::interpolationMethodNames_[mapMethod] << endl;
word patchMapMethod;
if (meshToMesh::interpolationMethodNames_.found(mapMethod))
{
// Lookup corresponding AMI method
meshToMesh::interpolationMethod method =
meshToMesh::interpolationMethodNames_[mapMethod];
patchMapMethod = AMIPatchToPatchInterpolation::interpolationMethodToWord
(
meshToMesh::interpolationMethodAMI(method)
);
}
// Optionally override
if (args.optionFound("patchMapMethod"))
{
patchMapMethod = args["patchMapMethod"];
Info<< "Patch mapping method: " << patchMapMethod << endl;
}
if (patchMapMethod.empty())
{
FatalErrorIn(args.executable())
<< "No valid patchMapMethod for method " << mapMethod
<< ". Please supply one through the 'patchMapMethod' option"
<< exit(FatalError);
}
const bool subtract = args.optionFound("subtract");
@ -304,8 +345,9 @@ int main(int argc, char *argv[])
)
);
Info<< "Source mesh size: " << meshSource.nCells() << tab
<< "Target mesh size: " << meshTarget.nCells() << nl << endl;
Info<< "Source mesh size: " << meshSource.globalData().nTotalCells() << tab
<< "Target mesh size: " << meshTarget.globalData().nTotalCells()
<< nl << endl;
if (consistent)
{
@ -314,6 +356,7 @@ int main(int argc, char *argv[])
meshSource,
meshTarget,
mapMethod,
patchMapMethod,
subtract,
selectedFields,
noLagrangian
@ -328,6 +371,7 @@ int main(int argc, char *argv[])
patchMap,
addProcessorPatches(meshTarget, cuttingPatches),
mapMethod,
patchMapMethod,
subtract,
selectedFields,
noLagrangian

View File

@ -1,3 +0,0 @@
surfaceAutoPatch.C
EXE = $(FOAM_APPBIN)/surfaceAutoPatch

View File

@ -1,7 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
EXE_LIBS = \
-lmeshTools \
-ltriSurface

View File

@ -1,125 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfaceAutoPatch
Description
Patches surface according to feature angle. Like autoPatch.
\*---------------------------------------------------------------------------*/
#include "triangle.H"
#include "triSurface.H"
#include "argList.H"
#include "surfaceFeatures.H"
#include "treeBoundBox.H"
#include "meshTools.H"
#include "OFstream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::noParallel();
argList::validArgs.append("input surfaceFile");
argList::validArgs.append("output surfaceFile");
argList::validArgs.append("includedAngle [0..180]");
argList args(argc, argv);
const fileName inFileName = args[1];
const fileName outFileName = args[2];
const scalar includedAngle = args.argRead<scalar>(3);
Info<< "Surface : " << inFileName << nl << endl;
// Read
// ~~~~
Info<< "Reading : " << inFileName << endl;
triSurface surf(inFileName);
Info<< "Read surface:" << endl;
surf.writeStats(Info);
Info<< endl;
// Construct features from surface&featureangle
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Info<< "Constructing feature set from included angle " << includedAngle
<< endl;
surfaceFeatures set(surf, includedAngle);
Info<< nl
<< "Feature set:" << nl
<< " feature points : " << set.featurePoints().size() << nl
<< " feature edges : " << set.featureEdges().size() << nl
<< " of which" << nl
<< " region edges : " << set.nRegionEdges() << nl
<< " external edges : " << set.nExternalEdges() << nl
<< " internal edges : " << set.nInternalEdges() << nl
<< endl;
// Get per-edge status.
boolList borderEdge(surf.nEdges(), false);
forAll(set.featureEdges(), i)
{
borderEdge[set.featureEdges()[i]] = true;
}
labelList faceRegion(surf.size());
label nRegions = surf.markZones(borderEdge, faceRegion);
// Reregion triangles.
forAll(surf, i)
{
surf[i].region() = faceRegion[i];
}
// Create some patches
surf.patches().setSize(nRegions);
forAll(surf.patches(), patchI)
{
surf.patches()[patchI].name() = "patch" + Foam::name(patchI);
surf.patches()[patchI].geometricType() = "empty";
}
Info<< "Writing : " << outFileName << endl;
surf.write(outFileName, true);
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,15 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
set -x
if [ -z "$CGAL_ARCH_PATH" ]
then
export COMPILE_FLAGS="-DNO_CGAL"
else
wmake PolyhedronReader
export COMPILE_FLAGS='-IPolyhedronReader'
export LINK_FLAGS='${CGAL_LIBS} -lPolyhedronReader'
fi
wmake
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,55 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedefs
CGAL3DKernel
Description
\*---------------------------------------------------------------------------*/
#ifndef CGAL3DKernel_H
#define CGAL3DKernel_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef CGAL_INEXACT
// Fast kernel using a double as the storage type
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
#else
// Very robust but expensive kernel
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,98 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Typedefs
IndexedPolyhedron
Description
CGAL data structures used for triSurface handling
Define CGAL_INEXACT to use Exact_predicates_inexact_constructions kernel
otherwise the more robust but much less efficient
Exact_predicates_exact_constructions will be used.
\*---------------------------------------------------------------------------*/
#ifndef IndexedPolyhedron_H
#define IndexedPolyhedron_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Include uint.H before CGAL headers to define __STDC_LIMIT_MACROS
#include "uint.H"
#include "CGAL3DKernel.H"
#include <CGAL/Polyhedron_3.h>
#include <CGAL/Nef_polyhedron_3.h>
#include "label.H"
typedef CGAL::Point_3<K> Point;
typedef CGAL::Segment_3<K> Segment;
typedef CGAL::Direction_3<K> Direction;
typedef CGAL::Plane_3<K> Plane;
typedef CGAL::Triangle_3<K> Triangle;
// Define new class with color and define the polyhedron types
template<class Refs>
struct IndexedFace
:
public CGAL::HalfedgeDS_face_base<Refs>
{
Foam::label index;
Foam::label region;
};
struct My_items
:
public CGAL::Polyhedron_items_3
{
template<class Refs, class Traits>
struct Face_wrapper
{
typedef IndexedFace<Refs> Face;
};
};
//typedef CGAL::Polyhedron_3<K> Polyhedron;
typedef CGAL::Polyhedron_3<K, My_items> Polyhedron;
typedef Polyhedron::HalfedgeDS HalfedgeDS;
typedef Polyhedron::Edge_iterator Edge_iterator;
typedef Polyhedron::Vertex Vertex;
typedef Polyhedron::Vertex_iterator Vertex_iterator;
typedef Polyhedron::Halfedge_handle Halfedge_handle;
typedef Polyhedron::Edge_iterator Edge_iterator;
typedef Polyhedron::Facet_iterator Facet_iterator;
typedef Polyhedron::Halfedge_around_facet_const_circulator HFCC;
typedef Polyhedron::Vertex_const_iterator VCI;
typedef CGAL::Nef_polyhedron_3<K> Nef_polyhedron;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,9 +1,29 @@
EXE_NDEBUG = -DNDEBUG
/* EXE_NDEBUG = -g -O0 -DFULLDEBUG */
c++CGALWARN = -Wno-old-style-cast
/*-- Define NO_CGAL to avoid using CGAL altogether */
/*-- Define CGAL_INEXACT to use inexact CGAL constructions */
include $(GENERAL_RULES)/CGAL
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
${ROUNDING_MATH} \
${EXE_NDEBUG} \
${CGAL_INC} \
${c++CGALWARN} \
$(COMPILE_FLAGS) \
-IPolyhedronReader \
-I$(FOAM_SRC)/surfMesh/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lsurfMesh \
-ltriSurface \
-ledgeMesh \
-lmeshTools
-lmeshTools \
$(LINK_FLAGS)

View File

@ -0,0 +1,3 @@
PolyhedronReader.C
LIB = $(FOAM_LIBBIN)/libPolyhedronReader

View File

@ -0,0 +1,25 @@
EXE_NDEBUG = -DNDEBUG
/* EXE_NDEBUG = -g -O0 -DFULLDEBUG */
c++CGALWARN = -Wno-old-style-cast
/*-- Define CGAL_INEXACT to use inexact CGAL constructions */
include $(GENERAL_RULES)/CGAL
EXE_INC = \
${ROUNDING_MATH} \
${EXE_NDEBUG} \
${CGAL_INC} \
${c++CGALWARN} \
-I.. \
-I$(FOAM_SRC)/surfMesh/lnInclude \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I/usr/include/Qt
LIB_LIBS = \
-L${CGAL_ARCH_PATH}/lib \
-ltriSurface

View File

@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PolyhedronReader.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
{
Build_triangle<HalfedgeDS> triangle(s);
p.delegate(triangle);
// Populate index and region
Foam::label nTris = 0;
for
(
Facet_iterator fi = p.facets_begin();
fi != p.facets_end();
++fi
)
{
fi->index = nTris++;
fi->region = s[fi->index].region();
}
}
// ************************************************************************* //

View File

@ -0,0 +1,101 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::PolyhedronReader
Description
SourceFiles
PolyhedronReader.C
\*---------------------------------------------------------------------------*/
#ifndef PolyhedronReader_H
#define PolyhedronReader_H
#include "CGALIndexedPolyhedron.H"
#include "triSurface.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class PolyhedronReader Declaration
\*---------------------------------------------------------------------------*/
class PolyhedronReader
{
// Private Classes
template<class HDS>
class Build_triangle
:
public CGAL::Modifier_base<HDS>
{
const triSurface& s_;
public:
Build_triangle(const triSurface& s);
void operator()(HDS& hds);
};
// Private Member Functions
//- Disallow default bitwise copy construct
PolyhedronReader(const PolyhedronReader&);
//- Disallow default bitwise assignment
void operator=(const PolyhedronReader&);
public:
// Constructors
//- Populate polyhedron from surface
PolyhedronReader(const triSurface& s, Polyhedron& p);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PolyhedronReaderTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "PolyhedronReader.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class HDS>
Foam::PolyhedronReader::Build_triangle<HDS>::Build_triangle
(
const triSurface& s
)
:
s_(s)
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class HDS>
void Foam::PolyhedronReader::Build_triangle<HDS>::operator()(HDS& hds)
{
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(s_.nPoints(), s_.size());
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
const Foam::pointField& pts = s_.points();
forAll(pts, i)
{
const Foam::point& pt = pts[i];
B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
}
forAll(s_, i)
{
const Foam::labelledTri& t = s_[i];
B.begin_facet();
B.add_vertex_to_facet(t[0]);
B.add_vertex_to_facet(t[1]);
B.add_vertex_to_facet(t[2]);
B.end_facet();
}
B.end_surface();
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -170,6 +170,101 @@ labelList countBins
}
void writeZoning
(
const triSurface& surf,
const labelList& faceZone,
const word& fieldName,
const fileName& surfFilePath,
const fileName& surfFileNameBase
)
{
Info<< "Writing zoning to "
<< fileName
(
surfFilePath
/ fieldName
+ '_'
+ surfFileNameBase
+ '.'
+ vtkSurfaceWriter::typeName
)
<< "..." << endl << endl;
// Convert data
scalarField scalarFaceZone(faceZone.size());
forAll(faceZone, i)
{
scalarFaceZone[i] = faceZone[i];
}
faceList faces(surf.size());
forAll(surf, i)
{
faces[i] = surf[i].triFaceFace();
}
vtkSurfaceWriter().write
(
surfFilePath,
surfFileNameBase,
surf.points(),
faces,
fieldName,
scalarFaceZone,
false // face based data
);
}
void writeParts
(
const triSurface& surf,
const label nFaceZones,
const labelList& faceZone,
const fileName& surfFilePath,
const fileName& surfFileNameBase
)
{
for (label zone = 0; zone < nFaceZones; zone++)
{
boolList includeMap(surf.size(), false);
forAll(faceZone, faceI)
{
if (faceZone[faceI] == zone)
{
includeMap[faceI] = true;
}
}
labelList pointMap;
labelList faceMap;
triSurface subSurf
(
surf.subsetMesh
(
includeMap,
pointMap,
faceMap
)
);
fileName subName
(
surfFilePath
/surfFileNameBase + "_" + name(zone) + ".obj"
);
Info<< "writing part " << zone << " size " << subSurf.size()
<< " to " << subName << endl;
subSurf.write(subName);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
@ -218,6 +313,20 @@ int main(int argc, char *argv[])
surf.writeStats(Info);
Info<< endl;
// Determine path and extension
fileName surfFileNameBase(surfFileName.name());
const word fileType = surfFileNameBase.ext();
// Strip extension
surfFileNameBase = surfFileNameBase.lessExt();
// If extension was .gz strip original extension
if (fileType == "gz")
{
surfFileNameBase = surfFileNameBase.lessExt();
}
const fileName surfFilePath(surfFileName.path());
// write bounding box corners
if (args.optionFound("blockMesh"))
{
@ -515,12 +624,12 @@ int main(int argc, char *argv[])
DynamicList<label> problemFaces(surf.size()/100 + 1);
const labelListList& eFaces = surf.edgeFaces();
const labelListList& edgeFaces = surf.edgeFaces();
label nSingleEdges = 0;
forAll(eFaces, edgeI)
forAll(edgeFaces, edgeI)
{
const labelList& myFaces = eFaces[edgeI];
const labelList& myFaces = edgeFaces[edgeI];
if (myFaces.size() == 1)
{
@ -531,9 +640,9 @@ int main(int argc, char *argv[])
}
label nMultEdges = 0;
forAll(eFaces, edgeI)
forAll(edgeFaces, edgeI)
{
const labelList& myFaces = eFaces[edgeI];
const labelList& myFaces = edgeFaces[edgeI];
if (myFaces.size() > 2)
{
@ -549,7 +658,8 @@ int main(int argc, char *argv[])
if ((nSingleEdges != 0) || (nMultEdges != 0))
{
Info<< "Surface is not closed since not all edges connected to "
Info<< "Surface is not closed since not all edges ("
<< edgeFaces.size() << ") connected to "
<< "two faces:" << endl
<< " connected to one face : " << nSingleEdges << endl
<< " connected to >2 faces : " << nMultEdges << endl;
@ -578,10 +688,9 @@ int main(int argc, char *argv[])
boolList borderEdge(surf.nEdges(), false);
if (splitNonManifold)
{
const labelListList& eFaces = surf.edgeFaces();
forAll(eFaces, edgeI)
forAll(edgeFaces, edgeI)
{
if (eFaces[edgeI].size() > 2)
if (edgeFaces[edgeI].size() > 2)
{
borderEdge[edgeI] = true;
}
@ -597,85 +706,15 @@ int main(int argc, char *argv[])
{
Info<< "Splitting surface into parts ..." << endl << endl;
fileName surfFileNameBase(surfFileName.name());
const word fileType = surfFileNameBase.ext();
// Strip extension
surfFileNameBase = surfFileNameBase.lessExt();
// If extension was .gz strip original extension
if (fileType == "gz")
{
surfFileNameBase = surfFileNameBase.lessExt();
}
{
Info<< "Writing zoning to "
<< fileName
(
"zone_"
+ surfFileNameBase
+ '.'
+ vtkSurfaceWriter::typeName
)
<< "..." << endl << endl;
// Convert data
scalarField scalarFaceZone(faceZone.size());
forAll(faceZone, i)
{
scalarFaceZone[i] = faceZone[i];
}
faceList faces(surf.size());
forAll(surf, i)
{
faces[i] = surf[i].triFaceFace();
}
vtkSurfaceWriter().write
(
surfFileName.path(),
surfFileNameBase,
surf.points(),
faces,
"zone",
scalarFaceZone,
false // face based data
);
}
for (label zone = 0; zone < numZones; zone++)
{
boolList includeMap(surf.size(), false);
forAll(faceZone, faceI)
{
if (faceZone[faceI] == zone)
{
includeMap[faceI] = true;
}
}
labelList pointMap;
labelList faceMap;
triSurface subSurf
(
surf.subsetMesh
(
includeMap,
pointMap,
faceMap
)
);
fileName subName(surfFileNameBase + "_" + name(zone) + ".obj");
Info<< "writing part " << zone << " size " << subSurf.size()
<< " to " << subName << endl;
subSurf.write(subName);
}
writeZoning(surf, faceZone, "zone", surfFilePath, surfFileNameBase);
writeParts
(
surf,
numZones,
faceZone,
surfFilePath,
surfFileNameBase
);
}
}
@ -700,6 +739,15 @@ int main(int argc, char *argv[])
if (numNormalZones > 1)
{
Info<< "More than one normal orientation." << endl;
writeZoning(surf, normalZone, "normal", surfFilePath, surfFileNameBase);
writeParts
(
surf,
numNormalZones,
normalZone,
surfFilePath,
surfFileNameBase + "_normal"
);
}
Info<< endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -99,7 +99,6 @@ int main(int argc, char *argv[])
mesh.write(exportName);
mesh.writeStats(Info);
Info<< endl;
Info<< "\nEnd\n" << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -406,7 +406,7 @@ int main(int argc, char *argv[])
str << "l " << 1 << ' ' << i + 1 << endl;
}
Info<< nl << "End" << nl << endl;
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -0,0 +1,3 @@
surfaceInflate.C
EXE = $(FOAM_APPBIN)/surfaceInflate

View File

@ -0,0 +1,10 @@
EXE_INC = \
-I$(FOAM_SRC)/triSurface/lnInclude \
-I$(FOAM_SRC)/surfMesh/lnInclude \
-I$(FOAM_SRC)/meshTools/lnInclude
EXE_LIBS = \
-ltriSurface \
-lsurfMesh \
-lmeshTools

View File

@ -0,0 +1,879 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfaceInflate
Description
Inflates surface. WIP. Checks for overlaps and locally lowers
inflation distance
Usage
- surfaceInflate [OPTION]
\param -checkSelfIntersection \n
Includes checks for self-intersection.
\param -nSmooth
Specify number of smoothing iterations
\param -featureAngle
Specify a feature angle
E.g. inflate surface by 2cm with 1.5 safety factor:
surfaceInflate DTC-scaled.obj 0.02 1.5 -featureAngle 45 -nSmooth 2
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "Time.H"
#include "triSurfaceFields.H"
#include "triSurfaceMesh.H"
#include "triSurfaceGeoMesh.H"
#include "PackedBoolList.H"
#include "OBJstream.H"
#include "surfaceFeatures.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
scalar calcVertexNormalWeight
(
const triFace& f,
const label pI,
const vector& fN,
const pointField& points
)
{
label index = findIndex(f, pI);
if (index == -1)
{
FatalErrorIn("calcVertexNormals()")
<< "Point not in face" << abort(FatalError);
}
const vector e1 = points[f[index]] - points[f[f.fcIndex(index)]];
const vector e2 = points[f[index]] - points[f[f.rcIndex(index)]];
return mag(fN)/(magSqr(e1)*magSqr(e2) + VSMALL);
}
tmp<vectorField> calcVertexNormals(const triSurface& surf)
{
// Weighted average of normals of faces attached to the vertex
// Weight = fA / (mag(e0)^2 * mag(e1)^2);
tmp<vectorField> tpointNormals
(
new pointField(surf.nPoints(), vector::zero)
);
vectorField& pointNormals = tpointNormals();
const pointField& points = surf.points();
const labelListList& pointFaces = surf.pointFaces();
const labelList& meshPoints = surf.meshPoints();
forAll(pointFaces, pI)
{
const labelList& pFaces = pointFaces[pI];
forAll(pFaces, fI)
{
const label faceI = pFaces[fI];
const triFace& f = surf[faceI];
vector fN = f.normal(points);
scalar weight = calcVertexNormalWeight
(
f,
meshPoints[pI],
fN,
points
);
pointNormals[pI] += weight*fN;
}
pointNormals[pI] /= mag(pointNormals[pI]) + VSMALL;
}
return tpointNormals;
}
tmp<vectorField> calcPointNormals
(
const triSurface& s,
const PackedBoolList& isFeaturePoint,
const List<surfaceFeatures::edgeStatus>& edgeStat
)
{
//const pointField pointNormals(s.pointNormals());
tmp<vectorField> tpointNormals(calcVertexNormals(s));
vectorField& pointNormals = tpointNormals();
// feature edges: create edge normals from edgeFaces only.
{
const labelListList& edgeFaces = s.edgeFaces();
labelList nNormals(s.nPoints(), 0);
forAll(edgeStat, edgeI)
{
if (edgeStat[edgeI] != surfaceFeatures::NONE)
{
const edge& e = s.edges()[edgeI];
forAll(e, i)
{
if (!isFeaturePoint[e[i]])
{
pointNormals[e[i]] = vector::zero;
}
}
}
}
forAll(edgeStat, edgeI)
{
if (edgeStat[edgeI] != surfaceFeatures::NONE)
{
const labelList& eFaces = edgeFaces[edgeI];
// Get average edge normal
vector n = vector::zero;
forAll(eFaces, i)
{
n += s.faceNormals()[eFaces[i]];
}
n /= eFaces.size();
// Sum to points
const edge& e = s.edges()[edgeI];
forAll(e, i)
{
if (!isFeaturePoint[e[i]])
{
pointNormals[e[i]] += n;
nNormals[e[i]]++;
}
}
}
}
forAll(nNormals, pointI)
{
if (nNormals[pointI] > 0)
{
pointNormals[pointI] /= mag(pointNormals[pointI]);
}
}
}
forAll(pointNormals, pointI)
{
if (mag(mag(pointNormals[pointI])-1) > SMALL)
{
FatalErrorIn("calcPointNormals()") << "unitialised"
<< exit(FatalError);
}
}
return tpointNormals;
}
void detectSelfIntersections
(
const triSurfaceMesh& s,
PackedBoolList& isEdgeIntersecting
)
{
const edgeList& edges = s.edges();
const indexedOctree<treeDataTriSurface>& tree = s.tree();
const labelList& meshPoints = s.meshPoints();
const pointField& points = s.points();
isEdgeIntersecting.setSize(edges.size());
isEdgeIntersecting = false;
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
pointIndexHit hitInfo
(
tree.findLine
(
points[meshPoints[e[0]]],
points[meshPoints[e[1]]],
treeDataTriSurface::findSelfIntersectOp(tree, edgeI)
)
);
if (hitInfo.hit())
{
isEdgeIntersecting[edgeI] = true;
}
}
}
label detectIntersectionPoints
(
const scalar tolerance,
const triSurfaceMesh& s,
const scalar extendFactor,
const pointField& initialPoints,
const vectorField& displacement,
const bool checkSelfIntersect,
const PackedBoolList& initialIsEdgeIntersecting,
PackedBoolList& isPointOnHitEdge,
scalarField& scale
)
{
const pointField initialLocalPoints(initialPoints, s.meshPoints());
const List<labelledTri>& localFaces = s.localFaces();
label nHits = 0;
isPointOnHitEdge.setSize(s.nPoints());
isPointOnHitEdge = false;
// 1. Extrusion offset vectors intersecting new surface location
{
scalar tol = max(tolerance, 10*s.tolerance());
// Collect all the edge vectors. Slightly shorten the edges to prevent
// finding lots of intersections. The fast triangle intersection routine
// has problems with rays passing through a point of the
// triangle.
pointField start(initialLocalPoints+tol*displacement);
pointField end(initialLocalPoints+extendFactor*displacement);
List<pointIndexHit> hits;
s.findLineAny(start, end, hits);
forAll(hits, pointI)
{
if
(
hits[pointI].hit()
&& findIndex(localFaces[hits[pointI].index()], pointI) == -1
)
{
scale[pointI] = max(0.0, scale[pointI]-0.2);
isPointOnHitEdge[pointI] = true;
nHits++;
}
}
}
// 2. (new) surface self intersections
if (checkSelfIntersect)
{
PackedBoolList isEdgeIntersecting;
detectSelfIntersections(s, isEdgeIntersecting);
const edgeList& edges = s.edges();
const pointField& points = s.points();
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
if (isEdgeIntersecting[edgeI] && !initialIsEdgeIntersecting[edgeI])
{
if (isPointOnHitEdge.set(e[0]))
{
label start = s.meshPoints()[e[0]];
const point& pt = points[start];
Pout<< "Additional self intersection at "
<< pt
<< endl;
scale[e[0]] = max(0.0, scale[e[0]]-0.2);
nHits++;
}
if (isPointOnHitEdge.set(e[1]))
{
label end = s.meshPoints()[e[1]];
const point& pt = points[end];
Pout<< "Additional self intersection at "
<< pt
<< endl;
scale[e[1]] = max(0.0, scale[e[1]]-0.2);
nHits++;
}
}
}
}
return nHits;
}
tmp<scalarField> avg
(
const triSurface& s,
const scalarField& fld,
const scalarField& edgeWeights
)
{
tmp<scalarField> tres(new scalarField(s.nPoints(), 0.0));
scalarField& res = tres();
scalarField sumWeight(s.nPoints(), 0.0);
const edgeList& edges = s.edges();
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
const scalar w = edgeWeights[edgeI];
res[e[0]] += w*fld[e[1]];
sumWeight[e[0]] += w;
res[e[1]] += w*fld[e[0]];
sumWeight[e[1]] += w;
}
// Average
// ~~~~~~~
forAll(res, pointI)
{
if (mag(sumWeight[pointI]) < VSMALL)
{
// Unconnected point. Take over original value
res[pointI] = fld[pointI];
}
else
{
res[pointI] /= sumWeight[pointI];
}
}
return tres;
}
void minSmooth
(
const triSurface& s,
const PackedBoolList& isAffectedPoint,
const scalarField& fld,
scalarField& newFld
)
{
const edgeList& edges = s.edges();
const pointField& points = s.points();
const labelList& mp = s.meshPoints();
scalarField edgeWeights(edges.size());
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
scalar w = mag(points[mp[e[0]]]-points[mp[e[1]]]);
edgeWeights[edgeI] = 1.0/(max(w, SMALL));
}
tmp<scalarField> tavgFld = avg(s, fld, edgeWeights);
const scalarField& avgFld = tavgFld();
forAll(fld, pointI)
{
if (isAffectedPoint.get(pointI) == 1)
{
newFld[pointI] = min
(
fld[pointI],
0.5*fld[pointI] + 0.5*avgFld[pointI]
//avgFld[pointI]
);
}
}
}
void lloydsSmoothing
(
const label nSmooth,
triSurface& s,
const PackedBoolList& isFeaturePoint,
const List<surfaceFeatures::edgeStatus>& edgeStat,
const PackedBoolList& isAffectedPoint
)
{
const labelList& meshPoints = s.meshPoints();
const edgeList& edges = s.edges();
PackedBoolList isSmoothPoint(isAffectedPoint);
// Extend isSmoothPoint
{
PackedBoolList newIsSmoothPoint(isSmoothPoint);
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
if (isSmoothPoint[e[0]])
{
newIsSmoothPoint[e[1]] = true;
}
if (isSmoothPoint[e[1]])
{
newIsSmoothPoint[e[0]] = true;
}
}
Info<< "From points-to-smooth " << isSmoothPoint.count()
<< " to " << newIsSmoothPoint.count()
<< endl;
isSmoothPoint.transfer(newIsSmoothPoint);
}
// Do some smoothing (Lloyds algorithm) around problematic points
for (label i = 0; i < nSmooth; i++)
{
const labelListList& pointFaces = s.pointFaces();
const pointField& faceCentres = s.faceCentres();
pointField newPoints(s.points());
forAll(isSmoothPoint, pointI)
{
if (isSmoothPoint[pointI] && !isFeaturePoint[pointI])
{
const labelList& pFaces = pointFaces[pointI];
point avg = point::zero;
forAll(pFaces, pFaceI)
{
avg += faceCentres[pFaces[pFaceI]];
}
avg /= pFaces.size();
newPoints[meshPoints[pointI]] = avg;
}
}
// Move points on feature edges only according to feature edges.
const pointField& points = s.points();
vectorField pointSum(s.nPoints(), vector::zero);
labelList nPointSum(s.nPoints(), 0);
forAll(edges, edgeI)
{
if (edgeStat[edgeI] != surfaceFeatures::NONE)
{
const edge& e = edges[edgeI];
const point& start = points[meshPoints[e[0]]];
const point& end = points[meshPoints[e[1]]];
point eMid = 0.5*(start+end);
pointSum[e[0]] += eMid;
nPointSum[e[0]]++;
pointSum[e[1]] += eMid;
nPointSum[e[1]]++;
}
}
forAll(pointSum, pointI)
{
if
(
isSmoothPoint[pointI]
&& isFeaturePoint[pointI]
&& nPointSum[pointI] >= 2
)
{
newPoints[meshPoints[pointI]] =
pointSum[pointI]/nPointSum[pointI];
}
}
s.movePoints(newPoints);
// Extend isSmoothPoint
{
PackedBoolList newIsSmoothPoint(isSmoothPoint);
forAll(edges, edgeI)
{
const edge& e = edges[edgeI];
if (isSmoothPoint[e[0]])
{
newIsSmoothPoint[e[1]] = true;
}
if (isSmoothPoint[e[1]])
{
newIsSmoothPoint[e[0]] = true;
}
}
Info<< "From points-to-smooth " << isSmoothPoint.count()
<< " to " << newIsSmoothPoint.count()
<< endl;
isSmoothPoint.transfer(newIsSmoothPoint);
}
}
}
// Main program:
int main(int argc, char *argv[])
{
argList::addNote("Inflates surface according to point normals.");
argList::noParallel();
argList::addNote
(
"Creates inflated version of surface using point normals."
" Takes surface, distance to inflate and additional safety factor"
);
argList::addBoolOption
(
"checkSelfIntersection",
"also check for self-intersection"
);
argList::addOption
(
"nSmooth",
"integer",
"number of smoothing iterations (default 20)"
);
argList::addOption
(
"featureAngle",
"scalar",
"feature angle"
);
argList::addBoolOption
(
"debug",
"switch on additional debug information"
);
argList::validArgs.append("inputFile");
argList::validArgs.append("distance");
argList::validArgs.append("safety factor [1..]");
#include "setRootCase.H"
#include "createTime.H"
runTime.functionObjects().off();
const word inputName(args.args()[1]);
const scalar distance(args.argRead<scalar>(2));
const scalar extendFactor(args.argRead<scalar>(3));
const bool checkSelfIntersect = args.optionFound("checkSelfIntersection");
const label nSmooth = args.optionLookupOrDefault("nSmooth", 10);
const scalar featureAngle = args.optionLookupOrDefault<scalar>
(
"featureAngle",
180
);
const bool debug = args.optionFound("debug");
Info<< "Inflating surface " << inputName
<< " according to point normals" << nl
<< " distance : " << distance << nl
<< " safety factor : " << extendFactor << nl
<< " self intersection test : " << checkSelfIntersect << nl
<< " smoothing iterations : " << nSmooth << nl
<< " feature angle : " << featureAngle << nl
<< endl;
if (extendFactor < 1 || extendFactor > 10)
{
FatalErrorIn(args.executable())
<< "Illegal safety factor " << extendFactor
<< ". It is usually 1..2"
<< exit(FatalError);
}
// Load triSurfaceMesh
triSurfaceMesh s
(
IOobject
(
inputName, // name
runTime.constant(), // instance
"triSurface", // local
runTime, // registry
IOobject::MUST_READ,
IOobject::AUTO_WRITE
)
);
// Mark features
const surfaceFeatures features(s, 180.0-featureAngle);
Info<< "Detected features:" << nl
<< " feature points : " << features.featurePoints().size()
<< " out of " << s.nPoints() << nl
<< " feature edges : " << features.featureEdges().size()
<< " out of " << s.nEdges() << nl
<< endl;
PackedBoolList isFeaturePoint(s.nPoints());
forAll(features.featurePoints(), i)
{
label pointI = features.featurePoints()[i];
isFeaturePoint[pointI] = true;
}
const List<surfaceFeatures::edgeStatus> edgeStat(features.toStatus());
const pointField initialPoints(s.points());
// Construct scale
Info<< "Constructing field scale\n" << endl;
triSurfacePointScalarField scale
(
IOobject
(
"scale", // name
runTime.timeName(), // instance
s, // registry
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
s,
dimensionedScalar("scale", dimLength, 1.0)
);
// Construct unit normals
Info<< "Calculating vertex normals\n" << endl;
const pointField pointNormals
(
calcPointNormals
(
s,
isFeaturePoint,
edgeStat
)
);
// Construct pointDisplacement
Info<< "Constructing field pointDisplacement\n" << endl;
triSurfacePointVectorField pointDisplacement
(
IOobject
(
"pointDisplacement", // name
runTime.timeName(), // instance
s, // registry
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
s,
dimLength,
distance*scale*pointNormals
);
const labelList& meshPoints = s.meshPoints();
// Any point on any intersected edge in any of the iterations
PackedBoolList isScaledPoint(s.nPoints());
// Detect any self intersections on initial mesh
PackedBoolList initialIsEdgeIntersecting;
if (checkSelfIntersect)
{
detectSelfIntersections(s, initialIsEdgeIntersecting);
}
else
{
// Mark all edges as already self intersecting so avoid detecting any
// new ones
initialIsEdgeIntersecting.setSize(s.nEdges(), true);
}
// Inflate
while (runTime.loop())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
// Move to new location
pointField newPoints(initialPoints);
forAll(meshPoints, i)
{
newPoints[meshPoints[i]] += pointDisplacement[i];
}
s.movePoints(newPoints);
Info<< "Bounding box : " << s.bounds() << endl;
// Work out scale from pointDisplacement
forAll(scale, pointI)
{
if (s.pointFaces()[pointI].size())
{
scale[pointI] = mag(pointDisplacement[pointI])/distance;
}
else
{
scale[pointI] = 1.0;
}
}
Info<< "Scale : " << gAverage(scale) << endl;
Info<< "Displacement : " << gAverage(pointDisplacement) << endl;
// Detect any intersections and scale back
PackedBoolList isAffectedPoint;
label nIntersections = detectIntersectionPoints
(
1e-9, // intersection tolerance
s,
extendFactor,
initialPoints,
pointDisplacement,
checkSelfIntersect,
initialIsEdgeIntersecting,
isAffectedPoint,
scale
);
Info<< "Detected " << nIntersections << " intersections" << nl
<< endl;
if (nIntersections == 0)
{
runTime.write();
break;
}
// Accumulate all affected points
forAll(isAffectedPoint, pointI)
{
if (isAffectedPoint[pointI])
{
isScaledPoint[pointI] = true;
}
}
// Smear out lowering of scale so any edges not found are
// still included
for (label i = 0; i < nSmooth; i++)
{
triSurfacePointScalarField oldScale(scale);
oldScale.rename("oldScale");
minSmooth
(
s,
PackedBoolList(s.nPoints(), true),
oldScale,
scale
);
}
// From scale update the pointDisplacement
pointDisplacement *= distance*scale/mag(pointDisplacement);
// Do some smoothing (Lloyds algorithm)
lloydsSmoothing(nSmooth, s, isFeaturePoint, edgeStat, isAffectedPoint);
// Update pointDisplacement
const pointField& pts = s.points();
forAll(meshPoints, i)
{
label meshPointI = meshPoints[i];
pointDisplacement[i] = pts[meshPointI]-initialPoints[meshPointI];
}
// Write
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
}
Info<< "Detected overall intersecting points " << isScaledPoint.count()
<< " out of " << s.nPoints() << nl << endl;
if (debug)
{
OBJstream str(runTime.path()/"isScaledPoint.obj");
forAll(isScaledPoint, pointI)
{
if (isScaledPoint[pointI])
{
str.write(initialPoints[meshPoints[pointI]]);
}
}
}
Info << "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -189,8 +189,6 @@ int main(int argc, char *argv[])
<< endl;
}
pointField newPoints(surf1.localPoints());
for (label iter = 0; iter < iters; iter++)
{
// Lambda

View File

@ -0,0 +1,7 @@
searchableSurfaceModifier/searchableSurfaceModifier.C
searchableSurfaceModifier/autoPatch.C
searchableSurfaceModifier/cut.C
surfacePatch.C
EXE = $(FOAM_APPBIN)/surfacePatch

View File

@ -0,0 +1,10 @@
EXE_INC = \
-IsearchableSurfaceModifier \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-ltriSurface \
-lmeshTools

View File

@ -0,0 +1,155 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "autoPatch.H"
#include "addToRunTimeSelectionTable.H"
#include "surfaceFeatures.H"
#include "triSurfaceMesh.H"
#include "PatchTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace searchableSurfaceModifiers
{
defineTypeNameAndDebug(autoPatch, 0);
addToRunTimeSelectionTable
(
searchableSurfaceModifier,
autoPatch,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifiers::autoPatch::autoPatch
(
const searchableSurfaces& geometry,
const dictionary& dict
)
:
searchableSurfaceModifier(geometry, dict),
featureAngle_(readScalar(dict.lookup("featureAngle")))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifiers::autoPatch::~autoPatch()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::searchableSurfaceModifiers::autoPatch::modify
(
const labelList& regions,
searchableSurface& geom
) const
{
triSurface& surf = refCast<triSurfaceMesh>(geom);
surfaceFeatures set(surf, 180.0-featureAngle_);
Info<< nl
<< "Feature set:" << nl
<< " feature points : " << set.featurePoints().size() << nl
<< " feature edges : " << set.featureEdges().size() << nl
<< " of which" << nl
<< " region edges : " << set.nRegionEdges() << nl
<< " external edges : " << set.nExternalEdges() << nl
<< " internal edges : " << set.nInternalEdges() << nl
<< endl;
// Get per-edge status.
boolList borderEdge(surf.nEdges(), false);
forAll(set.featureEdges(), i)
{
borderEdge[set.featureEdges()[i]] = true;
}
bool changed = false;
forAll(regions, i)
{
label regionI = regions[i];
labelList subRegion(surf.size(), -1);
label nSub = 0;
forAll(surf, faceI)
{
if (surf[faceI].region() == regionI && subRegion[faceI] == -1)
{
PatchTools::markZone(surf, borderEdge, faceI, nSub, subRegion);
nSub++;
}
}
Info<< "For region " << surf.patches()[regionI].name()
<< " detected sub regions " << nSub << endl;
if (nSub > 1)
{
label nOldPatches = surf.patches().size();
for (label subI = 0; subI < nSub; subI++)
{
geometricSurfacePatch patch
(
surf.patches()[regionI].geometricType(),
surf.patches()[regionI].name() + Foam::name(subI),
surf.patches().size()
);
Info<< "For region " << surf.patches()[regionI].name()
<< " creating region " << patch.name() << endl;
surf.patches().append(patch);
}
forAll(subRegion, faceI)
{
if (subRegion[faceI] != -1)
{
surf[faceI].region() = nOldPatches + subRegion[faceI];
}
}
changed = true;
}
}
return changed;
}
// ************************************************************************* //

View File

@ -0,0 +1,104 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::searchableSurfaceModifier::autoPatch
Description
Patchify triangles based on a feature angle. Replacement of surfaceAutoPatch
SourceFiles
autoPatch.C
\*---------------------------------------------------------------------------*/
#ifndef autoPatch_H
#define autoPatch_H
#include "searchableSurfaceModifier.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace searchableSurfaceModifiers
{
/*---------------------------------------------------------------------------*\
Class autoPatch Declaration
\*---------------------------------------------------------------------------*/
class autoPatch
:
public searchableSurfaceModifier
{
// Private data
//- Feature angle
const scalar featureAngle_;
// Private Member Functions
public:
//- Runtime type information
TypeName("autoPatch");
// Constructors
//- Construct from dictionary
autoPatch(const searchableSurfaces&, const dictionary&);
//- Clone
autoPtr<searchableSurfaceModifier> clone() const
{
notImplemented("autoPtr<searchableSurfaceModifier> clone() const");
return autoPtr<searchableSurfaceModifier>(NULL);
}
//- Destructor
virtual ~autoPatch();
// Member Functions
//- Apply this selector
virtual bool modify(const labelList& regions, searchableSurface&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace searchableSurfaceModifiers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,390 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "cut.H"
#include "addToRunTimeSelectionTable.H"
#include "searchableSurfaces.H"
#include "triSurfaceMesh.H"
#include "searchableBox.H"
#include "searchableRotatedBox.H"
#include "surfaceIntersection.H"
#include "intersectedSurface.H"
#include "edgeIntersections.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace searchableSurfaceModifiers
{
defineTypeNameAndDebug(cut, 0);
addToRunTimeSelectionTable(searchableSurfaceModifier, cut, dictionary);
}
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::searchableSurfaceModifiers::cut::triangulate
(
const faceList& fcs,
pointField& pts,
triSurface& cutSurf
) const
{
label nTris = 0;
forAll(fcs, i)
{
nTris += fcs[i].size()-2;
}
DynamicList<labelledTri> tris(nTris);
forAll(fcs, i)
{
const face& f = fcs[i];
// Triangulate around vertex 0
for (label fp = 1; fp < f.size()-1; fp++)
{
tris.append(labelledTri(f[0], f[fp], f[f.fcIndex(fp)], i));
}
}
geometricSurfacePatchList patches(fcs.size());
forAll(patches, patchI)
{
patches[patchI] = geometricSurfacePatch
(
"",
"patch" + Foam::name(patchI),
patchI
);
}
cutSurf = triSurface(tris.xfer(), patches, pts.xfer());
}
Foam::triSurface& Foam::searchableSurfaceModifiers::cut::triangulate
(
const searchableSurface& cutter,
triSurface& cutSurf
) const
{
if (isA<searchableBox>(cutter))
{
const searchableBox& bb = refCast<const searchableBox>(cutter);
pointField pts(bb.points());
triangulate(treeBoundBox::faces, pts, cutSurf);
return cutSurf;
}
else if (isA<searchableRotatedBox>(cutter))
{
const searchableRotatedBox& bb =
refCast<const searchableRotatedBox>(cutter);
pointField pts(bb.points());
triangulate(treeBoundBox::faces, pts, cutSurf);
return cutSurf;
}
else if (isA<triSurfaceMesh>(cutter))
{
return const_cast<triSurfaceMesh&>
(
refCast<const triSurfaceMesh>(cutter)
);
}
else
{
FatalErrorIn
(
"searchableSurfaceModifiers::cut::triangulate\n"
"(\n"
" const searchableSurface&,\n"
" triSurface&\n"
")"
) << "Triangulation only supported for triSurfaceMesh, searchableBox"
<< ", not for surface " << cutter.name()
<< " of type " << cutter.type()
<< exit(FatalError);
return const_cast<triSurfaceMesh&>
(
refCast<const triSurfaceMesh>(cutter)
);
}
}
// Keep on shuffling surface points until no more degenerate intersections.
// Moves both surfaces and updates set of edge cuts.
bool Foam::searchableSurfaceModifiers::cut::intersectSurfaces
(
triSurface& surf1,
edgeIntersections& edgeCuts1,
triSurface& surf2,
edgeIntersections& edgeCuts2
) const
{
bool hasMoved1 = false;
bool hasMoved2 = false;
for (label iter = 0; iter < 10; iter++)
{
Info<< "Determining intersections of surf1 edges with surf2"
<< " faces" << endl;
// Determine surface1 edge intersections. Allow surface to be moved.
// Number of iterations needed to resolve degenerates
label nIters1 = 0;
{
triSurfaceSearch querySurf2(surf2);
scalarField surf1PointTol
(
1E-6*edgeIntersections::minEdgeLength(surf1)
);
// Determine raw intersections
edgeCuts1 = edgeIntersections
(
surf1,
querySurf2,
surf1PointTol
);
// Shuffle a bit to resolve degenerate edge-face hits
{
pointField points1(surf1.points());
nIters1 =
edgeCuts1.removeDegenerates
(
5, // max iterations
surf1,
querySurf2,
surf1PointTol,
points1 // work array
);
if (nIters1 != 0)
{
// Update geometric quantities
surf1.movePoints(points1);
hasMoved1 = true;
}
}
}
Info<< "Determining intersections of surf2 edges with surf1"
<< " faces" << endl;
label nIters2 = 0;
{
triSurfaceSearch querySurf1(surf1);
scalarField surf2PointTol
(
1E-6*edgeIntersections::minEdgeLength(surf2)
);
// Determine raw intersections
edgeCuts2 = edgeIntersections
(
surf2,
querySurf1,
surf2PointTol
);
// Shuffle a bit to resolve degenerate edge-face hits
{
pointField points2(surf2.points());
nIters2 =
edgeCuts2.removeDegenerates
(
5, // max iterations
surf2,
querySurf1,
surf2PointTol,
points2 // work array
);
if (nIters2 != 0)
{
// Update geometric quantities
surf2.movePoints(points2);
hasMoved2 = true;
}
}
}
if (nIters1 == 0 && nIters2 == 0)
{
//Info<< "** Resolved all intersections to be proper"
// << "edge-face pierce" << endl;
break;
}
}
//if (hasMoved1)
//{
// fileName newFile("surf1.ftr");
// Info<< "Surface 1 has been moved. Writing to " << newFile
// << endl;
// surf1.write(newFile);
//}
//
//if (hasMoved2)
//{
// fileName newFile("surf2.ftr");
// Info<< "Surface 2 has been moved. Writing to " << newFile
// << endl;
// surf2.write(newFile);
//}
return hasMoved1 || hasMoved2;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifiers::cut::cut
(
const searchableSurfaces& geometry,
const dictionary& dict
)
:
searchableSurfaceModifier(geometry, dict),
cutterNames_(dict_.lookup("cutters"))
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifiers::cut::~cut()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::searchableSurfaceModifiers::cut::modify
(
const labelList& regions,
searchableSurface& geom
) const
{
triSurface& surf = refCast<triSurfaceMesh>(geom);
bool changed = false;
// Find the surfaces to cut with
forAll(cutterNames_, cutNameI)
{
labelList geomIDs =
findStrings(cutterNames_[cutNameI], geometry_.names());
forAll(geomIDs, j)
{
label geomI = geomIDs[j];
const searchableSurface& cutter = geometry_[geomI];
// Triangulate
triSurface work;
triSurface& cutSurf = triangulate(cutter, work);
// Determine intersection (with perturbation)
edgeIntersections edge1Cuts;
edgeIntersections edge2Cuts;
intersectSurfaces
(
surf,
edge1Cuts,
cutSurf,
edge2Cuts
);
// Determine intersection edges
surfaceIntersection inter(surf, edge1Cuts, cutSurf, edge2Cuts);
// Use intersection edges to cut up faces. (does all the hard work)
intersectedSurface surf3(surf, true, inter);
// Mark triangles based on whether they are inside or outside
List<volumeType> volTypes;
cutter.getVolumeType(surf3.faceCentres(), volTypes);
label nInside = 0;
forAll(volTypes, i)
{
if (volTypes[i] == volumeType::INSIDE)
{
nInside++;
}
}
// Add a patch for inside the box
if (nInside > 0 && surf3.patches().size() > 0)
{
geometricSurfacePatchList newPatches(surf3.patches());
label sz = newPatches.size();
newPatches.setSize(sz+1);
newPatches[sz] = geometricSurfacePatch
(
newPatches[sz-1].geometricType(),
newPatches[sz-1].name() + "_inside",
newPatches[sz-1].index()
);
Info<< "Moving " << nInside << " out of " << surf3.size()
<< " triangles to region "
<< newPatches[sz].name() << endl;
List<labelledTri> newTris(surf3);
forAll(volTypes, i)
{
if (volTypes[i] == volumeType::INSIDE)
{
newTris[i].region() = sz;
}
}
pointField newPoints(surf3.points());
surf = triSurface(newTris.xfer(), newPatches, newPoints.xfer());
changed = true;
}
}
}
return changed;
}
// ************************************************************************* //

View File

@ -0,0 +1,128 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::searchableSurfaceModifier::cut
Description
Patchify triangles based on orientation w.r.t other (triangulated or
triangulatable) surfaces
SourceFiles
cut.C
\*---------------------------------------------------------------------------*/
#ifndef cut_H
#define cut_H
#include "searchableSurfaceModifier.H"
#include "wordReList.H"
#include "faceList.H"
#include "pointField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class edgeIntersections;
namespace searchableSurfaceModifiers
{
/*---------------------------------------------------------------------------*\
Class cut Declaration
\*---------------------------------------------------------------------------*/
class cut
:
public searchableSurfaceModifier
{
// Private data
//- Name of surfaces to cut with
const wordReList cutterNames_;
// Private Member Functions
//- Triangulate faces around 0th vertex
void triangulate(const faceList&, pointField&, triSurface&) const;
//- Triangulate searchableSurface (currently only supported for
// searchableBox and triSurfaceMesh)
triSurface& triangulate(const searchableSurface&, triSurface&) const;
//- Intersect surfaces. Perturb to avoid degenerates.
bool intersectSurfaces
(
triSurface& surf1,
edgeIntersections& edgeCuts1,
triSurface& surf2,
edgeIntersections& edgeCuts2
) const;
public:
//- Runtime type information
TypeName("cut");
// Constructors
//- Construct from dictionary
cut(const searchableSurfaces&, const dictionary&);
//- Clone
autoPtr<searchableSurfaceModifier> clone() const
{
notImplemented("autoPtr<searchableSurfaceModifier> clone() const");
return autoPtr<searchableSurfaceModifier>(NULL);
}
//- Destructor
virtual ~cut();
// Member Functions
//- Apply this selector
virtual bool modify(const labelList& regions, searchableSurface&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace searchableSurfaceModifiers
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "searchableSurfaceModifier.H"
#include "triSurface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(searchableSurfaceModifier, 0);
defineRunTimeSelectionTable(searchableSurfaceModifier, dictionary);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifier::searchableSurfaceModifier
(
const searchableSurfaces& geometry,
const dictionary& dict
)
:
geometry_(geometry),
dict_(dict)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::searchableSurfaceModifier::~searchableSurfaceModifier()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::autoPtr<Foam::searchableSurfaceModifier>
Foam::searchableSurfaceModifier::New
(
const word& type,
const searchableSurfaces& geometry,
const dictionary& dict
)
{
dictionaryConstructorTable::iterator cstrIter =
dictionaryConstructorTablePtr_->find(type);
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"searchableSurfaceModifier::New"
"(const word&, const searchableSurfaces&, const dictionary&)"
) << "Unknown searchableSurfaceModifier type "
<< type << nl << nl
<< "Valid searchableSurfaceModifier types : " << endl
<< dictionaryConstructorTablePtr_->sortedToc()
<< exit(FatalError);
}
return autoPtr<searchableSurfaceModifier>(cstrIter()(geometry, dict));
}
// ************************************************************************* //

View File

@ -0,0 +1,134 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::searchableSurfaceModifier
Description
Changing a surface
SourceFiles
searchableSurfaceModifier.C
\*---------------------------------------------------------------------------*/
#ifndef searchableSurfaceModifier_H
#define searchableSurfaceModifier_H
#include "dictionary.H"
#include "typeInfo.H"
#include "runTimeSelectionTables.H"
#include "autoPtr.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class triSurface;
class searchableSurface;
class searchableSurfaces;
/*---------------------------------------------------------------------------*\
Class searchableSurfaceModifier Declaration
\*---------------------------------------------------------------------------*/
class searchableSurfaceModifier
{
protected:
// Protected data
const searchableSurfaces& geometry_;
//- Input dictionary
const dictionary dict_;
public:
//- Runtime type information
TypeName("searchableSurfaceModifier");
// Declare run-time constructor selection table
declareRunTimeSelectionTable
(
autoPtr,
searchableSurfaceModifier,
dictionary,
(
const searchableSurfaces& geometry,
const dictionary& dict
),
(geometry, dict)
);
// Constructors
//- Construct from dictionary
searchableSurfaceModifier(const searchableSurfaces&, const dictionary&);
//- Clone
autoPtr<searchableSurfaceModifier> clone() const
{
notImplemented("autoPtr<searchableSurfaceModifier> clone() const");
return autoPtr<searchableSurfaceModifier>(NULL);
}
// Selectors
//- Return a reference to the selected searchableSurfaceModifier
static autoPtr<searchableSurfaceModifier> New
(
const word& type,
const searchableSurfaces&,
const dictionary& dict
);
//- Destructor
virtual ~searchableSurfaceModifier();
// Member Functions
//- Do any operation on surface. Return true if anything changed
virtual bool modify(const labelList&, searchableSurface&) const = 0;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,169 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
surfacePatch
Description
Patches (regionises) a surface using a user-selectable method.
The current methods are either based on a geometric feature angle
(a replacement for the surfaceAutoPatch functionality) or on intersecting
a set of searchableSurfaces - this will re-triangulate the intersecting
triangles and regonise the resulting triangles according to being
inside/outside the surface.
\*---------------------------------------------------------------------------*/
#include "triSurface.H"
#include "argList.H"
#include "Time.H"
#include "triSurfaceMesh.H"
#include "searchableSurfaces.H"
#include "searchableSurfaceModifier.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::validArgs.clear();
argList::noParallel();
#include "addDictOption.H"
#include "setRootCase.H"
#include "createTime.H"
const word dictName("surfacePatchDict");
#include "setSystemRunTimeDictionaryIO.H"
const IOdictionary meshDict(dictIO);
// Read geometry
// ~~~~~~~~~~~~~
searchableSurfaces allGeometry
(
IOobject
(
"abc", // dummy name
runTime.constant(), // instance
triSurfaceMesh::meshSubDir, // local
runTime, // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
),
meshDict.subDict("geometry"),
meshDict.lookupOrDefault("singleRegionName", true)
);
const dictionary& surfacesDict = meshDict.subDict("surfaces");
forAllConstIter(dictionary, surfacesDict, surfacesIter)
{
if (surfacesIter().isDict())
{
const word& surfName = surfacesIter().keyword();
const dictionary& surfDict = surfacesIter().dict();
// Look up surface
searchableSurface& surf = allGeometry[surfName];
bool changed = false;
// Check for modifier on global level
if (surfDict.found("type"))
{
autoPtr<searchableSurfaceModifier> modifier
(
searchableSurfaceModifier::New
(
surfDict.lookup("type"),
allGeometry,
surfDict
)
);
if (modifier().modify(identity(surf.regions().size()), surf))
{
changed = true;
}
}
// Check for modifier on a per-region level
if (surfDict.found("regions"))
{
const dictionary& regionsDict = surfDict.subDict("regions");
forAllConstIter(dictionary, regionsDict, regionsIter)
{
const dictionary& regionDict = regionsIter().dict();
const keyType& regionName = regionsIter().keyword();
autoPtr<searchableSurfaceModifier> modifier
(
searchableSurfaceModifier::New
(
regionDict.lookup("type"),
allGeometry,
regionDict
)
);
labelList regionIDs =
findStrings(regionName, surf.regions());
if (modifier().modify(regionIDs, surf))
{
changed = true;
}
}
}
if (changed)
{
const fileName name(surf.name());
surf.rename(name.lessExt() + "_patched." + name.ext());
Info<< "Writing repatched surface " << name << " to "
<< surf.name() << nl << endl;
surf.write();
}
else
{
Info<< "Surface " << surf.name() << " unchanged" << nl << endl;
}
}
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,69 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
geometry
{
box
{
type searchableRotatedBox;
// box rotated 45 degrees around z axis
span (1 1 1);
origin (0 0 0);
e1 (1 1 0);
e3 (0 0 1);
}
singleTri.obj
{
type triSurfaceMesh;
}
unitCube_me.stl
{
type triSurfaceMesh;
}
};
surfaces
{
unitCube_me.stl
{
regions
{
// Divide region 'maxZ' into multiple regions according to
// a geometric feature angle
maxZ
{
type autoPatch;
featureAngle 60;
}
}
}
singleTri.obj
{
// Regionise surface according to triangles (after cutting) being
// inside or outside the 'box' geometry
type cut;
cutters (box);
}
}
// ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,21 +31,17 @@ Description
Note
- best decomposition option is hierarchGeomDecomp since
guarantees square decompositions.
guarantees square decompositions.
- triangles might be present on multiple processors.
- merging uses geometric tolerance so take care with writing precision.
\*---------------------------------------------------------------------------*/
#include "treeBoundBox.H"
#include "FixedList.H"
#include "argList.H"
#include "Time.H"
#include "polyMesh.H"
#include "distributedTriSurfaceMesh.H"
#include "mapDistribute.H"
#include "triSurfaceFields.H"
#include "Pair.H"
using namespace Foam;
@ -172,7 +168,7 @@ int main(int argc, char *argv[])
"triSurface", // local
runTime, // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
);
const fileName actualPath(io.filePath());
@ -215,6 +211,7 @@ int main(int argc, char *argv[])
Info<< "Writing dummy bounds dictionary to " << ioDict.name()
<< nl << endl;
// Force writing in ascii
ioDict.regIOobject::writeObject
(
IOstream::ASCII,
@ -239,23 +236,18 @@ int main(int argc, char *argv[])
(
IOobject
(
surfMesh.searchableSurface::name(), // name
surfMesh.searchableSurface::instance(), // instance
"faceCentres", // name
surfMesh.searchableSurface::time().timeName(), // instance
surfMesh.searchableSurface::local(), // local
surfMesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
surfMesh,
dimLength
dimLength,
s.faceCentres()
)
);
triSurfaceVectorField& fc = fcPtr();
forAll(fc, triI)
{
fc[triI] = s[triI].centre(s.points());
}
// Steal pointer and store object on surfMesh
fcPtr.ptr()->store();
@ -290,7 +282,7 @@ int main(int argc, char *argv[])
Info<< "Writing surface." << nl << endl;
surfMesh.searchableSurface::write();
surfMesh.objectRegistry::write();
Info<< "End\n" << endl;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -387,6 +387,8 @@ int main(int argc, char *argv[])
surf2.write(outFileName);
Info<< "\nEnd\n" << endl;
return 0;
}

View File

@ -3,7 +3,7 @@
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
# \\/ M anipulation |
# \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -52,7 +52,10 @@ cleanTimeDirectories()
rm -rf ./${timeDir} ./-${timeDir} > /dev/null 2>&1
zeros="0$zeros"
done
rm -rf ./[1-9]* ./-[1-9]* ./log ./log.* ./log-* ./logSummary.* ./.fxLock ./*.xml ./ParaView* ./paraFoam* ./*.OpenFOAM ./*.blockMesh ./.setSet > /dev/null 2>&1
rm -rf \
./[1-9]* ./-[1-9]* ./log ./log.* ./log-* ./logSummary.* \
./.fxLock ./*.xml ./ParaView* ./paraFoam* ./*.OpenFOAM ./*.blockMesh \
./.setSet > /dev/null 2>&1
}
@ -68,6 +71,33 @@ cleanDynamicCode()
}
cleanSnappyFiles()
{
rm -f \
constant/polyMesh/cellLevel \
constant/polyMesh/pointLevel \
constant/polyMesh/refinementHistory \
constant/polyMesh/level0Edge \
constant/polyMesh/surfaceIndex > /dev/null 2>&1
rm -f \
processor*/constant/polyMesh/cellLevel \
processor*/constant/polyMesh/pointLevel \
processor*/constant/polyMesh/refinementHistory \
processor*/constant/polyMesh/level0Edge \
processor*/constant/polyMesh/surfaceIndex > /dev/null 2>&1
rm -f \
constant/cellLevel \
constant/pointLevel \
0/cellLevel \
0/pointLevel > /dev/null 2>&1
rm -f \
processor*/constant/cellLevel \
processor*/constant/pointLevel \
processor*/0/cellLevel \
processor*/0/pointLevel > /dev/null 2>&1
}
cleanCase()
{
cleanTimeDirectories
@ -83,26 +113,25 @@ cleanCase()
rm -rf cuttingPlane > /dev/null 2>&1
rm -rf system/machines > /dev/null 2>&1
# From mpirunDebug
rm -f gdbCommands mpirun.schema
cleanSnappyFiles
if [ -d constant/polyMesh ]
then
(cd constant/polyMesh && \
rm -rf \
allOwner* cell* face* meshModifiers* \
owner* neighbour* point* edge* \
cellLevel* pointLevel* refinementHistory* level0Edge* surfaceIndex* sets \
owner* neighbour* point* edge* sets \
> /dev/null 2>&1 \
)
fi
(cd constant && \
rm -rf \
cellToRegion cellLevel* pointLevel* \
> /dev/null 2>&1 \
)
(cd constant && rm -rf cellToRegion > /dev/null 2>&1)
rm -rf constant/tetDualMesh > /dev/null 2>&1
rm -rf VTK > /dev/null 2>&1
rm -f 0/cellLevel 0/pointLevel 0/cellDist constant/cellDecomposition
rm -f 0/cellDist constant/cellDecomposition
if [ -e constant/polyMesh/blockMeshDict.m4 ]
then

View File

@ -15,12 +15,18 @@
#
#------------------------------------------------------------------------------
#- Lines to ignore
Ignore/Solving for .* region /
#- String to recognize new iteration by (usually same as 'Time')
Separator/^[ \t]*Time = /Time =
#- Time value:
Time/^[ \t]*Time = /Time =
#- DeltaT value:
deltaT/^[ \t]*deltaT = /deltaT =
#- Continuity errors:
contLocal/time step continuity errors :/sum local =
contGlobal/time step continuity errors :/ global =
@ -33,6 +39,10 @@ minFt/min\(ft\) = /min(ft) =
#- Execution time:
executionTime/ExecutionTime = /ExecutionTime =
#- Interface Courant no:
IntCourantMax/Interface Courant Number /max:
IntCourantMean/Interface Courant Number /mean:
#- Courant no:
CourantMax/Courant Number /max:
CourantMean/Courant Number /mean:
@ -48,8 +58,8 @@ epsMax/bounding epsilon,/max:
epsAvg/bounding epsilon,/average:
#- gamma bounding
alpha1Min/Min\(alpha1\) =/Min(alpha1) =
alpha1Max/Max\(alpha1\) =/Max(alpha1) =
alpha1Min/Min\(alpha1\) =/Min(alpha1) =
alpha1Max/Max\(alpha1\) =/Max(alpha1) =
# AMI
AMIMin/AMI: Patch source sum/average =

View File

@ -22,7 +22,7 @@ BirdCarreauCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
m [0 0 1 0 0 0 0] 1;
k [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}

View File

@ -22,7 +22,7 @@ BirdCarreauCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
m [0 0 1 0 0 0 0] 1;
k [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}

View File

@ -22,7 +22,7 @@ BirdCarreauCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
m [0 0 1 0 0 0 0] 1;
k [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}

View File

@ -22,7 +22,7 @@ BirdCarreauCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
m [0 0 1 0 0 0 0] 1;
k [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}

View File

@ -59,6 +59,8 @@ parallel/Allwmake $targetType $*
wmake $targetType ODE
wmake $targetType randomProcesses
wmake $targetType fvMotionSolver
transportModels/Allwmake $targetType $*
thermophysicalModels/Allwmake $targetType $*
TurbulenceModels/Allwmake $targetType $*
@ -69,7 +71,6 @@ mesh/Allwmake $targetType $*
renumber/Allwmake $targetType $*
fvAgglomerationMethods/Allwmake $targetType $*
wmake $targetType fvMotionSolver
wmake $targetType engine
wmake $targetType fvOptions
wmake $targetType regionCoupled
@ -78,5 +79,7 @@ postProcessing/Allwmake $targetType $*
wmake $targetType sixDoFRigidBodyMotion
# Needs access to Turbulence
wmake $targetType thermophysicalModels/properties/liquidPropertiesFvPatchFields
# ----------------------------------------------------------------- end-of-file

View File

@ -91,6 +91,9 @@ $(strings)/wordRe/wordRe.C
$(strings)/lists/hashedWordList.C
$(strings)/stringOps/stringOps.C
ops = primitives/ops
$(ops)/flipOp.C
primitives/hashes/Hasher/Hasher.C
sha1 = primitives/hashes/SHA1
@ -209,6 +212,7 @@ $(dll)/codedBase/codedBase.C
db/functionObjects/functionObject/functionObject.C
db/functionObjects/functionObjectList/functionObjectList.C
db/functionObjects/functionObjectFile/functionObjectFile.C
db/functionObjects/functionObjectState/functionObjectState.C
db/functionObjects/outputFilterOutputControl/outputFilterOutputControl.C
@ -504,6 +508,7 @@ $(mapPolyMesh)/mapPolyMesh.C
$(mapPolyMesh)/faceMapper/faceMapper.C
$(mapPolyMesh)/cellMapper/cellMapper.C
$(mapPolyMesh)/mapDistribute/mapDistribute.C
$(mapPolyMesh)/mapDistribute/mapDistributeBase.C
$(mapPolyMesh)/mapDistribute/mapDistributePolyMesh.C
$(mapPolyMesh)/mapDistribute/IOmapDistribute.C
$(mapPolyMesh)/mapAddedPolyMesh.C
@ -617,6 +622,8 @@ $(derivedPointPatchFields)/codedFixedValue/codedFixedValuePointPatchFields.C
fields/GeometricFields/pointFields/pointFields.C
fields/ReadFields/ReadFields.C
meshes/bandCompression/bandCompression.C
meshes/preservePatchTypes/preservePatchTypes.C

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -95,6 +95,12 @@ public:
t_(t)
{}
//- Construct from integer
explicit volumeType(const int t)
:
t_(static_cast<volumeType::type>(t))
{}
// Member Functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -226,7 +226,7 @@ label findLower
(
const ListType&,
typename ListType::const_reference,
const label stary,
const label start,
const BinaryOp& bop
);
@ -263,6 +263,15 @@ public:
};
//- Helper class for list to append unique elelements of y onto the end of x
template<class T>
class ListUniqueEqOp
{
public:
void operator()(List<T>& x, const List<T>& y) const;
};
//- Reverse a list. First element becomes last element etc.
template<class ListType>
ListType reverseList(const ListType& list);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -742,6 +742,29 @@ void Foam::ListAppendEqOp<T>::operator()(List<T>& x, const List<T>& y) const
}
template<class T>
void Foam::ListUniqueEqOp<T>::operator()(List<T>& x, const List<T>& y) const
{
if (y.size())
{
if (x.size())
{
forAll(y, i)
{
if (findIndex(x, y[i]) == -1)
{
x.append(y[i]);
}
}
}
else
{
x = y;
}
}
}
template<class ListType>
ListType Foam::reverseList(const ListType& list)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -101,7 +101,7 @@ inline void Foam::UList<T>::checkIndex(const label i) const
if (!size_)
{
FatalErrorIn("UList<T>::checkIndex(const label)")
<< "attempt to access element from zero sized list"
<< "attempt to access element " << i << " from zero sized list"
<< abort(FatalError);
}
else if (i<0 || i>=size_)

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -43,6 +43,30 @@ Foam::UPtrList<T>::UPtrList(const label s)
{}
template<class T>
Foam::UPtrList<T>::UPtrList(UList<T>& lst)
:
ptrs_(lst.size())
{
forAll(lst, i)
{
ptrs_[i] = &lst[i];
}
}
template<class T>
Foam::UPtrList<T>::UPtrList(PtrList<T>& lst)
:
ptrs_(lst.size())
{
forAll(lst, i)
{
ptrs_[i] = &lst[i];
}
}
template<class T>
Foam::UPtrList<T>::UPtrList(const Xfer<UPtrList<T> >& lst)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,6 +42,7 @@ SourceFiles
#define UPtrList_H
#include "List.H"
#include "PtrList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -109,6 +110,12 @@ public:
//- Construct with size specified.
explicit UPtrList(const label);
//- Construct from UList
explicit UPtrList(UList<T>&);
//- Construct from PtrList
explicit UPtrList(PtrList<T>&);
//- Construct by transferring the parameter contents
UPtrList(const Xfer<UPtrList<T> >&);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -234,6 +234,25 @@ Foam::IOobject::IOobject
}
Foam::IOobject::IOobject
(
const IOobject& io,
const word& name
)
:
name_(name),
headerClassName_(io.headerClassName_),
note_(io.note_),
instance_(io.instance_),
local_(io.local_),
db_(io.db_),
rOpt_(io.rOpt_),
wOpt_(io.wOpt_),
registerObject_(io.registerObject_),
objState_(io.objState_)
{}
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * //
Foam::IOobject::~IOobject()

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -236,6 +236,13 @@ public:
bool registerObject=true
);
//- Construct as copy resetting name
IOobject
(
const IOobject& io,
const word& name
);
//- Clone
Foam::autoPtr<IOobject> clone() const
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -58,6 +58,23 @@ void Foam::CompactIOList<T, BaseType>::readFromStream()
}
template<class T, class BaseType>
bool Foam::CompactIOList<T, BaseType>::overflows() const
{
label size = 0;
forAll(*this, i)
{
label oldSize = size;
size += this->operator[](i).size();
if (size < oldSize)
{
return true;
}
}
return false;
}
// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
template<class T, class BaseType>
@ -178,6 +195,29 @@ bool Foam::CompactIOList<T, BaseType>::writeObject
return good;
}
else if (overflows())
{
WarningIn
(
"CompactIOList<T, BaseType>::writeObject"
"(IOstream::streamFormat, IOstream::versionNumber"
", IOstream::compressionType) const"
) << "Overall number of elements of CompactIOList of size "
<< this->size() << " overflows the representation of a label"
<< endl << " Switching to ascii writing" << endl;
// Change type to be non-compact format type
const word oldTypeName = typeName;
const_cast<word&>(typeName) = IOList<T>::typeName;
bool good = regIOobject::writeObject(IOstream::ASCII, ver, cmp);
// Change type back
const_cast<word&>(typeName) = oldTypeName;
return good;
}
else
{
return regIOobject::writeObject(fmt, ver, cmp);
@ -264,7 +304,22 @@ Foam::Ostream& Foam::operator<<
start[0] = 0;
for (label i = 1; i < start.size(); i++)
{
start[i] = start[i-1]+L[i-1].size();
label prev = start[i-1];
start[i] = prev+L[i-1].size();
if (start[i] < prev)
{
FatalIOErrorIn
(
"operator<<"
"(Ostream& os, const CompactIOList<T, BaseType>&)",
os
) << "Overall number of elements " << start[i]
<< " of CompactIOList of size "
<< L.size() << " overflows the representation of a label"
<< endl << "Please recompile with a larger representation"
<< " for label" << exit(FatalIOError);
}
}
List<BaseType> elems(start[start.size()-1]);

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -79,6 +79,9 @@ class CompactIOList
//- Read according to header type
void readFromStream();
//- Has too many elements in it?
bool overflows() const;
public:
//- Runtime type information

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -57,22 +57,41 @@ const Foam::NamedEnum<Foam::UPstream::commsTypes, 3>
void Foam::UPstream::setParRun(const label nProcs)
{
parRun_ = true;
// Redo worldComm communicator (this has been created at static
// initialisation time)
freeCommunicator(UPstream::worldComm);
label comm = allocateCommunicator(-1, identity(nProcs), true);
if (comm != UPstream::worldComm)
if (nProcs == 0)
{
FatalErrorIn("UPstream::setParRun(const label)")
<< "problem : comm:" << comm
<< " UPstream::worldComm:" << UPstream::worldComm
<< Foam::exit(FatalError);
}
parRun_ = false;
freeCommunicator(UPstream::worldComm);
label comm = allocateCommunicator(-1, labelList(1, label(0)), false);
if (comm != UPstream::worldComm)
{
FatalErrorIn("UPstream::setParRun(const label)")
<< "problem : comm:" << comm
<< " UPstream::worldComm:" << UPstream::worldComm
<< Foam::exit(FatalError);
}
Pout.prefix() = '[' + name(myProcNo(Pstream::worldComm)) + "] ";
Perr.prefix() = '[' + name(myProcNo(Pstream::worldComm)) + "] ";
Pout.prefix() = "";
Perr.prefix() = "";
}
else
{
parRun_ = true;
// Redo worldComm communicator (this has been created at static
// initialisation time)
freeCommunicator(UPstream::worldComm);
label comm = allocateCommunicator(-1, identity(nProcs), true);
if (comm != UPstream::worldComm)
{
FatalErrorIn("UPstream::setParRun(const label)")
<< "problem : comm:" << comm
<< " UPstream::worldComm:" << UPstream::worldComm
<< Foam::exit(FatalError);
}
Pout.prefix() = '[' + name(myProcNo(Pstream::worldComm)) + "] ";
Perr.prefix() = '[' + name(myProcNo(Pstream::worldComm)) + "] ";
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -197,9 +197,6 @@ private:
// Private Member Functions
//- Set data for parallel running
static void setParRun(const label nProcs);
//- Calculate linear communication schedule
static List<commsStruct> calcLinearComm(const label nProcs);
@ -383,6 +380,10 @@ public:
return parRun_;
}
//- Set data for parallel running. Special case nProcs=0 to switch off
// parallel running
static void setParRun(const label nProcs);
//- Number of processes in parallel run
static label nProcs(const label communicator = 0)
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,7 +55,7 @@ void Pstream::combineGather
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -182,7 +182,7 @@ void Pstream::combineScatter
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -287,7 +287,7 @@ void Pstream::listCombineGather
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -421,7 +421,7 @@ void Pstream::listCombineScatter
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -540,7 +540,7 @@ void Pstream::mapCombineGather
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -640,7 +640,7 @@ void Pstream::mapCombineScatter
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const UPstream::commsStruct& myComm = comms[UPstream::myProcNo(comm)];

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -75,14 +75,15 @@ void Foam::Pstream::exchange
// Send sizes across. Note: blocks.
combineReduce(sizes, UPstream::listEq(), tag, comm);
if (UPstream::nProcs(comm) > 1)
recvBufs.setSize(sendBufs.size());
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
label startOfRequests = Pstream::nRequests();
// Set up receives
// ~~~~~~~~~~~~~~~
recvBufs.setSize(sendBufs.size());
forAll(sizes, procI)
{
label nRecv = sizes[procI][UPstream::myProcNo(comm)];

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -52,7 +52,7 @@ void Pstream::gather
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];
@ -151,7 +151,7 @@ void Pstream::scatter
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
// Get my communication order
const commsStruct& myComm = comms[UPstream::myProcNo(comm)];

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,7 +53,7 @@ void Pstream::gatherList
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
if (Values.size() != UPstream::nProcs(comm))
{
@ -212,7 +212,7 @@ void Pstream::scatterList
const label comm
)
{
if (UPstream::nProcs(comm) > 1)
if (UPstream::parRun() && UPstream::nProcs(comm) > 1)
{
if (Values.size() != UPstream::nProcs(comm))
{

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -59,7 +59,7 @@ inline Foam::ISstream& Foam::ISstream::get(char& c)
is_.get(c);
setState(is_.rdstate());
if (c == '\n')
if (good() && c == '\n')
{
lineNumber_++;
}

View File

@ -2,8 +2,8 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -54,7 +54,7 @@ class TimePaths
bool processorCase_;
const fileName rootPath_;
fileName globalCaseName_;
const fileName case_;
fileName case_;
const word system_;
const word constant_;
@ -111,6 +111,12 @@ public:
return case_;
}
//- Return case name
fileName& caseName()
{
return case_;
}
//- Return system name
const word& system() const
{

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -221,9 +221,7 @@ Foam::autoPtr<Foam::dictionary> Foam::dictionary::clone() const
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::dictionary::~dictionary()
{
// cerr<< "~dictionary() " << name() << " " << long(this) << std::endl;
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -238,7 +236,7 @@ const Foam::dictionary& Foam::dictionary::topDict() const
}
else
{
return p;
return *this;
}
}

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -200,7 +200,7 @@ public:
dictionary();
//- Construct top-level empty dictionary with given name
dictionary(const fileName& name);
explicit dictionary(const fileName& name);
//- Construct given the entry name, parent dictionary and Istream,
// reading entries until lastEntry or EOF

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -39,6 +39,7 @@ Foam::label Foam::functionObjectFile::addChars = 7;
void Foam::functionObjectFile::initStream(Ostream& os) const
{
os.setf(ios_base::scientific, ios_base::floatfield);
os.precision(writePrecision_);
os.width(charWidth());
}
@ -78,78 +79,44 @@ Foam::fileName Foam::functionObjectFile::baseTimeDir() const
}
void Foam::functionObjectFile::createFiles()
Foam::autoPtr<Foam::OFstream> Foam::functionObjectFile::createFile
(
const word& name
) const
{
if (Pstream::master())
autoPtr<OFstream> osPtr;
if (Pstream::master() && writeToFile_)
{
const word startTimeName =
obr_.time().timeName(obr_.time().startTime().value());
forAll(names_, i)
fileName outputDir(baseFileDir()/prefix_/startTimeName);
mkDir(outputDir);
word fName(name);
// Check if file already exists
IFstream is(outputDir/(fName + ".dat"));
if (is.good())
{
if (!filePtrs_.set(i))
{
fileName outputDir(baseFileDir()/prefix_/startTimeName);
mkDir(outputDir);
word fName(names_[i]);
// Check if file already exists
IFstream is(outputDir/(fName + ".dat"));
if (is.good())
{
fName = fName + "_" + obr_.time().timeName();
}
filePtrs_.set(i, new OFstream(outputDir/(fName + ".dat")));
initStream(filePtrs_[i]);
writeFileHeader(i);
}
fName = fName + "_" + obr_.time().timeName();
}
osPtr.set(new OFstream(outputDir/(fName + ".dat")));
initStream(osPtr());
}
return osPtr;
}
void Foam::functionObjectFile::writeFileHeader(const label i)
{}
void Foam::functionObjectFile::write()
void Foam::functionObjectFile::resetFile(const word& fileName)
{
createFiles();
}
void Foam::functionObjectFile::resetNames(const wordList& names)
{
names_.clear();
names_.append(names);
if (Pstream::master())
{
filePtrs_.clear();
filePtrs_.setSize(names_.size());
createFiles();
}
}
void Foam::functionObjectFile::resetName(const word& name)
{
names_.clear();
names_.append(name);
if (Pstream::master())
{
filePtrs_.clear();
filePtrs_.setSize(1);
createFiles();
}
fileName_ = fileName;
filePtr_ = createFile(fileName_);
}
@ -169,8 +136,10 @@ Foam::functionObjectFile::functionObjectFile
:
obr_(obr),
prefix_(prefix),
names_(),
filePtrs_()
fileName_("undefined"),
filePtr_(),
writePrecision_(IOstream::defaultPrecision()),
writeToFile_(true)
{}
@ -178,46 +147,22 @@ Foam::functionObjectFile::functionObjectFile
(
const objectRegistry& obr,
const word& prefix,
const word& name
const word& fileName,
const dictionary& dict
)
:
obr_(obr),
prefix_(prefix),
names_(),
filePtrs_()
fileName_(fileName),
filePtr_(),
writePrecision_(IOstream::defaultPrecision()),
writeToFile_(true)
{
names_.clear();
names_.append(name);
if (Pstream::master())
read(dict);
if (writeToFile_)
{
filePtrs_.clear();
filePtrs_.setSize(1);
// Cannot create files - need to access virtual function
}
}
Foam::functionObjectFile::functionObjectFile
(
const objectRegistry& obr,
const word& prefix,
const wordList& names
)
:
obr_(obr),
prefix_(prefix),
names_(names),
filePtrs_()
{
names_.clear();
names_.append(names);
if (Pstream::master())
{
filePtrs_.clear();
filePtrs_.setSize(names_.size());
// Cannot create files - need to access virtual function
filePtr_ = createFile(fileName_);
}
}
@ -230,72 +175,38 @@ Foam::functionObjectFile::~functionObjectFile()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::wordList& Foam::functionObjectFile::names() const
void Foam::functionObjectFile::read(const dictionary& dict)
{
return names_;
writePrecision_ =
dict.lookupOrDefault("writePrecision", IOstream::defaultPrecision());
// Only write on master process
writeToFile_ = dict.lookupOrDefault("writeToFile", true);
writeToFile_ = writeToFile_ && Pstream::master();
}
Foam::OFstream& Foam::functionObjectFile::file()
{
if (!Pstream::master())
if (!writeToFile_)
{
return Snull;
}
if (!filePtr_.valid())
{
FatalErrorIn("Foam::OFstream& Foam::functionObjectFile::file()")
<< "Request for file() can only be done by the master process"
<< "File pointer not allocated"
<< abort(FatalError);
}
if (filePtrs_.size() != 1)
{
WarningIn("Foam::Ostream& Foam::functionObjectFile::file()")
<< "Requested single file, but multiple files are present"
<< endl;
}
if (!filePtrs_.set(0))
{
FatalErrorIn("Foam::OFstream& Foam::functionObjectFile::file()")
<< "File pointer at index " << 0 << " not allocated"
<< abort(FatalError);
}
return filePtrs_[0];
return filePtr_();
}
Foam::PtrList<Foam::OFstream>& Foam::functionObjectFile::files()
bool Foam::functionObjectFile::writeToFile() const
{
if (!Pstream::master())
{
FatalErrorIn("Foam::OFstream& Foam::functionObjectFile::files()")
<< "Request for files() can only be done by the master process"
<< abort(FatalError);
}
return filePtrs_;
}
Foam::OFstream& Foam::functionObjectFile::file(const label i)
{
if (!Pstream::master())
{
FatalErrorIn
(
"Foam::OFstream& Foam::functionObjectFile::file(const label)"
)
<< "Request for file(i) can only be done by the master process"
<< abort(FatalError);
}
if (!filePtrs_.set(i))
{
FatalErrorIn("Foam::OFstream& Foam::functionObjectFile::file()")
<< "File pointer at index " << i << " not allocated"
<< abort(FatalError);
}
return filePtrs_[i];
return writeToFile_;
}

Some files were not shown because too many files have changed in this diff Show More