From bd5fafddec00cfb0f67c217d4c446a65d1571f81 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 11 Jul 2012 15:35:53 +0100 Subject: [PATCH 01/28] ENH: targetVolumeToCell: new cellSetSource --- .../mesh/manipulation/topoSet/topoSetDict | 9 + src/meshTools/Make/files | 1 + .../targetVolumeToCell/targetVolumeToCell.C | 328 ++++++++++++++++++ .../targetVolumeToCell/targetVolumeToCell.H | 142 ++++++++ 4 files changed, 480 insertions(+) create mode 100644 src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C create mode 100644 src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.H diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 562c006ab1..be90a8fb80 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -171,6 +171,15 @@ FoamFile // insidePoint (1 2 3); // point inside region to select // } // +// // Cells underneath plane such that volume is reached. Can be used +// // in setFields. +// source targetVolumeToCell; +// sourceInfo +// { +// volume 2e-05; +// normal (1 1 1); +// } +// // // // faceSet diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 4abc57669e..2621adbc23 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -99,6 +99,7 @@ $(cellSources)/sphereToCell/sphereToCell.C $(cellSources)/cylinderToCell/cylinderToCell.C $(cellSources)/faceZoneToCell/faceZoneToCell.C $(cellSources)/cylinderAnnulusToCell/cylinderAnnulusToCell.C +$(cellSources)/targetVolumeToCell/targetVolumeToCell.C faceSources = sets/faceSources $(faceSources)/faceToFace/faceToFace.C diff --git a/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C new file mode 100644 index 0000000000..c64c29e1e6 --- /dev/null +++ b/src/meshTools/sets/cellSources/targetVolumeToCell/targetVolumeToCell.C @@ -0,0 +1,328 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 . + +\*---------------------------------------------------------------------------*/ + +#include "targetVolumeToCell.H" +#include "polyMesh.H" +#include "globalMeshData.H" +#include "plane.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(targetVolumeToCell, 0); + +addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, word); + +addToRunTimeSelectionTable(topoSetSource, targetVolumeToCell, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::targetVolumeToCell::usage_ +( + targetVolumeToCell::typeName, + "\n Usage: targetVolumeToCell (nx ny nz)\n\n" + " Adjust plane until obtained selected volume\n\n" +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::scalar Foam::targetVolumeToCell::volumeOfSet +( + const PackedBoolList& selected +) const +{ + scalar sumVol = 0.0; + forAll(selected, cellI) + { + if (selected[cellI]) + { + sumVol += mesh_.cellVolumes()[cellI]; + } + } + return returnReduce(sumVol, sumOp()); +} + + +Foam::label Foam::targetVolumeToCell::selectCells +( + const scalar normalComp, + PackedBoolList& selected +) const +{ + selected.setSize(mesh_.nCells()); + selected = false; + + label nSelected = 0; + + forAll(mesh_.cellCentres(), cellI) + { + const point& cc = mesh_.cellCentres()[cellI]; + + if ((cc&n_) < normalComp) + { + selected[cellI] = true; + nSelected++; + } + } + return returnReduce(nSelected, sumOp