/[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 4441 by caltinay, Fri Jun 7 02:23:49 2013 UTC revision 4657 by jfenwick, Thu Feb 6 06:12:20 2014 UTC
# Line 1  Line 1 
1    
2  /*****************************************************************************  /*****************************************************************************
3  *  *
4  * Copyright (c) 2003-2013 by University of Queensland  * Copyright (c) 2003-2014 by University of Queensland
5  * http://www.uq.edu.au  * http://www.uq.edu.au
6  *  *
7  * Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
# Line 9  Line 9 
9  * http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
10  *  *
11  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)  * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12  * Development since 2012 by School of Earth Sciences  * Development 2012-2013 by School of Earth Sciences
13    * Development from 2014 by Centre for Geoscience Computing (GeoComp)
14  *  *
15  *****************************************************************************/  *****************************************************************************/
16    
# Line 46  const int MeshAdapter::ReducedContactEle Line 47  const int MeshAdapter::ReducedContactEle
47  const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;  const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;
48  const int MeshAdapter::ReducedContactElementsOne=FINLEY_REDUCED_CONTACT_ELEMENTS_2;  const int MeshAdapter::ReducedContactElementsOne=FINLEY_REDUCED_CONTACT_ELEMENTS_2;
49    
50  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)  MeshAdapter::MeshAdapter(Mesh* finleyMesh)
51  {  {
52      setFunctionSpaceTypeNames();      setFunctionSpaceTypeNames();
53      // need to use a null_deleter as Finley_Mesh_free deletes the pointer      // need to use a null_deleter as Finley_Mesh_free deletes the pointer
# Line 66  MeshAdapter::~MeshAdapter() Line 67  MeshAdapter::~MeshAdapter()
67  {  {
68      // I hope the case for the pointer being zero has been taken care of      // I hope the case for the pointer being zero has been taken care of
69      if (m_finleyMesh.unique()) {      if (m_finleyMesh.unique()) {
70          Finley_Mesh_free(m_finleyMesh.get());          delete m_finleyMesh.get();
71      }      }
72  }  }
73    
# Line 106  MeshAdapter::getMPIComm() const Line 107  MeshAdapter::getMPIComm() const
107  #endif  #endif
108  }  }
109    
110  Finley_Mesh* MeshAdapter::getFinley_Mesh() const  Mesh* MeshAdapter::getFinley_Mesh() const
111  {  {
112      return m_finleyMesh.get();      return m_finleyMesh.get();
113  }  }
114    
115  void MeshAdapter::write(const string& fileName) const  void MeshAdapter::write(const string& fileName) const
116  {  {
117      Finley_Mesh_write(m_finleyMesh.get(), fileName.c_str());      m_finleyMesh.get()->write(fileName);
118      checkFinleyError();      checkFinleyError();
119  }  }
120    
121  void MeshAdapter::Print_Mesh_Info(const bool full) const  void MeshAdapter::Print_Mesh_Info(const bool full) const
122  {  {
123      Finley_PrintMesh_Info(m_finleyMesh.get(), full);      m_finleyMesh.get()->printInfo(full);
124  }  }
125    
126  void MeshAdapter::dump(const string& fileName) const  void MeshAdapter::dump(const string& fileName) const
# Line 128  void MeshAdapter::dump(const string& fil Line 129  void MeshAdapter::dump(const string& fil
129      const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};      const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
130      NcVar *ids;      NcVar *ids;
131      int *int_ptr;      int *int_ptr;
132      Finley_Mesh *mesh = m_finleyMesh.get();      Mesh *mesh = m_finleyMesh.get();
133      int num_Tags = 0;      int num_Tags = 0;
134      int mpi_size                         = mesh->MPIInfo->size;      int mpi_size                         = mesh->MPIInfo->size;
135      int mpi_rank                         = mesh->MPIInfo->rank;      int mpi_rank                         = mesh->MPIInfo->rank;
# Line 152  void MeshAdapter::dump(const string& fil Line 153  void MeshAdapter::dump(const string& fil
153      }      }
154  #endif  #endif
155    
156      char *newFileName = Esys_MPI_appendRankToFileName(fileName.c_str(),      const std::string newFileName(esysUtils::appendRankToFileName(fileName,
157                                                       mpi_size, mpi_rank);                                                       mpi_size, mpi_rank));
158    
159      // Figure out how much storage is required for tags      // Figure out how much storage is required for tags
160      num_Tags = mesh->tagMap.size();      num_Tags = mesh->tagMap.size();
# Line 161  void MeshAdapter::dump(const string& fil Line 162  void MeshAdapter::dump(const string& fil
162      // NetCDF error handler      // NetCDF error handler
163      NcError err(NcError::verbose_nonfatal);      NcError err(NcError::verbose_nonfatal);
164      // Create the file.      // Create the file.
165      NcFile dataFile(newFileName, NcFile::Replace);      NcFile dataFile(newFileName.c_str(), NcFile::Replace);
166      string msgPrefix("Error in MeshAdapter::dump: NetCDF operation failed - ");      string msgPrefix("Error in MeshAdapter::dump: NetCDF operation failed - ");
167      // check if writing was successful      // check if writing was successful
168      if (!dataFile.is_valid())      if (!dataFile.is_valid())
# Line 201  void MeshAdapter::dump(const string& fil Line 202  void MeshAdapter::dump(const string& fil
202              throw FinleyAdapterException(msgPrefix+"add_dim(dim_Tags)");              throw FinleyAdapterException(msgPrefix+"add_dim(dim_Tags)");
203    
204      // Attributes: MPI size, MPI rank, Name, order, reduced_order      // Attributes: MPI size, MPI rank, Name, order, reduced_order
205      if (!dataFile.add_att("mpi_size", mpi_size) )      if (!dataFile.add_att("mpi_size", mpi_size))
206          throw FinleyAdapterException(msgPrefix+"add_att(mpi_size)");          throw FinleyAdapterException(msgPrefix+"add_att(mpi_size)");
207      if (!dataFile.add_att("mpi_rank", mpi_rank) )      if (!dataFile.add_att("mpi_rank", mpi_rank))
208          throw FinleyAdapterException(msgPrefix+"add_att(mpi_rank)");          throw FinleyAdapterException(msgPrefix+"add_att(mpi_rank)");
209      if (!dataFile.add_att("Name",mesh->Name) )      if (!dataFile.add_att("Name",mesh->m_name.c_str()))
210          throw FinleyAdapterException(msgPrefix+"add_att(Name)");          throw FinleyAdapterException(msgPrefix+"add_att(Name)");
211      if (!dataFile.add_att("numDim",numDim) )      if (!dataFile.add_att("numDim",numDim))
212          throw FinleyAdapterException(msgPrefix+"add_att(order)");          throw FinleyAdapterException(msgPrefix+"add_att(order)");
213      if (!dataFile.add_att("order",mesh->integrationOrder) )      if (!dataFile.add_att("order",mesh->integrationOrder))
214          throw FinleyAdapterException(msgPrefix+"add_att(order)");          throw FinleyAdapterException(msgPrefix+"add_att(order)");
215      if (!dataFile.add_att("reduced_order",mesh->reducedIntegrationOrder) )      if (!dataFile.add_att("reduced_order",mesh->reducedIntegrationOrder))
216          throw FinleyAdapterException(msgPrefix+"add_att(reduced_order)");          throw FinleyAdapterException(msgPrefix+"add_att(reduced_order)");
217      if (!dataFile.add_att("numNodes",numNodes) )      if (!dataFile.add_att("numNodes",numNodes))
218          throw FinleyAdapterException(msgPrefix+"add_att(numNodes)");          throw FinleyAdapterException(msgPrefix+"add_att(numNodes)");
219      if (!dataFile.add_att("num_Elements",num_Elements) )      if (!dataFile.add_att("num_Elements",num_Elements))
220          throw FinleyAdapterException(msgPrefix+"add_att(num_Elements)");          throw FinleyAdapterException(msgPrefix+"add_att(num_Elements)");
221      if (!dataFile.add_att("num_FaceElements",num_FaceElements) )      if (!dataFile.add_att("num_FaceElements",num_FaceElements))
222          throw FinleyAdapterException(msgPrefix+"add_att(num_FaceElements)");          throw FinleyAdapterException(msgPrefix+"add_att(num_FaceElements)");
223      if (!dataFile.add_att("num_ContactElements",num_ContactElements) )      if (!dataFile.add_att("num_ContactElements",num_ContactElements))
224          throw FinleyAdapterException(msgPrefix+"add_att(num_ContactElements)");          throw FinleyAdapterException(msgPrefix+"add_att(num_ContactElements)");
225      if (!dataFile.add_att("num_Points",num_Points) )      if (!dataFile.add_att("num_Points",num_Points))
226          throw FinleyAdapterException(msgPrefix+"add_att(num_Points)");          throw FinleyAdapterException(msgPrefix+"add_att(num_Points)");
227      if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )      if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes))
228          throw FinleyAdapterException(msgPrefix+"add_att(num_Elements_numNodes)");          throw FinleyAdapterException(msgPrefix+"add_att(num_Elements_numNodes)");
229      if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )      if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )
230          throw FinleyAdapterException(msgPrefix+"add_att(num_FaceElements_numNodes)");          throw FinleyAdapterException(msgPrefix+"add_att(num_FaceElements_numNodes)");
# Line 500  void MeshAdapter::dump(const string& fil Line 501  void MeshAdapter::dump(const string& fil
501     // NetCDF file is closed by destructor of NcFile object     // NetCDF file is closed by destructor of NcFile object
502    
503  #else // USE_NETCDF  #else // USE_NETCDF
504      Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with netCDF. Please contact your installation manager.");      setError(IO_ERROR, "MeshAdapter::dump: not configured with netCDF. Please contact your installation manager.");
505  #endif // USE_NETCDF  #endif // USE_NETCDF
506      checkFinleyError();      checkFinleyError();
507  }  }
# Line 628  int MeshAdapter::getDiracDeltaFunctionsC Line 629  int MeshAdapter::getDiracDeltaFunctionsC
629  //  //
630  int MeshAdapter::getDim() const  int MeshAdapter::getDim() const
631  {  {
632      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
633      int numDim=Finley_Mesh_getDim(mesh);      return mesh->getDim();
     checkFinleyError();  
     return numDim;  
634  }  }
635    
636  //  //
# Line 650  pair<int,int> MeshAdapter::getDataShape( Line 649  pair<int,int> MeshAdapter::getDataShape(
649  {  {
650      int numDataPointsPerSample=0;      int numDataPointsPerSample=0;
651      int numSamples=0;      int numSamples=0;
652      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
653      switch (functionSpaceCode) {      switch (functionSpaceCode) {
654          case Nodes:          case Nodes:
655              numDataPointsPerSample=1;              numDataPointsPerSample=1;
# Line 751  void MeshAdapter::addPDEToSystem( Line 750  void MeshAdapter::addPDEToSystem(
750      if (!smat)      if (!smat)
751          throw FinleyAdapterException("finley only supports Paso system matrices.");          throw FinleyAdapterException("finley only supports Paso system matrices.");
752    
753      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
754      Paso_SystemMatrix* S = smat->getPaso_SystemMatrix();      Paso_SystemMatrix* S = smat->getPaso_SystemMatrix();
755      Assemble_PDE(mesh->Nodes, mesh->Elements, S, rhs, A, B, C, D, X, Y);      Assemble_PDE(mesh->Nodes, mesh->Elements, S, rhs, A, B, C, D, X, Y);
756      checkFinleyError();      checkFinleyError();
757    
758    
759      Assemble_PDE(mesh->Nodes, mesh->FaceElements, S, rhs,      Assemble_PDE(mesh->Nodes, mesh->FaceElements, S, rhs,
760              escript::Data(), escript::Data(), escript::Data(), d,              escript::Data(), escript::Data(), escript::Data(), d,
761              escript::Data(), y);              escript::Data(), y);
# Line 775  void MeshAdapter::addPDEToLumpedSystem(e Line 775  void MeshAdapter::addPDEToLumpedSystem(e
775          const escript::Data& D, const escript::Data& d,          const escript::Data& D, const escript::Data& d,
776          const escript::Data& d_dirac, const bool useHRZ) const          const escript::Data& d_dirac, const bool useHRZ) const
777  {  {
778      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
779      Assemble_LumpedSystem(mesh->Nodes, mesh->Elements, mat, D, useHRZ);      Assemble_LumpedSystem(mesh->Nodes, mesh->Elements, mat, D, useHRZ);
780      checkFinleyError();      checkFinleyError();
781    
# Line 793  void MeshAdapter::addPDEToRHS(escript::D Line 793  void MeshAdapter::addPDEToRHS(escript::D
793          const escript::Data& Y, const escript::Data& y,          const escript::Data& Y, const escript::Data& y,
794          const escript::Data& y_contact, const escript::Data& y_dirac) const          const escript::Data& y_contact, const escript::Data& y_dirac) const
795  {  {
796      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
797      Assemble_PDE(mesh->Nodes, mesh->Elements, 0, rhs,      Assemble_PDE(mesh->Nodes, mesh->Elements, 0, rhs,
798              escript::Data(), escript::Data(), escript::Data(), escript::Data(),              escript::Data(), escript::Data(), escript::Data(), escript::Data(),
799              X, Y);              X, Y);
# Line 832  void MeshAdapter::addPDEToTransportProbl Line 832  void MeshAdapter::addPDEToTransportProbl
832    
833      source.expand();      source.expand();
834    
835      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
836      Paso_TransportProblem* _tp = tpa->getPaso_TransportProblem();      Paso_TransportProblem* _tp = tpa->getPaso_TransportProblem();
837    
838      Assemble_PDE(mesh->Nodes, mesh->Elements, _tp->mass_matrix, source,      Assemble_PDE(mesh->Nodes, mesh->Elements, _tp->mass_matrix, source,
# Line 873  void MeshAdapter::interpolateOnDomain(es Line 873  void MeshAdapter::interpolateOnDomain(es
873      if (targetDomain!=*this)      if (targetDomain!=*this)
874          throw FinleyAdapterException("Error - Illegal domain of interpolation target.");          throw FinleyAdapterException("Error - Illegal domain of interpolation target.");
875    
876      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
877      switch(in.getFunctionSpace().getTypeCode()) {      switch(in.getFunctionSpace().getTypeCode()) {
878          case Nodes:          case Nodes:
879              switch(target.getFunctionSpace().getTypeCode()) {              switch(target.getFunctionSpace().getTypeCode()) {
# Line 1135  void MeshAdapter::setToX(escript::Data& Line 1135  void MeshAdapter::setToX(escript::Data&
1135      const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));      const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1136      if (argDomain!=*this)      if (argDomain!=*this)
1137          throw FinleyAdapterException("Error - Illegal domain of data point locations");          throw FinleyAdapterException("Error - Illegal domain of data point locations");
1138      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1139      // in case of appropriate function space we can do the job directly:      // in case of appropriate function space we can do the job directly:
1140      if (arg.getFunctionSpace().getTypeCode()==Nodes) {      if (arg.getFunctionSpace().getTypeCode()==Nodes) {
1141          Assemble_NodeCoordinates(mesh->Nodes, arg);          Assemble_NodeCoordinates(mesh->Nodes, arg);
# Line 1156  void MeshAdapter::setToNormal(escript::D Line 1156  void MeshAdapter::setToNormal(escript::D
1156      const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));      const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));
1157      if (normalDomain!=*this)      if (normalDomain!=*this)
1158          throw FinleyAdapterException("Error - Illegal domain of normal locations");          throw FinleyAdapterException("Error - Illegal domain of normal locations");
1159      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1160      switch(normal.getFunctionSpace().getTypeCode()) {      switch(normal.getFunctionSpace().getTypeCode()) {
1161          case Nodes:          case Nodes:
1162              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
# Line 1172  void MeshAdapter::setToNormal(escript::D Line 1172  void MeshAdapter::setToNormal(escript::D
1172              break;              break;
1173          case FaceElements:          case FaceElements:
1174          case ReducedFaceElements:          case ReducedFaceElements:
1175              Assemble_setNormal(mesh->Nodes, mesh->FaceElements, normal);              Assemble_getNormal(mesh->Nodes, mesh->FaceElements, normal);
1176              break;              break;
1177          case Points:          case Points:
1178              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");
# Line 1181  void MeshAdapter::setToNormal(escript::D Line 1181  void MeshAdapter::setToNormal(escript::D
1181          case ContactElementsZero:          case ContactElementsZero:
1182          case ReducedContactElementsOne:          case ReducedContactElementsOne:
1183          case ReducedContactElementsZero:          case ReducedContactElementsZero:
1184              Assemble_setNormal(mesh->Nodes, mesh->ContactElements, normal);              Assemble_getNormal(mesh->Nodes, mesh->ContactElements, normal);
1185              break;              break;
1186          case DegreesOfFreedom:          case DegreesOfFreedom:
1187              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");              throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");
# Line 1216  void MeshAdapter::setToIntegrals(vector< Line 1216  void MeshAdapter::setToIntegrals(vector<
1216          throw FinleyAdapterException("Error - Illegal domain of integration kernel");          throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1217    
1218      double blocktimer_start = blocktimer_time();      double blocktimer_start = blocktimer_time();
1219      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1220      switch(arg.getFunctionSpace().getTypeCode()) {      switch(arg.getFunctionSpace().getTypeCode()) {
1221          case Nodes:          case Nodes:
1222              {              {
# Line 1276  void MeshAdapter::setToGradient(escript: Line 1276  void MeshAdapter::setToGradient(escript:
1276      if (gradDomain!=*this)      if (gradDomain!=*this)
1277          throw FinleyAdapterException("Error - Illegal domain of gradient");          throw FinleyAdapterException("Error - Illegal domain of gradient");
1278    
1279      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1280      escript::Data nodeData;      escript::Data nodeData;
1281      if (getMPISize()>1) {      if (getMPISize()>1) {
1282          if (arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom) {          if (arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom) {
# Line 1333  void MeshAdapter::setToGradient(escript: Line 1333  void MeshAdapter::setToGradient(escript:
1333  //  //
1334  void MeshAdapter::setToSize(escript::Data& size) const  void MeshAdapter::setToSize(escript::Data& size) const
1335  {  {
1336      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1337      switch(size.getFunctionSpace().getTypeCode()) {      switch(size.getFunctionSpace().getTypeCode()) {
1338          case Nodes:          case Nodes:
1339              throw FinleyAdapterException("Error - Size of nodes is not supported.");              throw FinleyAdapterException("Error - Size of nodes is not supported.");
# Line 1378  void MeshAdapter::setToSize(escript::Dat Line 1378  void MeshAdapter::setToSize(escript::Dat
1378  //  //
1379  void MeshAdapter::setNewX(const escript::Data& new_x)  void MeshAdapter::setNewX(const escript::Data& new_x)
1380  {  {
1381      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1382      const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));      const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1383      if (newDomain!=*this)      if (newDomain!=*this)
1384          throw FinleyAdapterException("Error - Illegal domain of new point locations");          throw FinleyAdapterException("Error - Illegal domain of new point locations");
1385      if (new_x.getFunctionSpace() == continuousFunction(*this)) {      if (new_x.getFunctionSpace() == continuousFunction(*this)) {
1386          Finley_Mesh_setCoordinates(mesh, new_x);          mesh->setCoordinates(new_x);
1387      } else {      } else {
1388          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.");
1389      }      }
# Line 1396  bool MeshAdapter::ownSample(int fs_code, Line 1396  bool MeshAdapter::ownSample(int fs_code,
1396  #ifdef ESYS_MPI  #ifdef ESYS_MPI
1397          int myFirstNode=0, myLastNode=0, k=0;          int myFirstNode=0, myLastNode=0, k=0;
1398          int* globalNodeIndex=0;          int* globalNodeIndex=0;
1399          Finley_Mesh* mesh_p=m_finleyMesh.get();          Mesh* mesh_p=m_finleyMesh.get();
1400          /*          /*
1401           * this method is only used by saveDataCSV which would use the returned           * this method is only used by saveDataCSV which would use the returned
1402           * values for reduced nodes wrongly so this case is disabled for now           * values for reduced nodes wrongly so this case is disabled for now
1403          if (fs_code == FINLEY_REDUCED_NODES) {          if (fs_code == FINLEY_REDUCED_NODES) {
1404              myFirstNode = Finley_NodeFile_getFirstReducedNode(mesh_p->Nodes);              myFirstNode = NodeFile_getFirstReducedNode(mesh_p->Nodes);
1405              myLastNode = Finley_NodeFile_getLastReducedNode(mesh_p->Nodes);              myLastNode = NodeFile_getLastReducedNode(mesh_p->Nodes);
1406              globalNodeIndex = Finley_NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);              globalNodeIndex = NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);
1407          } else          } else
1408          */          */
1409          if (fs_code == FINLEY_NODES) {          if (fs_code == FINLEY_NODES) {
# Line 1454  escript::ASM_ptr MeshAdapter::newSystemM Line 1454  escript::ASM_ptr MeshAdapter::newSystemM
1454      }      }
1455    
1456      // generate matrix:      // generate matrix:
1457      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(      Paso_SystemMatrixPattern* fsystemMatrixPattern=
1458              getFinley_Mesh(), reduceRowOrder, reduceColOrder);          getFinley_Mesh()->getPattern(reduceRowOrder, reduceColOrder);
1459      checkFinleyError();      checkFinleyError();
1460      Paso_SystemMatrix* fsystemMatrix;      Paso_SystemMatrix* fsystemMatrix;
1461      const int trilinos = 0;      const int trilinos = 0;
# Line 1493  escript::ATP_ptr MeshAdapter::newTranspo Line 1493  escript::ATP_ptr MeshAdapter::newTranspo
1493      }      }
1494    
1495      // generate transport problem:      // generate transport problem:
1496      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(      Paso_SystemMatrixPattern* fsystemMatrixPattern=
1497              getFinley_Mesh(), reduceOrder, reduceOrder);          getFinley_Mesh()->getPattern(reduceOrder, reduceOrder);
1498      checkFinleyError();      checkFinleyError();
1499      Paso_TransportProblem* transportProblem;      Paso_TransportProblem* transportProblem;
1500      transportProblem=Paso_TransportProblem_alloc(fsystemMatrixPattern, blocksize);      transportProblem=Paso_TransportProblem_alloc(fsystemMatrixPattern, blocksize);
# Line 1845  bool MeshAdapter::operator!=(const escri Line 1845  bool MeshAdapter::operator!=(const escri
1845    
1846  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1847  {  {
1848      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1849      return SystemMatrixAdapter::getSystemMatrixTypeId(solver, preconditioner,      return SystemMatrixAdapter::getSystemMatrixTypeId(solver, preconditioner,
1850                 package, symmetry, mesh->MPIInfo);                 package, symmetry, mesh->MPIInfo);
1851  }  }
1852    
1853  int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const  int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1854  {  {
1855      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1856      return TransportProblemAdapter::getTransportTypeId(solver, preconditioner,      return TransportProblemAdapter::getTransportTypeId(solver, preconditioner,
1857                  package, symmetry, mesh->MPIInfo);                  package, symmetry, mesh->MPIInfo);
1858  }  }
# Line 1875  escript::Data MeshAdapter::getSize() con Line 1875  escript::Data MeshAdapter::getSize() con
1875  const int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  const int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1876  {  {
1877      int *out = NULL;      int *out = NULL;
1878      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1879      switch (functionSpaceType) {      switch (functionSpaceType) {
1880          case Nodes:          case Nodes:
1881              out=mesh->Nodes->Id;              out=mesh->Nodes->Id;
# Line 1917  const int* MeshAdapter::borrowSampleRefe Line 1917  const int* MeshAdapter::borrowSampleRefe
1917  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1918  {  {
1919      int out=0;      int out=0;
1920      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1921      switch (functionSpaceType) {      switch (functionSpaceType) {
1922          case Nodes:          case Nodes:
1923              out=mesh->Nodes->Tag[sampleNo];              out=mesh->Nodes->Tag[sampleNo];
# Line 1960  int MeshAdapter::getTagFromSampleNo(int Line 1960  int MeshAdapter::getTagFromSampleNo(int
1960    
1961  void MeshAdapter::setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const  void MeshAdapter::setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const
1962  {  {
1963      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
1964      switch(functionSpaceType) {      switch(functionSpaceType) {
1965          case Nodes:          case Nodes:
1966              mesh->Nodes->setTags(newTag, mask);              mesh->Nodes->setTags(newTag, mask);
# Line 1998  void MeshAdapter::setTags(const int func Line 1998  void MeshAdapter::setTags(const int func
1998    
1999  void MeshAdapter::setTagMap(const string& name, int tag)  void MeshAdapter::setTagMap(const string& name, int tag)
2000  {  {
2001      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2002      Finley_Mesh_addTagMap(mesh, name.c_str(), tag);      mesh->addTagMap(name.c_str(), tag);
2003      checkFinleyError();      checkFinleyError();
2004  }  }
2005    
2006  int MeshAdapter::getTag(const string& name) const  int MeshAdapter::getTag(const string& name) const
2007  {  {
2008      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2009      int tag = Finley_Mesh_getTag(mesh, name.c_str());      int tag = mesh->getTag(name.c_str());
2010      checkFinleyError();      checkFinleyError();
2011      return tag;      return tag;
2012  }  }
2013    
2014  bool MeshAdapter::isValidTagName(const string& name) const  bool MeshAdapter::isValidTagName(const string& name) const
2015  {  {
2016      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2017      return Finley_Mesh_isValidTagName(mesh, name.c_str());      return mesh->isValidTagName(name.c_str());
2018  }  }
2019    
2020  string MeshAdapter::showTagNames() const  string MeshAdapter::showTagNames() const
2021  {  {
2022      stringstream temp;      stringstream temp;
2023      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2024      TagMap::const_iterator it = mesh->tagMap.begin();      TagMap::const_iterator it = mesh->tagMap.begin();
2025      while (it != mesh->tagMap.end()) {      while (it != mesh->tagMap.end()) {
2026          temp << it->first;          temp << it->first;
# Line 2033  string MeshAdapter::showTagNames() const Line 2033  string MeshAdapter::showTagNames() const
2033    
2034  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const
2035  {  {
2036      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2037      switch(functionSpaceCode) {      switch(functionSpaceCode) {
2038          case Nodes:          case Nodes:
2039              return mesh->Nodes->tagsInUse.size();              return mesh->Nodes->tagsInUse.size();
# Line 2067  int MeshAdapter::getNumberOfTagsInUse(in Line 2067  int MeshAdapter::getNumberOfTagsInUse(in
2067    
2068  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const
2069  {  {
2070      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2071      switch(functionSpaceCode) {      switch(functionSpaceCode) {
2072          case Nodes:          case Nodes:
2073              return &mesh->Nodes->tagsInUse[0];              return &mesh->Nodes->tagsInUse[0];
# Line 2120  bool MeshAdapter::canTag(int functionSpa Line 2120  bool MeshAdapter::canTag(int functionSpa
2120    
2121  escript::AbstractDomain::StatusType MeshAdapter::getStatus() const  escript::AbstractDomain::StatusType MeshAdapter::getStatus() const
2122  {  {
2123      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2124      return Finley_Mesh_getStatus(mesh);      return mesh->getStatus();
2125  }  }
2126    
2127  int MeshAdapter::getApproximationOrder(const int functionSpaceCode) const  int MeshAdapter::getApproximationOrder(const int functionSpaceCode) const
2128  {  {
2129      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2130      int order =-1;      int order =-1;
2131      switch(functionSpaceCode) {      switch(functionSpaceCode) {
2132          case Nodes:          case Nodes:
# Line 2163  bool MeshAdapter::supportsContactElement Line 2163  bool MeshAdapter::supportsContactElement
2163      return true;      return true;
2164  }  }
2165    
 ReferenceElementSetWrapper::ReferenceElementSetWrapper(Finley_ElementTypeId id,  
         index_t order, index_t reducedOrder)  
 {  
     m_refSet = Finley_ReferenceElementSet_alloc(id, order, reducedOrder);  
 }  
   
 ReferenceElementSetWrapper::~ReferenceElementSetWrapper()  
 {  
     Finley_ReferenceElementSet_dealloc(m_refSet);  
 }  
   
2166  void MeshAdapter::addDiracPoints(const vector<double>& points,  void MeshAdapter::addDiracPoints(const vector<double>& points,
2167                                   const vector<int>& tags) const                                   const vector<int>& tags) const
2168  {  {
# Line 2181  void MeshAdapter::addDiracPoints(const v Line 2170  void MeshAdapter::addDiracPoints(const v
2170      const int dim = getDim();      const int dim = getDim();
2171      int numPoints=points.size()/dim;      int numPoints=points.size()/dim;
2172      int numTags=tags.size();      int numTags=tags.size();
2173      Finley_Mesh* mesh=m_finleyMesh.get();      Mesh* mesh=m_finleyMesh.get();
2174    
2175      if ( points.size() % dim != 0 ) {      if ( points.size() % dim != 0 ) {
2176          throw FinleyAdapterException("Error - number of coords does not appear to be a multiple of dimension.");          throw FinleyAdapterException("Error - number of coords does not appear to be a multiple of dimension.");
# Line 2190  void MeshAdapter::addDiracPoints(const v Line 2179  void MeshAdapter::addDiracPoints(const v
2179      if ((numTags > 0) && (numPoints != numTags))      if ((numTags > 0) && (numPoints != numTags))
2180          throw FinleyAdapterException("Error - if tags are given number of tags and points must match.");          throw FinleyAdapterException("Error - if tags are given number of tags and points must match.");
2181    
2182      Finley_Mesh_addPoints(mesh, numPoints, &points[0], &tags[0]);      mesh->addPoints(numPoints, &points[0], &tags[0]);
2183      checkFinleyError();      checkFinleyError();
2184  }  }
2185    
# Line 2199  void MeshAdapter::addDiracPoints(const v Line 2188  void MeshAdapter::addDiracPoints(const v
2188  //       const int dim = getDim();  //       const int dim = getDim();
2189  //       int numPoints=boost::python::extract<int>(points.attr("__len__")());  //       int numPoints=boost::python::extract<int>(points.attr("__len__")());
2190  //       int numTags=boost::python::extract<int>(tags.attr("__len__")());  //       int numTags=boost::python::extract<int>(tags.attr("__len__")());
2191  //       Finley_Mesh* mesh=m_finleyMesh.get();  //       Mesh* mesh=m_finleyMesh.get();
2192  //  //
2193  //       if  ( (numTags > 0) && ( numPoints !=  numTags ) )  //       if  ( (numTags > 0) && ( numPoints !=  numTags ) )
2194  //       throw FinleyAdapterException("Error - if tags are given number of tags and points must match.");  //       throw FinleyAdapterException("Error - if tags are given number of tags and points must match.");

Legend:
Removed from v.4441  
changed lines
  Added in v.4657

  ViewVC Help
Powered by ViewVC 1.1.26