26 return((
int)std::ceil(std::sqrt((
double)x)));
107 messageAbort(
"L must be an integer multiple of sqrt(numProcs).");
164 for(
int i=0; i<sqrtElems; i++) {
165 for(
int j=0; j<sqrtElems; j++) {
191 if (size == 0)
messageAbort(
"loadElements: bad conn ptr.");
209 if (size == 0)
messageAbort(
"loadElemStiffnesses: bad conn ptr.");
219 for(
int j=0; j<size; j++) {
221 FEI_COUT <<
"("<<x[j]<<
","<<y[j]<<
") ";
242 if (size == 0)
messageAbort(
"loadElemLoads: bad conn ptr.");
252 for(
int j=0; j<size; j++) {
254 FEI_COUT <<
"("<<x[j]<<
","<<y[j]<<
") ";
277 int elemX = (int)elemID%
L_;
278 if (elemX == 0) elemX =
L_;
281 int elemY = ((int)elemID - elemX)/
L_ + 1;
294 conn[1] = lowerRight;
295 conn[2] = upperRight;
337 int* numProcsPerSharedNode,
338 int** sharingProcs) {
367 if (size == 0)
messageAbort(
"loadElements: bad conn ptr.");
371 sharedNodeIDs[0] = elemConn[3];
372 numProcsPerSharedNode[0] = 2;
387 int lowerLeftElemIndex = 0;
392 for(
int i=0; i<sqrtElems; i++){
396 int elemIndex = lowerLeftElemIndex+i*sqrtElems;
408 sharedNodeIDs[shOffset] = nodes[3];
411 numProcsPerSharedNode[shOffset++] = 2;
418 numProcsPerSharedNode[shOffset] = 4;
420 sharingProcs[shOffset][3] = sharingProcs[shOffset][2] - 1;
427 int* numProcsPerSharedNode,
428 int** sharingProcs) {
460 sharedNodeIDs[0] = nodes[1];
461 numProcsPerSharedNode[0] = 2;
481 for(
int i=0; i<sqrtElems; i++){
484 int elemIndex = upperRightElemIndex-i*sqrtElems;
495 sharedNodeIDs[shOffset] = nodes[1];
498 numProcsPerSharedNode[shOffset++] = 2;
505 numProcsPerSharedNode[shOffset] = 4;
507 sharingProcs[shOffset][3] = sharingProcs[shOffset][2] + 1;
514 int* numProcsPerSharedNode,
515 int** sharingProcs) {
547 sharedNodeIDs[0] = nodes[2];
548 numProcsPerSharedNode[0] = 2;
568 for(
int i=0; i<sqrtElems; i++){
571 int elemIndex = topLeftElemIndex+i;
583 sharedNodeIDs[shOffset] = nodes[2];
586 numProcsPerSharedNode[shOffset++] = 2;
592 numProcsPerSharedNode[shOffset] = 4;
594 sharingProcs[shOffset][3] = sharingProcs[shOffset][0] + 1;
601 int* numProcsPerSharedNode,
602 int** sharingProcs) {
634 sharedNodeIDs[0] = nodes[0];
635 numProcsPerSharedNode[0] = 2;
655 for(
int i=0; i<sqrtElems; i++){
659 int elemIndex = lowerRightElemIndex-i;
671 sharedNodeIDs[shOffset] = nodes[0];
674 numProcsPerSharedNode[shOffset++] = 2;
680 numProcsPerSharedNode[shOffset] = 4;
682 sharingProcs[shOffset][3] = sharingProcs[shOffset][0] - 1;
690 int** shareProcs,
int* numShareProcs)
692 for(
int i=0; i<numShared; i++) {
695 for(
int j=0; j<numShareProcs[i]; j++) {
696 FEI_COUT << shareProcs[i][j] <<
" ";
717 if (size == 0)
messageAbort(
"loadElements: bad conn ptr.");
727 for(
int j=0; j<size; j++) {
728 if ((std::abs(xcoord[j]) < 1.e-49) || (std::abs(xcoord[j] - 1.0) < 1.e-49) ||
729 (std::abs(ycoord[j]) < 1.e-49) || (std::abs(ycoord[j] - 1.0) < 1.e-49)) {
731 addBCNode(nodeIDs[j], xcoord[j], ycoord[j]);
740 std::vector<GlobalID>::iterator
743 if (iter ==
BCNodeIDs_.end() || *iter != nodeID) {
747 double bcValue = std::pow(x, 2.0) + std::pow(y, 2.0);
779 for(
int elem=0; elem<numLocalElements; elem++) {
783 CHK_ERR( fei->
initElem(elemBlockID, elemIDs[elem], elemConnectivity) );
793 int maxNumSharedNodes = (int)std::sqrt((
double)numLocalElements);
795 int* numProcsPerSharedNode =
new int[maxNumSharedNodes];
796 int** sharingProcs =
new int*[maxNumSharedNodes];
797 for(
int i=0; i<maxNumSharedNodes; i++) sharingProcs[i] =
new int[4];
804 numProcsPerSharedNode, sharingProcs);
807 numProcsPerSharedNode, sharingProcs));
812 numProcsPerSharedNode, sharingProcs);
815 numProcsPerSharedNode, sharingProcs));
820 numProcsPerSharedNode, sharingProcs);
823 numProcsPerSharedNode, sharingProcs));
828 numProcsPerSharedNode, sharingProcs);
831 numProcsPerSharedNode, sharingProcs));
833 for(
int j=0; j<maxNumSharedNodes; j++)
delete [] sharingProcs[j];
834 delete [] sharingProcs;
835 delete [] numProcsPerSharedNode;
836 delete [] sharedNodeIDs;
848 for(
int elem=0; elem<numLocalElements; elem++) {
854 elemConnectivity, elemStiffness,
857 double* elemLoad = poissonData.
getElemLoad(elemIDs[elem]);
860 elemConnectivity, elemLoad));
879 for(
int elem=0; elem<numLocalElements; elem++) {
885 elemConnectivity, elemStiffness,
888 double* elemLoad = poissonData.
getElemLoad(elemIDs[elem]);
890 for(
int i=0; i<numIDs; ++i) {
914 std::vector<int> offsets(numBCNodes, 0);
917 &offsets[0], values) );
938 nodeIDType, fieldIDsTable[0][0]);
941 numLocalElements, patternID) );
948 for(
int elem=0; elem<numLocalElements; elem++) {
963 int maxNumSharedNodes = (int)std::sqrt((
double)numLocalElements);
965 int* numProcsPerSharedNode =
new int[maxNumSharedNodes];
966 int** sharingProcs =
new int*[maxNumSharedNodes];
967 for(
int i=0; i<maxNumSharedNodes; i++) sharingProcs[i] =
new int[4];
974 numProcsPerSharedNode, sharingProcs);
978 numProcsPerSharedNode, sharingProcs));
983 numProcsPerSharedNode, sharingProcs);
986 numProcsPerSharedNode, sharingProcs));
991 numProcsPerSharedNode, sharingProcs);
994 numProcsPerSharedNode, sharingProcs));
999 numProcsPerSharedNode, sharingProcs);
1002 numProcsPerSharedNode, sharingProcs));
1004 for(
int j=0; j<maxNumSharedNodes; j++)
delete [] sharingProcs[j];
1005 delete [] sharingProcs;
1006 delete [] numProcsPerSharedNode;
1007 delete [] sharedNodeIDs;
1023 std::vector<int> indicesArray(numIndices);
1024 int* indicesPtr = &indicesArray[0];
1026 for(
int elem=0; elem<numLocalElements; elem++) {
1029 int checkNumIndices = 0;
1031 numIndices, indicesPtr,
1033 if (checkNumIndices != numIndices)
return(-1);
1038 double* elemLoad = poissonData.
getElemLoad(elemIDs[elem]);
1040 CHK_ERR( rhs->
sumIn(numIndices, indicesPtr, elemLoad));
double ** getElemStiffness(GlobalID elemID)
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
double * getElemLoad(int &size)
virtual int loadEssentialBCs(int numIDs, const int *IDs, int idType, int fieldID, int offsetIntoField, const double *prescribedValues)
double * getNodalY(int &size)
void messageAbort(const char *message)
double * getNodalX(int &size)
GlobalID * getBCNodeIDs()
int * getNumFieldsPerNodeList()
GlobalID getElemBlockID()
virtual int loadNodeBCs(int numNodes, const GlobalID *nodeIDs, int fieldID, const int *offsetsIntoField, const double *prescribedValues)=0
void getTopSharedNodes(int &numShared, GlobalID *sharedNodeIDs, int *numProcsPerSharedNode, int **sharingProcs)
void getBottomSharedNodes(int &numShared, GlobalID *sharedNodeIDs, int *numProcsPerSharedNode, int **sharingProcs)
std::vector< int > & indices()
void addBCNode(GlobalID nodeID, double x, double y)
int load_elem_data_putrhs(FEI *fei, PoissonData &poissonData)
std::vector< double > BCValues_
GlobalID * getElementConnectivity(GlobalID elemID)
void initializeFieldStuff()
virtual int putIntoRHS(int IDType, int fieldID, int numIDs, const GlobalID *IDs, const double *coefficients)=0
static int int_sqrt(int x)
virtual int getConnectivityNumIndices(int blockID) const =0
int init_elem_connectivities(FEI *fei, HexBeam &hexcube)
int load_elem_data(FEI *fei, HexBeam &hexcube)
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
void calculateDistribution()
int set_shared_nodes(FEI *fei, PoissonData &poissonData)
int ** getNodalFieldIDsTable()
double ** getElemStiff(int &size)
virtual int initElemBlock(GlobalID elemBlockID, int numElements, int numNodesPerElement, const int *numFieldsPerNode, const int *const *nodalFieldIDs, int numElemDofFieldsPerElement, const int *elemDOFFieldIDs, int interleaveStrategy)=0
void getLeftSharedNodes(int &numShared, GlobalID *sharedNodeIDs, int *numProcsPerSharedNode, 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
GlobalID * getElemConnPtr(int &size)
void calculateStiffness()
virtual int sumIn(int numValues, const int *indices, const double *values, int vectorIndex=0)=0
PoissonData(int L, int numProcs, int localProc, int outputLevel)
void printSharedNodes(const char *str, int numShared, GlobalID *nodeIDs, int **shareProcs, int *numShareProcs)
std::ostream & console_out()
bool fieldArraysAllocated_
int load_BC_data(FEI *fei, HexBeam &hexcube)
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
void getRightSharedNodes(int &numShared, GlobalID *sharedNodeIDs, int *numProcsPerSharedNode, int **sharingProcs)
int allocateInternals(int DOF)
void calculateConnectivity(GlobalID *conn, int size, GlobalID elemID)
int allocateStiffness(int DOF)
virtual int sumInElemRHS(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn, const double *elemLoad)=0
int localProc(MPI_Comm comm)
void add_entry(CSVec &vec, int eqn, double coef)
void setElemID(GlobalID gNID)
std::vector< GlobalID > BCNodeIDs_
virtual int definePattern(int numIDs, int idType)=0
int getNumNodesPerElement()
void setElemLength(double len)
void setTotalLength(double len)
double * getElemLoad(GlobalID elemID)
int getNumLocalElements()
virtual int initElem(GlobalID elemBlockID, GlobalID elemID, const GlobalID *elemConn)=0
GlobalID * getLocalElementIDs()
int allocateLoad(int DOF)
int numProcs(MPI_Comm comm)
std::vector< double > & coefs()
virtual int initConnectivityBlock(int blockID, int numConnectivityLists, int patternID, bool diagonal=false)=0