14 #define fei_file "HexBeam.cpp"
22 localProc_(localProc),
27 dofPerNode_(DofPerNode)
42 throw std::runtime_error(
"HexBeam: size D must be greater or equal num-procs.");
44 if (localProc < remainder) {
55 if (remainder <= localProc && remainder > 0) {
83 int elemX = elemID%
W_;
84 int elemY = (elemID%(
W_*
W_))/
W_;
87 + elemY*(
W_+1) + elemX;
89 nodeIDs[0] = firstElemNode;
90 nodeIDs[1] = firstElemNode+1;
91 nodeIDs[2] = firstElemNode+
W_+1;
92 nodeIDs[3] = nodeIDs[2]+1;
110 for(i=0; i<len; ++i) {
121 for(i=0; i<len; ++i) {
122 int offset = i*len+i;
123 elemMat[offset] = 4.0;
127 for(i=0; i<len; ++i) {
128 int offset = i*len+i;
130 elemMat[offset-2] = -0.5;
134 elemMat[offset+2] = -0.5;
138 elemMat[offset-4] = -0.1;
141 elemMat[offset+4] = -0.1;
155 for(i=0; i<len; ++i) {
165 return( numBCNodes );
176 for(
int i=0; i<numNodes; ++i) {
177 nodeIDs[i] = firstBCNode + W_+1;
189 for(
int i=0; i<numBCNodes; ++i) {
190 offsetsIntoField[i] = 0;
206 return(numSharedNodes);
211 int*& numSharingProcsPerNode,
220 sharedNodes =
new int[numSharedNodes];
221 numSharingProcsPerNode =
new int[numSharedNodes];
222 sharingProcs =
new int*[numSharedNodes];
223 int* sharingProcVals =
new int[numSharedNodes];
224 if (sharedNodes == NULL || numSharingProcsPerNode == NULL ||
225 sharingProcs == NULL || sharingProcVals == NULL) {
230 for(i=0; i<numSharedNodes; ++i) {
231 numSharingProcsPerNode[i] = 1;
232 sharingProcs[i] = &(sharingProcVals[i]);
240 sharedNodes[offset] = firstSharedNode+i;
248 sharedNodes[offset] = firstSharedNode+i;
256 namespace HexBeam_Functions {
267 FEI_COUT << localProc <<
": elem " << firstLocalElem+i <<
", nodes: ";
287 int** fieldIDsTable =
new int*[nodesPerElem];
288 int* numFieldsPerNode =
new int[nodesPerElem];
290 for(
int j=0; j<nodesPerElem; ++j) {
291 numFieldsPerNode[j] = 1;
292 fieldIDsTable[j] =
new int[numFieldsPerNode[j]];
293 for(
int k=0; k<numFieldsPerNode[j]; ++k) {
294 fieldIDsTable[j][k] = fieldID;
309 int* nodeIDs =
new int[nodesPerElem];
310 if (nodeIDs == NULL)
return(-1);
312 for(
int i=0; i<numLocalElems; ++i) {
319 delete [] numFieldsPerNode;
320 for(
int jj=0; jj<nodesPerElem; ++jj) {
321 delete [] fieldIDsTable[jj];
323 delete [] fieldIDsTable;
331 if (numSharedNodes == 0) {
336 int* numSharingProcsPerNode = NULL;
337 int** sharingProcs = NULL;
338 if (numSharedNodes > 0) {
340 sharedNodes, numSharingProcsPerNode,
345 numSharingProcsPerNode, sharingProcs) );
347 delete [] sharedNodes;
348 delete [] numSharingProcsPerNode;
349 delete [] sharingProcs[0];
350 delete [] sharingProcs;
363 int* crnodes_1d =
new int[numCRs*numNodesPerCR];
364 int** crNodes =
new int*[numCRs];
366 for(i=0; i<numCRs; ++i) {
367 crNodes[i] = &(crnodes_1d[offset]);
368 offset += numNodesPerCR;
374 int* fieldIDs =
new int[numNodesPerCR];
375 for(i=0; i<numNodesPerCR; ++i) fieldIDs[i] = 0;
377 for(i=0; i<numCRs; ++i) {
386 firstLocalCRID = crID;
390 delete [] crnodes_1d;
405 int* crnodes_1d =
new int[numCRs*numNodesPerCR];
406 int** crNodes =
new int*[numCRs];
408 for(i=0; i<numCRs; ++i) {
409 crNodes[i] = &(crnodes_1d[offset]);
410 offset += numNodesPerCR;
415 int* fieldIDs =
new int[numNodesPerCR];
416 for(i=0; i<numNodesPerCR; ++i) fieldIDs[i] = 0;
419 double* weights =
new double[fieldSize*numNodesPerCR];
421 for(i=0; i<fieldSize*numNodesPerCR; ++i) weights[i] = 0.0;
423 weights[fieldSize] = 1.0;
424 double rhsValue = 0.0;
426 for(i=0; i<numCRs; ++i) {
428 numNodesPerCR, crNodes[i], fieldIDs,
429 weights, rhsValue) );
432 delete [] crnodes_1d;
448 int len = nodesPerElem*fieldSize;
449 double* elemMat =
new double[len*len];
450 double** elemMat2D =
new double*[len];
451 double* elemVec =
new double[len];
453 int* nodeIDs =
new int[nodesPerElem];
455 if (elemMat == NULL || elemMat2D == NULL || elemVec == NULL ||
460 for(
int j=0; j<len; ++j) {
461 elemMat2D[j] = &(elemMat[j*len]);
467 for(
int i=0; i<numLocalElems; ++i) {
487 if (numBCNodes == 0) {
491 int* nodeIDs =
new int[numBCNodes];
495 int* offsetsIntoField =
new int[numBCNodes];
496 double* prescribed_vals =
new double[numBCNodes];
503 fieldID, offsetsIntoField, prescribed_vals) );
506 delete [] offsetsIntoField;
507 delete [] prescribed_vals;
525 nodeIDType, fieldID);
538 int* nodeIDs =
new int[nodesPerElem];
539 if (nodeIDs == NULL)
return(-1);
541 for(
int i=0; i<numLocalElems; ++i) {
555 if (numSharedNodes == 0) {
560 int* numSharingProcsPerNode = NULL;
561 int** sharingProcs = NULL;
562 if (numSharedNodes > 0) {
564 sharedNodes, numSharingProcsPerNode,
573 sharedNodes, numSharingProcsPerNode,
576 delete [] sharedNodes;
577 delete [] numSharingProcsPerNode;
578 delete [] sharingProcs[0];
579 delete [] sharingProcs;
593 int* crnodes_1d =
new int[numCRs*numNodesPerCR];
594 int** crNodes =
new int*[numCRs];
596 for(i=0; i<numCRs; ++i) {
597 crNodes[i] = &(crnodes_1d[offset]);
598 offset += numNodesPerCR;
603 int crID = localProc*100000;
604 firstLocalCRID = crID;
609 int* fieldIDs =
new int[numNodesPerCR];
610 int* idTypes =
new int[numNodesPerCR];
611 for(i=0; i<numNodesPerCR; ++i) {
613 idTypes[i] = nodeIDType;
616 for(i=0; i<numCRs; ++i) {
629 delete [] crnodes_1d;
644 int* crnodes_1d =
new int[numCRs*numNodesPerCR];
645 int** crNodes =
new int*[numCRs];
647 for(i=0; i<numCRs; ++i) {
648 crNodes[i] = &(crnodes_1d[offset]);
649 offset += numNodesPerCR;
656 int* fieldIDs =
new int[numNodesPerCR];
657 int* idTypes =
new int[numNodesPerCR];
658 for(i=0; i<numNodesPerCR; ++i) {
660 idTypes[i] = nodeIDType;
664 double* weights =
new double[fieldSize*numNodesPerCR];
666 for(i=0; i<fieldSize*numNodesPerCR; ++i) weights[i] = 0.0;
668 weights[fieldSize] = 1.0;
669 double rhsValue = 0.0;
670 int offsetOfSlave = 0;
671 int offsetIntoSlaveField = 0;
673 for(i=0; i<numCRs; ++i) {
679 offsetIntoSlaveField,
684 delete [] crnodes_1d;
703 int len = nodesPerElem*fieldSize;
704 double* elemMat =
new double[len*len];
705 double** elemMat2D =
new double*[len];
706 double* elemVec =
new double[len];
708 if (elemMat == NULL || elemMat2D == NULL || elemVec == NULL) {
712 for(
int j=0; j<len; ++j) {
713 elemMat2D[j] = &(elemMat[j*len]);
720 std::vector<int> indices(len);
726 for(
int i=0; i<numLocalElems; ++i) {
757 double* weights =
new double[fieldSize*numNodesPerCR];
760 for(i=0; i<fieldSize*numNodesPerCR; ++i) weights[i] = 0.0;
762 weights[fieldSize] = 1.0;
763 double rhsValue = 0.0;
765 for(i=0; i<numCRs; ++i) {
767 weights, rhsValue) );
778 if (numBCNodes == 0) {
782 int* nodeIDs =
new int[numBCNodes];
787 int* offsetsIntoField =
new int[numBCNodes];
788 double* prescribed_vals =
new double[numBCNodes];
796 offsetsIntoField, prescribed_vals) );
798 delete [] offsetsIntoField;
799 delete [] prescribed_vals;
virtual void setIndicesMode(int mode)=0
int load_constraints(FEI *fei, HexBeam &hexcube, int firstLocalCRID)
int initSharedIDs(int numShared, int idType, const int *sharedIDs, const int *numSharingProcsPerID, const int *sharingProcs)
virtual int sumInElemMatrix(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *const *elemStiffness, int elemFormat)=0
virtual int getCRNodes(int **nodeIDs)
virtual int loadEssentialBCs(int numIDs, const int *IDs, int idType, int fieldID, int offsetIntoField, const double *prescribedValues)
virtual int loadLagrangeConstraint(int constraintID, const double *weights, double rhsValue)=0
virtual bool usingBlockEntryStorage()=0
int init_slave_constraints(fei::MatrixGraph *matrixGraph, HexBeam &hexcube)
virtual int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)=0
virtual int initLagrangeConstraint(int constraintID, int constraintIDType, int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs)=0
virtual int initSlaveConstraint(int numIDs, const int *idTypes, const int *IDs, const int *fieldIDs, int offsetOfSlave, int offsetIntoSlaveField, const double *weights, double rhsValue)=0
virtual int getBCNodes(int numNodes, int *nodeIDs)
int init_constraints(FEI *fei, HexBeam &hexcube, int &firstLocalCRID)
virtual int loadCRMult(int CRMultID, int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, const double *CRWeights, double CRValue)=0
virtual int initCRMult(int numCRNodes, const GlobalID *CRNodeIDs, const int *CRFieldIDs, int &CRID)=0
virtual int getNumSharedNodes()
int init_elem_connectivities(FEI *fei, HexBeam &hexcube)
int print_cube_data(HexBeam &hexcube, int numProcs, int localProc)
int load_elem_data(FEI *fei, HexBeam &hexcube)
virtual fei::SharedPtr< fei::VectorSpace > getRowSpace()=0
virtual int firstLocalElem()
virtual int initConnectivity(int blockID, int connectivityID, const int *connectedIdentifiers)=0
virtual int initSharedNodes(int numSharedNodes, const GlobalID *sharedNodeIDs, const int *numProcsPerNode, const int *const *sharingProcIDs)=0
virtual int getBCValues(int numBCNodes, int *offsetsIntoField, double *vals)
virtual int numDofPerNode()
virtual int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)=0
virtual int getSharedNodes(int numSharedNodes, int *&sharedNodes, int *&numSharingProcsPerNode, int **&sharingProcs)
virtual int sumIn(int numRows, const int *rows, int numCols, const int *cols, const double *const *values, int format=0)=0
virtual int getConnectivityIndices(int blockID, int connectivityID, int indicesAllocLen, int *indices, int &numIndices)=0
int init_shared_nodes(FEI *fei, HexBeam &hexcube)
virtual int sumIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
virtual int getElemConnectivity(int elemID, int *nodeIDs)
virtual fei::SharedPtr< fei::MatrixGraph > getMatrixGraph() const =0
virtual int getElemStiffnessMatrix(int elemID, double *elemMat)
std::ostream & console_out()
int load_BC_data(FEI *fei, HexBeam &hexcube)
virtual int numNodesPerElem()
virtual int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)=0
int localProc(MPI_Comm comm)
virtual int getNumBCNodes()
virtual int getNumNodesPerCR()
virtual int definePattern(int numIDs, int idType)=0
virtual int getElemLoadVector(int elemID, double *elemVec)
virtual int numLocalElems()
HexBeam(int W, int D, int DofPerNode, int decomp, int numProcs, int localProc)
virtual int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)=0
int numProcs(MPI_Comm comm)
virtual int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)=0