escript  Revision_
NonReducedVariable.h
Go to the documentation of this file.
1 /*****************************************************************************
2 *
3 * Copyright (c) 2014-2018 by The University of Queensland
4 * http://www.uq.edu.au
5 *
6 * Primary Business: Queensland, Australia
7 * Licensed under the Apache License, version 2.0
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
11 * Development 2012-2013 by School of Earth Sciences
12 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
13 *
14 *****************************************************************************/
15 
16 #ifndef __ESCRIPT_NONREDUCEDVARIABLE_H__
17 #define __ESCRIPT_NONREDUCEDVARIABLE_H__
18 
19 #include "AbstractReducer.h"
20 #include "Data.h"
21 
22 namespace escript
23 {
24 
25 // plugs into the import/export mechanism but stays on the
26 // subworld it was created by (no actual reduction takes place)
27 class NonReducedVariable : public AbstractReducer
28 {
29 public:
32 
33  // This is not a constructor parameter because
34  // if these are created outside the subworld, they won't have
35  // access to a domain yet.
36  // I also want SplitWorld to be able to set this
38  bool valueCompatible(boost::python::object v);
39  bool reduceLocalValue(boost::python::object v, std::string& errstring);
40  void reset();
41  bool checkRemoteCompatibility(JMPI& mpi_info, std::string& errstring);
42 
43  void getCompatibilityInfo(std::vector<unsigned>& params);
44 
45  // talk to corresponding processes in other subworlds
46  bool reduceRemoteValues(MPI_Comm& mpi_info);
47 
48  // human readable description
49  std::string description();
50 
51  // Get a value for this variable from another process
52  // This is not a reduction and will replace any existing value
53  bool recvFrom(int localid, int source, JMPI& mpiinfo);
54 
55  // Send a value to this variable to another process
56  // This is not a reduction and will replace any existing value
57  bool sendTo(int localid, int target, JMPI& mpiinfo);
58  double getDouble();
59  virtual boost::python::object getPyObj();
60 
61  // send from proc 0 in the communicator to all others
62  bool groupSend(MPI_Comm& com, bool imsending);
63 
64  // reduction with some procs submitting identity values
65  bool groupReduce(MPI_Comm& com, char mystate);
66 
67  void copyValueFrom(boost::shared_ptr<AbstractReducer>& src);
68 
69 private:
70  boost::python::object value;
71  boost::python::object identity;
72 };
73 
75 
76 } // namespace escript
77 
78 #endif // __ESCRIPT_NONREDUCEDVARIABLE_H__
79 
escript::NonReducedVariable::identity
boost::python::object identity
Definition: NonReducedVariable.h:94
escript::NonReducedVariable::setDomain
void setDomain(escript::Domain_ptr d)
Definition: NonReducedVariable.cpp:29
escript::NonReducedVariable::checkRemoteCompatibility
bool checkRemoteCompatibility(JMPI &mpi_info, std::string &errstring)
Definition: NonReducedVariable.cpp:57
NonReducedVariable.h
AbstractReducer.h
escript::NonReducedVariable::NonReducedVariable
NonReducedVariable()
Definition: NonReducedVariable.cpp:20
escript::NonReducedVariable::~NonReducedVariable
~NonReducedVariable()
Definition: NonReducedVariable.cpp:25
escript::NonReducedVariable::getPyObj
virtual boost::python::object getPyObj()
Definition: NonReducedVariable.cpp:92
escript::Domain_ptr
boost::shared_ptr< AbstractDomain > Domain_ptr
Definition: AbstractDomain.h:47
SplitWorldException.h
escript::NonReducedVariable
Definition: NonReducedVariable.h:38
escript::NonReducedVariable::copyValueFrom
void copyValueFrom(boost::shared_ptr< AbstractReducer > &src)
Definition: NonReducedVariable.cpp:107
escript::Reducer_ptr
boost::shared_ptr< AbstractReducer > Reducer_ptr
Definition: AbstractReducer.h:128
escript::makeNonReducedVariable
Reducer_ptr makeNonReducedVariable()
Definition: NonReducedVariable.cpp:121
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:70
escript::NonReducedVariable::reduceLocalValue
bool reduceLocalValue(boost::python::object v, std::string &errstring)
Definition: NonReducedVariable.cpp:42
escript::SplitWorldException
Definition: SplitWorldException.h:38
escript::NonReducedVariable::value
boost::python::object value
Definition: NonReducedVariable.h:93
escript::NonReducedVariable::reduceRemoteValues
bool reduceRemoteValues(MPI_Comm &mpi_info)
Definition: NonReducedVariable.cpp:67
escript::NonReducedVariable::groupReduce
bool groupReduce(MPI_Comm &com, char mystate)
Definition: NonReducedVariable.cpp:102
escript::NonReducedVariable::groupSend
bool groupSend(MPI_Comm &com, bool imsending)
Definition: NonReducedVariable.cpp:97
escript::NonReducedVariable::getCompatibilityInfo
void getCompatibilityInfo(std::vector< unsigned > &params)
Definition: NonReducedVariable.cpp:62
escript::NonReducedVariable::valueCompatible
bool valueCompatible(boost::python::object v)
Definition: NonReducedVariable.cpp:36
escript::NonReducedVariable::recvFrom
bool recvFrom(int localid, int source, JMPI &mpiinfo)
Definition: NonReducedVariable.cpp:77
escript
Definition: AbstractContinuousDomain.cpp:22
escript::NonReducedVariable::getDouble
double getDouble()
Definition: NonReducedVariable.cpp:87
escript::NonReducedVariable::description
std::string description()
Definition: NonReducedVariable.cpp:72
MPI_Comm
int MPI_Comm
Definition: EsysMPI.h:40
Data.h
escript::NonReducedVariable::sendTo
bool sendTo(int localid, int target, JMPI &mpiinfo)
Definition: NonReducedVariable.cpp:82
escript::AbstractReducer::valueadded
bool valueadded
Definition: AbstractReducer.h:122
escript::NonReducedVariable::reset
void reset()
Definition: NonReducedVariable.cpp:49