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

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

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

revision 906 by gross, Tue Nov 21 05:34:15 2006 UTC revision 1802 by jfenwick, Tue Sep 23 01:03:29 2008 UTC
# Line 1  Line 1 
1    
2  /* $Id$ */  /* $Id$ */
3  /*  
4   ************************************************************  /*******************************************************
5   *          Copyright 2006 by ACcESS MNRF                   *   *
6   *                                                          *   *           Copyright 2003-2007 by ACceSS MNRF
7   *              http://www.access.edu.au                    *   *       Copyright 2007 by University of Queensland
8   *       Primary Business: Queensland, Australia            *   *
9   *  Licensed under the Open Software License version 3.0    *   *                http://esscc.uq.edu.au
10   *     http://www.opensource.org/licenses/osl-3.0.php       *   *        Primary Business: Queensland, Australia
11   *                                                          *   *  Licensed under the Open Software License version 3.0
12   ************************************************************   *     http://www.opensource.org/licenses/osl-3.0.php
13  */   *
14     *******************************************************/
15    
16  #include "FunctionSpace.h"  #include "FunctionSpace.h"
17  #include "FunctionSpaceException.h"  #include "FunctionSpaceException.h"
# Line 25  namespace escript { Line 27  namespace escript {
27    
28  //  //
29  // Create a null domain for use with any default-constructed function space  // Create a null domain for use with any default-constructed function space
30  ESCRIPT_DLL_API NullDomain FunctionSpace::m_nullDomainValue;  NullDomain const FunctionSpace::nullDomainValue;
31    
32  FunctionSpace::FunctionSpace():  FunctionSpace::FunctionSpace():
33    m_domain(static_cast<AbstractDomain*>(&m_nullDomainValue)),    m_domain(static_cast<const AbstractDomain*>(&nullDomainValue)),
34    m_functionSpaceType(m_nullDomainValue.getFunctionCode())    m_functionSpaceType(nullDomainValue.getFunctionCode())
35  {  {
36  }  }
37    
# Line 71  FunctionSpace::toString() const Line 73  FunctionSpace::toString() const
73    std::stringstream temp;    std::stringstream temp;
74    temp << m_domain->functionSpaceTypeAsString(m_functionSpaceType)    temp << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
75         << " on " << m_domain->getDescription();         << " on " << m_domain->getDescription();
76    
77    return temp.str();    return temp.str();
78  }  }
79    
80    
81    #ifdef DEBUG_PY_STRINGS
82    PyObject *
83    FunctionSpace::toPyString() const
84    {
85      boost::python::to_python_value<const std::string &> cvtr;
86      std::stringstream temp;
87    
88      temp << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
89           << " on " << m_domain->getDescription();
90    
91      return cvtr(temp.str());
92    }
93    #endif
94    
95    
96  int  int
97  FunctionSpace::getTagFromSampleNo(int sampleNo) const  FunctionSpace::getTagFromSampleNo(int sampleNo) const
98  {  {
# Line 110  FunctionSpace::getTagFromDataPointNo(int Line 129  FunctionSpace::getTagFromDataPointNo(int
129    return(tagNo);    return(tagNo);
130  }  }
131    
132  int  int FunctionSpace::getReferenceIDFromDataPointNo(int dataPointNo) const
133  FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const  {
134         //
135         // Get the number of samples and data-points per sample
136         int numSamples = getNumSamples();
137         int numDataPointsPerSample = getNumDPPSample();
138         int*referenceIDs= borrowSampleReferenceIDs();
139         int numDataPoints = numSamples * numDataPointsPerSample;
140    
141         if (numDataPointsPerSample==0) {
142            throw DataException("FunctionSpace::getReferenceIDFromDataPointNo error: no data-points associated with this object.");
143         }
144         if (dataPointNo<0 || dataPointNo>numDataPoints) {
145            throw DataException("FunctionSpace::getReferenceIDFromDataPointNo error: invalid data-point number supplied.");
146         }
147         int sampleNo = dataPointNo / numDataPointsPerSample;
148         return referenceIDs[sampleNo];
149    }
150    
151    int*
152    FunctionSpace::borrowSampleReferenceIDs() const
153  {  {
154    return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);    return m_domain->borrowSampleReferenceIDs(m_functionSpaceType);
155  }  }
156    
157  FunctionSpace&  FunctionSpace&
158  FunctionSpace::operator=(const FunctionSpace& other)  FunctionSpace::operator=(const FunctionSpace& other)
159  {  {
160    // explicitly defined assignment operator to emphasise pointer copy    // explicitly defined assignment operator to emphasise pointer copy
   m_nullDomainValue=other.m_nullDomainValue;  
161    m_functionSpaceType=other.m_functionSpaceType;    m_functionSpaceType=other.m_functionSpaceType;
162    m_domain=other.m_domain;    m_domain=other.m_domain;
163    return *this;    return *this;
# Line 175  FunctionSpace::setTags(const int newTag, Line 212  FunctionSpace::setTags(const int newTag,
212     }     }
213  }  }
214    
215    int
216    FunctionSpace::getNumberOfTagsInUse() const
217    {
218       return  m_domain->getNumberOfTagsInUse(m_functionSpaceType);
219    }
220    
221    int*
222    FunctionSpace::borrowListOfTagsInUse() const
223    {
224       return  m_domain->borrowListOfTagsInUse(m_functionSpaceType);
225    }
226    
227    std::list<int>
228    FunctionSpace::getListOfTagsSTL() const
229    {
230      std::list<int> taglist;
231      int i;
232      int* tags=borrowListOfTagsInUse();
233      for (i=0;i<getNumberOfTagsInUse();++i) taglist.push_back(tags[i]);
234      return taglist;
235    }
236    
237    
238    boost::python::list
239    FunctionSpace::getListOfTags() const
240    {
241      boost::python::list taglist;
242      int i;
243      int* tags=borrowListOfTagsInUse();
244      for (i=0;i<getNumberOfTagsInUse();++i) taglist.append(tags[i]);
245      return taglist;
246    }
247    
248    bool
249    FunctionSpace::canTag() const
250    {
251      return m_domain->canTag(m_functionSpaceType);
252    }
253    
254  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.906  
changed lines
  Added in v.1802

  ViewVC Help
Powered by ViewVC 1.1.26