/[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 1366 by gross, Tue Dec 18 05:49:17 2007 UTC revision 1464 by gross, Tue Apr 1 23:27:09 2008 UTC
# Line 24  extern "C" { Line 24  extern "C" {
24  }  }
25  #include <vector>  #include <vector>
26    
27    #define IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH  256
28    
29  using namespace std;  using namespace std;
30  using namespace escript;  using namespace escript;
31    
# Line 809  void MeshAdapter::addPDEToRHS( escript:: Line 811  void MeshAdapter::addPDEToRHS( escript::
811     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );
812     checkFinleyError();     checkFinleyError();
813  }  }
814    //
815    // adds PDE of second order into a transport problem
816    //
817    void MeshAdapter::addPDEToTransportProblem(
818                         TransportProblemAdapter& tp, escript::Data& source, const escript::Data& M,
819                         const escript::Data& A, const escript::Data& B, const escript::Data& C,
820                         const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,
821                         const escript::Data& d, const escript::Data& y,
822                         const escript::Data& d_contact,const escript::Data& y_contact) const
823    {
824       DataArrayView::ShapeType shape;
825       source.expand();
826       escriptDataC _source=source.getDataC();
827       escriptDataC _M=M.getDataC();
828       escriptDataC _A=A.getDataC();
829       escriptDataC _B=B.getDataC();
830       escriptDataC _C=C.getDataC();
831       escriptDataC _D=D.getDataC();
832       escriptDataC _X=X.getDataC();
833       escriptDataC _Y=Y.getDataC();
834       escriptDataC _d=d.getDataC();
835       escriptDataC _y=y.getDataC();
836       escriptDataC _d_contact=d_contact.getDataC();
837       escriptDataC _y_contact=y_contact.getDataC();
838    
839       Finley_Mesh* mesh=m_finleyMesh.get();
840       Paso_FCTransportProblem* _tp = tp.getPaso_FCTransportProblem();
841      
842       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->mass_matrix, &_source, 0, 0, 0, &_M, 0, 0 );
843       checkFinleyError();
844    
845       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->transport_matrix, &_source, &_A, &_B, &_C, &_D, &_X, &_Y );
846       checkFinleyError();
847    
848       Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, _tp->transport_matrix, &_source, 0, 0, 0, &_d, 0, &_y );
849       checkFinleyError();
850    
851       Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, _tp->transport_matrix, &_source , 0, 0, 0, &_d_contact, 0, &_y_contact );
852       checkFinleyError();
853    }
854    
855  //  //
856  // interpolates data between different function spaces:  // interpolates data between different function spaces:
# Line 920  void MeshAdapter::interpolateOnDomain(es Line 962  void MeshAdapter::interpolateOnDomain(es
962          }          }
963          break;          break;
964       case(ReducedFaceElements):       case(ReducedFaceElements):
965  cout << "A\n";          if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
         if (target.getFunctionSpace().getTypeCode()==FaceElements) {  
 cout << "B\n";  
966             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
 cout << "C\n";  
         throw FinleyAdapterException("A");  
967          } else {          } else {
968             throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");             throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
969         }         }
 cout << "A\n";  
