Skip to content
Snippets Groups Projects
Commit fbd2a071 authored by Oliver Sander's avatar Oliver Sander
Browse files

Some more methods accept an explicitly given level.

(überall implizit maxlevel zu nehmen ist DES TEUFELS!!)

[[Imported from SVN: r735]]
parent 8868690d
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,22 @@ namespace Dune
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
scalarProductDofs( const DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp ,LocalFunctionIteratorImp, DiscreteFunctionImp > &g ) const
{
int level = this->getFunctionSpace().getGrid().maxlevel();
return scalarProductDofs(g, level);
}
// scalarProductDofs
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp,
class DiscreteFunctionImp >
inline typename DiscreteFunctionSpaceType::RangeField
DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
scalarProductDofs( const DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp ,LocalFunctionIteratorImp, DiscreteFunctionImp > &g,
int level) const
{
typedef typename DiscreteFunctionSpaceType::RangeField RangeFieldType;
typedef DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
......@@ -27,8 +43,6 @@ namespace Dune
RangeFieldType skp = 0.;
int level = this->getFunctionSpace().getGrid().maxlevel();
// get DofIterator from this
/** \todo The const_casts are only necessary because we don't have
......@@ -46,6 +60,7 @@ namespace Dune
return skp;
}
// assign
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
......@@ -103,6 +118,9 @@ namespace Dune
}
// operator +=
/** \todo This operator can add a discretefunction defined on all levels to another
* one defined only on one level. We should somehow issue a warning in this case.
*/
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
inline Vector< typename DiscreteFunctionSpaceType::RangeField > &
......@@ -113,9 +131,9 @@ namespace Dune
typedef DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp, DiscreteFunctionImp > DiscreteFunctionDefaultType;
/** \todo Remove const_cast as soon as we have const iterators */
DiscreteFunctionDefaultType &gc =
const_cast<DiscreteFunctionDefaultType &>( static_cast<const DiscreteFunctionDefaultType &> ( g ));
// we would need const_iterators.....
int level = this->getFunctionSpace().getGrid().maxlevel();
......@@ -136,15 +154,25 @@ namespace Dune
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
addScaled( const Vector< typename DiscreteFunctionSpaceType::RangeField > & g ,
const typename DiscreteFunctionSpaceType::RangeField &scalar)
{
int level = this->getFunctionSpace().getGrid().maxlevel();
addScaled(g, scalar, level);
}
// operator +=
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
inline void DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
addScaled( const Vector< typename DiscreteFunctionSpaceType::RangeField > & g ,
const typename DiscreteFunctionSpaceType::RangeField &scalar, int level)
{
typedef DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp, DiscreteFunctionImp > DiscreteFunctionDefaultType;
/** \todo Remove the const cast as soon as we have const iterators */
DiscreteFunctionDefaultType &gc =
const_cast<DiscreteFunctionDefaultType &>( static_cast<const DiscreteFunctionDefaultType &> ( g ));
// we would need const_iterators.....
int level = this->getFunctionSpace().getGrid().maxlevel();
DofIteratorImp endit = this->dend ( level );
DofIteratorImp git = gc.dbegin ( level );
......@@ -155,6 +183,7 @@ namespace Dune
}
}
// operator -=
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
......@@ -199,6 +228,21 @@ namespace Dune
return *this;
}
// operator *=
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
inline Vector< typename DiscreteFunctionSpaceType::RangeField > &
DiscreteFunctionDefault<DiscreteFunctionSpaceType ,
DofIteratorImp , LocalFunctionIteratorImp,DiscreteFunctionImp >::
mult ( const typename DiscreteFunctionSpaceType::RangeField & scalar, int level )
{
DofIteratorImp endit = this->dend ( level );
for(DofIteratorImp it = this->dbegin( level ); it != endit; ++it)
*it *= scalar;
return *this;
}
// operator /=
template<class DiscreteFunctionSpaceType, class DofIteratorImp,
template <class,class> class LocalFunctionIteratorImp, class DiscreteFunctionImp >
......
......@@ -196,40 +196,53 @@ namespace Dune {
//! Evaluate a scalar product of the dofs of two DiscreteFunctions
typename DiscreteFunctionSpaceType::RangeField scalarProductDofs( const DiscreteFunctionDefault &g ) const;
//! on the top level of the underlying grid
RangeFieldType scalarProductDofs( const DiscreteFunctionDefault &g ) const;
//! Evaluate a scalar product of the dofs of two DiscreteFunctions
//! on an explicitly given level
RangeFieldType scalarProductDofs( const DiscreteFunctionDefault &g,
int level) const;
//! Assignment
Vector<typename DiscreteFunctionSpaceType::RangeField> &
assign(const Vector<typename DiscreteFunctionSpaceType::RangeField> &g);
Vector<RangeFieldType> &
assign(const Vector<RangeFieldType> &g);
//! Assignment operator
Vector<typename DiscreteFunctionSpaceType::RangeField> &
operator = (const Vector<typename DiscreteFunctionSpaceType::RangeField> &g);
Vector<RangeFieldType> & operator = (const Vector<RangeFieldType> &g);
//! Addition
Vector<typename DiscreteFunctionSpaceType::RangeField> &
operator += (const Vector<typename DiscreteFunctionSpaceType::RangeField> &g);
Vector<RangeFieldType> & operator += (const Vector<RangeFieldType> &g);
//! !
void addScaled (const Vector<typename DiscreteFunctionSpaceType::RangeField> &g,
const typename DiscreteFunctionSpaceType::RangeField &scalar);
//! Add scalar*g to this on the maxlevel
void addScaled (const Vector<RangeFieldType> &g,
const RangeFieldType &scalar);
//! Add scalar*g to this on a given level
void addScaled (const Vector<RangeFieldType> &g,
const RangeFieldType &scalar,
int level);
//! substract
Vector<typename DiscreteFunctionSpaceType::RangeField> &
operator -= (const Vector<typename DiscreteFunctionSpaceType::RangeField> &g);
Vector<RangeFieldType> &
operator -= (const Vector<RangeFieldType> &g);
//! multiply on maxlevel
Vector<RangeFieldType> &
operator *= (const RangeFieldType &scalar);
//! multiply
Vector<typename DiscreteFunctionSpaceType::RangeField> &
operator *= (const typename DiscreteFunctionSpaceType::RangeField &scalar);
Vector<RangeFieldType> &
mult (const RangeFieldType &scalar, int level);
//! Division by a scalar
Vector<typename DiscreteFunctionSpaceType::RangeField> &
operator /= (const typename DiscreteFunctionSpaceType::RangeField &scalar);
Vector<RangeFieldType> &
operator /= (const RangeFieldType &scalar);
//! add
Vector<typename DiscreteFunctionSpaceType::RangeField> &
add(const Vector<typename DiscreteFunctionSpaceType::RangeField> &g ,
typename DiscreteFunctionSpaceType::RangeField scalar );
/** \todo Ist das nicht das gleiche wie addScaled? */
Vector<RangeFieldType> &
add(const Vector<RangeFieldType> &g , RangeFieldType scalar );
//! clear all dofs of a given level of the discrete function
void clearLevel(int level );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment