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

Legend:
Removed from v.1388  
changed lines
  Added in v.1811

  ViewVC Help
Powered by ViewVC 1.1.26