/[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 562 by jgs, Thu Feb 23 05:03:16 2006 UTC
# Line 145  class Data { Line 145  class Data {
145       \param what - Input - A description of what this data represents.       \param what - Input - A description of what this data represents.
146       \param expanded - Input - Flag, if true fill the entire container with       \param expanded - Input - Flag, if true fill the entire container with
147                         the appropriate values.                         the appropriate values.
148        ==>*
149    */    */
150    Data(const DataTagged::TagListType& tagKeys,    Data(const DataTagged::TagListType& tagKeys,
151         const DataTagged::ValueListType& values,         const DataTagged::ValueListType& values,
# Line 307  class Data { Line 308  class Data {
308       If possible convert this Data to DataTagged. This will only allow       If possible convert this Data to DataTagged. This will only allow
309       Constant data to be converted to tagged. An attempt to convert       Constant data to be converted to tagged. An attempt to convert
310       Expanded data to tagged will throw an exception.       Expanded data to tagged will throw an exception.
311        ==>*
312    */    */
313    void    void
314    tag();    tag();
# Line 525  class Data { Line 527  class Data {
527       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
528       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
529       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
530        ==>*
531    */    */
532    void    void
533    setTaggedValue(int tagKey,    setTaggedValue(int tagKey,
# Line 537  class Data { Line 540  class Data {
540       cannot be converted to a DataTagged object.       cannot be converted to a DataTagged object.
541       \param tagKey - Input - Integer key.       \param tagKey - Input - Integer key.
542       \param value - Input - Value to associate with given key.       \param value - Input - Value to associate with given key.
543        ==>*
544    */    */
545    void    void
546    setTaggedValueFromCPP(int tagKey,    setTaggedValueFromCPP(int tagKey,
# Line 1478  inline Line 1482  inline
1482  Data  Data
1483  Data::dp_algorithm(BinaryFunction operation, double initial_value) const  Data::dp_algorithm(BinaryFunction operation, double initial_value) const
1484  {  {
   Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());  
1485    if (isExpanded()) {    if (isExpanded()) {
1486        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1487      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());      DataExpanded* dataE=dynamic_cast<DataExpanded*>(m_data.get());
1488      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());      DataExpanded* resultE=dynamic_cast<DataExpanded*>(result.m_data.get());
1489      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");      EsysAssert((dataE!=0), "Programming error - casting data to DataExpanded.");
1490      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");      EsysAssert((resultE!=0), "Programming error - casting result to DataExpanded.");
1491      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);      escript::dp_algorithm(*dataE,*resultE,operation,initial_value);
1492        return result;
1493    } else if (isTagged()) {    } else if (isTagged()) {
1494      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());      DataTagged* dataT=dynamic_cast<DataTagged*>(m_data.get());
1495        DataArrayView::ShapeType viewShape;
1496        DataArrayView::ValueType viewData(1);
1497        viewData[0]=0;
1498        DataArrayView defaultValue(viewData,viewShape);
1499        DataTagged::TagListType keys;
1500        DataTagged::ValueListType values;
1501        DataTagged::DataMapType::const_iterator i;
1502        for (i=dataT->getTagLookup().begin();i!=dataT->getTagLookup().end();i++) {
1503          keys.push_back(i->first);
1504          values.push_back(defaultValue);
1505        }
1506        Data result(keys,values,defaultValue,getFunctionSpace());
1507      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());      DataTagged* resultT=dynamic_cast<DataTagged*>(result.m_data.get());
1508      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");      EsysAssert((dataT!=0), "Programming error - casting data to DataTagged.");
1509      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");      EsysAssert((resultT!=0), "Programming error - casting result to DataTagged.");
1510      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);      escript::dp_algorithm(*dataT,*resultT,operation,initial_value);
1511        return result;
1512    } else if (isConstant()) {    } else if (isConstant()) {
1513        Data result(0,DataArrayView::ShapeType(),getFunctionSpace(),isExpanded());
1514      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());      DataConstant* dataC=dynamic_cast<DataConstant*>(m_data.get());
1515      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());      DataConstant* resultC=dynamic_cast<DataConstant*>(result.m_data.get());
1516      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");      EsysAssert((dataC!=0), "Programming error - casting data to DataConstant.");
1517      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");      EsysAssert((resultC!=0), "Programming error - casting result to DataConstant.");
1518      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);      escript::dp_algorithm(*dataC,*resultC,operation,initial_value);
1519        return result;
1520    }    }
1521    return result;    Data falseRetVal; // to keep compiler quiet
1522      return falseRetVal;
1523  }  }
1524    
1525  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.26