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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 117 - (hide annotations)
Fri Apr 1 05:48:57 2005 UTC (14 years, 3 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/FunctionSpace.cpp
File size: 3695 byte(s)
*** empty log message ***

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     namespace escript {
27    
28     //
29     // Create a null domain for use with a default constructed function space
30     NullDomain FunctionSpace::m_nullDomainValue;
31    
32     FunctionSpace::FunctionSpace():
33     m_domain(static_cast<AbstractDomain*>(&m_nullDomainValue)),
34     m_functionSpaceType(m_nullDomainValue.getFunctionCode())
35     {
36     }
37    
38 jgs 117 FunctionSpace::FunctionSpace(const AbstractDomain& domain,
39     int functionSpaceType):
40 jgs 82 m_domain(dynamic_cast<const AbstractDomain*>(&domain)),
41     m_functionSpaceType(functionSpaceType)
42     {
43     if (!m_domain->isValidFunctionSpaceType(functionSpaceType)) {
44     std::stringstream temp;
45     temp << "Invalid function space type: " << functionSpaceType
46     <<" for domain: " << m_domain->getDescription();
47     throw FunctionSpaceException(temp.str());
48     }
49     }
50    
51 jgs 117 std::pair<int,int>
52     FunctionSpace::getDataShape() const
53 jgs 82 {
54     return m_domain->getDataShape(m_functionSpaceType);
55     }
56    
57 jgs 117 int
58     FunctionSpace::getTypeCode() const
59 jgs 82 {
60     return m_functionSpaceType;
61     }
62    
63 jgs 117 const
64     AbstractDomain&
65     FunctionSpace::getDomain() const
66 jgs 82 {
67     return *m_domain;
68     }
69    
70 jgs 117 std::string
71     FunctionSpace::toString() const
72 jgs 82 {
73     std::stringstream temp;
74     temp << "Function space type: "
75     << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
76     << " on " << m_domain->getDescription();
77     return temp.str();
78     }
79    
80 jgs 117 int
81     FunctionSpace::getTagFromSampleNo(int sampleNo) const
82 jgs 82 {
83     return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
84     }
85    
86 jgs 117 int
87     FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
88 jgs 110 {
89     return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
90     }
91    
92 jgs 117 FunctionSpace&
93     FunctionSpace::operator=(const FunctionSpace& other)
94 jgs 82 {
95     //
96     // explicitly defined assignment operator to emphasise pointer copy
97     m_nullDomainValue=other.m_nullDomainValue;
98     m_functionSpaceType=other.m_functionSpaceType;
99     m_domain=other.m_domain;
100     return *this;
101     }
102    
103 jgs 117 bool
104     FunctionSpace::operator==(const FunctionSpace& other) const
105 jgs 82 {
106     return (other.m_domain==m_domain && other.m_functionSpaceType==m_functionSpaceType);
107     }
108    
109 jgs 117 bool
110     FunctionSpace::operator!=(const FunctionSpace& other) const
111 jgs 82 {
112     return (!(other==*this));
113     }
114    
115 jgs 117 escript::Data
116     FunctionSpace::getX() const
117 jgs 82 {
118     Data out=escript::Vector(0,*this,true);
119     getDomain().setToX(out);
120     return out;
121     }
122    
123 jgs 117 escript::Data
124     FunctionSpace::getNormal() const
125 jgs 82 {
126     Data out=escript::Vector(0,*this,true);
127     getDomain().setToNormal(out);
128     return out;
129     }
130    
131 jgs 117 escript::Data
132     FunctionSpace::getSize() const
133 jgs 82 {
134     Data out=escript::Scalar(0,*this,true);
135     getDomain().setToSize(out);
136     return out;
137     }
138    
139     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26