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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 110 - (hide annotations)
Mon Feb 14 04:14:42 2005 UTC (14 years, 9 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/FunctionSpace.cpp
File size: 3797 byte(s)
*** empty log message ***

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26