1 #ifndef DUNE_FEM_DISCRETEFUNCTION_INLINE_HH 2 #define DUNE_FEM_DISCRETEFUNCTION_INLINE_HH 6 #include <dune/geometry/referenceelements.hh> 23 template<
class Impl >
27 : dfSpace_( dfSpace ),
31 ldvAllocator_( &ldvStack_ ),
33 scalarProduct_( dfSpace )
38 template<
class Impl >
42 dofPointerLock_.lock();
44 const unsigned int size = BaseType :: size();
50 dofPointer[ i++ ] = *it;
57 template<
class Impl >
64 *it = dofPointer[ i++ ];
65 assert( i == BaseType :: size() );
68 dofPointerLock_.unlock();
72 template<
class Impl >
77 dofPointerLock_.unlock();
81 template<
class Impl >
87 out << (*dit) << std::endl;
91 template<
class Impl >
98 if( ! std::isfinite( *it ) )
106 template<
class Impl >
107 template<
class DFType >
111 if( BaseType::size() != g.
size() )
112 DUNE_THROW(InvalidStateException,
"DiscreteFunctionDefault: sizes do not match in axpy");
116 typename DFType :: ConstDofIteratorType git = g.
dbegin();
122 template<
class Impl >
123 template<
class DFType >
127 if( BaseType::size() != g.
size() )
128 DUNE_THROW(InvalidStateException,
"DiscreteFunctionDefault: sizes do not match in assign");
132 typename DFType :: ConstDofIteratorType git = g.
dbegin();
138 template<
class Impl >
139 template<
class Operation >
144 return BaseType :: space().createDataHandle( asImp(), operation );
148 template<
class Impl >
149 template<
class Functor >
153 typedef typename DiscreteFunctionSpaceType::GridPartType
GridPartType;
157 const typename EntityType::Geometry geometry = entity.geometry();
158 functor( geometry.local( x ), BaseType::localFunction( entity ) );
162 template<
class Impl >
163 template<
class DFType >
168 if( BaseType::size() != g.
size() )
169 DUNE_THROW(InvalidStateException,
"DiscreteFunctionDefault: sizes do not match in operator +=");
172 typename DFType :: ConstDofIteratorType git = g.
dbegin();
179 template<
class Impl >
180 template<
class DFType >
185 if( BaseType::size() != g.
size() )
186 DUNE_THROW(InvalidStateException,
"DiscreteFunctionDefault: sizes do not match in operator -=");
189 typename DFType :: ConstDofIteratorType git = g.
dbegin();
190 for(
DofIteratorType it = BaseType :: dbegin(); it != end; ++it, ++git )
196 template<
class Impl >
208 template<
class Impl >
209 template<
class StreamTraits >
214 if( versionId < DUNE_VERSION_ID(0,9,1) )
215 DUNE_THROW( IOError,
"Trying to read outdated file." );
216 else if( versionId > DUNE_MODULE_VERSION_ID(DUNE_FEM) )
217 std :: cerr <<
"Warning: Reading discrete function from newer version: " 218 << versionId << std :: endl;
221 if( versionId >= DUNE_VERSION_ID(1,5,0) )
230 if( spaceId != mySpaceId )
231 DUNE_THROW( IOError,
"Trying to read discrete function from different space: DFSpace (" <<
spaceName( spaceId ) <<
") != DataSpace (" <<
spaceName( mySpaceId ) <<
")" );
242 if( mysize != BaseType :: size() &&
243 BaseType :: size() != this->space().size() )
245 DUNE_THROW( IOError,
"Trying to read discrete function of different size." );
255 template<
class Impl >
256 template<
class StreamTraits >
260 unsigned int versionId = DUNE_MODULE_VERSION_ID(DUNE_FEM);
264 int spaceId = space().type();
271 if( BaseType :: size() != this->space().size() )
272 DUNE_THROW(InvalidStateException,
"Writing DiscreteFunction in uncompressed state!");
275 const int mysize = BaseType :: size();
285 template<
class Impl >
289 typedef typename DiscreteFunctionSpaceType::IndexSetType IndexSetType;
290 IndexSetType &indexSet = (IndexSetType &)space().indexSet();
297 if( persistentIndexSet )
302 template<
class Impl >
306 typedef typename DiscreteFunctionSpaceType::IndexSetType IndexSetType;
307 IndexSetType &indexSet = (IndexSetType &)space().indexSet();
314 if( persistentIndexSet )
320 template<
class Impl >
321 template<
class DFType >
325 if( BaseType :: size() != g.
size() )
331 typename DFType :: ConstDofIteratorType git = g.
dbegin();
332 for( ; fit != end; ++fit, ++git )
334 if(
std::abs( *fit - *git ) > 1e-15 )
353 template<
class Impl >
354 inline std :: ostream &
373 template<
class StreamTraits,
class Impl >
375 operator<< ( OutStreamInterface< StreamTraits > &out,
393 template<
class StreamTraits,
class Impl >
405 #endif // #ifndef DUNE_FEM_DISCRETEFUNCTION_INLINE_HH Definition: discretefunction.hh:622
void assign(const DiscreteFunctionInterface< DFType > &g)
Definition: discretefunction_inline.hh:125
virtual void insertSubData()
Definition: discretefunction_inline.hh:287
virtual void removeBackupRestore()=0
please doc me
RangeFieldType * allocDofPointer() const
allocate a pointer to a consecutive array storing the DoFs
Definition: discretefunction_inline.hh:40
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction_inline.hh:258
DiscreteFunctionType & operator-=(const DiscreteFunctionInterface< DFType > &g)
substract all degrees of freedom from given discrete function using the dof iterators ...
Definition: discretefunction_inline.hh:183
InStreamInterface< StreamTraits > & operator>>(InStreamInterface< StreamTraits > &in, DiscreteFunctionInterface< Impl > &df)
read a discrete function from an input stream
Definition: discretefunction_inline.hh:395
DFSpaceIdentifier
enumerator for identification of spaces
Definition: discretefunctionspace.hh:88
void axpy(const RangeFieldType &s, const DiscreteFunctionInterface< DFType > &g)
axpy operation
Definition: discretefunction_inline.hh:109
DiscreteFunctionSpaceType::DomainType DomainType
type of domain, i.e. type of coordinates
Definition: discretefunction.hh:107
Traits::DofType DofType
Definition: discretefunction.hh:131
bool dofsValid() const
check for NaNs
Definition: discretefunction_inline.hh:93
static double max(const Double &v, const double p)
Definition: double.hh:387
Definition: discretefunction.hh:63
Definition: entitysearch.hh:131
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction_inline.hh:211
void evaluateGlobal(const DomainType &x, Functor functor) const
evaluate functor in global coordinate
Definition: discretefunction_inline.hh:151
Traits::DofIteratorType DofIteratorType
Type of the dof iterator used in the discrete function implementation.
Definition: discretefunction.hh:126
DiscreteFunctionSpaceType::EntityType EntityType
type of entity local functions are defined on
Definition: discretefunction.hh:152
CommDataHandle< Operation >::Type dataHandle(const Operation *operation)
return reference to data handle object
ConstDofIteratorType dbegin() const
obtain an iterator pointing to the first DoF (read-only)
Definition: discretefunction.hh:265
void write(OutStreamInterface< StreamTraits > &out) const
write the discrete function into a stream
Definition: discretefunction.hh:508
Double abs(const Double &a)
Definition: double.hh:860
std::string spaceName(const DFSpaceIdentifier id)
Definition: discretefunctionspace.hh:102
DiscreteFunctionType & operator*=(const RangeFieldType &scalar)
multiply all DoFs with a scalar factor
Definition: discretefunction_inline.hh:199
void print(std::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction.hh:410
Definition: coordinate.hh:4
bool operator==(const DiscreteFunctionInterface< DFType > &g) const
Definition: discretefunction_inline.hh:323
void print(std::ostream &out) const
print all DoFs to a stream (for debugging purposes)
Definition: discretefunction_inline.hh:83
virtual void addBackupRestore()=0
please doc me
Traits::DiscreteFunctionType DiscreteFunctionType
type of the implementaton (Barton-Nackman)
Definition: discretefunction.hh:94
abstract interface for an input stream
Definition: streams.hh:177
void freeDofPointerNoCopy(const RangeFieldType *dofPointer) const
allocate a pointer to a consecutive array storing the DoFs
Definition: discretefunction_inline.hh:74
void read(InStreamInterface< StreamTraits > &in)
read the discrete function from a stream
Definition: discretefunction.hh:498
BaseType::DiscreteFunctionSpaceType DiscreteFunctionSpaceType
type of discrete function space
Definition: discretefunction.hh:571
DiscreteFunctionType & operator+=(const DiscreteFunctionInterface< DFType > &g)
add another discrete function to this one
Definition: discretefunction_inline.hh:166
int size() const
obtain total number of DoFs
Definition: discretefunction.hh:226
void readUnsignedInt(unsigned int &value)
read an unsigned int from the stream
Definition: streams.hh:311
DiscreteFunctionSpaceType::GridPartType GridPartType
type of the underlying grid part
Definition: discretefunction.hh:114
capability for persistent index sets
Definition: persistentindexset.hh:90
virtual void removeSubData()
Definition: discretefunction_inline.hh:304
DiscreteFunctionSpaceType::RangeFieldType RangeFieldType
type of range field, i.e. dof type
Definition: discretefunction.hh:105
Traits::LocalDofVectorType LocalDofVectorType
type of LocalDofVector
Definition: discretefunction.hh:599
OutStreamInterface< StreamTraits > & operator<<(OutStreamInterface< StreamTraits > &out, const DiscreteFunctionInterface< Impl > &df)
write a discrete function into an output stream
Definition: discretefunction_inline.hh:375
static constexpr PersistentIndexSetInterface * map(IndexSet &indexSet) noexcept
please doc me
Definition: persistentindexset.hh:101
Traits::ConstDofIteratorType ConstDofIteratorType
Type of the constantdof iterator used in the discrete function implementation.
Definition: discretefunction.hh:129
void freeDofPointer(RangeFieldType *dofPointer)
allocate a pointer to a consecutive array storing the DoFs
Definition: discretefunction_inline.hh:59
virtual base class for persistent index sets
Definition: persistentindexset.hh:34
abstract interface for an output stream
Definition: streams.hh:44
Definition: discretefunction.hh:81
DiscreteFunctionDefault(const std::string &name, const DiscreteFunctionSpaceType &dfSpace)
Constructor storing discrete function space and local function factory.
Definition: discretefunction_inline.hh:25