/[escript]/branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2548 by jfenwick, Mon Jul 20 06:20:06 2009 UTC revision 2642 by jfenwick, Tue Sep 1 04:15:50 2009 UTC
# Line 96  bool MeshAdapter::onMasterProcessor() co Line 96  bool MeshAdapter::onMasterProcessor() co
96  }  }
97    
98    
99    #ifdef PASO_MPI
100      MPI_Comm
101    #else
102      unsigned int
103    #endif
104    MeshAdapter::getMPIComm() const
105    {
106    #ifdef PASO_MPI
107        return m_finleyMesh->MPIInfo->comm;
108    #else
109        return 0;
110    #endif
111    }
112    
113    
114  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
115     return m_finleyMesh.get();     return m_finleyMesh.get();
116  }  }
# Line 1539  void MeshAdapter::saveVTK(const std::str Line 1554  void MeshAdapter::saveVTK(const std::str
1554     TMPMEMFREE(names);     TMPMEMFREE(names);
1555  }  }
1556    
1557    bool MeshAdapter::ownSample(int fs_code, index_t id) const
1558    {
1559        index_t myFirstNode=0, myLastNode=0, k=0;
1560        index_t* globalNodeIndex=0;
1561        Finley_Mesh* mesh_p=m_finleyMesh.get();
1562        if (fs_code == FINLEY_REDUCED_NODES)
1563        {
1564        myFirstNode = Finley_NodeFile_getFirstReducedNode(mesh_p->Nodes);
1565        myLastNode = Finley_NodeFile_getLastReducedNode(mesh_p->Nodes);
1566        globalNodeIndex = Finley_NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);
1567        }
1568        else
1569        {
1570        myFirstNode = Finley_NodeFile_getFirstNode(mesh_p->Nodes);
1571        myLastNode = Finley_NodeFile_getLastNode(mesh_p->Nodes);
1572        globalNodeIndex = Finley_NodeFile_borrowGlobalNodesIndex(mesh_p->Nodes);
1573        }
1574        k=globalNodeIndex[id];
1575        return static_cast<bool>( (myFirstNode <= k) && (k < myLastNode) );
1576    }
1577    
1578    
1579    
1580  //  //
1581  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros
1582  //  //
# Line 1585  SystemMatrixAdapter MeshAdapter::newSyst Line 1623  SystemMatrixAdapter MeshAdapter::newSyst
1623  #endif  #endif
1624     }     }
1625     else {     else {
1626        fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);        fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize,FALSE);
1627     }     }
1628     checkPasoError();     checkPasoError();
1629     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
# Line 1661  bool MeshAdapter::isCellOriented(int fun Line 1699  bool MeshAdapter::isCellOriented(int fun
1699     return false;     return false;
1700  }  }
1701    
1702    bool
1703    MeshAdapter::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const
1704    {
1705       /* The idea is to use equivalence classes. [Types which can be interpolated back and forth]
1706        class 1: DOF <-> Nodes
1707        class 2: ReducedDOF <-> ReducedNodes
1708        class 3: Points
1709        class 4: Elements
1710        class 5: ReducedElements
1711        class 6: FaceElements
1712        class 7: ReducedFaceElements
1713        class 8: ContactElementZero <-> ContactElementOne
1714        class 9: ReducedContactElementZero <-> ReducedContactElementOne
1715    
1716       There is also a set of lines. Interpolation is possible down a line but not between lines.
1717       class 1 and 2 belong to all lines so aren't considered.
1718        line 0: class 3
1719        line 1: class 4,5
1720        line 2: class 6,7
1721        line 3: class 8,9
1722    
1723       For classes with multiple members (eg class 2) we have vars to record if there is at least one instance.
1724       eg hasnodes is true if we have at least one instance of Nodes.
1725       */
1726        if (fs.size()==0)
1727        {
1728        return false;
1729        }
1730        std::vector<int> hasclass(10);
1731        std::vector<int> hasline(4);    
1732        bool hasnodes=false;
1733        bool hasrednodes=false;
1734        bool hascez=false;
1735        bool hasrcez=false;
1736        for (int i=0;i<fs.size();++i)
1737        {
1738        switch(fs[i])
1739        {
1740        case(Nodes):   hasnodes=true;   // no break is deliberate
1741        case(DegreesOfFreedom):
1742            hasclass[1]=1;
1743            break;
1744        case(ReducedNodes):    hasrednodes=true;    // no break is deliberate
1745        case(ReducedDegreesOfFreedom):
1746            hasclass[2]=1;
1747            break;
1748        case(Points):
1749            hasline[0]=1;
1750            hasclass[3]=1;
1751            break;
1752        case(Elements):
1753            hasclass[4]=1;
1754            hasline[1]=1;
1755            break;
1756        case(ReducedElements):
1757            hasclass[5]=1;
1758            hasline[1]=1;
1759            break;
1760        case(FaceElements):
1761            hasclass[6]=1;
1762            hasline[2]=1;
1763            break;
1764        case(ReducedFaceElements):
1765            hasclass[7]=1;
1766            hasline[2]=1;
1767            break;
1768        case(ContactElementsZero):  hascez=true;    // no break is deliberate
1769        case(ContactElementsOne):
1770            hasclass[8]=1;
1771            hasline[3]=1;
1772            break;
1773        case(ReducedContactElementsZero):   hasrcez=true;   // no break is deliberate
1774        case(ReducedContactElementsOne):
1775            hasclass[9]=1;
1776            hasline[3]=1;
1777            break;
1778        default:
1779            return false;
1780        }
1781        }
1782        int totlines=hasline[0]+hasline[1]+hasline[2]+hasline[3];
1783        // fail if we have more than one leaf group
1784    
1785        if (totlines>1)
1786        {
1787        return false;   // there are at least two branches we can't interpolate between
1788        }
1789        else if (totlines==1)
1790        {
1791        if (hasline[0]==1)      // we have points
1792        {
1793            resultcode=Points;
1794        }
1795        else if (hasline[1]==1)
1796        {
1797            if (hasclass[5]==1)
1798            {
1799            resultcode=ReducedElements;
1800            }
1801            else
1802            {
1803            resultcode=Elements;
1804            }
1805        }
1806        else if (hasline[2]==1)
1807        {
1808            if (hasclass[7]==ReducedFaceElements)
1809            {
1810            resultcode=ReducedFaceElements;
1811            }
1812            else
1813            {
1814            resultcode=FaceElements;
1815            }
1816        }
1817        else    // so we must be in line3
1818        {
1819            if (hasclass[9]==1)
1820            {
1821            // need something from class 9
1822            resultcode=(hasrcez?ReducedContactElementsZero:ReducedContactElementsOne);
1823            }
1824            else
1825            {
1826            // something from class 8
1827            resultcode=(hascez?ContactElementsZero:ContactElementsOne);
1828            }
1829        }
1830        }
1831        else    // totlines==0
1832        {
1833        if (hasclass[2]==1)
1834        {
1835            // something from class 2
1836            resultcode=(hasrednodes?ReducedNodes:ReducedDegreesOfFreedom);
1837        }
1838        else
1839        {   // something from class 1
1840            resultcode=(hasnodes?Nodes:DegreesOfFreedom);
1841        }
1842        }
1843        return true;
1844    }
1845    
1846  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
1847  {  {
1848     switch(functionSpaceType_source) {     switch(functionSpaceType_source) {
1849     case(Nodes):     case(Nodes):
1850     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1851     case(Nodes):      case(Nodes):
1852     case(ReducedNodes):      case(ReducedNodes):
1853     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1854     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1855     case(Elements):      case(Elements):
1856     case(ReducedElements):      case(ReducedElements):
1857     case(FaceElements):      case(FaceElements):
1858     case(ReducedFaceElements):      case(ReducedFaceElements):
1859     case(Points):      case(Points):
1860     case(ContactElementsZero):      case(ContactElementsZero):
1861     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1862     case(ContactElementsOne):      case(ContactElementsOne):
1863     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1864     return true;      return true;
1865     default:      default:
1866        stringstream temp;            stringstream temp;
1867        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;            temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1868        throw FinleyAdapterException(temp.str());            throw FinleyAdapterException(temp.str());
1869     }     }
1870     break;     break;
1871     case(ReducedNodes):     case(ReducedNodes):
1872     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1873     case(ReducedNodes):      case(ReducedNodes):
1874     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1875     case(Elements):      case(Elements):
1876     case(ReducedElements):      case(ReducedElements):
1877     case(FaceElements):      case(FaceElements):
1878     case(ReducedFaceElements):      case(ReducedFaceElements):
1879     case(Points):      case(Points):
1880     case(ContactElementsZero):      case(ContactElementsZero):
1881     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1882     case(ContactElementsOne):      case(ContactElementsOne):
1883     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1884     return true;      return true;
1885     case(Nodes):      case(Nodes):
1886     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1887     return false;      return false;
1888     default:      default:
1889        stringstream temp;          stringstream temp;
1890        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1891        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1892     }     }
1893     break;     break;
1894     case(Elements):     case(Elements):
1895     if (functionSpaceType_target==Elements) {      if (functionSpaceType_target==Elements) {
1896        return true;        return true;
1897     } else if (functionSpaceType_target==ReducedElements) {      } else if (functionSpaceType_target==ReducedElements) {
1898        return true;        return true;
1899     } else {          } else {
1900        return false;            return false;
1901     }          }
1902     case(ReducedElements):     case(ReducedElements):
1903     if (functionSpaceType_target==ReducedElements) {      if (functionSpaceType_target==ReducedElements) {
1904        return true;        return true;
1905     } else {      } else {
1906        return false;            return false;
1907     }      }
1908     case(FaceElements):     case(FaceElements):
1909     if (functionSpaceType_target==FaceElements) {      if (functionSpaceType_target==FaceElements) {
1910        return true;              return true;
1911     } else if (functionSpaceType_target==ReducedFaceElements) {      } else if (functionSpaceType_target==ReducedFaceElements) {
1912        return true;              return true;
1913     } else {      } else {
1914        return false;              return false;
1915     }      }
1916     case(ReducedFaceElements):     case(ReducedFaceElements):
1917     if (functionSpaceType_target==ReducedFaceElements) {      if (functionSpaceType_target==ReducedFaceElements) {
1918        return true;              return true;
1919     } else {      } else {
1920        return false;          return false;
1921     }      }
1922     case(Points):     case(Points):
1923     if (functionSpaceType_target==Points) {      if (functionSpaceType_target==Points) {
1924        return true;              return true;
1925     } else {      } else {
1926        return false;              return false;
1927     }      }
1928     case(ContactElementsZero):     case(ContactElementsZero):
1929     case(ContactElementsOne):     case(ContactElementsOne):
1930     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {      if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1931        return true;              return true;
1932     } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1933        return true;              return true;
1934     } else {      } else {
1935        return false;              return false;
1936     }      }
1937     case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1938     case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1939     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1940        return true;              return true;
1941     } else {      } else {
1942        return false;              return false;
1943     }      }
1944     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1945     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1946     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1947     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1948     case(Nodes):      case(Nodes):
1949     case(ReducedNodes):      case(ReducedNodes):
1950     case(Elements):      case(Elements):
1951     case(ReducedElements):      case(ReducedElements):
1952     case(Points):      case(Points):
1953     case(FaceElements):      case(FaceElements):
1954     case(ReducedFaceElements):      case(ReducedFaceElements):
1955     case(ContactElementsZero):      case(ContactElementsZero):
1956     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1957     case(ContactElementsOne):      case(ContactElementsOne):
1958     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1959     return true;      return true;
1960     default:      default:
1961        stringstream temp;          stringstream temp;
1962        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1963        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1964     }      }
1965     break;      break;
1966     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1967     switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1968     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1969     case(ReducedNodes):      case(ReducedNodes):
1970     case(Elements):      case(Elements):
1971     case(ReducedElements):      case(ReducedElements):
1972     case(FaceElements):      case(FaceElements):
1973     case(ReducedFaceElements):      case(ReducedFaceElements):
1974     case(Points):      case(Points):
1975     case(ContactElementsZero):      case(ContactElementsZero):
1976     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1977     case(ContactElementsOne):      case(ContactElementsOne):
1978     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1979     return true;      return true;
1980     case(Nodes):      case(Nodes):
1981     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1982     return false;      return false;
1983     default:      default:
1984        stringstream temp;          stringstream temp;
1985        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1986        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1987     }      }
1988     break;      break;
1989     default:     default:
1990        stringstream temp;        stringstream temp;
1991        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;

Legend:
Removed from v.2548  
changed lines
  Added in v.2642

  ViewVC Help
Powered by ViewVC 1.1.26