Merge branch 'nextRelease' of git://git.code.sf.net/p/openfoam-extend/foam-extend-3.1 into nextRelease

This commit is contained in:
Dominik Christ 2014-06-09 10:45:34 +01:00
commit efe1070f30
148 changed files with 16283 additions and 42443 deletions

View file

@ -75,3 +75,5 @@ Contents:
Michael Leonard
David McAuliffe
Tian Tang
Håkan Nilsson
Klas Jareteg

View file

@ -0,0 +1,280 @@
# -*- mode: org; -*-
#
#+TITLE: *Release notes for foam-extend-3.1*
#+AUTHOR: foam-extend administrators:
#+AUTHOR: Hrvoje Jasak
#+AUTHOR: Håkan Nilsson
#+AUTHOR: Dominik Christ
#+AUTHOR: Henrik Rusche
#+AUTHOR: Martin Beaudoin
#+AUTHOR: Bernhard Gschaider
#+DATE: 8 June 2014
#+LINK: http://foam-extend.org
#+OPTIONS: author:nil
################################################################################
Contents:
* Overview
* Installation
* Compatibility
* Main differentiators compared to OpenFOAM
* New features in foam-extend-3.1, since foam-extend-3.0
* Reporting bugs
* How to contribute
* List of Contributors
################################################################################
* Overview
The foam-extend project is a fork of the OpenFOAM® open source library for
Computational Fluid Dynamics (CFD). It is an open project welcoming and
integrating contributions from all users and developers. Previously known as
OpenFOAM®-dev and OpenFOAM®-extend, it contains bug fixes and performance
improvements, as well as extensions and additional features provided
by community contributors (see file ListOfContributors), such as dynamic mesh
and topological change support, turbomachinery extensions including general
grid interpolation (GGI), cyclic GGI and mixing plane, block-coupled matrix
support, finite area method, comprehensive mesh motion capability and GPU
support. For a full list, see below and previous release notes at:
http://sourceforge.net/p/openfoam-extend/wiki/Home/
Version 3.1, nicknamed "Zagreb", is the current version of foam-extend. The
release continues the tradition and spirit of the original FOAM code
developed by prof. Jasak and Mr. Weller during their time at
Imperial College and released as the general purpose CFD/CCM package by
Nabla Ltd. in 2000. In this spirit, we reverted 18 December 2013 to the
original numbering scheme (foam-2.3.2, 13 December 2004) as release
number 3.0.
Visit http://foam-extend.org for more information.
OPENFOAM® is a registered trademark of ESI Group. OpenFOAM-extend and
foam-extend are a community effort not endorsed by ESI Group.
* Installation
foam-extend-3.1 can be compiled and runs on any linux system
Main supported OSs:
Ubuntu 14.04
Mac OS X
** Compile from source:
Please refer to doc/buildInstructions/ for details. Further
installation instruction are available on the unofficial OpenFOAM Wiki:
http://openfoamwiki.net/index.php/Installation/Linux/foam-extend-3.0
If you have improvements or build instructions for a new system, please
share them with the community (see section "How to contribute", below).
** Download binary packages:
Binary packages are available for download at
http://sourceforge.net/projects/openfoam-extend/
for the following systems: Ubuntu 12.04, Ubuntu 13.10 and Fedora 19.
** Accompanying ThirdParty software:
gcc compatibility up to 4.8.2
Paraview 4.0.1
qt 4.8.5
openmpi 1.6.5
cmake 2.8.12
metis 5.1.0
parmetis 4.0.3
scotch 6.0.0
ParMGridGen 1.0
mesquite 2.1.2
PyFoam 0.6.3
swak4Foam 0.3.1
zoltan 3.6
bison 2.7
hwloc 1.7.2
libccmio 2.6.1
* Compatibility
Upstream features from the OpenFOAM® code base are merged into foam-extend
on regular basis. The interface format of foam-extend-3.1 is largely
compatible to OpenFOAM-1.6-ext and OpenFOAM-1.7.x. In some cases,
the differences are caused by bug fixes and algorithmic improvements,
considered more important than inter-operability.
* Main differentiators compared to OpenFOAM
A large number of features have been lost within the release of OpenFOAM
since version 1.3, the code base has shrunk by more than 40%. While
we understand the lack of technical ability of supporting advanced
CFD features, we feel that existing features and specifically large-scale
contributions should remain active and developed further. Below is a list
of main features of foam-extend which are lacking, lost, deactivated or
unusable in ESI releases:
** Turbomachinery features, including General Grid Interface (GGI),
partial overlap GGI, cyclic GGI, with improvements in parallel scaling.
First release of a mixing plane stage interface
** Dynamic mesh with topological changes
Sliding interfaces, mesh layering, attach-detach boundaries etc.
In foam-extend, full parallel support for topological changes
is released for the first time
** Finite Element Method with support for polyhedral meshes
This is mainly used in mesh deformation and over the last 15 years
it has proven vastly superior to all other dynamic mesh methods.
** Advanced mesh deformation technology
Including tet FEM mesh deformation, Radial Basis Function (RBF) mesh
deformation, tetrahedral remeshing dynamic mesh support and solid body
motion functions. All of the above include parallelisation support
** Library of dynamic meshes with topological changes with full
second order FVM discretisation support on moving meshes with
topological changes
** Internal combustion engine-specific dynamic mesh classes such as
two-stroke engine and various forms of 4-stroke and multi-valve
dynamic mesh classes
** Finite Area Method providing support for FVM-like discretisation on
a curved surface in 3-D, with examples of liquid film modelling
** Block-coupled matrix support, allowing fully implicit multi-equation
solution of NxN equation sets, with full parallelisation support.
First release of a block-AMG linear equation solver
** Fully implicit conjugate-coupled solution framework, allowing implicit
solution fo multiple equations over multiple meshes, with parallelism
** Proper Orthogonal Decomposition data analysis tools, with applications
to FOAM field classes
** Equation reader classes and tutorials
** Multi-solver solution framework, allowing multiple field models to be
solved in a coupled manner
** A major contribution is solid mechanics modelling, including linear
and non-linear materials, contact, self-contact and friction, with
updated Lagrangian or absolute Lagrangian formulation. Solution of
damage models and crack propagation in complex materials via
topological changes
** CUDA solver release, provided in full source and as an example of
coupling external linear equation solvers with FOAM
** Library-level support for Immersed Boundary Method and Overset Mesh
** Major improvements in accuracy and stability of FVM discretisation
with options on convection and diffusion discretisation, deferred
correction or explicit schemes
** Algebraic multigrid solver framework
** 210 tutorials with automated run scripts
** Automatic test harness
* New features in foam-extend-3.1, since foam-extend-3.0
The list of features is a result of the work of numerous contributors. The
maintainers of foam-extend would formally like to thank them all.
Get a full log of the updates by (either):
git log 3.0.. > commitLog
git log 3.0.. --oneline > commitLog
gitg 3.0..
Major new features:
Pressure-based compressible turbo functionalities
Pressure-based coupled solver (block-coupling p and U)
Licence:
Bumped to GPLv3
Installation:
Updated and bug-fixed installation procedures
Removed need for gmake link in Ubuntu
Scripts for minimizing installation after compilation
ThirdParty/Allclean alsoPackage - new option
wcleanAllButLibBinLnInclude
Fixed problem with ParaView reader for Ubuntu 14.04
foamToTecplot360: building tecio doesn't require X.org development files
Solvers:
compressible/dbnsFoam
compressible/dbnsTurbFoam
compressible/steadyCompressibleFoam
compressible/steadyCompressibleMRFFoam
compressible/steadyCompressibleSRFFoam
coupled/pUCoupledFoam (incl. core library changes)
---
Update and cleanup of solvers/solidMechanics
Update for segregated FEM matrix, solvers/solidMechanics/stressFemFoam
Utilities:
convertPhi (for steadyCompressible solvers)
fluent3DMeshToElmer
foamMeshToElmer
transformPoints -cylToCart "origin axis direction" - new option
blockMesh syntax backport (see commit a78b12074)
Libraries:
General:
Added Gauss-Seidel as asymmetric solver
Block matrix agglomeration (for pUCoupledFoam)
Block AMG solver
dbns library (src/dbns)
Boundary conditions:
cfdTools/general/SRF/derivedFvPatchFields/SRFFlowRateInletVelocity
cfdTools/general/SRF/derivedFvPatchFields/SRFSurfaceNormalVelocity*
cfdTools/general/SRF/derivedFvPatchFields/SRFTotalPressure
cfdTools/general/SRF/derivedFvPatchFields/SRFTotalTemperature
cfdTools/general/SRF/derivedFvPatchFields/pulseFixedValue
cfdTools/general/SRF/derivedFvPatchFields/waveTransmissiveInlet
thermophysicalModels/basic/derivedFvPatchFields/isentropicTotalTemperature
thermophysicalModels/basic/derivedFvPatchFields/temperatureDirectedInletOutletVelocity
Turbulence modeling:
Removed kOmegaSST_lowRe - USE WHAT INSTEAD???
Tutorial updates (settings, initial conditions, bug fixes etc.):
incompressible/icoDyMFoam/mixerGgi
incompressible/icoDyMFoam/movingConeMotion
incompressible/icoDyMFoam/movingConeTopo
solidMechanics/elasticNonLinTLSolidFoam/largeStrainCantileverBeam
solidMechanics/elasticNonLinTLSolidFoam/nonLinBlock
solidMechanics/elasticNonLinTLSolidFoam/rotateSphereTL
solidMechanics/elasticThermalSolidFoam/hotCylinder
solidMechanics/stressFemFoam/plateHole
Many other updates due to blockMesh backport
New tutorials:
compressible/dbnsFoam/forwardStep
compressible/dbnsFoam/shockTube
compressible/dbnsTurbFoam/naca0012
compressible/steadyCompressibleFoam/2bump
compressible/steadyCompressibleFoam/bumpBlockMesh
compressible/steadyCompressibleFoam/bumpFine05
compressible/steadyCompressibleMRFFoam/bentRotorStator
compressible/steadyCompressibleMRFFoam/simpleRotorStator
compressible/steadyCompressibleSRFFoam/bentBlade
compressible/steadyCompressibleSRFFoam/simpleBlade
coupled/pUCoupledFoam/cavity
incompressible/MRFSimpleFoam/axialTurbine_ggi
incompressible/MRFSimpleFoam/axialTurbine_mixingPlane
incompressible/pimpleDyMFoam/axialTurbine
incompressible/pimpleDyMFoam/movingCylinders
incompressible/pUCoupledFoam/backwardFacingStepLaminar
incompressible/pUCoupledFoam/backwardFacingStepTurbulent
incompressible/pUCoupledFoam/cavity
incompressible/simpleSRFFoam/axialTurbine
mesh/moveDynamicMesh/movingCylinders
Bug fixes:
LinearUpwind no longer hangs in parallel execution on empty patches
* Reporting bugs
To report bugs, please use the MantisBT bugtracker at
http://sourceforge.net/apps/mantisbt/openfoam-extend
* How to contribute
All your contributions are highly welcome: New solvers, utilities and
models; bug fixes; documentation. The many ways of contributing and the
contribution process are described in detail in the file "HowToContribute"
and at http://sourceforge.net/p/openfoam-extend/wiki/Home/
* List of Contributors:
See file ListOfContributors

View file

@ -47,6 +47,7 @@ Description
using namespace Foam;
#include "argList.H"
#include "objectRegistry.H"
#include "Time.H"
#include "polyMesh.H"
#include "emptyPolyPatch.H"

View file

@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "objectRegistry.H"
#include "Time.H"
#include "IFstream.H"
#include "hexBlock.H"

View file

@ -39,6 +39,7 @@ Description
\* ------------------------------------------------------------------------- */
#include "argList.H"
#include "objectRegistry.H"
#include "Time.H"
#include "IStringStream.H"
#include "polyMesh.H"

View file

@ -46,6 +46,7 @@ Description
using namespace Foam;
#include "argList.H"
#include "objectRegistry.H"
#include "Time.H"
#include "polyMesh.H"
#include "emptyPolyPatch.H"

View file

@ -30,6 +30,7 @@ Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "objectRegistry.H"
#include "Time.H"
#include "polyMesh.H"
#include "IFstream.H"

View file

@ -46,6 +46,7 @@ Usage
\*---------------------------------------------------------------------------*/
#include "objectRegistry.H"
#include "Time.H"
#include "IOdictionary.H"
#include "IOPtrList.H"

View file

@ -1,6 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/autoMesh/lnInclude \
-I$(LIB_SRC)/mesh/autoMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \

View file

@ -6,6 +6,7 @@ EXE_INC = \
-I../PV4FoamReader
LIB_LIBS = \
-l$(WM_PROJECT) \
-lfiniteVolume \
-llagrangian \
-lmeshTools \

View file

@ -60,7 +60,6 @@ lagrangian/Allwmake
postProcessing/Allwmake
conversion/Allwmake
wmake libso autoMesh
wmake libso errorEstimation
fvAgglomerationMethods/Allwmake

View file

@ -1,26 +0,0 @@
autoHexMesh = autoHexMesh
autoHexMeshDriver = $(autoHexMesh)/autoHexMeshDriver
$(autoHexMeshDriver)/autoLayerDriver.C
$(autoHexMeshDriver)/autoLayerDriverShrink.C
$(autoHexMeshDriver)/autoSnapDriver.C
$(autoHexMeshDriver)/autoRefineDriver.C
$(autoHexMeshDriver)/autoHexMeshDriver.C
$(autoHexMeshDriver)/layerParameters/layerParameters.C
$(autoHexMeshDriver)/refinementParameters/refinementParameters.C
$(autoHexMeshDriver)/snapParameters/snapParameters.C
$(autoHexMeshDriver)/pointData/pointData.C
$(autoHexMesh)/meshRefinement/meshRefinementBaffles.C
$(autoHexMesh)/meshRefinement/meshRefinement.C
$(autoHexMesh)/meshRefinement/meshRefinementMerge.C
$(autoHexMesh)/meshRefinement/meshRefinementProblemCells.C
$(autoHexMesh)/meshRefinement/meshRefinementRefine.C
$(autoHexMesh)/refinementSurfaces/refinementSurfaces.C
$(autoHexMesh)/shellSurfaces/shellSurfaces.C
$(autoHexMesh)/trackedParticle/trackedParticle.C
$(autoHexMesh)/trackedParticle/trackedParticleCloud.C
LIB = $(FOAM_LIBBIN)/libautoMesh

View file

@ -1,19 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/dynamicFvMesh/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude
LIB_LIBS = \
-ldecompositionMethods \
-ldynamicMesh \
-ldynamicFvMesh \
-lfiniteVolume \
-llagrangian \
-lmeshTools \
-ledgeMesh \
-ltriSurface

View file

