1 #ifndef DUNE_FEM_PASS_COMMON_PASS_HH 2 #define DUNE_FEM_PASS_COMMON_PASS_HH 9 #include <dune/common/deprecated.hh> 10 #include <dune/common/timer.hh> 11 #include <dune/common/tuples.hh> 26 template <
class Destination>
30 template <
class Destination>
34 template <
class Destination>
45 template <
class ArgumentImp ,
int passIdImp,
49 NonBlockingCommunication nonBlockingComm_;
52 static const int passNum = 0;
53 static const int passId = passIdImp;
56 typedef std::tuple< std::integral_constant< int, passIdImp > >
PassIds;
71 void pass(
const GlobalArgumentType& arg )
const 73 nonBlockingComm_.initComm( arg );
79 nonBlockingComm_.receiveComm( arg );
85 nonBlockingComm_.finalizeComm( arg );
116 template <
class DiscreteModelImp,
class PreviousPassImp ,
int passIdImp>
118 public Operator<typename PreviousPassImp::GlobalArgumentType,
119 typename DiscreteModelImp::Traits::DestinationType>
121 template <
class PT,
class PP,
int PI>
126 template <
class ObjectToDelete>
153 static const int passNum = PreviousPassType::passNum + 1;
154 static const int passId = passIdImp;
157 typedef typename Dune::PushBackTuple< typename PreviousPassType::PassIds, std::integral_constant< int, passIdImp > >::type
PassIds;
166 typedef typename DestinationType :: DiscreteFunctionSpaceType :: CommunicationManagerType
177 typedef typename PushFrontTuple< LocalArgumentType, const GlobalArgumentType* >::type
TotalArgumentType;
179 typedef typename PushBackTuple< LocalArgumentType, DestinationType* >::type
NextArgumentType;
193 finalizeCommunication_( true )
197 previousPass_.allocateLocalMemory();
205 if( deleteHandler_ ) deleteHandler_->freeLocalMemory(destination_);
212 previousPass_.printTexInfo(out);
218 void operator()(
const GlobalArgumentType& arg, DestinationType& dest)
const 220 previousPass_.pass(arg);
221 LocalArgumentType prevArg = previousPass_.localArgument();
223 this->compute(totalArg, dest);
227 if( finalizeCommunication_ )
228 finalizeCommunication( arg );
233 virtual void allocateLocalMemory() = 0;
238 previousPass_.setTime(t);
248 double ret=
std::min( previousPass_.timeStepEstimate(),
249 this->timeStepEstimateImpl() );
254 double time()
const {
return time_; }
259 assert(destination_);
260 return *destination_;
267 void pass(
const GlobalArgumentType& arg)
const 273 finalizeCommunication_ = false ;
274 operator()(arg, *destination_);
280 typename PreviousPassType::NextArgumentType nextArg( previousPass_.localArgument() );
292 previousPass_.finalizeCommunication( arg );
297 finalizeCommunication_ =
true;
308 previousPass_.receiveCommunication( arg );
329 virtual void compute(
const TotalArgumentType& arg,
330 DestinationType& dest)
const = 0;
341 previousPass_.finalizeCommunication( *(get<0> ( totalArg )) );
353 previousPass_.receiveCommunication( *(get<0> ( totalArg )) );
396 #endif // #ifndef DUNE_FEM_PASS_COMMON_PASS_HH double time_
Definition: common/pass.hh:386
DeleteHandlerType * deleteHandler_
object to delete destination_
Definition: common/pass.hh:380
StartPass(const StartPass &)
copy constructor
Definition: common/pass.hh:67
Pass(PreviousPassType &pass)
Definition: common/pass.hh:188
std::tuple< Args..., T > tuple_push_back(const std::tuple< Args... > &tup, T t)
Definition: tupleutility.hh:99
void receiveCommunication(const GlobalArgumentType &arg) const
receive data for previously initialized communication
Definition: common/pass.hh:77
static constexpr T min(T a)
Definition: utility.hh:81
void receiveCommunication(const TotalArgumentType &totalArg) const
receiveCommunication collects possbily initiated non-blocking communications for all passes ...
Definition: common/pass.hh:347
PreviousPassType::GlobalArgumentType GlobalArgumentType
Definition: common/pass.hh:171
void setTime(const double)
StartPass does not need a time.
Definition: common/pass.hh:98
std::tuple NextArgumentType
End marker for tuple of return types of the passes.
Definition: common/pass.hh:61
static constexpr T max(T a)
Definition: utility.hh:65
Definition: common/pass.hh:23
virtual void finalizeComm() const
finalizeCommunication of this pass, this will collect the communication of destination_ and has to be...
Definition: common/pass.hh:366
double timeStepEstimate() const
return time step estimate for explicit Runge Kutta solver, calls recursively the method timeStepEstim...
Definition: common/pass.hh:246
static DeleteHandler< ObjectToDelete > & instance()
return reference to default object deleter
Definition: common/pass.hh:142
double timeStepEstimate() const
return time step estimate
Definition: common/pass.hh:101
void pass(const GlobalArgumentType &arg) const
The pass method initialized the communication only.
Definition: common/pass.hh:71
PushBackTuple< LocalArgumentType, DestinationType * >::type NextArgumentType
Tuple containing destination types of all passes up to this one.
Definition: common/pass.hh:179
PreviousPassType & previousPass_
Definition: common/pass.hh:383
void printTexInfo(std::ostream &out) const
printTex info of operator
Definition: common/pass.hh:210
void printTexInfo(std::ostream &out) const
Definition: common/pass.hh:89
virtual void receiveComm() const
receiveCommunication of this pass, which will reset changes the communication did to the destination_...
Definition: common/pass.hh:373
ArgumentImp GlobalArgumentType
The argument (and destination) type of the overall operator.
Definition: common/pass.hh:59
std::tuple< T, Args... > tuple_push_front(const std::tuple< Args... > &tup, T t)
Definition: tupleutility.hh:110
void finalizeCommunication(const GlobalArgumentType &arg) const
cleanup of overwritten data. i.e. ghost values if neccessary
Definition: common/pass.hh:83
abstract operator
Definition: operator.hh:25
virtual ~Pass()
Destructor.
Definition: common/pass.hh:201
int passNumber() const
Definition: common/pass.hh:183
void pass(const GlobalArgumentType &arg) const
Definition: common/pass.hh:267
PreviousPassImp PreviousPassType
Type of the preceding pass.
Definition: common/pass.hh:150
Definition: coordinate.hh:4
void receiveCommunication(const GlobalArgumentType &arg) const
finalizeCommunication collects possbily initiated non-blocking communications for all passes includin...
Definition: common/pass.hh:304
void initComm(const Destination &) const
Definition: common/pass.hh:27
Definition: common/pass.hh:127
double time() const
return current time of calculation
Definition: common/pass.hh:254
PreviousPassType::NextArgumentType LocalArgumentType
Tuple containing destination types of all preceding passes.
Definition: common/pass.hh:173
NextArgumentType localArgument() const
Returns a compilation of the results of the preceding passes.
Definition: common/pass.hh:278
void finalizeCommunication(const TotalArgumentType &totalArg) const
finalizeCommunication collects possbily initiated non-blocking communications for all passes ...
Definition: common/pass.hh:335
void receiveComm(const Destination &) const
Definition: common/pass.hh:31
const DestinationType & destination() const
return reference to internal discrete function
Definition: common/pass.hh:257
virtual void freeLocalMemory(ObjectToDelete *obj)
default implementation just deletes obj
Definition: common/pass.hh:136
virtual void initComm() const
initializeCommunication of this pass, this will initialize the communication of destination_ and has ...
Definition: common/pass.hh:360
void operator()(const GlobalArgumentType &arg, DestinationType &dest) const
Application operator. The application operator is called by the client directly. It makes only sense ...
Definition: common/pass.hh:218
void finalizeComm(const Destination &) const
Definition: common/pass.hh:35
Base class for specific pass implementations.
Definition: local.hh:19
DeleteHandler()
Definition: common/pass.hh:131
StartPass()
empty constructor
Definition: common/pass.hh:65
DiscreteModelImp::Traits::DestinationType DestinationType
Definition: common/pass.hh:161
virtual double timeStepEstimateImpl() const
Definition: common/pass.hh:316
virtual bool requireCommunication() const
requireCommunication returns true if the pass needs communication at all
Definition: common/pass.hh:324
NextArgumentType localArgument() const
Returns the closure of the destination tuple.
Definition: common/pass.hh:92
PushFrontTuple< LocalArgumentType, const GlobalArgumentType * >::type TotalArgumentType
Definition: common/pass.hh:177
virtual ~DeleteHandler()
destructor
Definition: common/pass.hh:134
void finalizeCommunication(const GlobalArgumentType &arg) const
finalizeCommunication collects possbily initiated non-blocking communications for all passes includin...
Definition: common/pass.hh:288
DeleteHandler< DestinationType > DeleteHandlerType
type of mem handler, which deletes destination
Definition: common/pass.hh:164
End marker for a compile-time list of passes.
Definition: common/pass.hh:47
std::tuple< std::integral_constant< int, passIdImp > > PassIds
pass ids up to here (tuple of integral constants)
Definition: common/pass.hh:56
bool finalizeCommunication_
Definition: common/pass.hh:389
void setTime(const double t)
Set time provider (which gives you access to the global time).
Definition: common/pass.hh:236
DestinationType * destination_
destination (might be set from outside)
Definition: common/pass.hh:377
Dune::PushBackTuple< typename PreviousPassType::PassIds, std::integral_constant< int, passIdImp > >::type PassIds
pass ids up to here (tuple of integral constants)
Definition: common/pass.hh:157
DestinationType::DiscreteFunctionSpaceType::CommunicationManagerType::NonBlockingCommunicationType NonBlockingCommunicationType
Definition: common/pass.hh:167
void allocateLocalMemory()
No memory needs to be allocated.
Definition: common/pass.hh:95