/[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

trunk/esys2/finley/src/CPPAdapter/MeshAdapter.cpp revision 110 by jgs, Mon Feb 14 04:14:42 2005 UTC trunk/finley/src/CPPAdapter/MeshAdapter.cpp revision 471 by jgs, Fri Jan 27 01:33:02 2006 UTC
# Line 13  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15  extern "C" {  extern "C" {
16  #include "finley/finleyC/Finley.h"  #include "Finley.h"
17  #include "finley/finleyC/Assemble.h"  #include "Assemble.h"
18  #include "finley/finleyC/Mesh.h"  #include "Mesh.h"
19  #include "finley/finleyC/Finley.h"  #include "Finley.h"
20  #include "finley/finleyC/System.h"  #include "SystemMatrix.h"
21  }  }
22  #include "finley/CPPAdapter/SystemMatrixAdapter.h"  #include "SystemMatrixAdapter.h"
23  #include "finley/CPPAdapter/MeshAdapter.h"  #include "MeshAdapter.h"
24  #include "finley/CPPAdapter/FinleyError.h"  #include "FinleyError.h"
25  #include "finley/CPPAdapter/FinleyAdapterException.h"  #include "FinleyAdapterException.h"
26  #include "escript/Data/FunctionSpaceFactory.h"  #include "escript/Data/FunctionSpaceFactory.h"
27  #include "escript/Data/Data.h"  #include "escript/Data/Data.h"
28  #include "escript/Data/DataArrayView.h"  #include "escript/Data/DataArrayView.h"
29  #include "escript/Data/FunctionSpace.h"  #include "escript/Data/FunctionSpace.h"
30  #include "escript/Data/DataFactory.h"  #include "escript/Data/DataFactory.h"
31    #include <boost/python/extract.hpp>
32    
33  #include <iostream>  #include <iostream>
 #include <vector>  
34  #include <sstream>  #include <sstream>
35    
36  using namespace std;  using namespace std;
# Line 37  using namespace escript; Line 38  using namespace escript;
38    
39  namespace finley {  namespace finley {
40    
 struct null_deleter  
 {  
   void operator()(void const *ptr) const  
   {  
   }  
 };  
   
41  //  //
42  // define the statics  // define the static constants
43  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;
44  const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;  const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;
45  const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;  const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;
# Line 64  MeshAdapter::MeshAdapter(Finley_Mesh* fi Line 58  MeshAdapter::MeshAdapter(Finley_Mesh* fi
58    // for us.    // for us.
59    m_finleyMesh.reset(finleyMesh,null_deleter());    m_finleyMesh.reset(finleyMesh,null_deleter());
60  }  }
61    
62  //  //
63  // The copy constructor should just increment the use count  // The copy constructor should just increment the use count
64  MeshAdapter::MeshAdapter(const MeshAdapter& in):  MeshAdapter::MeshAdapter(const MeshAdapter& in):
# Line 150  int MeshAdapter::getContinuousFunctionCo Line 145  int MeshAdapter::getContinuousFunctionCo
145  {  {
146    return Nodes;    return Nodes;
147  }  }
148    
149  int MeshAdapter::getFunctionCode() const  int MeshAdapter::getFunctionCode() const
150  {  {
151    return Elements;    return Elements;
152  }  }
153    
154  int MeshAdapter::getFunctionOnBoundaryCode() const  int MeshAdapter::getFunctionOnBoundaryCode() const
155  {  {
156    return FaceElements;    return FaceElements;
157  }  }
158    
159  int MeshAdapter::getFunctionOnContactZeroCode() const  int MeshAdapter::getFunctionOnContactZeroCode() const
160  {  {
161    return ContactElementsZero;    return ContactElementsZero;
162  }  }
163    
164  int MeshAdapter::getFunctionOnContactOneCode() const  int MeshAdapter::getFunctionOnContactOneCode() const
165  {  {
166    return ContactElementsOne;    return ContactElementsOne;
# Line 171  int MeshAdapter::getSolutionCode() const Line 170  int MeshAdapter::getSolutionCode() const
170  {  {
171    return DegreesOfFreedom;    return DegreesOfFreedom;
172  }  }
173    
174  int MeshAdapter::getReducedSolutionCode() const  int MeshAdapter::getReducedSolutionCode() const
175  {  {
176    return ReducedDegreesOfFreedom;    return ReducedDegreesOfFreedom;
177  }  }
178    
179  int MeshAdapter::getDiracDeltaFunctionCode() const  int MeshAdapter::getDiracDeltaFunctionCode() const
180  {  {
181    return Points;    return Points;
182  }  }
183    
184  //  //
185  // returns a pointer to the tag list of samples of functionSpaceType  // returns a pointer to the tag list of samples of functionSpaceType
186  //  //
# Line 239  void MeshAdapter::getTagList(int functio Line 241  void MeshAdapter::getTagList(int functio
241      break;      break;
242    default:    default:
243      stringstream temp;      stringstream temp;
244      temp << "Error - Invalid function space type: "      temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
      << functionSpaceType << " for domain: " << getDescription();  
245      throw FinleyAdapterException(temp.str());      throw FinleyAdapterException(temp.str());
246      break;      break;
247    }    }
# Line 251  void MeshAdapter::getTagList(int functio Line 252  void MeshAdapter::getTagList(int functio
252    }    }
253    return;    return;
254  }  }
255    
256  //  //
257  // returns a pointer to the reference no list of samples of functionSpaceType  // returns a pointer to the reference no list of samples of functionSpaceType
258  //  //
# Line 311  void MeshAdapter::getReferenceNoList(int Line 313  void MeshAdapter::getReferenceNoList(int
313      break;      break;
314    default:    default:
315      stringstream temp;      stringstream temp;
316      temp << "Error - Invalid function space type: "      temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
      << functionSpaceType << " for domain: " << getDescription();  
