Created
July 3, 2015 10:26
-
-
Save ftalbrecht/371b0935c2ec560be3ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template< class GridViewImp, class RangeImp, class SourceImp = RangeImp, class FieldImp = typename RangeImp::RangeFieldType > | |
class LocalizableProductBase | |
: public LocalizableProductInterface< GridViewImp, RangeImp, SourceImp, FieldImp > | |
{ | |
// not all types and methods shown ... | |
public: | |
LocalizableProductBase(GridViewType grid_view, const RangeType& range, const SourceType& source) | |
: BaseType(grid_view) | |
, range_(range) | |
, source_(source) | |
, walked_(false) | |
{} | |
LocalizableProductBase(GridViewType grid_view, const RangeType& range) | |
: BaseType(grid_view) | |
, range_(range) | |
, source_(range) | |
, walked_(false) | |
{} | |
virtual ~LocalizableProductBase() {} | |
virtual const SourceType& source() const override final | |
{ | |
return source_; | |
} | |
virtual const RangeType& range() const override final | |
{ | |
return range_; | |
} | |
template< class V > | |
void add(const LocalOperator::Codim0Integral< V >& volume_operator, | |
const DSG::ApplyOn::WhichEntity< GridViewType >* where = new DSG::ApplyOn::AllEntities< GridViewType >()) | |
{ | |
typedef LocalAssembler::Codim0OperatorAccumulateFunctor | |
< GridViewType, LocalOperator::Codim0Integral< V >, RangeType, SourceType, FieldType > AccumulateFunctor; | |
volume_operators_.emplace_back( | |
new AccumulateFunctor(grid_view_, volume_operator, range_, source_, *where)); | |
BaseType::add(*volume_operators_.back(), where); | |
} | |
FieldType compute_locally(const EntityType& entity) const | |
{ | |
FieldType local_result = 0.; | |
for (const auto& volume_operator : volume_operators_) | |
local_result += volume_operator->compute_locally(entity); | |
return local_result; | |
} | |
virtual FieldType apply2() override final | |
{ | |
if (!walked_) { | |
this->walk(); | |
walked_ = true; | |
} | |
FieldType result = 0.; | |
for (const auto& volume_operator : volume_operators_) | |
result += volume_operator->result(); | |
return result; | |
} | |
private: | |
using BaseType::grid_view_; | |
const RangeType& range_; | |
const SourceType& source_; | |
std::vector< std::unique_ptr< DSG::internal::Codim0ReturnObject< GridViewType, FieldType > > > volume_operators_; | |
bool walked_; | |
}; // class LocalizableProductBase |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment