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_) );
1593 std::ofstream myFile;
1594 if(this->comm_->getRank() ==0)
1595 myFile.open (meshName);
1597 bool verbose = (this->comm_->getRank() == 0);
1599 std::cout <<
" --------------------------------------" << std::endl;
1600 std::cout <<
" ------------ Exporting Mesh ----------" << std::endl;
1601 std::cout <<
" --------------------------------------" << std::endl;
1605 int numberNodes = mapUnique->getGlobalNumElements();
1610 vec_GO_Type globalImportIDsNodes(0);
1611 for(
int i = 0; i < this->mapUnique_->getGlobalNumElements(); i++)
1613 if(this->mapUnique_->getLocalElement(i) == -1){
1614 globalImportIDsNodes.push_back(i);
1617 Teuchos::ArrayView<GO> globalNodesArrayImp = Teuchos::arrayViewFromVector( globalImportIDsNodes);
1619 MapPtr_Type mapNodesImport =
1620 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalNodesArrayImp, 0, this->
getComm()) );
1622 MultiVectorPtr_Type nodesImp = Teuchos::rcp(
new MultiVector_Type( mapNodesImport, 1 ) );
1623 Teuchos::ArrayRCP< SC > entriesNodesImp = nodesImp->getDataNonConst(0);
1625 MultiVectorPtr_Type nodesExport = Teuchos::rcp(
new MultiVector_Type( this->mapUnique_, 1 ) );
1626 Teuchos::ArrayRCP< SC > entriesNodesExport = nodesExport->getDataNonConst(0);
1628 vec2D_dbl_Type missingNodes(entriesNodesImp.size(),vec_dbl_Type(this->dim_+1));
1630 for(
int j= 0; j < this->dim_; j++)
1632 for(
int i=0; i< entriesNodesExport.size(); i++)
1635 nodesImp->importFromVector(nodesExport,
false,
"Insert");
1636 for(
int i=0; i< entriesNodesImp.size(); i++)
1637 missingNodes[i][j] = entriesNodesImp[i];
1643 for(
int i=0; i< entriesNodesExport.size(); i++)
1644 entriesNodesExport[i] = this->bcFlagUni_->at(i);
1646 nodesImp->importFromVector(nodesExport,
false,
"Insert");
1647 for(
int i=0; i< entriesNodesImp.size(); i++)
1648 missingNodes[i][this->dim_] = entriesNodesImp[i];
1652 if(this->comm_->getRank() == 0){
1654 std::cout <<
" ----- Write Nodes .....";
1656 myFile <<
"MeshVersionFormatted 2" << std::endl;
1657 myFile <<
"Dimension" <<
" " << this->dim_ << std::endl;
1658 myFile << std::endl;
1659 myFile <<
"Vertices";
1660 myFile << std::endl;
1661 myFile << numberNodes;
1662 myFile << std::endl;
1663 for(
int i = 0; i < mapUnique->getGlobalNumElements(); i++)
1666 if(mapUnique->getLocalElement(i) != -1){
1667 LO
id = mapUnique->getLocalElement(i);
1673 if(this->dim_ == 2){
1677 myFile << this->bcFlagUni_->at(
id);
1678 myFile << std::endl;
1681 LO
id = mapNodesImport->getLocalElement(i);
1682 for(
int j= 0; j < this->dim_; j++)
1684 myFile << missingNodes[id][j];
1687 if(this->dim_ == 2){
1691 myFile << missingNodes[id][this->dim_];
1692 myFile << std::endl;
1698 myFile << std::endl;
1700 std::cout <<
".... done ----- " <<
'\n';
1707 std::cout <<
" ----- Write Edges .....";
1709 if(this->FEType_ ==
"P2")
1714 vec2D_GO_Type edgesSubelements(0,vec_GO_Type(dofsEdges+1));
1716 for(
int T=0; T< elements->numberElements() ; T++){
1718 ElementsPtr_Type subEl = fe.getSubElements();
1719 for (
int surface=0; surface<fe.numSubElements(); surface++) {
1721 vec_GO_Type edgeTmp;
1722 edgeTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getFlag()};
1723 if(this->FEType_==
"P2")
1724 edgeTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getVectorNodeList().at(2),feSub.getFlag()};
1726 edgesSubelements.push_back(edgeTmp);
1731 int numSubEl = edgesSubelements.size();
1733 int maxRank = std::get<1>(this->rankRange_);
1734 vec_GO_Type globalProcs(0);
1735 for (
int i=0; i<= maxRank; i++)
1736 globalProcs.push_back(i);
1738 Teuchos::ArrayView<GO> globalProcArray = Teuchos::arrayViewFromVector( globalProcs);
1740 vec_GO_Type localProc(0);
1741 localProc.push_back(this->comm_->getRank());
1742 Teuchos::ArrayView<GO> localProcArray = Teuchos::arrayViewFromVector( localProc);
1744 MapPtr_Type mapGlobalProc =
1745 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalProcArray, 0, this->comm_) );
1747 MapPtr_Type mapProc =
1748 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), localProcArray, 0, this->comm_) );
1750 MultiVectorLOPtr_Type exportLocalEntry = Teuchos::rcp(
new MultiVectorLO_Type( mapProc, 1 ) );
1751 exportLocalEntry->putScalar( (LO) numSubEl );
1754 MultiVectorLOPtr_Type numEdgesProc= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
1755 numEdgesProc->putScalar( (LO) 0 );
1756 numEdgesProc->importFromVector( exportLocalEntry,
false,
"Insert");
1759 Teuchos::ArrayRCP< const LO > edgesRanks = numEdgesProc->getData(0);
1760 vec_GO_Type vecGlobalIDsElements(0);
1762 GO procOffsetElements=0;
1763 int myRank = this->comm_->getRank();
1764 for(
int i=0; i< myRank; i++)
1765 procOffsetElements = procOffsetElements + edgesRanks[i];
1767 for (
int i=0; i<numSubEl; i++){
1768 vecGlobalIDsElements.push_back( i + procOffsetElements);
1771 Teuchos::RCP<std::vector<GO> > edgesGlobMapping = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsElements ) );
1772 Teuchos::ArrayView<GO> edgesGlobMappingArray = Teuchos::arrayViewFromVector( *edgesGlobMapping);
1773 MapPtr_Type mapEdgesExport =
1774 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesGlobMappingArray, 0, this->
getComm()) );
1776 vec_GO_Type vecGlobalIDsEdgesImport(0);
1777 int maxIndex = mapEdgesExport->getMaxAllGlobalIndex();
1778 if(this->comm_->getRank() == 0){
1779 for(
int i=numSubEl; i<maxIndex+1 ; i++)
1780 vecGlobalIDsEdgesImport.push_back(i);
1782 Teuchos::RCP<std::vector<GO> > edgesGlobMappingImport = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsEdgesImport ) );
1783 Teuchos::ArrayView<GO> edgesGlobMappingImportArray = Teuchos::arrayViewFromVector( *edgesGlobMappingImport);
1784 MapPtr_Type mapEdgesImport =
1785 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), edgesGlobMappingImportArray, 0, this->
getComm()) );
1787 int numberEdges = maxIndex+1;
1789 MultiVectorPtr_Type edgesImp = Teuchos::rcp(
new MultiVector_Type( mapEdgesImport, 1 ) );
1790 Teuchos::ArrayRCP< SC > entriesEdgesImp = edgesImp->getDataNonConst(0);
1792 MultiVectorPtr_Type edgesExport = Teuchos::rcp(
new MultiVector_Type( mapEdgesExport , 1 ) );
1793 Teuchos::ArrayRCP< SC > entriesEdgesExport = edgesExport->getDataNonConst(0);
1796 vec2D_dbl_Type missingEdges(entriesEdgesImp.size(),vec_dbl_Type(dofsEdges+1));
1798 for(
int j= 0; j < dofsEdges+1; j++)
1800 for(
int i=0; i< entriesEdgesExport.size(); i++){
1802 entriesEdgesExport[i] = mapRep->getGlobalElement(edgesSubelements[i][j]);
1804 entriesEdgesExport[i] = edgesSubelements[i][j];
1808 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1809 for(
int i=0; i< entriesEdgesImp.size(); i++)
1810 missingEdges[i][j] = entriesEdgesImp[i];
1813 if(this->comm_->getRank() == 0){
1816 myFile << std::endl;
1817 myFile << numberEdges;
1818 myFile << std::endl;
1819 for(
int i = 0; i < mapEdgesExport->getGlobalNumElements(); i++)
1821 if(mapEdgesExport->getLocalElement(i) != -1){
1822 LO
id = this->edgeMap_->getLocalElement(i);
1824 for(
int j= 0; j < dofsEdges; j++)
1826 myFile << mapRep->getGlobalElement(edgesSubelements[i][j])+1;
1830 myFile << edgesSubelements[i][dofsEdges];
1831 myFile << std::endl;
1836 LO
id = mapEdgesImport->getLocalElement(i);
1837 for(
int j= 0; j < dofsEdges; j++)
1839 myFile << missingEdges[id][j]+1;
1842 myFile << missingEdges[id][dofsEdges];
1843 myFile << std::endl;
1848 myFile << std::endl;
1852 std::cout <<
".... done ---- " <<
'\n';
1855 else if(this->dim_ == 3){
1857 if(this->FEType_ !=
"P2")
1860 vec_GO_Type globalImportIDsEdges(0);
1862 MapConstPtr_Type edgeMapUnique = this->edgeMap_->buildUniqueMap( this->rankRange_ );
1864 vec2D_int_Type edgesUnique(edgeMapUnique->getNodeNumElements(),vec_int_Type(2,0));
1865 for (
int i=0; i < edgeMapUnique->getNodeNumElements(); i++) {
1866 GO gid = edgeMapUnique->getGlobalElement( i );
1867 LO
id = this->edgeMap_->getLocalElement( gid );
1868 edgesUnique[i] = this->edgeElements_->getElement(
id).getVectorNodeListNonConst();
1871 if(this->comm_->getRank() == 0){
1872 for(
int i = 0; i < edgeMapUnique->getGlobalNumElements(); i++)
1874 if(edgeMapUnique->getLocalElement(i) == -1){
1875 globalImportIDsEdges.push_back(i);
1879 int numberEdges = edgeMapUnique->getGlobalNumElements();
1881 Teuchos::ArrayView<GO> globalEdgesArrayImp = Teuchos::arrayViewFromVector( globalImportIDsEdges);
1883 MapPtr_Type mapEdgesImport =
1884 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalEdgesArrayImp, 0, this->
getComm()) );
1886 MultiVectorPtr_Type edgesImp = Teuchos::rcp(
new MultiVector_Type( mapEdgesImport, 1 ) );
1887 Teuchos::ArrayRCP< SC > entriesEdgesImp = edgesImp->getDataNonConst(0);
1889 MultiVectorPtr_Type edgesExport = Teuchos::rcp(
new MultiVector_Type( edgeMapUnique, 1 ) );
1890 Teuchos::ArrayRCP< SC > entriesEdgesExport = edgesExport->getDataNonConst(0);
1892 vec2D_dbl_Type missingEdges(entriesEdgesImp.size(),vec_dbl_Type(dofsEdges+1));
1894 for(
int j= 0; j < 2; j++)
1896 for(
int i=0; i< entriesEdgesExport.size(); i++)
1897 entriesEdgesExport[i] = mapRep->getGlobalElement(edgesUnique[i][j])+1;
1899 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1900 for(
int i=0; i< entriesEdgesImp.size(); i++)
1901 missingEdges[i][j] = entriesEdgesImp[i];
1904 if(this->FEType_ ==
"P2"){
1905 for(
int i=0; i< entriesEdgesExport.size(); i++){
1906 GO gid = edgeMapUnique->getGlobalElement( i );
1907 LO
id = this->edgeMap_->getLocalElement( gid );
1908 entriesEdgesExport[i] = mapRep->getGlobalElement(this->edgeElements_->getMidpoint(
id))+1;
1911 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1912 for(
int i=0; i< entriesEdgesImp.size(); i++)
1913 missingEdges[i][2] = entriesEdgesImp[i];
1917 for(
int i=0; i< entriesEdgesExport.size(); i++){
1918 GO gid = edgeMapUnique->getGlobalElement( i );
1919 LO
id = this->edgeMap_->getLocalElement( gid);
1920 entriesEdgesExport[i] = this->edgeElements_->getElement(
id).getFlag();
1923 edgesImp->importFromVector(edgesExport,
false,
"Insert");
1924 for(
int i=0; i< entriesEdgesImp.size(); i++)
1925 missingEdges[i][dofsEdges] = entriesEdgesImp[i];
1928 if(this->comm_->getRank() == 0){
1931 vec2D_int_Type edges(0,vec_int_Type(0));
1932 for(
int i = 0; i < edgeMapUnique->getGlobalNumElements(); i++)
1934 vec_int_Type entry(0);
1935 if(edgeMapUnique->getLocalElement(i) != -1){
1936 LO
id = this->edgeMap_->getLocalElement(i);
1937 if(this->edgeElements_->getElement(
id).getFlag() < this->volumeID_)
1939 for(
int j= 0; j < 2; j++)
1941 entry.push_back(mapRep->getGlobalElement(this->edgeElements_->getElement(
id).getVectorNodeList().at(j))+1);
1943 if(this->FEType_ ==
"P2")
1944 entry.push_back(mapRep->getGlobalElement(this->edgeElements_->getMidpoint(
id))+1);
1946 entry.push_back(this->edgeElements_->getElement(
id).getFlag());
1948 edges.push_back(entry);
1954 LO
id = mapEdgesImport->getLocalElement(i);
1955 if(missingEdges[
id][dofsEdges]< this->volumeID_){
1957 for(
int j= 0; j < dofsEdges; j++)
1959 entry.push_back(missingEdges[
id][j]);
1961 entry.push_back(missingEdges[
id][dofsEdges]);
1963 edges.push_back(entry);
1971 myFile << std::endl;
1972 myFile << edges.size();
1973 myFile << std::endl;
1975 for(
int i = 0; i < edges.size(); i++)
1978 for(
int j= 0; j < 2; j++)
1980 myFile << edges[i][j];
1983 if(this->FEType_ ==
"P2")
1984 myFile << edges[i][2];
1986 myFile << edges[i][edges[i].size()-1];
1987 myFile << std::endl;
1992 myFile << std::endl;
1994 std::cout <<
".... done ----- " <<
'\n';
1999 this->comm_->barrier();
2001 if(exportSurface && this->dim_ >2){
2003 std::cout <<
" ----- Write Surfaces ...";
2005 if(this->FEType_ ==
"P2")
2010 vec2D_GO_Type surfacesSubelements(0,vec_GO_Type(dofsSurfaces+1));
2012 for(
int T=0; T< elements->numberElements() ; T++){
2014 for (
int surface=0; surface<fe.numSubElements(); surface++) {
2015 ElementsPtr_Type subEl = fe.getSubElements();
2016 if(subEl->getDimension() == this->dim_-1 ){
2018 vec_GO_Type surfaceTmp;
2019 surfaceTmp = {feSub.getVectorNodeList().at(0),feSub.getVectorNodeList().at(1),feSub.getVectorNodeList().at(2),feSub.getFlag()};
2020 if(this->FEType_==
"P2")
2021 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()};
2023 surfacesSubelements.push_back(surfaceTmp);
2028 int numSubEl = surfacesSubelements.size();
2030 int maxRank = std::get<1>(this->rankRange_);
2031 vec_GO_Type globalProcs(0);
2032 for (
int i=0; i<= maxRank; i++)
2033 globalProcs.push_back(i);
2035 Teuchos::ArrayView<GO> globalProcArray = Teuchos::arrayViewFromVector( globalProcs);
2037 vec_GO_Type localProc(0);
2038 localProc.push_back(this->comm_->getRank());
2039 Teuchos::ArrayView<GO> localProcArray = Teuchos::arrayViewFromVector( localProc);
2041 MapPtr_Type mapGlobalProc =
2042 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalProcArray, 0, this->comm_) );
2044 MapPtr_Type mapProc =
2045 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), localProcArray, 0, this->comm_) );
2047 MultiVectorLOPtr_Type exportLocalEntry = Teuchos::rcp(
new MultiVectorLO_Type( mapProc, 1 ) );
2048 exportLocalEntry->putScalar( (LO) numSubEl );
2050 MultiVectorLOPtr_Type numSurfacesProc= Teuchos::rcp(
new MultiVectorLO_Type( mapGlobalProc, 1 ) );
2051 numSurfacesProc->putScalar( (LO) 0 );
2052 numSurfacesProc->importFromVector( exportLocalEntry,
false,
"Insert");
2054 Teuchos::ArrayRCP< const LO > surfacesRanks = numSurfacesProc->getData(0);
2055 vec_GO_Type vecGlobalIDsElements(0);
2057 GO procOffsetElements=0;
2058 int myRank = this->comm_->getRank();
2059 for(
int i=0; i< myRank; i++)
2060 procOffsetElements = procOffsetElements + surfacesRanks[i];
2062 for (
int i=0; i<numSubEl; i++){
2063 vecGlobalIDsElements.push_back( i + procOffsetElements);
2066 Teuchos::RCP<std::vector<GO> > surfacesGlobMapping = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsElements ) );
2067 Teuchos::ArrayView<GO> surfacesGlobMappingArray = Teuchos::arrayViewFromVector( *surfacesGlobMapping);
2068 MapPtr_Type mapSurfacesExport =
2069 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), surfacesGlobMappingArray, 0, this->
getComm()) );
2072 vec_GO_Type vecGlobalIDsSurfacesImport(0);
2073 int maxIndex = mapSurfacesExport->getMaxAllGlobalIndex();
2074 if(this->comm_->getRank() == 0){
2075 for(
int i=numSubEl; i<maxIndex+1 ; i++)
2076 vecGlobalIDsSurfacesImport.push_back(i);
2078 Teuchos::RCP<std::vector<GO> > surfacesGlobMappingImport = Teuchos::rcp(
new std::vector<GO>( vecGlobalIDsSurfacesImport ) );
2079 Teuchos::ArrayView<GO> surfacesGlobMappingImportArray = Teuchos::arrayViewFromVector( *surfacesGlobMappingImport);
2080 MapPtr_Type mapSurfacesImport =
2081 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), surfacesGlobMappingImportArray, 0, this->
getComm()) );
2083 int numberSurfaces = maxIndex+1;
2085 MultiVectorPtr_Type surfacesImp = Teuchos::rcp(
new MultiVector_Type( mapSurfacesImport, 1 ) );
2086 Teuchos::ArrayRCP< SC > entriesSurfacesImp = surfacesImp->getDataNonConst(0);
2088 MultiVectorPtr_Type surfacesExport = Teuchos::rcp(
new MultiVector_Type( mapSurfacesExport , 1 ) );
2089 Teuchos::ArrayRCP< SC > entriesSurfacesExport = surfacesExport->getDataNonConst(0);
2092 vec2D_dbl_Type missingSurfaces(entriesSurfacesImp.size(),vec_dbl_Type(dofsSurfaces+1));
2094 for(
int j= 0; j < dofsSurfaces+1; j++)
2096 for(
int i=0; i< entriesSurfacesExport.size(); i++){
2098 entriesSurfacesExport[i] = mapRep->getGlobalElement(surfacesSubelements[i][j]);
2100 entriesSurfacesExport[i] = surfacesSubelements[i][j];
2103 surfacesImp->importFromVector(surfacesExport,
false,
"Insert");
2104 for(
int i=0; i< entriesSurfacesImp.size(); i++)
2105 missingSurfaces[i][j] = entriesSurfacesImp[i];
2108 if(this->comm_->getRank() == 0){
2110 myFile <<
"Triangles";
2111 myFile << std::endl;
2112 myFile << numberSurfaces;
2113 myFile << std::endl;
2114 for(
int i = 0; i < mapSurfacesExport->getGlobalNumElements(); i++)
2116 if(mapSurfacesExport->getLocalElement(i) != -1){
2118 for(
int j= 0; j < dofsSurfaces; j++)
2120 myFile << mapRep->getGlobalElement(surfacesSubelements[i][j])+1;
2125 myFile << surfacesSubelements[i][dofsSurfaces];
2126 myFile << std::endl;
2131 LO
id = mapSurfacesImport->getLocalElement(i);
2132 for(
int j= 0; j < dofsSurfaces; j++)
2134 myFile << missingSurfaces[id][j]+1;
2137 myFile << missingSurfaces[id][dofsSurfaces];
2138 myFile << std::endl;
2143 myFile << std::endl;
2149 std::cout <<
"... done -----" <<
'\n';
2155 this->comm_->barrier();
2158 std::cout <<
" ----- Write Elements ...";
2162 vec_GO_Type globalImportIDs(0);
2163 for(
int i = 0; i < this->elementMap_->getGlobalNumElements(); i++)
2165 if(this->elementMap_->getLocalElement(i) == -1){
2166 globalImportIDs.push_back(i);
2169 Teuchos::ArrayView<GO> globalElementArrayImp = Teuchos::arrayViewFromVector( globalImportIDs);
2171 MapPtr_Type mapElementImport =
2172 Teuchos::rcp(
new Map_Type( Teuchos::OrdinalTraits<GO>::invalid(), globalElementArrayImp, 0, this->
getComm()) );
2174 MultiVectorPtr_Type idsElement = Teuchos::rcp(
new MultiVector_Type( mapElementImport, 1 ) );
2175 Teuchos::ArrayRCP< SC > entriesElement = idsElement->getDataNonConst(0);
2177 MultiVectorPtr_Type idsElementExport = Teuchos::rcp(
new MultiVector_Type( this->elementMap_, 1 ) );
2178 Teuchos::ArrayRCP< SC > entriesElementExport = idsElementExport->getDataNonConst(0);
2180 int dofsElement = this->
getElements()->at(0).size();
2181 vec2D_GO_Type missingElements(entriesElement.size(),vec_GO_Type(dofsElement+1));
2183 for(
int j= 0; j < this->
getElements()->at(0).size(); j++)
2185 for(
int i=0; i< entriesElementExport.size(); i++)
2186 entriesElementExport[i] = mapRep->getGlobalElement(this->getElements()->at(i).at(j))+1;
2188 idsElement->importFromVector(idsElementExport,
false,
"Insert");
2189 for(
int i=0; i< entriesElement.size(); i++)
2190 missingElements[i][j] = entriesElement[i];
2192 for(
int i=0; i< entriesElementExport.size(); i++)
2193 entriesElementExport[i] = this->
getElementsC()->getElement(i).getFlag();
2195 idsElement->importFromVector(idsElementExport,
false,
"Insert");
2196 for(
int i=0; i< entriesElement.size(); i++)
2197 missingElements[i][dofsElement] = entriesElement[i];
2199 if(this->comm_->getRank() == 0){
2202 myFile <<
"Triangles";
2203 else if(this->dim_ ==3)
2204 myFile <<
"Tetrahedra";
2206 myFile << std::endl;
2208 int numberElements = this->elementMap_->getGlobalNumElements();
2210 myFile << numberElements;
2211 myFile << std::endl;
2213 for(
int i = 0; i < this->elementMap_->getGlobalNumElements(); i++)
2215 if(this->elementMap_->getLocalElement(i) != -1){
2216 LO
id = this->elementMap_->getLocalElement(i);
2218 for(
int j= 0; j < this->
getElements()->at(
id).size(); j++)
2220 myFile << mapRep->getGlobalElement(this->
getElements()->at(
id).at(j))+1;
2223 myFile << this->
getElementsC()->getElement(
id).getFlag();
2224 myFile << std::endl;
2228 LO
id = mapElementImport->getLocalElement(i);
2229 for(
int j= 0; j < dofsElement; j++)
2231 myFile << missingElements[id][j];
2234 myFile << missingElements[id][dofsElement];
2235 myFile << std::endl;
2240 std::cout <<
"... done ----- " <<
'\n';
2243 if(this->comm_->getRank() ==0)
2246 std::cout <<
" --------------------------------------" << std::endl;
2247 std::cout <<
" ------- Finished exporting Mesh ------" << std::endl;
2248 std::cout <<
" ------- File Name: " << meshName <<
" -------" << std::endl;
2250 std::cout <<
" - Info: In 3D all edges are exported -" << std::endl;
2252 std::cout <<
" --------------------------------------" << std::endl;
2255 this->comm_->barrier();