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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (hide annotations)
Fri Aug 12 01:45:47 2005 UTC (14 years, 8 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/FunctionSpace.cpp
File size: 3729 byte(s)
erge of development branch dev-02 back to main trunk on 2005-08-12

1 jgs 115 /* $Id$ */
2 jgs 82 /*
3     ******************************************************************************
4     * *
5     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
6     * *
7     * This software is the property of ACcESS. No part of this code *
8     * may be copied in any form or by any means without the expressed written *
9     * consent of ACcESS. Copying, use or modification of this software *
10     * by any unauthorised person is illegal unless that person has a software *
11     * license agreement with ACcESS. *
12     * *
13     ******************************************************************************
14     */
15    
16     #include "escript/Data/AbstractContinuousDomain.h"
17     #include "escript/Data/FunctionSpaceException.h"
18     #include "escript/Data/Data.h"
19     #include "escript/Data/DataFactory.h"
20    
21     #include "escript/Data/FunctionSpace.h"
22    
23     #include <iostream>
24     #include <sstream>
25    
26 jgs 121 using namespace std;
27 jgs 82 namespace escript {
28    
29     //
30     // Create a null domain for use with a default constructed function space
31     NullDomain FunctionSpace::m_nullDomainValue;
32    
33     FunctionSpace::FunctionSpace():
34     m_domain(static_cast<AbstractDomain*>(&m_nullDomainValue)),
35     m_functionSpaceType(m_nullDomainValue.getFunctionCode())
36     {
37     }
38    
39 jgs 117 FunctionSpace::FunctionSpace(const AbstractDomain& domain,
40     int functionSpaceType):
41 jgs 82 m_domain(dynamic_cast<const AbstractDomain*>(&domain)),
42     m_functionSpaceType(functionSpaceType)
43     {
44     if (!m_domain->isValidFunctionSpaceType(functionSpaceType)) {
45     std::stringstream temp;
46     temp << "Invalid function space type: " << functionSpaceType
47     <<" for domain: " << m_domain->getDescription();
48     throw FunctionSpaceException(temp.str());
49     }
50     }
51    
52 jgs 117 std::pair<int,int>
53     FunctionSpace::getDataShape() const
54 jgs 82 {
55     return m_domain->getDataShape(m_functionSpaceType);
56     }
57    
58 jgs 117 int
59     FunctionSpace::getTypeCode() const
60 jgs 82 {
61     return m_functionSpaceType;
62     }
63    
64 jgs 117 const
65     AbstractDomain&
66     FunctionSpace::getDomain() const
67 jgs 82 {
68     return *m_domain;
69     }
70    
71 jgs 117 std::string
72     FunctionSpace::toString() const
73 jgs 82 {
74     std::stringstream temp;
75     temp << "Function space type: "
76     << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
77     << " on " << m_domain->getDescription();
78     return temp.str();
79     }
80    
81 jgs 117 int
82     FunctionSpace::getTagFromSampleNo(int sampleNo) const
83 jgs 82 {
84     return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
85     }
86    
87 jgs 117 int
88     FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
89 jgs 110 {
90     return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
91     }
92    
93 jgs 117 FunctionSpace&
94     FunctionSpace::operator=(const FunctionSpace& other)
95 jgs 82 {
96     //
97     // explicitly defined assignment operator to emphasise pointer copy
98     m_nullDomainValue=other.m_nullDomainValue;
99     m_functionSpaceType=other.m_functionSpaceType;
100     m_domain=other.m_domain;
101     return *this;
102     }
103    
104 jgs 117 bool
105     FunctionSpace::operator==(const FunctionSpace& other) const
106 jgs 82 {
107 jgs 121 return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
108 jgs 82 }
109    
110 jgs 117 bool
111     FunctionSpace::operator!=(const FunctionSpace& other) const
112 jgs 82 {
113 jgs 121 return !(operator==(other));
114 jgs 82 }
115    
116 jgs 117 escript::Data
117     FunctionSpace::getX() const
118 jgs 82 {
119     Data out=escript::Vector(0,*this,true);
120     getDomain().setToX(out);
121     return out;
122     }
123    
124 jgs 117 escript::Data
125     FunctionSpace::getNormal() const
126 jgs 82 {
127     Data out=escript::Vector(0,*this,true);
128     getDomain().setToNormal(out);
129     return out;
130     }
131    
132 jgs 117 escript::Data
133     FunctionSpace::getSize() const
134 jgs 82 {
135     Data out=escript::Scalar(0,*this,true);
136     getDomain().setToSize(out);
137     return out;
138     }
139    
140     } // end of namespace

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26