970         break;         break;
971       case(Points):       case(Points):
972          if (target.getFunctionSpace().getTypeCode()==Points) {          if (target.getFunctionSpace().getTypeCode()==Points) {
# Line 1046  cout << "A\n"; Line 1083  cout << "A\n";
1083            case(Elements):            case(Elements):
1084            case(ReducedElements):            case(ReducedElements):
1085                if (getMPISize()>1) {                if (getMPISize()>1) {
1086                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );                   escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1087                   escriptDataC _in2 = temp.getDataC();                   escriptDataC _in2 = temp.getDataC();
1088                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1089                } else {                } else {
# Line 1056  cout << "A\n"; Line 1093  cout << "A\n";
1093            case(FaceElements):            case(FaceElements):
1094            case(ReducedFaceElements):            case(ReducedFaceElements):
1095                if (getMPISize()>1) {                if (getMPISize()>1) {
1096                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );                   escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1097                   escriptDataC _in2 = temp.getDataC();                   escriptDataC _in2 = temp.getDataC();
1098                   Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);                   Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1099                } else {                } else {
# Line 1065  cout << "A\n"; Line 1102  cout << "A\n";
1102               break;               break;
1103            case(Points):            case(Points):
1104                if (getMPISize()>1) {                if (getMPISize()>1) {
1105                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );                   escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1106                   escriptDataC _in2 = temp.getDataC();                   escriptDataC _in2 = temp.getDataC();
1107                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1108                } else {                } else {
# Line 1077  cout << "A\n"; Line 1114  cout << "A\n";
1114            case(ReducedContactElementsZero):            case(ReducedContactElementsZero):
1115            case(ReducedContactElementsOne):            case(ReducedContactElementsOne):
1116                if (getMPISize()>1) {                if (getMPISize()>1) {
1117                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );                   escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1118                   escriptDataC _in2 = temp.getDataC();                   escriptDataC _in2 = temp.getDataC();
1119                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1120                } else {                } else {
# Line 1408  void MeshAdapter::setNewX(const escript: Line 1445  void MeshAdapter::setNewX(const escript:
1445  // saves a data array in openDX format:  // saves a data array in openDX format:
1446  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
1447  {  {
1448      int MAX_namelength=256;      unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1449      const int num_data=boost::python::extract<int>(arg.attr("__len__")());      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1450    /* win32 refactor */    /* win32 refactor */
1451    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
# Line 1456  void MeshAdapter::saveDX(const std::stri Line 1493  void MeshAdapter::saveDX(const std::stri
1493  // saves a data array in openVTK format:  // saves a data array in openVTK format:
1494  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
1495  {  {
1496      int MAX_namelength=256;      unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1497      const int num_data=boost::python::extract<int>(arg.attr("__len__")());      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1498    /* win32 refactor */    /* win32 refactor */
1499    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
# Line 1555  SystemMatrixAdapter MeshAdapter::newSyst Line 1592  SystemMatrixAdapter MeshAdapter::newSyst
1592  // creates a TransportProblemAdapter  // creates a TransportProblemAdapter
1593  TransportProblemAdapter MeshAdapter::newTransportProblem(  TransportProblemAdapter MeshAdapter::newTransportProblem(
1594                        const double theta,                        const double theta,
                       const double dt_max,  
1595                        const int blocksize,                        const int blocksize,
1596                        const escript::FunctionSpace& functionspace,                        const escript::FunctionSpace& functionspace,
1597                        const int type) const                        const int type) const
# Line 1578  TransportProblemAdapter MeshAdapter::new Line 1614  TransportProblemAdapter MeshAdapter::new
1614      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceOrder,reduceOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceOrder,reduceOrder);
1615      checkFinleyError();      checkFinleyError();
1616      Paso_FCTransportProblem* transportProblem;      Paso_FCTransportProblem* transportProblem;
1617      transportProblem=Paso_FCTransportProblem_alloc(theta,dt_max,fsystemMatrixPattern,blocksize);      transportProblem=Paso_FCTransportProblem_alloc(theta,fsystemMatrixPattern,blocksize);
1618      checkPasoError();      checkPasoError();
1619      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1620      return TransportProblemAdapter(transportProblem,theta,dt_max,blocksize,functionspace);      return TransportProblemAdapter(transportProblem,theta,blocksize,functionspace);
1621  }  }
1622    
1623  //  //
# Line 1817  escript::Data MeshAdapter::getSize() con Line 1853  escript::Data MeshAdapter::getSize() con
1853    
1854  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1855  {  {
1856    int *out=0,i;    int *out = NULL;
1857    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1858    switch (functionSpaceType) {    switch (functionSpaceType) {
1859      case(Nodes):      case(Nodes):

Legend:
Removed from v.1366  
changed lines
  Added in v.1464

  ViewVC Help
Powered by ViewVC 1.1.26