/[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 1859 by gross, Wed Oct 8 03:03:37 2008 UTC revision 2087 by jfenwick, Mon Nov 24 04:51:30 2008 UTC
# Line 23  Line 23 
23  #include "paso/Paso_MPI.h"  #include "paso/Paso_MPI.h"
24  #endif  #endif
25  extern "C" {  extern "C" {
26  #include "escript/blocktimer.h"  #include "esysUtils/blocktimer.h"
27  }  }
28  #include <vector>  #include <vector>
29    
# Line 86  int MeshAdapter::getMPIRank() const Line 86  int MeshAdapter::getMPIRank() const
86  {  {
87     return m_finleyMesh.get()->MPIInfo->rank;     return m_finleyMesh.get()->MPIInfo->rank;
88  }  }
89    void MeshAdapter::MPIBarrier() const
90    {
91    #ifdef PASO_MPI
92       MPI_Barrier(m_finleyMesh.get()->MPIInfo->comm);
93    #endif
94       return;
95    }
96    bool MeshAdapter::onMasterProcessor() const
97    {
98       return m_finleyMesh.get()->MPIInfo->rank == 0;
99    }
100    
101    
102  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
# Line 109  void MeshAdapter::Print_Mesh_Info(const Line 120  void MeshAdapter::Print_Mesh_Info(const
120  void MeshAdapter::dump(const std::string& fileName) const  void MeshAdapter::dump(const std::string& fileName) const
121  {  {
122  #ifdef USE_NETCDF  #ifdef USE_NETCDF
123     const NcDim* ncdims[12];     const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
124     NcVar *ids;     NcVar *ids;
125     int *int_ptr;     int *int_ptr;
126     Finley_Mesh *mesh = m_finleyMesh.get();     Finley_Mesh *mesh = m_finleyMesh.get();
# Line 860  void MeshAdapter::addPDEToTransportProbl Line 871  void MeshAdapter::addPDEToTransportProbl
871  //  //
872  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const
873  {  {
874     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(*(in.getFunctionSpace().getDomain()));
875     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(*(target.getFunctionSpace().getDomain()));
876     if (inDomain!=*this)       if (inDomain!=*this)  
877        throw FinleyAdapterException("Error - Illegal domain of interpolant.");        throw FinleyAdapterException("Error - Illegal domain of interpolant.");
878     if (targetDomain!=*this)     if (targetDomain!=*this)
# Line 1145  void MeshAdapter::interpolateOnDomain(es Line 1156  void MeshAdapter::interpolateOnDomain(es
1156  //  //
1157  void MeshAdapter::setToX(escript::Data& arg) const  void MeshAdapter::setToX(escript::Data& arg) const
1158  {  {
1159     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1160     if (argDomain!=*this)     if (argDomain!=*this)
1161        throw FinleyAdapterException("Error - Illegal domain of data point locations");        throw FinleyAdapterException("Error - Illegal domain of data point locations");
1162     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
# Line 1168  void MeshAdapter::setToX(escript::Data& Line 1179  void MeshAdapter::setToX(escript::Data&
1179  //  //
1180  void MeshAdapter::setToNormal(escript::Data& normal) const  void MeshAdapter::setToNormal(escript::Data& normal) const
1181  {  {
1182     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());  /*   const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());*/
1183       const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));
1184     if (normalDomain!=*this)     if (normalDomain!=*this)
1185        throw FinleyAdapterException("Error - Illegal domain of normal locations");        throw FinleyAdapterException("Error - Illegal domain of normal locations");
1186     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
# Line 1223  void MeshAdapter::setToNormal(escript::D Line 1235  void MeshAdapter::setToNormal(escript::D
1235  //  //
1236  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const
1237  {  {
1238     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const_Domain_ptr targetDomain_p=target.getFunctionSpace().getDomain();
1239     if (targetDomain!=*this)     const MeshAdapter* targetDomain=dynamic_cast<const MeshAdapter*>(targetDomain_p.get());
1240       if (targetDomain!=this)
1241        throw FinleyAdapterException("Error - Illegal domain of interpolation target");        throw FinleyAdapterException("Error - Illegal domain of interpolation target");
1242    
1243     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
# Line 1235  void MeshAdapter::interpolateACross(escr Line 1248  void MeshAdapter::interpolateACross(escr
1248  //  //
1249  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
1250  {  {
1251     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1252     if (argDomain!=*this)     if (argDomain!=*this)
1253        throw FinleyAdapterException("Error - Illegal domain of integration kernel");        throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1254    
# Line 1246  void MeshAdapter::setToIntegrals(std::ve Line 1259  void MeshAdapter::setToIntegrals(std::ve
1259     escriptDataC _arg=arg.getDataC();     escriptDataC _arg=arg.getDataC();
1260     switch(arg.getFunctionSpace().getTypeCode()) {     switch(arg.getFunctionSpace().getTypeCode()) {
1261     case(Nodes):     case(Nodes):
1262     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1263     _temp=temp.getDataC();     _temp=temp.getDataC();
1264     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1265     break;     break;
1266     case(ReducedNodes):     case(ReducedNodes):
1267     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1268     _temp=temp.getDataC();     _temp=temp.getDataC();
1269     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1270     break;     break;
# Line 1283  void MeshAdapter::setToIntegrals(std::ve Line 1296  void MeshAdapter::setToIntegrals(std::ve
1296     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1297     break;     break;
1298     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1299     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1300     _temp=temp.getDataC();     _temp=temp.getDataC();
1301     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1302     break;     break;
1303     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1304     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1305     _temp=temp.getDataC();     _temp=temp.getDataC();
1306     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1307     break;     break;
# Line 1307  void MeshAdapter::setToIntegrals(std::ve Line 1320  void MeshAdapter::setToIntegrals(std::ve
1320  //  //
1321  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
1322  {  {
1323     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1324     if (argDomain!=*this)     if (argDomain!=*this)
1325        throw FinleyAdapterException("Error - Illegal domain of gradient argument");        throw FinleyAdapterException("Error - Illegal domain of gradient argument");
1326     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(*(grad.getFunctionSpace().getDomain()));
1327     if (gradDomain!=*this)     if (gradDomain!=*this)
1328        throw FinleyAdapterException("Error - Illegal domain of gradient");        throw FinleyAdapterException("Error - Illegal domain of gradient");
1329    
# Line 1437  void MeshAdapter::setNewX(const escript: Line 1450  void MeshAdapter::setNewX(const escript:
1450  {  {
1451     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1452     escriptDataC tmp;     escriptDataC tmp;
1453     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1454     if (newDomain!=*this)     if (newDomain!=*this)
1455        throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw FinleyAdapterException("Error - Illegal domain of new point locations");
1456     tmp = new_x.getDataC();     tmp = new_x.getDataC();
# Line 1464  void MeshAdapter::saveDX(const std::stri Line 1477  void MeshAdapter::saveDX(const std::stri
1477     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1478        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1479        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1480        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1481           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1482        data[i]=d.getDataC();        data[i]=d.getDataC();
1483        ptr_data[i]= &(data[i]);        ptr_data[i]= &(data[i]);
# Line 1509  void MeshAdapter::saveVTK(const std::str Line 1522  void MeshAdapter::saveVTK(const std::str
1522     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1523        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1524        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1525        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1526           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1527        data[i]=d.getDataC();        data[i]=d.getDataC();
1528        ptr_data[i]=&(data[i]);        ptr_data[i]=&(data[i]);
# Line 1547  SystemMatrixAdapter MeshAdapter::newSyst Line 1560  SystemMatrixAdapter MeshAdapter::newSyst
1560     int reduceRowOrder=0;     int reduceRowOrder=0;
1561     int reduceColOrder=0;     int reduceColOrder=0;
1562     // is the domain right?     // is the domain right?
1563     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(*(row_functionspace.getDomain()));
1564     if (row_domain!=*this)     if (row_domain!=*this)
1565        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");
1566     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(*(column_functionspace.getDomain()));
1567     if (col_domain!=*this)     if (col_domain!=*this)
1568        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");
1569     // is the function space type right     // is the function space type right
# Line 1595  TransportProblemAdapter MeshAdapter::new Line 1608  TransportProblemAdapter MeshAdapter::new
1608  {  {
1609     int reduceOrder=0;     int reduceOrder=0;
1610     // is the domain right?     // is the domain right?
1611     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(functionspace.getDomain());     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(*(functionspace.getDomain()));
1612     if (domain!=*this)     if (domain!=*this)
1613        throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");        throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");
1614     // is the function space type right     // is the function space type right
# Line 1851  escript::Data MeshAdapter::getNormal() c Line 1864  escript::Data MeshAdapter::getNormal() c
1864    
1865  escript::Data MeshAdapter::getSize() const  escript::Data MeshAdapter::getSize() const
1866  {  {
1867     return function(asAbstractContinuousDomain()).getSize();     return escript::function(asAbstractContinuousDomain()).getSize();
1868  }  }
1869    
1870  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const

Legend:
Removed from v.1859  
changed lines
  Added in v.2087

  ViewVC Help
Powered by ViewVC 1.1.26