@ -1,552 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*----------------------------------------------------------------------------*/
#include "autoHexMeshDriver.H"
#include "fvMesh.H"
#include "Time.H"
#include "boundBox.H"
#include "wallPolyPatch.H"
#include "cellSet.H"
#include "syncTools.H"
#include "refinementParameters.H"
#include "snapParameters.H"
#include "layerParameters.H"
#include "autoRefineDriver.H"
#include "autoSnapDriver.H"
#include "autoLayerDriver.H"
#include "triSurfaceMesh.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(autoHexMeshDriver, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Check writing tolerance before doing any serious work
Foam::scalar Foam::autoHexMeshDriver::getMergeDistance(const scalar mergeTol)
const
{
const boundBox& meshBb = mesh_.bounds();
scalar mergeDist = mergeTol * meshBb.mag();
scalar writeTol = std::pow
(
scalar(10.0),
-scalar(IOstream::defaultPrecision())
);
Info<< nl
<< "Overall mesh bounding box : " << meshBb << nl
<< "Relative tolerance : " << mergeTol << nl
<< "Absolute matching distance : " << mergeDist << nl
<< endl;
if (mesh_.time().writeFormat() == IOstream::ASCII && mergeTol < writeTol)
{
FatalErrorIn("autoHexMeshDriver::getMergeDistance(const scalar) const")
<< "Your current settings specify ASCII writing with "
<< IOstream::defaultPrecision() << " digits precision." << endl
<< "Your merging tolerance (" << mergeTol << ") is finer than this."
<< endl
<< "Please change your writeFormat to binary"
<< " or increase the writePrecision" << endl
<< "or adjust the merge tolerance (-mergeTol)."
<< exit(FatalError);
}
return mergeDist;
}
//// Specifically orient using a calculated point outside
//void Foam::autoHexMeshDriver::orientOutside
//(
// PtrList<searchableSurface>& shells
//)
//{
// // Determine outside point.
// boundBox overallBb = boundBox::invertedBox;
//
// bool hasSurface = false;
//
// forAll(shells, shellI)
// {
// if (isA<triSurfaceMesh>(shells[shellI]))
// {
// const triSurfaceMesh& shell =
// refCast<const triSurfaceMesh>(shells[shellI]);
//
// hasSurface = true;
//
// boundBox shellBb(shell.localPoints(), false);
//
// overallBb.min() = min(overallBb.min(), shellBb.min());
// overallBb.max() = max(overallBb.max(), shellBb.max());
// }
// }
//
// if (hasSurface)
// {
// const point outsidePt = 2 * overallBb.span();
//
// //Info<< "Using point " << outsidePt << " to orient shells" << endl;
//
// forAll(shells, shellI)
// {
// if (isA<triSurfaceMesh>(shells[shellI]))
// {
// triSurfaceMesh& shell =
// refCast<triSurfaceMesh>(shells[shellI]);
//
// if (!refinementSurfaces::isSurfaceClosed(shell))
// {
// FatalErrorIn("orientOutside(PtrList<searchableSurface>&)")
// << "Refinement shell "
// << shell.searchableSurface::name()
// << " is not closed." << exit(FatalError);
// }
//
// refinementSurfaces::orientSurface(outsidePt, shell);
// }
// }
// }
//}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::autoHexMeshDriver::autoHexMeshDriver
(
fvMesh& mesh,
const bool overwrite,
const dictionary& dict,
const dictionary& decomposeDict
)
:
mesh_(mesh),
dict_(dict),
debug_(readLabel(dict_.lookup("debug"))),
mergeDist_(getMergeDistance(readScalar(dict_.lookup("mergeTolerance"))))
{
if (debug_ > 0)
{
meshRefinement::debug = debug_;
autoHexMeshDriver::debug = debug_;
autoRefineDriver::debug = debug;
autoSnapDriver::debug = debug;
autoLayerDriver::debug = debug;
}
refinementParameters refineParams(dict, 1);
Info<< "Overall cell limit : "
<< refineParams.maxGlobalCells() << endl;
Info<< "Per processor cell limit : "
<< refineParams.maxLocalCells() << endl;
Info<< "Minimum number of cells to refine : "
<< refineParams.minRefineCells() << endl;
Info<< "Curvature : "
<< refineParams.curvature() << nl << endl;
Info<< "Layers between different refinement levels : "
<< refineParams.nBufferLayers() << endl;
PtrList<dictionary> shellDicts(dict_.lookup("refinementShells"));
PtrList<dictionary> surfaceDicts(dict_.lookup("surfaces"));
// Read geometry
// ~~~~~~~~~~~~~
{
Info<< "Reading all geometry." << endl;
// Construct dictionary with all shells and all refinement surfaces
dictionary geometryDict;
forAll(shellDicts, shellI)
{
dictionary shellDict = shellDicts[shellI];
const word name(shellDict.lookup("name"));
shellDict.remove("name");
shellDict.remove("level");
shellDict.remove("refineInside");
geometryDict.add(name, shellDict);
}
forAll(surfaceDicts, surfI)
{
dictionary surfDict = surfaceDicts[surfI];
const word name(string::validate<word>(surfDict.lookup("file")));
surfDict.remove("file");
surfDict.remove("regions");
if (!surfDict.found("name"))
{
surfDict.add("name", name);
}
surfDict.add("type", triSurfaceMesh::typeName);
geometryDict.add(name, surfDict);
}
allGeometryPtr_.reset
(
new searchableSurfaces
(
IOobject
(
"abc", // dummy name
//mesh_.time().findInstance("triSurface", word::null),
// instance
mesh_.time().constant(), // instance
"triSurface", // local
mesh_.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE
),
geometryDict
)
);
Info<< "Read geometry in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
}
// Read refinement surfaces
// ~~~~~~~~~~~~~~~~~~~~~~~~
{
Info<< "Reading surfaces and constructing search trees." << endl;
surfacesPtr_.reset
(
new refinementSurfaces
(
allGeometryPtr_(),
surfaceDicts
)
);
Info<< "Read surfaces in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
}
// Read refinement shells
// ~~~~~~~~~~~~~~~~~~~~~~
{
Info<< "Reading refinement shells." << endl;
shellsPtr_.reset
(
new shellSurfaces
(
allGeometryPtr_(),
shellDicts
)
);
Info<< "Read refinement shells in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
//// Orient shell surfaces before any searching is done.
//Info<< "Orienting triSurface shells so point far away is outside."
// << endl;
//orientOutside(shells_);
//Info<< "Oriented shells in = "
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
Info<< "Setting refinement level of surface to be consistent"
<< " with shells." << endl;
surfacesPtr_().setMinLevelFields(shells());
Info<< "Checked shell refinement in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
}
// Check faceZones are synchronised
meshRefinement::checkCoupledFaceZones(mesh_);
// Refinement engine
// ~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Determining initial surface intersections" << nl
<< "-----------------------------------------" << nl
<< endl;
// Main refinement engine
meshRefinerPtr_.reset
(
new meshRefinement
(
mesh,
mergeDist_, // tolerance used in sorting coordinates
overwrite,
surfaces(),
shells()
)
);
Info<< "Calculated surface intersections in = "
<< mesh_.time().cpuTimeIncrement() << " s" << endl;
// Some stats
meshRefinerPtr_().printMeshInfo(debug_, "Initial mesh");
meshRefinerPtr_().write
(
debug_&meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/meshRefinerPtr_().timeName()
);
}
// Add all the surface regions as patches
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
{
Info<< nl
<< "Adding patches for surface regions" << nl
<< "----------------------------------" << nl
<< endl;
// From global region number to mesh patch.
globalToPatch_.setSize(surfaces().nRegions(), -1);
Info<< "Patch\tRegion" << nl
<< "-----\t------"
<< endl;
const labelList& surfaceGeometry = surfaces().surfaces();
forAll(surfaceGeometry, surfI)
{
label geomI = surfaceGeometry[surfI];
const wordList& regNames = allGeometryPtr_().regionNames()[geomI];
Info<< surfaces().names()[surfI] << ':' << nl << nl;
forAll(regNames, i)
{
label patchI = meshRefinerPtr_().addMeshedPatch
(
regNames[i],
wallPolyPatch::typeName
);
Info<< patchI << '\t' << regNames[i] << nl;
globalToPatch_[surfaces().globalRegion(surfI, i)] = patchI;
}
Info<< nl;
}
Info<< "Added patches in = "
<< mesh_.time().cpuTimeIncrement() << " s" << nl << endl;
}
//// Add cyclics for any named faceZones
//// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//// (these cyclics are used later on to temporarily put the faceZones
//// in when snapping)
//
//labelList namedSurfaces(surfaces().getNamedSurfaces());
//if (namedSurfaces.size())
//{
// Info<< nl
// << "Introducing cyclics for faceZones" << nl
// << "---------------------------------" << nl
// << endl;
//
// // From surface to cyclic patch
// surfaceToCyclicPatch_.setSize(surfaces().size(), -1);
//
// Info<< "Patch\tZone" << nl
// << "----\t-----"
// << endl;
//
// forAll(namedSurfaces, i)
// {
// label surfI = namedSurfaces[i];
//
// surfaceToCyclicPatch_[surfI] = meshRefinement::addPatch
// (
// mesh,
// surfaces().faceZoneNames()[surfI],
// cyclicPolyPatch::typeName
// );
//
// Info<< surfaceToCyclicPatch_[surfI] << '\t'
// << surfaces().faceZoneNames()[surfI] << nl << endl;
// }
// Info<< "Added cyclic patches in = "
// << mesh_.time().cpuTimeIncrement() << " s" << endl;
//}
// Parallel
// ~~~~~~~~
{
// Decomposition
decomposerPtr_ = decompositionMethod::New
(
decomposeDict,
mesh_
);
decompositionMethod& decomposer = decomposerPtr_();
if (Pstream::parRun() && !decomposer.parallelAware())
{
FatalErrorIn("autoHexMeshDriver::autoHexMeshDriver"
"(const IOobject&, fvMesh&)")
<< "You have selected decomposition method "
<< decomposer.typeName
<< " which is not parallel aware." << endl
<< "Please select one that is (parMetis, hierarchical)"
<< exit(FatalError);
}
// Mesh distribution engine (uses tolerance to reconstruct meshes)
distributorPtr_.reset(new fvMeshDistribute(mesh_, mergeDist_));
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::autoHexMeshDriver::writeMesh(const string& msg) const
{
const meshRefinement& meshRefiner = meshRefinerPtr_();
meshRefiner.printMeshInfo(debug_, msg);
Info<< "Writing mesh to time " << meshRefiner.timeName() << endl;
meshRefiner.write(meshRefinement::MESH|meshRefinement::SCALARLEVELS, "");
if (debug_ & meshRefinement::OBJINTERSECTIONS)
{
meshRefiner.write
(
meshRefinement::OBJINTERSECTIONS,
mesh_.time().path()/meshRefiner.timeName()
);
}
Info<< "Written mesh in = "
<< mesh_.time().cpuTimeIncrement() << " s." << endl;
}
void Foam::autoHexMeshDriver::doMesh()
{
Switch wantRefine(dict_.lookup("doRefine"));
Switch wantSnap(dict_.lookup("doSnap"));
Switch wantLayers(dict_.lookup("doLayers"));
Info<< "Do refinement : " << wantRefine << nl
<< "Do snapping : " << wantSnap << nl
<< "Do layers : " << wantLayers << nl
<< endl;
if (wantRefine)
{
const dictionary& motionDict = dict_.subDict("motionDict");
autoRefineDriver refineDriver
(
meshRefinerPtr_(),
decomposerPtr_(),
distributorPtr_(),
globalToPatch_
);
// Get all the refinement specific params
refinementParameters refineParams(dict_, 1);
refineDriver.doRefine(dict_, refineParams, wantSnap, motionDict);
// Write mesh
writeMesh("Refined mesh");
}
if (wantSnap)
{
const dictionary& snapDict = dict_.subDict("snapDict");
const dictionary& motionDict = dict_.subDict("motionDict");
autoSnapDriver snapDriver
(
meshRefinerPtr_(),
globalToPatch_
);
// Get all the snapping specific params
snapParameters snapParams(snapDict, 1);
snapDriver.doSnap(snapDict, motionDict, snapParams);
// Write mesh.
writeMesh("Snapped mesh");
}
if (wantLayers)
{
const dictionary& motionDict = dict_.subDict("motionDict");
const dictionary& shrinkDict = dict_.subDict("shrinkDict");
PtrList<dictionary> surfaceDicts(dict_.lookup("surfaces"));
autoLayerDriver layerDriver(meshRefinerPtr_());
// Get all the layer specific params
layerParameters layerParams
(
surfaceDicts,
surfacesPtr_(),
globalToPatch_,
shrinkDict,
mesh_.boundaryMesh()
);
layerDriver.doLayers
(
shrinkDict,
motionDict,
layerParams,
true, // pre-balance
decomposerPtr_(),
distributorPtr_()
);
// Write mesh.
writeMesh("Layer mesh");
}
}
// ************************************************************************* //

View file

@ -1,233 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::autoHexMeshDriver
Description
main meshing driver.
SourceFiles
autoHexMeshDriver.C
\*---------------------------------------------------------------------------*/
#ifndef autoHexMeshDriver_H
#define autoHexMeshDriver_H
#include "autoPtr.H"
#include "dictionary.H"
#include "wallPoint.H"
#include "searchableSurfaces.H"
#include "refinementSurfaces.H"
#include "shellSurfaces.H"
#include "meshRefinement.H"
#include "decompositionMethod.H"
#include "fvMeshDistribute.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class fvMesh;
/*---------------------------------------------------------------------------*\
Class autoHexMeshDriver Declaration
\*---------------------------------------------------------------------------*/
class autoHexMeshDriver
{
// Static data members
//- Extrusion controls
enum extrudeMode
{
NOEXTRUDE, /*!< Do not extrude. No layers added. */
EXTRUDE, /*!< Extrude */
EXTRUDEREMOVE /*!< Extrude but afterwards remove added */
/*!< faces locally */
};
// Private classes
//- Combine operator class for equalizing displacements.
class minMagEqOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (magSqr(y) < magSqr(x))
{
x = y;
}
}
};
//- Combine operator class to combine normal with other normal.
class nomalsCombine
{
public:
void operator()(vector& x, const vector& y) const
{
if (y != wallPoint::greatPoint)
{
if (x == wallPoint::greatPoint)
{
x = y;
}
else
{
x *= (x&y);
}
}
}
};
// Private data
//- Reference to mesh
fvMesh& mesh_;
//- Input dictionary
const dictionary dict_;
//- Debug level
const label debug_;
//- Merge distance
const scalar mergeDist_;
//- All surface based geometry
autoPtr<searchableSurfaces> allGeometryPtr_;
//- Shells (geometry for inside/outside refinement)
autoPtr<shellSurfaces> shellsPtr_;
//- Surfaces (geometry for intersection based refinement)
autoPtr<refinementSurfaces> surfacesPtr_;
//- Per refinement surface region the patch
labelList globalToPatch_;
//- Mesh refinement engine
autoPtr<meshRefinement> meshRefinerPtr_;
//- Decomposition engine
autoPtr<decompositionMethod> decomposerPtr_;
//- Mesh distribution engine
autoPtr<fvMeshDistribute> distributorPtr_;
// Private Member Functions
//- Calculate merge distance. Check against writing tolerance.
scalar getMergeDistance(const scalar mergeTol) const;
//static void orientOutside(PtrList<searchableSurface>&);
//- Disallow default bitwise copy construct
autoHexMeshDriver(const autoHexMeshDriver&);
//- Disallow default bitwise assignment
void operator=(const autoHexMeshDriver&);
public:
//- Runtime type information
ClassName("autoHexMeshDriver");
// Constructors
//- Construct from dictionary and mesh to modify
autoHexMeshDriver
(
fvMesh& mesh,
const bool overwrite,
const dictionary& meshDict,
const dictionary& decomposeDict
);
// Member Functions
// Access
//- reference to mesh
const fvMesh& mesh() const
{
return mesh_;
}
fvMesh& mesh()
{
return mesh_;
}
//- Surfaces to base refinement on
const refinementSurfaces& surfaces() const
{
return surfacesPtr_();
}
//- Surfaces to volume refinement on
const shellSurfaces& shells() const
{
return shellsPtr_();
}
//- Per refinementsurface, per region the patch
const labelList& globalToPatch() const
{
return globalToPatch_;
}
// Meshing
//- Write mesh
void writeMesh(const string&) const;
//- Do all : refine, snap, layers
void doMesh();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,561 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::autoLayerDriver
Description
All to do with adding layers
SourceFiles
autoLayerDriver.C
\*---------------------------------------------------------------------------*/
#ifndef autoLayerDriver_H
#define autoLayerDriver_H
#include "PackedBoolList.H"
#include "meshRefinement.H"
#include "wallPoint.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class removePoints;
class pointSet;
class motionSmoother;
class addPatchCellLayer;
class pointData;
class wallPoint;
class faceSet;
class layerParameters;
/*---------------------------------------------------------------------------*\
Class autoLayerDriver Declaration
\*---------------------------------------------------------------------------*/
class autoLayerDriver
{
// Static data members
//- Extrusion controls
enum extrudeMode
{
NOEXTRUDE, /*!< Do not extrude. No layers added. */
EXTRUDE, /*!< Extrude */
EXTRUDEREMOVE /*!< Extrude but afterwards remove added */
/*!< faces locally */
};
// Private classes
//- Combine operator class to combine normal with other normal.
class nomalsCombine
{
public:
void operator()(vector& x, const vector& y) const
{
if (y != wallPoint::greatPoint)
{
if (x == wallPoint::greatPoint)
{
x = y;
}
else
{
x *= (x&y);
}
}
}
};
// Private data
//- Mesh+surface
meshRefinement& meshRefiner_;
// Private Member Functions
// Face merging
//- Merge patch faces. Undo until no checkMesh errors.
label mergePatchFacesUndo
(
const scalar minCos,
const scalar concaveCos,
const dictionary&
);
//- Remove points.
autoPtr<mapPolyMesh> doRemovePoints
(
removePoints& pointRemover,
const boolList& pointCanBeDeleted
);
//- Restore faces (which contain removed points)
autoPtr<mapPolyMesh> doRestorePoints
(
removePoints& pointRemover,
const labelList& facesToRestore
);
//- Return candidateFaces that are also in set.
labelList collectFaces
(
const labelList& candidateFaces,
const labelHashSet& set
) const;
//- Pick up faces of cells of faces in set.
labelList growFaceCellFace(const labelHashSet&) const;
//- Remove points not used by any face or points used by only
// two faces where the edges are in line
label mergeEdgesUndo(const scalar minCos, const dictionary&);
// Layers
//- For debugging: Dump displacement to .obj files
static void dumpDisplacement
(
const fileName&,
const indirectPrimitivePatch&,
const vectorField&,
const List<extrudeMode>&
);
//- Check that primitivePatch is not multiply connected.
// Collect non-manifold points in pointSet.
static void checkManifold
(
const indirectPrimitivePatch&,
pointSet& nonManifoldPoints
);
//- Check that mesh outside is not multiply connected.
void checkMeshManifold() const;
// Static extrusion setup
//- Unset extrusion on point. Returns true if anything unset.
static bool unmarkExtrusion
(
const label patchPointI,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
);
//- Unset extrusion on face. Returns true if anything unset.
static bool unmarkExtrusion
(
const face& localFace,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
);
//- No extrusion at non-manifold points.
void handleNonManifolds
(
const indirectPrimitivePatch& pp,
const labelList& meshEdges,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- No extrusion on feature edges. Assumes non-manifold
// edges already handled.
void handleFeatureAngle
(
const indirectPrimitivePatch& pp,
const labelList& meshEdges,
const scalar minCos,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- No extrusion on warped faces
void handleWarpedFaces
(
const indirectPrimitivePatch& pp,
const scalar faceRatio,
const scalar edge0Len,
const labelList& cellLevel,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- Determine the number of layers per point from the number of
// layers per surface.
void setNumLayers
(
const labelList& patchToNLayers,
const labelList& patchIDs,
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- Grow no-extrusion layer.
static void growNoExtrusion
(
const indirectPrimitivePatch& pp,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
);
//- Calculate pointwise wanted and minimum thickness.
// thickness: wanted thickness
// minthickness: when to give up and not extrude
// Gets per patch parameters and determine pp pointwise
// parameters.
void calculateLayerThickness
(
const indirectPrimitivePatch& pp,
const labelList& patchIDs,
const scalarField& patchExpansionRatio,
const bool relativeSizes,
const scalarField& patchFinalLayerThickness,
const scalarField& patchMinThickness,
const labelList& cellLevel,
const labelList& patchNLayers,
const scalar edge0Len,
scalarField& thickness,
scalarField& minThickness,
scalarField& expansionRatio
) const;
// Extrusion execution
//- Synchronize displacement among coupled patches.
void syncPatchDisplacement
(
const motionSmoother& meshMover,
const scalarField& minThickness,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- Get nearest point on surface to snap to
void getPatchDisplacement
(
const motionSmoother& meshMover,
const scalarField& thickness,
const scalarField& minThickness,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- Truncates displacement
// - for all patchFaces in the faceset displacement gets set
// to zero
// - all displacement < minThickness gets set to zero
label truncateDisplacement
(
const motionSmoother& meshMover,
const scalarField& minThickness,
const faceSet& illegalPatchFaces,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
) const;
//- Setup layer information (at points and faces) to
// modify mesh topology in
// regions where layer mesh terminates. Guarantees an
// optional slow decreasing of the number of layers.
// Returns the number of layers per face and per point
// to go into the actual layer addition engine.
void setupLayerInfoTruncation
(
const motionSmoother& meshMover,
const labelList& patchNLayers,
const List<extrudeMode>& extrudeStatus,
const label nBufferCellsNoExtrude,
labelList& nPatchPointLayers,
labelList& nPatchFaceLayers
) const;
//- Does any of the cells use a face from faces?
static bool cellsUseFace
(
const polyMesh& mesh,
const labelList& cellLabels,
const labelHashSet& faces
);
//- Checks the newly added cells and locally unmarks points
// so they will not get extruded next time round. Returns
// global number of unmarked points (0 if all was fine)
static label checkAndUnmark
(
const addPatchCellLayer& addLayer,
const dictionary& motionDict,
const indirectPrimitivePatch& pp,
const polyMesh&,
pointField& patchDisp,
labelList& patchNLayers,
List<extrudeMode>& extrudeStatus
);
//- Count global number of extruded faces
static label countExtrusion
(
const indirectPrimitivePatch& pp,
const List<extrudeMode>& extrudeStatus
);
//- Collect layer faces and layer cells into bools
// for ease of handling
static void getLayerCellsFaces
(
const polyMesh&,
const addPatchCellLayer&,
boolList&,
boolList&
);
// Mesh shrinking (to create space for layers)
//- Average field (over all subset of mesh points) by
// summing contribution from edges. Global parallel since only
// does master edges for coupled edges.
template<class Type>
static void averageNeighbours
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
const scalarField& invSumWeight,
const Field<Type>& data,
Field<Type>& average
);
//- Calculate inverse sum of edge weights
// (currently always 1.0)
void sumWeights
(
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
scalarField& invSumWeight
) const;
//- Smooth scalar field on patch
void smoothField
(
const motionSmoother& meshMover,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const scalarField& fieldMin,
const label nSmoothDisp,
scalarField& field
) const;
//- Smooth normals on patch.
void smoothPatchNormals
(
const motionSmoother& meshMover,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const label nSmoothDisp,
pointField& normals
) const;
//- Smooth normals in interior.
void smoothNormals
(
const label nSmoothDisp,
const PackedBoolList& isMasterEdge,
const labelList& fixedPoints,
pointVectorField& normals
) const;
bool isMaxEdge
(
const List<pointData>&,
const label edgeI,
const scalar minCos
) const;
//- Stop layer growth where mesh wraps around edge with a
// large feature angle
void handleFeatureAngleLayerTerminations
(
const indirectPrimitivePatch& pp,
const scalar minCos,
List<extrudeMode>& extrudeStatus,
pointField& patchDisp,
labelList& patchNLayers,
label& nPointCounter
) const;
//- Find isolated islands (points, edges and faces and
// layer terminations)
// in the layer mesh and stop any layer growth at these points.
void findIsolatedRegions
(
const indirectPrimitivePatch& pp,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const scalar minCosLayerTermination,
scalarField& field,
List<extrudeMode>& extrudeStatus,
pointField& patchDisp,
labelList& patchNLayers
) const;
// Calculate medial axis fields
void medialAxisSmoothingInfo
(
const motionSmoother& meshMover,
const label nSmoothNormals,
const label nSmoothSurfaceNormals,
const scalar minMedianAxisAngleCos,
pointVectorField& dispVec,
pointScalarField& medialRatio,
pointScalarField& medialDist
) const;
//- Main routine to shrink mesh
void shrinkMeshMedialDistance
(
motionSmoother& meshMover,
const dictionary& meshQualityDict,
const label nSmoothThickness,
const scalar maxThicknessToMedialRatio,
const label nAllowableErrors,
const label nSnap,
const scalar minCosLayerTermination,
const scalarField& layerThickness,
const scalarField& minThickness,
const pointVectorField& dispVec,
const pointScalarField& medialRatio,
const pointScalarField& medialDist,
List<extrudeMode>& extrudeStatus,
pointField& patchDisp,
labelList& patchNLayers
) const;
//- Disallow default bitwise copy construct
autoLayerDriver(const autoLayerDriver&);
//- Disallow default bitwise assignment
void operator=(const autoLayerDriver&);
public:
//- Runtime type information
ClassName("autoLayerDriver");
// Constructors
//- Construct from components
autoLayerDriver(meshRefinement& meshRefiner);
// Member Functions
//- Merge patch faces on same cell.
void mergePatchFacesUndo
(
const layerParameters& layerParams,
const dictionary& motionDict
);
//- Add cell layers
void addLayers
(
const layerParameters& layerParams,
const dictionary& motionDict,
const labelList& patchIDs,
const label nAllowableErrors,
decompositionMethod& decomposer,
fvMeshDistribute& distributor
);
//- Add layers according to the dictionary settings
void doLayers
(
const dictionary& shrinkDict,
const dictionary& motionDict,
const layerParameters& layerParams,
const bool preBalance, // balance before adding?
decompositionMethod& decomposer,
fvMeshDistribute& distributor
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "autoLayerDriverTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,75 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "autoLayerDriver.H"
#include "syncTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::autoLayerDriver::averageNeighbours
(
const polyMesh& mesh,
const PackedBoolList& isMasterEdge,
const labelList& meshEdges,
const labelList& meshPoints,
const edgeList& edges,
const scalarField& invSumWeight,
const Field<Type>& data,
Field<Type>& average
)
{
average = pTraits<Type>::zero;
forAll(edges, edgeI)
{
if (isMasterEdge.get(meshEdges[edgeI]) == 1)
{
const edge& e = edges[edgeI];
//scalar eWeight = edgeWeights[edgeI];
scalar eWeight = 1.0;
label v0 = e[0];
label v1 = e[1];
average[v0] += eWeight*data[v1];
average[v1] += eWeight*data[v0];
}
}
syncTools::syncPointList
(
mesh,
meshPoints,
average,
plusEqOp<Type>(),
pTraits<Type>::zero, // null value
false // no separation
);
average *= invSumWeight;
}
// ************************************************************************* //

View file

@ -1,874 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*----------------------------------------------------------------------------*/
#include "autoRefineDriver.H"
#include "meshRefinement.H"
#include "fvMesh.H"
#include "Time.H"
#include "cellSet.H"
#include "syncTools.H"
#include "refinementParameters.H"
#include "featureEdgeMesh.H"
#include "refinementSurfaces.H"
#include "shellSurfaces.H"
#include "mapDistributePolyMesh.H"
#include "mathematicalConstants.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(autoRefineDriver, 0);
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Read explicit feature edges
Foam::label Foam::autoRefineDriver::readFeatureEdges
(
const PtrList<dictionary>& featDicts,
PtrList<featureEdgeMesh>& featureMeshes,
labelList& featureLevels
) const
{
Info<< "Reading external feature lines." << endl;
const fvMesh& mesh = meshRefiner_.mesh();
featureMeshes.setSize(featDicts.size());
featureLevels.setSize(featDicts.size());
forAll(featDicts, i)
{
const dictionary& dict = featDicts[i];
fileName featFileName(dict.lookup("file"));
featureMeshes.set
(
i,
new featureEdgeMesh
(
IOobject
(
featFileName, // name
//mesh.time().findInstance("triSurface", featFileName),
// // instance
mesh.time().constant(), // instance
"triSurface", // local
mesh.time(), // registry
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
)
);
featureMeshes[i].mergePoints(meshRefiner_.mergeDistance());
featureLevels[i] = readLabel(dict.lookup("level"));
Info<< "Refinement level " << featureLevels[i]
<< " for all cells crossed by feature " << featFileName
<< " (" << featureMeshes[i].points().size() << " points, "
<< featureMeshes[i].edges().size() << " edges)." << endl;
}
Info<< "Read feature lines in = "
<< mesh.time().cpuTimeIncrement() << " s" << nl << endl;
return featureMeshes.size();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
Foam::autoRefineDriver::autoRefineDriver
(
meshRefinement& meshRefiner,
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelList& globalToPatch
)
:
meshRefiner_(meshRefiner),
decomposer_(decomposer),
distributor_(distributor),
globalToPatch_(globalToPatch)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::label Foam::autoRefineDriver::featureEdgeRefine
(
const refinementParameters& refineParams,
const PtrList<dictionary>& featDicts,
const label maxIter,
const label minRefine
)
{
const fvMesh& mesh = meshRefiner_.mesh();
// Read explicit feature edges
PtrList<featureEdgeMesh> featureMeshes;
// Per feature the refinement level
labelList featureLevels;
readFeatureEdges(featDicts, featureMeshes, featureLevels);
label iter = 0;
if (featureMeshes.size() && maxIter > 0)
{
for (; iter < maxIter; iter++)
{
Info<< nl
<< "Feature refinement iteration " << iter << nl
<< "------------------------------" << nl
<< endl;
labelList candidateCells
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints()[0], // For now only use one.
refineParams.curvature(),
featureMeshes,
featureLevels,
true, // featureRefinement
false, // internalRefinement
false, // surfaceRefinement
false, // curvatureRefinement
refineParams.maxGlobalCells(),
refineParams.maxLocalCells()
)
);
labelList cellsToRefine
(
meshRefiner_.meshCutter().consistentRefinement
(
candidateCells,
true
)
);
Info<< "Determined cells to refine in = "
<< mesh.time().cpuTimeIncrement() << " s" << endl;
label nCellsToRefine = cellsToRefine.size();
reduce(nCellsToRefine, sumOp<label>());
Info<< "Selected for feature refinement : " << nCellsToRefine
<< " cells (out of " << mesh.globalData().nTotalCells()
<< ')' << endl;
if (nCellsToRefine <= minRefine)
{
Info<< "Stopping refining since too few cells selected."
<< nl << endl;
break;
}
if (debug > 0)
{
const_cast<Time&>(mesh.time())++;
}
if
(
returnReduce
(
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
)
)
{
meshRefiner_.balanceAndRefine
(
"feature refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
else
{
meshRefiner_.refineAndBalance
(
"feature refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
}
}
return iter;
}
Foam::label Foam::autoRefineDriver::surfaceOnlyRefine
(
const refinementParameters& refineParams,
const label maxIter
)
{
const fvMesh& mesh = meshRefiner_.mesh();
// Determine the maximum refinement level over all surfaces. This
// determines the minumum number of surface refinement iterations.
label overallMaxLevel = max(meshRefiner_.surfaces().maxLevel());
label iter;
for (iter = 0; iter < maxIter; iter++)
{
Info<< nl
<< "Surface refinement iteration " << iter << nl
<< "------------------------------" << nl
<< endl;
// Determine cells to refine
// ~~~~~~~~~~~~~~~~~~~~~~~~~
// Only look at surface intersections (minLevel and surface curvature),
// do not do internal refinement (refinementShells)
const PtrList<featureEdgeMesh> dummyFeatures;
PtrList<featureEdgeMesh> dummy(0);
labelList candidateCells
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints()[0],
refineParams.curvature(),
dummyFeatures, // dummy featureMeshes;
labelList(0), // dummy featureLevels;
false, // featureRefinement
false, // internalRefinement
true, // surfaceRefinement
true, // curvatureRefinement
refineParams.maxGlobalCells(),
refineParams.maxLocalCells()
)
);
labelList cellsToRefine
(
meshRefiner_.meshCutter().consistentRefinement
(
candidateCells,
true
)
);
Info<< "Determined cells to refine in = "
<< mesh.time().cpuTimeIncrement() << " s" << endl;
label nCellsToRefine = cellsToRefine.size();
reduce(nCellsToRefine, sumOp<label>());
Info<< "Selected for refinement : " << nCellsToRefine
<< " cells (out of " << mesh.globalData().nTotalCells()
<< ')' << endl;
// Stop when no cells to refine or have done minimum nessecary
// iterations and not enough cells to refine.
if
(
nCellsToRefine == 0
|| (
iter >= overallMaxLevel
&& nCellsToRefine <= refineParams.minRefineCells()
)
)
{
Info<< "Stopping refining since too few cells selected."
<< nl << endl;
break;
}
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
if
(
returnReduce
(
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
)
)
{
meshRefiner_.balanceAndRefine
(
"surface refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
else
{
meshRefiner_.refineAndBalance
(
"surface refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
}
return iter;
}
void Foam::autoRefineDriver::removeInsideCells
(
const refinementParameters& refineParams,
const label nBufferLayers
)
{
Info<< nl
<< "Removing mesh beyond surface intersections" << nl
<< "------------------------------------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
meshRefiner_.splitMesh
(
nBufferLayers, // nBufferLayers
globalToPatch_,
refineParams.keepPoints()[0]
);
if (debug)
{
Pout<< "Writing subsetted mesh to time "
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
Pout<< "Dumped mesh in = "
<< mesh.time().cpuTimeIncrement() << " s\n" << nl << endl;
}
}
Foam::label Foam::autoRefineDriver::shellRefine
(
const refinementParameters& refineParams,
const label maxIter
)
{
const fvMesh& mesh = meshRefiner_.mesh();
// Mark current boundary faces with 0. Have meshRefiner maintain them.
meshRefiner_.userFaceData().setSize(1);
// mark list to remove any refined faces
meshRefiner_.userFaceData()[0].first() = meshRefinement::REMOVE;
meshRefiner_.userFaceData()[0].second() = createWithValues<labelList>
(
mesh.nFaces(),
-1,
meshRefiner_.intersectedFaces(),
0
);
// Determine the maximum refinement level over all volume refinement
// regions. This determines the minumum number of shell refinement
// iterations.
label overallMaxShellLevel = meshRefiner_.shells().maxLevel();
label iter;
for (iter = 0; iter < maxIter; iter++)
{
Info<< nl
<< "Shell refinement iteration " << iter << nl
<< "----------------------------" << nl
<< endl;
const PtrList<featureEdgeMesh> dummyFeatures;
PtrList<featureEdgeMesh> dummy(0);
labelList candidateCells
(
meshRefiner_.refineCandidates
(
refineParams.keepPoints()[0],
refineParams.curvature(),
dummyFeatures, // dummy featureMeshes;
labelList(0), // dummy featureLevels;
false, // featureRefinement
true, // internalRefinement
false, // surfaceRefinement
false, // curvatureRefinement
refineParams.maxGlobalCells(),
refineParams.maxLocalCells()
)
);
if (debug)
{
Pout<< "Dumping " << candidateCells.size()
<< " cells to cellSet candidateCellsFromShells." << endl;
cellSet
(
mesh,
"candidateCellsFromShells",
labelHashSet(candidateCells)
).write();
}
// Problem choosing starting faces for bufferlayers (bFaces)
// - we can't use the current intersected boundary faces
// (intersectedFaces) since this grows indefinitely
// - if we use 0 faces we don't satisfy bufferLayers from the
// surface.
// - possibly we want to have bFaces only the initial set of faces
// and maintain the list while doing the refinement.
labelList bFaces
(
findIndices(meshRefiner_.userFaceData()[0].second(), 0)
);
//Info<< "Collected boundary faces : "
// << returnReduce(bFaces.size(), sumOp<label>()) << endl;
labelList cellsToRefine;
if (refineParams.nBufferLayers() <= 2)
{
cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement
(
refineParams.nBufferLayers(),
candidateCells, // cells to refine
bFaces, // faces for nBufferLayers
1, // point difference
meshRefiner_.intersectedPoints() // points to check
);
}
else
{
cellsToRefine = meshRefiner_.meshCutter().consistentSlowRefinement2
(
refineParams.nBufferLayers(),
candidateCells, // cells to refine
bFaces // faces for nBufferLayers
);
}
Info<< "Determined cells to refine in = "
<< mesh.time().cpuTimeIncrement() << " s" << endl;
label nCellsToRefine = cellsToRefine.size();
reduce(nCellsToRefine, sumOp<label>());
Info<< "Selected for internal refinement : " << nCellsToRefine
<< " cells (out of " << mesh.globalData().nTotalCells()
<< ')' << endl;
// Stop when no cells to refine or have done minimum nessecary
// iterations and not enough cells to refine.
if
(
nCellsToRefine == 0
|| (
iter >= overallMaxShellLevel
&& nCellsToRefine <= refineParams.minRefineCells()
)
)
{
Info<< "Stopping refining since too few cells selected."
<< nl << endl;
break;
}
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
if
(
returnReduce
(
(mesh.nCells() >= refineParams.maxLocalCells()),
orOp<bool>()
)
)
{
meshRefiner_.balanceAndRefine
(
"shell refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
else
{
meshRefiner_.refineAndBalance
(
"shell refinement iteration " + name(iter),
decomposer_,
distributor_,
cellsToRefine,
refineParams.maxLoadUnbalance()
);
}
}
meshRefiner_.userFaceData().clear();
return iter;
}
void Foam::autoRefineDriver::baffleAndSplitMesh
(
const refinementParameters& refineParams,
const bool handleSnapProblems,
const dictionary& motionDict
)
{
Info<< nl
<< "Splitting mesh at surface intersections" << nl
<< "---------------------------------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
// Introduce baffles at surface intersections. Note:
// meshRefiment::surfaceIndex() will
// be like boundary face from now on so not coupled anymore.
meshRefiner_.baffleAndSplitMesh
(
handleSnapProblems, // detect&remove potential snap problem
false, // perpendicular edge connected cells
scalarField(0), // per region perpendicular angle
!handleSnapProblems, // merge free standing baffles?
motionDict,
const_cast<Time&>(mesh.time()),
globalToPatch_,
refineParams.keepPoints()[0]
);
}
void Foam::autoRefineDriver::zonify
(
const refinementParameters& refineParams
)
{
// Mesh is at its finest. Do zoning
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// This puts all faces with intersection across a zoneable surface
// into that surface's faceZone. All cells inside faceZone get given the
// same cellZone.
if (meshRefiner_.surfaces().getNamedSurfaces().size())
{
Info<< nl
<< "Introducing zones for interfaces" << nl
<< "--------------------------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
meshRefiner_.zonify
(
refineParams.keepPoints()[0],
refineParams.allowFreeStandingZoneFaces()
);
if (debug)
{
Pout<< "Writing zoned mesh to time "
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write
(
debug,
mesh.time().path()/meshRefiner_.timeName()
);
}
// Check that all faces are synced
meshRefinement::checkCoupledFaceZones(mesh);
}
}
void Foam::autoRefineDriver::splitAndMergeBaffles
(
const refinementParameters& refineParams,
const bool handleSnapProblems,
const dictionary& motionDict
)
{
Info<< nl
<< "Handling cells with snap problems" << nl
<< "---------------------------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
// Introduce baffles and split mesh
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
const scalarField& perpAngle = meshRefiner_.surfaces().perpendicularAngle();
meshRefiner_.baffleAndSplitMesh
(
handleSnapProblems,
handleSnapProblems, // remove perp edge connected cells
perpAngle, // perp angle
false, // merge free standing baffles?
motionDict,
const_cast<Time&>(mesh.time()),
globalToPatch_,
refineParams.keepPoints()[0]
);
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
// Duplicate points on baffles that are on more than one cell
// region. This will help snapping pull them to separate surfaces.
meshRefiner_.dupNonManifoldPoints();
// Merge all baffles that are still remaining after duplicating points.
List<labelPair> couples
(
meshRefiner_.getDuplicateFaces // get all baffles
(
identity(mesh.nFaces()-mesh.nInternalFaces())
+ mesh.nInternalFaces()
)
);
label nCouples = returnReduce(couples.size(), sumOp<label>());
Info<< "Detected unsplittable baffles : "
<< nCouples << endl;
if (nCouples > 0)
{
// Actually merge baffles. Note: not exactly parallellized. Should
// convert baffle faces into processor faces if they resulted
// from them.
meshRefiner_.mergeBaffles(couples);
if (debug)
{
// Debug:test all is still synced across proc patches
meshRefiner_.checkData();
}
Info<< "Merged free-standing baffles in = "
<< mesh.time().cpuTimeIncrement() << " s." << endl;
}
if (debug)
{
Pout<< "Writing handleProblemCells mesh to time "
<< meshRefiner_.timeName() << '.' << endl;
meshRefiner_.write(debug, mesh.time().path()/meshRefiner_.timeName());
}
}
void Foam::autoRefineDriver::mergePatchFaces
(
const refinementParameters& refineParams
)
{
const fvMesh& mesh = meshRefiner_.mesh();
Info<< nl
<< "Merge refined boundary faces" << nl
<< "----------------------------" << nl
<< endl;
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
meshRefiner_.mergePatchFaces
(
Foam::cos(45*mathematicalConstant::pi/180.0),
Foam::cos(45*mathematicalConstant::pi/180.0),
meshRefiner_.meshedPatches()
);
if (debug)
{
meshRefiner_.checkData();
}
meshRefiner_.mergeEdges(Foam::cos(45*mathematicalConstant::pi/180.0));
if (debug)
{
meshRefiner_.checkData();
}
}
void Foam::autoRefineDriver::doRefine
(
const dictionary& refineDict,
const refinementParameters& refineParams,
const bool prepareForSnapping,
const dictionary& motionDict
)
{
Info<< nl
<< "Refinement phase" << nl
<< "----------------" << nl
<< endl;
const fvMesh& mesh = meshRefiner_.mesh();
// Check that all the keep points are inside the mesh.
refineParams.findCells(mesh);
PtrList<dictionary> featDicts(refineDict.lookup("features"));
// Refine around feature edges
featureEdgeRefine
(
refineParams,
featDicts,
100, // maxIter
0 // min cells to refine
);
// Refine based on surface
surfaceOnlyRefine
(
refineParams,
100 // maxIter
);
// Remove cells (a certain distance) beyond surface intersections
removeInsideCells
(
refineParams,
1 // nBufferLayers
);
// Internal mesh refinement
shellRefine
(
refineParams,
100 // maxIter
);
// Introduce baffles at surface intersections
baffleAndSplitMesh(refineParams, prepareForSnapping, motionDict);
// Mesh is at its finest. Do optional zoning.
zonify(refineParams);
// Pull baffles apart
splitAndMergeBaffles(refineParams, prepareForSnapping, motionDict);
// Do something about cells with refined faces on the boundary
if (prepareForSnapping)
{
mergePatchFaces(refineParams);
}
if (Pstream::parRun())
{
Info<< nl
<< "Doing final balancing" << nl
<< "---------------------" << nl
<< endl;
if (debug)
{
const_cast<Time&>(mesh.time())++;
}
// Do final balancing. Keep zoned faces on one processor since the
// snap phase will convert them to baffles and this only works for
// internal faces.
meshRefiner_.balance
(
true,
false,
scalarField(mesh.nCells(), 1), // dummy weights
decomposer_,
distributor_
);
}
}
// ************************************************************************* //

View file

@ -1,183 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::autoRefineDriver
Description
SourceFiles
autoRefineDriver.C
\*---------------------------------------------------------------------------*/
#ifndef autoRefineDriver_H
#define autoRefineDriver_H
#include "treeBoundBox.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class featureEdgeMesh;
class refinementParameters;
class meshRefinement;
class decompositionMethod;
class fvMeshDistribute;
/*---------------------------------------------------------------------------*\
Class autoRefineDriver Declaration
\*---------------------------------------------------------------------------*/
class autoRefineDriver
{
// Private data
//- Mesh+surface
meshRefinement& meshRefiner_;
//- Reference to decomposition method
decompositionMethod& decomposer_;
//- Reference to mesh distribution engine
fvMeshDistribute& distributor_;
//- From surface region to patch
const labelList globalToPatch_;
// Private Member Functions
//- Read explicit feature edges
label readFeatureEdges
(
const PtrList<dictionary>& featDicts,
PtrList<featureEdgeMesh>& featureMeshes,
labelList& featureLevel
) const;
//- Refine all cells pierced by explicit feature edges
label featureEdgeRefine
(
const refinementParameters& refineParams,
const PtrList<dictionary>& featDicts,
const label maxIter,
const label minRefine
);
//- Refine all cells interacting with the surface
label surfaceOnlyRefine
(
const refinementParameters& refineParams,
const label maxIter
);
//- Remove all cells within intersected region
void removeInsideCells
(
const refinementParameters& refineParams,
const label nBufferLayers
);
//- Remove all cells inside/outside shell
label shellRefine
(
const refinementParameters& refineParams,
const label maxIter
);
//- Add baffles and remove unreachable cells
void baffleAndSplitMesh
(
const refinementParameters& refineParams,
const bool handleSnapProblems,
const dictionary& motionDict
);
//- Add zones
void zonify(const refinementParameters& refineParams);
void splitAndMergeBaffles
(
const refinementParameters& refineParams,
const bool handleSnapProblems,
const dictionary& motionDict
);
//- Merge refined boundary faces (from exposing coarser cell)
void mergePatchFaces
(
const refinementParameters& refineParams
);
//- Disallow default bitwise copy construct
autoRefineDriver(const autoRefineDriver&);
//- Disallow default bitwise assignment
void operator=(const autoRefineDriver&);
public:
//- Runtime type information
ClassName("autoRefineDriver");
// Constructors
//- Construct from components
autoRefineDriver
(
meshRefinement& meshRefiner,
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelList& globalToPatch
);
// Member Functions
//- Do all the refinement
void doRefine
(
const dictionary& refineDict,
const refinementParameters& refineParams,
const bool prepareForSnapping,
const dictionary& motionDict
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,242 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::autoSnapDriver
Description
All to do with snapping to surface
SourceFiles
autoSnapDriver.C
\*---------------------------------------------------------------------------*/
#ifndef autoSnapDriver_H
#define autoSnapDriver_H
#include "PackedBoolList.H"
#include "meshRefinement.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of classes
class motionSmoother;
class snapParameters;
/*---------------------------------------------------------------------------*\
Class autoSnapDriver Declaration
\*---------------------------------------------------------------------------*/
class autoSnapDriver
{
// Private classes
//- Combine operator class for equalizing displacements.
class minMagEqOp
{
public:
void operator()(vector& x, const vector& y) const
{
if (magSqr(y) < magSqr(x))
{
x = y;
}
}
};
// Private data
//- Mesh+surface
meshRefinement& meshRefiner_;
//- From surface region to patch
const labelList globalToPatch_;
// Private Member Functions
// Snapping
//- Get faces to repatch. Returns map from face to patch.
Map<label> getZoneBafflePatches(const bool allowBoundary) const;
//- Calculates (geometric) shared points
static label getCollocatedPoints
(
const scalar tol,
const pointField&,
PackedBoolList&
);
//- Calculate displacement per patch point to smooth out patch.
// Quite complicated in determining which points to move where.
pointField smoothPatchDisplacement
(
const motionSmoother&,
const List<labelPair>&
) const;
//- Check that face zones are synced
void checkCoupledFaceZones() const;
//- Per edge distance to patch
static tmp<scalarField> edgePatchDist
(
const pointMesh&,
const indirectPrimitivePatch&
);
//- Write displacement as .obj file.
static void dumpMove
(
const fileName&,
const pointField&,
const pointField&
);
//- Check displacement is outwards pointing
static bool outwardsDisplacement
(
const indirectPrimitivePatch&,
const vectorField&
);
//- Disallow default bitwise copy construct
autoSnapDriver(const autoSnapDriver&);
//- Disallow default bitwise assignment
void operator=(const autoSnapDriver&);
public:
//- Runtime type information
ClassName("autoSnapDriver");
// Constructors
//- Construct from components
autoSnapDriver
(
meshRefinement& meshRefiner,
const labelList& globalToPatch
);
// Member Functions
// Snapping
//- Create baffles for faces straddling zoned surfaces. Return
// baffles.
autoPtr<mapPolyMesh> createZoneBaffles(List<labelPair>&);
//- Merge baffles.
autoPtr<mapPolyMesh> mergeZoneBaffles(const List<labelPair>&);
//- Calculate edge length per patch point.
scalarField calcSnapDistance
(
const snapParameters& snapParams,
const indirectPrimitivePatch&
) const;
//- Smooth the mesh (patch and internal) to increase visibility
// of surface points (on castellated mesh) w.r.t. surface.
void preSmoothPatch
(
const snapParameters& snapParams,
const label nInitErrors,
const List<labelPair>& baffles,
motionSmoother&
) const;
//- Get points both on patch and facezone.
labelList getZoneSurfacePoints
(
const indirectPrimitivePatch&,
const word& zoneName
) const;
//- Per patch point calculate point on nearest surface. Set as
// boundary conditions of motionSmoother displacement field. Return
// displacement of patch points.
vectorField calcNearestSurface
(
const scalarField& snapDist,
motionSmoother& meshMover
) const;
//- Smooth the displacement field to the internal.
void smoothDisplacement
(
const snapParameters& snapParams,
motionSmoother&
) const;
//- Do the hard work: move the mesh according to displacement,
// locally relax the displacement.
void scaleMesh
(
const snapParameters& snapParams,
const label nInitErrors,
const List<labelPair>& baffles,
motionSmoother&
);
//- Repatch faces according to surface nearest the face centre
autoPtr<mapPolyMesh> repatchToSurface
(
const snapParameters& snapParams,
const labelList& adaptPatchIDs
);
void doSnap
(
const dictionary& snapDict,
const dictionary& motionDict,
const snapParameters& snapParams
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,384 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "layerParameters.H"
#include "polyBoundaryMesh.H"
#include "mathematicalConstants.H"
#include "refinementSurfaces.H"
#include "searchableSurfaces.H"
#include "regExp.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::scalar Foam::layerParameters::defaultConcaveAngle = 90;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Read the number of layers from dictionary. Per patch 0 or the number
// of layers.
Foam::labelList Foam::layerParameters::readNumLayers
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const polyBoundaryMesh& boundaryMesh
)
{
// Per surface the number of layers
labelList globalSurfLayers(surfaceDicts.size());
// Per surface, per region the number of layers
List<Map<label> > regionSurfLayers(surfaceDicts.size());
const labelList& surfaceIndices = refineSurfaces.surfaces();
forAll(surfaceDicts, surfI)
{
const dictionary& dict = surfaceDicts[surfI];
globalSurfLayers[surfI] = readLabel(dict.lookup("surfaceLayers"));
if (dict.found("regions"))
{
// Per-region layer information
PtrList<dictionary> regionDicts(dict.lookup("regions"));
const wordList& regionNames =
refineSurfaces.geometry()[surfaceIndices[surfI]].regions();
forAll(regionDicts, dictI)
{
const dictionary& regionDict = regionDicts[dictI];
const word regionName(regionDict.lookup("name"));
label regionI = findIndex(regionNames, regionName);
label nLayers = readLabel(regionDict.lookup("surfaceLayers"));
Info<< " region " << regionName << ':'<< nl
<< " surface layers:" << nLayers << nl;
regionSurfLayers[surfI].insert(regionI, nLayers);
}
}
}
// Transfer per surface/region information into patchwise region info
labelList nLayers(boundaryMesh.size(), 0);
forAll(surfaceIndices, surfI)
{
const wordList& regionNames =
refineSurfaces.geometry()[surfaceIndices[surfI]].regions();
forAll(regionNames, regionI)
{
const word& regionName = regionNames[regionI];
label global = refineSurfaces.globalRegion(surfI, regionI);
label patchI = globalToPatch[global];
// Initialise to surface-wise layers
nLayers[patchI] = globalSurfLayers[surfI];
// Override with region specific data if available
Map<label>::const_iterator iter =
regionSurfLayers[surfI].find(regionI);
if (iter != regionSurfLayers[surfI].end())
{
nLayers[patchI] = iter();
}
// Check
if (nLayers[patchI] < 0)
{
FatalErrorIn
(
"layerParameters::readNumLayers(..)"
) << "Illegal number of layers " << nLayers[patchI]
<< " for surface "
<< refineSurfaces.names()[surfI]
<< " region " << regionName << endl
<< exit(FatalError);
}
}
}
return nLayers;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::layerParameters::layerParameters
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const dictionary& dict,
const polyBoundaryMesh& boundaryMesh
)
:
numLayers_
(
readNumLayers
(
surfaceDicts,
refineSurfaces,
globalToPatch,
boundaryMesh
)
),
expansionRatio_
(
numLayers_.size(),
readScalar(dict.lookup("expansionRatio"))
),
relativeSizes_(false),
finalLayerThickness_
(
numLayers_.size(),
readScalar(dict.lookup("finalLayerRatio"))
),
minThickness_
(
numLayers_.size(),
readScalar(dict.lookup("minThickness"))
),
featureAngle_(readScalar(dict.lookup("featureAngle"))),
concaveAngle_
(
dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)
),
nGrow_(readLabel(dict.lookup("nGrow"))),
nSmoothSurfaceNormals_
(
readLabel(dict.lookup("nSmoothSurfaceNormals"))
),
nSmoothNormals_(readLabel(dict.lookup("nSmoothNormals"))),
nSmoothThickness_(readLabel(dict.lookup("nSmoothThickness"))),
maxFaceThicknessRatio_
(
readScalar(dict.lookup("maxFaceThicknessRatio"))
),
layerTerminationCos_
(
Foam::cos
(
0.5
* featureAngle_
* mathematicalConstant::pi/180.
)
),
maxThicknessToMedialRatio_
(
readScalar(dict.lookup("maxThicknessToMedialRatio"))
),
minMedianAxisAngleCos_
(
Foam::cos(readScalar(dict.lookup("minMedianAxisAngle")))
* mathematicalConstant::pi/180.
),
nBufferCellsNoExtrude_
(
readLabel(dict.lookup("nBufferCellsNoExtrude"))
),
nSnap_(readLabel(dict.lookup("nSnap"))),
nLayerIter_(readLabel(dict.lookup("nLayerIter"))),
nRelaxedIter_(labelMax)
{
if (dict.found("nRelaxedIter"))
{
dict.lookup("nRelaxedIter") >> nRelaxedIter_;
}
if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
{
FatalErrorIn("layerParameters::layerParameters(..)")
<< "Layer iterations should be >= 0." << endl
<< "nLayerIter:" << nLayerIter_
<< " nRelaxedIter:" << nRelaxedIter_
<< exit(FatalError);
}
}
// Construct from dictionary
Foam::layerParameters::layerParameters
(
const dictionary& dict,
const polyBoundaryMesh& boundaryMesh
)
:
numLayers_(boundaryMesh.size(), 0),
expansionRatio_
(
boundaryMesh.size(),
readScalar(dict.lookup("expansionRatio"))
),
relativeSizes_(dict.lookup("relativeSizes")),
finalLayerThickness_
(
boundaryMesh.size(),
readScalar(dict.lookup("finalLayerThickness"))
),
minThickness_
(
boundaryMesh.size(),
readScalar(dict.lookup("minThickness"))
),
featureAngle_(readScalar(dict.lookup("featureAngle"))),
concaveAngle_
(
dict.lookupOrDefault("concaveAngle", defaultConcaveAngle)
),
nGrow_(readLabel(dict.lookup("nGrow"))),
nSmoothSurfaceNormals_
(
readLabel(dict.lookup("nSmoothSurfaceNormals"))
),
nSmoothNormals_(readLabel(dict.lookup("nSmoothNormals"))),
nSmoothThickness_(readLabel(dict.lookup("nSmoothThickness"))),
maxFaceThicknessRatio_
(
readScalar(dict.lookup("maxFaceThicknessRatio"))
),
layerTerminationCos_
(
Foam::cos
(
0.5
* featureAngle_
* mathematicalConstant::pi/180.
)
),
maxThicknessToMedialRatio_
(
readScalar(dict.lookup("maxThicknessToMedialRatio"))
),
minMedianAxisAngleCos_
(
Foam::cos(readScalar(dict.lookup("minMedianAxisAngle")))
* mathematicalConstant::pi/180.
),
nBufferCellsNoExtrude_
(
readLabel(dict.lookup("nBufferCellsNoExtrude"))
),
nSnap_(readLabel(dict.lookup("nRelaxIter"))),
nLayerIter_(readLabel(dict.lookup("nLayerIter"))),
nRelaxedIter_(labelMax)
{
if (dict.found("nRelaxedIter"))
{
dict.lookup("nRelaxedIter") >> nRelaxedIter_;
}
if (nLayerIter_ < 0 || nRelaxedIter_ < 0)
{
FatalErrorIn("layerParameters::layerParameters(..)")
<< "Layer iterations should be >= 0." << endl
<< "nLayerIter:" << nLayerIter_
<< " nRelaxedIter:" << nRelaxedIter_
<< exit(FatalError);
}
const dictionary& layersDict = dict.subDict("layers");
forAll(boundaryMesh, patchI)
{
const word& patchName = boundaryMesh[patchI].name();
if (layersDict.found(patchName))
{
const dictionary& layerDict = layersDict.subDict(patchName);
numLayers_[patchI] =
readLabel(layerDict.lookup("nSurfaceLayers"));
layerDict.readIfPresent
(
"expansionRatio",
expansionRatio_[patchI]
);
layerDict.readIfPresent
(
"finalLayerThickness",
finalLayerThickness_[patchI]
);
layerDict.readIfPresent
(
"minThickness",
minThickness_[patchI]
);
}
}
// Check whether layer specification matches any patches
const List<keyType> wildCards = layersDict.keys(true);
forAll(wildCards, i)
{
regExp re(wildCards[i]);
bool hasMatch = false;
forAll(boundaryMesh, patchI)
{
if (re.match(boundaryMesh[patchI].name()))
{
hasMatch = true;
break;
}
}
if (!hasMatch)
{
IOWarningIn("layerParameters::layerParameters(..)", layersDict)
<< "Wildcard layer specification for " << wildCards[i]
<< " does not match any patch." << endl;
}
}
const List<keyType> nonWildCards = layersDict.keys(false);
forAll(nonWildCards, i)
{
if (boundaryMesh.findPatchID(nonWildCards[i]) == -1)
{
IOWarningIn("layerParameters::layerParameters(..)", layersDict)
<< "Layer specification for " << nonWildCards[i]
<< " does not match any patch." << endl;
}
}
}
// ************************************************************************* //

View file

@ -1,290 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::layerParameters
Description
Simple container to keep together layer specific information.
SourceFiles
layerParameters.C
\*---------------------------------------------------------------------------*/
#ifndef layerParameters_H
#define layerParameters_H
#include "dictionary.H"
#include "scalarField.H"
#include "labelList.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class polyBoundaryMesh;
class refinementSurfaces;
/*---------------------------------------------------------------------------*\
Class layerParameters Declaration
\*---------------------------------------------------------------------------*/
class layerParameters
{
// Static data members
//- Default angle for faces to be convcave
static const scalar defaultConcaveAngle;
// Private data
// Per patch (not region!) information
//- How many layers to add.
labelList numLayers_;
scalarField expansionRatio_;
Switch relativeSizes_;
scalarField finalLayerThickness_;
scalarField minThickness_;
scalar featureAngle_;
scalar concaveAngle_;
label nGrow_;
label nSmoothSurfaceNormals_;
label nSmoothNormals_;
label nSmoothThickness_;
scalar maxFaceThicknessRatio_;
scalar layerTerminationCos_;
scalar maxThicknessToMedialRatio_;
scalar minMedianAxisAngleCos_;
label nBufferCellsNoExtrude_;
label nSnap_;
label nLayerIter_;
label nRelaxedIter_;
// Private Member Functions
//- Extract patch-wise number of layers
static labelList readNumLayers
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const polyBoundaryMesh& boundaryMesh
);
//- Disallow default bitwise copy construct
layerParameters(const layerParameters&);
//- Disallow default bitwise assignment
void operator=(const layerParameters&);
public:
// Constructors
//- Construct from dictionary - old syntax
layerParameters
(
const PtrList<dictionary>& surfaceDicts,
const refinementSurfaces& refineSurfaces,
const labelList& globalToPatch,
const dictionary& dict,
const polyBoundaryMesh& boundaryMesh
);
//- Construct from dictionary - new syntax
layerParameters(const dictionary& dict, const polyBoundaryMesh&);
// Member Functions
// Access
// Per patch information
//- How many layers to add.
const labelList& numLayers() const
{
return numLayers_;
}
// Expansion factor for layer mesh
const scalarField& expansionRatio() const
{
return expansionRatio_;
}
//- Are size parameters relative to inner cell size or
// absolute distances.
bool relativeSizes() const
{
return relativeSizes_;
}
//- Wanted thickness of final added cell layer. If multiple
// layers is the thickness of the layer furthest away
// from the wall (i.e. nearest the original mesh)
// If relativeSize() this number is relative to undistorted
// size of the cell outside layer.
const scalarField& finalLayerThickness() const
{
return finalLayerThickness_;
}
//- Minimum thickness of cell layer. If for any reason layer
// cannot be above minThickness do not add layer.
// If relativeSize() this number is relative to undistorted
// size of the cell outside layer.
const scalarField& minThickness() const
{
return minThickness_;
}
scalar featureAngle() const
{
return featureAngle_;
}
scalar concaveAngle() const
{
return concaveAngle_;
}
//- If points get not extruded do nGrow layers of connected faces
// that are not grown. Is used to not do layers at all close to
// features.
label nGrow() const
{
return nGrow_;
}
//- Number of smoothing iterations of surface normals
label nSmoothSurfaceNormals() const
{
return nSmoothSurfaceNormals_;
}
//- Number of smoothing iterations of interior mesh movement
// direction
label nSmoothNormals() const
{
return nSmoothNormals_;
}
//- Stop layer growth on highly warped cells
scalar maxFaceThicknessRatio() const
{
return maxFaceThicknessRatio_;
}
scalar layerTerminationCos() const
{
return layerTerminationCos_;
}
//- Smooth layer thickness over surface patches
label nSmoothThickness() const
{
return nSmoothThickness_;
}
//- Reduce layer growth where ratio thickness to medial
// distance is large
scalar maxThicknessToMedialRatio() const
{
return maxThicknessToMedialRatio_;
}
//- Angle used to pick up medial axis points
scalar minMedianAxisAngleCos() const
{
return minMedianAxisAngleCos_;
}
//- Create buffer region for new layer terminations
label nBufferCellsNoExtrude() const
{
return nBufferCellsNoExtrude_;
}
label nSnap() const
{
return nSnap_;
}
// Overall
//- Number of overall layer addition iterations
label nLayerIter() const
{
return nLayerIter_;
}
//- Number of iterations after which relaxed motion rules
// are to be used.
label nRelaxedIter() const
{
return nRelaxedIter_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,50 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pointData.H"
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const pointData& wDist)
{
if (os.format() == IOstream::ASCII)
{
return os
<< wDist.origin() << token::SPACE << wDist.distSqr()
<< token::SPACE << wDist.s() << token::SPACE << wDist.v();
}
else
{
return os
<< wDist.origin() << wDist.distSqr() << wDist.s() << wDist.v();
}
}
Foam::Istream& Foam::operator>>(Istream& is, pointData& wDist)
{
return is >> wDist.origin_ >> wDist.distSqr_ >> wDist.s_ >> wDist.v_;
}
// ************************************************************************* //

View file

@ -1,226 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::pointData
Description
Holds information regarding nearest wall point. Used in pointEdgeWave.
(so not standard meshWave)
To be used in wall distance calculation.
SourceFiles
pointDataI.H
pointData.C
\*---------------------------------------------------------------------------*/
#ifndef pointData_H
#define pointData_H
#include "point.H"
#include "label.H"
#include "tensor.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class polyPatch;
class polyMesh;
/*---------------------------------------------------------------------------*\
Class pointData Declaration
\*---------------------------------------------------------------------------*/
class pointData
{
// Private data
//- position of nearest wall center
point origin_;
//- normal distance (squared) from point to origin
scalar distSqr_;
//- additional information.
scalar s_;
//- additional information.
vector v_;
// Private Member Functions
//- Evaluate distance to point. Update distSqr, origin from whomever
// is nearer pt. Return true if w2 is closer to point,
// false otherwise.
inline bool update
(
const point&,
const pointData& w2,
const scalar tol
);
//- Combine current with w2. Update distSqr, origin if w2 has smaller
// quantities and returns true.
inline bool update
(
const pointData& w2,
const scalar tol
);
public:
// Constructors
//- Construct null
inline pointData();
//- Construct from origin, distance
inline pointData
(
const point& origin,
const scalar distSqr,
const scalar s,
const vector& v
);
//- Construct as copy
inline pointData(const pointData&);
// Member Functions
// Access
inline const point& origin() const;
inline scalar distSqr() const;
inline scalar s() const;
inline const vector& v() const;
// Needed by meshWave
//- Check whether origin has been changed at all or
// still contains original (invalid) value.
inline bool valid() const;
//- Check for identical geometrical data. Used for cyclics checking.
inline bool sameGeometry(const pointData&, const scalar tol)
const;
//- Convert origin to relative vector to leaving point
// (= point coordinate)
inline void leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
);
//- Convert relative origin to absolute by adding entering point
inline void enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& pos
);
//- Apply rotation matrix to origin
inline void transform(const tensor& rotTensor);
//- Influence of edge on point
inline bool updatePoint
(
const polyMesh& mesh,
const label pointI,
const label edgeI,
const pointData& edgeInfo,
const scalar tol
);
//- Influence of different value on same point.
// Merge new and old info.
inline bool updatePoint
(
const polyMesh& mesh,
const label pointI,
const pointData& newPointInfo,
const scalar tol
);
//- Influence of different value on same point.
// No information about current position whatsoever.
inline bool updatePoint
(
const pointData& newPointInfo,
const scalar tol
);
//- Influence of point on edge.
inline bool updateEdge
(
const polyMesh& mesh,
const label edgeI,
const label pointI,
const pointData& pointInfo,
const scalar tol
);
// Member Operators
//Note: Used to determine whether to call update.
inline bool operator==(const pointData&) const;
inline bool operator!=(const pointData&) const;
// IOstream Operators
friend Ostream& operator<<(Ostream&, const pointData&);
friend Istream& operator>>(Istream&, pointData&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pointDataI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,353 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "polyMesh.H"
#include "transform.H"
#include "wallPoint.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Update this with w2 if w2 nearer to pt.
inline bool Foam::pointData::update
(
const point& pt,
const pointData& w2,
const scalar tol
)
{
scalar dist2 = magSqr(pt - w2.origin());
if (!valid())
{
distSqr_ = dist2;
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
// if (v_ != w2.v())
// {
// return false;
// }
scalar diff = distSqr_ - dist2;
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = dist2;
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
}
// Update this with w2 (information on same point)
inline bool Foam::pointData::update
(
const pointData& w2,
const scalar tol
)
{
if (!valid())
{
// current not yet set so use any value
distSqr_ = w2.distSqr();
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
// if (v_ != w2.v())
// {
// return false;
// }
scalar diff = distSqr_ - w2.distSqr();
if (diff < 0)
{
// already nearer to pt
return false;
}
if ((diff < SMALL) || ((distSqr_ > SMALL) && (diff/distSqr_ < tol)))
{
// don't propagate small changes
return false;
}
else
{
// update with new values
distSqr_ = w2.distSqr();
origin_ = w2.origin();
s_ = w2.s();
v_ = w2.v();
return true;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Null constructor
inline Foam::pointData::pointData()
:
origin_(wallPoint::greatPoint),
distSqr_(GREAT),
s_(GREAT),
v_(wallPoint::greatPoint)
{}
// Construct from origin, distance
inline Foam::pointData::pointData
(
const point& origin,
const scalar distSqr,
const scalar s,
const vector& v
)
:
origin_(origin),
distSqr_(distSqr),
s_(s),
v_(v)
{}
// Construct as copy
inline Foam::pointData::pointData(const pointData& wpt)
:
origin_(wpt.origin()),
distSqr_(wpt.distSqr()),
s_(wpt.s()),
v_(wpt.v())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::point& Foam::pointData::origin() const
{
return origin_;
}
inline Foam::scalar Foam::pointData::distSqr() const
{
return distSqr_;
}
inline Foam::scalar Foam::pointData::s() const
{
return s_;
}
inline const Foam::vector& Foam::pointData::v() const
{
return v_;
}
inline bool Foam::pointData::valid() const
{
return origin_ != wallPoint::greatPoint;
}
// Checks for cyclic points
inline bool Foam::pointData::sameGeometry
(
const pointData& w2,
const scalar tol
) const
{
scalar diff = Foam::mag(distSqr() - w2.distSqr());
if (diff < SMALL)
{
return true;
}
else
{
if ((distSqr() > SMALL) && ((diff/distSqr()) < tol))
{
return true;
}
else
{
return false;
}
}
}
inline void Foam::pointData::leaveDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
)
{
origin_ -= coord;
}
inline void Foam::pointData::transform(const tensor& rotTensor)
{
origin_ = Foam::transform(rotTensor, origin_);
}
// Update absolute geometric quantities. Note that distance (distSqr_)
// is not affected by leaving/entering domain.
inline void Foam::pointData::enterDomain
(
const polyPatch& patch,
const label patchPointI,
const point& coord
)
{
// back to absolute form
origin_ += coord;
}
// Update this with information from connected edge
inline bool Foam::pointData::updatePoint
(
const polyMesh& mesh,
const label pointI,
const label edgeI,
const pointData& edgeInfo,
const scalar tol
)
{
return
update
(
mesh.points()[pointI],
edgeInfo,
tol
);
}
// Update this with new information on same point
inline bool Foam::pointData::updatePoint
(
const polyMesh& mesh,
const label pointI,
const pointData& newPointInfo,
const scalar tol
)
{
return
update
(
mesh.points()[pointI],
newPointInfo,
tol
);
}
// Update this with new information on same point. No extra information.
inline bool Foam::pointData::updatePoint
(
const pointData& newPointInfo,
const scalar tol
)
{
return update(newPointInfo, tol);
}
// Update this with information from connected point
inline bool Foam::pointData::updateEdge
(
const polyMesh& mesh,
const label edgeI,
const label pointI,
const pointData& pointInfo,
const scalar tol
)
{
const pointField& points = mesh.points();
const edge& e = mesh.edges()[edgeI];
const point edgeMid(0.5*(points[e[0]] + points[e[1]]));
return
update
(
edgeMid,
pointInfo,
tol
);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline bool Foam::pointData::operator==(const pointData& rhs) const
{
return origin() == rhs.origin();
}
inline bool Foam::pointData::operator!=(const pointData& rhs) const
{
return !(*this == rhs);
}
// ************************************************************************* //

View file

@ -1,140 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "refinementParameters.H"
#include "mathematicalConstants.H"
#include "polyMesh.H"
#include "globalIndex.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::refinementParameters::refinementParameters
(
const dictionary& dict,
const label dummy
)
:
maxGlobalCells_(readLabel(dict.lookup("cellLimit"))),
maxLocalCells_(readLabel(dict.lookup("procCellLimit"))),
minRefineCells_(readLabel(dict.lookup("minimumRefine"))),
curvature_(readScalar(dict.lookup("curvature"))),
nBufferLayers_(readLabel(dict.lookup("nBufferLayers"))),
keepPoints_(dict.lookup("keepPoints")),
allowFreeStandingZoneFaces_
(
dict.lookupOrDefault<Switch>
(
"allowFreeStandingZoneFaces",
true
)
),
maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
{}
Foam::refinementParameters::refinementParameters(const dictionary& dict)
:
maxGlobalCells_(readLabel(dict.lookup("maxGlobalCells"))),
maxLocalCells_(readLabel(dict.lookup("maxLocalCells"))),
minRefineCells_(readLabel(dict.lookup("minRefinementCells"))),
nBufferLayers_(readLabel(dict.lookup("nCellsBetweenLevels"))),
keepPoints_(pointField(1, dict.lookup("locationInMesh"))),
allowFreeStandingZoneFaces_
(
dict.lookupOrDefault<Switch>
(
"allowFreeStandingZoneFaces",
true
)
),
maxLoadUnbalance_(dict.lookupOrDefault<scalar>("maxLoadUnbalance",0))
{
scalar featAngle(readScalar(dict.lookup("resolveFeatureAngle")));
if (featAngle < 0 || featAngle > 180)
{
curvature_ = -GREAT;
}
else
{
curvature_ = Foam::cos(featAngle*mathematicalConstant::pi/180.0);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::labelList Foam::refinementParameters::findCells(const polyMesh& mesh)
const
{
// Global calculation engine
globalIndex globalCells(mesh.nCells());
// Cell label per point
labelList cellLabels(keepPoints_.size());
forAll(keepPoints_, i)
{
const point& keepPoint = keepPoints_[i];
label localCellI = mesh.findCell(keepPoint);
label globalCellI = -1;
if (localCellI != -1)
{
Pout<< "Found point " << keepPoint << " in cell " << localCellI
<< " on processor " << Pstream::myProcNo() << endl;
globalCellI = globalCells.toGlobal(localCellI);
}
reduce(globalCellI, maxOp<label>());
if (globalCellI == -1)
{
FatalErrorIn
(
"refinementParameters::findCells(const polyMesh&) const"
) << "Point " << keepPoint
<< " is not inside the mesh or on a face or edge." << nl
<< "Bounding box of the mesh:" << mesh.bounds()
<< exit(FatalError);
}
if (globalCells.isLocal(globalCellI))
{
cellLabels[i] = localCellI;
}
else
{
cellLabels[i] = -1;
}
}
return cellLabels;
}
// ************************************************************************* //

View file

@ -1,174 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::refinementParameters
Description
Simple container to keep together refinement specific information.
SourceFiles
refinementParameters.C
\*---------------------------------------------------------------------------*/
#ifndef refinementParameters_H
#define refinementParameters_H
#include "dictionary.H"
#include "pointField.H"
#include "Switch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class polyMesh;
/*---------------------------------------------------------------------------*\
Class refinementParameters Declaration
\*---------------------------------------------------------------------------*/
class refinementParameters
{
// Private data
//- Total number of cells
const label maxGlobalCells_;
//- Per processor max number of cells
const label maxLocalCells_;
//- When to stop refining
const label minRefineCells_;
//- Curvature
scalar curvature_;
//- Number of layers between different refinement levels
const label nBufferLayers_;
//- Areas to keep
const pointField keepPoints_;
//- FaceZone faces allowed which have owner and neighbour in same
// cellZone?
Switch allowFreeStandingZoneFaces_;
//- Allowed load unbalance
scalar maxLoadUnbalance_;
// Private Member Functions
//- Disallow default bitwise copy construct
refinementParameters(const refinementParameters&);
//- Disallow default bitwise assignment
void operator=(const refinementParameters&);
public:
// Constructors
//- Construct from dictionary - old syntax
refinementParameters(const dictionary& dict, const label dummy);
//- Construct from dictionary - new syntax
refinementParameters(const dictionary& dict);
// Member Functions
// Access
//- Total number of cells
label maxGlobalCells() const
{
return maxGlobalCells_;
}
//- Per processor max number of cells
label maxLocalCells() const
{
return maxLocalCells_;
}
//- When to stop refining
label minRefineCells() const
{
return minRefineCells_;
}
//- Curvature
scalar curvature() const
{
return curvature_;
}
//- Number of layers between different refinement levels
label nBufferLayers() const
{
return nBufferLayers_;
}
//- Areas to keep
const pointField& keepPoints() const
{
return keepPoints_;
}
//- Are zone faces allowed only inbetween different cell zones
// or also just free standing?
bool allowFreeStandingZoneFaces() const
{
return allowFreeStandingZoneFaces_;
}
//- Allowed load unbalance
scalar maxLoadUnbalance() const
{
return maxLoadUnbalance_;
}
// Other
//- Checks that cells are in mesh. Returns cells they are in.
labelList findCells(const polyMesh&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,53 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "snapParameters.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from dictionary
Foam::snapParameters::snapParameters(const dictionary& dict, const label dummy)
:
nSmoothPatch_(readLabel(dict.lookup("nSmoothPatch"))),
snapTol_(readScalar(dict.lookup("snapTol"))),
nSmoothDispl_(readLabel(dict.lookup("nSmoothDispl"))),
nSnap_(readLabel(dict.lookup("nSnap")))
{}
// Construct from dictionary
Foam::snapParameters::snapParameters(const dictionary& dict)
:
nSmoothPatch_(readLabel(dict.lookup("nSmoothPatch"))),
snapTol_(readScalar(dict.lookup("tolerance"))),
nSmoothDispl_(readLabel(dict.lookup("nSolveIter"))),
nSnap_(readLabel(dict.lookup("nRelaxIter")))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// ************************************************************************* //

View file

@ -1,128 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::snapParameters
Description
Simple container to keep together snap specific information.
SourceFiles
snapParameters.C
\*---------------------------------------------------------------------------*/
#ifndef snapParameters_H
#define snapParameters_H
#include "dictionary.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
/*---------------------------------------------------------------------------*\
Class snapParameters Declaration
\*---------------------------------------------------------------------------*/
class snapParameters
{
// Private data
const label nSmoothPatch_;
const scalar snapTol_;
const label nSmoothDispl_;
const label nSnap_;
// Private Member Functions
//- Disallow default bitwise copy construct
snapParameters(const snapParameters&);
//- Disallow default bitwise assignment
void operator=(const snapParameters&);
public:
// Constructors
//- Construct from dictionary - old syntax
snapParameters(const dictionary& dict, const label dummy);
//- Construct from dictionary - new syntax
snapParameters(const dictionary& dict);
// Member Functions
// Access
//- Number of patch smoothing iterations before finding
// correspondence to surface
label nSmoothPatch() const
{
return nSmoothPatch_;
}
//- Relative distance for points to be attracted by surface
// feature point
// or edge. True distance is this factor times local
// maximum edge length.
scalar snapTol() const
{
return snapTol_;
}
//- Number of mesh displacement smoothing iterations.
label nSmoothDispl() const
{
return nSmoothDispl_;
}
//- Maximum number of snapping relaxation iterations. Should stop
// before upon reaching a correct mesh.
label nSnap() const
{
return nSnap_;
}
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,841 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::meshRefinement
Description
Helper class which maintains intersections of (changing) mesh with
(static) surfaces.
Maintains
- per face any intersections of the cc-cc segment with any of the surfaces
SourceFiles
meshRefinement.C
meshRefinementBaffles.C
meshRefinementMerge.C
meshRefinementProblemCells.C
meshRefinementRefine.C
\*---------------------------------------------------------------------------*/
#ifndef meshRefinement_H
#define meshRefinement_H
#include "hexRef8.H"
#include "mapPolyMesh.H"
#include "autoPtr.H"
#include "labelPair.H"
#include "indirectPrimitivePatch.H"
#include "pointFieldsFwd.H"
#include "Tuple2.H"
#include "pointIndexHit.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Class forward declarations
class fvMesh;
class mapDistributePolyMesh;
class decompositionMethod;
class refinementSurfaces;
class shellSurfaces;
class removeCells;
class featureEdgeMesh;
class fvMeshDistribute;
class searchableSurface;
class regionSplit;
class globalIndex;
/*---------------------------------------------------------------------------*\
Class meshRefinement Declaration
\*---------------------------------------------------------------------------*/
class meshRefinement
{
public:
// Public data types
//- Enumeration for debug dumping
enum writeFlag
{
MESH = 1,
SCALARLEVELS = 2,
OBJINTERSECTIONS = 4
};
//- Enumeration for how the userdata is to be mapped upon refinement.
enum mapType
{
MASTERONLY = 1, /*!< maintain master only */
KEEPALL = 2, /*!< have slaves (upon refinement) from master */
REMOVE = 4 /*!< set value to -1 any face that was refined */
};
private:
// Private data
//- Reference to mesh
fvMesh& mesh_;
//- tolerance used for sorting coordinates (used in 'less' routine)
const scalar mergeDistance_;
//- overwrite the mesh?
const bool overwrite_;
//- Instance of mesh upon construction. Used when in overwrite_ mode.
const word oldInstance_;
//- All surface-intersection interaction
const refinementSurfaces& surfaces_;
//- All shell-refinement interaction
const shellSurfaces& shells_;
//- refinement engine
hexRef8 meshCutter_;
//- per cc-cc vector the index of the surface hit
labelIOList surfaceIndex_;
//- user supplied face based data.
List<Tuple2<mapType, labelList> > userFaceData_;
//- Meshed patches - are treated differently. Stored as wordList since
// order changes.
wordList meshedPatches_;
// Private Member Functions
//- Reorder list according to map.
template<class T>
static void updateList
(
const labelList& newToOld,
const T& nullValue,
List<T>& elems
);
//- Add patchfield of given type to all fields on mesh
template<class GeoField>
static void addPatchFields(fvMesh&, const word& patchFieldType);
//- Reorder patchfields of all fields on mesh
template<class GeoField>
static void reorderPatchFields(fvMesh&, const labelList& oldToNew);
//- Find out which faces have changed given cells (old mesh labels)
// that were marked for refinement.
static labelList getChangedFaces
(
const mapPolyMesh&,
const labelList& oldCellsToRefine
);
//- Calculate coupled boundary end vector and refinement level
void calcNeighbourData
(
labelList& neiLevel,
pointField& neiCc
) const;
//- Find any intersection of surface. Store in surfaceIndex_.
void updateIntersections(const labelList& changedFaces);
//- Remove cells. Put exposedFaces into exposedPatchIDs.
autoPtr<mapPolyMesh> doRemoveCells
(
const labelList& cellsToRemove,
const labelList& exposedFaces,
const labelList& exposedPatchIDs,
removeCells& cellRemover
);
// Get cells which are inside any closed surface. Note that
// all closed surfaces
// will have already been oriented to have keepPoint outside.
labelList getInsideCells(const word&) const;
// Do all to remove inside cells
autoPtr<mapPolyMesh> removeInsideCells
(
const string& msg,
const label exposedPatchI
);
// For decomposeCombineRegions
//- Used in decomposeCombineRegions. Given global region per cell
// determines master processor/cell for regions straddling
// procboundaries.
void getCoupledRegionMaster
(
const globalIndex& globalCells,
const boolList& blockedFace,
const regionSplit& globalRegion,
Map<label>& regionToMaster
) const;
//- Determine regions that are local to me or coupled ones that
// are owned by me. Determine representative location.
void calcLocalRegions
(
const globalIndex& globalCells,
const labelList& globalRegion,
const Map<label>& coupledRegionToMaster,
const scalarField& cellWeights,
Map<label>& globalToLocalRegion,
pointField& localPoints,
scalarField& localWeights
) const;
//- Convert region into global index.
static label getShiftedRegion
(
const globalIndex& indexer,
const Map<label>& globalToLocalRegion,
const Map<label>& coupledRegionToShifted,
const label globalRegion
);
//- helper: add element if not in list. Linear search.
static void addUnique(const label, labelList&);
//- Calculate region connectivity. Major communication.
void calcRegionRegions
(
const labelList& globalRegion,
const Map<label>& globalToLocalRegion,
const Map<label>& coupledRegionToMaster,
labelListList& regionRegions
) const;
// Refinement candidate selection
//- Mark cell for refinement (if not already marked). Return false
// if refinelimit hit. Keeps running count (in nRefine) of cells
// marked for refinement
static bool markForRefine
(
const label markValue,
const label nAllowRefine,
label& cellValue,
label& nRefine
);
//- Calculate list of cells to refine based on intersection of
// features.
label markFeatureRefinement
(
const point& keepPoint,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const label nAllowRefine,
labelList& refineCell,
label& nRefine
) const;
//- Mark cells for refinement-shells based refinement.
label markInternalRefinement
(
const label nAllowRefine,
labelList& refineCell,
label& nRefine
) const;
//- Collect faces that are intersected and whose neighbours aren't
// yet marked for refinement.
labelList getRefineCandidateFaces
(
const labelList& refineCell
) const;
//- Mark cells for surface intersection based refinement.
label markSurfaceRefinement
(
const label nAllowRefine,
const labelList& neiLevel,
const pointField& neiCc,
labelList& refineCell,
label& nRefine
) const;
//- Mark cell if local curvature > curvature or
// markDifferingRegions = true and intersections with different
// regions.
bool checkCurvature
(
const scalar curvature,
const label nAllowRefine,
const label surfaceLevel,
const vector& surfaceNormal,
const label cellI,
label& cellMaxLevel,
vector& cellMaxNormal,
labelList& refineCell,
label& nRefine
) const;
//- Mark cells for surface curvature based refinement. Marks if
// local curvature > curvature or if on different regions
// (markDifferingRegions)
label markSurfaceCurvatureRefinement
(
const scalar curvature,
const label nAllowRefine,
const labelList& neiLevel,
const pointField& neiCc,
labelList& refineCell,
label& nRefine
) const;
// Baffle handling
//- Determine patches for baffles
void getBafflePatches
(
const labelList& globalToPatch,
const labelList& neiLevel,
const pointField& neiCc,
labelList& ownPatch,
labelList& neiPatch
) const;
//- Determine patch for baffle using some heuristic (and not
// surface)
label getBafflePatch
(
const labelList& facePatch,
const label faceI
) const;
//- Repatches external face or creates baffle for internal face
// with user specified patches (might be different for both sides).
// Returns label of added face.
label createBaffle
(
const label faceI,
const label ownPatch,
const label neiPatch,
directTopoChange& meshMod
) const;
// Problem cell handling
//- Helper function to mark face as being on 'boundary'. Used by
// markFacesOnProblemCells
void markBoundaryFace
(
const label faceI,
boolList& isBoundaryFace,
boolList& isBoundaryEdge,
boolList& isBoundaryPoint
) const;
void findNearest
(
const labelList& meshFaces,
List<pointIndexHit>& nearestInfo,
labelList& nearestSurface,
labelList& nearestRegion,
vectorField& nearestNormal
) const;
Map<label> findEdgeConnectedProblemCells
(
const scalarField& perpendicularAngle,
const labelList&
) const;
bool isCollapsedFace
(
const pointField&,
const pointField& neiCc,
const scalar minFaceArea,
const scalar maxNonOrtho,
const label faceI
) const;
bool isCollapsedCell
(
const pointField&,
const scalar volFraction,
const label cellI
) const;
//- Returns list with for every internal face -1 or the patch
// they should be baffled into. If removeEdgeConnectedCells is set
// removes cells based on perpendicularAngle.
labelList markFacesOnProblemCells
(
const dictionary& motionDict,
const bool removeEdgeConnectedCells,
const scalarField& perpendicularAngle,
const labelList& globalToPatch
) const;
////- Initial test of marking faces using geometric information.
//labelList markFacesOnProblemCellsGeometric
//(
// const dictionary& motionDict
//) const;
// Baffle merging
//- Extract those baffles (duplicate) faces that are on the edge
// of a baffle region. These are candidates for merging.
List<labelPair> filterDuplicateFaces(const List<labelPair>&) const;
// Zone handling
//- Finds zone per cell for cells inside closed named surfaces.
// (uses geometric test for insideness)
// Adapts namedSurfaceIndex so all faces on boundary of cellZone
// have corresponding faceZone.
void findCellZoneGeometric
(
const labelList& closedNamedSurfaces,
labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone,
labelList& cellToZone
) const;
//- Determines cell zone from cell region information.
bool calcRegionToZone
(
const label surfZoneI,
const label ownRegion,
const label neiRegion,
labelList& regionToCellZone
) const;
//- Finds zone per cell. Uses topological walk with all faces
// marked in namedSurfaceIndex regarded as blocked.
void findCellZoneTopo
(
const point& keepPoint,
const labelList& namedSurfaceIndex,
const labelList& surfaceToCellZone,
labelList& cellToZone
) const;
void makeConsistentFaceIndex
(
const labelList& cellToZone,
labelList& namedSurfaceIndex
) const;
//- Disallow default bitwise copy construct
meshRefinement(const meshRefinement&);
//- Disallow default bitwise assignment
void operator=(const meshRefinement&);
public:
//- Runtime type information
ClassName("meshRefinement");
// Constructors
//- Construct from components
meshRefinement
(
fvMesh& mesh,
const scalar mergeDistance,
const bool overwrite,
const refinementSurfaces&,
const shellSurfaces&
);
// Member Functions
// Access
//- reference to mesh
const fvMesh& mesh() const
{
return mesh_;
}
fvMesh& mesh()
{
return mesh_;
}
scalar mergeDistance() const
{
return mergeDistance_;
}
//- Overwrite the mesh?
bool overwrite() const
{
return overwrite_;
}
//- (points)instance of mesh upon construction
const word& oldInstance() const
{
return oldInstance_;
}
//- reference to surface search engines
const refinementSurfaces& surfaces() const
{
return surfaces_;
}
//- reference to refinement shells (regions)
const shellSurfaces& shells() const
{
return shells_;
}
//- reference to meshcutting engine
const hexRef8& meshCutter() const
{
return meshCutter_;
}
//- per start-end edge the index of the surface hit
const labelList& surfaceIndex() const
{
return surfaceIndex_;
}
labelList& surfaceIndex()
{
return surfaceIndex_;
}
//- Additional face data that is maintained across
// topo changes. Every entry is a list over all faces.
// Bit of a hack. Additional flag to say whether to maintain master
// only (false) or increase set to account for face-from-face.
const List<Tuple2<mapType, labelList> >& userFaceData() const
{
return userFaceData_;
}
List<Tuple2<mapType, labelList> >& userFaceData()
{
return userFaceData_;
}
// Other
//- Count number of intersections (local)
label countHits() const;
//- Helper function to get decomposition such that all connected
// regions get moved onto one processor. Used to prevent baffles
// straddling processor boundaries. explicitConnections is to
// keep pairs of non-coupled boundary faces together
// (e.g. to keep baffles together)
labelList decomposeCombineRegions
(
const scalarField& cellWeights,
const boolList& blockedFace,
const List<labelPair>& explicitConnections,
decompositionMethod&
) const;
//- Redecompose according to cell count
// keepZoneFaces : find all faceZones from zoned surfaces and keep
// owner and neighbour together
// keepBaffles : find all baffles and keep them together
autoPtr<mapDistributePolyMesh> balance
(
const bool keepZoneFaces,
const bool keepBaffles,
const scalarField& cellWeights,
decompositionMethod& decomposer,
fvMeshDistribute& distributor
);
//- Get faces with intersection.
labelList intersectedFaces() const;
//- Get points on surfaces with intersection and boundary faces.
labelList intersectedPoints() const;
//- Create patch from set of patches
static autoPtr<indirectPrimitivePatch> makePatch
(
const polyMesh&,
const labelList&
);
//- Helper function to make a pointVectorField with correct
// bcs for mesh movement:
// - adaptPatchIDs : fixedValue
// - processor : calculated (so free to move)
// - cyclic/wedge/symmetry : slip
// - other : slip
static tmp<pointVectorField> makeDisplacementField
(
const pointMesh& pMesh,
const labelList& adaptPatchIDs
);
//- Helper function: check that face zones are synced
static void checkCoupledFaceZones(const polyMesh&);
// Refinement
//- Calculate list of cells to refine.
labelList refineCandidates
(
const point& keepPoint,
const scalar curvature,
const PtrList<featureEdgeMesh>& featureMeshes,
const labelList& featureLevels,
const bool featureRefinement,
const bool internalRefinement,
const bool surfaceRefinement,
const bool curvatureRefinement,
const label maxGlobalCells,
const label maxLocalCells
) const;
//- Refine some cells
autoPtr<mapPolyMesh> refine(const labelList& cellsToRefine);
//- Refine some cells and rebalance
autoPtr<mapDistributePolyMesh> refineAndBalance
(
const string& msg,
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelList& cellsToRefine,
const scalar maxLoadUnbalance
);
//- Balance before refining some cells
autoPtr<mapDistributePolyMesh> balanceAndRefine
(
const string& msg,
decompositionMethod& decomposer,
fvMeshDistribute& distributor,
const labelList& cellsToRefine,
const scalar maxLoadUnbalance
);
// Baffle handling
//- Split off unreachable areas of mesh.
void baffleAndSplitMesh
(
const bool handleSnapProblems,
const bool removeEdgeConnectedCells,
const scalarField& perpendicularAngle,
const bool mergeFreeStanding,
const dictionary& motionDict,
Time& runTime,
const labelList& globalToPatch,
const point& keepPoint
);
//- Split off (with optional buffer layers) unreachable areas
// of mesh. Does not introduce baffles.
autoPtr<mapPolyMesh> splitMesh
(
const label nBufferLayers,
const labelList& globalToPatch,
const point& keepPoint
);
//- Find boundary points that connect to more than one cell
// region and split them.
autoPtr<mapPolyMesh> dupNonManifoldPoints();
//- Create baffle for every internal face where ownPatch != -1.
// External faces get repatched according to ownPatch (neiPatch
// should be -1 for these)
autoPtr<mapPolyMesh> createBaffles
(
const labelList& ownPatch,
const labelList& neiPatch
);
//- Return a list of coupled face pairs, i.e. faces that
// use the same vertices.
List<labelPair> getDuplicateFaces(const labelList& testFaces) const;
//- Merge baffles. Gets pairs of faces.
autoPtr<mapPolyMesh> mergeBaffles(const List<labelPair>&);
//- Put faces/cells into zones according to surface specification.
// Returns null if no zone surfaces present. Region containing
// the keepPoint will not be put into a cellZone.
autoPtr<mapPolyMesh> zonify
(
const point& keepPoint,
const bool allowFreeStandingZoneFaces
);
// Other topo changes
//- Helper:add patch to mesh. Update all registered fields.
// Use addMeshedPatch to add patches originating from surfaces.
static label addPatch(fvMesh&, const word& name, const word& type);
//- Add patch originating from meshing. Update meshedPatches_.
label addMeshedPatch(const word& name, const word& type);
//- Get patchIDs for patches added in addMeshedPatch.
labelList meshedPatches() const;
//- Split mesh. Keep part containing point.
autoPtr<mapPolyMesh> splitMeshRegions(const point& keepPoint);
//- Update local numbering for mesh redistribution
void distribute(const mapDistributePolyMesh&);
//- Update for external change to mesh. changedFaces are in new mesh
// face labels.
void updateMesh
(
const mapPolyMesh&,
const labelList& changedFaces
);
// Restoring : is where other processes delete and reinsert data.
//- Signal points/face/cells for which to store data
void storeData
(
const labelList& pointsToStore,
const labelList& facesToStore,
const labelList& cellsToStore
);
//- Update local numbering + undo
// Data to restore given as new pointlabel + stored pointlabel
// (i.e. what was in pointsToStore)
void updateMesh
(
const mapPolyMesh&,
const labelList& changedFaces,
const Map<label>& pointsToRestore,
const Map<label>& facesToRestore,
const Map<label>& cellsToRestore
);
//- Merge faces on the same patch (usually from exposing refinement)
// Returns global number of faces merged.
label mergePatchFaces
(
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs
);
//- Remove points not used by any face or points used
// by only two faces where the edges are in line
autoPtr<mapPolyMesh> mergeEdges(const scalar minCos);
// Debug/IO
//- Debugging: check that all faces still obey start()>end()
void checkData();
//- Compare two lists over all boundary faces
template<class T>
void testSyncBoundaryFaceList
(
const scalar mergeDistance,
const string&,
const UList<T>&,
const UList<T>&
) const;
//- Print some mesh stats.
void printMeshInfo(const bool, const string&) const;
//- Replacement for Time::timeName() : return oldInstance (if
// overwrite_)
word timeName() const;
//- Set instance of all local IOobjects
void setInstance(const fileName&);
//- Write mesh and all data
bool write() const;
//- Write refinement level as volScalarFields for postprocessing
void dumpRefinementLevel() const;
//- Debug: Write intersection information to OBJ format
void dumpIntersections(const fileName& prefix) const;
//- Do any one of above IO functions. flag is combination of
// writeFlag values.
void write(const label flag, const fileName&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "meshRefinementTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,246 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*----------------------------------------------------------------------------*/
#include "meshRefinement.H"
#include "combineFaces.H"
#include "directTopoChange.H"
#include "removePoints.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Merge faces that are in-line.
Foam::label Foam::meshRefinement::mergePatchFaces
(
const scalar minCos,
const scalar concaveCos,
const labelList& patchIDs
)
{
// Patch face merging engine
combineFaces faceCombiner(mesh_);
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
// Pick up all candidate cells on boundary
labelHashSet boundaryCells(mesh_.nFaces()-mesh_.nInternalFaces());
forAll(patchIDs, i)
{
label patchI = patchIDs[i];
const polyPatch& patch = patches[patchI];
if (!patch.coupled())
{
forAll(patch, i)
{
boundaryCells.insert(mesh_.faceOwner()[patch.start()+i]);
}
}
}
// Get all sets of faces that can be merged
labelListList mergeSets
(
faceCombiner.getMergeSets
(
minCos,
concaveCos,
boundaryCells
)
);
label nFaceSets = returnReduce(mergeSets.size(), sumOp<label>());
Info<< "mergePatchFaces : Merging " << nFaceSets
<< " sets of faces." << endl;
if (nFaceSets > 0)
{
// Topology changes container
directTopoChange meshMod(mesh_);
// Merge all faces of a set into the first face of the set. Remove
// unused points.
faceCombiner.setRefinement(mergeSets, meshMod);
// Change the mesh (no inflation)
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh_, false, true);
// Update fields
mesh_.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes. No other way to do this?
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
faceCombiner.updateMesh(map);
// Get the kept faces that need to be recalculated.
// Merging two boundary faces might shift the cell centre
// (unless the faces are absolutely planar)
labelHashSet retestFaces(6*mergeSets.size());
forAll(mergeSets, setI)
{
label oldMasterI = mergeSets[setI][0];
label faceI = map().reverseFaceMap()[oldMasterI];
// faceI is always uncoupled boundary face
const cell& cFaces = mesh_.cells()[mesh_.faceOwner()[faceI]];
forAll(cFaces, i)
{
retestFaces.insert(cFaces[i]);
}
}
updateMesh(map, retestFaces.toc());
}
return nFaceSets;
}
// Remove points not used by any face or points used by only two faces where
// the edges are in line
Foam::autoPtr<Foam::mapPolyMesh> Foam::meshRefinement::mergeEdges
(
const scalar minCos
)
{
// Point removal analysis engine
removePoints pointRemover(mesh_);
// Count usage of points
boolList pointCanBeDeleted;
label nRemove = pointRemover.countPointUsage(minCos, pointCanBeDeleted);
Info<< "Removing " << nRemove
<< " straight edge points." << endl;
autoPtr<mapPolyMesh> map;
if (nRemove > 0)
{
// Save my local faces that will change. These changed faces might
// cause a shift in the cell centre which needs to be retested.
// Have to do this before changing mesh since point will be removed.
labelHashSet retestOldFaces(nRemove / Pstream::nProcs());
{
const faceList& faces = mesh_.faces();
forAll(faces, faceI)
{
const face& f = faces[faceI];
forAll(f, fp)
{
if (pointCanBeDeleted[f[fp]])
{
retestOldFaces.insert(faceI);
break;
}
}
}
}
// Topology changes container
directTopoChange meshMod(mesh_);
pointRemover.setRefinement(pointCanBeDeleted, meshMod);
// Change the mesh (no inflation)
map = meshMod.changeMesh(mesh_, false, true);
// Update fields
mesh_.updateMesh(map);
// Move mesh (since morphing does not do this)
if (map().hasMotionPoints())
{
mesh_.movePoints(map().preMotionPoints());
}
else
{
// Delete mesh volumes. No other way to do this?
mesh_.clearOut();
}
if (overwrite())
{
mesh_.setInstance(oldInstance());
}
pointRemover.updateMesh(map);
// Get the kept faces that need to be recalculated.
labelHashSet retestFaces(6*retestOldFaces.size());
const cellList& cells = mesh_.cells();
forAllConstIter(labelHashSet, retestOldFaces, iter)
{
label faceI = map().reverseFaceMap()[iter.key()];
const cell& ownFaces = cells[mesh_.faceOwner()[faceI]];
forAll(ownFaces, i)
{
retestFaces.insert(ownFaces[i]);
}
if (mesh_.isInternalFace(faceI))
{
const cell& neiFaces = cells[mesh_.faceNeighbour()[faceI]];
forAll(neiFaces, i)
{
retestFaces.insert(neiFaces[i]);
}
}
}
updateMesh(map, retestFaces.toc());
}
return map;
}
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -1,194 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "meshRefinement.H"
#include "fvMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Add a T entry
template<class T> void meshRefinement::updateList
(
const labelList& newToOld,
const T& nullValue,
List<T>& elems
)
{
List<T> newElems(newToOld.size(), nullValue);
forAll(newElems, i)
{
label oldI = newToOld[i];
if (oldI >= 0)
{
newElems[i] = elems[oldI];
}
}
elems.transfer(newElems);
}
// Compare two lists over all boundary faces
template<class T>
void meshRefinement::testSyncBoundaryFaceList
(
const scalar tol,
const string& msg,
const UList<T>& faceData,
const UList<T>& syncedFaceData
) const
{
label nBFaces = mesh_.nFaces() - mesh_.nInternalFaces();
if (faceData.size() != nBFaces || syncedFaceData.size() != nBFaces)
{
FatalErrorIn
(
"meshRefinement::testSyncBoundaryFaceList"
"(const scalar, const string&, const List<T>&, const List<T>&)"
) << "Boundary faces:" << nBFaces
<< " faceData:" << faceData.size()
<< " syncedFaceData:" << syncedFaceData.size()
<< abort(FatalError);
}
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
label bFaceI = pp.start() - mesh_.nInternalFaces();
forAll(pp, i)
{
const T& data = faceData[bFaceI];
const T& syncData = syncedFaceData[bFaceI];
if (mag(data - syncData) > tol)
{
label faceI = pp.start()+i;
FatalErrorIn("testSyncFaces")
<< msg
<< "patchFace:" << i
<< " face:" << faceI
<< " fc:" << mesh_.faceCentres()[faceI]
<< " patch:" << pp.name()
<< " faceData:" << data
<< " syncedFaceData:" << syncData
<< " diff:" << mag(data - syncData)
<< abort(FatalError);
}
bFaceI++;
}
}
}
//template <class T, class Mesh>
template<class GeoField>
void meshRefinement::addPatchFields(fvMesh& mesh, const word& patchFieldType)
{
HashTable<const GeoField*> flds
(
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
typename GeoField::GeometricBoundaryField& bfld =
const_cast<typename GeoField::GeometricBoundaryField&>
(
fld.boundaryField()
);
label sz = bfld.size();
bfld.setSize(sz+1);
bfld.set
(
sz,
GeoField::PatchFieldType::New
(
patchFieldType,
mesh.boundary()[sz],
fld.dimensionedInternalField()
)
);
}
}
// Reorder patch field
template<class GeoField>
void meshRefinement::reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
{
HashTable<const GeoField*> flds
(
mesh.objectRegistry::lookupClass<GeoField>()
);
for
(
typename HashTable<const GeoField*>::const_iterator iter = flds.begin();
iter != flds.end();
++iter
)
{
const GeoField& fld = *iter();
typename GeoField::GeometricBoundaryField& bfld =
const_cast<typename GeoField::GeometricBoundaryField&>
(
fld.boundaryField()
);
bfld.reorder(oldToNew);
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -1,317 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::refinementSurfaces
Description
Container for data on surfaces used for surface-driven refinement.
Contains all the data about the level of refinement needed per
surface.
SourceFiles
refinementSurfaces.C
\*---------------------------------------------------------------------------*/
#ifndef refinementSurfaces_H
#define refinementSurfaces_H
#include "triSurfaceGeoMesh.H"
#include "triSurfaceFields.H"
#include "vectorList.H"
#include "pointIndexHit.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class searchableSurfaces;
class shellSurfaces;
class triSurfaceMesh;
/*---------------------------------------------------------------------------*\
Class refinementSurfaces Declaration
\*---------------------------------------------------------------------------*/
class refinementSurfaces
{
// Private data
//- Reference to all geometry.
const searchableSurfaces& allGeometry_;
//- Indices of surfaces that are refinement ones
labelList surfaces_;
//- Surface name (word)
wordList names_;
//- Per 'interface' surface : name of faceZone to put faces into
wordList faceZoneNames_;
//- Per 'interface' surface : name of cellZone to put cells into
wordList cellZoneNames_;
//- Per 'interface' surface : (only used if surface is closed)
// whether to zone cells inside or outside surface.
boolList zoneInside_;
//- From local region number to global region number
labelList regionOffset_;
//- From global region number to refinement level
labelList minLevel_;
//- From global region number to refinement level
labelList maxLevel_;
//- From global region number to perpendicular angle
scalarField perpendicularAngle_;
// Private Member Functions
//- Disallow default bitwise copy construct
refinementSurfaces(const refinementSurfaces&);
//- Disallow default bitwise assignment
void operator=(const refinementSurfaces&);
public:
// Constructors
//- Construct from surfaces and dictionaries
refinementSurfaces
(
const searchableSurfaces& allGeometry,
const PtrList<dictionary>&
);
//- Construct from surfaces and dictionary
refinementSurfaces
(
const searchableSurfaces& allGeometry,
const dictionary&
);
// Member Functions
// Access
const searchableSurfaces& geometry() const
{
return allGeometry_;
}
const labelList& surfaces() const
{
return surfaces_;
}
//- Names of surfaces
const wordList& names() const
{
return names_;
}
//- Per 'interface' surface : name of faceZone to put faces into
const wordList& faceZoneNames() const
{
return faceZoneNames_;
}
//- Per 'interface' surface : name of cellZone to put cells into
const wordList& cellZoneNames() const
{
return cellZoneNames_;
}
//- Get indices of unnamed surfaces (surfaces without faceZoneName)
labelList getUnnamedSurfaces() const;
//- Get indices of named surfaces (surfaces with faceZoneName)
labelList getNamedSurfaces() const;
//- Get indices of closed named surfaces
labelList getClosedNamedSurfaces() const;
//- From local region number to global region number
const labelList& regionOffset() const
{
return regionOffset_;
}
//- From global region number to refinement level
const labelList& minLevel() const
{
return minLevel_;
}
//- From global region number to refinement level
const labelList& maxLevel() const
{
return maxLevel_;
}
//- From global region number to perpendicular angle
const scalarField& perpendicularAngle() const
{
return perpendicularAngle_;
}
// Helper
//- From surface and region on surface to global region
label globalRegion(const label surfI, const label regionI) const
{
return regionOffset_[surfI]+regionI;
}
//- Min level for surface and region on surface
label minLevel(const label surfI, const label regionI) const
{
return minLevel_[globalRegion(surfI, regionI)];
}
//- Max level for surface and region on surface
label maxLevel(const label surfI, const label regionI) const
{
return maxLevel_[globalRegion(surfI, regionI)];
}
label nRegions() const
{
return minLevel_.size();
}
//- Calculate minLevelFields
void setMinLevelFields
(
const shellSurfaces& shells
);
////- Helper: count number of triangles per region
//static labelList countRegions(const triSurface&);
// Searching
//- Find intersection of edge. Return -1 or first surface
// with higher (than currentLevel) minlevel.
// Return surface number and level.
void findHigherIntersection
(
const pointField& start,
const pointField& end,
const labelList& currentLevel, // current cell refinement level
labelList& surfaces,
labelList& surfaceLevel
) const;
//- Find all intersections of edge. Unsorted order.
void findAllHigherIntersections
(
const pointField& start,
const pointField& end,
const labelList& currentLevel, // current cell refinement level
List<vectorList>& surfaceNormal,
labelListList& surfaceLevel
) const;
//- Find intersection nearest to the endpoints. surface1,2 are
// not indices into surfacesToTest but refinement surface indices.
// Returns surface, region on surface (so not global surface)
// and position on surface.
void findNearestIntersection
(
const labelList& surfacesToTest,
const pointField& start,
const pointField& end,
labelList& surface1,
List<pointIndexHit>& hit1,
labelList& region1,
labelList& surface2,
List<pointIndexHit>& hit2,
labelList& region2
) const;
//- Used for debugging only: find intersection of edge.
void findAnyIntersection
(
const pointField& start,
const pointField& end,
labelList& surfaces,
List<pointIndexHit>&
) const;
//- Find nearest point on surfaces.
void findNearest
(
const labelList& surfacesToTest,
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& surfaces,
List<pointIndexHit>&
) const;
//- Find nearest point on surfaces. Return surface and region on
// surface (so not global surface)
void findNearestRegion
(
const labelList& surfacesToTest,
const pointField& samples,
const scalarField& nearestDistSqr,
labelList& hitSurface,
labelList& hitRegion
) const;
//- Detect if a point is 'inside' (closed) surfaces.
// Returns -1 if not, returns first surface it is.
void findInside
(
const labelList& surfacesToTest,
const pointField& pt,
labelList& insideSurfaces
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,481 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "searchableSurface.H"
#include "shellSurfaces.H"
#include "boundBox.H"
#include "triSurfaceMesh.H"
#include "refinementSurfaces.H"
#include "searchableSurfaces.H"
#include "orientedSurface.H"
#include "pointIndexHit.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char*
NamedEnum<shellSurfaces::refineMode, 3>::
names[] =
{
"inside",
"outside",
"distance"
};
const NamedEnum<shellSurfaces::refineMode, 3> shellSurfaces::refineModeNames_;
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::shellSurfaces::setAndCheckLevels
(
const label shellI,
const List<Tuple2<scalar, label> >& distLevels
)
{
if (modes_[shellI] != DISTANCE && distLevels.size() != 1)
{
FatalErrorIn
(
"shellSurfaces::shellSurfaces"
"(const searchableSurfaces&, const dictionary&)"
) << "For refinement mode "
<< refineModeNames_[modes_[shellI]]
<< " specify only one distance+level."
<< " (its distance gets discarded)"
<< exit(FatalError);
}
// Extract information into separate distance and level
distances_[shellI].setSize(distLevels.size());
levels_[shellI].setSize(distLevels.size());
forAll(distLevels, j)
{
distances_[shellI][j] = distLevels[j].first();
levels_[shellI][j] = distLevels[j].second();
// Check in incremental order
if (j > 0)
{
if
(
(distances_[shellI][j] <= distances_[shellI][j-1])
|| (levels_[shellI][j] > levels_[shellI][j-1])
)
{
FatalErrorIn
(
"shellSurfaces::shellSurfaces"
"(const searchableSurfaces&, const dictionary&)"
) << "For refinement mode "
<< refineModeNames_[modes_[shellI]]
<< " : Refinement should be specified in order"
<< " of increasing distance"
<< " (and decreasing refinement level)." << endl
<< "Distance:" << distances_[shellI][j]
<< " refinementLevel:" << levels_[shellI][j]
<< exit(FatalError);
}
}
}
const searchableSurface& shell = allGeometry_[shells_[shellI]];
if (modes_[shellI] == DISTANCE)
{
Info<< "Refinement level according to distance to "
<< shell.name() << endl;
forAll(levels_[shellI], j)
{
Info<< " level " << levels_[shellI][j]
<< " for all cells within " << distances_[shellI][j]
<< " meter." << endl;
}
}
else
{
if (!allGeometry_[shells_[shellI]].hasVolumeType())
{
FatalErrorIn
(
"shellSurfaces::shellSurfaces"
"(const searchableSurfaces&"
", const PtrList<dictionary>&)"
) << "Shell " << shell.name()
<< " does not support testing for "
<< refineModeNames_[modes_[shellI]] << endl
<< "Probably it is not closed."
<< exit(FatalError);
}
if (modes_[shellI] == INSIDE)
{
Info<< "Refinement level " << levels_[shellI][0]
<< " for all cells inside " << shell.name() << endl;
}
else
{
Info<< "Refinement level " << levels_[shellI][0]
<< " for all cells outside " << shell.name() << endl;
}
}
}
// Specifically orient triSurfaces using a calculated point outside.
// Done since quite often triSurfaces not of consistent orientation which
// is (currently) necessary for sideness calculation
void Foam::shellSurfaces::orient()
{
// Determine outside point.
boundBox overallBb = boundBox::invertedBox;
bool hasSurface = false;
forAll(shells_, shellI)
{
const searchableSurface& s = allGeometry_[shells_[shellI]];
if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
{
const triSurfaceMesh& shell = refCast<const triSurfaceMesh>(s);
if (shell.triSurface::size())
{
const pointField& points = shell.points();
hasSurface = true;
boundBox shellBb(points[0], points[0]);
// Assume surface is compact!
for (label i = 0; i < points.size(); i++)
{
const point& pt = points[i];
shellBb.min() = min(shellBb.min(), pt);
shellBb.max() = max(shellBb.max(), pt);
}
overallBb.min() = min(overallBb.min(), shellBb.min());
overallBb.max() = max(overallBb.max(), shellBb.max());
}
}
}
if (hasSurface)
{
const point outsidePt = overallBb.max() + overallBb.span();
//Info<< "Using point " << outsidePt << " to orient shells" << endl;
forAll(shells_, shellI)
{
const searchableSurface& s = allGeometry_[shells_[shellI]];
if (modes_[shellI] != DISTANCE && isA<triSurfaceMesh>(s))
{
triSurfaceMesh& shell = const_cast<triSurfaceMesh&>
(
refCast<const triSurfaceMesh>(s)
);
// Flip surface so outsidePt is outside.
bool anyFlipped = orientedSurface::orient
(
shell,
outsidePt,
true
);
if (anyFlipped)
{
// orientedSurface will have done a clearOut of the surface.
// we could do a clearout of the triSurfaceMeshes::trees()
// but these aren't affected by orientation
// (except for cached
// sideness which should not be set at this point.
// !!Should check!)
Info<< "shellSurfaces : Flipped orientation of surface "
<< s.name()
<< " so point " << outsidePt << " is outside." << endl;
}
}
}
}
}
// Find maximum level of a shell.
void Foam::shellSurfaces::findHigherLevel
(
const pointField& pt,
const label shellI,
labelList& maxLevel
) const
{
const labelList& levels = levels_[shellI];
if (modes_[shellI] == DISTANCE)
{
// Distance mode.
const scalarField& distances = distances_[shellI];
// Collect all those points that have a current maxLevel less than
// (any of) the shell. Also collect the furthest distance allowable
// to any shell with a higher level.
pointField candidates(pt.size());
labelList candidateMap(pt.size());
scalarField candidateDistSqr(pt.size());
label candidateI = 0;
forAll(maxLevel, pointI)
{
forAllReverse(levels, levelI)
{
if (levels[levelI] > maxLevel[pointI])
{
candidates[candidateI] = pt[pointI];
candidateMap[candidateI] = pointI;
candidateDistSqr[candidateI] = sqr(distances[levelI]);
candidateI++;
break;
}
}
}
candidates.setSize(candidateI);
candidateMap.setSize(candidateI);
candidateDistSqr.setSize(candidateI);
// Do the expensive nearest test only for the candidate points.
List<pointIndexHit> nearInfo;
allGeometry_[shells_[shellI]].findNearest
(
candidates,
candidateDistSqr,
nearInfo
);
// Update maxLevel
forAll(nearInfo, candidateI)
{
if (nearInfo[candidateI].hit())
{
// Check which level it actually is in.
label minDistI = findLower
(
distances,
mag(nearInfo[candidateI].hitPoint()-candidates[candidateI])
);
label pointI = candidateMap[candidateI];
// pt is inbetween shell[minDistI] and shell[minDistI+1]
maxLevel[pointI] = levels[minDistI+1];
}
}
}
else
{
// Inside/outside mode
// Collect all those points that have a current maxLevel less than the
// shell.
pointField candidates(pt.size());
labelList candidateMap(pt.size());
label candidateI = 0;
forAll(maxLevel, pointI)
{
if (levels[0] > maxLevel[pointI])
{
candidates[candidateI] = pt[pointI];
candidateMap[candidateI] = pointI;
candidateI++;
}
}
candidates.setSize(candidateI);
candidateMap.setSize(candidateI);
// Do the expensive nearest test only for the candidate points.
List<searchableSurface::volumeType> volType;
allGeometry_[shells_[shellI]].getVolumeType(candidates, volType);
forAll(volType, i)
{
label pointI = candidateMap[i];
if
(
(
modes_[shellI] == INSIDE
&& volType[i] == searchableSurface::INSIDE
)
|| (
modes_[shellI] == OUTSIDE
&& volType[i] == searchableSurface::OUTSIDE
)
)
{
maxLevel[pointI] = levels[0];
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::shellSurfaces::shellSurfaces
(
const searchableSurfaces& allGeometry,
const PtrList<dictionary>& shellDicts
)
:
allGeometry_(allGeometry)
{
shells_.setSize(shellDicts.size());
modes_.setSize(shellDicts.size());
distances_.setSize(shellDicts.size());
levels_.setSize(shellDicts.size());
forAll(shellDicts, shellI)
{
const dictionary& dict = shellDicts[shellI];
const word name = dict.lookup("name");
const word type = dict.lookup("type");
shells_[shellI] = allGeometry_.findSurfaceID(name);
if (shells_[shellI] == -1)
{
FatalErrorIn
(
"shellSurfaces::shellSurfaces"
"(const searchableSurfaces&, const PtrList<dictionary>&)"
) << "No surface called " << name << endl
<< "Valid surfaces are " << allGeometry_.names()
<< exit(FatalError);
}
modes_[shellI] = refineModeNames_.read(dict.lookup("refineMode"));
// Read pairs of distance+level
setAndCheckLevels(shellI, dict.lookup("levels"));
}
// Orient shell surfaces before any searching is done. Note that this
// only needs to be done for inside or outside. Orienting surfaces
// constructs lots of addressing which we want to avoid.
orient();
}
Foam::shellSurfaces::shellSurfaces
(
const searchableSurfaces& allGeometry,
const dictionary& shellsDict
)
:
allGeometry_(allGeometry)
{
shells_.setSize(shellsDict.size());
modes_.setSize(shellsDict.size());
distances_.setSize(shellsDict.size());
levels_.setSize(shellsDict.size());
label shellI = 0;
forAllConstIter(dictionary, shellsDict, iter)
{
shells_[shellI] = allGeometry_.findSurfaceID(iter().keyword());
if (shells_[shellI] == -1)
{
FatalErrorIn
(
"shellSurfaces::shellSurfaces"
"(const searchableSurfaces&, const dictionary>&"
) << "No surface called " << iter().keyword() << endl
<< "Valid surfaces are " << allGeometry_.names()
<< exit(FatalError);
}
const dictionary& dict = shellsDict.subDict(iter().keyword());
modes_[shellI] = refineModeNames_.read(dict.lookup("mode"));
// Read pairs of distance+level
setAndCheckLevels(shellI, dict.lookup("levels"));
shellI++;
}
// Orient shell surfaces before any searching is done. Note that this
// only needs to be done for inside or outside. Orienting surfaces
// constructs lots of addressing which we want to avoid.
orient();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Highest shell level
Foam::label Foam::shellSurfaces::maxLevel() const
{
label overallMax = 0;
forAll(levels_, shellI)
{
overallMax = max(overallMax, max(levels_[shellI]));
}
return overallMax;
}
void Foam::shellSurfaces::findHigherLevel
(
const pointField& pt,
const labelList& ptLevel,
labelList& maxLevel
) const
{
// Maximum level of any shell. Start off with level of point.
maxLevel = ptLevel;
forAll(shells_, shellI)
{
findHigherLevel(pt, shellI, maxLevel);
}
}
// ************************************************************************* //

View file

@ -1,181 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::shellSurfaces
Description
Encapsulates queries for volume refinement ('refine all cells within
shell').
SourceFiles
shellSurfaces.C
\*---------------------------------------------------------------------------*/
#ifndef shellSurfaces_H
#define shellSurfaces_H
#include "searchableSurface.H"
#include "Tuple2.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class searchableSurfaces;
/*---------------------------------------------------------------------------*\
Class shellSurfaces Declaration
\*---------------------------------------------------------------------------*/
class shellSurfaces
{
public:
// Public data types
//- Volume refinement controls
enum refineMode
{
INSIDE, // Refine all inside shell
OUTSIDE, // ,, outside
DISTANCE // Refine based on distance to shell
};
private:
// Private data
//- Reference to all geometry.
const searchableSurfaces& allGeometry_;
//- Indices of surfaces that are shells
labelList shells_;
//- Per shell whether to refine inside or outside
List<refineMode> modes_;
//- Per shell the list of ranges
List<scalarField> distances_;
//- Per shell per distance the refinement level
labelListList levels_;
// Private data
//- refineMode names
static const NamedEnum<refineMode, 3> refineModeNames_;
// Private Member Functions
//- Helper function for initialisation.
void setAndCheckLevels
(
const label shellI,
const List<Tuple2<scalar, label> >&
);
void orient();
void findHigherLevel
(
const pointField& pt,
const label shellI,
labelList& maxLevel
) const;
public:
// Constructors
//- Construct from components
shellSurfaces
(
const searchableSurfaces& allGeometry,
const labelList& shells,
const List<refineMode>& modes,
const List<scalarField>& distances,
const labelListList& levels
);
//- Construct from geometry and dictionaries
shellSurfaces
(
const searchableSurfaces& allGeometry,
const PtrList<dictionary>& shellDicts
);
//- Construct from geometry and dictionary
shellSurfaces
(
const searchableSurfaces& allGeometry,
const dictionary& shellsDict
);
// Member Functions
// Access
//const List<scalarField>& distances() const
//{
// return distances_;
//}
//
////- Per shell per distance the refinement level
//const labelListList& levels() const
//{
// return levels_;
//}
// Query
//- Highest shell level
label maxLevel() const;
//- Find shell level higher than ptLevel
void findHigherLevel
(
const pointField& pt,
const labelList& ptLevel,
labelList& maxLevel
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,261 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "ExactParticle.H"
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class ParticleType>
template<class TrackingData>
Foam::label Foam::ExactParticle<ParticleType>::track
(
const vector& endPosition,
TrackingData& td
)
{
this->facei_ = -1;
// Tracks to endPosition or stop on boundary
while (!this->onBoundary() && this->stepFraction_ < 1.0 - SMALL)
{
this->stepFraction_ +=
trackToFace(endPosition, td)
*(1.0 - this->stepFraction_);
}
return this->facei_;
}
template<class ParticleType>
Foam::label Foam::ExactParticle<ParticleType>::track
(
const vector& endPosition
)
{
int dummyTd;
return track(endPosition, dummyTd);
}
template<class ParticleType>
template<class TrackingData>
Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
(
const vector& endPosition,
TrackingData& td
)
{
const polyMesh& mesh = this->cloud().pMesh();
const labelList& cFaces = mesh.cells()[this->celli_];
point intersection(vector::zero);
scalar trackFraction = VGREAT;
label hitFacei = -1;
const vector vec = endPosition-this->position_;
forAll(cFaces, i)
{
label facei = cFaces[i];
if (facei != this->face())
{
pointHit inter = mesh.faces()[facei].fastIntersection
(
this->position_,
vec,
mesh.faceCentres()[facei],
mesh.points(),
intersection::HALF_RAY
);
if (inter.hit() && inter.distance() < trackFraction)
{
trackFraction = inter.distance();
hitFacei = facei;
intersection = inter.hitPoint();
}
}
}
if (hitFacei == -1)
{
// Did not find any intersection. Fall back to original approximate
// algorithm
return Particle<ParticleType>::trackToFace
(
endPosition,
td
);
}
if (trackFraction >= (1.0-SMALL))
{
// Nearest intersection beyond endPosition so we hit endPosition.
trackFraction = 1.0;
this->position_ = endPosition;
this->facei_ = -1;
return 1.0;
}
else
{
this->position_ = intersection;
this->facei_ = hitFacei;
}
// Normal situation (trackFraction 0..1). Straight copy
// of Particle::trackToFace.
bool internalFace = this->cloud().internalFace(this->facei_);
// change cell
if (internalFace) // Internal face
{
if (this->celli_ == mesh.faceOwner()[this->facei_])
{
this->celli_ = mesh.faceNeighbour()[this->facei_];
}
else if (this->celli_ == mesh.faceNeighbour()[this->facei_])
{
this->celli_ = mesh.faceOwner()[this->facei_];
}
else
{
FatalErrorIn
(
"ExactParticle::trackToFace"
"(const vector&, TrackingData&)"
)<< "addressing failure" << nl
<< abort(FatalError);
}
}
else
{
ParticleType& p = static_cast<ParticleType&>(*this);
// Soft-sphere algorithm ignores the boundary
if (p.softImpact())
{
trackFraction = 1.0;
this->position_ = endPosition;
}
label patchi = this->patch(this->facei_);
const polyPatch& patch = mesh.boundaryMesh()[patchi];
if (isA<wedgePolyPatch>(patch))
{
p.hitWedgePatch
(
static_cast<const wedgePolyPatch&>(patch), td
);
}
else if (isA<symmetryPolyPatch>(patch))
{
p.hitSymmetryPatch
(
static_cast<const symmetryPolyPatch&>(patch), td
);
}
else if (isA<cyclicPolyPatch>(patch))
{
p.hitCyclicPatch
(
static_cast<const cyclicPolyPatch&>(patch), td
);
}
else if (isA<processorPolyPatch>(patch))
{
p.hitProcessorPatch
(
static_cast<const processorPolyPatch&>(patch), td
);
}
else if (isA<wallPolyPatch>(patch))
{
p.hitWallPatch
(
static_cast<const wallPolyPatch&>(patch), td
);
}
else if (isA<polyPatch>(patch))
{
p.hitPatch
(
static_cast<const polyPatch&>(patch), td
);
}
else
{
FatalErrorIn
(
"ExactParticle::trackToFace"
"(const vector& endPosition, scalar& trackFraction)"
)<< "patch type " << patch.type() << " not suported" << nl
<< abort(FatalError);
}
}
// If the trackFraction = 0 something went wrong.
// Either the particle is flipping back and forth across a face perhaps
// due to velocity interpolation errors or it is in a "hole" in the mesh
// caused by face warpage.
// In both cases resolve the positional ambiguity by moving the particle
// slightly towards the cell-centre.
if (trackFraction < SMALL)
{
this->position_ +=
1.0e-6*(mesh.cellCentres()[this->celli_] - this->position_);
}
return trackFraction;
}
template<class ParticleType>
Foam::scalar Foam::ExactParticle<ParticleType>::trackToFace
(
const vector& endPosition
)
{
int dummyTd;
return trackToFace(endPosition, dummyTd);
}
template<class ParticleType>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const ExactParticle<ParticleType>& p
)
{
return operator<<(os, static_cast<const Particle<ParticleType>&>(p));
}
// ************************************************************************* //

View file

@ -1,192 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::ExactParticle
Description
Special version of Particle to do tracking on non-convex cells.
\*---------------------------------------------------------------------------*/
#ifndef ExactParticle_H
#define ExactParticle_H
#include "face.H"
#include "Particle.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class ExactParticle>
class Cloud;
// Forward declaration of friend functions and operators
template<class ParticleType>
class ExactParticle;
template<class ParticleType>
Ostream& operator<<
(
Ostream&,
const ExactParticle<ParticleType>&
);
/*---------------------------------------------------------------------------*\
Class ExactParticle Declaration
\*---------------------------------------------------------------------------*/
template<class ParticleType>
class ExactParticle
:
public Particle<ParticleType>
{
public:
friend class Cloud<ParticleType>;
// Constructors
//- Construct from components
ExactParticle
(
const Cloud<ParticleType>& cloud,
const vector& position,
const label celli
)
:
Particle<ParticleType>(cloud, position, celli)
{}
//- Construct from Istream
ExactParticle
(
const Cloud<ParticleType>& cloud,
Istream& is,
bool readFields = true
)
:
Particle<ParticleType>(cloud, is, readFields)
{}
//- Factory class to read-construct particles used for parallel transfer
class iNew
{
// Private data
const Cloud<ParticleType>& cloud_;
public:
iNew(const Cloud<ParticleType>& cloud)
:
cloud_(cloud)
{}
autoPtr<ParticleType> operator()(Istream& is) const
{
return autoPtr<ParticleType>
(
new ParticleType(cloud_, is)
);
}
};
// Destructor
virtual ~ExactParticle()
{}
// Member Functions
//- Track particle to end of trajectory
// or until it hits the boundary.
// On entry 'stepFraction()' should be set to the fraction of the
// time-step at which the tracking starts and on exit it contains
// the fraction of the time-step completed.
// Returns the boundary face index if the track stops at the
// boundary, -1 otherwise.
template<class TrackingData>
label track
(
const vector& endPosition,
TrackingData& td
);
//- Calls the templated track with dummy TrackingData
label track(const vector& endPosition);
//- Track particle to a given position and returns 1.0 if the
// trajectory is completed without hitting a face otherwise
// stops at the face and returns the fraction of the trajectory
// completed.
// on entry 'stepFraction()' should be set to the fraction of the
// time-step at which the tracking starts.
template<class TrackingData>
scalar trackToFace
(
const vector& endPosition,
TrackingData& td
);
//- Calls the templated trackToFace with dummy TrackingData
scalar trackToFace(const vector& endPosition);
// Ostream Operator
friend Ostream& operator<< <ParticleType>
(
Ostream&,
const ExactParticle<ParticleType>&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "ExactParticle.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,282 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*----------------------------------------------------------------------------*/
#include "trackedParticle.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
//- Construct from components
Foam::trackedParticle::trackedParticle
(
const Cloud<trackedParticle>& c,
const vector& position,
const label celli,
const point& end,
const label level,
const label i,
const label j
)
:
ExactParticle<trackedParticle>(c, position, celli),
end_(end),
level_(level),
i_(i),
j_(j)
{}
//- Construct from Istream
Foam::trackedParticle::trackedParticle
(
const Cloud<trackedParticle>& c,
Istream& is,
bool readFields
)
:
ExactParticle<trackedParticle>(c, is, readFields)
{
if (readFields)
{
if (is.format() == IOstream::ASCII)
{
is >> end_;
level_ = readLabel(is);
i_ = readLabel(is);
j_ = readLabel(is);
}
else
{
is.read
(
reinterpret_cast<char*>(&end_),
sizeof(end_) + sizeof(level_) + sizeof(i_) + sizeof(j_)
);
}
}
// Check state of Istream
is.check
(
"trackedParticle::trackedParticle"
"(const Cloud<trackedParticle>&, Istream&, bool)"
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::trackedParticle::move(trackedParticle::trackData& td)
{
td.switchProcessor = false;
td.keepParticle = true;
scalar deltaT = cloud().pMesh().time().deltaT().value();
scalar tEnd = (1.0 - stepFraction())*deltaT;
scalar dtMax = tEnd;
while (td.keepParticle && !td.switchProcessor && tEnd > SMALL)
{
// set the lagrangian time-step
scalar dt = min(dtMax, tEnd);
// mark visited cell with max level.
td.maxLevel()[cell()] = max(td.maxLevel()[cell()], level_);
dt *= trackToFace(end_, td);
tEnd -= dt;
stepFraction() = 1.0 - tEnd/deltaT;
}
return td.keepParticle;
}
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
const label patchI
)
{
return false;
}
bool Foam::trackedParticle::hitPatch
(
const polyPatch&,
int&,
const label
)
{
return false;
}
void Foam::trackedParticle::hitWedgePatch
(
const wedgePolyPatch&,
trackedParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::trackedParticle::hitWedgePatch
(
const wedgePolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
trackedParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::trackedParticle::hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
trackedParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::trackedParticle::hitCyclicPatch
(
const cyclicPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitProcessorPatch
(
const processorPolyPatch&,
trackedParticle::trackData& td
)
{
// Remove particle
td.switchProcessor = true;
}
void Foam::trackedParticle::hitProcessorPatch
(
const processorPolyPatch&,
int&
)
{}
void Foam::trackedParticle::hitWallPatch
(
const wallPolyPatch& wpp,
trackedParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::trackedParticle::hitWallPatch
(
const wallPolyPatch& wpp,
int&
)
{}
void Foam::trackedParticle::hitPatch
(
const polyPatch& wpp,
trackedParticle::trackData& td
)
{
// Remove particle
td.keepParticle = false;
}
void Foam::trackedParticle::hitPatch
(
const polyPatch& wpp,
int&
)
{}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Ostream& Foam::operator<<(Ostream& os, const trackedParticle& p)
{
if (os.format() == IOstream::ASCII)
{
os << static_cast<const ExactParticle<trackedParticle>&>(p)
<< token::SPACE << p.end_
<< token::SPACE << p.level_
<< token::SPACE << p.i_
<< token::SPACE << p.j_;
}
else
{
os << static_cast<const ExactParticle<trackedParticle>&>(p);
os.write
(
reinterpret_cast<const char*>(&p.end_),
sizeof(p.end_) + sizeof(p.level_) + sizeof(p.i_) + sizeof(p.j_)
);
}
// Check state of Ostream
os.check("Ostream& operator<<(Ostream&, const trackedParticle&)");
return os;
}
// ************************************************************************* //

View file

@ -1,290 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::trackedParticle
Description
Particle class that marks cells it passes through. Used to mark cells
visited by feature edges. Uses ExactParticle tracking class so
will work on concave cells.
SourceFiles
trackedParticle.C
\*---------------------------------------------------------------------------*/
#ifndef trackedParticle_H
#define trackedParticle_H
#include "ExactParticle.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class trackedParticleCloud;
/*---------------------------------------------------------------------------*\
Class trackedParticle Declaration
\*---------------------------------------------------------------------------*/
class trackedParticle
:
public ExactParticle<trackedParticle>
{
// Private data
//- end point to track to
point end_;
//- level of this particle
label level_;
//- passive label
label i_;
//- passive label
label j_;
public:
friend class Cloud<trackedParticle>;
//- Class used to pass tracking data to the trackToFace function
class trackData
{
//- Reference to the cloud containing this particle
Cloud<trackedParticle>& cloud_;
labelList& maxLevel_;
public:
bool switchProcessor;
bool keepParticle;
// Constructors
trackData(Cloud<trackedParticle>& cloud, labelList& maxLevel)
:
cloud_(cloud),
maxLevel_(maxLevel)
{}
// Member functions
Cloud<trackedParticle>& cloud()
{
return cloud_;
}
labelList& maxLevel()
{
return maxLevel_;
}
};
// Constructors
//- Construct from components
trackedParticle
(
const Cloud<trackedParticle>& c,
const vector& position,
const label celli,
const point& end,
const label level,
const label i,
const label j
);
//- Construct from Istream
trackedParticle
(
const Cloud<trackedParticle>& c,
Istream& is,
bool readFields = true
);
//- Construct and return a clone
autoPtr<trackedParticle> clone() const
{
return autoPtr<trackedParticle>(new trackedParticle(*this));
}
// Member Functions
//- point to track to
point& end()
{
return end_;
}
//- transported label
label& i()
{
return i_;
}
//- transported label
label& j()
{
return j_;
}
// Tracking
//- Track all particles to their end point
bool move(trackData&);
//- Overridable function to handle the particle hitting a patch
// Executed before other patch-hitting functions
bool hitPatch
(
const polyPatch&,
trackedParticle::trackData& td,
const label patchI
);
bool hitPatch
(
const polyPatch&,
int&,
const label patchI
);
//- Overridable function to handle the particle hitting a wedge
void hitWedgePatch
(
const wedgePolyPatch&,
trackedParticle::trackData& td
);
void hitWedgePatch
(
const wedgePolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a
// symmetryPlane
void hitSymmetryPatch
(
const symmetryPolyPatch&,
trackedParticle::trackData& td
);
void hitSymmetryPatch
(
const symmetryPolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a cyclic
void hitCyclicPatch
(
const cyclicPolyPatch&,
trackedParticle::trackData& td
);
void hitCyclicPatch
(
const cyclicPolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a
//- processorPatch
void hitProcessorPatch
(
const processorPolyPatch&,
trackedParticle::trackData& td
);
void hitProcessorPatch
(
const processorPolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a wallPatch
void hitWallPatch
(
const wallPolyPatch&,
trackedParticle::trackData& td
);
void hitWallPatch
(
const wallPolyPatch&,
int&
);
//- Overridable function to handle the particle hitting a polyPatch
void hitPatch
(
const polyPatch&,
trackedParticle::trackData& td
);
void hitPatch
(
const polyPatch&,
int&
);
// Ostream Operator
friend Ostream& operator<<(Ostream&, const trackedParticle&);
};
template<>
inline bool contiguous<trackedParticle>()
{
return true;
}
//template<>
//void Cloud<trackedParticle>::readFields();
//
//template<>
//void Cloud<trackedParticle>::writeFields() const;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | foam-extend: Open Source CFD
\\ / O peration |
\\ / A nd | For copyright notice see file Copyright
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of foam-extend.
foam-extend 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.
foam-extend 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 foam-extend. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "trackedParticle.H"
#include "Cloud.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineParticleTypeNameAndDebug(trackedParticle, 0);
defineTemplateTypeNameAndDebug(Cloud<trackedParticle>, 0);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -100,22 +100,52 @@ public:
return false;
}
//- Decompose cells with weights
//- Return for every coordinate the wanted processor number. Use the
// mesh connectivity (if needed)
// Weights get normalised so the minimum value is 1 before truncation
// to an integer so the weights should be multiples of the minimum
// value. The overall sum of weights might otherwise overflow.
virtual labelList decompose
(
const pointField& points,
const scalarField& pointWeights
);
//- Decompose cell clusters with weights on clusters
//- Return for every coordinate the wanted processor number. Gets
// passed agglomeration map (from fine to coarse cells) and coarse cell
// location. Can be overridden by decomposers that provide this
// functionality natively.
// See note on weights above.
virtual labelList decompose
(
const labelList& fineToCoarse,
const pointField& coarsePoints,
const scalarField& coarseWeights
const labelList& agglom,
const pointField& regionPoints,
const scalarField& regionWeights
);
//- Decompose cells with weights with explicitly provided connectivity
//- Same but with uniform weights
virtual labelList decompose
(
const labelList& agglom,
const pointField& regionPoints
)
{
return decompose
(
agglom,
regionPoints,
scalarField(regionPoints.size(), 1.0)
);
}
//- Return for every coordinate the wanted processor number. Explicitly
// provided mesh connectivity.
// The connectivity is equal to mesh.cellCells() except for
// - in parallel the cell numbers are global cell numbers (starting
// from 0 at processor0 and then incrementing all through the
// processors)
// - the connections are across coupled patches
// See note on weights above.
virtual labelList decompose
(
const labelListList& globalCellCells,

View file

@ -112,14 +112,22 @@ public:
return true;
}
//- Decompose cells with weights
//- Return for every coordinate the wanted processor number. Use the
// mesh connectivity (if needed)
// Weights get normalised so the minimum value is 1 before truncation
// to an integer so the weights should be multiples of the minimum
// value. The overall sum of weights might otherwise overflow.
virtual labelList decompose
(
const pointField& points,
const scalarField& pointWeights
);
//- Decompose cell clusters with weights on clusters
//- Return for every coordinate the wanted processor number. Gets
// passed agglomeration map (from fine to coarse cells) and coarse cell
// location. Can be overridden by decomposers that provide this
// functionality natively.
// See note on weights above.
virtual labelList decompose
(
const labelList& cellToRegion,
@ -127,7 +135,29 @@ public:
const scalarField& regionWeights
);
//- Decompose cells with weights with explicitly provided connectivity
//- Same but with uniform weights
virtual labelList decompose
(
const labelList& cellToRegion,
const pointField& regionPoints
)
{
return decompose
(
cellToRegion,
regionPoints,
scalarField(regionPoints.size(), 1.0)
);
}
//- Return for every coordinate the wanted processor number. Explicitly
// provided mesh connectivity.
// The connectivity is equal to mesh.cellCells() except for
// - in parallel the cell numbers are global cell numbers (starting
// from 0 at processor0 and then incrementing all through the
// processors)
// - the connections are across coupled patches
// See note on weights above.
virtual labelList decompose
(
const labelListList& globalCellCells,

View file

@ -111,22 +111,52 @@ public:
return false;
}
//- Decompose cells with weights
//- Return for every coordinate the wanted processor number. Use the
// mesh connectivity (if needed)
// Weights get normalised so the minimum value is 1 before truncation
// to an integer so the weights should be multiples of the minimum
// value. The overall sum of weights might otherwise overflow.
virtual labelList decompose
(
const pointField& points,
const scalarField& pointWeights
);
//- Decompose cell clusters with weights on clusters
//- Return for every coordinate the wanted processor number. Gets
// passed agglomeration map (from fine to coarse cells) and coarse cell
// location. Can be overridden by decomposers that provide this
// functionality natively.
// See note on weights above.
virtual labelList decompose
(
const labelList& fineToCoarse,
const pointField& coarsePoints,
const scalarField& coarseWeights
const labelList& agglom,
const pointField& regionPoints,
const scalarField& regionWeights
);
//- Decompose cells with weights with explicitly provided connectivity
//- Same but with uniform weights
virtual labelList decompose
(
const labelList& agglom,
const pointField& regionPoints
)
{
return decompose
(
agglom,
regionPoints,
scalarField(regionPoints.size(), 1.0)
);
}
//- Return for every coordinate the wanted processor number. Explicitly
// provided mesh connectivity.
// The connectivity is equal to mesh.cellCells() except for
// - in parallel the cell numbers are global cell numbers (starting
// from 0 at processor0 and then incrementing all through the
// processors)
// - the connections are across coupled patches
// See note on weights above.
virtual labelList decompose
(
const labelListList& globalCellCells,

View file

@ -1014,8 +1014,7 @@ void Foam::refinementHistory::compact()
}
splitCells_.transfer(newSplitCells);
freeSplitCells_.clear();
freeSplitCells_.labelList::clear();
freeSplitCells_.clearStorage();
if (debug)

View file

@ -336,7 +336,6 @@ void Foam::coordinateSystem::writeDict(Ostream& os, bool subDict) const
}
os.writeKeyword("name") << name_ << token::END_STATEMENT << nl;
os.writeKeyword("type") << type() << token::END_STATEMENT << nl;
os.writeKeyword("origin") << origin_ << token::END_STATEMENT << nl;
os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl;
os.writeKeyword("e3") << e3() << token::END_STATEMENT << nl;

View file

@ -136,7 +136,7 @@ boundary
}
cylinder
{
type symmetry;
type symmetryPlane;
faces
(
(10 5 24 29)

View file

@ -68,7 +68,7 @@ boundary
centreLeft
{
type symmetry;
type symmetryPlane;
faces
(
(0 4 7 3)

View file

@ -8,8 +8,5 @@ cleanCase
rm -f 0/cellToRegion
rm -rf constant/polyMesh/boundary
if [ -d "VTK" ]
then
rm -r VTK
fi
rm -rf VTK

View file

@ -1,25 +0,0 @@
#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application="MRFSimpleFoam"
#application="simpleFoam"
#Create the mesh:
m4 < constant/polyMesh/blockMeshDict_mixingPlane.m4 > constant/polyMesh/blockMeshDict
blockMesh
transformPoints -cylToCart "((0 0 0) (0 0 1) (1 0 0))"
# Set 0-directory and create GGI set:
cp -r 0_orig 0
setSet -batch setBatchGgi
setsToZones -noFlipMap
#Fix constant/boundary:
changeDictionary
#Pick settings:
cp system/fvSolution_mixingPlane system/fvSolution
runApplication $application

View file

@ -1,112 +0,0 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object changeDictionaryDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dictionaryReplacement
{
epsilon
{
boundaryField
{
GVOUTLET
{
type mixingPlane;
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
DTINLET
{
type mixingPlane;
}
}
}
k
{
boundaryField
{
GVOUTLET
{
type mixingPlane;
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
DTINLET
{
type mixingPlane;
}
}
}
U
{
boundaryField
{
GVOUTLET
{
type mixingPlane;
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
DTINLET
{
type mixingPlane;
}
}
}
p
{
boundaryField
{
GVOUTLET
{
type mixingPlane;
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
DTINLET
{
type mixingPlane;
}
}
}
}
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
GVINLET
{
type calculated;
value uniform 0;
}
GVOUTLET
{
type ggi;
value uniform 0;
}
GVCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
GVCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
GVBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUINLET
{
type ggi;
value uniform 0;
}
RUOUTLET
{
type ggi;
value uniform 0;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
RUBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTINLET
{
type ggi;
value uniform 0;
}
DTOUTLET
{
type calculated;
value uniform 0;
}
DTCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
DTCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
DTHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
}
// ************************************************************************* //

View file

@ -1,5 +1,4 @@
#!/bin/sh
( cd constant/polyMesh && \rm -rf boundary* blockMeshDict *Zones* faces* neighbour* owner* points* sets )
( cd system && \rm -f fvSolution )
\rm -rf 0 [1-9]* VTK log* processor*

View file

@ -3,19 +3,17 @@
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application="MRFSimpleFoam"
application=`getApplication`
#Create the mesh:
m4 < constant/polyMesh/blockMeshDict.m4 > constant/polyMesh/blockMeshDict
blockMesh
runApplication blockMesh
transformPoints -scale "(1 20 1)"
transformPoints -cylToCart "((0 0 0) (0 0 1) (1 0 0))"
# Set 0-directory and create GGI set:
cp -r 0_orig 0
setSet -batch setBatchGgi
setsToZones -noFlipMap
#Pick settings:
cp system/fvSolution_ggi system/fvSolution
runApplication setSet -batch setBatchGgi
runApplication setsToZones -noFlipMap
runApplication $application

View file

@ -20,7 +20,7 @@ define(calc, [esyscmd(perl -e 'printf ($1)')])
//define(calc, [esyscmd(echo $1 | bc | tr -d \\n)])
define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
define(pi, 3.14159265)
define(pi, calc(3.14159265/20))
define(hex2D, hex ($1b $2b $3b $4b $1t $2t $3t $4t))
define(quad2D, ($1b $2b $2t $1t))
@ -200,7 +200,7 @@ blocks
hex2D(GV1l, GV1r, GV2r, GV2l)
(GVtc GVbac GVrc)
simpleGrading (1 0.2 1)
simpleGrading (1 1 1)
hex2D(GV2l, GV2r, GV3r, GV3l)
(GVtc GViac GVrc)
@ -215,7 +215,7 @@ blocks
hex2D(RU1l, RU1r, RU2r, RU2l)
rotor
(RUtc RUbac RUrc)
simpleGrading (1 0.4 1)
simpleGrading (1 1 1)
hex2D(RU2l, RU2r, RU3r, RU3l)
rotor

View file

@ -44,4 +44,19 @@ timePrecision 6;
runTimeModifiable yes;
// Compute the flux value on each side of a GGI interface
functions
(
ggiCheck
{
// Type of functionObject
type ggiCheck;
phi phi;
// Where to load it from (if not already in solver)
functionObjectLibs ("libcheckFunctionObjects.so");
}
);
// ************************************************************************* //

View file

@ -0,0 +1,119 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 1 -1 0 0 0 0 ];
internalField uniform ( 0 0 -1 );
boundaryField
{
GVINLET
{
type fixedValue;
value uniform ( 0 0 -1 );
}
GVOUTLET
{
type mixingPlane;
}
GVCYCLIC1
{
type cyclicGgi;
}
GVCYCLIC2
{
type cyclicGgi;
}
GVBLADE
{
type fixedValue;
value uniform ( 0 0 0 );
}
GVHUB
{
type rotatingWallVelocity;
origin ( 0 0 0 );
axis ( 0 0 1 );
omega -10;
value uniform ( 0 0 0 );
}
GVSHROUD
{
type fixedValue;
value uniform ( 0 0 0 );
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
RUCYCLIC1
{
type cyclicGgi;
}
RUCYCLIC2
{
type cyclicGgi;
}
RUBLADE
{
type fixedValue;
value uniform ( 0 0 0 );
}
RUHUB
{
type fixedValue;
value uniform ( 0 0 0 );
}
RUSHROUD
{
type fixedValue;
value uniform ( 0 0 0 );
}
DTINLET
{
type mixingPlane;
}
DTOUTLET
{
type zeroGradient;
}
DTCYCLIC1
{
type cyclicGgi;
}
DTCYCLIC2
{
type cyclicGgi;
}
DTHUB
{
type fixedValue;
value uniform ( 0 0 0 );
}
DTSHROUD
{
type fixedValue;
value uniform ( 0 0 0 );
}
}
// ************************************************************************* //

View file

@ -0,0 +1,158 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 2 -3 0 0 0 0 ];
internalField uniform 14.855;
boundaryField
{
GVINLET
{
type fixedValue;
value uniform 14.855;
}
GVOUTLET
{
type mixingPlane;
value uniform 14.855;
}
GVCYCLIC1
{
type cyclicGgi;
value uniform 14.855;
}
GVCYCLIC2
{
type cyclicGgi;
value uniform 14.855;
}
GVBLADE
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
GVHUB
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
GVSHROUD
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
RUINLET
{
type mixingPlane;
value uniform 14.855;
}
RUOUTLET
{
type mixingPlane;
value uniform 14.855;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 14.855;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 14.855;
}
RUBLADE
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
RUHUB
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
RUSHROUD
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
DTINLET
{
type mixingPlane;
value uniform 14.855;
}
DTOUTLET
{
type zeroGradient;
}
DTCYCLIC1
{
type cyclicGgi;
value uniform 14.855;
}
DTCYCLIC2
{
type cyclicGgi;
value uniform 14.855;
}
DTHUB
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
DTSHROUD
{
type epsilonWallFunction;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,126 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 0.375;
boundaryField
{
GVINLET
{
type fixedValue;
value uniform 0.375;
}
GVOUTLET
{
type mixingPlane;
value uniform 0.375;
}
GVCYCLIC1
{
type cyclicGgi;
value uniform 0.375;
}
GVCYCLIC2
{
type cyclicGgi;
value uniform 0.375;
}
GVBLADE
{
type kqRWallFunction;
value uniform 0.375;
}
GVHUB
{
type kqRWallFunction;
value uniform 0.375;
}
GVSHROUD
{
type kqRWallFunction;
value uniform 0.375;
}
RUINLET
{
type mixingPlane;
value uniform 0.375;
}
RUOUTLET
{
type mixingPlane;
value uniform 0.375;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 0.375;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 0.375;
}
RUBLADE
{
type kqRWallFunction;
value uniform 0.375;
}
RUHUB
{
type kqRWallFunction;
value uniform 0.375;
}
RUSHROUD
{
type kqRWallFunction;
value uniform 0.375;
}
DTINLET
{
type mixingPlane;
value uniform 0.375;
}
DTOUTLET
{
type zeroGradient;
}
DTCYCLIC1
{
type cyclicGgi;
value uniform 0.375;
}
DTCYCLIC2
{
type cyclicGgi;
value uniform 0.375;
}
DTHUB
{
type kqRWallFunction;
value uniform 0.375;
}
DTSHROUD
{
type kqRWallFunction;
value uniform 0.375;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
GVINLET
{
type calculated;
value uniform 0;
}
GVOUTLET
{
type mixingPlane;
value uniform 0;
}
GVCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
GVCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
GVBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUINLET
{
type mixingPlane;
value uniform 0;
}
RUOUTLET
{
type mixingPlane;
value uniform 0;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
RUBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTINLET
{
type mixingPlane;
value uniform 0;
}
DTOUTLET
{
type calculated;
value uniform 0;
}
DTCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
DTCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
DTHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,108 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [ 0 2 -2 0 0 0 0 ];
internalField uniform 0;
boundaryField
{
GVINLET
{
type zeroGradient;
}
GVOUTLET
{
type mixingPlane;
}
GVCYCLIC1
{
type cyclicGgi;
}
GVCYCLIC2
{
type cyclicGgi;
}
GVBLADE
{
type zeroGradient;
}
GVHUB
{
type zeroGradient;
}
GVSHROUD
{
type zeroGradient;
}
RUINLET
{
type mixingPlane;
}
RUOUTLET
{
type mixingPlane;
}
RUCYCLIC1
{
type cyclicGgi;
}
RUCYCLIC2
{
type cyclicGgi;
}
RUBLADE
{
type zeroGradient;
}
RUHUB
{
type zeroGradient;
}
RUSHROUD
{
type zeroGradient;
}
DTINLET
{
type mixingPlane;
}
DTOUTLET
{
type fixedValue;
value uniform 0;
}
DTCYCLIC1
{
type cyclicGgi;
}
DTCYCLIC2
{
type cyclicGgi;
}
DTHUB
{
type zeroGradient;
}
DTSHROUD
{
type zeroGradient;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,4 @@
#!/bin/sh
( cd constant/polyMesh && \rm -rf boundary* blockMeshDict *Zones* faces* neighbour* owner* points* sets )
\rm -rf 0 [1-9]* VTK log* processor*

View file

@ -0,0 +1,19 @@
#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application=`getApplication`
#Create the mesh:
m4 < constant/polyMesh/blockMeshDict.m4 > constant/polyMesh/blockMeshDict
runApplication blockMesh
transformPoints -scale "(1 20 1)"
transformPoints -cylToCart "((0 0 0) (0 0 1) (1 0 0))"
# Set 0-directory and create GGI set:
cp -r 0_orig 0
runApplication setSet -batch setBatchGgi
runApplication setsToZones -noFlipMap
runApplication $application

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object MRFZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
1
(
rotor
{
//patches (rotor);
// Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches ( RUSHROUD );
origin origin [0 1 0 0 0 0 0] (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1);
omega omega [0 0 -1 0 0 0 0] -10;
}
)
// ************************************************************************* //

View file

@ -0,0 +1,191 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel RNGkEpsilon;
turbulence on;
printCoeffs on;
laminarCoeffs
{
}
kEpsilonCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
RNGkEpsilonCoeffs
{
Cmu 0.0845;
C1 1.42;
C2 1.68;
alphak 1.39;
alphaEps 1.39;
eta0 4.38;
beta 0.012;
}
kOmegaSSTCoeffs
{
alphaK1 0.85034;
alphaK2 1.0;
alphaOmega1 0.5;
alphaOmega2 0.85616;
gamma1 0.5532;
gamma2 0.4403;
beta1 0.0750;
beta2 0.0828;
betaStar 0.09;
a1 0.31;
c1 10;
Cmu 0.09;
}
NonlinearKEShihCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76932;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
}
LienCubicKECoeffs
{
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
}
QZetaCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaZeta 0.76923;
anisotropic no;
}
LaunderSharmaKECoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
LamBremhorstKECoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphaEps 0.76923;
}
LienCubicKELowReCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
A1 1.25;
A2 1000;
Ctau1 -4;
Ctau2 13;
Ctau3 -2;
alphaKsi 0.9;
Am 0.016;
Aepsilon 0.263;
Amu 0.00222;
}
LienLeschzinerLowReCoeffs
{
Cmu 0.09;
C1 1.44;
C2 1.92;
alphak 1;
alphaEps 0.76923;
Am 0.016;
Aepsilon 0.263;
Amu 0.00222;
}
LRRCoeffs
{
Cmu 0.09;
Clrr1 1.8;
Clrr2 0.6;
C1 1.44;
C2 1.92;
Cs 0.25;
Ceps 0.15;
alphaEps 0.76923;
}
LaunderGibsonRSTMCoeffs
{
Cmu 0.09;
Clg1 1.8;
Clg2 0.6;
C1 1.44;
C2 1.92;
C1Ref 0.5;
C2Ref 0.3;
Cs 0.25;
Ceps 0.15;
alphaEps 0.76923;
alphaR 1.22;
}
SpalartAllmarasCoeffs
{
alphaNut 1.5;
Cb1 0.1355;
Cb2 0.622;
Cw2 0.3;
Cw3 2;
Cv1 7.1;
Cv2 5.0;
}
wallFunctionCoeffs
{
kappa 0.4187;
E 9;
}
// ************************************************************************* //

View file

@ -20,7 +20,7 @@ define(calc, [esyscmd(perl -e 'printf ($1)')])
//define(calc, [esyscmd(echo $1 | bc | tr -d \\n)])
define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
define(pi, 3.14159265)
define(pi, calc(3.14159265/20))
define(hex2D, hex ($1b $2b $3b $4b $1t $2t $3t $4t))
define(quad2D, ($1b $2b $2t $1t))
@ -200,7 +200,7 @@ blocks
hex2D(GV1l, GV1r, GV2r, GV2l)
(GVtc GVbac GVrc)
simpleGrading (1 0.2 1)
simpleGrading (1 1 1)
hex2D(GV2l, GV2r, GV3r, GV3l)
(GVtc GViac GVrc)
@ -215,7 +215,7 @@ blocks
hex2D(RU1l, RU1r, RU2r, RU2l)
rotor
(RUtc RUbac RUrc)
simpleGrading (1 0.4 1)
simpleGrading (1 1 1)
hex2D(RU2l, RU2r, RU3r, RU3l)
rotor
@ -285,11 +285,13 @@ boundary
zone GVOUTLETZone;
coordinateSystem
{
type cylindrical;
//type cylindrical;
//name mixingCS;
origin (0 0 0);
e1 (1 0 0);
e3 (0 0 1);
axis (0 0 1);
direction (1 0 0);
//e1 (1 0 0);
//e3 (0 0 1);
}
ribbonPatch
{
@ -386,11 +388,13 @@ boundary
zone RUINLETZone;
coordinateSystem
{
type cylindrical;
//type cylindrical;
//name mixingCS;
origin (0 0 0);
e1 (1 0 0);
e3 (0 0 1);
axis (0 0 1);
direction (1 0 0);
//e1 (1 0 0);
//e3 (0 0 1);
}
ribbonPatch
{
@ -411,11 +415,13 @@ boundary
zone RUOUTLETZone;
coordinateSystem
{
type cylindrical;
//type cylindrical;
//name mixingCS;
origin (0 0 0);
e1 (1 0 0);
e3 (0 0 1);
axis (0 0 1);
direction (1 0 0);
//e1 (1 0 0);
//e3 (0 0 1);
}
ribbonPatch
{
@ -512,11 +518,13 @@ boundary
zone DTINLETZone;
coordinateSystem
{
type cylindrical;
//type cylindrical;
//name mixingCS;
origin (0 0 0);
e1 (1 0 0);
e3 (0 0 1);
axis (0 0 1);
direction (1 0 0);
//e1 (1 0 0);
//e3 (0 0 1);
}
ribbonPatch
{

View file

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu nu [0 2 -1 0 0 0 0] 1e-05;
CrossPowerLawCoeffs
{
nu0 nu0 [0 2 -1 0 0 0 0] 1e-06;
nuInf nuInf [0 2 -1 0 0 0 0] 1e-06;
m m [0 0 1 0 0 0 0] 1;
n n [0 0 0 0 0 0 0] 1;
}
BirdCarreauCoeffs
{
nu0 nu0 [0 2 -1 0 0 0 0] 1e-06;
nuInf nuInf [0 2 -1 0 0 0 0] 1e-06;
k k [0 0 1 0 0 0 0] 0;
n n [0 0 0 0 0 0 0] 1;
}
// ************************************************************************* //

View file

@ -0,0 +1,11 @@
faceSet GVCYCLIC1Zone new patchToFace GVCYCLIC1
faceSet GVCYCLIC2Zone new patchToFace GVCYCLIC2
faceSet RUCYCLIC1Zone new patchToFace RUCYCLIC1
faceSet RUCYCLIC2Zone new patchToFace RUCYCLIC2
faceSet DTCYCLIC1Zone new patchToFace DTCYCLIC1
faceSet DTCYCLIC2Zone new patchToFace DTCYCLIC2
faceSet GVOUTLETZone new patchToFace GVOUTLET
faceSet RUINLETZone new patchToFace RUINLET
faceSet RUOUTLETZone new patchToFace RUOUTLET
faceSet DTINLETZone new patchToFace DTINLET
quit

View file

@ -0,0 +1,74 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application MRFSimpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 200;
deltaT 1;
writeControl timeStep;
writeInterval 20;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression compressed;
timeFormat general;
timePrecision 6;
runTimeModifiable yes;
// Compute the flux value on each side of a GGI interface
functions
(
ggiCheck
{
// Type of functionObject
type ggiCheck;
phi phi;
// Where to load it from (if not already in solver)
functionObjectLibs ("libcheckFunctionObjects.so");
}
// Compute the flux value on each side of a mixingPlane interface
mixingPlaneCheck
{
// Type of functionObject
type mixingPlaneCheck;
phi phi;
// Where to load it from (if not already in solver)
functionObjectLibs ("libcheckFunctionObjects.so");
}
);
// ************************************************************************* //

View file

@ -0,0 +1,89 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object decomposeParDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
numberOfSubdomains 8;
//method metis;
method patchConstrained;
globalFaceZones
(
GVCYCLIC2Zone
RUCYCLIC1Zone
RUINLETZone
RUCYCLIC2Zone
RUOUTLETZone
GVOUTLETZone
DTINLETZone
GVCYCLIC1Zone
DTCYCLIC1Zone
DTCYCLIC2Zone
);
patchConstrainedCoeffs
{
method metis;
numberOfSubdomains 8;
patchConstraints
(
(RUINLET 1)
(GVOUTLET 1)
(RUOUTLET 2)
(DTINLET 2)
);
}
simpleCoeffs
{
n (2 2 1);
delta 0.001;
}
hierarchicalCoeffs
{
n (1 1 1);
delta 0.001;
order xyz;
}
metisCoeffs
{
processorWeights
(
1
1
1
1
1
1
1
1
);
}
manualCoeffs
{
dataFile "";
}
distributed no;
roots
(
);
// ************************************************************************* //

View file

@ -0,0 +1,71 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default steadyState;
}
gradSchemes
{
default Gauss linear;
grad(p) Gauss linear;
grad(U) Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss limitedLinearV 1;
div(phi,k) Gauss limitedLinear 1;
div(phi,epsilon) Gauss limitedLinear 1;
div((nuEff*dev(grad(U).T()))) Gauss linear;
}
laplacianSchemes
{
default none;
laplacian(nuEff,U) Gauss linear corrected;
laplacian((1|A(U)),p) Gauss linear corrected;
laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
interpolate(U) linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p;
}
mixingPlane
{
default areaAveraging;
//U fluxAveragingAdjustMassFlow;
//p zeroGradientAreaAveragingMix;
}
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object nut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
GVINLET
{
type calculated;
value uniform 0;
}
GVOUTLET
{
type overlapGgi;
value uniform 0;
}
GVCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
GVCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
GVBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
GVSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUINLET
{
type overlapGgi;
value uniform 0;
}
RUOUTLET
{
type overlapGgi;
value uniform 0;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
RUBLADE
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
RUSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTINLET
{
type overlapGgi;
value uniform 0;
}
DTOUTLET
{
type calculated;
value uniform 0;
}
DTCYCLIC1
{
type cyclicGgi;
value uniform 0;
}
DTCYCLIC2
{
type cyclicGgi;
value uniform 0;
}
DTHUB
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
DTSHROUD
{
type nutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
}
// ************************************************************************* //

View file

@ -1,4 +1,4 @@
#!/bin/sh
( cd constant/polyMesh && rm -r boundary* blockMeshDict *Zones* faces* neighbour* owner* points* sets )
rm -r 0 0.* [1-9]* VTK log* processor*
( cd constant/polyMesh && rm -rf boundary* blockMeshDict *Zones* faces* neighbour* owner* points* sets )
rm -rf 0 0.* [1-9]* VTK log* processor*

View file

@ -3,16 +3,17 @@
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
application="pimpleDyMFoam"
application=`getApplication`
#Create the mesh:
m4 < constant/polyMesh/blockMeshDict.m4 > constant/polyMesh/blockMeshDict
blockMesh
runApplication blockMesh
transformPoints -scale "(1 20 1)"
transformPoints -cylToCart "((0 0 0) (0 0 1) (1 0 0))"
# Set 0-directory and create GGI set:
cp -r 0_orig 0
setSet -batch setBatchGgi
setsToZones -noFlipMap
runApplication setSet -batch setBatchGgi
runApplication setsToZones -noFlipMap
runApplication $application

View file

@ -20,7 +20,7 @@ define(calc, [esyscmd(perl -e 'printf ($1)')])
//define(calc, [esyscmd(echo $1 | bc | tr -d \\n)])
define(VCOUNT, 0)
define(vlabel, [[// ]Vertex $1 = VCOUNT define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))])
define(pi, 3.14159265)
define(pi, calc(3.14159265/20))
define(hex2D, hex ($1b $2b $3b $4b $1t $2t $3t $4t))
define(quad2D, ($1b $2b $2t $1t))
@ -200,7 +200,7 @@ blocks
hex2D(GV1l, GV1r, GV2r, GV2l)
(GVtc GVbac GVrc)
simpleGrading (1 0.2 1)
simpleGrading (1 1 1)
hex2D(GV2l, GV2r, GV3r, GV3l)
(GVtc GViac GVrc)
@ -215,7 +215,7 @@ blocks
hex2D(RU1l, RU1r, RU2r, RU2l)
rotor
(RUtc RUbac RUrc)
simpleGrading (1 0.4 1)
simpleGrading (1 1 1)
hex2D(RU2l, RU2r, RU3r, RU3l)
rotor

View file

@ -14,7 +14,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application simpleFoam;
application pimpleDyMFoam;
startFrom startTime;

View file

@ -0,0 +1,62 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object Uabs;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
RUINLET
{
type calculated;
value uniform (0 0 0);
}
RUOUTLET
{
type calculated;
value uniform (0 0 0);
}
RUCYCLIC1
{
type cyclicGgi;
value uniform (0 0 0);
}
RUCYCLIC2
{
type cyclicGgi;
value uniform (0 0 0);
}
RUBLADE
{
type calculated;
value uniform (0 0 0);
}
RUHUB
{
type calculated;
value uniform (0 0 0);
}
RUSHROUD
{
type calculated;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,61 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object Urel;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 -1);
boundaryField
{
RUINLET
{
type SRFVelocity;
inletValue uniform (0 0 -1);
relative no;
value uniform (0 0 0);
}
RUOUTLET
{
type zeroGradient;
}
RUCYCLIC1
{
type cyclicGgi;
}
RUCYCLIC2
{
type cyclicGgi;
}
RUBLADE
{
type fixedValue;
value uniform (0 0 0);
}
RUHUB
{
type fixedValue;
value uniform (0 0 0);
}
RUSHROUD
{
type SRFVelocity;
inletValue uniform (0 0 0);
relative yes;
value uniform (0 0 0);
}
}
// ************************************************************************* //

View file

@ -0,0 +1,75 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | foam-extend: Open Source CFD |
| \\ / O peration | Version: 3.1 |
| \\ / A nd | Web: http://www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 14.855;
boundaryField
{
RUINLET
{
type fixedValue;
value uniform 14.855;
}
RUOUTLET
{
type zeroGradient;
}
RUCYCLIC1
{
type cyclicGgi;
value uniform 14.855;
}
RUCYCLIC2
{
type cyclicGgi;
value uniform 14.855;
}
RUBLADE
{
type epsilonWallFunction;
U Urel;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
RUHUB
{
type epsilonWallFunction;
U Urel;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
RUSHROUD
{
type epsilonWallFunction;
U Urel;
refValue uniform 0;
value uniform 14.855;
Cmu 0.09;
kappa 0.41;
E 9.8;
}
}
// ************************************************************************* //

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