317      throw FinleyAdapterException(temp.str());      throw FinleyAdapterException(temp.str());
318      break;      break;
319    }    }
# Line 333  int MeshAdapter::getDim() const Line 334  int MeshAdapter::getDim() const
334    checkFinleyError();    checkFinleyError();
335    return numDim;    return numDim;
336  }  }
337    
338  //  //
339  // return the number of data points per sample and the number of samples  // return the number of data points per sample and the number of samples
340  // needed to represent data on a parts of the mesh.  // needed to represent data on a parts of the mesh.
# Line 391  pair<int,int> MeshAdapter::getDataShape( Line 393  pair<int,int> MeshAdapter::getDataShape(
393             break;             break;
394        default:        default:
395          stringstream temp;          stringstream temp;
396          temp << "Error - Invalid function space type: "          temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();
          << functionSpaceCode << " for domain: " << getDescription();  
397          throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
398          break;          break;
399        }        }
400        return pair<int,int>(numDataPointsPerSample,numSamples);        return pair<int,int>(numDataPointsPerSample,numSamples);
401  }  }
402    
403  //  //
404  // adds linear PDE of second order into a given stiffness matrix and right hand side:  // adds linear PDE of second order into a given stiffness matrix and right hand side:
405  //  //
# Line 408  void MeshAdapter::addPDEToSystem( Line 410  void MeshAdapter::addPDEToSystem(
410                       const Data& d_contact,const Data& y_contact) const                       const Data& d_contact,const Data& y_contact) const
411  {  {
412     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
413     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getFinley_SystemMatrix(),&(rhs.getDataC()),     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(),&(rhs.getDataC()),
414                         &(A.getDataC()),&(B.getDataC()),&(C.getDataC()),&(D.getDataC()),&(X.getDataC()),&(Y.getDataC()));                         &(A.getDataC()),&(B.getDataC()),&(C.getDataC()),&(D.getDataC()),&(X.getDataC()),&(Y.getDataC()));
415     checkFinleyError();     checkFinleyError();
416     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,
417                    mat.getFinley_SystemMatrix(),                    mat.getPaso_SystemMatrix(),
418                    &(rhs.getDataC()),                    &(rhs.getDataC()),
419                                    &(d.getDataC()),&(y.getDataC()),                                    &(d.getDataC()),&(y.getDataC()),
420                                    Finley_Assemble_handelShapeMissMatch_Mean_out);                                    Finley_Assemble_handelShapeMissMatch_Mean_out);
421     checkFinleyError();     checkFinleyError();
422     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->ContactElements,
423                    mat.getFinley_SystemMatrix(),                    mat.getPaso_SystemMatrix(),
424                    &(rhs.getDataC()),                    &(rhs.getDataC()),
425                                    &(d_contact.getDataC()),                                    &(d_contact.getDataC()),
426                    &(y_contact.getDataC()),                    &(y_contact.getDataC()),
427                                    Finley_Assemble_handelShapeMissMatch_Step_out);                                    Finley_Assemble_handelShapeMissMatch_Step_out);
428     checkFinleyError();     checkFinleyError();
429  }  }
430    
431  //  //
432  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
433  //  //
# Line 432  void MeshAdapter::addPDEToRHS( Data& rhs Line 435  void MeshAdapter::addPDEToRHS( Data& rhs
435                       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
436  {  {
437     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
438     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,0,&(rhs.getDataC()),0,0,0,0,&(X.getDataC()),&(Y.getDataC()));  
439       // Finley_Assemble_PDE_RHS(mesh->Nodes,mesh->Elements,&(rhs.getDataC()),&(X.getDataC()),&(Y.getDataC()));
440       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,0,&(rhs.getDataC()),0,0,0,0,&(X.getDataC()),&(Y.getDataC()));
441     checkFinleyError();     checkFinleyError();
442     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,0,&(rhs.getDataC()),0,&(y.getDataC()),  
443                                    Finley_Assemble_handelShapeMissMatch_Mean_out);     // Finley_Assemble_RobinCondition_RHS(mesh->Nodes,mesh->FaceElements,&(rhs.getDataC()),&(y.getDataC()),Finley_Assemble_handelShapeMissMatch_Mean_out);
444  // cout << "Calling :addPDEToRHS." << endl;     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,0,&(rhs.getDataC()),0,&(y.getDataC()),Finley_Assemble_handelShapeMissMatch_Mean_out);
445    
446     checkFinleyError();     checkFinleyError();
447     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);
448                                    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;  
449     checkFinleyError();     checkFinleyError();
450  }  }
451    
452  //  //
453  // interpolates data between different function spaces:  // interpolates data between different function spaces:
454  //  //
# Line 480  void MeshAdapter::interpolateOnDomain(Da Line 486  void MeshAdapter::interpolateOnDomain(Da
486                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
487                 break;                 break;
488             default:             default:
489                 Finley_ErrorCode=TYPE_ERROR;                 stringstream temp;
490                 sprintf(Finley_ErrorMsg,"Interpolation on Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());                 temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
491                   throw FinleyAdapterException(temp.str());
492                 break;                 break;
493          }          }
494          break;          break;
# Line 489  void MeshAdapter::interpolateOnDomain(Da Line 496  void MeshAdapter::interpolateOnDomain(Da
496          if (target.getFunctionSpace().getTypeCode()==Elements) {          if (target.getFunctionSpace().getTypeCode()==Elements) {
497             Finley_Assemble_CopyElementData(mesh->Elements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->Elements,&(target.getDataC()),&(in.getDataC()));
498          } else {          } else {
499             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on elements possible.");  
500          }          }
501          break;          break;
502       case(FaceElements):       case(FaceElements):
503          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
504             Finley_Assemble_CopyElementData(mesh->FaceElements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->FaceElements,&(target.getDataC()),&(in.getDataC()));
505          } else {          } else {
506             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on face elements possible.");  
507             break;             break;
508         }         }
509       case(Points):       case(Points):
510          if (target.getFunctionSpace().getTypeCode()==Points) {          if (target.getFunctionSpace().getTypeCode()==Points) {
511             Finley_Assemble_CopyElementData(mesh->Points,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->Points,&(target.getDataC()),&(in.getDataC()));
512          } else {          } else {
513             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on points possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on points possible.");  
514             break;             break;
515          }          }
516          break;          break;
# Line 515  void MeshAdapter::interpolateOnDomain(Da Line 519  void MeshAdapter::interpolateOnDomain(Da
519          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
520             Finley_Assemble_CopyElementData(mesh->ContactElements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->ContactElements,&(target.getDataC()),&(in.getDataC()));
521          } else {          } else {
522             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on contact elements possible.");  
523             break;             break;
524          }          }
525          break;          break;
# Line 541  void MeshAdapter::interpolateOnDomain(Da Line 544  void MeshAdapter::interpolateOnDomain(Da
544                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
545               break;               break;
546             default:             default:
547               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
548               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
549                 throw FinleyAdapterException(temp.str());
550               break;               break;
551          }          }
552          break;          break;
553       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
554         switch(target.getFunctionSpace().getTypeCode()) {         switch(target.getFunctionSpace().getTypeCode()) {
555            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
           case(Nodes):  
556               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));
557               break;               break;
558            case(Elements):            case(Elements):
# Line 565  void MeshAdapter::interpolateOnDomain(Da Line 568  void MeshAdapter::interpolateOnDomain(Da
568            case(ContactElementsOne):            case(ContactElementsOne):
569               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
570               break;               break;
571              case(Nodes):
572                 throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
573                 break;
574            case(DegreesOfFreedom):            case(DegreesOfFreedom):
575               Finley_ErrorCode=TYPE_ERROR;               throw FinleyAdapterException("Error - 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");  
576               break;               break;
577            default:            default:
578               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
579               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
580                 throw FinleyAdapterException(temp.str());
581               break;               break;
582         }         }
583         break;         break;
584       default:       default:
585          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
586          sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",in.getFunctionSpace().getTypeCode());          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();
587            throw FinleyAdapterException(temp.str());
588          break;          break;
589    }    }
590    checkFinleyError();    checkFinleyError();
# Line 603  void MeshAdapter::setToX(Data& arg) cons Line 610  void MeshAdapter::setToX(Data& arg) cons
610    }    }
611    checkFinleyError();    checkFinleyError();
612  }  }
613    
614  //  //
615  // return the normal vectors at the location of data points as a Data object:  // return the normal vectors at the location of data points as a Data object:
616  //  //
# Line 614  void MeshAdapter::setToNormal(Data& norm Line 622  void MeshAdapter::setToNormal(Data& norm
622    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
623    switch(normal.getFunctionSpace().getTypeCode()) {    switch(normal.getFunctionSpace().getTypeCode()) {
624      case(Nodes):      case(Nodes):
625        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for nodes");  
626        break;        break;
627      case(Elements):      case(Elements):
628        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for elements");  
629        break;        break;
630      case (FaceElements):      case (FaceElements):
631        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&(normal.getDataC()));
632        break;        break;
633      case(Points):      case(Points):
634        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for point elements");  
635        break;        break;
636      case (ContactElementsOne):      case (ContactElementsOne):
637      case (ContactElementsZero):      case (ContactElementsZero):
638        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&(normal.getDataC()));
639        break;        break;
640      case(DegreesOfFreedom):      case(DegreesOfFreedom):
641        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for degrees of freedom.");  
642        break;        break;
643      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
644        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for reduced degrees of freedom.");  
645        break;        break;
646      default:      default:
647        Finley_ErrorCode=TYPE_ERROR;        stringstream temp;
648        sprintf(Finley_ErrorMsg,"Normal Vectors: Finley does not know anything about function space type %d",normal.getFunctionSpace().getTypeCode());        temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();
649          throw FinleyAdapterException(temp.str());
650        break;        break;
651    }    }
652    checkFinleyError();    checkFinleyError();
653  }  }
654    
655  //  //
656  // interpolates data to other domain:  // interpolates data to other domain:
657  //  //
# Line 656  void MeshAdapter::interpolateACross(Data Line 661  void MeshAdapter::interpolateACross(Data
661    if (targetDomain!=*this)    if (targetDomain!=*this)
662       throw FinleyAdapterException("Error - Illegal domain of interpolation target");       throw FinleyAdapterException("Error - Illegal domain of interpolation target");
663    
664    Finley_ErrorCode=SYSTEM_ERROR;    throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
   sprintf(Finley_ErrorMsg,"Finley does not allow interpolation across domains yet.");  
   checkFinleyError();  
