mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
Creation of OpenFOAM-dev repository 15/04/2008
This commit is contained in:
3
applications/test/primitivePatch/Make/files
Normal file
3
applications/test/primitivePatch/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
testPrimitivePatch.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/testPrimitivePatch
|
||||
2
applications/test/primitivePatch/Make/options
Normal file
2
applications/test/primitivePatch/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
|
||||
/* EXE_LIBS = -lfiniteVolume */
|
||||
258
applications/test/primitivePatch/testPrimitivePatch.C
Normal file
258
applications/test/primitivePatch/testPrimitivePatch.C
Normal file
@ -0,0 +1,258 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / 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
|
||||
Test new primitive patches.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Time.H"
|
||||
#include "polyMesh.H"
|
||||
#include "primitivePatch.H"
|
||||
#include "faceIOList.H"
|
||||
#include "IFstream.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef PrimitivePatch<face, List, const pointField&> myPrimitivePatch;
|
||||
|
||||
|
||||
void writeObj(Ostream& os,const pointField& points)
|
||||
{
|
||||
forAll(points, pointI)
|
||||
{
|
||||
const point& pt = points[pointI];
|
||||
|
||||
os << "v " << pt.x() << ' ' << pt.y()
|
||||
<< ' ' << pt.z() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void checkFaceEdges
|
||||
(
|
||||
const faceList& localFaces,
|
||||
const edgeList& edges,
|
||||
const labelListList& faceEdges
|
||||
)
|
||||
{
|
||||
forAll(faceEdges, faceI)
|
||||
{
|
||||
const face& f = localFaces[faceI];
|
||||
|
||||
const labelList& myEdges = faceEdges[faceI];
|
||||
|
||||
forAll(f, fp)
|
||||
{
|
||||
label fp1 = (fp + 1) % f.size();
|
||||
|
||||
if (edges[myEdges[fp]] != edge(f[fp], f[fp1]))
|
||||
{
|
||||
FatalErrorIn("checkFaceEdges")
|
||||
<< "Edges of face not in face point order:"
|
||||
<< "face:" << faceI << " localF:" << f
|
||||
<< " faceEdges:" << myEdges
|
||||
<< abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeEdges
|
||||
(
|
||||
const pointField& localPoints,
|
||||
const edgeList& edges,
|
||||
const label nInternalEdges
|
||||
)
|
||||
{
|
||||
Info<< "Writing internal edges to internalEdges.obj" << nl << endl;
|
||||
|
||||
OFstream intStream("internalEdges.obj");
|
||||
|
||||
writeObj(intStream, localPoints);
|
||||
|
||||
for (label edgeI = 0; edgeI < nInternalEdges; edgeI++)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
intStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
|
||||
}
|
||||
|
||||
Info<< "Writing boundary edges to boundaryEdges.obj" << nl << endl;
|
||||
|
||||
OFstream bndStream("boundaryEdges.obj");
|
||||
|
||||
writeObj(bndStream, localPoints);
|
||||
|
||||
for (label edgeI = nInternalEdges; edgeI < edges.size(); edgeI++)
|
||||
{
|
||||
const edge& e = edges[edgeI];
|
||||
|
||||
bndStream << "l " << e.start()+1 << ' ' << e.end()+1 << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeFaceEdges
|
||||
(
|
||||
const pointField& localPoints,
|
||||
const edgeList& edges,
|
||||
const labelListList& faceEdges
|
||||
)
|
||||
{
|
||||
Info<< "Writing faceEdges per face to faceEdges.obj" << nl << endl;
|
||||
|
||||
OFstream feStream("faceEdges.obj");
|
||||
|
||||
writeObj(feStream, localPoints);
|
||||
|
||||
forAll(faceEdges, faceI)
|
||||
{
|
||||
const labelList& myEdges = faceEdges[faceI];
|
||||
|
||||
forAll(myEdges, i)
|
||||
{
|
||||
const edge& e = edges[myEdges[i]];
|
||||
|
||||
feStream<< "l " << e.start()+1 << ' ' << e.end()+1 << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeEdgeFaces
|
||||
(
|
||||
const pointField& localPoints,
|
||||
const faceList& localFaces,
|
||||
const edgeList& edges,
|
||||
const labelListList& edgeFaces
|
||||
)
|
||||
{
|
||||
Info<< "Writing edgeFaces per face to edgeFaces.obj" << nl << endl;
|
||||
|
||||
OFstream efStream("edgeFaces.obj");
|
||||
|
||||
pointField ctrs(localFaces.size(), vector::zero);
|
||||
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
ctrs[faceI] = localFaces[faceI].centre(localPoints);
|
||||
}
|
||||
writeObj(efStream, ctrs);
|
||||
|
||||
|
||||
forAll(edgeFaces, edgeI)
|
||||
{
|
||||
const labelList& myFaces = edgeFaces[edgeI];
|
||||
|
||||
forAll(myFaces, i)
|
||||
{
|
||||
efStream<< "l " << myFaces[0]+1 << ' ' << myFaces[i]+1 << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeFaceFaces
|
||||
(
|
||||
const pointField& localPoints,
|
||||
const faceList& localFaces,
|
||||
const labelListList& faceFaces
|
||||
)
|
||||
{
|
||||
Info<< "Writing faceFaces per face to faceFaces.obj" << nl << endl;
|
||||
|
||||
OFstream ffStream("faceFaces.obj");
|
||||
|
||||
pointField ctrs(localFaces.size(), vector::zero);
|
||||
|
||||
forAll(localFaces, faceI)
|
||||
{
|
||||
ctrs[faceI] = localFaces[faceI].centre(localPoints);
|
||||
}
|
||||
writeObj(ffStream, ctrs);
|
||||
|
||||
forAll(faceFaces, faceI)
|
||||
{
|
||||
const labelList& nbrs = faceFaces[faceI];
|
||||
|
||||
forAll(nbrs, nbI)
|
||||
{
|
||||
ffStream << "l " << faceI+1 << ' ' << nbrs[nbI]+1 << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
argList::noParallel();
|
||||
argList::validArgs.append("patch");
|
||||
|
||||
# include "setRootCase.H"
|
||||
# include "createTime.H"
|
||||
# include "createPolyMesh.H"
|
||||
|
||||
word patchName(args.additionalArgs()[0]);
|
||||
|
||||
label patchI = mesh.boundaryMesh().findPatchID(patchName);
|
||||
|
||||
const polyPatch& patch = mesh.boundaryMesh()[patchI];
|
||||
|
||||
Info<< "Patch:" << patch.name() << endl;
|
||||
|
||||
PrimitivePatch<face, List, const pointField&> pp(patch, patch.points());
|
||||
|
||||
const pointField& localPoints = pp.localPoints();
|
||||
const faceList& localFaces = pp.localFaces();
|
||||
const labelListList& faceFaces = pp.faceFaces();
|
||||
const edgeList& edges = pp.edges();
|
||||
const labelListList& edgeFaces = pp.edgeFaces();
|
||||
const labelListList& faceEdges = pp.faceEdges();
|
||||
|
||||
|
||||
checkFaceEdges(localFaces, edges, faceEdges);
|
||||
|
||||
writeEdges(localPoints, edges, pp.nInternalEdges());
|
||||
|
||||
writeFaceEdges(localPoints, edges, faceEdges);
|
||||
|
||||
writeEdgeFaces(localPoints, localFaces, edges, edgeFaces);
|
||||
|
||||
writeFaceFaces(localPoints, localFaces, faceFaces);
|
||||
|
||||
Info << "End\n" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user