GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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#include "gmPCR.h"
32
33class GmCellGroupSet;
34class GmFileFormat;
35
46{
47public:
48 GmFileNodeRenumbering(const GmCellMesh* mesh, GmAffectedNodes mode, bool useModelOrder);
49
52
54 const GmCellMesh* mesh() const { return _mesh; }
55
57 const GmAffectedNodes mode() const { return _mode; }
58
59 bool filter(bool active, const GmCellGroupSet* group, const GmFileFormat* fileFormat);
60
64 int numActiveNodes() const { return _nActiveNodes; }
65
68
74 bool active(int node) const
75 {
76 assert(node >= 0 && node < _nMeshNodes);
77 return _map ? (_map[node] != -1) : true;
78 }
79
89 int map(int node) const
90 {
91 if(GmMesh::isGhostNode(node))
92 {
93 node = GmMesh::clearGhostFlag(node);
94 if(_mode == GM_BOTH)
95 node += _mesh->numNodes();
96 }
97
98 assert(node >= 0 && node < _nMeshNodes);
99 if(_map)
100 return _map[node];
101 else
102 {
103 // If there is no mapping but the class was constructed with _modelOrder == true, we
104 // still need to convert the node from internal to model order.
105 if(_modelOrder)
106 {
109 }
110 else
111 return node;
112 }
113 }
114
115private:
122 int* _map;
123};
124
125#endif
126
Interface for helping managing mesh cell groups and returning the elements in their union.
Definition gmCellGroupSet.h:35
Base interface class for CellMesh type plugins.
Definition gmCellMesh.h:40
Basic interface for describing high level file format capabilities.
Definition gmFileFormat.h:35
An auxiliary class for renumbering nodes when filtering cells from an output mesh....
Definition gmFileNodeRenumbering.h:46
int _nActiveNodes
The total number of active nodes in the mesh. Equals _nMeshNodes before filter()
Definition gmFileNodeRenumbering.h:120
const GmCellMesh * _mesh
The mesh.
Definition gmFileNodeRenumbering.h:116
int _nActiveGhostNodes
The number of nodes in _nActiveNodes that are ghost nodes.
Definition gmFileNodeRenumbering.h:121
bool _modelOrder
Should the order of nodes in map follow the order from the original set of model nodes (true) or from...
Definition gmFileNodeRenumbering.h:118
int * _map
The mapping between node indices. Size equal to _nMeshNodes. -1 if an index is not active....
Definition gmFileNodeRenumbering.h:122
GmFileNodeRenumbering(const GmCellMesh *mesh, GmAffectedNodes mode, bool useModelOrder)
Constructor. Gets as parameter the mesh and the definition of which types of nodes should be consider...
Definition gmFileNodeRenumbering.cpp:41
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:74
int map(int node) const
Returns the mapping between a node number and its position in the renumbered node set....
Definition gmFileNodeRenumbering.h:89
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:64
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:77
int _nMeshNodes
The total number of nodes in the mesh, respecting mode.
Definition gmFileNodeRenumbering.h:119
int numActiveGhostNodes() const
Returns the number of active nodes (like numActiveNodes()) that are ghost nodes.
Definition gmFileNodeRenumbering.h:67
const GmCellMesh * mesh() const
Returns the associated mesh.
Definition gmFileNodeRenumbering.h:54
GmAffectedNodes _mode
Which kind of nodes are we dealing with?
Definition gmFileNodeRenumbering.h:117
~GmFileNodeRenumbering()
Destructor.
Definition gmFileNodeRenumbering.h:51
const GmAffectedNodes mode() const
Returns the associated node mode.
Definition gmFileNodeRenumbering.h:57
virtual int numNodes() const =0
Returns the number of nodes in the mesh.
static bool isGhostNode(int nodeIndex)
Returns true if the given index is a ghost node index, false if not.
Definition gmMesh.h:136
virtual GmPCR * pcrObject() const =0
Returns the PCR(Partition - Color - Renumber) object associated with this mesh. Should NEVER return N...
static int clearGhostFlag(int nodeIndex)
Returns the given index with the ghost node bit cleared.
Definition gmMesh.h:142
virtual int localOrderToOriginalGhostNodeHighClear(int nodeId) const =0
An specialization of localOrderToOriginalNode, accepting ONLY ghost nodes with the high bit CLEARED (...
virtual int localOrderToOriginalNode(int nodeId) const =0
Translates a local, ordered, node id used by the mesh into the original (model) node id....
Declaration of the GmCellMesh interface class.
Implementation of the GmPCR class.
Declaration of the GmValueInfo class.
GmAffectedNodes
Affected node types for node based values (GM_NODE_COORDINATES, GM_NODE_ATTRIBUTE or GM_NODE_STATEVAR...
Definition gmValueInfo.h:97
@ GM_GHOST_NODE
Specifies that this value exists over ghost nodes only.
Definition gmValueInfo.h:99
@ GM_BOTH
Specifies that this value exists over mesh and ghost nodes.
Definition gmValueInfo.h:100