/[escript]/trunk-mpi-branch/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /trunk-mpi-branch/finley/src/CPPAdapter/MeshAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1271 by gross, Tue Aug 21 00:15:52 2007 UTC revision 1272 by gross, Fri Aug 24 00:40:43 2007 UTC
# Line 846  void MeshAdapter::setToIntegrals(std::ve Line 846  void MeshAdapter::setToIntegrals(std::ve
846  //  //
847  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
848  {  {
849    cout << "AAAAAAAAAAAA\n";
850    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
851    if (argDomain!=*this)    if (argDomain!=*this)
852      throw FinleyAdapterException("Error - Illegal domain of gradient argument");      throw FinleyAdapterException("Error - Illegal domain of gradient argument");
# Line 861  void MeshAdapter::setToGradient(escript: Line 862  void MeshAdapter::setToGradient(escript:
862        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
863          temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );          temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );
864          nodeDataC = temp.getDataC();          nodeDataC = temp.getDataC();
865        } else if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {        } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
866          temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );          temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );
867          nodeDataC = temp.getDataC();          nodeDataC = temp.getDataC();
868        } else {        } else {
# Line 1003  void MeshAdapter::saveDX(const std::stri Line 1004  void MeshAdapter::saveDX(const std::stri
1004    
1005      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
1006      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
1007           data_in[i]=boost::python::extract<escript::Data&>(arg[keys[i]]);  
1008           if (dynamic_cast<const MeshAdapter&>(data_in[i].getFunctionSpace().getDomain()) !=*this)           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1009               throw FinleyAdapterException("Error  in saveDX: Data must be defined on same Domain");  
1010           if ( (data_in[i].getFunctionSpace().getTypeCode() == DegreesOfFreedom) ||           if (d.getFunctionSpace().getTypeCode() == DegreesOfFreedom)  {
1011                (data_in[i].getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom) ||              escript::Data d2(d,reducedContinuousFunction(asAbstractContinuousDomain()));
1012                (data_in[i].getFunctionSpace().getTypeCode() == Nodes)  ) {              data_in.push_back(d2);
1013              data_in[i]=escript::Data(data_in[i],reducedContinuousFunction(asAbstractContinuousDomain()));              data[i]=d2.getDataC();
1014              data[i]=data_in[i].getDataC();           } else if (d.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom) {
1015                escript::Data d2(d,reducedContinuousFunction(asAbstractContinuousDomain()));
1016                data_in.push_back(d2);
1017                data[i]=d2.getDataC();
1018             } else if (d.getFunctionSpace().getTypeCode() == Nodes) {
1019                escript::Data d2(d,reducedContinuousFunction(asAbstractContinuousDomain()));
1020                data_in.push_back(d2);
1021                data[i]=d2.getDataC();
1022           } else {           } else {
1023              data[i]=data_in[i].getDataC();              data[i]=d.getDataC();
1024           }           }
1025           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
1026    
1027           std::string n=boost::python::extract<std::string>(keys[i]);           std::string n=boost::python::extract<std::string>(keys[i]);
1028           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1029           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
# Line 1045  void MeshAdapter::saveVTK(const std::str Line 1054  void MeshAdapter::saveVTK(const std::str
1054  {  {
1055      int MAX_namelength=256;      int MAX_namelength=256;
1056      const int num_data=boost::python::extract<int>(arg.attr("__len__")());      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1057        std::vector<escript::Data> data_in;
1058    /* win32 refactor */    /* win32 refactor */
1059    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1060    for(int i=0;i<num_data;i++)    for(int i=0;i<num_data;i++)
# Line 1059  void MeshAdapter::saveVTK(const std::str Line 1069  void MeshAdapter::saveVTK(const std::str
1069      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
1070      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
1071           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1072    
1073           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1074               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1075           data[i]=d.getDataC();           if (d.getFunctionSpace().getTypeCode() == DegreesOfFreedom)  {
1076                escript::Data d2(d,continuousFunction(asAbstractContinuousDomain()));
1077                data_in.push_back(d2);
1078                data[i]=d2.getDataC();
1079             } else if (d.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom) {
1080                escript::Data d2(d,reducedContinuousFunction(asAbstractContinuousDomain()));
1081                data_in.push_back(d2);
1082                data[i]=d2.getDataC();
1083             } else {
1084                data[i]=d.getDataC();
1085             }
1086    
1087           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
1088           std::string n=boost::python::extract<std::string>(keys[i]);           std::string n=boost::python::extract<std::string>(keys[i]);
1089           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);

Legend:
Removed from v.1271  
changed lines
  Added in v.1272

  ViewVC Help
Powered by ViewVC 1.1.26