/[escript]/trunk/finley/src/NodeFile.cpp
ViewVC logotype

Diff of /trunk/finley/src/NodeFile.cpp

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

revision 4625 by jfenwick, Tue Aug 27 01:32:10 2013 UTC revision 4626 by caltinay, Wed Jan 22 06:07:34 2014 UTC
# Line 200  void NodeFile::print() const Line 200  void NodeFile::print() const
200  }  }
201    
202  /// copies the array newX into this->coordinates  /// copies the array newX into this->coordinates
203  void NodeFile::setCoordinates(const escript::Data& cNewX)  void NodeFile::setCoordinates(const escript::Data& newX)
204  {  {
205      if (cNewX.getDataPointSize() != numDim)  {      if (newX.getDataPointSize() != numDim)  {
206          std::stringstream ss;          std::stringstream ss;
207          ss << "NodeFile::setCoordinates: number of dimensions of new "          ss << "NodeFile::setCoordinates: number of dimensions of new "
208              "coordinates has to be " << numDim;              "coordinates has to be " << numDim;
209          const std::string errorMsg(ss.str());          const std::string errorMsg(ss.str());
210          setError(VALUE_ERROR, errorMsg.c_str());          setError(VALUE_ERROR, errorMsg.c_str());
211      } else if (cNewX.getNumDataPointsPerSample() != 1 ||      } else if (newX.getNumDataPointsPerSample() != 1 ||
212              cNewX.getNumSamples() != numNodes) {              newX.getNumSamples() != numNodes) {
213          std::stringstream ss;          std::stringstream ss;
214          ss << "NodeFile::setCoordinates: number of given nodes must be "          ss << "NodeFile::setCoordinates: number of given nodes must be "
215              << numNodes;              << numNodes;
# Line 218  void NodeFile::setCoordinates(const escr Line 218  void NodeFile::setCoordinates(const escr
218      } else {      } else {
219          const size_t numDim_size=numDim*sizeof(double);          const size_t numDim_size=numDim*sizeof(double);
220          ++status;          ++status;
         escript::Data& newX = *const_cast<escript::Data*>(&cNewX);  
221  #pragma omp parallel for  #pragma omp parallel for
222          for (int n=0; n<numNodes; n++) {          for (int n=0; n<numNodes; n++) {
223              memcpy(&(Coordinates[INDEX2(0,n,numDim)]), newX.getSampleDataRO(n), numDim_size);              memcpy(&(Coordinates[INDEX2(0,n,numDim)]), newX.getSampleDataRO(n), numDim_size);
# Line 227  void NodeFile::setCoordinates(const escr Line 226  void NodeFile::setCoordinates(const escr
226  }  }
227    
228  /// sets tags to newTag where mask>0  /// sets tags to newTag where mask>0
229  void NodeFile::setTags(const int newTag, const escript::Data& cMask)  void NodeFile::setTags(const int newTag, const escript::Data& mask)
230  {  {
231      resetError();      resetError();
232    
233      if (1 != cMask.getDataPointSize()) {      if (1 != mask.getDataPointSize()) {
234         setError(TYPE_ERROR, "NodeFile::setTags: number of components of mask must be 1.");         setError(TYPE_ERROR, "NodeFile::setTags: number of components of mask must be 1.");
235         return;         return;
236      } else if (cMask.getNumDataPointsPerSample() != 1 ||      } else if (mask.getNumDataPointsPerSample() != 1 ||
237              cMask.getNumSamples() != numNodes) {              mask.getNumSamples() != numNodes) {
238         setError(TYPE_ERROR, "NodeFile::setTags: illegal number of samples of mask Data object");         setError(TYPE_ERROR, "NodeFile::setTags: illegal number of samples of mask Data object");
239         return;         return;
240      }      }
241    
     escript::Data& mask = *const_cast<escript::Data*>(&cMask);  
242  #pragma omp parallel for  #pragma omp parallel for
243      for (int n=0; n<numNodes; n++) {      for (int n=0; n<numNodes; n++) {
244           if (mask.getSampleDataRO(n)[0] > 0)           if (mask.getSampleDataRO(n)[0] > 0)

Legend:
Removed from v.4625  
changed lines
  Added in v.4626

  ViewVC Help
Powered by ViewVC 1.1.26