From e6155d8ce5e4c5b6537c89b4699979318b5d60ee Mon Sep 17 00:00:00 2001 From: mattijs <mattijs> Date: Thu, 2 May 2013 13:58:47 +0100 Subject: [PATCH] ENH: lduMesh: added printing --- src/OpenFOAM/meshes/lduMesh/lduMesh.C | 102 +++++++++++++++++++++++++- src/OpenFOAM/meshes/lduMesh/lduMesh.H | 16 +++- 2 files changed, 116 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/meshes/lduMesh/lduMesh.C b/src/OpenFOAM/meshes/lduMesh/lduMesh.C index 2ab4cfe0465..bd7c6aacd51 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduMesh.C +++ b/src/OpenFOAM/meshes/lduMesh/lduMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,4 +44,104 @@ const Foam::objectRegistry& Foam::lduMesh::thisDb() const } +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<lduMesh>& ip) +{ + const lduMesh& ldum = ip.t_; + const lduAddressing& addr = ldum.lduAddr(); + const lduInterfacePtrsList interfaces = ldum.interfaces(); + + os << "lduMesh :" + << " size:" << addr.size() + << " l:" << addr.lowerAddr().size() + << " u:" << addr.upperAddr().size() + << " interfaces:" << interfaces.size() + << " comm:" << ldum.comm() + << endl; + label nCouples = 0; + forAll(interfaces, i) + { + if (interfaces.set(i)) + { + const labelUList& faceCells = addr.patchAddr(i); + nCouples += faceCells.size(); + + if (isA<processorLduInterface>(interfaces[i])) + { + const processorLduInterface& pi = refCast + < + const processorLduInterface + >(interfaces[i]); + + os << " patch:" << i + << " type:" << interfaces[i].type() + << " size:" << faceCells.size() + << " myProcNo:" << pi.myProcNo() + << " neighbProcNo:" << pi.neighbProcNo() + << " comm:" << pi.comm() + << endl; + } + else + { + os << " patch:" << i + << " type:" << interfaces[i].type() + << " size:" << faceCells.size() + << endl; + } + } + } + os << " Interface faces/cells:" << scalar(nCouples)/addr.size() + << endl; + + + // Print actual contents + if (lduMesh::debug) + { + const labelList& l = addr.lowerAddr(); + const labelList& u = addr.upperAddr(); + forAll(l, faceI) + { + os << " face:" << faceI << " l:" << l[faceI] + << " u:" << u[faceI] << endl; + } + forAll(interfaces, i) + { + if (interfaces.set(i)) + { + const labelUList& faceCells = addr.patchAddr(i); + if (faceCells.size()) + { + os << " patch:" << i + << " type:" << interfaces[i].type() << endl; + + if (isA<processorLduInterface>(interfaces[i])) + { + const processorLduInterface& pi = refCast + < + const processorLduInterface + >(interfaces[i]); + + os << " myProcNo:" << pi.myProcNo() + << " neighbProcNo:" << pi.neighbProcNo() + << " comm:" << pi.comm() + << endl; + } + + forAll(faceCells, i) + { + os << " " << i << " own:" << faceCells[i] + << endl; + } + } + } + } + } + + os.check("Ostream& operator<<(Ostream&, const lduMesh&"); + + return os; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/lduMesh/lduMesh.H b/src/OpenFOAM/meshes/lduMesh/lduMesh.H index 0c3314452ad..aa96663e49b 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduMesh.H +++ b/src/OpenFOAM/meshes/lduMesh/lduMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +36,7 @@ Description #include "lduAddressing.H" #include "lduInterfacePtrsList.H" #include "typeInfo.H" +#include "InfoProxy.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -77,6 +78,19 @@ public: //- Return a list of pointers for each patch // with only those pointing to interfaces being set virtual lduInterfacePtrsList interfaces() const = 0; + + // Info + + //- Return info proxy. + // Used to print mesh information to a stream + InfoProxy<lduMesh> info() const + { + return *this; + } + + // Ostream operator + + friend Ostream& operator<<(Ostream&, const InfoProxy<lduMesh>&); }; -- GitLab