GemaCoreLib
The GeMA Core library
gmFileNodeRenumbering.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_FILE_NODE_RENUMBERING_H_
25 #define _GEMA_FILE_NODE_RENUMBERING_H_
26 
27 #include <assert.h>
28 
29 #include "gmValueInfo.h"
30 #include "gmCellMesh.h"
31 
32 class GmCellGroupSet;
33 class GmFileFormat;
34 
43 {
44 public:
46 
48  ~GmFileNodeRenumbering() { delete[] _map; }
49 
51  const GmCellMesh* mesh() const { return _mesh; }
52 
54  const GmAffectedNodes mode() const { return _mode; }
55 
56  bool filter(bool active, const GmCellGroupSet* group, const GmFileFormat* fileFormat);
57 
61  int numActiveNodes() const { return _nActiveNodes; }
62 
64  int numActiveGhostNodes() const { return _nActiveGhostNodes; }
65 
70  bool active(int node) const
71  {
72  assert(node >= 0 && node < _nMeshNodes);
73  return _map ? (_map[node] != -1) : true;
74  }
75 
84  int map(int node) const
85  {
86  if(GmMesh::isGhostNode(node))
87  {
88  node = GmMesh::clearGhostFlag(node);
89  if(_mode == GM_BOTH)
90  node += _mesh->numNodes();
91  }
92 
93  assert(node >= 0 && node < _nMeshNodes);
94  return _map ? _map[node] : node;
95  }
96 
97 private:
98  const GmCellMesh* _mesh;
103  int* _map;
104 };
105 
106 #endif
107 
const GmAffectedNodes mode() const
Returns the associated node mode.
Definition: gmFileNodeRenumbering.h:54
bool active(int node) const
Returns true if the node belongs to an active cell, false if not. The node index should be a linear n...
Definition: gmFileNodeRenumbering.h:70
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition: gmCellGroupSet.h:34
int _nActiveNodes
The total number of active nodes in the mesh. Equals _nMeshNodes before filter()
Definition: gmFileNodeRenumbering.h:101
GmAffectedNodes _mode
Which kind of nodes are we dealing with?
Definition: gmFileNodeRenumbering.h:99
bool filter(bool active, const GmCellGroupSet *group, const GmFileFormat *fileFormat)
Initializes the node mapping structure to enable saving node data without nodes that are used only by...
Definition: gmFileNodeRenumbering.cpp:73
const GmCellMesh * _mesh
The mesh.
Definition: gmFileNodeRenumbering.h:98
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition: gmValueInfo.h:91
Declaration of the GmValueInfo class.
int numActiveGhostNodes() const
Returns the number of active nodes (like numActiveNodes()) that are ghost nodes.
Definition: gmFileNodeRenumbering.h:64
Specifies that this value exists over mesh and ghost nodes.
Definition: gmValueInfo.h:95
static bool isGhostNode(int nodeIndex)
Returns true if the given index is a ghost node index, false if not.
Definition: gmMesh.h:109
Specifies that this value exists over common geometry mesh nodes only.
Definition: gmValueInfo.h:93
int map(int node) const
Returns the mapping between a node number and its position in the renumbered node set....
Definition: gmFileNodeRenumbering.h:84
int _nActiveGhostNodes
The number of nodes in _nActiveNodes that are ghost nodes.
Definition: gmFileNodeRenumbering.h:102
static int clearGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit cleared.
Definition: gmMesh.h:115
Base interface class for CellMesh type plugins.
Definition: gmCellMesh.h:39
~GmFileNodeRenumbering()
Destructor.
Definition: gmFileNodeRenumbering.h:48
int numActiveNodes() const
Returns the number of active nodes in the mesh: the number of nodes belonging to an unfiltered cell a...
Definition: gmFileNodeRenumbering.h:61
Declaration of the GmCellMesh interface class.
int _nMeshNodes
The total number of nodes in the mesh, respecting mode.
Definition: gmFileNodeRenumbering.h:100
int * _map
The mapping between node indices. Size equal to _nMeshNodes. -1 if an index is not active....
Definition: gmFileNodeRenumbering.h:103
const GmCellMesh * mesh() const
Returns the associated mesh.
Definition: gmFileNodeRenumbering.h:51
virtual int numNodes() const =0
Returns the number of nodes in the mesh.
Basic interface for describing high level file format capabilities.
Definition: gmFileFormat.h:34
GmFileNodeRenumbering(const GmCellMesh *mesh, GmAffectedNodes mode=GM_GEOMETRY_NODE)
Constructor. Gets as parameter the mesh and the definition of which types of nodes should be consider...
Definition: gmFileNodeRenumbering.cpp:38
An auxilliary class for renumbering nodes when filtering cells from an output mesh....
Definition: gmFileNodeRenumbering.h:42