/[escript]/trunk/escript/src/Data.cpp
ViewVC logotype

Diff of /trunk/escript/src/Data.cpp

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

revision 108 by jgs, Thu Jan 27 06:21:59 2005 UTC revision 110 by jgs, Mon Feb 14 04:14:42 2005 UTC
# Line 639  Data::saveDX(std::string fileName) const Line 639  Data::saveDX(std::string fileName) const
639    return;    return;
640  }  }
641    
642    void
643    Data::saveVTK(std::string fileName) const
644    {
645      getDomain().saveVTK(fileName,*this);
646      return;
647    }
648    
649  Data&  Data&
650  Data::operator+=(const Data& right)  Data::operator+=(const Data& right)
651  {  {
# Line 1030  Data::setTaggedValue(int tagKey, Line 1037  Data::setTaggedValue(int tagKey,
1037    m_data->setTaggedValue(tagKey,valueDataArray.getView());    m_data->setTaggedValue(tagKey,valueDataArray.getView());
1038  }  }
1039    
1040    void
1041    Data::setRefValue(int ref,
1042                      const boost::python::numeric::array& value)
1043    {
1044      //
1045      // Construct DataArray from boost::python::object input value
1046      DataArray valueDataArray(value);
1047    
1048      //
1049      // Call DataAbstract::setRefValue
1050      m_data->setRefValue(ref,valueDataArray);
1051    }
1052    
1053    void
1054    Data::getRefValue(int ref,
1055                      boost::python::numeric::array& value)
1056    {
1057      //
1058      // Construct DataArray for boost::python::object return value
1059      DataArray valueDataArray(value);
1060    
1061      //
1062      // Load DataArray with values from data-points specified by ref
1063      m_data->getRefValue(ref,valueDataArray);
1064    
1065      //
1066      // Load values from valueDataArray into return numarray
1067    
1068      // extract the shape of the numarray
1069      int rank = value.getrank();
1070      DataArrayView::ShapeType shape;
1071      for (int i=0; i < rank; i++) {
1072        shape.push_back(extract<int>(value.getshape()[i]));
1073      }
1074    
1075      // and load the numarray with the data from the DataArray
1076      DataArrayView valueView = valueDataArray.getView();
1077    
1078      if (rank==0) {
1079        throw DataException("Data::getRefValue error: only rank 1 data handled for now.");
1080      }
1081      if (rank==1) {
1082        for (int i=0; i < shape[0]; i++) {
1083          value[i] = valueView(i);
1084        }
1085      }
1086      if (rank==2) {
1087        throw DataException("Data::getRefValue error: only rank 1 data handled for now.");
1088      }
1089      if (rank==3) {
1090        throw DataException("Data::getRefValue error: only rank 1 data handled for now.");
1091      }
1092      if (rank==4) {
1093        throw DataException("Data::getRefValue error: only rank 1 data handled for now.");
1094      }
1095    
1096    }
1097    
1098  /*  /*
1099  Note: this version removed for now. Not needed, and breaks escript.cpp  Note: this version removed for now. Not needed, and breaks escript.cpp
1100  void  void

Legend:
Removed from v.108  
changed lines
  Added in v.110

  ViewVC Help
Powered by ViewVC 1.1.26