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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 121 - (hide 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 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 jgs 121 cout << "toString" << m_domain->getDescription() << "\n";
75 jgs 82 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 jgs 117 int
83     FunctionSpace::getTagFromSampleNo(int sampleNo) const
84 jgs 82 {
85     return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
86     }
87    
88 jgs 117 int
89     FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
90 jgs 110 {
91     return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
92     }
93    
94 jgs 117 FunctionSpace&
95     FunctionSpace::operator=(const FunctionSpace& other)
96 jgs 82 {
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 jgs 117 bool
106     FunctionSpace::operator==(const FunctionSpace& other) const
107 jgs 82 {
108 jgs 121 return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
109 jgs 82 }
110    
111 jgs 117 bool
112     FunctionSpace::operator!=(const FunctionSpace& other) const
113 jgs 82 {
114 jgs 121 return !(operator==(other));
115 jgs 82 }
116    
117 jgs 117 escript::Data
118     FunctionSpace::getX() const
119 jgs 82 {
120     Data out=escript::Vector(0,*this,true);
121     getDomain().setToX(out);
122     return out;
123     }
124    
125 jgs 117 escript::Data
126     FunctionSpace::getNormal() const
127 jgs 82 {
128     Data out=escript::Vector(0,*this,true);
129     getDomain().setToNormal(out);
130     return out;
131     }
132    
133 jgs 117 escript::Data
134     FunctionSpace::getSize() const
135 jgs 82 {
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