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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 121 - (show annotations)
Fri May 6 04:26:16 2005 UTC (14 years, 5 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/FunctionSpace.cpp
File size: 3787 byte(s)
Merge of development branch back to main trunk on 2005-05-06

1 /* $Id$ */
2 /*
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 using namespace std;
27 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 FunctionSpace::FunctionSpace(const AbstractDomain& domain,
40 int functionSpaceType):
41 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 std::pair<int,int>
53 FunctionSpace::getDataShape() const
54 {
55 return m_domain->getDataShape(m_functionSpaceType);
56 }
57
58 int
59 FunctionSpace::getTypeCode() const
60 {
61 return m_functionSpaceType;
62 }
63
64 const
65 AbstractDomain&
66 FunctionSpace::getDomain() const
67 {
68 return *m_domain;
69 }
70
71 std::string
72 FunctionSpace::toString() const
73 {
74 cout << "toString" << m_domain->getDescription() << "\n";
75 std::stringstream temp;
76 temp << "Function space type: "
77 << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
78 << " on " << m_domain->getDescription();
79 return temp.str();
80 }
81
82 int
83 FunctionSpace::getTagFromSampleNo(int sampleNo) const
84 {
85 return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
86 }
87
88 int
89 FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
90 {
91 return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
92 }
93
94 FunctionSpace&
95 FunctionSpace::operator=(const FunctionSpace& other)
96 {
97 //
98 // explicitly defined assignment operator to emphasise pointer copy
99 m_nullDomainValue=other.m_nullDomainValue;
100 m_functionSpaceType=other.m_functionSpaceType;
101 m_domain=other.m_domain;
102 return *this;
103 }
104
105 bool
106 FunctionSpace::operator==(const FunctionSpace& other) const
107 {
108 return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
109 }
110
111 bool
112 FunctionSpace::operator!=(const FunctionSpace& other) const
113 {
114 return !(operator==(other));
115 }
116
117 escript::Data
118 FunctionSpace::getX() const
119 {
120 Data out=escript::Vector(0,*this,true);
121 getDomain().setToX(out);
122 return out;
123 }
124
125 escript::Data
126 FunctionSpace::getNormal() const
127 {
128 Data out=escript::Vector(0,*this,true);
129 getDomain().setToNormal(out);
130 return out;
131 }
132
133 escript::Data
134 FunctionSpace::getSize() const
135 {
136 Data out=escript::Scalar(0,*this,true);
137 getDomain().setToSize(out);
138 return out;
139 }
140
141 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26