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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1628 - (hide annotations)
Fri Jul 11 13:12:46 2008 UTC (11 years, 7 months ago) by phornby
File size: 4637 byte(s)

Merge in /branches/windows_from_1456_trunk_1620_merged_in branch.

You will find a preserved pre-merge trunk in tags under tags/trunk_at_1625.
That will be useful for diffing & checking on my stupidity.

Here is a list of the conflicts and their resolution at this
point in time.


=================================================================================
(LLWS == looks like white space).

finley/src/Assemble_addToSystemMatrix.c - resolve to branch - unused var. may be wrong.....
finley/src/CPPAdapter/SystemMatrixAdapter.cpp - resolve to branch - LLWS
finley/src/CPPAdapter/MeshAdapter.cpp - resolve to branch - LLWS
paso/src/PCG.c - resolve to branch - unused var fixes.
paso/src/SolverFCT.c - resolve to branch - LLWS
paso/src/FGMRES.c - resolve to branch - LLWS
paso/src/Common.h - resolve to trunk version. It's omp.h's include... not sure it's needed,
but for the sake of saftey.....
paso/src/Functions.c - resolve to branch version, indentation/tab removal and return error
on bad unimplemented Paso_FunctionCall.
paso/src/SolverFCT_solve.c - resolve to branch version, unused vars
paso/src/SparseMatrix_MatrixVector.c - resolve to branch version, unused vars.
escript/src/Utils.cpp - resloved to branch, needs WinSock2.h
escript/src/DataExpanded.cpp - resolved to branch version - LLWS
escript/src/DataFactory.cpp - resolve to branch version
=================================================================================

This currently passes tests on linux (debian), but is not checked on windows or Altix yet.

This checkin is to make a trunk I can check out for windows to do tests on it.

Known outstanding problem is in the operator=() method of exceptions
causing warning messages on the intel compilers.

May the God of doughnuts have mercy on my soul.


1 ksteube 1312
2 jgs 115 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 jgs 480 #include "FunctionSpace.h"
17 jgs 474 #include "FunctionSpaceException.h"
18     #include "Data.h"
19     #include "DataFactory.h"
20 jgs 82
21     #include <iostream>
22     #include <sstream>
23    
24 jgs 121 using namespace std;
25 jgs 149
26 jgs 82 namespace escript {
27    
28     //
29 jgs 149 // Create a null domain for use with any default-constructed function space
30 trankine 1426 NullDomain const FunctionSpace::nullDomainValue;
31 jgs 82
32     FunctionSpace::FunctionSpace():
33 trankine 1426 m_domain(static_cast<const AbstractDomain*>(&nullDomainValue)),
34     m_functionSpaceType(nullDomainValue.getFunctionCode())
35 jgs 82 {
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 jgs 149 << " for domain: " << m_domain->getDescription();
47 jgs 82 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 phornby 1628 std::string
71 jgs 117 FunctionSpace::toString() const
72 jgs 82 {
73     std::stringstream temp;
74 ksteube 1312 temp << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
75     << " on " << m_domain->getDescription();
76 trankine 1426
77 phornby 1628 return temp.str();
78 jgs 82 }
79    
80 trankine 1426
81     #ifdef DEBUG_PY_STRINGS
82     PyObject *
83     FunctionSpace::toPyString() const
84     {
85     boost::python::to_python_value<const std::string &> cvtr;
86     std::stringstream temp;
87    
88     temp << m_domain->functionSpaceTypeAsString(m_functionSpaceType)
89     << " on " << m_domain->getDescription();
90    
91 phornby 1628 return cvtr(temp.str());
92 trankine 1426 }
93     #endif
94    
95    
96 jgs 117 int
97     FunctionSpace::getTagFromSampleNo(int sampleNo) const
98 jgs 82 {
99     return m_domain->getTagFromSampleNo(m_functionSpaceType,sampleNo);
100     }
101    
102 jgs 117 int
103 jgs 149 FunctionSpace::getTagFromDataPointNo(int dataPointNo) const
104     {
105     //
106     // Get the number of samples and data-points per sample
107     int numSamples = getNumSamples();
108     int numDataPointsPerSample = getNumDPPSample();
109     int numDataPoints = numSamples * numDataPointsPerSample;
110    
111     if (numDataPointsPerSample==0) {
112     throw DataException("FunctionSpace::getTagFromDataPointNo error: no data-points associated with this object.");
113     }
114    
115     if (dataPointNo<0 || dataPointNo>numDataPoints) {
116     throw DataException("FunctionSpace::getTagFromDataPointNo error: invalid data-point number supplied.");
117     }
118    
119     //
120     // Determine the sample number which corresponds to this data-point number
121     int sampleNo = dataPointNo / numDataPointsPerSample;
122    
123     //
124     // Determine the tag number which corresponds to this sample number
125     int tagNo = getTagFromSampleNo(sampleNo);
126    
127     //
128     // return the tag number
129     return(tagNo);
130     }
131    
132 gross 964 int*
133     FunctionSpace::borrowSampleReferenceIDs() const
134 jgs 110 {
135 gross 964 return m_domain->borrowSampleReferenceIDs(m_functionSpaceType);
136 jgs 110 }
137    
138 jgs 117 FunctionSpace&
139     FunctionSpace::operator=(const FunctionSpace& other)
140 jgs 82 {
141     // explicitly defined assignment operator to emphasise pointer copy
142     m_functionSpaceType=other.m_functionSpaceType;
143     m_domain=other.m_domain;
144     return *this;
145     }
146    
147 jgs 117 bool
148     FunctionSpace::operator==(const FunctionSpace& other) const
149 jgs 82 {
150 jgs 121 return ((*(other.m_domain)==*(m_domain)) && (other.m_functionSpaceType==m_functionSpaceType));
151 jgs 82 }
152    
153 jgs 117 bool
154     FunctionSpace::operator!=(const FunctionSpace& other) const
155 jgs 82 {
156 jgs 121 return !(operator==(other));
157 jgs 82 }
158    
159 jgs 117 escript::Data
160     FunctionSpace::getX() const
161 jgs 82 {
162     Data out=escript::Vector(0,*this,true);
163     getDomain().setToX(out);
164 gross 783 out.setProtection();
165 jgs 82 return out;
166     }
167    
168 jgs 117 escript::Data
169     FunctionSpace::getNormal() const
170 jgs 82 {
171     Data out=escript::Vector(0,*this,true);
172     getDomain().setToNormal(out);
173 gross 783 out.setProtection();
174 jgs 82 return out;
175     }
176    
177 jgs 117 escript::Data
178     FunctionSpace::getSize() const
179 jgs 82 {
180     Data out=escript::Scalar(0,*this,true);
181     getDomain().setToSize(out);
182 gross 783 out.setProtection();
183 jgs 82 return out;
184     }
185    
186 gross 767 void
187     FunctionSpace::setTags(const int newTag, const escript::Data& mask) const
188     {
189     if (mask.getFunctionSpace()== *this) {
190     m_domain->setTags(m_functionSpaceType,newTag,mask);
191     } else {
192     throw FunctionSpaceException("illegal function space of mask.");
193     }
194     }
195    
196 jgs 82 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26