1#ifndef DUNE_FEM_FUNCTION_COMBINEDFUNCTION_COMBINEDFUNCTION_HH
2#define DUNE_FEM_FUNCTION_COMBINEDFUNCTION_COMBINEDFUNCTION_HH
23 template<
class ContainedDiscreteFunction,
int N >
24 class CombinedDiscreteFunction;
26 template<
class ContainedDiscreteFunction,
int N >
27 class CombinedDiscreteFunctionDofIterator;
33 template<
class ContainedDiscreteFunction,
int N >
40 typedef typename ContainedDiscreteFunctionType :: DiscreteFunctionSpaceType
47 typedef typename DiscreteFunctionSpaceType :: DomainType
DomainType;
48 typedef typename DiscreteFunctionSpaceType :: RangeType
RangeType;
53 typedef typename DiscreteFunctionSpaceType :: MapperType
MapperType;
54 typedef typename DiscreteFunctionSpaceType :: GridType
GridType;
55 typedef typename DiscreteFunctionSpaceType :: GridPartType
GridPartType;
61 typedef typename ContainedDiscreteFunctionType :: DofBlockType
DofBlockType;
62 typedef typename ContainedDiscreteFunctionType :: ConstDofBlockType
64 typedef typename ContainedDiscreteFunctionType :: DofBlockPtrType
66 typedef typename ContainedDiscreteFunctionType :: ConstDofBlockPtrType
80 template <
class ContainedDiscreteFunctionImp,
int N >
110 typedef typename Traits::ContainedDiscreteFunctionSpaceType
147 for (
int i=0; i<N; ++i)
156 for (
int i=0; i<N; ++i)
165 for (
int i=0; i<N; ++i)
175 ldvStack_( other.ldvStack_ )
177 for (
int i=0; i<N; ++i)
184 for (
int i=0; i<N; ++i)
197 for (
int i=0; i<N; ++i)
204 for(
int i=0; i<N; ++i)
211 return func_[0]->size()*N;
217 for (
int i=0; i<N; ++i)
224 using BaseType::operator-=;
227 for(
int i = 0; i < N; ++i )
235 for (
int i=0; i<N; ++i)
243 for (
int i=0; i<N; ++i)
259 for (
int i=0; i<N; ++i)
267 for(
int i = 0; i < N; ++i )
273 template<
class StreamTraits >
276 for (
int i=0; i<N; ++i)
280 template<
class StreamTraits >
283 for (
int i=0; i<N; ++i)
290 for (
int i=0; i<N; ++i)
297 bool ret = func_[0]->dofsValid();
298 for (
int i=1;i<N;i++)
306 const int containedSize = func_[ 0 ]->space().blockMapper().size();
307 const int component = index / containedSize;
308 const int containedIndex = index % containedSize;
310 return func.block( containedIndex );
316 const int containedSize = func_[ 0 ]->space().blockMapper().size();
317 const int component = index / containedSize;
318 const int containedIndex = index % containedSize;
319 return func_[ component ]->block( containedIndex );
324 int variable = index / func_[0]->size();
325 int point = index % func_[0]->size();
326 return func_[variable]->dof(point);
331 int variable = index / func_[0]->size();
332 int point = index % func_[0]->size();
333 return func_[variable]->dof(point);
369 return space().containedSpace();
373 const ThisType& interface()
const
384 typename Traits :: LocalDofVectorStackType ldvStack_;
392 template <
class ContainedDiscreteFunctionImp,
int N>
395 typename ContainedDiscreteFunctionImp::DofType ,
396 CombinedDiscreteFunctionDofIterator<ContainedDiscreteFunctionImp,N> >
411 iter_(df.func_[N-1]->dend()),
412 endIter_(df.func_[N-1]->dend())
418 iter_(df.func_[0]->dbegin()),
419 endIter_(df.func_[0]->dend())
425 iter_(df.func_[N-1]->dend()),
426 endIter_(df.func_[N-1]->dend())
432 iter_(df.func_[0]->dbegin()),
433 endIter_(df.func_[0]->dend())
440 endIter_(other.endIter_)
449 endIter_ = other.endIter_;
469 if (iter_==endIter_ && comp_<N-1)
472 iter_ = df_.func_[comp_]->dbegin();
473 endIter_ = df_.func_[comp_]->dend();
481 return (comp_ == I.comp_) && (iter_ == I.iter_);
487 return !((*this) == I);
493 iter_ = df_.func_[ 0 ]->dbegin();
494 endIter_ = df_.func_[ 0 ]->dend();
Definition: bindguard.hh:11
static double max(const Double &v, const double p)
Definition: double.hh:398
Definition: stackallocator.hh:61
Definition: combinedfunction/combinedfunction.hh:83
CombinedDiscreteFunction(const ThisType &other)
Definition: combinedfunction/combinedfunction.hh:173
RangeFieldType scalarProductDofs(const ThisType &other) const
Definition: combinedfunction/combinedfunction.hh:264
RangeFieldType & dof(unsigned int index)
Definition: combinedfunction/combinedfunction.hh:329
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
the combined discrete function type
Definition: combinedfunction/combinedfunction.hh:108
DofIteratorType dend()
obtain an iterator pointing behind the last DoF (read-write)
Definition: combinedfunction/combinedfunction.hh:352
DofIteratorType dbegin()
obtain an iterator pointing to the first DoF (read-write)
Definition: combinedfunction/combinedfunction.hh:347
BaseType::LocalDofVectorAllocatorType LocalDofVectorAllocatorType
Definition: combinedfunction/combinedfunction.hh:136
ThisType & operator+=(const ThisType &g)
Definition: combinedfunction/combinedfunction.hh:215
void clear()
set all degrees of freedom to zero
Definition: combinedfunction/combinedfunction.hh:195
ThisType & operator-=(const ThisType &g)
Definition: combinedfunction/combinedfunction.hh:225
DofBlockPtrType block(unsigned int index)
Definition: combinedfunction/combinedfunction.hh:313
void assign(const ThisType &g)
Definition: combinedfunction/combinedfunction.hh:202
ConstDofIteratorType dbegin() const
obtain an iterator pointing to the first DoF (read-only)
Definition: combinedfunction/combinedfunction.hh:337
int size() const
obtain total number of DoFs
Definition: combinedfunction/combinedfunction.hh:209
BaseType::GridPartType GridPartType
GridPart implementation.
Definition: combinedfunction/combinedfunction.hh:100
void axpy(const RangeFieldType &s, const ThisType &g)
axpy operation
Definition: combinedfunction/combinedfunction.hh:257
ContainedDiscreteFunctionType SubDiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:91
CombinedDiscreteFunction(const std::string &name, const ContainedDiscreteFunctionSpaceType &spc)
Definition: combinedfunction/combinedfunction.hh:151
BaseType::RangeType RangeType
Vector type used for the range field.
Definition: combinedfunction/combinedfunction.hh:121
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: combinedfunction/combinedfunction.hh:274
Traits::MapperType MapperType
Mapper type (from the space)
Definition: combinedfunction/combinedfunction.hh:125
bool dofsValid() const
check for NaNs
Definition: combinedfunction/combinedfunction.hh:295
BaseType::ConstDofIteratorType ConstDofIteratorType
Read-only iterator over dof container.
Definition: combinedfunction/combinedfunction.hh:131
ThisType & operator=(const ThisType &)=delete
BaseType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: combinedfunction/combinedfunction.hh:134
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: combinedfunction/combinedfunction.hh:281
BaseType::RangeFieldType RangeFieldType
Intrinsic type used for range field (like DofType)
Definition: combinedfunction/combinedfunction.hh:117
CombinedDiscreteFunction(const std::string &name, const DiscreteFunctionSpaceType &spc)
Definition: combinedfunction/combinedfunction.hh:160
ContainedDiscreteFunctionSpaceType & subSpace()
Definition: combinedfunction/combinedfunction.hh:367
BaseType::DofIteratorType DofIteratorType
Iterator over dof container.
Definition: combinedfunction/combinedfunction.hh:128
ContainedDiscreteFunctionType & subFunction(const int i)
Definition: combinedfunction/combinedfunction.hh:357
void addScaled(const ThisType &g, const RangeFieldType &s)
Definition: combinedfunction/combinedfunction.hh:250
BaseType::DomainType DomainType
Vector type used for the domain field.
Definition: combinedfunction/combinedfunction.hh:123
BaseType::GridType GridType
Grid implementation.
Definition: combinedfunction/combinedfunction.hh:97
ConstDofIteratorType dend() const
obtain an iterator pointing behind the last DoF (read-only)
Definition: combinedfunction/combinedfunction.hh:342
BaseType::DofBlockPtrType DofBlockPtrType
Definition: combinedfunction/combinedfunction.hh:133
ConstDofBlockPtrType block(unsigned int index) const
Definition: combinedfunction/combinedfunction.hh:303
BaseType::DofType DofType
Intrinsic type used for dofs (typically a float type)
Definition: combinedfunction/combinedfunction.hh:115
CombinedDiscreteFunction()=delete
BaseType::DiscreteFunctionType DiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:105
const ContainedDiscreteFunctionType & subFunction(const int i) const
Definition: combinedfunction/combinedfunction.hh:362
DiscreteFunctionTraits< ThisType > Traits
Traits class with all necessary type definitions.
Definition: combinedfunction/combinedfunction.hh:94
ContainedDiscreteFunctionSpaceType SubDiscreteFunctionSpaceType
Definition: combinedfunction/combinedfunction.hh:113
Traits::ContainedDiscreteFunctionSpaceType ContainedDiscreteFunctionSpaceType
Contained discrete function space.
Definition: combinedfunction/combinedfunction.hh:111
ContainedDiscreteFunctionImp ContainedDiscreteFunctionType
Discrete function this discrete function belongs to.
Definition: combinedfunction/combinedfunction.hh:90
~CombinedDiscreteFunction()
Destructor.
Definition: combinedfunction/combinedfunction.hh:182
BaseType::DomainFieldType DomainFieldType
Intrinsic type used for the domain field.
Definition: combinedfunction/combinedfunction.hh:119
CombinedDiscreteFunction(const ContainedDiscreteFunctionType &func)
Constructor.
Definition: combinedfunction/combinedfunction.hh:143
void print(std ::ostream &out) const
Definition: combinedfunction/combinedfunction.hh:288
DiscreteFunctionType & operator/=(const RangeFieldType &scalar)
multiply all DoFs by a scalar factor
Definition: combinedfunction/combinedfunction.hh:241
const RangeFieldType & dof(unsigned int index) const
Definition: combinedfunction/combinedfunction.hh:322
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs by a scalar factor
Definition: combinedfunction/combinedfunction.hh:233
Iterator over an array of dofs.
Definition: combinedfunction/combinedfunction.hh:397
bool operator!=(const ThisType &I) const
compare
Definition: combinedfunction/combinedfunction.hh:485
Traits::DiscreteFunctionType DiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:401
CombinedDiscreteFunctionDofIterator(DiscreteFunctionType &df)
Constructor.
Definition: combinedfunction/combinedfunction.hh:429
ThisType & operator++()
go to next dof
Definition: combinedfunction/combinedfunction.hh:466
CombinedDiscreteFunctionDofIterator(bool end, const DiscreteFunctionType &df)
End constructor.
Definition: combinedfunction/combinedfunction.hh:408
CombinedDiscreteFunctionDofIterator(const DiscreteFunctionType &df)
Constructor (const)
Definition: combinedfunction/combinedfunction.hh:415
CombinedDiscreteFunctionDofIterator< ContainedDiscreteFunctionImp, N > ThisType
Definition: combinedfunction/combinedfunction.hh:399
DofType & operator*()
return dof
Definition: combinedfunction/combinedfunction.hh:454
Traits::DofType DofType
Definition: combinedfunction/combinedfunction.hh:405
void reset()
Definition: combinedfunction/combinedfunction.hh:490
CombinedDiscreteFunctionDofIterator(const ThisType &other)
Copy Constructor.
Definition: combinedfunction/combinedfunction.hh:436
Traits::ContainedDiscreteFunctionType ContainedDiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:402
bool operator==(const ThisType &I) const
compare
Definition: combinedfunction/combinedfunction.hh:479
CombinedDiscreteFunctionDofIterator(bool end, DiscreteFunctionType &df)
End constructor.
Definition: combinedfunction/combinedfunction.hh:422
DiscreteFunctionTraits< CombinedDiscreteFunction< ContainedDiscreteFunctionImp, N > > Traits
Definition: combinedfunction/combinedfunction.hh:400
ContainedDiscreteFunctionType::ConstDofIteratorType ContainedConstDofIteratorType
Definition: combinedfunction/combinedfunction.hh:404
ContainedDiscreteFunctionType::DofIteratorType ContainedDofIteratorType
Definition: combinedfunction/combinedfunction.hh:403
ThisType & operator=(const ThisType &other)
Assignment operator.
Definition: combinedfunction/combinedfunction.hh:444
CombinedDiscreteFunctionDofIterator< ContainedDiscreteFunctionType, N > DofIteratorType
Definition: combinedfunction/combinedfunction.hh:58
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
Definition: combinedfunction/combinedfunction.hh:46
CombinedSpace< ContainedDiscreteFunctionSpaceType, N, VariableBased > DiscreteFunctionSpaceType
Definition: combinedfunction/combinedfunction.hh:43
ThreadSafeValue< UninitializedObjectStack > LocalDofVectorStackType
Definition: combinedfunction/combinedfunction.hh:69
StackAllocator< DofType, LocalDofVectorStackType * > LocalDofVectorAllocatorType
Definition: combinedfunction/combinedfunction.hh:70
DiscreteFunctionSpaceType::DomainType DomainType
Definition: combinedfunction/combinedfunction.hh:47
CombinedDiscreteFunction< ContainedDiscreteFunctionType, N > DiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:38
ConstDofIteratorDefault< DofIteratorType > ConstDofIteratorType
Definition: combinedfunction/combinedfunction.hh:59
DiscreteFunctionSpaceType::GridPartType GridPartType
Definition: combinedfunction/combinedfunction.hh:55
MutableLocalFunction< DiscreteFunctionType > LocalFunctionType
Definition: combinedfunction/combinedfunction.hh:73
ContainedDiscreteFunctionType::DofBlockPtrType DofBlockPtrType
Definition: combinedfunction/combinedfunction.hh:65
DiscreteFunctionSpaceType::RangeType RangeType
Definition: combinedfunction/combinedfunction.hh:48
DiscreteFunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: combinedfunction/combinedfunction.hh:50
DynamicReferenceVector< DofType, LocalDofVectorAllocatorType > LocalDofVectorType
Definition: combinedfunction/combinedfunction.hh:71
ContainedDiscreteFunctionType::DofBlockType DofBlockType
Definition: combinedfunction/combinedfunction.hh:61
DiscreteFunctionSpaceType::MapperType MapperType
Definition: combinedfunction/combinedfunction.hh:53
ContainedDiscreteFunctionType::DiscreteFunctionSpaceType ContainedDiscreteFunctionSpaceType
Definition: combinedfunction/combinedfunction.hh:41
ContainedDiscreteFunctionType::ConstDofBlockPtrType ConstDofBlockPtrType
Definition: combinedfunction/combinedfunction.hh:67
ContainedDiscreteFunctionType::ConstDofBlockType ConstDofBlockType
Definition: combinedfunction/combinedfunction.hh:63
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
Definition: combinedfunction/combinedfunction.hh:45
ContainedDiscreteFunction ContainedDiscreteFunctionType
Definition: combinedfunction/combinedfunction.hh:36
DiscreteFunctionSpaceType::GridType GridType
Definition: combinedfunction/combinedfunction.hh:54
RangeFieldType DofType
Definition: combinedfunction/combinedfunction.hh:52
Traits class for a DiscreteFunction.
Definition: common/discretefunction.hh:61
Definition: common/discretefunction.hh:584
const DiscreteFunctionSpaceType & space() const
obtain a reference to the corresponding DiscreteFunctionSpace
Definition: common/discretefunction.hh:709
BaseType::GridPartType GridPartType
type of the underlying grid part
Definition: common/discretefunction.hh:609
Traits::ConstDofIteratorType ConstDofIteratorType
type of the const dof iterator
Definition: common/discretefunction.hh:628
BaseType::DofType DofType
Definition: common/discretefunction.hh:649
const std::string & name() const
obtain the name of the discrete function
Definition: common/discretefunction.hh:691
DiscreteFunctionSpaceType::RangeType RangeType
type of range vector
Definition: common/discretefunction.hh:614
Traits::DofIteratorType DofIteratorType
type of the dof iterator
Definition: common/discretefunction.hh:626
const GridPartType & gridPart() const
obtain a reference to the underlying grid part
Definition: common/discretefunction.hh:712
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: common/discretefunction.hh:606
DiscreteFunctionSpaceType::DomainType DomainType
type of domain vector
Definition: common/discretefunction.hh:612
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field (usually a float type)
Definition: common/discretefunction.hh:623
DiscreteFunctionSpaceType::DomainFieldType DomainFieldType
type of domain field (usually a float type)
Definition: common/discretefunction.hh:621
DiscreteFunctionSpaceType::GridType GridType
type of the underlying grid
Definition: common/discretefunction.hh:122
default implementation of DofManagerInterface
Definition: dofiterator.hh:143
Definition: dofiterator.hh:211
abstract interface for an output stream
Definition: streams.hh:46
abstract interface for an input stream
Definition: streams.hh:179
Definition: combinedspace/combinedspace.hh:32
An implementation of DenseVector which uses a std::vector of references as storage.
Definition: storage/referencevector.hh:53