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

Annotation of /trunk/finley/src/CPPAdapter/TransportProblemAdapter.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1365 - (hide annotations)
Mon Dec 17 07:28:23 2007 UTC (14 years, 8 months ago) by gross
File size: 3997 byte(s)
some cosmetics.
1 ksteube 1312 /*******************************************************
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 ksteube 817 #ifdef PASO_MPI
13     #include <mpi.h>
14     #endif
15 gross 1364 #include "TransportProblemAdapter.h"
16 jgs 203 #include "SystemMatrixAdapter.h"
17 jgs 82
18     using namespace std;
19    
20     namespace finley {
21    
22 jgs 102 struct null_deleter
23     {
24     void operator()(void const *ptr) const
25     {
26     }
27     };
28    
29    
30 gross 1364 TransportProblemAdapter::TransportProblemAdapter()
31 jgs 82 {
32 gross 1364 throw FinleyAdapterException("Error - Illegal to generate default TransportProblemAdapter.");
33 jgs 82 }
34    
35 gross 1364
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 jgs 82 {
43 gross 1364 m_transport_problem.reset(transport_problem,null_deleter());
44 jgs 82 }
45    
46 gross 1364 TransportProblemAdapter::~TransportProblemAdapter()
47 jgs 82 {
48 gross 1364 if (m_transport_problem.unique()) {
49     Paso_FCTransportProblem* transp=m_transport_problem.get();
50     Paso_FCTransportProblem_free(transp);
51 jgs 82 }
52     }
53    
54 gross 1364 Paso_FCTransportProblem* TransportProblemAdapter::getPaso_FCTransportProblem() const
55 jgs 82 {
56 gross 1364 return m_transport_problem.get();
57 jgs 82 }
58    
59 jgs 150
60 gross 1364 void TransportProblemAdapter::setToSolution(escript::Data& out, escript::Data& source, const double dt, const boost::python::dict& options) const
61 ksteube 1339 {
62 gross 1364 Paso_FCTransportProblem* transp=getPaso_FCTransportProblem();
63 jgs 150 Paso_Options paso_options;
64 gross 1364 SystemMatrixAdapter::dictToPasoOptions(&paso_options,options);
65     if ( out.getDataPointSize() != getBlockSize()) {
66 gross 1365 throw FinleyAdapterException("solve : block size of solution does not match block size of transport problems.");
67 gross 1364 } else if ( source.getDataPointSize() != getBlockSize()) {
68 gross 1365 throw FinleyAdapterException("solve : block size of source term does not match block size of transport problems.");
69 gross 1364 } else if ( out.getFunctionSpace() != getFunctionSpace()) {
70 gross 1365 throw FinleyAdapterException("solve : function spaces of solution and of transport problem don't match.");
71 gross 1364 } else if (source.getFunctionSpace() != getFunctionSpace()) {
72 gross 1365 throw FinleyAdapterException("solve : function spaces of source term and of transport problem don't match.");
73 gross 1364 } else if (dt<=0.) {
74 gross 1365 throw FinleyAdapterException("solve : time increment dt needs to be positive.");
75 jgs 150 }
76 jgs 153 out.expand();
77 gross 1364 source.expand();
78 jgs 150 double* out_dp=out.getSampleData(0);
79 gross 1364 double* source_dp=source.getSampleData(0);
80     Paso_SolverFCT_solve(transp,out_dp,dt,source_dp,&paso_options);
81 jgs 150 checkPasoError();
82 jgs 82 }
83    
84 gross 1364 void TransportProblemAdapter::resetTransport() const
85 jgs 82 {
86 gross 1364 Paso_FCTransportProblem* transp = getPaso_FCTransportProblem();
87     throw FinleyAdapterException("resetTransport() not implemented yet.");
88     //
89     //
90     // Paso_FCTransportProblem_setValues(transp,0.);
91     // Paso_solve_free(transp);
92     checkPasoError();
93 jgs 82 }
94    
95 gross 1364 void TransportProblemAdapter::copyInitialValue(escript::Data& u) const
96 jgs 102 {
97 gross 1364 Paso_FCTransportProblem* transp=getPaso_FCTransportProblem();
98 gross 1365 if ( u.getDataPointSize() != getBlockSize()) {
99     throw FinleyAdapterException("copyInitialValue : block size of solution does not match block size of transport problems.");
100     } else if ( u.getFunctionSpace() != getFunctionSpace()) {
101     throw FinleyAdapterException("copyInitialValue : function spaces of solution and of transport problem don't match.");
102     }
103 gross 1364 u.expand();
104     double* u_dp=u.getSampleData(0);
105     Paso_FCTransportProblem_checkinSolution( transp,u_dp);
106 jgs 150 checkPasoError();
107 jgs 102 }
108    
109 woo409 757
110 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