/[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 102 by jgs, Wed Dec 15 07:08:39 2004 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 36  using namespace std; Line 36  using namespace std;
36  using namespace escript;  using namespace escript;
37    
38  namespace finley {  namespace finley {
   
 struct null_deleter  
 {  
   void operator()(void const *ptr) const  
   {  
   }  
 };  
   
39  //  //
40  // define the statics  // define the statics
41  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;
# Line 179  int MeshAdapter::getDiracDeltaFunctionCo Line 171  int MeshAdapter::getDiracDeltaFunctionCo
171  {  {
172    return Points;    return Points;
173  }  }
   
 int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const  
 {  
   //  
   // It is assumed the sampleNo has been checked  
   // before calling this function.  
   int* tagList;  
   int numTags;  
   getTagList(functionSpaceType, &tagList, &numTags);  
   return tagList[sampleNo];  
 }  
   
174  //  //
175  // returns a pointer to the tag list of samples of functionSpaceType  // returns a pointer to the tag list of samples of functionSpaceType
176  //  //
# Line 256  void MeshAdapter::getTagList(int functio Line 236  void MeshAdapter::getTagList(int functio
236      throw FinleyAdapterException(temp.str());      throw FinleyAdapterException(temp.str());
237      break;      break;
238    }    }
239      if (*tagList==NULL) {
240        stringstream temp;
241        temp << "Error - no tags available for " << functionSpaceType << " for domain: " << getDescription();
242        throw FinleyAdapterException(temp.str());
243      }
244      return;
245    }
246    //
247    // returns a pointer to the reference no list of samples of functionSpaceType
248    //
249    void MeshAdapter::getReferenceNoList(int functionSpaceType, int** referenceNoList,
250                     int* numReferenceNo) const
251    {
252      *referenceNoList=NULL;
253      *numReferenceNo=0;
254      Finley_Mesh* mesh=m_finleyMesh.get();
255      switch (functionSpaceType) {
256      case(Nodes):
257        if (mesh->Nodes!=NULL) {
258          *referenceNoList=mesh->Nodes->Id;
259          *numReferenceNo=mesh->Nodes->numNodes;
260        }
261        break;
262      case(Elements):
263        if (mesh->Elements!=NULL) {
264          *referenceNoList=mesh->Elements->Id;
265          *numReferenceNo=mesh->Elements->numElements;
266        }
267        break;
268      case(FaceElements):
269        if (mesh->FaceElements!=NULL) {
270          *referenceNoList=mesh->FaceElements->Id;
271          *numReferenceNo=mesh->FaceElements->numElements;
272        }
273        break;
274      case(Points):
275        if (mesh->Points!=NULL) {
276          *referenceNoList=mesh->Points->Id;
277          *numReferenceNo=mesh->Points->numElements;
278        }
279        break;
280      case(ContactElementsZero):
281        if (mesh->ContactElements!=NULL) {
282          *referenceNoList=mesh->ContactElements->Id;
283          *numReferenceNo=mesh->ContactElements->numElements;
284        }
285        break;
286      case(ContactElementsOne):
287        if (mesh->ContactElements!=NULL) {
288          *referenceNoList=mesh->ContactElements->Id;
289          *numReferenceNo=mesh->ContactElements->numElements;
290        }
291        break;
292      case(DegreesOfFreedom):
293        if (mesh->Nodes!=NULL) {
294          *referenceNoList=NULL;
295          *numReferenceNo=0;
296        }
297        break;
298      case(ReducedDegreesOfFreedom):
299        if (mesh->Nodes!=NULL) {
300          *referenceNoList=NULL;
301          *numReferenceNo=0;
302        }
303        break;
304      default:
305        stringstream temp;
306        temp << "Error - Invalid function space type: "
307         << functionSpaceType << " for domain: " << getDescription();
308        throw FinleyAdapterException(temp.str());
309        break;
310      }
311      if (*referenceNoList==NULL) {
312        stringstream temp;
313        temp << "Error - reference number list available for " << functionSpaceType << " for domain: " << getDescription();
314        throw FinleyAdapterException(temp.str());
315      }
316    return;    return;
317  }  }
318    
# Line 352  void MeshAdapter::addPDEToSystem( Line 409  void MeshAdapter::addPDEToSystem(
409                                    &(d.getDataC()),&(y.getDataC()),                                    &(d.getDataC()),&(y.getDataC()),
410                                    Finley_Assemble_handelShapeMissMatch_Mean_out);                                    Finley_Assemble_handelShapeMissMatch_Mean_out);
411     checkFinleyError();     checkFinleyError();
412     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->ContactElements,
413                    mat.getFinley_SystemMatrix(),                    mat.getFinley_SystemMatrix(),
414                    &(rhs.getDataC()),                    &(rhs.getDataC()),
415                                    &(d_contact.getDataC()),                                    &(d_contact.getDataC()),
# Line 367  void MeshAdapter::addPDEToRHS( Data& rhs Line 424  void MeshAdapter::addPDEToRHS( Data& rhs
424                       const  Data& X,const  Data& Y, const Data& y, const Data& y_contact) const                       const  Data& X,const  Data& Y, const Data& y, const Data& y_contact) const
425  {  {
426     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
427     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,0,&(rhs.getDataC()),0,0,0,0,&(X.getDataC()),&(Y.getDataC()));  
428       // Finley_Assemble_PDE_RHS(mesh->Nodes,mesh->Elements,&(rhs.getDataC()),&(X.getDataC()),&(Y.getDataC()));
429       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,0,&(rhs.getDataC()),0,0,0,0,&(X.getDataC()),&(Y.getDataC()));
430     checkFinleyError();     checkFinleyError();
431     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,0,&(rhs.getDataC()),0,&(y.getDataC()),  
432                                    Finley_Assemble_handelShapeMissMatch_Mean_out);     // Finley_Assemble_RobinCondition_RHS(mesh->Nodes,mesh->FaceElements,&(rhs.getDataC()),&(y.getDataC()),Finley_Assemble_handelShapeMissMatch_Mean_out);
433  // cout << "Calling :addPDEToRHS." << endl;     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,0,&(rhs.getDataC()),0,&(y.getDataC()),Finley_Assemble_handelShapeMissMatch_Mean_out);
434    
435     checkFinleyError();     checkFinleyError();
436     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,0,&(rhs.getDataC()),0,&(y_contact.getDataC()),     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->ContactElements,0,&(rhs.getDataC()),0,&(y_contact.getDataC()),Finley_Assemble_handelShapeMissMatch_Step_out);
437                                    Finley_Assemble_handelShapeMissMatch_Step_out);     // Finley_Assemble_RobinCondition_RHS(mesh->Nodes,mesh->ContactElements,&(rhs.getDataC()),&(y_contact.getDataC()),Finley_Assemble_handelShapeMissMatch_Step_out);
 // cout << "Calling :addPDEToRHS." << endl;  
