Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "SundanceOut.hpp"
00043 #include "PlayaTabs.hpp"
00044 #include "SundanceFunctionalAssemblyKernel.hpp"
00045 #include "SundanceIntegralGroup.hpp"
00046 #include "Teuchos_Time.hpp"
00047 #include "Teuchos_TimeMonitor.hpp"
00048
00049 using namespace Sundance;
00050 using namespace Teuchos;
00051 using Playa::MPIComm;
00052 using Playa::MPIDataType;
00053 using Playa::MPIOp;
00054
00055 using std::setw;
00056 using std::endl;
00057
00058 FunctionalAssemblyKernel::FunctionalAssemblyKernel(
00059 const MPIComm& comm,
00060 double* value,
00061 int verb
00062 )
00063 : AssemblyKernelBase(verb),
00064 comm_(comm),
00065 value_(value),
00066 localValue_(0.0)
00067 {}
00068
00069 void FunctionalAssemblyKernel::postLoopFinalization()
00070 {
00071 Tabs tab;
00072 SUNDANCE_MSG3(verb(), tab << "reducing functional values across processors");
00073 SUNDANCE_MSG3(verb(), tab << "local value=" << localValue_);
00074 double globalVal = localValue_;
00075
00076 comm_.allReduce((void*) &localValue_, (void*) &globalVal, 1,
00077 MPIDataType::doubleType(), MPIOp::sumOp());
00078
00079 *value_ = globalVal;
00080
00081 SUNDANCE_MSG3(verb(), tab << "reduced value = " << *value_);
00082 }
00083
00084 void FunctionalAssemblyKernel::fill(
00085 bool isBC,
00086 const IntegralGroup& group,
00087 const RCP<Array<double> >& localValues)
00088 {
00089 Tabs tab;
00090 SUNDANCE_MSG2(verb(), tab << "adding local increment " << (*localValues)[0]
00091 << " to local value" << std::endl << tab << "Before: " << localValue_);
00092
00093 localValue_ += (*localValues)[0];
00094 SUNDANCE_MSG2(verb(), tab << "After: " << localValue_);
00095 }
00096
00097