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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (show annotations)
Fri Aug 12 01:45:47 2005 UTC (14 years, 3 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 /* $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 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 int
82 FunctionSpace::getTagFromSampleNo(int sampleNo) const
83 {
84 return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
85 }
86
87 int
88 FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
89 {
90 return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
91 }
92
93 FunctionSpace&
94 FunctionSpace::operator=(const FunctionSpace& other)
95 {
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 bool
105 FunctionSpace::operator==(const FunctionSpace& other) const
106 {
107 return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
108 }
109
110 bool
111 FunctionSpace::operator!=(const FunctionSpace& other) const
112 {
113 return !(operator==(other));
114 }
115
116 escript::Data
117 FunctionSpace::getX() const
118 {
119 Data out=escript::Vector(0,*this,true);
120 getDomain().setToX(out);
121 return out;
122 }
123
124 escript::Data
125 FunctionSpace::getNormal() const
126 {
127 Data out=escript::Vector(0,*this,true);
128 getDomain().setToNormal(out);
129 return out;
130 }
131
132 escript::Data
133 FunctionSpace::getSize() const
134 {
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