diff --git a/src/foam/meshes/meshShapes/cellShape/cellShape.H b/src/foam/meshes/meshShapes/cellShape/cellShape.H index c1aaaa7c9..f64da9652 100644 --- a/src/foam/meshes/meshShapes/cellShape/cellShape.H +++ b/src/foam/meshes/meshShapes/cellShape/cellShape.H @@ -74,7 +74,7 @@ class cellShape // Private data //- Access to the cellShape's model - const cellModel *m; + const cellModel* m_; public: @@ -104,6 +104,9 @@ public: //- Return the points corresponding to this cellShape inline pointField points(const pointField& meshPoints) const; + //- Is model reference valid (model exists) + inline bool validModel() const; + //- Model reference inline const cellModel& model() const; diff --git a/src/foam/meshes/meshShapes/cellShape/cellShapeI.H b/src/foam/meshes/meshShapes/cellShape/cellShapeI.H index ba177a2c1..a9ba98c05 100644 --- a/src/foam/meshes/meshShapes/cellShape/cellShapeI.H +++ b/src/foam/meshes/meshShapes/cellShape/cellShapeI.H @@ -30,7 +30,7 @@ License inline Foam::cellShape::cellShape() : - m(NULL) + m_(NULL) {} @@ -42,7 +42,7 @@ inline Foam::cellShape::cellShape ) : labelList(l), - m(&M) + m_(&M) { if (doCollapse) { @@ -85,9 +85,15 @@ inline Foam::pointField Foam::cellShape::points } +inline bool Foam::cellShape::validModel() const +{ + return m_ != NULL; +} + + inline const Foam::cellModel& Foam::cellShape::model() const { - return *m; + return *m_; } @@ -161,7 +167,7 @@ inline Foam::labelList Foam::cellShape::meshEdges inline Foam::faceList Foam::cellShape::faces() const { - return m->faces(*this); + return m_->faces(*this); } @@ -216,19 +222,19 @@ inline Foam::faceList Foam::cellShape::collapsedFaces() const inline Foam::label Foam::cellShape::nFaces() const { - return m->nFaces(); + return m_->nFaces(); } inline Foam::edgeList Foam::cellShape::edges() const { - return m->edges(*this); + return m_->edges(*this); } inline Foam::label Foam::cellShape::nEdges() const { - return m->nEdges(); + return m_->nEdges(); } @@ -240,13 +246,13 @@ inline Foam::label Foam::cellShape::nPoints() const inline Foam::point Foam::cellShape::centre(const pointField& points) const { - return m->centre(*this, points); + return m_->centre(*this, points); } inline Foam::scalar Foam::cellShape::mag(const pointField& points) const { - return m->mag(*this, points); + return m_->mag(*this, points); } diff --git a/src/foam/meshes/meshShapes/cellShape/cellShapeIO.C b/src/foam/meshes/meshShapes/cellShape/cellShapeIO.C index 7cf766410..23a51103a 100644 --- a/src/foam/meshes/meshShapes/cellShape/cellShapeIO.C +++ b/src/foam/meshes/meshShapes/cellShape/cellShapeIO.C @@ -64,11 +64,11 @@ Istream& operator>>(Istream& is, cellShape& s) // it is allowed to have either a word or a number describing the model if (t.isLabel()) { - s.m = cellModeller::lookup(int(t.labelToken())); + s.m_ = cellModeller::lookup(int(t.labelToken())); } else if (t.isWord()) { - s.m = cellModeller::lookup(t.wordToken()); + s.m_ = cellModeller::lookup(t.wordToken()); } else { @@ -79,11 +79,12 @@ Istream& operator>>(Istream& is, cellShape& s) } // Check that a model was found - if (!s.m) + if (!s.m_) { FatalIOErrorIn("operator>>(Istream& is, cellShape& s)", is) << "CellShape has unknown model " << t.info() << exit(FatalIOError); + return is; } @@ -106,10 +107,10 @@ Ostream& operator<<(Ostream& os, const cellShape & s) os << token::BEGIN_LIST; // Write the list label for the symbol (ONE OR THE OTHER !!!) - os << (s.m)->index() << token::SPACE; + os << (s.m_)->index() << token::SPACE; // Write the model name instead of the label (ONE OR THE OTHER !!!) - // os << (s.m)->name() << token::SPACE; + // os << (s.m_)->name() << token::SPACE; // Write the geometry os << static_cast(s); @@ -128,7 +129,7 @@ Ostream& operator<<(Ostream& os, const InfoProxy& ip) { const cellShape& cs = ip.t_; - if (!(&cs.model())) + if (!cs.validModel()) { os << " cellShape has no model!\n"; }