9 #include <fei_macros.hpp>
11 #include <test_utils/HexBeamCR.hpp>
13 HexBeamCR::HexBeamCR(
int W,
int D,
int DofPerNode,
14 int decomp,
int numProcs,
int localProc)
15 :
HexBeam(W, D, DofPerNode, decomp, numProcs, localProc)
17 totalNumElems_ = W*W*D;
18 totalNumNodes_ = (W+1)*(W+1)*(D+1) + (W+1)*(W+1)*(2*numProcs_-1);
20 numGlobalDOF_ = totalNumNodes_*dofPerNode_;
22 numLocalSlices_ = D/numProcs;
23 int remainder = D%numProcs;
24 firstLocalSlice_ = localProc_*numLocalSlices_;
33 if (localProc < remainder) {
38 localNumNodes_ = numNodesPerSlice_*(numLocalSlices_+2);
40 localNumElems_ = numElemsPerSlice_*numLocalSlices_;
41 numLocalDOF_ = localNumNodes_*dofPerNode_;
44 firstLocalElem_ = localProc*numLocalSlices_*numElemsPerSlice_;
46 firstLocalNode_ = localProc*localNumNodes_;
48 if (remainder <= localProc && remainder > 0) {
49 firstLocalElem_ += remainder*numElemsPerSlice_;
50 firstLocalNode_ += remainder*numNodesPerSlice_;
57 case HexBeamCR::ThreeD:
60 <<
" aborting." << FEI_ENDL;
64 localCRslice_ = firstLocalSlice_ + numLocalSlices_/2;
65 numLocalCRs_ = numNodesPerSlice_;
66 if (localProc_ < numProcs_-1) {
67 numLocalCRs_ += numNodesPerSlice_;
73 HexBeamCR::~HexBeamCR()
77 int HexBeamCR::getElemConnectivity(
int elemID,
int* nodeIDs)
79 if (elemID < firstLocalElem_ || elemID > firstLocalElem_+localNumElems_) {
83 int whichGlobalSlice = elemID/numElemsPerSlice_;
84 int elemX = elemID%W_;
85 int elemY = (elemID%(W_*W_))/W_;
87 int firstElemNode = (whichGlobalSlice + localProc_*2)*numNodesPerSlice_
88 + elemY*(W_+1) + elemX;
90 if (whichGlobalSlice >= localCRslice_) {
91 firstElemNode += numNodesPerSlice_;
94 nodeIDs[0] = firstElemNode;
95 nodeIDs[1] = firstElemNode+1;
96 nodeIDs[2] = firstElemNode+W_+1;
97 nodeIDs[3] = nodeIDs[2]+1;
99 nodeIDs[4] = nodeIDs[0]+numNodesPerSlice_;
100 nodeIDs[5] = nodeIDs[1]+numNodesPerSlice_;
101 nodeIDs[6] = nodeIDs[2]+numNodesPerSlice_;
102 nodeIDs[7] = nodeIDs[3]+numNodesPerSlice_;
107 int HexBeamCR::getCRNodes(
int** nodeIDs)
110 int firstCRnode = (localCRslice_+localProc_*2)*numNodesPerSlice_;
112 for(i=0; i<numNodesPerSlice_; ++i) {
113 nodeIDs[offset][0] = firstCRnode+i;
114 nodeIDs[offset++][1] = firstCRnode+i+numNodesPerSlice_;
117 if (localProc_ >= numProcs_-1)
return(0);
119 int nextCRnode = firstLocalNode_ + localNumNodes_ - numNodesPerSlice_;
120 for(i=0; i<numNodesPerSlice_; ++i) {
121 nodeIDs[offset][0] = nextCRnode+i;
122 nodeIDs[offset++][1] = nextCRnode+i+numNodesPerSlice_;
128 int HexBeamCR::getElemStiffnessMatrix(
int elemID,
double* elemMat)
130 if (elemID < firstLocalElem_ || elemID > firstLocalElem_+localNumElems_) {
134 int i, len = nodesPerElem_*dofPerNode_*nodesPerElem_*dofPerNode_;
136 for(i=0; i<len; ++i) {
146 len = nodesPerElem_*dofPerNode_;
147 for(i=0; i<len; ++i) {
148 int offset = i*len+i;
149 elemMat[offset] = 4.0;
153 for(i=0; i<len; ++i) {
154 int offset = i*len+i;
156 elemMat[offset-2] = -0.5;
160 elemMat[offset+2] = -0.5;
164 elemMat[offset-4] = -0.1;
167 elemMat[offset+4] = -0.1;
174 int HexBeamCR::getElemLoadVector(
int elemID,
double* elemVec)
176 if (elemID < firstLocalElem_ || elemID > firstLocalElem_+localNumElems_) {
180 int i, len = nodesPerElem_*dofPerNode_;
181 for(i=0; i<len; ++i) {
188 int HexBeamCR::getNumBCNodes()
190 int numBCNodes = (numLocalSlices_+1)*(W_+1);
191 return( numBCNodes );
194 int HexBeamCR::getBCNodes(
int numNodes,
int* nodeIDs)
196 if (numNodes != getNumBCNodes()) {
200 int firstBCNode = firstLocalNode_ + W_;
202 for(
int i=0; i<numNodes; ++i) {
203 nodeIDs[i] = firstBCNode + W_+1;
209 int HexBeamCR::getBCGammaValues(
int numBCDofs,
double* gamma)
211 if (numBCDofs != getNumBCNodes()*dofPerNode_) {
215 for(
int i=0; i<numBCDofs; ++i) {
222 int HexBeamCR::getNumSharedNodes()
224 if (numProcs_ < 2)
return(0);
226 int numSharedNodes = numNodesPerSlice_;
227 if (localProc_ > 0 && localProc_ < numProcs_-1) {
228 numSharedNodes += numNodesPerSlice_;
231 return(numSharedNodes);
234 int HexBeamCR::getSharedNodes(
int numSharedNodes,
236 int*& numSharingProcsPerNode,
239 if (numProcs_ < 2)
return(0);
241 if (numSharedNodes != getNumSharedNodes()) {
245 sharedNodes =
new int[numSharedNodes];
246 numSharingProcsPerNode =
new int[numSharedNodes];
247 sharingProcs =
new int*[numSharedNodes];
248 int* sharingProcVals =
new int[numSharedNodes];
249 if (sharedNodes == NULL || numSharingProcsPerNode == NULL ||
250 sharingProcs == NULL || sharingProcVals == NULL) {
255 for(i=0; i<numSharedNodes; ++i) {
256 numSharingProcsPerNode[i] = 1;
257 sharingProcs[i] = &(sharingProcVals[i]);
260 int firstSharedNode = firstLocalNode_+numNodesPerSlice_*(numLocalSlices_+2);
263 if (localProc_ < numProcs_ - 1) {
264 for(i=0; i<numNodesPerSlice_; ++i) {
265 sharedNodes[offset] = firstSharedNode+i;
266 sharingProcs[offset++][0] = localProc_+1;
270 firstSharedNode = firstLocalNode_;
272 if (localProc_ > 0) {
273 for(i=0; i<numNodesPerSlice_; ++i) {
274 sharedNodes[offset] = firstSharedNode+i;
275 sharingProcs[offset++][0] = localProc_-1;
std::ostream & console_out()