438     checkFinleyError();     checkFinleyError();
439  }  }
440  //  //
# Line 484  void MeshAdapter::interpolateOnDomain(Da Line 543  void MeshAdapter::interpolateOnDomain(Da
543       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
544         switch(target.getFunctionSpace().getTypeCode()) {         switch(target.getFunctionSpace().getTypeCode()) {
545            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
           case(Nodes):  
546               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));
547               break;               break;
548            case(Elements):            case(Elements):
# Line 500  void MeshAdapter::interpolateOnDomain(Da Line 558  void MeshAdapter::interpolateOnDomain(Da
558            case(ContactElementsOne):            case(ContactElementsOne):
559               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
560               break;               break;
561              case(Nodes):
562                 Finley_ErrorCode=TYPE_ERROR;
563                 sprintf(Finley_ErrorMsg,"Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
564                 break;
565            case(DegreesOfFreedom):            case(DegreesOfFreedom):
566               Finley_ErrorCode=TYPE_ERROR;               Finley_ErrorCode=TYPE_ERROR;
567               sprintf(Finley_ErrorMsg,"Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");               sprintf(Finley_ErrorMsg,"Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
# Line 747  void MeshAdapter::saveDX(const std::stri Line 809  void MeshAdapter::saveDX(const std::stri
809    Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));    Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));
810    checkFinleyError();    checkFinleyError();
811  }  }
812    // saves a data array in openVTK format:
813    void MeshAdapter::saveVTK(const std::string& filename,const Data& arg) const
814    {
815      Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));
816      checkFinleyError();
817    }
818  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
819  SystemMatrixAdapter MeshAdapter::newSystemMatrix(  SystemMatrixAdapter MeshAdapter::newSystemMatrix(
820                        const int row_blocksize,                        const int row_blocksize,
# Line 879  bool MeshAdapter::probeInterpolationOnDo Line 947  bool MeshAdapter::probeInterpolationOnDo
947       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
948         switch(functionSpaceType_target) {         switch(functionSpaceType_target) {
949            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
           case(Nodes):  
950            case(Elements):            case(Elements):
951            case(FaceElements):            case(FaceElements):
952            case(Points):            case(Points):
953            case(ContactElementsZero):            case(ContactElementsZero):
954            case(ContactElementsOne):            case(ContactElementsOne):
955                return true;                return true;
956              case(Nodes):
957            case(DegreesOfFreedom):            case(DegreesOfFreedom):
958               return false;               return false;
959            default:            default:
# Line 905  bool MeshAdapter::probeInterpolationACro Line 973  bool MeshAdapter::probeInterpolationACro
973  {  {
974      return false;      return false;
975  }  }
976  bool MeshAdapter::operator==(const MeshAdapter& other) const  
977    bool MeshAdapter::operator==(const AbstractDomain& other) const
978    {
979      const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);
980      if (temp!=0) {
981        return (m_finleyMesh==temp->m_finleyMesh);
982      } else {
983        return false;
984      }
985    }
986    
987    bool MeshAdapter::operator!=(const AbstractDomain& other) const
988  {  {
989    return (m_finleyMesh==other.m_finleyMesh);    return !(operator==(other));
990  }  }
991    
992  int MeshAdapter::getSystemMatrixTypeId(const int solver, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const bool symmetry) const
# Line 929  Data MeshAdapter::getSize() const Line 1008  Data MeshAdapter::getSize() const
1008    return function(asAbstractContinuousDomain()).getSize();    return function(asAbstractContinuousDomain()).getSize();
1009  }  }
1010    
1011    int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1012    {
1013      int* tagList;
1014      int numTags;
1015      getTagList(functionSpaceType, &tagList, &numTags);
1016      return tagList[sampleNo];
1017    }
1018    
1019  bool MeshAdapter::operator!=(const MeshAdapter& other) const  int MeshAdapter::getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const
1020  {  {
1021    return !operator==(other);    int* referenceNoList;
1022      int numReferenceNo;
1023      getReferenceNoList(functionSpaceType, &referenceNoList, &numReferenceNo);
1024      return referenceNoList[sampleNo];
1025  }  }
1026  // bool MeshAdapter::operator==(const AbstractDomain& other) const  
 // {  
   // try {  
     // const MeshAdapter& ref = dynamic_cast<const MeshAdapter&>(other);  
     // return (operator==(ref));  
   // }  
   // catch (bad_cast) {  
     // return false;  
   // }  
 // }  
1027  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.102  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26