/[escript]/trunk/escript/src/Data.h
ViewVC logotype

Diff of /trunk/escript/src/Data.h

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

revision 480 by jgs, Wed Feb 1 05:15:12 2006 UTC revision 615 by elspeth, Wed Mar 22 02:12:00 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                          *   *                                                          *
11   * person has a software license agreement with ACcESS.                       *   ************************************************************
  *                                                                            *  
  ******************************************************************************  
12  */  */
13    
14  /** \file Data.h */  /** \file Data.h */
# Line 145  class Data { Line 143  class Data {
143       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
144       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
145                         the appropriate values.                         the appropriate values.
146        ==>*
147    */    */
148    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
149         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
# Line 307  class Data { Line 306  class Data {
306       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
307       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
308       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
309        ==>*
310    */    */
311    void    void
312    tag();    tag();
# Line 525  class Data { Line 525  class Data {
525       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
526       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
527       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
528        ==>*
529    */    */
530    void    void
531    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 537  class Data { Line 538  class Data {
538       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
539       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
540       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
541        ==>*
542    */    */
543    void    void
544    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
# Line 589  class Data { Line 591  class Data {
591       *       *
592    */    */
593    Data    Data
594    wherePositive() const;    wherePositive(double tol=0.0) const;
595    
596    /**    /**
597       \brief       \brief
# Line 597  class Data { Line 599  class Data {
599       *       *
600    */    */
601    Data    Data
602    whereNegative() const;    whereNegative(double tol=0.0) const;
603    
604    /**    /**
605       \brief       \brief
# Line 605  class Data { Line 607  class Data {
607       *       *
608    */    */
609    Data    Data
610    whereNonNegative() const;    whereNonNegative(double tol=0.0) const;
611    
612    /**    /**
613       \brief       \brief
# Line 613  class Data { Line 615  class Data {
615       *       *
616    */    */
617    Data    Data
618    whereNonPositive() const;    whereNonPositive(double tol=0.0) const;
619    
620    /**    /**
621       \brief       \brief
# Line 621  class Data { Line 623  class Data {
623       *       *
624    */    */
625    Data    Data
626    whereZero() const;    whereZero(double tol=0.0) const;
627    
628    /**    /**
629       \brief       \brief
# Line 629  class Data { Line 631  class Data {
631       *       *
632    */    */
633    Data    Data
634    whereNonZero() const;    whereNonZero(double tol=0.0) const;
635    
636    /**    /**
637       \brief       \brief
# Line 710  class Data { Line 712  class Data {
712    
713    /**    /**
714       \brief       \brief
715         Return the eigenvalues of the symmetric part at each data point of this Data object in increasing values.
716         Currently this function is restricted to rank 2, square shape, and dimension 3.
717         *
718      */
719      Data
720      eigenvalues() const;
721    
722      /**
723         \brief
724         Return the eigenvalues and corresponding eigenvcetors of the symmetric part at each data point of this Data object.
725         the eigenvalues are ordered in increasing size where eigenvalues with relative difference less than
726         tol are treated as equal. The eigenvectors are orthogonal, normalized and the sclaed such that the
727         first non-zero entry is positive.
728         Currently this function is restricted to rank 2, square shape, and dimension 3
729         *
730      */
731      const boost::python::tuple
732      eigenvalues_and_eigenvectors(const double tol=1.e-12) const;
733    
734      /**
735         \brief
736       Transpose each data point of this Data object around the given axis.       Transpose each data point of this Data object around the given axis.
737       --* not implemented yet *--       --* not implemented yet *--
738       *       *
# Line 720  class Data { Line 743  class Data {
743    /**    /**
744       \brief       \brief
745       Calculate the trace of each data point of this Data object.       Calculate the trace of each data point of this Data object.
      sum(A[i,i,i,i])  
746       *       *
747    */    */
748    Data    Data
# Line 1478  inline Line 1500  inline
1500  Data  Data
1501  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1502  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1503    if (isExpanded()) {    if (isExpanded()) {
1504        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1505      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1506      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1507      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1508      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1509      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1510        return result;
1511    } else if (isTagged()) {    } else if (isTagged()) {
1512      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1513        DataArrayView::ShapeType viewShape;
1514        DataArrayView::ValueType viewData(1);
1515        viewData[0]=0;
1516        DataArrayView defaultValue(viewData,viewShape);
1517        DataTagged::TagListType keys;
1518        DataTagged::ValueListType values;
1519        DataTagged::DataMapType::const_iterator i;
1520        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1521          keys.push_back(i->first);
1522          values.push_back(defaultValue);
1523        }
1524        Data result(keys,values,defaultValue,getFunctionSpace());
1525      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1526      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1527      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1528      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1529        return result;
1530    } else if (isConstant()) {    } else if (isConstant()) {
1531        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1532      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1533      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1534      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1535      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1536      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1537        return result;
1538    }    }
1539    return result;    Data falseRetVal; // to keep compiler quiet
1540      return falseRetVal;
1541  }  }
1542    
1543  }  }

Legend:
Removed from v.480  
changed lines
  Added in v.615

  ViewVC Help
Powered by ViewVC 1.1.26