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

Diff of /trunk/finley/src/CPPAdapter/MeshAdapter.cpp

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

revision 2551 by gross, Thu Jul 23 09:19:15 2009 UTC revision 2635 by jfenwick, Thu Aug 27 04:54:41 2009 UTC
# Line 1661  bool MeshAdapter::isCellOriented(int fun Line 1661  bool MeshAdapter::isCellOriented(int fun
1661     return false;     return false;
1662  }  }
1663    
1664    bool
1665    MeshAdapter::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const
1666    {
1667       /* The idea is to use equivalence classes. [Types which can be interpolated back and forth]
1668        class 1: DOF <-> Nodes
1669        class 2: ReducedDOF <-> ReducedNodes
1670        class 3: Points
1671        class 4: Elements
1672        class 5: ReducedElements
1673        class 6: FaceElements
1674        class 7: ReducedFaceElements
1675        class 8: ContactElementZero <-> ContactElementOne
1676        class 9: ReducedContactElementZero <-> ReducedContactElementOne
1677    
1678       There is also a set of lines. Interpolation is possible down a line but not between lines.
1679       class 1 and 2 belong to all lines so aren't considered.
1680        line 0: class 3
1681        line 1: class 4,5
1682        line 2: class 6,7
1683        line 3: class 8,9
1684    
1685       For classes with multiple members (eg class 2) we have vars to record if there is at least one instance.
1686       eg hasnodes is true if we have at least one instance of Nodes.
1687       */
1688        if (fs.size()==0)
1689        {
1690        return false;
1691        }
1692        std::vector<int> hasclass(10);
1693        std::vector<int> hasline(4);    
1694        bool hasnodes=false;
1695        bool hasrednodes=false;
1696        bool hascez=false;
1697        bool hasrcez=false;
1698        for (int i=0;i<fs.size();++i)
1699        {
1700        switch(fs[i])
1701        {
1702        case(Nodes):   hasnodes=true;   // no break is deliberate
1703        case(DegreesOfFreedom):
1704            hasclass[1]=1;
1705            break;
1706        case(ReducedNodes):    hasrednodes=true;    // no break is deliberate
1707        case(ReducedDegreesOfFreedom):
1708            hasclass[2]=1;
1709            break;
1710        case(Points):
1711            hasline[0]=1;
1712            hasclass[3]=1;
1713            break;
1714        case(Elements):
1715            hasclass[4]=1;
1716            hasline[1]=1;
1717            break;
1718        case(ReducedElements):
1719            hasclass[5]=1;
1720            hasline[1]=1;
1721            break;
1722        case(FaceElements):
1723            hasclass[6]=1;
1724            hasline[2]=1;
1725            break;
1726        case(ReducedFaceElements):
1727            hasclass[7]=1;
1728            hasline[2]=1;
1729            break;
1730        case(ContactElementsZero):  hascez=true;    // no break is deliberate
1731        case(ContactElementsOne):
1732            hasclass[8]=1;
1733            hasline[3]=1;
1734            break;
1735        case(ReducedContactElementsZero):   hasrcez=true;   // no break is deliberate
1736        case(ReducedContactElementsOne):
1737            hasclass[9]=1;
1738            hasline[3]=1;
1739            break;
1740        default:
1741            return false;
1742        }
1743        }
1744        int totlines=hasline[0]+hasline[1]+hasline[2]+hasline[3];
1745        // fail if we have more than one leaf group
1746    
1747        if (totlines>1)
1748        {
1749        return false;   // there are at least two branches we can't interpolate between
1750        }
1751        else if (totlines==1)
1752        {
1753        if (hasline[0]==1)      // we have points
1754        {
1755            resultcode=Points;
1756        }
1757        else if (hasline[1]==1)
1758        {
1759            if (hasclass[5]==1)
1760            {
1761            resultcode=ReducedElements;
1762            }
1763            else
1764            {
1765            resultcode=Elements;
1766            }
1767        }
1768        else if (hasline[2]==1)
1769        {
1770            if (hasclass[7]==ReducedFaceElements)
1771            {
1772            resultcode=ReducedFaceElements;
1773            }
1774            else
1775            {
1776            resultcode=FaceElements;
1777            }
1778        }
1779        else    // so we must be in line3
1780        {
1781            if (hasclass[9]==1)
1782            {
1783            // need something from class 9
1784            resultcode=(hasrcez?ReducedContactElementsZero:ReducedContactElementsOne);
1785            }
1786            else
1787            {
1788            // something from class 8
1789            resultcode=(hascez?ContactElementsZero:ContactElementsOne);
1790            }
1791        }
1792        }
1793        else    // totlines==0
1794        {
1795        if (hasclass[2]==1)
1796        {
1797            // something from class 2
1798            resultcode=(hasrednodes?ReducedNodes:ReducedDegreesOfFreedom);
1799        }
1800        else
1801        {   // something from class 1
1802            resultcode=(hasnodes?Nodes:DegreesOfFreedom);
1803        }
1804        }
1805        return true;
1806    }
1807    
1808  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
1809  {  {
1810     switch(functionSpaceType_source) {     switch(functionSpaceType_source) {
1811     case(Nodes):     case(Nodes):
1812     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1813     case(Nodes):      case(Nodes):
1814     case(ReducedNodes):      case(ReducedNodes):
1815     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1816     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1817     case(Elements):      case(Elements):
1818     case(ReducedElements):      case(ReducedElements):
1819     case(FaceElements):      case(FaceElements):
1820     case(ReducedFaceElements):      case(ReducedFaceElements):
1821     case(Points):      case(Points):
1822     case(ContactElementsZero):      case(ContactElementsZero):
1823     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1824     case(ContactElementsOne):      case(ContactElementsOne):
1825     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1826     return true;      return true;
1827     default:      default:
1828        stringstream temp;            stringstream temp;
1829        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;
1830        throw FinleyAdapterException(temp.str());            throw FinleyAdapterException(temp.str());
1831     }     }
1832     break;     break;
1833     case(ReducedNodes):     case(ReducedNodes):
1834     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1835     case(ReducedNodes):      case(ReducedNodes):
1836     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1837     case(Elements):      case(Elements):
1838     case(ReducedElements):      case(ReducedElements):
1839     case(FaceElements):      case(FaceElements):
1840     case(ReducedFaceElements):      case(ReducedFaceElements):
1841     case(Points):      case(Points):
1842     case(ContactElementsZero):      case(ContactElementsZero):
1843     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1844     case(ContactElementsOne):      case(ContactElementsOne):
1845     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1846     return true;      return true;
1847     case(Nodes):      case(Nodes):
1848     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1849     return false;      return false;
1850     default:      default:
1851        stringstream temp;          stringstream temp;
1852        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;
1853        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1854     }     }
1855     break;     break;
1856     case(Elements):     case(Elements):
1857     if (functionSpaceType_target==Elements) {      if (functionSpaceType_target==Elements) {
1858        return true;        return true;
1859     } else if (functionSpaceType_target==ReducedElements) {      } else if (functionSpaceType_target==ReducedElements) {
1860        return true;        return true;
1861     } else {          } else {
1862        return false;            return false;
1863     }          }
1864     case(ReducedElements):     case(ReducedElements):
1865     if (functionSpaceType_target==ReducedElements) {      if (functionSpaceType_target==ReducedElements) {
1866        return true;        return true;
1867     } else {      } else {
1868        return false;            return false;
1869     }      }
1870     case(FaceElements):     case(FaceElements):
1871     if (functionSpaceType_target==FaceElements) {      if (functionSpaceType_target==FaceElements) {
1872        return true;              return true;
1873     } else if (functionSpaceType_target==ReducedFaceElements) {      } else if (functionSpaceType_target==ReducedFaceElements) {
1874        return true;              return true;
1875     } else {      } else {
1876        return false;              return false;
1877     }      }
1878     case(ReducedFaceElements):     case(ReducedFaceElements):
1879     if (functionSpaceType_target==ReducedFaceElements) {      if (functionSpaceType_target==ReducedFaceElements) {
1880        return true;              return true;
1881     } else {      } else {
1882        return false;          return false;
1883     }      }
1884     case(Points):     case(Points):
1885     if (functionSpaceType_target==Points) {      if (functionSpaceType_target==Points) {
1886        return true;              return true;
1887     } else {      } else {
1888        return false;              return false;
1889     }      }
1890     case(ContactElementsZero):     case(ContactElementsZero):
1891     case(ContactElementsOne):     case(ContactElementsOne):
1892     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {      if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1893        return true;              return true;
1894     } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1895        return true;              return true;
1896     } else {      } else {
1897        return false;              return false;
1898     }      }
1899     case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1900     case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1901     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1902        return true;              return true;
1903     } else {      } else {
1904        return false;              return false;
1905     }      }
1906     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1907     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1908     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1909     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1910     case(Nodes):      case(Nodes):
1911     case(ReducedNodes):      case(ReducedNodes):
1912     case(Elements):      case(Elements):
1913     case(ReducedElements):      case(ReducedElements):
1914     case(Points):      case(Points):
1915     case(FaceElements):      case(FaceElements):
1916     case(ReducedFaceElements):      case(ReducedFaceElements):
1917     case(ContactElementsZero):      case(ContactElementsZero):
1918     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1919     case(ContactElementsOne):      case(ContactElementsOne):
1920     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1921     return true;      return true;
1922     default:      default:
1923        stringstream temp;          stringstream temp;
1924        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;
1925        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1926     }      }
1927     break;      break;
1928     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1929     switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1930     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1931     case(ReducedNodes):      case(ReducedNodes):
1932     case(Elements):      case(Elements):
1933     case(ReducedElements):      case(ReducedElements):
1934     case(FaceElements):      case(FaceElements):
1935     case(ReducedFaceElements):      case(ReducedFaceElements):
1936     case(Points):      case(Points):
1937     case(ContactElementsZero):      case(ContactElementsZero):
1938     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1939     case(ContactElementsOne):      case(ContactElementsOne):
1940     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1941     return true;      return true;
1942     case(Nodes):      case(Nodes):
1943     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1944     return false;      return false;
1945     default:      default:
1946        stringstream temp;          stringstream temp;
1947        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;
1948        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1949     }      }
1950     break;      break;
1951     default:     default:
1952        stringstream temp;        stringstream temp;
1953        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.2551  
changed lines
  Added in v.2635

  ViewVC Help
Powered by ViewVC 1.1.26