This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNodeBC.cpp
131 lines (107 loc) · 2.8 KB
/
NodeBC.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//-------------------------------------------------------------------------
// Filename : NodeBC.cpp
//
// Purpose : Represents general boundary condition on a set of nodes
//
// Special Notes :
//
// Creator : Ray Meyers
//
// Date : 11/08/2001
//
// Owner : Ray Meyers
//-------------------------------------------------------------------------
/*!
NodeBC represents a general boundary condition applied to one or more nodes
*/
#include "NodeBC.hpp"
#include "VerdeDefines.hpp"
#include "NodeRef.hpp"
int NodeBC::numActiveNodesets = 0;
NodeBC::NodeBC(int id)
{
bcId = id;
numberNodes = 0;
nodeIds = NULL;
numberDistributionFactors = 0;
distributionFactors = NULL;
bcActive = VERDE_FALSE;
}
NodeBC::~NodeBC()
{
// delete any memory
if (nodeIds)
delete [] nodeIds;
if (distributionFactors)
delete [] distributionFactors;
}
/*!
NodeBC::load stores the information for the NodeBC. This is an exodusII centric
function. More general access will be provided when VMI is available.
NOTE: it is assumed that the arrays ids and factors are heap memory, and pointers
to these are stored in NodeBC and deleted in the destructor
*/
void NodeBC::load(int number_nodes, int *ids,
int number_distribution_factors,
double *factors)
{
// we will assume that the arrays ids and factors have heap memory
// so that we can just store the pointers
numberNodes = number_nodes;
nodeIds = ids;
numberDistributionFactors = number_distribution_factors;
distributionFactors = factors;
// temp debugging
// PRINT_INFO("NodeBC saved: \n"
// " id = %d\n"
// " node_ids = ",bcId);
// for(int i = 0; i < numberNodes; i++)
// {
// PRINT_INFO("%d, ",nodeIds[i]);
// }
// PRINT_INFO("\n");
}
void NodeBC::node_id_list(std::deque<int> &id_list)
{
for(int i = 0; i < numberNodes; i++)
{
id_list.push_back(nodeIds[i]);
}
}
int NodeBC::number_dist_factors()
{
return numberDistributionFactors;
}
int* NodeBC::get_nodeIds()
{
return nodeIds;
}
int NodeBC::number_active_nodes()
{
// go through the list of node ids, and find out which are active (marked)
int count = 0;
for(int i = 0; i < numberNodes; i++)
{
NodeRef node_ref(nodeIds[i]);
if (node_ref.is_marked())
{
count++;
}
}
return count;
}
//! fills factor_array with distribution factors of active array
void NodeBC::active_dist_factor_data(double *factor_array)
{
// assume the array is sized correctly (number_active_nodes)
double *ptr = factor_array;
// if the node is active, add its distribution factors to array
for(int i = 0; i < numberNodes; i++)
{
NodeRef node_ref(nodeIds[i]);
if (node_ref.is_marked())
{
*ptr++ = distributionFactors[i];
}
}
}