ENH: indexedCell,indexedVertex: added info() for printing

This commit is contained in:
mattijs
2011-07-19 16:28:48 +01:00
parent ea15911286
commit 534c6e03ff
4 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "indexedCell.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
template<class Gt, class Cb>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const InfoProxy<CGAL::indexedCell<Gt, Cb> >& p
)
{
const CGAL::indexedCell<Gt, Cb>& iv = p.t_;
os << "Cell : index:" << iv.index_ << " filterCount:" << iv.filterCount_
<< nl;
os << " " << iv.vertex(0)->info();
os << " " << iv.vertex(1)->info();
os << " " << iv.vertex(2)->info();
os << " " << iv.vertex(3)->info();
return os;
}
// ************************************************************************* //

View File

@ -40,9 +40,26 @@ Description
#include "globalIndex.H"
#include "Pstream.H"
#include "Swap.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CGAL
{
template<class Gt, class Cb> class indexedCell;
}
namespace Foam
{
class Ostream;
template<class Gt, class Cb> Ostream& operator<<
(
Ostream&,
const Foam::InfoProxy<CGAL::indexedCell<Gt, Cb> >&
);
}
namespace CGAL
{
@ -339,6 +356,23 @@ public:
)
);
}
// Info
//- Return info proxy.
// Used to print indexedCell information to a stream
Foam::InfoProxy<indexedCell<Gt, Cb> > info() const
{
return *this;
}
friend Foam::Ostream& Foam::operator<< <Gt, Cb>
(
Foam::Ostream&,
const Foam::InfoProxy<indexedCell<Gt, Cb> >&
);
};
@ -348,6 +382,12 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "indexedCell.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,111 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "indexedVertex.H"
//#include "conformalVoronoiMesh.H"
#include "point.H"
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
template<class Gt, class Vb>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const InfoProxy<CGAL::indexedVertex<Gt, Vb> >& p
)
{
const CGAL::indexedVertex<Gt, Vb>& iv = p.t_;
if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtNearBoundary)
{
os << "internal near boundary point" << nl;
}
else if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtInternal)
{
os << "internal point" << nl;
}
else if (iv.type_ == CGAL::indexedVertex<Gt, Vb>::vtFar)
{
os << "far point" << nl;
}
else if (iv.type_ > CGAL::indexedVertex<Gt, Vb>::vtFar && iv.type_ < 0)
{
if (iv.index_ >= 0)
{
os << "referred (master) point from processor " << iv.procIndex()
<< nl;
}
else
{
os << "referred (slave) point from processor " << iv.procIndex()
<< nl;
}
}
else if (iv.type_ >= 0)
{
if (iv.ppMaster())
{
os << "master of point pair. paired up with point " << iv.index_
<< nl;
}
else if (iv.ppSlave())
{
os << "slave of point pair. paired up with point " << iv.index_
<< nl;
}
else
{
FatalErrorIn
(
"operator<<"
"(Ostream&, const InfoProxy<CGAL::indexedVertex<Gt, Vb> >&)"
) << "unhandled type " << iv.type_ << " index " << iv.index_
<< abort(FatalError);
}
}
else
{
FatalErrorIn
(
"operator<<"
"(Ostream&, const InfoProxy<CGAL::indexedVertex<Gt, Vb> >&)"
) << "unhandled type " << iv.type_ << " index " << iv.index_
<< abort(FatalError);
}
const Foam::point pos
(
CGAL::to_double(iv.point().x()),
CGAL::to_double(iv.point().y()),
CGAL::to_double(iv.point().z())
);
os << " type:" << iv.type_ << " index:" << iv.index_
<< " at:" << pos << nl;
return os;
}
// ************************************************************************* //

View File

@ -35,9 +35,26 @@ Description
#include <CGAL/Triangulation_3.h>
#include "tensor.H"
#include "InfoProxy.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace CGAL
{
template<class Gt, class Vb> class indexedVertex;
}
namespace Foam
{
class Ostream;
template<class Gt, class Vb> Ostream& operator<<
(
Ostream&,
const Foam::InfoProxy<CGAL::indexedVertex<Gt, Vb> >&
);
}
namespace CGAL
{
@ -365,6 +382,24 @@ public:
// this->type_ = vit->type();
// }
// Info
//- Return info proxy.
// Used to print indexedVertex information to a stream
Foam::InfoProxy<indexedVertex<Gt, Vb> > info() const
{
return *this;
}
friend Foam::Ostream& Foam::operator<< <Gt, Vb>
(
Foam::Ostream&,
const Foam::InfoProxy<indexedVertex<Gt, Vb> >&
);
};
@ -372,6 +407,11 @@ public:
} // End namespace CGAL
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "indexedVertex.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //