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

Diff of /trunk/escript/src/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 113 by jgs, Mon Feb 28 07:06:33 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      // Get the number of samples and data-points per sample.
308      int numSamples = getNumSamples();
309      int numDPPSample = getNumDPPSample();
310    
311      //
312      // Determine the sample number which corresponds to this reference number.
313      int sampleNo = -1;
314      int tempRef = -1;
315      for (int n=0; n<numSamples; n++) {
316        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
317        if (tempRef == ref) {
318          sampleNo = n;
319          break;
320        }
321      }
322      if (sampleNo == -1) {
323        throw DataException("DataExpanded::setRefValue error: invalid ref number supplied.");
324      }
325    
326      for (int n=0; n<numDPPSample; n++) {
327        //
328        // Get each data-point in the sample in turn.
329        DataArrayView pointView = getDataPoint(sampleNo, n);
330    
331        //
332        // Assign the values in the DataArray to this data-point.
333        pointView.copy(value.getView());
334      }
335    }
336    
337    void
338    DataExpanded::getRefValue(int ref,
339                              DataArray& value)
340    {
341      //
342      // Get the number of samples and data-points per sample.
343      int numSamples = getNumSamples();
344      int numDPPSample = getNumDPPSample();
345    
346      //
347      // Determine the sample number which corresponds to this reference number
348      int sampleNo = -1;
349      int tempRef = -1;
350      for (int n=0; n<numSamples; n++) {
351        tempRef = getFunctionSpace().getReferenceNoFromSampleNo(n);
352        if (tempRef == ref) {
353          sampleNo = n;
354          break;
355        }
356      }
357      if (sampleNo == -1) {
358        throw DataException("DataExpanded::getRefValue error: invalid ref number supplied.");
359      }
360    
361      //
362      // Get the first data-point associated with this sample number.
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.113

  ViewVC Help
Powered by ViewVC 1.1.26