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

revision 1801 by ksteube, Fri Sep 19 01:37:09 2008 UTC revision 1877 by ksteube, Tue Oct 14 02:58:39 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #include "MeshAdapter.h"  #include "MeshAdapter.h"
16  #include "escript/Data.h"  #include "escript/Data.h"
# Line 87  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 861  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 1146  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 1169  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 1224  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 MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(*(target.getFunctionSpace().getDomain()));
1239     if (targetDomain!=*this)     if (targetDomain!=*this)
1240        throw FinleyAdapterException("Error - Illegal domain of interpolation target");        throw FinleyAdapterException("Error - Illegal domain of interpolation target");
1241    
# Line 1236  void MeshAdapter::interpolateACross(escr Line 1247  void MeshAdapter::interpolateACross(escr
1247  //  //
1248  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
1249  {  {
1250     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1251     if (argDomain!=*this)     if (argDomain!=*this)
1252        throw FinleyAdapterException("Error - Illegal domain of integration kernel");        throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1253    
# Line 1247  void MeshAdapter::setToIntegrals(std::ve Line 1258  void MeshAdapter::setToIntegrals(std::ve
1258     escriptDataC _arg=arg.getDataC();     escriptDataC _arg=arg.getDataC();
1259     switch(arg.getFunctionSpace().getTypeCode()) {     switch(arg.getFunctionSpace().getTypeCode()) {
1260     case(Nodes):     case(Nodes):
1261     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1262     _temp=temp.getDataC();     _temp=temp.getDataC();
1263     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1264     break;     break;
1265     case(ReducedNodes):     case(ReducedNodes):
1266     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1267     _temp=temp.getDataC();     _temp=temp.getDataC();
1268     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1269     break;     break;
# Line 1284  void MeshAdapter::setToIntegrals(std::ve Line 1295  void MeshAdapter::setToIntegrals(std::ve
1295     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1296     break;     break;
1297     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1298     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1299     _temp=temp.getDataC();     _temp=temp.getDataC();
1300     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1301     break;     break;
1302     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1303     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1304     _temp=temp.getDataC();     _temp=temp.getDataC();
1305     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1306     break;     break;
# Line 1308  void MeshAdapter::setToIntegrals(std::ve Line 1319  void MeshAdapter::setToIntegrals(std::ve
1319  //  //
1320  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
1321  {  {
1322     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1323     if (argDomain!=*this)     if (argDomain!=*this)
1324        throw FinleyAdapterException("Error - Illegal domain of gradient argument");        throw FinleyAdapterException("Error - Illegal domain of gradient argument");
1325     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(*(grad.getFunctionSpace().getDomain()));
1326     if (gradDomain!=*this)     if (gradDomain!=*this)
1327        throw FinleyAdapterException("Error - Illegal domain of gradient");        throw FinleyAdapterException("Error - Illegal domain of gradient");
1328    
# Line 1438  void MeshAdapter::setNewX(const escript: Line 1449  void MeshAdapter::setNewX(const escript:
1449  {  {
1450     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1451     escriptDataC tmp;     escriptDataC tmp;
1452     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1453     if (newDomain!=*this)     if (newDomain!=*this)
1454        throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw FinleyAdapterException("Error - Illegal domain of new point locations");
1455     tmp = new_x.getDataC();     tmp = new_x.getDataC();
# Line 1465  void MeshAdapter::saveDX(const std::stri Line 1476  void MeshAdapter::saveDX(const std::stri
1476     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1477        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1478        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1479        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1480           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1481        data[i]=d.getDataC();        data[i]=d.getDataC();
1482        ptr_data[i]= &(data[i]);        ptr_data[i]= &(data[i]);
# Line 1510  void MeshAdapter::saveVTK(const std::str Line 1521  void MeshAdapter::saveVTK(const std::str
1521     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1522        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1523        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1524        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1525           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1526        data[i]=d.getDataC();        data[i]=d.getDataC();
1527        ptr_data[i]=&(data[i]);        ptr_data[i]=&(data[i]);
# Line 1548  SystemMatrixAdapter MeshAdapter::newSyst Line 1559  SystemMatrixAdapter MeshAdapter::newSyst
1559     int reduceRowOrder=0;     int reduceRowOrder=0;
1560     int reduceColOrder=0;     int reduceColOrder=0;
1561     // is the domain right?     // is the domain right?
1562     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(*(row_functionspace.getDomain()));
1563     if (row_domain!=*this)     if (row_domain!=*this)
1564        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.");
1565     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(*(column_functionspace.getDomain()));
1566     if (col_domain!=*this)     if (col_domain!=*this)
1567        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.");
1568     // is the function space type right     // is the function space type right
# Line 1596  TransportProblemAdapter MeshAdapter::new Line 1607  TransportProblemAdapter MeshAdapter::new
1607  {  {
1608     int reduceOrder=0;     int reduceOrder=0;
1609     // is the domain right?     // is the domain right?
1610     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(functionspace.getDomain());     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(*(functionspace.getDomain()));
1611     if (domain!=*this)     if (domain!=*this)
1612        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.");
1613     // is the function space type right     // is the function space type right
# Line 1827  bool MeshAdapter::operator!=(const Abstr Line 1838  bool MeshAdapter::operator!=(const Abstr
1838     return !(operator==(other));     return !(operator==(other));
1839  }  }
1840    
1841  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1842  {  {
1843     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1844       checkPasoError();
1845       return out;
1846    }
1847    int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1848    {
1849       int out=Paso_FCTransportProblem_getTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1850     checkPasoError();     checkPasoError();
1851     return out;     return out;
1852  }  }
# Line 1846  escript::Data MeshAdapter::getNormal() c Line 1863  escript::Data MeshAdapter::getNormal() c
1863    
1864  escript::Data MeshAdapter::getSize() const  escript::Data MeshAdapter::getSize() const
1865  {  {
1866     return function(asAbstractContinuousDomain()).getSize();     return escript::function(asAbstractContinuousDomain()).getSize();
1867  }  }
1868    
1869  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
# Line 2129  int* MeshAdapter::borrowListOfTagsInUse( Line 2146  int* MeshAdapter::borrowListOfTagsInUse(
2146  }  }
2147    
2148    
2149    bool MeshAdapter::canTag(int functionSpaceCode) const
2150    {
2151      switch(functionSpaceCode) {
2152       case(Nodes):
2153       case(Elements):
2154       case(ReducedElements):
2155       case(FaceElements):
2156       case(ReducedFaceElements):
2157       case(Points):
2158       case(ContactElementsZero):
2159       case(ReducedContactElementsZero):
2160       case(ContactElementsOne):
2161       case(ReducedContactElementsOne):
2162              return true;
2163       case(ReducedNodes):
2164       case(DegreesOfFreedom):
2165       case(ReducedDegreesOfFreedom):
2166          return false;
2167       default:
2168        return false;
2169      }
2170    }
2171    
2172    
2173  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.1801  
changed lines
  Added in v.1877

  ViewVC Help
Powered by ViewVC 1.1.26