revision 155 by jgs, Wed Nov 9 02:02:19 2005 UTC revision 532 by gross, Wed Feb 15 09:45:53 2006 UTC
# Line 12  Line 12
12   *                                                                            *   *                                                                            *
13   ******************************************************************************   ******************************************************************************
14  */  */
extern "C" {
#include "finley/finleyC/Finley.h"
#include "finley/finleyC/Assemble.h"
#include "finley/finleyC/Mesh.h"
#include "finley/finleyC/Finley.h"
#include "paso/SystemMatrix.h"
}
#include "escript/Data/FunctionSpaceFactory.h"
#include "escript/Data/Data.h"
#include "escript/Data/DataArrayView.h"
#include "escript/Data/FunctionSpace.h"
#include "escript/Data/DataFactory.h"
#include <boost/python/extract.hpp>
15
17  #include <sstream>
18    #include "Data.h"
19    #include "DataFactory.h"
20
21  using namespace std;  using namespace std;
22  using namespace escript;  using namespace escript;
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  //  //
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()),
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  //  //
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
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  {  {
578  //  //
579  // copies the locations of sample points into x:  // copies the locations of sample points into x:
580  //  //
582  {  {
584    if (argDomain!=*this)    if (argDomain!=*this)
# Line 603  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 614  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  //  //
603  {  {
605    if (normalDomain!=*this)    if (normalDomain!=*this)
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  {  {
646    if (targetDomain!=*this)    if (targetDomain!=*this)
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  {  {
658    if (argDomain!=*this)    if (argDomain!=*this)
696  //  //
697  // calculates the gradient of arg:  // calculates the gradient of arg:
698  //  //
700  {  {
702    if (argDomain!=*this)    if (argDomain!=*this)
743  //  //
744  // returns the size of elements:  // returns the size of elements:
745  //  //
747  {  {
748    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
749    escriptDataC tmp=size.getDataC();    escriptDataC tmp=size.getDataC();
780  }  }
781
782  // sets the location of nodes:  // sets the location of nodes:
784  {  {
785    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
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
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]]);
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();
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]]);
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();
1044     return out;     return out;
1045  }  }
1046
1048  {  {
1049    return continuousFunction(asAbstractContinuousDomain()).getX();    return continuousFunction(asAbstractContinuousDomain()).getX();
1050  }  }
1051