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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 82 - (hide annotations)
Tue Oct 26 06:53:54 2004 UTC (15 years ago) by jgs
File size: 3649 byte(s)
Initial revision

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     FunctionSpace& FunctionSpace::operator=(const FunctionSpace& other)
81     {
82     //
83     // explicitly defined assignment operator to emphasise pointer copy
84     m_nullDomainValue=other.m_nullDomainValue;
85     m_functionSpaceType=other.m_functionSpaceType;
86     m_domain=other.m_domain;
87     return *this;
88     }
89    
90     bool FunctionSpace::operator==(const FunctionSpace& other) const
91     {
92     return (other.m_domain==m_domain && other.m_functionSpaceType==m_functionSpaceType);
93     }
94    
95     bool FunctionSpace::operator!=(const FunctionSpace& other) const
96     {
97     return (!(other==*this));
98     }
99    
100     escript::Data FunctionSpace::getX() const
101     {
102     Data out=escript::Vector(0,*this,true);
103     getDomain().setToX(out);
104     return out;
105     }
106    
107     escript::Data FunctionSpace::getNormal() const
108     {
109     Data out=escript::Vector(0,*this,true);
110     getDomain().setToNormal(out);
111     return out;
112     }
113    
114     escript::Data FunctionSpace::getSize() const
115     {
116     Data out=escript::Scalar(0,*this,true);
117     getDomain().setToSize(out);
118     return out;
119     }
120    
121     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26