/[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 4410 by caltinay, Tue May 14 11:29:23 2013 UTC revision 4428 by caltinay, Thu May 30 06:39:10 2013 UTC
# Line 649  int MeshAdapter::getDim() const Line 649  int MeshAdapter::getDim() const
649  //  //
650  int MeshAdapter::getNumDataPointsGlobal() const  int MeshAdapter::getNumDataPointsGlobal() const
651  {  {
652      return Finley_NodeFile_getGlobalNumNodes(m_finleyMesh.get()->Nodes);      return m_finleyMesh.get()->Nodes->getGlobalNumNodes();
653  }  }
654    
655  //  //
# Line 664  pair<int,int> MeshAdapter::getDataShape( Line 664  pair<int,int> MeshAdapter::getDataShape(
664      switch (functionSpaceCode) {      switch (functionSpaceCode) {
665          case Nodes:          case Nodes:
666              numDataPointsPerSample=1;              numDataPointsPerSample=1;
667              numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);              numSamples=mesh->Nodes->getNumNodes();
668              break;              break;
669          case ReducedNodes:          case ReducedNodes:
670              numDataPointsPerSample=1;              numDataPointsPerSample=1;
671              numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);              numSamples=mesh->Nodes->getNumReducedNodes();
672              break;              break;
673          case Elements:          case Elements:
674              if (mesh->Elements!=NULL) {              if (mesh->Elements!=NULL) {
# Line 727  pair<int,int> MeshAdapter::getDataShape( Line 727  pair<int,int> MeshAdapter::getDataShape(
727          case DegreesOfFreedom:          case DegreesOfFreedom:
728              if (mesh->Nodes!=NULL) {              if (mesh->Nodes!=NULL) {
729                  numDataPointsPerSample=1;                  numDataPointsPerSample=1;
730                  numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);                  numSamples=mesh->Nodes->getNumDegreesOfFreedom();
731              }              }
732              break;              break;
733          case ReducedDegreesOfFreedom:          case ReducedDegreesOfFreedom:
734              if (mesh->Nodes!=NULL) {              if (mesh->Nodes!=NULL) {
735                  numDataPointsPerSample=1;                  numDataPointsPerSample=1;
736                  numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);                  numSamples=mesh->Nodes->getNumReducedDegreesOfFreedom();
737              }              }
738              break;              break;
739          default:          default:
# Line 1445  void MeshAdapter::setToSize(escript::Dat Line 1445  void MeshAdapter::setToSize(escript::Dat
1445  void MeshAdapter::setNewX(const escript::Data& new_x)  void MeshAdapter::setNewX(const escript::Data& new_x)
1446  {  {
1447      Finley_Mesh* mesh=m_finleyMesh.get();      Finley_Mesh* mesh=m_finleyMesh.get();
     escriptDataC tmp;  
1448      const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));      const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1449      if (newDomain!=*this)      if (newDomain!=*this)
1450          throw FinleyAdapterException("Error - Illegal domain of new point locations");          throw FinleyAdapterException("Error - Illegal domain of new point locations");
1451      if (new_x.getFunctionSpace() == continuousFunction(*this)) {      if (new_x.getFunctionSpace() == continuousFunction(*this)) {
1452          tmp = new_x.getDataC();          Finley_Mesh_setCoordinates(mesh, new_x);
         Finley_Mesh_setCoordinates(mesh,&tmp);  
1453      } else {      } else {
1454          throw FinleyAdapterException("As of escript version 3.3 SetX() only accepts ContinuousFunction arguments. Please interpolate.");          throw FinleyAdapterException("As of escript version 3.3 SetX() only accepts ContinuousFunction arguments. Please interpolate.");
1455          //escript::Data new_x_inter=escript::Data( new_x,  continuousFunction(*this) );          //escript::Data new_x_inter=escript::Data(new_x, continuousFunction(*this));
1456          //tmp = new_x_inter.getDataC();          //Finley_Mesh_setCoordinates(mesh, new_x_inter);
         //Finley_Mesh_setCoordinates(mesh,&tmp);  
1457      }      }
1458      checkFinleyError();      checkFinleyError();
1459  }  }
# Line 1478  bool MeshAdapter::ownSample(int fs_code, Line 1475  bool MeshAdapter::ownSample(int fs_code,
1475          } else          } else
1476          */          */
1477          if (fs_code == FINLEY_NODES) {          if (fs_code == FINLEY_NODES) {
1478              myFirstNode = Finley_NodeFile_getFirstNode(mesh_p->Nodes);              myFirstNode = mesh_p->Nodes->getFirstNode();
1479              myLastNode = Finley_NodeFile_getLastNode(mesh_p->Nodes);              myLastNode = mesh_p->Nodes->getLastNode();
1480              globalNodeIndex = Finley_NodeFile_borrowGlobalNodesIndex(mesh_p->Nodes);              globalNodeIndex = mesh_p->Nodes->borrowGlobalNodesIndex();
1481          } else {          } else {
1482              throw FinleyAdapterException("Unsupported function space type for ownSample()");              throw FinleyAdapterException("Unsupported function space type for ownSample()");
1483          }          }
# Line 2035  void MeshAdapter::setTags(const int func Line 2032  void MeshAdapter::setTags(const int func
2032      escriptDataC tmp=mask.getDataC();      escriptDataC tmp=mask.getDataC();
2033      switch(functionSpaceType) {      switch(functionSpaceType) {
2034          case Nodes:          case Nodes:
2035              Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);              mesh->Nodes->setTags(newTag, mask);
2036              break;              break;
2037          case ReducedNodes:          case ReducedNodes:
2038              throw FinleyAdapterException("Error - ReducedNodes does not support tags");              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
# Line 2108  string MeshAdapter::showTagNames() const Line 2105  string MeshAdapter::showTagNames() const
2105  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const
2106  {  {
2107      Finley_Mesh* mesh=m_finleyMesh.get();      Finley_Mesh* mesh=m_finleyMesh.get();
     dim_t numTags=0;  
2108      switch(functionSpaceCode) {      switch(functionSpaceCode) {
2109          case Nodes:          case Nodes:
2110              numTags=mesh->Nodes->numTagsInUse;              return mesh->Nodes->tagsInUse.size();
             break;  
2111          case ReducedNodes:          case ReducedNodes:
2112              throw FinleyAdapterException("Error - ReducedNodes does not support tags");              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
             break;  
2113          case DegreesOfFreedom:          case DegreesOfFreedom:
2114              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
             break;  
2115          case ReducedDegreesOfFreedom:          case ReducedDegreesOfFreedom:
2116              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
             break;  
2117          case Elements:          case Elements:
2118          case ReducedElements:          case ReducedElements:
2119              numTags=mesh->Elements->numTagsInUse;              return mesh->Elements->tagsInUse.size();
             break;  
2120          case FaceElements:          case FaceElements:
2121          case ReducedFaceElements:          case ReducedFaceElements:
2122              numTags=mesh->FaceElements->numTagsInUse;              return mesh->FaceElements->tagsInUse.size();
             break;  
2123          case Points:          case Points:
2124              numTags=mesh->Points->numTagsInUse;              return mesh->Points->tagsInUse.size();
             break;  
2125          case ContactElementsZero:          case ContactElementsZero:
2126          case ReducedContactElementsZero:          case ReducedContactElementsZero:
2127          case ContactElementsOne:          case ContactElementsOne:
2128          case ReducedContactElementsOne:          case ReducedContactElementsOne:
2129              numTags=mesh->ContactElements->numTagsInUse;              return mesh->ContactElements->tagsInUse.size();
             break;  
2130          default:          default:
2131              stringstream temp;              stringstream ss;
2132              temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;              ss << "Finley does not know anything about function space type "
2133              throw FinleyAdapterException(temp.str());                   << functionSpaceCode;
2134                throw FinleyAdapterException(ss.str());
2135      }      }
2136      return numTags;      return 0;
2137  }  }
2138    
2139  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const
2140  {  {
2141      Finley_Mesh* mesh=m_finleyMesh.get();      Finley_Mesh* mesh=m_finleyMesh.get();
     index_t* tags=NULL;  
2142      switch(functionSpaceCode) {      switch(functionSpaceCode) {
2143          case Nodes:          case Nodes:
2144              tags=mesh->Nodes->tagsInUse;              return &mesh->Nodes->tagsInUse[0];
             break;  
2145          case ReducedNodes:          case ReducedNodes:
2146              throw FinleyAdapterException("Error - ReducedNodes does not support tags");              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
             break;  
2147          case DegreesOfFreedom:          case DegreesOfFreedom:
2148              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
             break;  
2149          case ReducedDegreesOfFreedom:          case ReducedDegreesOfFreedom:
2150              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
             break;  
2151          case Elements:          case Elements:
2152          case ReducedElements:          case ReducedElements:
2153              tags=mesh->Elements->tagsInUse;              return &mesh->Elements->tagsInUse[0];
             break;  
2154          case FaceElements:          case FaceElements:
2155          case ReducedFaceElements:          case ReducedFaceElements:
2156              tags=mesh->FaceElements->tagsInUse;              return &mesh->FaceElements->tagsInUse[0];
             break;  
2157          case Points:          case Points:
2158              tags=mesh->Points->tagsInUse;              return &mesh->Points->tagsInUse[0];
             break;  
2159          case ContactElementsZero:          case ContactElementsZero:
2160          case ReducedContactElementsZero:          case ReducedContactElementsZero:
2161          case ContactElementsOne:          case ContactElementsOne:
2162          case ReducedContactElementsOne:          case ReducedContactElementsOne:
2163              tags=mesh->ContactElements->tagsInUse;              return &mesh->ContactElements->tagsInUse[0];
             break;  
2164          default:          default:
2165              stringstream temp;              stringstream temp;
2166              temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;              temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;
2167              throw FinleyAdapterException(temp.str());              throw FinleyAdapterException(temp.str());
2168      }      }
2169      return tags;      return NULL;
2170  }  }
2171    
2172    

Legend:
Removed from v.4410  
changed lines
  Added in v.4428

  ViewVC Help
Powered by ViewVC 1.1.26