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

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

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

trunk/esys2/escript/src/Data/DataConstant.cpp revision 119 by jgs, Tue Apr 12 04:45:05 2005 UTC trunk/escript/src/DataConstant.cpp revision 682 by robwdcock, Mon Mar 27 02:43:09 2006 UTC
# Line 1  Line 1 
1  //$Id$  //$Id$
2  /*  /*
3   ******************************************************************************   ************************************************************
4   *                                                                            *   *          Copyright 2006 by ACcESS MNRF                   *
5   *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *   *                                                          *
6   *                                                                            *   *              http://www.access.edu.au                    *
7   * This software is the property of ACcESS. No part of this code              *   *       Primary Business: Queensland, Australia            *
8   * may be copied in any form or by any means without the expressed written    *   *  Licensed under the Open Software License version 3.0    *
9   * consent of ACcESS.  Copying, use or modification of this software          *   *     http://www.opensource.org/licenses/osl-3.0.php       *
10   * by any unauthorised person is illegal unless that person has a software    *   *                                                          *
11   * license agreement with ACcESS.                                             *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13    
14  #include "escript/Data/DataConstant.h"  #include "DataConstant.h"
15  #include "escript/Data/DataException.h"  #include "DataException.h"
16  #include "esysUtils/EsysAssert.h"  #include "esysUtils/EsysAssert.h"
17    
18  #include <iostream>  #include <iostream>
# Line 72  DataConstant::DataConstant(const DataCon Line 70  DataConstant::DataConstant(const DataCon
70    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));    DataArrayView::ShapeType shape(DataArrayView::getResultSliceShape(region));
71    //    //
72    // allocate space for this new DataConstant's data    // allocate space for this new DataConstant's data
73    m_data.resize(DataArrayView::noValues(shape));    int len = DataArrayView::noValues(shape);
74      m_data.resize(len,0.,len);
75    //    //
76    // create a view of the data with the correct shape    // create a view of the data with the correct shape
77    DataArrayView tempView(m_data,shape);    DataArrayView tempView(m_data,shape);
# Line 109  DataConstant::getPointOffset(int sampleN Line 108  DataConstant::getPointOffset(int sampleN
108  {  {
109    EsysAssert((validSamplePointNo(dataPointNo) && validSampleNo(sampleNo)),    EsysAssert((validSamplePointNo(dataPointNo) && validSampleNo(sampleNo)),
110                "Invalid index, sampleNo: " << sampleNo << " dataPointNo: " << dataPointNo);                "Invalid index, sampleNo: " << sampleNo << " dataPointNo: " << dataPointNo);
111      //
112      // Whatever the coord's always return the same value as this is constant data.
113    return 0;    return 0;
114  }  }
115    
# Line 168  DataConstant::reshapeDataPoint(const Dat Line 169  DataConstant::reshapeDataPoint(const Dat
169           << "This Data has data points with rank: " << getPointDataView().getRank();           << "This Data has data points with rank: " << getPointDataView().getRank();
170      throw DataException(temp.str());      throw DataException(temp.str());
171    }    }
172    m_data.resize(DataArrayView::noValues(shape),getPointDataView()());    int len = DataArrayView::noValues(shape);
173      m_data.resize(len,getPointDataView()(),len);
174    DataArrayView newView(m_data,shape);    DataArrayView newView(m_data,shape);
175    setPointDataView(newView);    setPointDataView(newView);
176  }  }
177    
178    int
179    DataConstant::archiveData(ofstream& archiveFile,
180                              const DataArrayView::ValueType::size_type noValues) const
181    {
182      return(m_data.archiveData(archiveFile, noValues));
183    }
184    
185    int
186    DataConstant::extractData(ifstream& archiveFile,
187                              const DataArrayView::ValueType::size_type noValues)
188    {
189      return(m_data.extractData(archiveFile, noValues));
190    }
191    
192    void
193    DataConstant::eigenvalues(DataAbstract* ev)
194    {
195      DataConstant* temp_ev=dynamic_cast<DataConstant*>(ev);
196      if (temp_ev==0) {
197        throw DataException("Error - DataConstant::eigenvalues: casting to DataConstant failed (propably a programming error).");
198      }
199      DataArrayView& thisView=getPointDataView();
200      DataArrayView& evView=ev->getPointDataView();
201      DataArrayView::eigenvalues(thisView,0,evView,0);
202    }
203    void
204    DataConstant::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
205    {
206      DataConstant* temp_ev=dynamic_cast<DataConstant*>(ev);
207      if (temp_ev==0) {
208        throw DataException("Error - DataConstant::eigenvalues_and_eigenvectors: casting to DataConstant failed (propably a programming error).");
209      }
210      DataConstant* temp_V=dynamic_cast<DataConstant*>(V);
211      if (temp_V==0) {
212        throw DataException("Error - DataConstant::eigenvalues_and_eigenvectors: casting to DataConstant failed (propably a programming error).");
213      }
214      DataArrayView thisView=getPointDataView();
215      DataArrayView evView=ev->getPointDataView();
216      DataArrayView VView=V->getPointDataView();
217    
218      DataArrayView::eigenvalues_and_eigenvectors(thisView,0,evView,0,VView,tol);
219    }
220    
221    
222  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.119  
changed lines
  Added in v.682

  ViewVC Help
Powered by ViewVC 1.1.26