665  }  }
666    
667  //  //
668  // calculates the integral of a function defined of arg:  // calculates the integral of a function defined of arg:
669  //  //
# Line 672  void MeshAdapter::setToIntegrals(std::ve Line 676  void MeshAdapter::setToIntegrals(std::ve
676    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
677    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
678       case(Nodes):       case(Nodes):
679          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on nodes is not supported.");  
680          break;          break;
681       case(Elements):       case(Elements):
682          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&(arg.getDataC()),&integrals[0]);
# Line 682  void MeshAdapter::setToIntegrals(std::ve Line 685  void MeshAdapter::setToIntegrals(std::ve
685          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&(arg.getDataC()),&integrals[0]);
686          break;          break;
687       case(Points):       case(Points):
688          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on points is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on points is not supported.");  
689          break;          break;
690       case(ContactElementsZero):       case(ContactElementsZero):
691          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);
# Line 692  void MeshAdapter::setToIntegrals(std::ve Line 694  void MeshAdapter::setToIntegrals(std::ve
694          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);
695          break;          break;
696       case(DegreesOfFreedom):       case(DegreesOfFreedom):
697          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on degrees of freedom is not supported.");  
698          break;          break;
699       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
700          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on reduced degrees of freedom is not supported.");  
701          break;          break;
702       default:       default:
703          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
704          sprintf(Finley_ErrorMsg,"Integrals: Finley does not know anything about function space type %d",arg.getFunctionSpace().getTypeCode());          temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
705            throw FinleyAdapterException(temp.str());
706          break;          break;
707    }    }
708    checkFinleyError();    checkFinleyError();
709  }  }
710    
711  //  //
712  // calculates the gradient of arg:  // calculates the gradient of arg:
713  //  //
# Line 721  void MeshAdapter::setToGradient(Data& gr Line 723  void MeshAdapter::setToGradient(Data& gr
723    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
724    switch(grad.getFunctionSpace().getTypeCode()) {    switch(grad.getFunctionSpace().getTypeCode()) {
725         case(Nodes):         case(Nodes):
726            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at nodes is not supported.");  
727            break;            break;
728         case(Elements):         case(Elements):
729            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&(grad.getDataC()),&(arg.getDataC()));
# Line 731  void MeshAdapter::setToGradient(Data& gr Line 732  void MeshAdapter::setToGradient(Data& gr
732            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&(grad.getDataC()),&(arg.getDataC()));
733            break;            break;
734         case(Points):         case(Points):
735            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at points is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at points is not supported.");  
736            break;            break;
737         case(ContactElementsZero):         case(ContactElementsZero):
738            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));
# Line 741  void MeshAdapter::setToGradient(Data& gr Line 741  void MeshAdapter::setToGradient(Data& gr
741            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));
742            break;            break;
743         case(DegreesOfFreedom):         case(DegreesOfFreedom):
744            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at degrees of freedom is not supported.");  
745            break;            break;
746         case(ReducedDegreesOfFreedom):         case(ReducedDegreesOfFreedom):
747            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at reduced degrees of freedom is not supported.");  
748            break;            break;
749         default:         default:
750            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
751            sprintf(Finley_ErrorMsg,"Gradient: Finley does not know anything about function space type %d",arg.getFunctionSpace().getTypeCode());            temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
752              throw FinleyAdapterException(temp.str());
753            break;            break;
754    }    }
755    checkFinleyError();    checkFinleyError();
756  }  }
757    
758  //  //
759  // returns the size of elements:  // returns the size of elements:
760  //  //
# Line 764  void MeshAdapter::setToSize(Data& size) Line 764  void MeshAdapter::setToSize(Data& size)
764    escriptDataC tmp=size.getDataC();    escriptDataC tmp=size.getDataC();
765    switch(size.getFunctionSpace().getTypeCode()) {    switch(size.getFunctionSpace().getTypeCode()) {
766         case(Nodes):         case(Nodes):
767            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of nodes is not supported.");
           sprintf(Finley_ErrorMsg,"Size of nodes is not supported.");  
768            break;            break;
769         case(Elements):         case(Elements):
770            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
# Line 774  void MeshAdapter::setToSize(Data& size) Line 773  void MeshAdapter::setToSize(Data& size)
773            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
774            break;            break;
775         case(Points):         case(Points):
776            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of point elements is not supported.");
           sprintf(Finley_ErrorMsg,"Size of point elements is not supported.");  
777            break;            break;
778         case(ContactElementsZero):         case(ContactElementsZero):
779         case(ContactElementsOne):         case(ContactElementsOne):
780            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
781            break;            break;
782         case(DegreesOfFreedom):         case(DegreesOfFreedom):
783            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Size of degrees of freedom is not supported.");  
784            break;            break;
785         case(ReducedDegreesOfFreedom):         case(ReducedDegreesOfFreedom):
786            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Size of reduced degrees of freedom is not supported.");  
787            break;            break;
788         default:         default:
789            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
790            sprintf(Finley_ErrorMsg,"Element size: Finley does not know anything about function space type %d",size.getFunctionSpace().getTypeCode());            temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();
791              throw FinleyAdapterException(temp.str());
792            break;            break;
793    }    }
794    checkFinleyError();    checkFinleyError();
795  }  }
796    
797  // sets the location of nodes:  // sets the location of nodes:
798  void MeshAdapter::setNewX(const Data& new_x)  void MeshAdapter::setNewX(const Data& new_x)
799  {  {
# Line 806  void MeshAdapter::setNewX(const Data& ne Line 804  void MeshAdapter::setNewX(const Data& ne
804    Finley_NodeFile_setCoordinates(mesh->Nodes,&(new_x.getDataC()));    Finley_NodeFile_setCoordinates(mesh->Nodes,&(new_x.getDataC()));
805    checkFinleyError();    checkFinleyError();
806  }  }
807    
808  // saves a data array in openDX format:  // saves a data array in openDX format:
809  void MeshAdapter::saveDX(const std::string& filename,const Data& arg) const  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
810  {  {
811    Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));      int MAX_namelength=256;
812    checkFinleyError();      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
813        char names[num_data][MAX_namelength];
814        char* c_names[num_data];
815        escriptDataC data[num_data];
816        escriptDataC* ptr_data[num_data];
817    
818        boost::python::list keys=arg.keys();
819        for (int i=0;i<num_data;++i) {
820             Data& d=boost::python::extract<Data&>(arg[keys[i]]);
821             if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
822                 throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
823             data[i]=d.getDataC();
824             ptr_data[i]=&(data[i]);
825             std::string n=boost::python::extract<std::string>(keys[i]);
826             c_names[i]=&(names[i][0]);
827             if (n.length()>MAX_namelength-1) {
828                strncpy(c_names[i],n.c_str(),MAX_namelength-1);
829                c_names[i][MAX_namelength-1]='\0';
830             } else {
831                strcpy(c_names[i],n.c_str());
832             }
833        }
834        Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
835        checkFinleyError();
836        return;
837  }  }
838    
839  // saves a data array in openVTK format:  // saves a data array in openVTK format:
840  void MeshAdapter::saveVTK(const std::string& filename,const Data& arg) const  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
841  {  {
842    Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));      int MAX_namelength=256;
843    checkFinleyError();      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
844        char names[num_data][MAX_namelength];
845        char* c_names[num_data];
846        escriptDataC data[num_data];
847        escriptDataC* ptr_data[num_data];
848    
849        boost::python::list keys=arg.keys();
850        for (int i=0;i<num_data;++i) {
851             Data& d=boost::python::extract<Data&>(arg[keys[i]]);
852             if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
853                 throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
854             data[i]=d.getDataC();
855             ptr_data[i]=&(data[i]);
856             std::string n=boost::python::extract<std::string>(keys[i]);
857             c_names[i]=&(names[i][0]);
858             if (n.length()>MAX_namelength-1) {
859                strncpy(c_names[i],n.c_str(),MAX_namelength-1);
860                c_names[i][MAX_namelength-1]='\0';
861             } else {
862                strcpy(c_names[i],n.c_str());
863             }
864        }
865        Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
866        checkFinleyError();
867        return;
868  }  }
869                                                                                                                                                                            
870                                                                                                                                                                            
871  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
872  SystemMatrixAdapter MeshAdapter::newSystemMatrix(  SystemMatrixAdapter MeshAdapter::newSystemMatrix(
873                        const int row_blocksize,                        const int row_blocksize,
# Line 852  SystemMatrixAdapter MeshAdapter::newSyst Line 902  SystemMatrixAdapter MeshAdapter::newSyst
902      }      }
903      // generate matrix:      // generate matrix:
904            
905      Finley_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
     checkFinleyError();  
     Finley_SystemMatrix* fsystemMatrix=Finley_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);  
