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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 115 - (show annotations)
Fri Mar 4 07:12:47 2005 UTC (14 years, 7 months ago) by jgs
Original Path: trunk/esys2/escript/src/Data/FunctionSpace.cpp
File size: 3808 byte(s)
*** empty log message ***

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 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 //std::cout << "Called FunctionSpace DEFAULT constructor." << std::endl;
37 }
38
39 FunctionSpace::FunctionSpace(const AbstractDomain& domain, int functionSpaceType):
40 m_domain(dynamic_cast<const AbstractDomain*>(&domain)),
41 m_functionSpaceType(functionSpaceType)
42 {
43 //std::cout << "Called FunctionSpace constructor." << std::endl;
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> FunctionSpace::getDataShape() const
53 {
54 return m_domain->getDataShape(m_functionSpaceType);
55 }
56
57 int FunctionSpace::getTypeCode() const
58 {
59 return m_functionSpaceType;
60 }
61
62 const AbstractDomain& FunctionSpace::getDomain() const
63 {
64 return *m_domain;
65 }
66
67 std::string FunctionSpace::toString() const
68 {
69 std::stringstream temp;
70 temp << "Function space type: "
71 << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
72 << " on " << m_domain->getDescription();
73 return temp.str();
74 }
75
76 int FunctionSpace::getTagFromSampleNo(int sampleNo) const
77 {
78 return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
79 }
80
81 int FunctionSpace::getReferenceNoFromSampleNo(int sampleNo) const
82 {
83 return m_domain->getReferenceNoFromSampleNo(m_functionSpaceType,sampleNo);
84 }
85
86 FunctionSpace& FunctionSpace::operator=(const FunctionSpace& other)
87 {
88 //
89 // explicitly defined assignment operator to emphasise pointer copy
90 m_nullDomainValue=other.m_nullDomainValue;
91 m_functionSpaceType=other.m_functionSpaceType;
92 m_domain=other.m_domain;
93 return *this;
94 }
95
96 bool FunctionSpace::operator==(const FunctionSpace& other) const
97 {
98 return (other.m_domain==m_domain && other.m_functionSpaceType==m_functionSpaceType);
99 }
100
101 bool FunctionSpace::operator!=(const FunctionSpace& other) const
102 {
103 return (!(other==*this));
104 }
105
106 escript::Data FunctionSpace::getX() const
107 {
108 Data out=escript::Vector(0,*this,true);
109 getDomain().setToX(out);
110 return out;
111 }
112
113 escript::Data FunctionSpace::getNormal() const
114 {
115 Data out=escript::Vector(0,*this,true);
116 getDomain().setToNormal(out);
117 return out;
118 }
119
120 escript::Data FunctionSpace::getSize() const
121 {
122 Data out=escript::Scalar(0,*this,true);
123 getDomain().setToSize(out);
124 return out;
125 }
126
127 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26