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

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

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

revision 110 by jgs, Mon Feb 14 04:14:42 2005 UTC revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC
# Line 1  Line 1 
1    /* $Id$ */
2  /*  /*
3   ******************************************************************************   ******************************************************************************
4   *                                                                            *   *                                                                            *
# Line 22  Line 23 
23  #include <iostream>  #include <iostream>
24  #include <sstream>  #include <sstream>
25    
26    using namespace std;
27  namespace escript {  namespace escript {
28    
29  //  //
# Line 32  FunctionSpace::FunctionSpace(): Line 34  FunctionSpace::FunctionSpace():
34    m_domain(static_cast<AbstractDomain*>(&m_nullDomainValue)),    m_domain(static_cast<AbstractDomain*>(&m_nullDomainValue)),
35    m_functionSpaceType(m_nullDomainValue.getFunctionCode())    m_functionSpaceType(m_nullDomainValue.getFunctionCode())
36  {  {
   //std::cout << "Called FunctionSpace DEFAULT constructor." << std::endl;  
37  }  }
38    
39  FunctionSpace::FunctionSpace(const AbstractDomain& domain, int functionSpaceType):  FunctionSpace::FunctionSpace(const AbstractDomain& domain,
40                                 int functionSpaceType):
41    m_domain(dynamic_cast<const AbstractDomain*>(&domain)),    m_domain(dynamic_cast<const AbstractDomain*>(&domain)),
42    m_functionSpaceType(functionSpaceType)    m_functionSpaceType(functionSpaceType)
43  {  {
   //std::cout << "Called FunctionSpace constructor." << std::endl;  
44    if (!m_domain->isValidFunctionSpaceType(functionSpaceType)) {    if (!m_domain->isValidFunctionSpaceType(functionSpaceType)) {
45      std::stringstream temp;      std::stringstream temp;
46      temp << "Invalid function space type: " << functionSpaceType      temp << "Invalid function space type: " << functionSpaceType
# Line 48  FunctionSpace::FunctionSpace(const Abstr Line 49  FunctionSpace::FunctionSpace(const Abstr
49    }    }
50  }  }
51    
52  std::pair<int,int> FunctionSpace::getDataShape() const  std::pair<int,int>
53    FunctionSpace::getDataShape() const
54  {  {
55    return m_domain->getDataShape(m_functionSpaceType);    return m_domain->getDataShape(m_functionSpaceType);
56  }  }
57    
58  int FunctionSpace::getTypeCode() const  int
59    FunctionSpace::getTypeCode() const
60  {  {
61    return  m_functionSpaceType;    return  m_functionSpaceType;
62  }  }
63    
64  const AbstractDomain& FunctionSpace::getDomain() const  const
65    AbstractDomain&
66    FunctionSpace::getDomain() const
67  {  {
68    return *m_domain;    return *m_domain;
69  }  }
70    
71  std::string FunctionSpace::toString() const  std::string
72    FunctionSpace::toString() const
73  {  {
74    std::stringstream temp;    std::stringstream temp;
75    temp << "Function space type: "    temp << "Function space type: "
# Line 72  std::string FunctionSpace::toString() co Line 78  std::string FunctionSpace::toString() co
78    return temp.str();    return temp.str();
79  }  }
80    
81  int FunctionSpace::getTagFromSampleNo(int sampleNo) const  int
82    FunctionSpace::getTagFromSampleNo(int sampleNo) const
83  {  {
84    return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);    return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
85  }  }
86    
87  int FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const  int
88    FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
89  {  {
90    return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);    return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
91  }  }
92    
93  FunctionSpace& FunctionSpace::operator=(const FunctionSpace& other)  FunctionSpace&
94    FunctionSpace::operator=(const FunctionSpace& other)
95  {  {
96    //    //
97    // explicitly defined assignment operator to emphasise pointer copy    // explicitly defined assignment operator to emphasise pointer copy
# Line 92  FunctionSpace& FunctionSpace::operator=( Line 101  FunctionSpace& FunctionSpace::operator=(
101    return *this;    return *this;
102  }  }
103    
104  bool FunctionSpace::operator==(const FunctionSpace& other) const  bool
105    FunctionSpace::operator==(const FunctionSpace& other) const
106  {  {
107    return (other.m_domain==m_domain && other.m_functionSpaceType==m_functionSpaceType);    return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
108  }  }
109    
110  bool FunctionSpace::operator!=(const FunctionSpace& other) const  bool
111    FunctionSpace::operator!=(const FunctionSpace& other) const
112  {  {
113    return (!(other==*this));    return !(operator==(other));
114  }  }
115    
116  escript::Data FunctionSpace::getX() const  escript::Data
117    FunctionSpace::getX() const
118  {  {
119    Data out=escript::Vector(0,*this,true);    Data out=escript::Vector(0,*this,true);
120    getDomain().setToX(out);    getDomain().setToX(out);
121    return out;    return out;
122  }  }
123    
124  escript::Data FunctionSpace::getNormal() const  escript::Data
125    FunctionSpace::getNormal() const
126  {  {
127    Data out=escript::Vector(0,*this,true);    Data out=escript::Vector(0,*this,true);
128    getDomain().setToNormal(out);    getDomain().setToNormal(out);
129    return out;    return out;
130  }  }
131    
132  escript::Data FunctionSpace::getSize() const  escript::Data
133    FunctionSpace::getSize() const
134  {  {
135    Data out=escript::Scalar(0,*this,true);    Data out=escript::Scalar(0,*this,true);
136    getDomain().setToSize(out);    getDomain().setToSize(out);

Legend:
Removed from v.110  
changed lines
  Added in v.147

  ViewVC Help
Powered by ViewVC 1.1.26