/[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 472 by jgs, Fri Jan 27 01:50:59 2006 UTC revision 532 by gross, Wed Feb 15 09:45:53 2006 UTC
# Line 15  Line 15 
15    
16  #include "MeshAdapter.h"  #include "MeshAdapter.h"
17    
18    #include "Data.h"
19    #include "DataFactory.h"
20    
21  using namespace std;  using namespace std;
22  using namespace escript;  using namespace escript;
23    
# Line 386  pair<int,int> MeshAdapter::getDataShape( Line 389  pair<int,int> MeshAdapter::getDataShape(
389  // 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:
390  //  //
391  void MeshAdapter::addPDEToSystem(  void MeshAdapter::addPDEToSystem(
392                       SystemMatrixAdapter& mat, Data& rhs,                       SystemMatrixAdapter& mat, escript::Data& rhs,
393                       const Data& A, const Data& B, const Data& C,const  Data& D,const  Data& X,const  Data& Y,                       const escript::Data& A, const escript::Data& B, const escript::Data& C,const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,
394                       const Data& d, const Data& y,                       const escript::Data& d, const escript::Data& y,
395                       const Data& d_contact,const Data& y_contact) const                       const escript::Data& d_contact,const escript::Data& y_contact) const
396  {  {
397     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
398     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(),&(rhs.getDataC()),     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(),&(rhs.getDataC()),
# Line 413  void MeshAdapter::addPDEToSystem( Line 416  void MeshAdapter::addPDEToSystem(
416  //  //
417  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
418  //  //
419  void MeshAdapter::addPDEToRHS( Data& rhs,  void MeshAdapter::addPDEToRHS( escript::Data& rhs,
420                       const  Data& X,const  Data& Y, const Data& y, const Data& y_contact) const                       const  escript::Data& X,const  escript::Data& Y, const escript::Data& y, const escript::Data& y_contact) const
421  {  {
422     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
423    
# Line 434  void MeshAdapter::addPDEToRHS( Data& rhs Line 437  void MeshAdapter::addPDEToRHS( Data& rhs
437  //  //
438  // interpolates data between different function spaces:  // interpolates data between different function spaces:
439  //  //
440  void MeshAdapter::interpolateOnDomain(Data& target,const Data& in) const  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const
441  {  {
442    const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());    const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());
443    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
# Line 575  void MeshAdapter::interpolateOnDomain(Da Line 578  void MeshAdapter::interpolateOnDomain(Da
578  //  //
579  // copies the locations of sample points into x:  // copies the locations of sample points into x:
580  //  //
581  void MeshAdapter::setToX(Data& arg) const  void MeshAdapter::setToX(escript::Data& arg) const
582  {  {
583    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
584    if (argDomain!=*this)    if (argDomain!=*this)
# Line 585  void MeshAdapter::setToX(Data& arg) cons Line 588  void MeshAdapter::setToX(Data& arg) cons
588    if (arg.getFunctionSpace().getTypeCode()==Nodes) {    if (arg.getFunctionSpace().getTypeCode()==Nodes) {
589       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(arg.getDataC()));       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(arg.getDataC()));
590    } else {    } else {
591       Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);       escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);
592       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(tmp_data.getDataC()));       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(tmp_data.getDataC()));
593       // this is then interpolated onto arg:       // this is then interpolated onto arg:
594       interpolateOnDomain(arg,tmp_data);       interpolateOnDomain(arg,tmp_data);
# Line 596  void MeshAdapter::setToX(Data& arg) cons Line 599  void MeshAdapter::setToX(Data& arg) cons
599  //  //
600  // 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:
601  //  //
602  void MeshAdapter::setToNormal(Data& normal) const  void MeshAdapter::setToNormal(escript::Data& normal) const
603  {  {
604    const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());    const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());
605    if (normalDomain!=*this)    if (normalDomain!=*this)
# Line 637  void MeshAdapter::setToNormal(Data& norm Line 640  void MeshAdapter::setToNormal(Data& norm
640  //  //
641  // interpolates data to other domain:  // interpolates data to other domain:
642  //  //
643  void MeshAdapter::interpolateACross(Data& target,const Data& source) const  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const
644  {  {
645    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
646    if (targetDomain!=*this)    if (targetDomain!=*this)
# Line 649  void MeshAdapter::interpolateACross(Data Line 652  void MeshAdapter::interpolateACross(Data
652  //  //
653  // calculates the integral of a function defined of arg:  // calculates the integral of a function defined of arg:
654  //  //
655  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const Data& arg) const  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
656  {  {
657    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
658    if (argDomain!=*this)    if (argDomain!=*this)
# Line 693  void MeshAdapter::setToIntegrals(std::ve Line 696  void MeshAdapter::setToIntegrals(std::ve
696  //  //
697  // calculates the gradient of arg:  // calculates the gradient of arg:
698  //  //
699  void MeshAdapter::setToGradient(Data& grad,const Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
700  {  {
701    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
702    if (argDomain!=*this)    if (argDomain!=*this)
# Line 740  void MeshAdapter::setToGradient(Data& gr Line 743  void MeshAdapter::setToGradient(Data& gr
743  //  //
744  // returns the size of elements:  // returns the size of elements:
745  //  //
746  void MeshAdapter::setToSize(Data& size) const  void MeshAdapter::setToSize(escript::Data& size) const
747  {  {
748    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
749    escriptDataC tmp=size.getDataC();    escriptDataC tmp=size.getDataC();
# Line 777  void MeshAdapter::setToSize(Data& size) Line 780  void MeshAdapter::setToSize(Data& size)
780  }  }
781    
782  // sets the location of nodes:  // sets the location of nodes:
783  void MeshAdapter::setNewX(const Data& new_x)  void MeshAdapter::setNewX(const escript::Data& new_x)
784  {  {
785    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
786    const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());    const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());
787    if (newDomain!=*this)    if (newDomain!=*this)
788       throw FinleyAdapterException("Error - Illegal domain of new point locations");       throw FinleyAdapterException("Error - Illegal domain of new point locations");
789    Finley_NodeFile_setCoordinates(mesh->Nodes,&(new_x.getDataC()));    Finley_Mesh_setCoordinates(mesh,&(new_x.getDataC()));
790    checkFinleyError();    checkFinleyError();
791  }  }
792    
# Line 799  void MeshAdapter::saveDX(const std::stri Line 802  void MeshAdapter::saveDX(const std::stri
802    
803      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
804      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
805           Data& d=boost::python::extract<Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
806           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
807               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
808           data[i]=d.getDataC();           data[i]=d.getDataC();
# Line 830  void MeshAdapter::saveVTK(const std::str Line 833  void MeshAdapter::saveVTK(const std::str
833    
834      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
835      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
836           Data& d=boost::python::extract<Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
837           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
838               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
839           data[i]=d.getDataC();           data[i]=d.getDataC();
# Line 1041  int MeshAdapter::getSystemMatrixTypeId(c Line 1044  int MeshAdapter::getSystemMatrixTypeId(c
1044     return out;     return out;
1045  }  }
1046    
1047  Data MeshAdapter::getX() const  escript::Data MeshAdapter::getX() const
1048  {  {
1049    return continuousFunction(asAbstractContinuousDomain()).getX();    return continuousFunction(asAbstractContinuousDomain()).getX();
1050  }  }
1051    
1052  Data MeshAdapter::getNormal() const  escript::Data MeshAdapter::getNormal() const
1053  {  {
1054    return functionOnBoundary(asAbstractContinuousDomain()).getNormal();    return functionOnBoundary(asAbstractContinuousDomain()).getNormal();
1055  }  }
1056    
1057  Data MeshAdapter::getSize() const  escript::Data MeshAdapter::getSize() const
1058  {  {
1059    return function(asAbstractContinuousDomain()).getSize();    return function(asAbstractContinuousDomain()).getSize();
1060  }  }

Legend:
Removed from v.472  
changed lines
  Added in v.532

  ViewVC Help
Powered by ViewVC 1.1.26