createPatch: writing the cyclic match OBJ files is now optional

The new optional switch 'writeCyclicMatch' can be set to 'true' to enable the writing of
the cyclic match OBJ files; defaults to 'false'.

Patch contributed by Bruno Santos
Resolves patch request https://bugs.openfoam.org/view.php?id=2685
This commit is contained in:
Henry Weller
2017-09-09 23:00:27 +01:00
parent 9faf06fe54
commit f53f52a691
29 changed files with 647 additions and 12 deletions

View File

@ -195,8 +195,8 @@ void filterPatches(polyMesh& mesh, const HashSet<word>& addedPatchNames)
}
// Dump for all patches the current match
void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
// Write current match for all patches the as OBJ files
void writeCyclicMatchObjs(const fileName& prefix, const polyMesh& mesh)
{
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -211,10 +211,10 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
const cyclicPolyPatch& cycPatch =
refCast<const cyclicPolyPatch>(patches[patchi]);
// Dump patches
// Write patches
{
OFstream str(prefix+cycPatch.name()+".obj");
Pout<< "Dumping " << cycPatch.name()
OFstream str(prefix+cycPatch.name() + ".obj");
Pout<< "Writing " << cycPatch.name()
<< " faces to " << str.name() << endl;
meshTools::writeOBJ
(
@ -227,7 +227,7 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
const cyclicPolyPatch& nbrPatch = cycPatch.neighbPatch();
{
OFstream str(prefix+nbrPatch.name()+".obj");
Pout<< "Dumping " << nbrPatch.name()
Pout<< "Writing " << nbrPatch.name()
<< " faces to " << str.name() << endl;
meshTools::writeOBJ
(
@ -242,7 +242,7 @@ void dumpCyclicMatch(const fileName& prefix, const polyMesh& mesh)
OFstream str(prefix+cycPatch.name()+nbrPatch.name()+"_match.obj");
label vertI = 0;
Pout<< "Dumping cyclic match as lines between face centres to "
Pout<< "Writing cyclic match as lines between face centres to "
<< str.name() << endl;
forAll(cycPatch, facei)
@ -532,6 +532,12 @@ int main(int argc, char *argv[])
// Whether to synchronise points
const Switch pointSync(dict.lookup("pointSync"));
// Whether to write cyclic matches to .OBJ files
const Switch writeCyclicMatch
(
dict.lookupOrDefault("writeCyclicMatch", false)
);
const polyBoundaryMesh& patches = mesh.boundaryMesh();
@ -539,7 +545,10 @@ int main(int argc, char *argv[])
patches.checkParallelSync(true);
dumpCyclicMatch("initial_", mesh);
if (writeCyclicMatch)
{
writeCyclicMatchObjs("initial_", mesh);
}
// Read patch construct info from dictionary
PtrList<dictionary> patchSources(dict.lookup("patches"));
@ -758,7 +767,10 @@ int main(int argc, char *argv[])
autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, true);
mesh.movePoints(map().preMotionPoints());
dumpCyclicMatch("coupled_", mesh);
if (writeCyclicMatch)
{
writeCyclicMatchObjs("coupled_", mesh);
}
// Synchronise points.
if (!pointSync)
@ -869,7 +881,10 @@ int main(int argc, char *argv[])
filterPatches(mesh, addedPatchNames);
dumpCyclicMatch("final_", mesh);
if (writeCyclicMatch)
{
writeCyclicMatchObjs("final_", mesh);
}
// Set the precision of the points data to 10

View File

@ -44,6 +44,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -12,9 +12,8 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
matchTolerance 1E-3;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pointSync false;

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -12,6 +12,7 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do a synchronisation of coupled points after creation of any patches.
@ -19,6 +20,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -14,6 +14,7 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pointSync false;
patches

View File

@ -12,6 +12,7 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
pointSync false;

View File

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0 0 0);
boundaryField
{
movingWall
{
type fixedValue;
value uniform (1 0 0);
}
bottomWall
{
type noSlip;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,36 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0;
boundaryField
{
movingWall
{
type zeroGradient;
}
bottomWall
{
type zeroGradient;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,37 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volSymmTensorField;
object R;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform (0 0 0 0 0 0);
boundaryField
{
movingWall
{
type zeroGradient;
}
bottomWall
{
type zeroGradient;
}
#includeEtc "caseDicts/setConstraintTypes"
}
// ************************************************************************* //

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
# Delete OBJ files that are created by createPatch,
# when 'dumpCyclicMatches' set to true.
rm -f $objFiles > /dev/null 2>&1
#------------------------------------------------------------------------------

View File

@ -0,0 +1,13 @@
#!/bin/sh
cd ${0%/*} || exit 1 # Run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication createPatch -overwrite
runApplication $(getApplication)
#------------------------------------------------------------------------------

View File

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object transportProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
transportModel Newtonian;
nu [0 2 -1 0 0 0 0] 1.5e-05;
BirdCarreauCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
k [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}
CrossPowerLawCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
nuInf [0 2 -1 0 0 0 0] 1e-05;
m [0 0 1 0 0 0 0] 1;
n [0 0 0 0 0 0 0] 0.5;
}
powerLawCoeffs
{
nuMax [0 2 -1 0 0 0 0] 1e-03;
nuMin [0 2 -1 0 0 0 0] 1e-05;
k [0 2 -1 0 0 0 0] 1e-05;
n [0 0 0 0 0 0 0] 1;
}
HerschelBulkleyCoeffs
{
nu0 [0 2 -1 0 0 0 0] 1e-03;
tau0 [0 2 -2 0 0 0 0] 1;
k [0 2 -1 0 0 0 0] 1e-05;
n [0 0 0 0 0 0 0] 1;
}
// ************************************************************************* //

View File

@ -0,0 +1,32 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
laminar
{
laminarModel Maxwell;
MaxwellCoeffs
{
nuM 1;
lambda 5;
}
printCoeffs on;
}
// ************************************************************************* //

View File

@ -0,0 +1,89 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 0.1;
vertices
(
(0 0 0)
(1 0 0)
(1 1 0)
(0 1 0)
(0 0 0.1)
(1 0 0.1)
(1 1 0.1)
(0 1 0.1)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (20 20 1) simpleGrading (1 1 1)
);
edges
(
);
boundary
(
movingWall
{
type wall;
faces
(
(3 7 6 2)
);
}
bottomWall
{
type wall;
faces
(
(1 5 4 0)
);
}
left
{
type wall;
faces
(
(0 4 7 3)
);
}
right
{
type wall;
faces
(
(2 6 5 1)
);
}
frontAndBack
{
type empty;
faces
(
(0 3 2 1)
(4 5 6 7)
);
}
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application pimpleFoam;
startFrom startTime;
startTime 0;
stopAt endTime;
endTime 25;
deltaT 0.005;
writeControl runTime;
writeInterval 0.5;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression off;
timeFormat general;
timePrecision 6;
runTimeModifiable true;
// ************************************************************************* //

View File

@ -0,0 +1,96 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// This application/dictionary controls:
// - optional: create new patches from boundary faces (either given as
// a set of patches or as a faceSet)
// - always: order faces on coupled patches such that they are opposite. This
// is done for all coupled faces, not just for any patches created.
// - optional: synchronise points on coupled patches.
// - always: remove zero-sized (non-coupled) patches (that were not added)
// 1. Create cyclic:
// - specify where the faces should come from
// - specify the type of cyclic. If a rotational specify the rotationAxis
// and centre to make matching easier
// - always create both halves in one invocation with correct 'neighbourPatch'
// setting.
// - optionally pointSync true to guarantee points to line up.
// 2. Correct incorrect cyclic:
// This will usually fail upon loading:
// "face 0 area does not match neighbour 2 by 0.0100005%"
// " -- possible face ordering problem."
// - in polyMesh/boundary file:
// - loosen matchTolerance of all cyclics to get case to load
// - or change patch type from 'cyclic' to 'patch'
// and regenerate cyclic as above
// Do a synchronisation of coupled points after creation of any patches.
// Note: this does not work with points that are on multiple coupled patches
// with transformations (i.e. cyclics).
pointSync true;
// Optional: Write cyclic matches into .obj format; defaults to false.
// writeCyclicMatch false;
// Patches to create.
patches
(
{
// Name of new patch
name cyc_half0;
// Dictionary to construct new patch from
patchInfo
{
type cyclic;
neighbourPatch cyc_half1;
}
// How to construct: either from 'patches' or 'set'
constructFrom patches;
// If constructFrom = patches : names of patches. Wildcards allowed.
patches (left);
// If constructFrom = set : name of faceSet
set f0;
}
{
// Name of new patch
name cyc_half1;
// Dictionary to construct new patch from
patchInfo
{
type cyclic;
neighbourPatch cyc_half0;
}
// How to construct: either from 'patches' or 'set'
constructFrom patches;
// If constructFrom = patches : names of patches. Wildcards allowed.
patches (right);
// If constructFrom = set : name of faceSet
set f0;
}
);
// ************************************************************************* //

View File

@ -0,0 +1,54 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default backward;
}
gradSchemes
{
default Gauss linear;
}
divSchemes
{
default none;
div(phi,U) Gauss linearUpwind grad(U);
div(phi,sigma) Gauss vanAlbada;
div(sigma) Gauss linear;
div((nu*dev2(T(grad(U))))) Gauss linear;
div((nuM*grad(U))) Gauss linear;
}
laplacianSchemes
{
default Gauss linear uncorrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default uncorrected;
}
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
smoother DIC;
tolerance 1e-6;
relTol 0.05;
}
"(U|sigma)"
{
solver smoothSolver;
smoother symGaussSeidel;
tolerance 1e-6;
relTol 0.1;
}
pFinal
{
$p;
relTol 0;
}
"(U|sigma)Final"
{
$U;
relTol 0;
}
}
PIMPLE
{
momentumPredictor off;
nOuterCorrectors 15;
nCorrectors 3;
nNonOrthogonalCorrectors 0;
pRefCell 0;
pRefValue 0;
turbOnFinalIterOnly no;
}
relaxationFactors
{
equations
{
".*" 1;
}
}
// ************************************************************************* //

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patchInfo
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -45,6 +45,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -12,6 +12,7 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do a synchronisation of coupled points after creation of any patches.
@ -19,6 +20,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -12,6 +12,7 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do a synchronisation of coupled points after creation of any patches.
@ -19,6 +20,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(

View File

@ -12,6 +12,7 @@ FoamFile
class dictionary;
object createPatchDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Do a synchronisation of coupled points after creation of any patches.
@ -19,6 +20,9 @@ FoamFile
// with transformations (i.e. cyclics).
pointSync false;
// Optional: Write cyclic matches into .obj format; defaults to false.
writeCyclicMatch false;
// Patches to create.
patches
(