mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://dm/home/dm4/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -12,7 +12,4 @@
|
||||
tmp<volScalarField> tkappa = thermo.kappa();
|
||||
const volScalarField& kappa = tkappa();
|
||||
|
||||
//tmp<volSymmTensorField> tkappa = thermo.directionalKappa();
|
||||
//const volSymmTensorField& kappa = tkappa();
|
||||
|
||||
volScalarField& h = thermo.he();
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -123,7 +123,7 @@ void starMesh::createCoupleMatches()
|
||||
cellRemovedFaces.insert
|
||||
(
|
||||
fp.masterCell(),
|
||||
fp.masterFace()
|
||||
SLList<label>(fp.masterFace())
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -1362,7 +1362,7 @@ void starMesh::createCoupleMatches()
|
||||
cellRemovedFaces.insert
|
||||
(
|
||||
fp.masterCell(),
|
||||
fp.masterFace()
|
||||
SLList<label>(fp.masterFace())
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -1378,7 +1378,7 @@ void starMesh::createCoupleMatches()
|
||||
cellRemovedFaces.insert
|
||||
(
|
||||
fp.slaveCell(),
|
||||
fp.slaveFace()
|
||||
SLList<label>(fp.slaveFace())
|
||||
);
|
||||
}
|
||||
else
|
||||
|
||||
@ -179,18 +179,19 @@ int main(int argc, char *argv[])
|
||||
// Read decomposePar dictionary
|
||||
dictionary decomposeDict;
|
||||
{
|
||||
IOobject io
|
||||
(
|
||||
"decomposeParDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
if (io.headerOk())
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
decomposeDict = IOdictionary(io);
|
||||
decomposeDict = IOdictionary
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"decomposeParDict",
|
||||
runTime.system(),
|
||||
mesh,
|
||||
IOobject::MUST_READ_IF_MODIFIED,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -95,11 +95,12 @@ FoamFile
|
||||
// type hex; // hex/wedge/prism/pyr/tet/tetWedge/splitHex
|
||||
// }
|
||||
//
|
||||
// // Cells with cell centre within box
|
||||
// // Cells with cell centre within box ('box') or multiple boxes ('boxes')
|
||||
// source boxToCell;
|
||||
// sourceInfo
|
||||
// {
|
||||
// box (0 0 0) (1 1 1);
|
||||
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
|
||||
// }
|
||||
//
|
||||
// // Cells with cell centre within box
|
||||
@ -170,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
|
||||
@ -223,11 +233,12 @@ FoamFile
|
||||
// name ".*Zone1"; // Name of faceZone, regular expressions allowed
|
||||
// }
|
||||
//
|
||||
// // Faces with face centre within box
|
||||
// // Faces with face centre within box ('box') or multiple boxes ('boxes')
|
||||
// source boxToFace;
|
||||
// sourceInfo
|
||||
// {
|
||||
// box (0 0 0) (1 1 1);
|
||||
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
|
||||
// }
|
||||
//
|
||||
// // Faces with normal to within certain angle aligned with vector.
|
||||
@ -295,11 +306,12 @@ FoamFile
|
||||
// points ((0 0 0) (1 1 1));
|
||||
// }
|
||||
//
|
||||
// // Points with coordinate within box
|
||||
// // Points with coordinate within box ('box') or multiple boxes ('boxes')
|
||||
// source boxToPoint;
|
||||
// sourceInfo
|
||||
// {
|
||||
// box (0 0 0) (1 1 1);
|
||||
// //boxes ((0 0 0) (1 1 1) (10 10 10)(11 11 11));
|
||||
// }
|
||||
//
|
||||
// // Select based on surface
|
||||
|
||||
@ -122,7 +122,8 @@ structuredCoeffs
|
||||
patches (bottomPatch);
|
||||
}
|
||||
|
||||
//// Is the case distributed
|
||||
//// Is the case distributed? Note: command-line argument -roots takes
|
||||
//// precedence
|
||||
//distributed yes;
|
||||
//// Per slave (so nProcs-1 entries) the directory above the case.
|
||||
//roots
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -59,13 +59,13 @@ public:
|
||||
{}
|
||||
|
||||
//- Construct given initial T
|
||||
SLList(T a)
|
||||
explicit SLList(T a)
|
||||
:
|
||||
LList<SLListBase, T>(a)
|
||||
{}
|
||||
|
||||
//- Construct from Istream
|
||||
SLList(Istream& is)
|
||||
explicit SLList(Istream& is)
|
||||
:
|
||||
LList<SLListBase, T>(is)
|
||||
{}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -85,7 +85,7 @@ public:
|
||||
gradScheme<Type>(mesh),
|
||||
minDet_(readScalar(schemeData))
|
||||
{
|
||||
if (minDet_ < 0 || minDet_ > 8)
|
||||
if (minDet_ < 0) //-for facearea weighted: || minDet_ > 8)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
@ -93,7 +93,7 @@ public:
|
||||
"(const fvMesh&, Istream& schemeData)",
|
||||
schemeData
|
||||
) << "Minimum determinant = " << minDet_
|
||||
<< " should be >= 0 and <= 8"
|
||||
<< " should be >= 0" // and <= 8"
|
||||
<< exit(FatalIOError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,7 +138,7 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
|
||||
else if (nDims == 2)
|
||||
{
|
||||
Info<< "extendedLeastSquares : detected " << nDims
|
||||
<< " valid directions. Missing direction " << twoD << nl << endl;
|
||||
<< " valid directions. Missing direction " << twoD << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -207,6 +207,7 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
|
||||
<< "min(detdd) = " << min(detdd) << nl
|
||||
<< "average(detdd) = " << average(detdd) << endl;
|
||||
|
||||
label nAdaptedCells = 0;
|
||||
label nAddCells = 0;
|
||||
label maxNaddCells = 4*detdd.size();
|
||||
additionalCellsPtr_ = new List<labelPair>(maxNaddCells);
|
||||
@ -216,6 +217,8 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
|
||||
{
|
||||
label count = 0;
|
||||
|
||||
label oldNAddCells = nAddCells;
|
||||
|
||||
while (++count < 100 && detdd[i] < minDet_)
|
||||
{
|
||||
if (nAddCells == maxNaddCells)
|
||||
@ -305,16 +308,24 @@ void Foam::extendedLeastSquaresVectors::makeLeastSquaresVectors() const
|
||||
detdd[i] = det(dd[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (oldNAddCells < nAddCells)
|
||||
{
|
||||
nAdaptedCells++;
|
||||
}
|
||||
}
|
||||
|
||||
additionalCells_.setSize(nAddCells);
|
||||
|
||||
reduce(nAddCells, sumOp<label>());
|
||||
reduce(nAdaptedCells, sumOp<label>());
|
||||
if (nAddCells)
|
||||
{
|
||||
Info<< "max(detdd) = " << max(detdd) << nl
|
||||
<< "min(detdd) = " << min(detdd) << nl
|
||||
<< "average(detdd) = " << average(detdd) << nl
|
||||
<< "nAdapted/nCells = "
|
||||
<< scalar(nAdaptedCells)/mesh.globalData().nTotalCells() << nl
|
||||
<< "nAddCells/nCells = "
|
||||
<< scalar(nAddCells)/mesh.globalData().nTotalCells()
|
||||
<< endl;
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,9 +58,13 @@ void Foam::boxToCell::combine(topoSet& set, const bool add) const
|
||||
|
||||
forAll(ctrs, cellI)
|
||||
{
|
||||
if (bb_.contains(ctrs[cellI]))
|
||||
forAll(bbs_, i)
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
if (bbs_[i].contains(ctrs[cellI]))
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,11 +76,11 @@ void Foam::boxToCell::combine(topoSet& set, const bool add) const
|
||||
Foam::boxToCell::boxToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bbs
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(bb)
|
||||
bbs_(bbs)
|
||||
{}
|
||||
|
||||
|
||||
@ -88,7 +92,12 @@ Foam::boxToCell::boxToCell
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(dict.lookup("box"))
|
||||
bbs_
|
||||
(
|
||||
dict.found("box")
|
||||
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
|
||||
: dict.lookup("boxes")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -100,7 +109,7 @@ Foam::boxToCell::boxToCell
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(checkIs(is))
|
||||
bbs_(1, treeBoundBox(checkIs(is)))
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
@ -119,13 +128,13 @@ void Foam::boxToCell::applyToSet
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding cells with center within box " << bb_ << endl;
|
||||
Info<< " Adding cells with center within boxes " << bbs_ << endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing cells with center within box " << bb_ << endl;
|
||||
Info<< " Removing cells with center within boxes " << bbs_ << endl;
|
||||
|
||||
combine(set, false);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -25,7 +25,7 @@ Class
|
||||
Foam::boxToCell
|
||||
|
||||
Description
|
||||
A topoSetSource to select cells based on cell centres inside box.
|
||||
A topoSetSource to select cells based on cell centres inside box(es).
|
||||
|
||||
SourceFiles
|
||||
boxToCell.C
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#define boxToCell_H
|
||||
|
||||
#include "topoSetSource.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -59,7 +59,7 @@ class boxToCell
|
||||
|
||||
|
||||
//- bounding box.
|
||||
treeBoundBox bb_;
|
||||
treeBoundBoxList bbs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -78,7 +78,7 @@ public:
|
||||
boxToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bbs
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
@ -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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#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<scalar>());
|
||||
}
|
||||
|
||||
|
||||
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<label>());
|
||||
}
|
||||
|
||||
|
||||
void Foam::targetVolumeToCell::combine(topoSet& set, const bool add) const
|
||||
{
|
||||
if (vol_ <= 0)
|
||||
{
|
||||
// Select no cells
|
||||
return;
|
||||
}
|
||||
else if (gSum(mesh_.cellVolumes()) < vol_)
|
||||
{
|
||||
// Select all cells
|
||||
forAll(mesh_.cellVolumes(), cellI)
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Get plane for min,max volume.
|
||||
// Planes all have base (0 0 0) and fixed normal so work only on normal
|
||||
// component.
|
||||
|
||||
scalar maxComp = -GREAT;
|
||||
label maxCells = 0;
|
||||
scalar maxVol = 0;
|
||||
scalar minComp = GREAT;
|
||||
{
|
||||
const boundBox& bb = mesh_.bounds();
|
||||
pointField points(bb.points());
|
||||
|
||||
label minPointI = -1;
|
||||
label maxPointI = -1;
|
||||
forAll(points, pointI)
|
||||
{
|
||||
scalar c = (points[pointI]&n_);
|
||||
if (c > maxComp)
|
||||
{
|
||||
maxComp = c;
|
||||
maxPointI = pointI;
|
||||
}
|
||||
else if (c < minComp)
|
||||
{
|
||||
minComp = c;
|
||||
minPointI = pointI;
|
||||
}
|
||||
}
|
||||
|
||||
PackedBoolList maxSelected(mesh_.nCells());
|
||||
maxCells = selectCells(maxComp, maxSelected);
|
||||
maxVol = volumeOfSet(maxSelected);
|
||||
|
||||
// Check that maxPoint indeed selects all cells
|
||||
if (maxCells != mesh_.globalData().nTotalCells())
|
||||
{
|
||||
WarningIn("targetVolumeToCell::combine(topoSet&, const bool) const")
|
||||
<< "Plane " << plane(points[maxPointI], n_)
|
||||
<< " selects " << maxCells
|
||||
<< " cells instead of all " << mesh_.globalData().nTotalCells()
|
||||
<< " cells. Results might be wrong." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Bisection
|
||||
// ~~~~~~~~~
|
||||
|
||||
PackedBoolList selected(mesh_.nCells());
|
||||
label nSelected = -1;
|
||||
scalar selectedVol = 0.0;
|
||||
scalar selectedComp = 0.0;
|
||||
|
||||
|
||||
scalar low = minComp;
|
||||
scalar high = maxComp;
|
||||
|
||||
const scalar tolerance = SMALL*100*(maxComp-minComp);
|
||||
|
||||
while ((high-low) > tolerance)
|
||||
{
|
||||
scalar mid = 0.5*(low + high);
|
||||
|
||||
nSelected = selectCells(mid, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
//Pout<< "High:" << high << " low:" << low << " mid:" << mid << nl
|
||||
// << " nSelected:" << nSelected << nl
|
||||
// << " vol :" << selectedVol << nl
|
||||
// << endl;
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
low = mid;
|
||||
|
||||
PackedBoolList highSelected(mesh_.nCells());
|
||||
label nHigh = selectCells(high, selected);
|
||||
if (nSelected == nHigh)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
high = mid;
|
||||
|
||||
PackedBoolList lowSelected(mesh_.nCells());
|
||||
label nLow = selectCells(low, selected);
|
||||
if (nSelected == nLow)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nSelected = selectCells(high, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = high;
|
||||
}
|
||||
else
|
||||
{
|
||||
nSelected = selectCells(low, selected);
|
||||
selectedVol = volumeOfSet(selected);
|
||||
|
||||
if (selectedVol < vol_)
|
||||
{
|
||||
selectedComp = low;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("targetVolumeToCell::combine(topoSet&, const bool) const")
|
||||
<< "Did not converge onto plane. " << nl
|
||||
<< "high plane:"
|
||||
<< plane(high*n_, n_)
|
||||
<< nl
|
||||
<< "low plane :"
|
||||
<< plane(low*n_, n_)
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Info<< " Selected " << nSelected << " with actual volume " << selectedVol
|
||||
<< endl;
|
||||
|
||||
forAll(selected, cellI)
|
||||
{
|
||||
if (selected[cellI])
|
||||
{
|
||||
addOrDelete(set, cellI, add);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const scalar vol,
|
||||
const vector& n
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(vol),
|
||||
n_(n)
|
||||
{}
|
||||
|
||||
|
||||
// Construct from dictionary
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(readScalar(dict.lookup("volume"))),
|
||||
n_(dict.lookup("normal"))
|
||||
{}
|
||||
|
||||
|
||||
// Construct from Istream
|
||||
Foam::targetVolumeToCell::targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream& is
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
vol_(readScalar(checkIs(is))),
|
||||
n_(checkIs(is))
|
||||
{}
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::targetVolumeToCell::~targetVolumeToCell()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::targetVolumeToCell::applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet& set
|
||||
) const
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding cells up to target volume " << vol_
|
||||
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing cells up to target volume " << vol_
|
||||
<< " out of total volume " << gSum(mesh_.cellVolumes()) << endl;
|
||||
|
||||
combine(set, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,142 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::targetVolumeToCell
|
||||
|
||||
Description
|
||||
A topoSetSource to select cells based on the wanted volume of selected
|
||||
cells. Adapts a plane until it has enough.
|
||||
|
||||
SourceFiles
|
||||
targetVolumeToCell.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef targetVolumeToCell_H
|
||||
#define targetVolumeToCell_H
|
||||
|
||||
#include "topoSetSource.H"
|
||||
//#include "plane.H"
|
||||
#include "PackedBoolList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class targetVolumeToCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class targetVolumeToCell
|
||||
:
|
||||
public topoSetSource
|
||||
{
|
||||
|
||||
// Private data
|
||||
|
||||
//- Add usage string
|
||||
static addToUsageTable usage_;
|
||||
|
||||
//- Wanted volume
|
||||
const scalar vol_;
|
||||
|
||||
//- Normal of plane to sweep
|
||||
vector n_;
|
||||
//plane pl_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
scalar volumeOfSet(const PackedBoolList&) const;
|
||||
|
||||
label selectCells
|
||||
(
|
||||
const scalar normalComp,
|
||||
PackedBoolList& selected
|
||||
) const;
|
||||
|
||||
void combine(topoSet& set, const bool add) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("targetVolumeToCell");
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const scalar vol,
|
||||
//const plane&
|
||||
const vector&
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct from Istream
|
||||
targetVolumeToCell
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
Istream&
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~targetVolumeToCell();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
virtual sourceType setType() const
|
||||
{
|
||||
return CELLSETSOURCE;
|
||||
}
|
||||
|
||||
virtual void applyToSet
|
||||
(
|
||||
const topoSetSource::setAction action,
|
||||
topoSet&
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,9 +58,13 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
|
||||
|
||||
forAll(ctrs, faceI)
|
||||
{
|
||||
if (bb_.contains(ctrs[faceI]))
|
||||
forAll(bbs_, i)
|
||||
{
|
||||
addOrDelete(set, faceI, add);
|
||||
if (bbs_[i].contains(ctrs[faceI]))
|
||||
{
|
||||
addOrDelete(set, faceI, add);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,11 +76,11 @@ void Foam::boxToFace::combine(topoSet& set, const bool add) const
|
||||
Foam::boxToFace::boxToFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bbs
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(bb)
|
||||
bbs_(bbs)
|
||||
{}
|
||||
|
||||
|
||||
@ -88,7 +92,12 @@ Foam::boxToFace::boxToFace
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(dict.lookup("box"))
|
||||
bbs_
|
||||
(
|
||||
dict.found("box")
|
||||
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
|
||||
: dict.lookup("boxes")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -100,7 +109,7 @@ Foam::boxToFace::boxToFace
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(checkIs(is))
|
||||
bbs_(1, treeBoundBox(checkIs(is)))
|
||||
{}
|
||||
|
||||
|
||||
@ -120,13 +129,13 @@ void Foam::boxToFace::applyToSet
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding faces with centre within box " << bb_ << endl;
|
||||
Info<< " Adding faces with centre within boxes " << bbs_ << endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing faces with centre within box " << bb_ << endl;
|
||||
Info<< " Removing faces with centre within boxes " << bbs_ << endl;
|
||||
|
||||
combine(set, false);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#define boxToFace_H
|
||||
|
||||
#include "topoSetSource.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,7 +58,7 @@ class boxToFace
|
||||
static addToUsageTable usage_;
|
||||
|
||||
//- bounding box.
|
||||
treeBoundBox bb_;
|
||||
treeBoundBoxList bbs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -77,7 +77,7 @@ public:
|
||||
boxToFace
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bbs
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,9 +58,12 @@ void Foam::boxToPoint::combine(topoSet& set, const bool add) const
|
||||
|
||||
forAll(pts, pointI)
|
||||
{
|
||||
if (bb_.contains(pts[pointI]))
|
||||
forAll(bbs_, i)
|
||||
{
|
||||
addOrDelete(set, pointI, add);
|
||||
if (bbs_[i].contains(pts[pointI]))
|
||||
{
|
||||
addOrDelete(set, pointI, add);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -72,11 +75,11 @@ void Foam::boxToPoint::combine(topoSet& set, const bool add) const
|
||||
Foam::boxToPoint::boxToPoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bbs
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(bb)
|
||||
bbs_(bbs)
|
||||
{}
|
||||
|
||||
|
||||
@ -88,7 +91,12 @@ Foam::boxToPoint::boxToPoint
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(dict.lookup("box"))
|
||||
bbs_
|
||||
(
|
||||
dict.found("box")
|
||||
? treeBoundBoxList(1, treeBoundBox(dict.lookup("box")))
|
||||
: dict.lookup("boxes")
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
@ -100,7 +108,7 @@ Foam::boxToPoint::boxToPoint
|
||||
)
|
||||
:
|
||||
topoSetSource(mesh),
|
||||
bb_(checkIs(is))
|
||||
bbs_(1, treeBoundBox(checkIs(is)))
|
||||
{}
|
||||
|
||||
|
||||
@ -120,14 +128,14 @@ void Foam::boxToPoint::applyToSet
|
||||
{
|
||||
if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD))
|
||||
{
|
||||
Info<< " Adding points that are within box " << bb_ << " ..."
|
||||
Info<< " Adding points that are within boxes " << bbs_ << " ..."
|
||||
<< endl;
|
||||
|
||||
combine(set, true);
|
||||
}
|
||||
else if (action == topoSetSource::DELETE)
|
||||
{
|
||||
Info<< " Removing points that are within box " << bb_ << " ..."
|
||||
Info<< " Removing points that are within boxes " << bbs_ << " ..."
|
||||
<< endl;
|
||||
|
||||
combine(set, false);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -36,7 +36,7 @@ SourceFiles
|
||||
#define boxToPoint_H
|
||||
|
||||
#include "topoSetSource.H"
|
||||
#include "treeBoundBox.H"
|
||||
#include "treeBoundBoxList.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,7 +58,7 @@ class boxToPoint
|
||||
static addToUsageTable usage_;
|
||||
|
||||
//- bounding box.
|
||||
treeBoundBox bb_;
|
||||
treeBoundBoxList bbs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
@ -77,7 +77,7 @@ public:
|
||||
boxToPoint
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const treeBoundBox& bb
|
||||
const treeBoundBoxList& bb
|
||||
);
|
||||
|
||||
//- Construct from dictionary
|
||||
|
||||
@ -1,40 +0,0 @@
|
||||
/*--------------------------------*- 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 polyBoundaryMesh;
|
||||
location "constant/polyMesh";
|
||||
object boundary;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
3
|
||||
(
|
||||
movingWall
|
||||
{
|
||||
type wall;
|
||||
nFaces 20;
|
||||
startFace 760;
|
||||
}
|
||||
fixedWalls
|
||||
{
|
||||
type wall;
|
||||
nFaces 60;
|
||||
startFace 780;
|
||||
}
|
||||
frontAndBack
|
||||
{
|
||||
type empty;
|
||||
nFaces 800;
|
||||
startFace 840;
|
||||
}
|
||||
)
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -292,7 +292,7 @@ meshQualityControls
|
||||
// <0 = inside out tet,
|
||||
// 0 = flat tet
|
||||
// 1 = regular tet
|
||||
minTetQuality 1e-30;
|
||||
minTetQuality 1e-9;
|
||||
|
||||
//- Minimum face area. Set to <0 to disable.
|
||||
minArea -1;
|
||||
|
||||
@ -13,4 +13,4 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $$SOURCE -o $@
|
||||
LINK_LIBS = $(cDBUG) -L$(IA32ROOT)/lib
|
||||
|
||||
LINKLIBSO = $(cc) $(cFLAGS) -shared
|
||||
LINKEXE = $(cc) $(cFLAGS)
|
||||
LINKEXE = $(cc) $(cFLAGS) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs
|
||||
|
||||
@ -17,5 +17,5 @@ cpptoo = $(Ctoo)
|
||||
|
||||
LINK_LIBS = $(c++DBUG) -L$(IA64ROOT)/lib
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared
|
||||
LINKEXE = $(CC) $(c++FLAGS)
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
|
||||
LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
|
||||
|
||||
@ -13,4 +13,4 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $$SOURCE -o $@
|
||||
LINK_LIBS = $(cDBUG) -L$(IA32ROOT)/lib
|
||||
|
||||
LINKLIBSO = $(cc) $(cFLAGS) -shared
|
||||
LINKEXE = $(cc) $(cFLAGS)
|
||||
LINKEXE = $(cc) $(cFLAGS) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs
|
||||
|
||||
@ -19,5 +19,5 @@ cpptoo = $(Ctoo)
|
||||
#LINK_LIBS = $(c++DBUG) -lstdc++
|
||||
LINK_LIBS = $(c++DBUG) -L$(IA32ROOT)/lib
|
||||
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared
|
||||
LINKEXE = $(CC) $(c++FLAGS)
|
||||
LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed
|
||||
LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed
|
||||
|
||||
Reference in New Issue
Block a user