/[escript]/branches/windows_from_1383_trunk/finley/src/CPPAdapter/TransportProblemAdapter.cpp
ViewVC logotype

Contents of /branches/windows_from_1383_trunk/finley/src/CPPAdapter/TransportProblemAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1394 - (show annotations)
Wed Jan 23 05:24:17 2008 UTC (12 years, 5 months ago) by trankine
File size: 4041 byte(s)
Somehow an ESCRIPT_DLL_API had crept into the header file, and to compound matters, the definition in the cpp file had no call method specifier at all. Windows hates people doing that.
1 /*******************************************************
2 *
3 * Copyright 2007 by University of Queensland
4 *
5 * http://esscc.uq.edu.au
6 * Primary Business: Queensland, Australia
7 * Licensed under the Open Software License version 3.0
8 * http://www.opensource.org/licenses/osl-3.0.php
9 *
10 *******************************************************/
11
12 #ifdef PASO_MPI
13 #include <mpi.h>
14 #endif
15 #include "TransportProblemAdapter.h"
16 #include "SystemMatrixAdapter.h"
17
18 using namespace std;
19
20 namespace finley {
21
22 struct null_deleter
23 {
24 void operator()(void const *ptr) const
25 {
26 }
27 };
28
29
30 TransportProblemAdapter::TransportProblemAdapter()
31 {
32 throw FinleyAdapterException("Error - Illegal to generate default TransportProblemAdapter.");
33 }
34
35
36 TransportProblemAdapter::TransportProblemAdapter(Paso_FCTransportProblem* transport_problem,
37 const double theta,
38 const double dt_max,
39 const int block_size,
40 const escript::FunctionSpace& functionspace):
41 AbstractTransportProblem(theta, dt_max, block_size, functionspace)
42 {
43 m_transport_problem.reset(transport_problem,null_deleter());
44 }
45
46 TransportProblemAdapter::~TransportProblemAdapter()
47 {
48 if (m_transport_problem.unique()) {
49 Paso_FCTransportProblem* transp=m_transport_problem.get();
50 Paso_FCTransportProblem_free(transp);
51 }
52 }
53
54 Paso_FCTransportProblem* TransportProblemAdapter::getPaso_FCTransportProblem() const
55 {
56 return m_transport_problem.get();
57 }
58
59 FINLEY_DLL_API
60 void TransportProblemAdapter::setToSolution(escript::Data& out, escript::Data& source, const double dt, const boost::python::dict& options) const
61 {
62 Paso_FCTransportProblem* transp=getPaso_FCTransportProblem();
63 Paso_Options paso_options;
64 SystemMatrixAdapter::dictToPasoOptions(&paso_options,options);
65 if ( out.getDataPointSize() != getBlockSize()) {
66 throw FinleyAdapterException("solve : block size of solution does not match block size of transport problems.");
67 } else if ( source.getDataPointSize() != getBlockSize()) {
68 throw FinleyAdapterException("solve : block size of source term does not match block size of transport problems.");
69 } else if ( out.getFunctionSpace() != getFunctionSpace()) {
70 throw FinleyAdapterException("solve : function spaces of solution and of transport problem don't match.");
71 } else if (source.getFunctionSpace() != getFunctionSpace()) {
72 throw FinleyAdapterException("solve : function spaces of source term and of transport problem don't match.");
73 } else if (dt<=0.) {
74 throw FinleyAdapterException("solve : time increment dt needs to be positive.");
75 }
76 out.expand();
77 source.expand();
78 double* out_dp=out.getSampleData(0);
79 double* source_dp=source.getSampleData(0);
80 Paso_SolverFCT_solve(transp,out_dp,dt,source_dp,&paso_options);
81 checkPasoError();
82 }
83
84 FINLEY_DLL_API
85 void TransportProblemAdapter::resetTransport() const
86 {
87 Paso_FCTransportProblem* transp = getPaso_FCTransportProblem();
88 throw FinleyAdapterException("resetTransport() not implemented yet.");
89 //
90 //
91 // Paso_FCTransportProblem_setValues(transp,0.);
92 // Paso_solve_free(transp);
93 checkPasoError();
94 }
95
96 FINLEY_DLL_API
97 void TransportProblemAdapter::copyInitialValue(escript::Data& u) const
98 {
99 Paso_FCTransportProblem* transp=getPaso_FCTransportProblem();
100 if ( u.getDataPointSize() != getBlockSize()) {
101 throw FinleyAdapterException("copyInitialValue : block size of solution does not match block size of transport problems.");
102 } else if ( u.getFunctionSpace() != getFunctionSpace()) {
103 throw FinleyAdapterException("copyInitialValue : function spaces of solution and of transport problem don't match.");
104 }
105 u.expand();
106 double* u_dp=u.getSampleData(0);
107 Paso_FCTransportProblem_checkinSolution( transp,u_dp);
108 checkPasoError();
109 }
110
111
112 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26