906      checkFinleyError();      checkFinleyError();
907        Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
908        checkPasoError();
909        Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);
910      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
911  }  }
912    
913  //  //
914  // vtkObject MeshAdapter::createVtkObject() const  // vtkObject MeshAdapter::createVtkObject() const
915  // TODO:  // TODO:
916  //  //
917    
918  //  //
919  // returns true if data at the atom_type is considered as being cell centered:  // returns true if data at the atom_type is considered as being cell centered:
920  bool MeshAdapter::isCellOriented(int functionSpaceCode) const  bool MeshAdapter::isCellOriented(int functionSpaceCode) const
# Line 880  bool MeshAdapter::isCellOriented(int fun Line 933  bool MeshAdapter::isCellOriented(int fun
933            return true;            return true;
934            break;            break;
935         default:         default:
936            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
937            sprintf(Finley_ErrorMsg,"Cell: Finley does not know anything about function space type %d",functionSpaceCode);            temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;
938              throw FinleyAdapterException(temp.str());
939            break;            break;
940    }    }
941    checkFinleyError();    checkFinleyError();
942    return false;    return false;
943  }  }
944    
945  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
946  {  {
947    switch(functionSpaceType_source) {    switch(functionSpaceType_source) {
# Line 902  bool MeshAdapter::probeInterpolationOnDo Line 957  bool MeshAdapter::probeInterpolationOnDo
957             case(ContactElementsOne):             case(ContactElementsOne):
958                 return true;                 return true;
959             default:             default:
960                 Finley_ErrorCode=TYPE_ERROR;                 stringstream temp;
961                 sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);                 temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
962                   throw FinleyAdapterException(temp.str());
963          }          }
964          break;          break;
965       case(Elements):       case(Elements):
# Line 943  bool MeshAdapter::probeInterpolationOnDo Line 999  bool MeshAdapter::probeInterpolationOnDo
999             case(ContactElementsOne):             case(ContactElementsOne):
1000                return true;                return true;
1001             default:             default:
1002               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
1003               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1004                 throw FinleyAdapterException(temp.str());
1005          }          }
1006          break;          break;
1007       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
1008         switch(functionSpaceType_target) {         switch(functionSpaceType_target) {
1009            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
           case(Nodes):  
1010            case(Elements):            case(Elements):
1011            case(FaceElements):            case(FaceElements):
1012            case(Points):            case(Points):
1013            case(ContactElementsZero):            case(ContactElementsZero):
1014            case(ContactElementsOne):            case(ContactElementsOne):
1015                return true;                return true;
1016              case(Nodes):
1017            case(DegreesOfFreedom):            case(DegreesOfFreedom):
1018               return false;               return false;
1019            default:            default:
1020               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
1021               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1022                 throw FinleyAdapterException(temp.str());
1023         }         }
1024         break;         break;
1025       default:       default:
1026          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
1027          sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_source);          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;
1028            throw FinleyAdapterException(temp.str());
1029          break;          break;
1030    }    }
1031    checkFinleyError();    checkFinleyError();
1032    return false;    return false;
1033  }  }
1034    
1035  bool MeshAdapter::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const
1036  {  {
1037      return false;      return false;
1038  }  }
1039    
1040  bool MeshAdapter::operator==(const MeshAdapter& other) const  bool MeshAdapter::operator==(const AbstractDomain& other) const
1041  {  {
1042    return (m_finleyMesh==other.m_finleyMesh);    const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);
1043      if (temp!=0) {
1044        return (m_finleyMesh==temp->m_finleyMesh);
1045      } else {
1046        return false;
1047      }
1048  }  }
1049    
1050  bool MeshAdapter::operator!=(const MeshAdapter& other) const  bool MeshAdapter::operator!=(const AbstractDomain& other) const
1051  {  {
1052    return !operator==(other);    return !(operator==(other));
1053  }  }
1054    
1055  int MeshAdapter::getSystemMatrixTypeId(const int solver, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const
1056  {  {
1057     int out=Finley_SystemMatrix_getSystemMatrixTypeId(solver,symmetry?1:0);     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1058     checkFinleyError();     checkPasoError();
1059     return out;     return out;
1060  }  }
1061    
1062  Data MeshAdapter::getX() const  Data MeshAdapter::getX() const
1063  {  {
1064    return continuousFunction(asAbstractContinuousDomain()).getX();    return continuousFunction(asAbstractContinuousDomain()).getX();
1065  }  }
1066    
1067  Data MeshAdapter::getNormal() const  Data MeshAdapter::getNormal() const
1068  {  {
1069    return functionOnBoundary(asAbstractContinuousDomain()).getNormal();    return functionOnBoundary(asAbstractContinuousDomain()).getNormal();
1070  }  }
1071    
1072  Data MeshAdapter::getSize() const  Data MeshAdapter::getSize() const
1073  {  {
1074    return function(asAbstractContinuousDomain()).getSize();    return function(asAbstractContinuousDomain()).getSize();

Legend:
Removed from v.110  
changed lines
  Added in v.471

  ViewVC Help
Powered by ViewVC 1.1.26