/[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

trunk/esys2/escript/src/Data/DataExpanded.cpp revision 126 by jgs, Fri Jul 22 03:53:08 2005 UTC trunk/escript/src/DataExpanded.cpp revision 800 by gross, Tue Aug 8 11:23:18 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/DataException.h"  #include "DataExpanded.h"
15  #include "escript/Data/DataExpanded.h"  #include "DataException.h"
16  #include "escript/Data/DataConstant.h"  #include "DataConstant.h"
17  #include "escript/Data/DataTagged.h"  #include "DataTagged.h"
 #include "escript/Data/DataArrayView.h"  
18    
19  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
20    
 #include <iostream>  
   
21  using namespace std;  using namespace std;
22  using namespace boost::python;  using namespace boost::python;
23  using namespace boost;  using namespace boost;
# Line 148  DataExpanded::DataExpanded(const Functio Line 143  DataExpanded::DataExpanded(const Functio
143    : DataAbstract(what)    : DataAbstract(what)
144  {  {
145    //    //
146      // create the view of the data
147      initialise(shape,what.getNumSamples(),what.getNumDPPSample());
148      //
149    // copy the data in the correct format    // copy the data in the correct format
150    m_data.getData()=data;    m_data.getData()=data;
   //  
   // create the view of the data  
   DataArrayView tempView(m_data.getData(),shape);  
   setPointDataView(tempView);  
151  }  }
152    
153  DataExpanded::~DataExpanded()  DataExpanded::~DataExpanded()
# Line 219  DataExpanded::setSlice(const DataAbstrac Line 213  DataExpanded::setSlice(const DataAbstrac
213    if (getPointDataView().getRank()!=region.size()) {    if (getPointDataView().getRank()!=region.size()) {
214      throw DataException("Error - Invalid slice region.");      throw DataException("Error - Invalid slice region.");
215    }    }
216    if (tempDataExp->getPointDataView().getRank()>0 and !value->getPointDataView().checkShape(shape)) {    if (tempDataExp->getPointDataView().getRank()>0 && !value->getPointDataView().checkShape(shape)) {
217      throw DataException (value->getPointDataView().createShapeErrorMessage(      throw DataException (value->getPointDataView().createShapeErrorMessage(
218          "Error - Couldn't copy slice due to shape mismatch.",shape));          "Error - Couldn't copy slice due to shape mismatch.",shape));
219    }    }
# Line 468  DataExpanded::copyAll(const boost::pytho Line 462  DataExpanded::copyAll(const boost::pytho
462      }      }
463    }    }
464  }  }
465    void
466    DataExpanded::symmetric(DataAbstract* ev)
467    {
468      int sampleNo,dataPointNo;
469      int numSamples = getNumSamples();
470      int numDataPointsPerSample = getNumDPPSample();
471      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
472      if (temp_ev==0) {
473        throw DataException("Error - DataExpanded::symmetric: casting to DataExpanded failed (propably a programming error).");
474      }
475      DataArrayView& thisView=getPointDataView();
476      DataArrayView& evView=ev->getPointDataView();
477      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
478      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
479        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
480             DataArrayView::symmetric(thisView,getPointOffset(sampleNo,dataPointNo),
481                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
482        }
483      }
484    }
485    void
486    DataExpanded::nonsymmetric(DataAbstract* ev)
487    {
488      int sampleNo,dataPointNo;
489      int numSamples = getNumSamples();
490      int numDataPointsPerSample = getNumDPPSample();
491      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
492      if (temp_ev==0) {
493        throw DataException("Error - DataExpanded::nonsymmetric: casting to DataExpanded failed (propably a programming error).");
494      }
495      DataArrayView& thisView=getPointDataView();
496      DataArrayView& evView=ev->getPointDataView();
497      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
498      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
499        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
500             DataArrayView::nonsymmetric(thisView,getPointOffset(sampleNo,dataPointNo),
501                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
502        }
503      }
504    }
505    void
506    DataExpanded::trace(DataAbstract* ev, int axis_offset)
507    {
508      int sampleNo,dataPointNo;
509      int numSamples = getNumSamples();
510      int numDataPointsPerSample = getNumDPPSample();
511      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
512      if (temp_ev==0) {
513        throw DataException("Error - DataExpanded::trace: casting to DataExpanded failed (propably a programming error).");
514      }
515      DataArrayView& thisView=getPointDataView();
516      DataArrayView& evView=ev->getPointDataView();
517      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
518      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
519        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
520             DataArrayView::trace(thisView,getPointOffset(sampleNo,dataPointNo),
521                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
522        }
523      }
524    }
525    
526    void
527    DataExpanded::transpose(DataAbstract* ev, int axis_offset)
528    {
529      int sampleNo,dataPointNo;
530      int numSamples = getNumSamples();
531      int numDataPointsPerSample = getNumDPPSample();
532      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
533      if (temp_ev==0) {
534        throw DataException("Error - DataExpanded::transpose: casting to DataExpanded failed (propably a programming error).");
535      }
536      DataArrayView& thisView=getPointDataView();
537      DataArrayView& evView=ev->getPointDataView();
538      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
539      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
540        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
541             DataArrayView::transpose(thisView,getPointOffset(sampleNo,dataPointNo),
542                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
543        }
544      }
545    }
546    
547    void
548    DataExpanded::swap(DataAbstract* ev, int axis_offset)
549    {
550      int sampleNo,dataPointNo;
551      int numSamples = getNumSamples();
552      int numDataPointsPerSample = getNumDPPSample();
553      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
554      if (temp_ev==0) {
555        throw DataException("Error - DataExpanded::swap: casting to DataExpanded failed (propably a programming error).");
556      }
557      DataArrayView& thisView=getPointDataView();
558      DataArrayView& evView=ev->getPointDataView();
559      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
560      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
561        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
562             DataArrayView::swap(thisView,getPointOffset(sampleNo,dataPointNo),
563                                        evView,ev->getPointOffset(sampleNo,dataPointNo),axis_offset);
564        }
565      }
566    }
567    void
568    DataExpanded::eigenvalues(DataAbstract* ev)
569    {
570      int sampleNo,dataPointNo;
571      int numSamples = getNumSamples();
572      int numDataPointsPerSample = getNumDPPSample();
573      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
574      if (temp_ev==0) {
575        throw DataException("Error - DataExpanded::eigenvalues: casting to DataExpanded failed (propably a programming error).");
576      }
577      DataArrayView& thisView=getPointDataView();
578      DataArrayView& evView=ev->getPointDataView();
579      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
580      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
581        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
582             DataArrayView::eigenvalues(thisView,getPointOffset(sampleNo,dataPointNo),
583                                        evView,ev->getPointOffset(sampleNo,dataPointNo));
584        }
585      }
586    }
587    void
588    DataExpanded::eigenvalues_and_eigenvectors(DataAbstract* ev,DataAbstract* V,const double tol)
589    {
590      int numSamples = getNumSamples();
591      int numDataPointsPerSample = getNumDPPSample();
592      int sampleNo,dataPointNo;
593      DataExpanded* temp_ev=dynamic_cast<DataExpanded*>(ev);
594      if (temp_ev==0) {
595        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
596      }
597      DataExpanded* temp_V=dynamic_cast<DataExpanded*>(V);
598      if (temp_V==0) {
599        throw DataException("Error - DataExpanded::eigenvalues_and_eigenvectors: casting to DataExpanded failed (propably a programming error).");
600      }
601      DataArrayView& thisView=getPointDataView();
602      DataArrayView& evView=ev->getPointDataView();
603      DataArrayView& VView=V->getPointDataView();
604      #pragma omp parallel for private(sampleNo,dataPointNo) schedule(static)
605      for (sampleNo = 0; sampleNo < numSamples; sampleNo++) {
606        for (dataPointNo = 0; dataPointNo < numDataPointsPerSample; dataPointNo++) {
607             DataArrayView::eigenvalues_and_eigenvectors(thisView,getPointOffset(sampleNo,dataPointNo),
608                                                         evView,ev->getPointOffset(sampleNo,dataPointNo),
609                                                         VView,V->getPointOffset(sampleNo,dataPointNo),
610                                                         tol);
611        }
612      }
613    }
614    
615  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.126  
changed lines
  Added in v.800

  ViewVC Help
Powered by ViewVC 1.1.26