mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Initial autoMesh merge
This commit is contained in:
@ -87,7 +87,7 @@ void hexBlock::setHandedness()
|
||||
|
||||
if (blockHandedness_ == noPoints)
|
||||
{
|
||||
WarningIn("hexBlock::readPoints(const bool, Istream&)")
|
||||
WarningIn("hexBlock::hexBlock::setHandedness()")
|
||||
<< "Cannot determine orientation of block."
|
||||
<< " Continuing as if right handed." << endl;
|
||||
blockHandedness_ = right;
|
||||
@ -105,35 +105,67 @@ hexBlock::hexBlock(const label nx, const label ny, const label nz)
|
||||
zDim_(nz - 1),
|
||||
blockHandedness_(noPoints),
|
||||
points_((xDim_ + 1)*(yDim_ + 1)*(zDim_ + 1))
|
||||
{
|
||||
Pout<< "xDim:" << nx << " yDim:" << ny << " zDim:" << nz << endl;
|
||||
}
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void hexBlock::readPoints(const bool readBlank, Istream& is)
|
||||
void hexBlock::readPoints
|
||||
(
|
||||
const bool readBlank,
|
||||
const scalar twoDThicknes,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
scalar iBlank;
|
||||
|
||||
forAll (points_, i)
|
||||
label nPoints = points_.size();
|
||||
|
||||
if (twoDThicknes > 0)
|
||||
{
|
||||
nPoints /= 2;
|
||||
}
|
||||
|
||||
Info<< "Reading " << nPoints << " x coordinates..." << endl;
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
is >> points_[i].x();
|
||||
}
|
||||
|
||||
forAll (points_, i)
|
||||
Info<< "Reading " << nPoints << " y coordinates..." << endl;
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
is >> points_[i].y();
|
||||
}
|
||||
|
||||
forAll (points_, i)
|
||||
if (twoDThicknes > 0)
|
||||
{
|
||||
is >> points_[i].z();
|
||||
Info<< "Extruding " << nPoints << " points in z direction..." << endl;
|
||||
// Duplicate points
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
points_[i+nPoints] = points_[i];
|
||||
}
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
points_[i].z() = 0;
|
||||
points_[i+nPoints].z() = twoDThicknes;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Reading " << nPoints << " z coordinates..." << endl;
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
is >> points_[i].z();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (readBlank)
|
||||
{
|
||||
forAll (points_, i)
|
||||
Info<< "Reading " << nPoints << " blanks..." << endl;
|
||||
for (label i=0; i < nPoints; i++)
|
||||
{
|
||||
is >> iBlank;
|
||||
}
|
||||
|
||||
@ -145,7 +145,14 @@ public:
|
||||
|
||||
|
||||
//- Read block points either with or without blanking after every block.
|
||||
void readPoints(const bool readBlank, Istream&);
|
||||
// If twoDThickness > 0 reads (half) the points and extrudes the
|
||||
// points in z direction.
|
||||
void readPoints
|
||||
(
|
||||
const bool readBlank,
|
||||
const scalar twoDThicknes,
|
||||
Istream&
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -23,11 +23,12 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Plot3d mesh (ascii format) converter.
|
||||
Plot3d mesh (ascii/formatted format) converter.
|
||||
|
||||
Work in progress! Handles ascii multiblock (and optionally singleBlock)
|
||||
format.
|
||||
By default expects blanking. Use -noBlank if none.
|
||||
Use -2D <thickness> if 2D.
|
||||
Niklas Nordin has experienced a problem with lefthandedness of the blocks.
|
||||
The code should detect this automatically - see hexBlock::readPoints but
|
||||
if this goes wrong just set the blockHandedness_ variable to 'right'
|
||||
@ -59,6 +60,7 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("scale", "scale factor");
|
||||
argList::validOptions.insert("noBlank", "");
|
||||
argList::validOptions.insert("singleBlock", "");
|
||||
argList::validOptions.insert("2D", "thickness");
|
||||
|
||||
argList args(argc, argv);
|
||||
|
||||
@ -75,6 +77,13 @@ int main(int argc, char *argv[])
|
||||
|
||||
bool readBlank = !args.options().found("noBlank");
|
||||
bool singleBlock = args.options().found("singleBlock");
|
||||
scalar twoDThicknes = -1;
|
||||
if (args.options().found("2D"))
|
||||
{
|
||||
twoDThicknes = readScalar(IStringStream(args.options()["2D"])());
|
||||
Info<< "Reading 2D case by extruding points by " << twoDThicknes
|
||||
<< " in z direction." << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
# include "createTime.H"
|
||||
@ -95,7 +104,7 @@ int main(int argc, char *argv[])
|
||||
plot3dFile >> nblock;
|
||||
}
|
||||
|
||||
Info << "Reading " << nblock << " blocks" << endl;
|
||||
Info<< "Reading " << nblock << " blocks" << endl;
|
||||
|
||||
PtrList<hexBlock> blocks(nblock);
|
||||
|
||||
@ -104,20 +113,32 @@ int main(int argc, char *argv[])
|
||||
|
||||
forAll (blocks, blockI)
|
||||
{
|
||||
plot3dFile >> nx >> ny >> nz;
|
||||
if (twoDThicknes > 0)
|
||||
{
|
||||
// Fake second set of points (done in readPoints below)
|
||||
plot3dFile >> nx >> ny;
|
||||
nz = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
plot3dFile >> nx >> ny >> nz;
|
||||
}
|
||||
|
||||
Info<< "block " << blockI << " nx:" << nx
|
||||
<< " ny:" << ny << " nz:" << nz << endl;
|
||||
|
||||
blocks.set(blockI, new hexBlock(nx, ny, nz));
|
||||
}
|
||||
}
|
||||
|
||||
Info << "Reading block points" << endl;
|
||||
Info<< "Reading block points" << endl;
|
||||
label sumPoints(0);
|
||||
label nMeshCells(0);
|
||||
|
||||
forAll (blocks, blockI)
|
||||
{
|
||||
Info << "block " << blockI << ":" << nl;
|
||||
blocks[blockI].readPoints(readBlank, plot3dFile);
|
||||
Info<< "block " << blockI << ":" << nl;
|
||||
blocks[blockI].readPoints(readBlank, twoDThicknes, plot3dFile);
|
||||
sumPoints += blocks[blockI].nBlockPoints();
|
||||
nMeshCells += blocks[blockI].nBlockCells();
|
||||
Info<< nl;
|
||||
@ -136,7 +157,6 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// From old to new master point
|
||||
labelList oldToNew;
|
||||
pointField newPoints;
|
||||
@ -151,13 +171,17 @@ int main(int argc, char *argv[])
|
||||
newPoints
|
||||
);
|
||||
|
||||
Info<< "Merged points within " << SMALL << " distance. Merged from "
|
||||
<< oldToNew.size() << " down to " << newPoints.size()
|
||||
<< " points." << endl;
|
||||
|
||||
// Scale the points
|
||||
if (scaleFactor > 1.0 + SMALL || scaleFactor < 1.0 - SMALL)
|
||||
{
|
||||
newPoints *= scaleFactor;
|
||||
}
|
||||
|
||||
Info << "Creating cells" << endl;
|
||||
Info<< "Creating cells" << endl;
|
||||
|
||||
cellShapeList cellShapes(nMeshCells);
|
||||
|
||||
@ -190,7 +214,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
Info << "Creating boundary patches" << endl;
|
||||
Info<< "Creating boundary patches" << endl;
|
||||
|
||||
faceListList boundary(0);
|
||||
wordList patchNames(0);
|
||||
@ -220,10 +244,10 @@ int main(int argc, char *argv[])
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(10);
|
||||
|
||||
Info << "Writing polyMesh" << endl;
|
||||
Info<< "Writing polyMesh" << endl;
|
||||
pShapeMesh.write();
|
||||
|
||||
Info << "End\n" << endl;
|
||||
Info<< "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ Description
|
||||
#include "demandDrivenData.H"
|
||||
#include "writePatch.H"
|
||||
#include "writePointSet.H"
|
||||
#include "IOobjectList.H"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@ -233,8 +234,10 @@ void writeVTK
|
||||
|
||||
void printHelp(Ostream& os)
|
||||
{
|
||||
os << "Please type 'help', 'quit', 'time ddd'"
|
||||
os << "Please type 'help', 'list', 'quit', 'time ddd'"
|
||||
<< " or a set command after prompt." << endl
|
||||
<< "'list' will show all current cell/face/point sets." << endl
|
||||
<< "'time ddd' will change the current time." << endl
|
||||
<< endl
|
||||
<< "A set command should be of the following form" << endl
|
||||
<< endl
|
||||
@ -272,6 +275,47 @@ void printHelp(Ostream& os)
|
||||
}
|
||||
|
||||
|
||||
void printAllSets(const polyMesh& mesh, Ostream& os)
|
||||
{
|
||||
IOobjectList objects
|
||||
(
|
||||
mesh,
|
||||
mesh.pointsInstance(),
|
||||
polyMesh::meshSubDir/"sets"
|
||||
);
|
||||
IOobjectList cellSets(objects.lookupClass(cellSet::typeName));
|
||||
if (cellSets.size() > 0)
|
||||
{
|
||||
os << "cellSets:" << endl;
|
||||
forAllConstIter(IOobjectList, cellSets, iter)
|
||||
{
|
||||
cellSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
}
|
||||
}
|
||||
IOobjectList faceSets(objects.lookupClass(faceSet::typeName));
|
||||
if (faceSets.size() > 0)
|
||||
{
|
||||
os << "faceSets:" << endl;
|
||||
forAllConstIter(IOobjectList, faceSets, iter)
|
||||
{
|
||||
faceSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
}
|
||||
}
|
||||
IOobjectList pointSets(objects.lookupClass(pointSet::typeName));
|
||||
if (pointSets.size() > 0)
|
||||
{
|
||||
os << "pointSets:" << endl;
|
||||
forAllConstIter(IOobjectList, pointSets, iter)
|
||||
{
|
||||
pointSet set(*iter());
|
||||
os << '\t' << set.name() << "\tsize:" << set.size() << endl;
|
||||
}
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
// Read command and execute. Return true if ok, false otherwise.
|
||||
bool doCommand
|
||||
@ -531,6 +575,12 @@ commandStatus parseType
|
||||
|
||||
return INVALID;
|
||||
}
|
||||
else if (setType == "list")
|
||||
{
|
||||
printAllSets(mesh, Pout);
|
||||
|
||||
return INVALID;
|
||||
}
|
||||
else if (setType == "time")
|
||||
{
|
||||
scalar time = readScalar(is);
|
||||
@ -612,8 +662,9 @@ commandStatus parseType
|
||||
(
|
||||
"commandStatus parseType(Time&, polyMesh&, const word&"
|
||||
", IStringStream&)"
|
||||
) << "Illegal set type " << setType << endl
|
||||
<< "Should be one of 'cellSet' 'faceSet' 'pointSet'"
|
||||
) << "Illegal command " << setType << endl
|
||||
<< "Should be one of 'help', 'list', 'time' or a set type :"
|
||||
<< " 'cellSet', 'faceSet', 'pointSet'"
|
||||
<< endl;
|
||||
|
||||
return INVALID;
|
||||
|
||||
@ -1,27 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: 1.0 |
|
||||
| \\ / A nd | Web: http://www.openfoam.org |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
// couplePatches tool definition
|
||||
|
||||
description "Utility to reorder face numbering for cyclic and processor patches";
|
||||
|
||||
couplePatchesDict
|
||||
{
|
||||
type dictionary;
|
||||
description "couplePatches control dictionary";
|
||||
dictionaryPath "system";
|
||||
|
||||
entries
|
||||
{
|
||||
arguments
|
||||
{
|
||||
type rootCaseArguments;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +0,0 @@
|
||||
couplePatches.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/couplePatches
|
||||
@ -1,7 +0,0 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-ldynamicMesh \
|
||||
-lmeshTools
|
||||
@ -1,160 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
Utility to reorder cyclic and processor patches.
|
||||
|
||||
Uses dummy morph to sort things out.
|
||||
|
||||
Is bit of hack since polyMesh constructor already checks for coupled
|
||||
face areas so might bomb out. You might need to compile in a local
|
||||
processorPolyPatch that gives a warning instead to make this utility
|
||||
complete.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "polyMesh.H"
|
||||
#include "Time.H"
|
||||
#include "polyTopoChange.H"
|
||||
#include "mapPolyMesh.H"
|
||||
#include "OFstream.H"
|
||||
#include "coupledPolyPatch.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
Info<< "Using geometry to calculate face correspondence across"
|
||||
<< " coupled boundaries (processor, cyclic)" << nl
|
||||
<< "This will only work for cyclics if they are parallel or"
|
||||
<< " their rotation is defined across the origin" << nl
|
||||
<< endl;
|
||||
|
||||
const polyBoundaryMesh& patches = mesh.boundaryMesh();
|
||||
|
||||
bool hasCoupled = false;
|
||||
forAll(patches, patchI)
|
||||
{
|
||||
const polyPatch& pp = patches[patchI];
|
||||
|
||||
if (pp.coupled())
|
||||
{
|
||||
hasCoupled = true;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
reduce(hasCoupled, orOp<bool>());
|
||||
|
||||
if (hasCoupled)
|
||||
{
|
||||
Info<< "Mesh has coupled patches ..." << nl << endl;
|
||||
|
||||
// Dummy topo changes container
|
||||
polyTopoChange meshMod(mesh);
|
||||
|
||||
// Do all changes
|
||||
Info<< "Doing dummy mesh morph to correct face ordering ..."
|
||||
<< endl;
|
||||
|
||||
runTime++;
|
||||
|
||||
faceList oldFaces(mesh.faces());
|
||||
|
||||
autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh(mesh, false);
|
||||
|
||||
// Update fields
|
||||
mesh.updateMesh(morphMap);
|
||||
|
||||
// Move mesh (since morphing does not do this)
|
||||
if (morphMap().hasMotionPoints())
|
||||
{
|
||||
mesh.movePoints(morphMap().preMotionPoints());
|
||||
}
|
||||
|
||||
// Find out if anything changed.
|
||||
// Problem is that - if the topo change is only rotation -
|
||||
// face::operator= does not detect a change so use labelList::operator=
|
||||
bool meshChanged = false;
|
||||
|
||||
if (mesh.faces().size() != oldFaces.size())
|
||||
{
|
||||
meshChanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(mesh.faces(), faceI)
|
||||
{
|
||||
const labelList& f = mesh.faces()[faceI];
|
||||
const labelList& oldF = oldFaces[faceI];
|
||||
|
||||
if (f != oldF)
|
||||
{
|
||||
meshChanged = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reduce(meshChanged, orOp<label>());
|
||||
|
||||
if (meshChanged)
|
||||
{
|
||||
// Set the precision of the points data to 10
|
||||
IOstream::defaultPrecision(10);
|
||||
|
||||
// Write resulting mesh
|
||||
Info << "Writing morphed mesh to time " << runTime.value() << endl;
|
||||
|
||||
mesh.write();
|
||||
}
|
||||
else
|
||||
{
|
||||
Info << "Mesh ordering ok. Nothing changed." << endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Mesh has no coupled patches. Nothing changed ..." << nl << endl;
|
||||
}
|
||||
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user