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

Diff of /trunk/esys2/escript/src/Data/DataExpanded.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 299  DataExpanded::getLength() const Line 299  DataExpanded::getLength() const
299    return m_data.getData().size();    return m_data.getData().size();
300  }  }
301    
302    void
303    DataExpanded::setRefValue(int ref,
304                              const DataArray& value)
305    {
306      //
307      // Check number of samples and data-points per sample.
308      int numSamples = getNumSamples();
309      int numDPPSample = getNumDPPSample();
310      if (numDPPSample > 1) {
311        throw DataException("DataExpanded::setRefValue error: more than one DPPSample in this Data.");
312      }
313    
314      //
315      // Determine the data-point which corresponds to this reference number.
316      int sampleNo = -1;
317      int tempRef = -1;
318      for (int n=0; n<numSamples; n++) {
319        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
320        if (tempRef == ref) {
321          sampleNo = n;
322          break;
323        }
324      }
325      if (sampleNo == -1) {
326        throw DataException("DataExpanded::setRefValue error: invalid ref number supplied.");
327      }
328    
329      DataArrayView pointView = getDataPoint(sampleNo, 0);
330    
331      //
332      // Assign the values in the DataArray to this data-point.
333      pointView.copy(value.getView());
334    }
335    
336    void
337    DataExpanded::getRefValue(int ref,
338                              DataArray& value)
339    {
340      //
341      // Check number of samples and data-points per sample.
342      int numSamples = getNumSamples();
343      int numDPPSample = getNumDPPSample();
344      if (numDPPSample > 1) {
345        throw DataException("DataExpanded::getRefValue error: more than one DPPSample in this Data.");
346      }
347    
348      //
349      // Determine the data-point which corresponds to this reference number
350      int sampleNo = -1;
351      int tempRef = -1;
352      for (int n=0; n<numSamples; n++) {
353        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
354        if (tempRef == ref) {
355          sampleNo = n;
356          break;
357        }
358      }
359      if (sampleNo == -1) {
360        throw DataException("DataExpanded::getRefValue error: invalid ref number supplied.");
361      }
362    
363      DataArrayView pointView = getDataPoint(sampleNo, 0);
364    
365      //
366      // Load the values from this data-point into the DataArray
367      value.getView().copy(pointView);
368    }
369    
370  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26