Commit 54ac451b authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add -dict option for mirrorMesh

parent c4ec4121
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -31,24 +31,37 @@ License
Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
:
fvMesh(io),
mirrorMeshDict_
mirrorFvMesh
(
IOobject
io,
IOdictionary
(
"mirrorMeshDict",
time().system(),
*this,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
IOobject
(
"mirrorMeshDict",
io.time().system(),
io.time(),
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
)
)
{}
Foam::mirrorFvMesh::mirrorFvMesh
(
const IOobject& io,
const IOdictionary& mirrorDict
)
:
fvMesh(io)
{
plane mirrorPlane(mirrorMeshDict_);
plane mirrorPlane(mirrorDict);
const scalar planeTolerance
(
mirrorMeshDict_.get<scalar>("planeTolerance")
mirrorDict.get<scalar>("planeTolerance")
);
const pointField& oldPoints = points();
......@@ -57,6 +70,9 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
const label nOldInternalFaces = nInternalFaces();
const polyPatchList& oldPatches = boundaryMesh();
Info<< "Mirroring mesh at origin:" << mirrorPlane.origin()
<< " normal:" << mirrorPlane.normal() << nl;
// Mirror the points
Info<< "Mirroring points. Old points: " << oldPoints.size();
......@@ -66,15 +82,15 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
labelList mirrorPointLookup(oldPoints.size(), -1);
// Grab the old points
forAll(oldPoints, pointi)
for (const point& pt : oldPoints)
{
newPoints[nNewPoints] = oldPoints[pointi];
nNewPoints++;
newPoints[nNewPoints] = pt;
++nNewPoints;
}
forAll(oldPoints, pointi)
{
scalar alpha =
const scalar alpha =
mirrorPlane.normalIntersect
(
oldPoints[pointi],
......@@ -121,7 +137,6 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
}
Info<< "Mirroring faces. Old faces: " << oldFaces.size();
// Algorithm:
......@@ -325,7 +340,7 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
Info<< "Mirroring patches. Old patches: " << boundary().size()
<< " New patches: " << boundary().size() << endl;
Info<< "Mirroring cells. Old cells: " << oldCells.size()
Info<< "Mirroring cells. Old cells: " << oldCells.size()
<< " New cells: " << 2*oldCells.size() << endl;
cellList newCells(2*oldCells.size());
......
......@@ -51,9 +51,6 @@ class mirrorFvMesh
{
// Private data
//- Mirror dictionary
IOdictionary mirrorMeshDict_;
//- Mirrored mesh
autoPtr<fvMesh> mirrorMeshPtr_;
......@@ -77,8 +74,11 @@ public:
// Constructors
//- Construct from IOobject
mirrorFvMesh(const IOobject& io);
//- Construct from IOobject, using system mirrorMeshDict
explicit mirrorFvMesh(const IOobject& io);
//- Construct from IOobject and specified mirrorMeshDict
mirrorFvMesh(const IOobject& io, const IOdictionary& mirrorDict);
//- Destructor
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -49,12 +49,25 @@ int main(int argc, char *argv[])
"Mirrors a mesh around a given plane."
);
#include "addDictOption.H"
// Adjust the help text
argList::addUsage("dict", "Specify alternative mirrorMeshDict");
argList::setAdvanced("decomposeParDict");
#include "addOverwriteOption.H"
#include "setRootCase.H"
#include "createTime.H"
const bool overwrite = args.found("overwrite");
const word dictName("mirrorMeshDict");
#include "setSystemRunTimeDictionaryIO.H"
Info<< "Reading " << dictName << "\n" << endl;
const IOdictionary mirrorDict(dictIO);
mirrorFvMesh mesh
(
IOobject
......@@ -62,7 +75,8 @@ int main(int argc, char *argv[])
mirrorFvMesh::defaultRegion,
runTime.constant(),
runTime
)
),
mirrorDict
);
hexRef8Data refData
......
......@@ -138,7 +138,7 @@ _of_complete_cache_[mergeOrSplitBaffles]="-case -decomposeParDict -dict -fileHan
_of_complete_cache_[mergeSurfacePatches]="-case -fileHandler -output -patchIdRange -patchIds -patchNames | -keep -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[meshToFPMA]="-case -decomposeParDict -fileHandler | -noFunctionObjects -parallel -doc -doc-source -help"
_of_complete_cache_[mhdFoam]="-case -decomposeParDict -fileHandler | -dry-run -dry-run-write -listFunctionObjects -listRegisteredSwitches -listScalarBCs -listSwitches -listUnsetSwitches -listVectorBCs -noFunctionObjects -parallel -postProcess -doc -doc-source -help"
_of_complete_cache_[mirrorMesh]="-case -decomposeParDict -fileHandler | -noFunctionObjects -overwrite -parallel -doc -doc-source -help"
_of_complete_cache_[mirrorMesh]="-case -dict -decomposeParDict -fileHandler | -noFunctionObjects -overwrite -parallel -doc -doc-source -help"
_of_complete_cache_[mixtureAdiabaticFlameT]="-case -fileHandler | -doc -doc-source -help"
_of_complete_cache_[modifyMesh]="-case -decomposeParDict -dict -fileHandler | -overwrite -parallel -doc -doc-source -help"
_of_complete_cache_[moveDynamicMesh]="-case -decomposeParDict -fileHandler -region | -checkAMI -noFunctionObjects -parallel -doc -doc-source -help"
......
......@@ -5,13 +5,8 @@ cd ${0%/*} || exit 1 # Run from this directory
runApplication blockMesh
runApplication transformPoints -scale '(1.6666 1 1)'
runApplication changeDictionary -instance system -dict system/changeDictionaryDict.X
runApplication mirrorMesh -overwrite
rm -f log.mirrorMesh
rm -f log.changeDictionary
runApplication changeDictionary -instance system -dict system/changeDictionaryDict.Y
runApplication mirrorMesh -overwrite
runApplication -s xplane mirrorMesh -dict system/mirrorMeshDict.X -overwrite
runApplication -s yplane mirrorMesh -dict system/mirrorMeshDict.Y -overwrite
restore0Dir
......
......@@ -10,7 +10,6 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
location "system";
object mirrorMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -20,10 +19,9 @@ planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 -1 0);
normal (0 0 -1);
}
planeTolerance 1e-06;
planeTolerance 1e-6;
// ************************************************************************* //
......@@ -10,17 +10,18 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object changeDictionaryDict;
object mirrorMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
mirrorMeshDict
planeType pointAndNormal;
pointAndNormalDict
{
pointAndNormalDict
{
point (0 0 0);
normal (-1 0 0);
}
point (0 0 0);
normal (-1 0 0);
}
planeTolerance 1e-6;
// ************************************************************************* //
......@@ -10,17 +10,18 @@ FoamFile
version 2.0;
format ascii;
class dictionary;
object changeDictionaryDict;
object mirrorMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
mirrorMeshDict
planeType pointAndNormal;
pointAndNormalDict
{
pointAndNormalDict
{
point (0 0 0);
normal (0 -1 0);
}
point (0 0 0);
normal (0 -1 0);
}
planeTolerance 1e-6;
// ************************************************************************* //
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment