405 for (
int j=0; j<surfacePermutation.size(); j++) {
406 vec_int_Type tmpSurface(2);
407 tmpSurface[0] = feP2.getNode( surfacePermutation.at(j).at(0) );
408 tmpSurface[1] = feP2.getNode( surfacePermutation.at(j).at(1) );
410 sort( tmpSurface.begin(), tmpSurface.end() );
412 vec_int_Type surfaceNodeP2(0);
413 const vec_int_Type surfaceNodeP1 = surfFeP1.getVectorNodeList();
414 if ( tmpSurface[0] == surfaceNodeP1[0] && tmpSurface[1] == surfaceNodeP1[1] ) {
416 surfaceNodeP2.push_back( surfaceNodeP1[0] );
417 surfaceNodeP2.push_back( surfaceNodeP1[1] );
419 surfaceNodeP2.push_back( feP2.getNode( 3 ) );
421 surfaceNodeP2.push_back( feP2.getNode( 5 ) );
423 surfaceNodeP2.push_back( feP2.getNode( 4 ) );
425 int flag = surfFeP1.getFlag();
428 if ( !feP2.subElementsInitialized() )
429 feP2.initializeSubElements(
"P2",dim-1);
430 feP2.addSubElement(feP2Surf);
436 for (
int j=0; j<surfacePermutation.size(); j++) {
437 vec_int_Type tmpSurface(3);
438 tmpSurface[0] = feP2.getNode( surfacePermutation.at(j).at(0) );
439 tmpSurface[1] = feP2.getNode( surfacePermutation.at(j).at(1) );
440 tmpSurface[2] = feP2.getNode( surfacePermutation.at(j).at(2) );
444 vec_int_Type index(3, 0);
445 for (
int i = 0 ; i != index.size() ; i++)
448 sort(index.begin(), index.end(),
449 [&](
const int& a,
const int& b) {
450 return tmpSurface[a] < tmpSurface[b];
454 tmpSurface = sort_from_ref(tmpSurface, index);
456 vec_int_Type surfaceNodeP2(0);
457 const vec_int_Type surfaceNodeP1Unsorted = surfFeP1.getVectorNodeList();
458 vec_int_Type surfaceNodeP1 = surfFeP1.getVectorNodeList();
461 vec_int_Type index2(3, 0);
462 for (
int i = 0 ; i != index2.size() ; i++)
465 sort(index2.begin(), index2.end(),
466 [&](
const int& a,
const int& b) {
467 return surfaceNodeP1[a] < surfaceNodeP1[b];
471 surfaceNodeP1 = sort_from_ref(surfaceNodeP1, index2);
473 if ( tmpSurface[0] == surfaceNodeP1[0] &&
474 tmpSurface[1] == surfaceNodeP1[1] &&
475 tmpSurface[2] == surfaceNodeP1[2]) {
476 surfaceNodeP2.push_back( surfaceNodeP1Unsorted[0] );
477 surfaceNodeP2.push_back( surfaceNodeP1Unsorted[1] );
478 surfaceNodeP2.push_back( surfaceNodeP1Unsorted[2] );
479 vec_int_Type additionalP2IDs(3);
481 additionalP2IDs[0] = feP2.getNode( 4 );
482 additionalP2IDs[1] = feP2.getNode( 5 );
483 additionalP2IDs[2] = feP2.getNode( 6 );
486 additionalP2IDs[0] = feP2.getNode( 4 );
487 additionalP2IDs[1] = feP2.getNode( 7 );
488 additionalP2IDs[2] = feP2.getNode( 8 );
491 additionalP2IDs[0] = feP2.getNode( 5 );
492 additionalP2IDs[1] = feP2.getNode( 8 );
493 additionalP2IDs[2] = feP2.getNode( 9 );
496 additionalP2IDs[0] = feP2.getNode( 6 );
497 additionalP2IDs[1] = feP2.getNode( 7 );
498 additionalP2IDs[2] = feP2.getNode( 9 );
502 surfaceNodeP2.push_back( additionalP2IDs[0] );
503 surfaceNodeP2.push_back( additionalP2IDs[1] );
504 surfaceNodeP2.push_back( additionalP2IDs[2] );
508 int flag = surfFeP1.getFlag();
510 if ( !feP2.subElementsInitialized() )
511 feP2.initializeSubElements(
"P2",dim-1);
512 feP2.addSubElement(feP2Surf);
967 vec2D_LO_Type markedPoints(0);
971 vec_int_Type newFlags(edgeElements->numberElements());
973 MapConstPtr_Type edgeMap = this->
getEdgeMap();
975 vec_int_Type markedTrue(edgeElements->numberElements());
976 for(
int i=0; i< edgeElements->numberElements() ; i++){
977 LO p1ID =edgeElements->getElement(i).getNode(0);
978 LO p2ID =edgeElements->getElement(i).getNode(1);
980 if(newFlags[i] != -1){
981 vec_LO_Type elementsOfEdge = edgeElements->getElementsOfEdge( (
int) i );
982 for (
int j=0; j<elementsOfEdge.size(); j++) {
983 if ( elementsOfEdge[j] == -1 )
991 int maxRank = std::get<1>(this->rankRange_);
993 vec_GO_Type edgeSwitch(0);
994 vec_LO_Type flags(0);
995 for(
int i=0; i<edgeElements->numberElements(); i++){
996 if(markedTrue[i]==1){
997 edgeSwitch.push_back(edgeMap->getGlobalElement(i));
998 flags.push_back(newFlags[i]);
1003 Teuchos::ArrayView<GO> edgeSwitchArray = Teuchos::arrayViewFromVector( edgeSwitch);
1005 MapPtr_Type mapGlobalInterface =
1006 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgeSwitchArray, 0, this->comm_) );
1010 MultiVectorLOPtr_Type edgeFlags = Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalInterface, 1 ) );
1011 Teuchos::ArrayRCP< LO > edgeFlagsEntries = edgeFlags->getDataNonConst(0);
1013 for(
int i=0; i< edgeFlagsEntries.size() ; i++){
1014 edgeFlagsEntries[i] = flags[i] ;
1017 MapConstPtr_Type mapGlobalInterfaceUnique = mapGlobalInterface;
1018 if(mapGlobalInterface->getGlobalNumElements()>0){
1019 mapGlobalInterfaceUnique = mapGlobalInterface->buildUniqueMap( this->rankRange_ );
1023 MultiVectorLOPtr_Type isInterfaceElement_imp = Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalInterfaceUnique, 1 ) );
1024 isInterfaceElement_imp->putScalar( (LO) 0 );
1025 isInterfaceElement_imp->importFromVector( edgeFlags,
false,
"Insert");
1027 MultiVectorLOPtr_Type isInterfaceElement_exp = Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalInterfaceUnique, 1 ) );
1028 isInterfaceElement_exp->putScalar( (LO) 0 );
1029 isInterfaceElement_exp->exportFromVector( edgeFlags,
false,
"Insert");
1031 MultiVectorLOPtr_Type isInterfaceElement2_imp = Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalInterface, 1 ) );
1032 isInterfaceElement2_imp->putScalar( (LO) 0 );
1033 isInterfaceElement2_imp->importFromVector(isInterfaceElement_imp,
false,
"Insert");
1035 isInterfaceElement2_imp->exportFromVector(isInterfaceElement_exp,
false,
"Insert");
1037 edgeFlagsEntries = isInterfaceElement2_imp->getDataNonConst(0);
1039 for(
int i=0; i<edgeFlagsEntries.size(); i++){
1040 LO entry = edgeMap->getLocalElement(edgeSwitch[i]);
1041 if(newFlags[entry] > edgeFlagsEntries[i]){
1042 newFlags[entry] = edgeFlagsEntries[i];
1049 vec_GO_Type edgesNeeded(0);
1050 vec_GO_Type edgesActive(0);
1051 vec_int_Type flagsTmp(0);
1052 for(
int i=0; i<edgeElements->numberElements(); i++){
1053 if(newFlags[i]==-1){
1054 edgesNeeded.push_back(edgeMap->getGlobalElement(i));
1057 edgesActive.push_back(edgeMap->getGlobalElement(i));
1058 flagsTmp.push_back(newFlags[i]);
1064 Teuchos::ArrayView<GO> edgesNeededArray = Teuchos::arrayViewFromVector( edgesNeeded);
1065 Teuchos::ArrayView<GO> edgesActiveArray = Teuchos::arrayViewFromVector( edgesActive);
1067 MapPtr_Type mapEdgesNeeded =
1068 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesNeededArray, 0, this->comm_) );
1070 MapPtr_Type mapEdgesActive =
1071 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesActiveArray, 0, this->comm_) );
1073 MultiVectorLOPtr_Type flagsImport = Teuchos::rcp(
new MultiVectorLO_Type( mapEdgesNeeded, 1 ) );
1074 flagsImport->putScalar(this->volumeID_);
1076 MultiVectorLOPtr_Type flagsExport = Teuchos::rcp(
new MultiVectorLO_Type( mapEdgesActive, 1 ) );
1077 Teuchos::ArrayRCP< LO > flagExportEntries = flagsExport->getDataNonConst(0);
1078 for(
int i=0; i< flagExportEntries.size(); i++){
1079 flagExportEntries[i] = flagsTmp[i];
1082 flagsImport->importFromVector(flagsExport,
false,
"Insert");
1084 Teuchos::ArrayRCP< LO > flagImportEntries = flagsImport->getDataNonConst(0);
1085 for(
int i=0; i<flagImportEntries.size(); i++){
1086 LO entry = edgeMap->getLocalElement(edgesNeeded[i]);
1087 if(newFlags[entry] ==-1){
1088 newFlags[entry] = flagImportEntries[i];
1092 for(
int i=0; i< edgeElements->numberElements() ; i++){
1093 edgeElements->getElement(i).setFlag(newFlags[i]);
1101 int maxRank = std::get<1>(this->rankRange_);
1102 vec_GO_Type globalProcs(0);
1103 for (
int i=0; i<= maxRank; i++)
1104 globalProcs.push_back(i);
1106 Teuchos::ArrayView<GO> globalProcArray = Teuchos::arrayViewFromVector( globalProcs);
1108 vec_GO_Type localProc(0);
1109 localProc.push_back(this->comm_->getRank());
1110 Teuchos::ArrayView<GO> localProcArray = Teuchos::arrayViewFromVector( localProc);
1112 MapPtr_Type mapGlobalProc =
1113 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalProcArray, 0, this->comm_) );
1115 MapPtr_Type mapProc =
1116 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), localProcArray, 0, this->comm_) );
1119 vec2D_int_Type interfaceEdgesLocalId(1,vec_int_Type(1));
1120 const int myRank = this->comm_->getRank();
1122 MultiVectorLOPtr_Type exportLocalEntry = Teuchos::rcp(
new MultiVectorLO_Type( mapProc, 1 ) );
1126 int numEdges= this->edgeElements_->numberElements();
1127 vec2D_GO_Type inzidenzIndices(0,vec_GO_Type(2));
1128 vec_LO_Type localEdgeIndex(0);
1131 EdgeElementsPtr_Type edgeElements = this->edgeElements_;
1133 vec2D_dbl_ptr_Type points = this->pointsRep_;
1136 for(
int i=0; i<numEdges; i++ ){
1137 if(edgeElements->getElement(i).isInterfaceElement()){
1139 id[0] = this->mapRepeated_->getGlobalElement(edgeElements->getElement(i).getNode(0));
1140 id[1] = this->mapRepeated_->getGlobalElement(edgeElements->getElement(i).getNode(1));
1144 sort(
id.begin(),
id.end());
1145 inzidenzIndices.push_back(
id);
1147 localEdgeIndex.push_back(i);
1159 MatrixPtr_Type inzidenzMatrix = Teuchos::rcp(
new Matrix_Type(this->mapUnique_, 40 ) );
1160 Teuchos::Array<GO> index(1);
1161 Teuchos::Array<GO> col(1);
1162 Teuchos::Array<SC> value(1, Teuchos::ScalarTraits<SC>::one() );
1164 for(
int i=0; i<inzidenzIndices.size(); i++ ){
1166 index[0] = inzidenzIndices[i][0];
1167 col[0] = inzidenzIndices[i][1];
1168 inzidenzMatrix->insertGlobalValues(index[0], col(), value());
1171 inzidenzMatrix->fillComplete();
1177 exportLocalEntry->putScalar( (LO) edgesUnique );
1179 MultiVectorLOPtr_Type newEdgesUniqueGlobal= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
1180 newEdgesUniqueGlobal->putScalar( (LO) 0 );
1181 newEdgesUniqueGlobal->importFromVector( exportLocalEntry,
true,
"Insert");
1183 Teuchos::ArrayRCP< const LO > newEdgesList = newEdgesUniqueGlobal->getData(0);
1185 GO procOffsetEdges=0;
1186 for(
int i=0; i< myRank; i++)
1187 procOffsetEdges= procOffsetEdges + newEdgesList[i];
1190 vec_GO_Type vecGlobalIDsEdges(this->edgeElements_->numberElements());
1194 for(
int i=0; i< this->edgeElements_->numberElements(); i++){
1195 if(!this->edgeElements_->getElement(i).isInterfaceElement()){
1196 vecGlobalIDsEdges.at(i) = procOffsetEdges+count;
1203 GO offsetInterface=0;
1204 for(
int i=0; i< maxRank+1; i++)
1205 offsetInterface= offsetInterface + newEdgesList[i];
1209 Teuchos::ArrayView<const LO> indices;
1210 Teuchos::ArrayView<const SC> values;
1211 vec2D_GO_Type inzidenzIndicesUnique(0,vec_GO_Type(2));
1212 MapConstPtr_Type colMap = inzidenzMatrix->getMap(
"col");
1213 MapConstPtr_Type rowMap = inzidenzMatrix->getMap(
"row");
1214 int numRows = rowMap->getNodeNumElements();
1216 for(
int i=0; i<numRows; i++ ){
1217 inzidenzMatrix->getLocalRowView(i, indices,values);
1218 uniqueEdges = uniqueEdges+indices.size();
1219 vec_GO_Type edgeTmp(2);
1220 for(
int j=0; j<indices.size(); j++){
1221 edgeTmp[0] = rowMap->getGlobalElement(i);
1222 edgeTmp[1] = colMap->getGlobalElement(indices[j]);
1223 inzidenzIndicesUnique.push_back(edgeTmp);
1227 exportLocalEntry->putScalar( uniqueEdges );
1228 MultiVectorLOPtr_Type newEdgesInterfaceGlobal= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
1229 newEdgesInterfaceGlobal->putScalar( (LO) 0 );
1230 newEdgesInterfaceGlobal->importFromVector( exportLocalEntry,
true,
"Insert");
1233 Teuchos::ArrayRCP< const LO > numUniqueInterface = newEdgesInterfaceGlobal->getData(0);
1236 for(
int i=0; i< myRank; i++)
1237 procOffsetEdges= procOffsetEdges + numUniqueInterface[i];
1239 int numInterfaceEdges=0;
1241 vec_GO_Type uniqueInterfaceIDsList_(inzidenzIndicesUnique.size());
1242 for(
int i=0; i< uniqueInterfaceIDsList_.size(); i++)
1243 uniqueInterfaceIDsList_[i] = procOffsetEdges + i;
1245 MatrixPtr_Type indMatrix = Teuchos::rcp(
new Matrix_Type(this->mapUnique_, 40 ) );
1247 for(
int i=0; i<inzidenzIndicesUnique.size(); i++ ){
1248 index[0] = inzidenzIndicesUnique[i][0];
1249 col[0] = inzidenzIndicesUnique[i][1];
1250 Teuchos::Array<SC> value2(1,uniqueInterfaceIDsList_[i]);
1251 indMatrix->insertGlobalValues(index[0], col(), value2());
1253 indMatrix->fillComplete();
1255 MatrixPtr_Type importMatrix = Teuchos::rcp(
new Matrix_Type(this->mapRepeated_, 40 ) );
1257 importMatrix->importFromVector(indMatrix,
false,
"Insert");
1258 importMatrix->fillComplete();
1262 colMap = importMatrix->getMap(
"col");
1263 rowMap = importMatrix->getMap(
"row");
1268 for(
int i=0; i<inzidenzIndices.size(); i++ ){
1270 importMatrix->getLocalRowView(rowMap->getLocalElement(inzidenzIndices[i][0]), indices,values);
1274 vec2D_GO_Type indicesTmp(indices.size(),vec_GO_Type(2));
1275 vec_GO_Type indTmp(2);
1276 for(
int j=0; j<indices.size(); j++){
1277 indTmp[0] = colMap->getGlobalElement(indices[j]);
1278 indTmp[1] = values[j];
1279 indicesTmp.push_back(indTmp);
1282 for(
int k=0; k<indicesTmp.size();k++){
1283 if(inzidenzIndices[i][1] == indicesTmp[k][0]){
1285 k = indicesTmp.size();
1286 edgeID = indicesTmp[entry][1];
1287 vecGlobalIDsEdges.at(localEdgeIndex[i]) = offsetInterface + edgeID;
1295 Teuchos::RCP<std::vector<GO>> edgesGlobMapping = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsEdges ) );
1296 Teuchos::ArrayView<GO> edgesGlobMappingArray = Teuchos::arrayViewFromVector( *edgesGlobMapping);
1298 this->edgeMap_.reset(
new Map<LO,GO,NO>( Teuchos::OrdinalTraits<GO>::invalid(), edgesGlobMappingArray, 0, this->comm_) );
1575 std::ofstream myFile;
1576 if(this->comm_->getRank() ==0)
1577 myFile.open (meshName);
1579 bool verbose = (this->comm_->getRank() == 0);
1581 std::cout <<
" --------------------------------------" << std::endl;
1582 std::cout <<
" ------------ Exporting Mesh ----------" << std::endl;
1583 std::cout <<
" --------------------------------------" << std::endl;
1587 int numberNodes = mapUnique->getGlobalNumElements();
1592 vec_GO_Type globalImportIDsNodes(0);
1593 for(
int i = 0; i < this->mapUnique_->getGlobalNumElements(); i++)
1595 if(this->mapUnique_->getLocalElement(i) == -1){
1596 globalImportIDsNodes.push_back(i);
1599 Teuchos::ArrayView<GO> globalNodesArrayImp = Teuchos::arrayViewFromVector( globalImportIDsNodes);
1601 MapPtr_Type mapNodesImport =
1602 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalNodesArrayImp, 0, this->
getComm()) );
1604 MultiVectorPtr_Type nodesImp = Teuchos::rcp(
new MultiVector_Type( mapNodesImport, 1 ) );
1605 Teuchos::ArrayRCP< SC > entriesNodesImp = nodesImp->getDataNonConst(0);
1607 MultiVectorPtr_Type nodesExport = Teuchos::rcp(
new MultiVector_Type( this->mapUnique_, 1 ) );
1608 Teuchos::ArrayRCP< SC > entriesNodesExport = nodesExport->getDataNonConst(0);
1610 vec2D_dbl_Type missingNodes(entriesNodesImp.size(),vec_dbl_Type(this->dim_+1));
1612 for(
int j= 0; j < this->dim_; j++)
1614 for(
int i=0; i< entriesNodesExport.size(); i++)
1617 nodesImp->importFromVector(nodesExport,
false,
"Insert");
1618 for(
int i=0; i< entriesNodesImp.size(); i++)
1619 missingNodes[i][j] = entriesNodesImp[i];
1625 for(
int i=0; i< entriesNodesExport.size(); i++)
1626 entriesNodesExport[i] = this->bcFlagUni_->at(i);
1628 nodesImp->importFromVector(nodesExport,
false,
"Insert");
1629 for(
int i=0; i< entriesNodesImp.size(); i++)
1630 missingNodes[i][this->dim_] = entriesNodesImp[i];
1634 if(this->comm_->getRank() == 0){
1636 std::cout <<
" ----- Write Nodes .....";
1638 myFile <<
"MeshVersionFormatted 2" << std::endl;
1639 myFile <<
"Dimension" <<
" " << this->dim_ << std::endl;
1640 myFile << std::endl;
1641 myFile <<
"Vertices";
1642 myFile << std::endl;
1643 myFile << numberNodes;
1644 myFile << std::endl;
1645 for(
int i = 0; i < mapUnique->getGlobalNumElements(); i++)
1648 if(mapUnique->getLocalElement(i) != -1){
1649 LO
id = mapUnique->getLocalElement(i);
1655 if(this->dim_ == 2){
1659 myFile << this->bcFlagUni_->at(
id);
1660 myFile << std::endl;
1663 LO
id = mapNodesImport->getLocalElement(i);
1664 for(
int j= 0; j < this->dim_; j++)
1666 myFile << missingNodes[id][j];
1669 if(this->dim_ == 2){
1673 myFile << missingNodes[id][this->dim_];
1674 myFile << std::endl;
1680 myFile << std::endl;
1682 std::cout <<
".... done ----- " <<
'\n';
1689 std::cout <<
" ----- Write Edges .....";
1691 if(this->FEType_ ==
"P2")
1696 vec2D_GO_Type edgesSubelements(0,vec_GO_Type(dofsEdges+1));
1698 for(
int T=0; T< elements->numberElements() ; T++){
1700 ElementsPtr_Type subEl = fe.getSubElements();
1701 for (
int surface=0; surface<fe.numSubElements(); surface++) {
1703 vec_GO_Type edgeTmp;
1704 edgeTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getFlag()};
1705 if(this->FEType_==
"P2")
1706 edgeTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getVectorNodeList().at(2),feSub.getFlag()};
1708 edgesSubelements.push_back(edgeTmp);
1713 int numSubEl = edgesSubelements.size();
1715 int maxRank = std::get<1>(this->rankRange_);
1716 vec_GO_Type globalProcs(0);
1717 for (
int i=0; i<= maxRank; i++)
1718 globalProcs.push_back(i);
1720 Teuchos::ArrayView<GO> globalProcArray = Teuchos::arrayViewFromVector( globalProcs);
1722 vec_GO_Type localProc(0);
1723 localProc.push_back(this->comm_->getRank());
1724 Teuchos::ArrayView<GO> localProcArray = Teuchos::arrayViewFromVector( localProc);
1726 MapPtr_Type mapGlobalProc =
1727 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalProcArray, 0, this->comm_) );
1729 MapPtr_Type mapProc =
1730 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), localProcArray, 0, this->comm_) );
1732 MultiVectorLOPtr_Type exportLocalEntry = Teuchos::rcp(
new MultiVectorLO_Type( mapProc, 1 ) );
1733 exportLocalEntry->putScalar( (LO) numSubEl );
1736 MultiVectorLOPtr_Type numEdgesProc= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
1737 numEdgesProc->putScalar( (LO) 0 );
1738 numEdgesProc->importFromVector( exportLocalEntry,
false,
"Insert");
1741 Teuchos::ArrayRCP< const LO > edgesRanks = numEdgesProc->getData(0);
1742 vec_GO_Type vecGlobalIDsElements(0);
1744 GO procOffsetElements=0;
1745 int myRank = this->comm_->getRank();
1746 for(
int i=0; i< myRank; i++)
1747 procOffsetElements = procOffsetElements + edgesRanks[i];
1749 for (
int i=0; i<numSubEl; i++){
1750 vecGlobalIDsElements.push_back( i + procOffsetElements);
1753 Teuchos::RCP<std::vector<GO> > edgesGlobMapping = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsElements ) );
1754 Teuchos::ArrayView<GO> edgesGlobMappingArray = Teuchos::arrayViewFromVector( *edgesGlobMapping);
1755 MapPtr_Type mapEdgesExport =
1756 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesGlobMappingArray, 0, this->
getComm()) );
1758 vec_GO_Type vecGlobalIDsEdgesImport(0);
1759 int maxIndex = mapEdgesExport->getMaxAllGlobalIndex();
1760 if(this->comm_->getRank() == 0){
1761 for(
int i=numSubEl; i<maxIndex+1 ; i++)
1762 vecGlobalIDsEdgesImport.push_back(i);
1764 Teuchos::RCP<std::vector<GO> > edgesGlobMappingImport = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsEdgesImport ) );
1765 Teuchos::ArrayView<GO> edgesGlobMappingImportArray = Teuchos::arrayViewFromVector( *edgesGlobMappingImport);
1766 MapPtr_Type mapEdgesImport =
1767 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesGlobMappingImportArray, 0, this->
getComm()) );
1769 int numberEdges = maxIndex+1;
1771 MultiVectorPtr_Type edgesImp = Teuchos::rcp(
new MultiVector_Type( mapEdgesImport, 1 ) );
1772 Teuchos::ArrayRCP< SC > entriesEdgesImp = edgesImp->getDataNonConst(0);
1774 MultiVectorPtr_Type edgesExport = Teuchos::rcp(
new MultiVector_Type( mapEdgesExport , 1 ) );
1775 Teuchos::ArrayRCP< SC > entriesEdgesExport = edgesExport->getDataNonConst(0);
1778 vec2D_dbl_Type missingEdges(entriesEdgesImp.size(),vec_dbl_Type(dofsEdges+1));
1780 for(
int j= 0; j < dofsEdges+1; j++)
1782 for(
int i=0; i< entriesEdgesExport.size(); i++){
1784 entriesEdgesExport[i] = mapRep->getGlobalElement(edgesSubelements[i][j]);
1786 entriesEdgesExport[i] = edgesSubelements[i][j];
1790 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1791 for(
int i=0; i< entriesEdgesImp.size(); i++)
1792 missingEdges[i][j] = entriesEdgesImp[i];
1795 if(this->comm_->getRank() == 0){
1798 myFile << std::endl;
1799 myFile << numberEdges;
1800 myFile << std::endl;
1801 for(
int i = 0; i < mapEdgesExport->getGlobalNumElements(); i++)
1803 if(mapEdgesExport->getLocalElement(i) != -1){
1804 LO
id = this->edgeMap_->getLocalElement(i);
1806 for(
int j= 0; j < dofsEdges; j++)
1808 myFile << mapRep->getGlobalElement(edgesSubelements[i][j])+1;
1812 myFile << edgesSubelements[i][dofsEdges];
1813 myFile << std::endl;
1818 LO
id = mapEdgesImport->getLocalElement(i);
1819 for(
int j= 0; j < dofsEdges; j++)
1821 myFile << missingEdges[id][j]+1;
1824 myFile << missingEdges[id][dofsEdges];
1825 myFile << std::endl;
1830 myFile << std::endl;
1834 std::cout <<
".... done ---- " <<
'\n';
1837 else if(this->dim_ == 3){
1839 if(this->FEType_ !=
"P2")
1842 vec_GO_Type globalImportIDsEdges(0);
1844 MapConstPtr_Type edgeMapUnique = this->edgeMap_->buildUniqueMap( this->rankRange_ );
1846 vec2D_int_Type edgesUnique(edgeMapUnique->getNodeNumElements(),vec_int_Type(2,0));
1847 for (
int i=0; i < edgeMapUnique->getNodeNumElements(); i++) {
1848 GO gid = edgeMapUnique->getGlobalElement( i );
1849 LO
id = this->edgeMap_->getLocalElement( gid );
1850 edgesUnique[i] = this->edgeElements_->getElement(
id).getVectorNodeListNonConst();
1853 if(this->comm_->getRank() == 0){
1854 for(
int i = 0; i < edgeMapUnique->getGlobalNumElements(); i++)
1856 if(edgeMapUnique->getLocalElement(i) == -1){
1857 globalImportIDsEdges.push_back(i);
1861 int numberEdges = edgeMapUnique->getGlobalNumElements();
1863 Teuchos::ArrayView<GO> globalEdgesArrayImp = Teuchos::arrayViewFromVector( globalImportIDsEdges);
1865 MapPtr_Type mapEdgesImport =
1866 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalEdgesArrayImp, 0, this->
getComm()) );
1868 MultiVectorPtr_Type edgesImp = Teuchos::rcp(
new MultiVector_Type( mapEdgesImport, 1 ) );
1869 Teuchos::ArrayRCP< SC > entriesEdgesImp = edgesImp->getDataNonConst(0);
1871 MultiVectorPtr_Type edgesExport = Teuchos::rcp(
new MultiVector_Type( edgeMapUnique, 1 ) );
1872 Teuchos::ArrayRCP< SC > entriesEdgesExport = edgesExport->getDataNonConst(0);
1874 vec2D_dbl_Type missingEdges(entriesEdgesImp.size(),vec_dbl_Type(dofsEdges+1));
1876 for(
int j= 0; j < 2; j++)
1878 for(
int i=0; i< entriesEdgesExport.size(); i++)
1879 entriesEdgesExport[i] = mapRep->getGlobalElement(edgesUnique[i][j])+1;
1881 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1882 for(
int i=0; i< entriesEdgesImp.size(); i++)
1883 missingEdges[i][j] = entriesEdgesImp[i];
1886 if(this->FEType_ ==
"P2"){
1887 for(
int i=0; i< entriesEdgesExport.size(); i++){
1888 GO gid = edgeMapUnique->getGlobalElement( i );
1889 LO
id = this->edgeMap_->getLocalElement( gid );
1890 entriesEdgesExport[i] = mapRep->getGlobalElement(this->edgeElements_->getMidpoint(
id))+1;
1893 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1894 for(
int i=0; i< entriesEdgesImp.size(); i++)
1895 missingEdges[i][2] = entriesEdgesImp[i];
1899 for(
int i=0; i< entriesEdgesExport.size(); i++){
1900 GO gid = edgeMapUnique->getGlobalElement( i );
1901 LO
id = this->edgeMap_->getLocalElement( gid);
1902 entriesEdgesExport[i] = this->edgeElements_->getElement(
id).getFlag();
1905 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1906 for(
int i=0; i< entriesEdgesImp.size(); i++)
1907 missingEdges[i][dofsEdges] = entriesEdgesImp[i];
1910 if(this->comm_->getRank() == 0){
1913 vec2D_int_Type edges(0,vec_int_Type(0));
1914 for(
int i = 0; i < edgeMapUnique->getGlobalNumElements(); i++)
1916 vec_int_Type entry(0);
1917 if(edgeMapUnique->getLocalElement(i) != -1){
1918 LO
id = this->edgeMap_->getLocalElement(i);
1919 if(this->edgeElements_->getElement(
id).getFlag() < this->volumeID_)
1921 for(
int j= 0; j < 2; j++)
1923 entry.push_back(mapRep->getGlobalElement(this->edgeElements_->getElement(
id).getVectorNodeList().at(j))+1);
1925 if(this->FEType_ ==
"P2")
1926 entry.push_back(mapRep->getGlobalElement(this->edgeElements_->getMidpoint(
id))+1);
1928 entry.push_back(this->edgeElements_->getElement(
id).getFlag());
1930 edges.push_back(entry);
1936 LO
id = mapEdgesImport->getLocalElement(i);
1937 if(missingEdges[
id][dofsEdges]< this->volumeID_){
1939 for(
int j= 0; j < dofsEdges; j++)
1941 entry.push_back(missingEdges[
id][j]);
1943 entry.push_back(missingEdges[
id][dofsEdges]);
1945 edges.push_back(entry);
1953 myFile << std::endl;
1954 myFile << edges.size();
1955 myFile << std::endl;
1957 for(
int i = 0; i < edges.size(); i++)
1960 for(
int j= 0; j < 2; j++)
1962 myFile << edges[i][j];
1965 if(this->FEType_ ==
"P2")
1966 myFile << edges[i][2];
1968 myFile << edges[i][edges[i].size()-1];
1969 myFile << std::endl;
1974 myFile << std::endl;
1976 std::cout <<
".... done ----- " <<
'\n';
1981 this->comm_->barrier();
1983 if(exportSurface && this->dim_ >2){
1985 std::cout <<
" ----- Write Surfaces ...";
1987 if(this->FEType_ ==
"P2")
1992 vec2D_GO_Type surfacesSubelements(0,vec_GO_Type(dofsSurfaces+1));
1994 for(
int T=0; T< elements->numberElements() ; T++){
1996 for (
int surface=0; surface<fe.numSubElements(); surface++) {
1997 ElementsPtr_Type subEl = fe.getSubElements();
1998 if(subEl->getDimension() == this->dim_-1 ){
2000 vec_GO_Type surfaceTmp;
2001 surfaceTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getVectorNodeList().at(2),feSub.getFlag()};
2002 if(this->FEType_==
"P2")
2003 surfaceTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getVectorNodeList().at(2),feSub.getVectorNodeList().at(3),feSub.getVectorNodeList().at(4),feSub.getVectorNodeList().at(5),feSub.getFlag()};
2005 surfacesSubelements.push_back(surfaceTmp);
2010 int numSubEl = surfacesSubelements.size();
2012 int maxRank = std::get<1>(this->rankRange_);
2013 vec_GO_Type globalProcs(0);
2014 for (
int i=0; i<= maxRank; i++)
2015 globalProcs.push_back(i);
2017 Teuchos::ArrayView<GO> globalProcArray = Teuchos::arrayViewFromVector( globalProcs);
2019 vec_GO_Type localProc(0);
2020 localProc.push_back(this->comm_->getRank());
2021 Teuchos::ArrayView<GO> localProcArray = Teuchos::arrayViewFromVector( localProc);
2023 MapPtr_Type mapGlobalProc =
2024 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalProcArray, 0, this->comm_) );
2026 MapPtr_Type mapProc =
2027 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), localProcArray, 0, this->comm_) );
2029 MultiVectorLOPtr_Type exportLocalEntry = Teuchos::rcp(
new MultiVectorLO_Type( mapProc, 1 ) );
2030 exportLocalEntry->putScalar( (LO) numSubEl );
2032 MultiVectorLOPtr_Type numSurfacesProc= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
2033 numSurfacesProc->putScalar( (LO) 0 );
2034 numSurfacesProc->importFromVector( exportLocalEntry,
false,
"Insert");
2036 Teuchos::ArrayRCP< const LO > surfacesRanks = numSurfacesProc->getData(0);
2037 vec_GO_Type vecGlobalIDsElements(0);
2039 GO procOffsetElements=0;
2040 int myRank = this->comm_->getRank();
2041 for(
int i=0; i< myRank; i++)
2042 procOffsetElements = procOffsetElements + surfacesRanks[i];
2044 for (
int i=0; i<numSubEl; i++){
2045 vecGlobalIDsElements.push_back( i + procOffsetElements);
2048 Teuchos::RCP<std::vector<GO> > surfacesGlobMapping = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsElements ) );
2049 Teuchos::ArrayView<GO> surfacesGlobMappingArray = Teuchos::arrayViewFromVector( *surfacesGlobMapping);
2050 MapPtr_Type mapSurfacesExport =
2051 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), surfacesGlobMappingArray, 0, this->
getComm()) );
2054 vec_GO_Type vecGlobalIDsSurfacesImport(0);
2055 int maxIndex = mapSurfacesExport->getMaxAllGlobalIndex();
2056 if(this->comm_->getRank() == 0){
2057 for(
int i=numSubEl; i<maxIndex+1 ; i++)
2058 vecGlobalIDsSurfacesImport.push_back(i);
2060 Teuchos::RCP<std::vector<GO> > surfacesGlobMappingImport = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsSurfacesImport ) );
2061 Teuchos::ArrayView<GO> surfacesGlobMappingImportArray = Teuchos::arrayViewFromVector( *surfacesGlobMappingImport);
2062 MapPtr_Type mapSurfacesImport =
2063 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), surfacesGlobMappingImportArray, 0, this->
getComm()) );
2065 int numberSurfaces = maxIndex+1;
2067 MultiVectorPtr_Type surfacesImp = Teuchos::rcp(
new MultiVector_Type( mapSurfacesImport, 1 ) );
2068 Teuchos::ArrayRCP< SC > entriesSurfacesImp = surfacesImp->getDataNonConst(0);
2070 MultiVectorPtr_Type surfacesExport = Teuchos::rcp(
new MultiVector_Type( mapSurfacesExport , 1 ) );
2071 Teuchos::ArrayRCP< SC > entriesSurfacesExport = surfacesExport->getDataNonConst(0);
2074 vec2D_dbl_Type missingSurfaces(entriesSurfacesImp.size(),vec_dbl_Type(dofsSurfaces+1));
2076 for(
int j= 0; j < dofsSurfaces+1; j++)
2078 for(
int i=0; i< entriesSurfacesExport.size(); i++){
2080 entriesSurfacesExport[i] = mapRep->getGlobalElement(surfacesSubelements[i][j]);
2082 entriesSurfacesExport[i] = surfacesSubelements[i][j];
2085 surfacesImp->importFromVector(surfacesExport,
false,
"Insert");
2086 for(
int i=0; i< entriesSurfacesImp.size(); i++)
2087 missingSurfaces[i][j] = entriesSurfacesImp[i];
2090 if(this->comm_->getRank() == 0){
2092 myFile <<
"Triangles";
2093 myFile << std::endl;
2094 myFile << numberSurfaces;
2095 myFile << std::endl;
2096 for(
int i = 0; i < mapSurfacesExport->getGlobalNumElements(); i++)
2098 if(mapSurfacesExport->getLocalElement(i) != -1){
2100 for(
int j= 0; j < dofsSurfaces; j++)
2102 myFile << mapRep->getGlobalElement(surfacesSubelements[i][j])+1;
2107 myFile << surfacesSubelements[i][dofsSurfaces];
2108 myFile << std::endl;
2113 LO
id = mapSurfacesImport->getLocalElement(i);
2114 for(
int j= 0; j < dofsSurfaces; j++)
2116 myFile << missingSurfaces[id][j]+1;
2119 myFile << missingSurfaces[id][dofsSurfaces];
2120 myFile << std::endl;
2125 myFile << std::endl;
2131 std::cout <<
"... done -----" <<
'\n';
2137 this->comm_->barrier();
2140 std::cout <<
" ----- Write Elements ...";
2144 vec_GO_Type globalImportIDs(0);
2145 for(
int i = 0; i < this->elementMap_->getGlobalNumElements(); i++)
2147 if(this->elementMap_->getLocalElement(i) == -1){
2148 globalImportIDs.push_back(i);
2151 Teuchos::ArrayView<GO> globalElementArrayImp = Teuchos::arrayViewFromVector( globalImportIDs);
2153 MapPtr_Type mapElementImport =
2154 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalElementArrayImp, 0, this->
getComm()) );
2156 MultiVectorPtr_Type idsElement = Teuchos::rcp(
new MultiVector_Type( mapElementImport, 1 ) );
2157 Teuchos::ArrayRCP< SC > entriesElement = idsElement->getDataNonConst(0);
2159 MultiVectorPtr_Type idsElementExport = Teuchos::rcp(
new MultiVector_Type( this->elementMap_, 1 ) );
2160 Teuchos::ArrayRCP< SC > entriesElementExport = idsElementExport->getDataNonConst(0);
2162 int dofsElement = this->
getElements()->at(0).size();
2163 vec2D_GO_Type missingElements(entriesElement.size(),vec_GO_Type(dofsElement+1));
2165 for(
int j= 0; j < this->
getElements()->at(0).size(); j++)
2167 for(
int i=0; i< entriesElementExport.size(); i++)
2168 entriesElementExport[i] = mapRep->getGlobalElement(this->getElements()->at(i).at(j))+1;
2170 idsElement->importFromVector(idsElementExport,
false,
"Insert");
2171 for(
int i=0; i< entriesElement.size(); i++)
2172 missingElements[i][j] = entriesElement[i];
2174 for(
int i=0; i< entriesElementExport.size(); i++)
2175 entriesElementExport[i] = this->
getElementsC()->getElement(i).getFlag();
2177 idsElement->importFromVector(idsElementExport,
false,
"Insert");
2178 for(
int i=0; i< entriesElement.size(); i++)
2179 missingElements[i][dofsElement] = entriesElement[i];
2181 if(this->comm_->getRank() == 0){
2184 myFile <<
"Triangles";
2185 else if(this->dim_ ==3)
2186 myFile <<
"Tetrahedra";
2188 myFile << std::endl;
2190 int numberElements = this->elementMap_->getGlobalNumElements();
2192 myFile << numberElements;
2193 myFile << std::endl;
2195 for(
int i = 0; i < this->elementMap_->getGlobalNumElements(); i++)
2197 if(this->elementMap_->getLocalElement(i) != -1){
2198 LO
id = this->elementMap_->getLocalElement(i);
2200 for(
int j= 0; j < this->
getElements()->at(
id).size(); j++)
2202 myFile << mapRep->getGlobalElement(this->
getElements()->at(
id).at(j))+1;
2205 myFile << this->
getElementsC()->getElement(
id).getFlag();
2206 myFile << std::endl;
2210 LO
id = mapElementImport->getLocalElement(i);
2211 for(
int j= 0; j < dofsElement; j++)
2213 myFile << missingElements[id][j];
2216 myFile << missingElements[id][dofsElement];
2217 myFile << std::endl;
2222 std::cout <<
"... done ----- " <<
'\n';
2225 if(this->comm_->getRank() ==0)
2228 std::cout <<
" --------------------------------------" << std::endl;
2229 std::cout <<
" ------- Finished exporting Mesh ------" << std::endl;
2230 std::cout <<
" ------- File Name: " << meshName <<
" -------" << std::endl;
2232 std::cout <<
" - Info: In 3D all edges are exported -" << std::endl;
2234 std::cout <<
" --------------------------------------" << std::endl;
2237 this->comm_->barrier();