3 #ifndef DUNE_ALBERTA_DOFVECTOR_HH
4 #define DUNE_ALBERTA_DOFVECTOR_HH
42 return ALBERTA get_dof_int_vec( name.c_str(), dofSpace );
47 ALBERTA free_dof_int_vec( dofVector );
52 return ALBERTA read_dof_int_vec_xdr( filename.c_str(), mesh, dofSpace );
55 static bool write (
const DofVector *dofVector,
const std::string &filename )
57 int success =
ALBERTA write_dof_int_vec_xdr( dofVector, filename.c_str() );
58 return (success == 0);
69 return ALBERTA get_dof_schar_vec( name.c_str(), dofSpace );
74 ALBERTA free_dof_schar_vec( dofVector );
79 return ALBERTA read_dof_schar_vec_xdr( filename.c_str(), mesh, dofSpace );
82 static bool write (
const DofVector *dofVector,
const std::string &filename )
84 int success =
ALBERTA write_dof_schar_vec_xdr( dofVector, filename.c_str() );
85 return (success == 0);
96 return ALBERTA get_dof_uchar_vec( name.c_str(), dofSpace );
101 ALBERTA free_dof_uchar_vec( dofVector );
106 return ALBERTA read_dof_uchar_vec_xdr( filename.c_str(), mesh, dofSpace );
111 int success =
ALBERTA write_dof_uchar_vec_xdr( dofVector, filename.c_str() );
112 return (success == 0);
123 return ALBERTA get_dof_real_vec( name.c_str(), dofSpace );
128 ALBERTA free_dof_real_vec( dofVector );
133 return ALBERTA read_dof_real_vec_xdr( filename.c_str(), mesh, dofSpace );
138 int success =
ALBERTA write_dof_real_vec_xdr( dofVector, filename.c_str() );
139 return (success == 0);
150 return ALBERTA get_dof_real_d_vec( name.c_str(), dofSpace );
155 ALBERTA free_dof_real_d_vec( dofVector );
160 return ALBERTA read_dof_real_d_vec_xdr( filename.c_str(), mesh, dofSpace );
165 int success =
ALBERTA write_dof_real_d_vec_xdr( dofVector, filename.c_str() );
166 return (success == 0);
175 template<
class Dof >
196 const std::string &
name =
"" )
201 : dofVector_( dofVector )
204 operator bool ()
const
206 return (
bool)dofVector_;
214 operator Dof * ()
const
217 GET_DOF_VEC( ptr, dofVector_ );
223 return dofVector_->fe_space;
229 return dofVector_->name;
231 return std::string();
237 dofVector_ = DofVectorProvider::get( dofSpace,
name );
244 dofVector_ = DofVectorProvider::read( filename, meshPointer, NULL );
247 bool write (
const std::string &filename )
const
249 return DofVectorProvider::write( dofVector_, filename );
256 DofVectorProvider::free( dofVector_ );
261 template<
class Functor >
264 Dof *array = (Dof *)(*
this);
265 FOR_ALL_DOFS(
dofSpace()->admin, functor( array[ dof ] ) );
270 Dof *array = (Dof *)(*
this);
271 FOR_ALL_DOFS(
dofSpace()->admin, array[ dof ] = value );
274 template<
class AdaptationData >
277 assert( dofVector_ );
278 #if DUNE_ALBERTA_VERSION >= 0x300
279 assert( dofVector_->user_data );
280 return static_cast< AdaptationData *
>( dofVector_->user_data );
286 template<
class AdaptationData >
289 assert( dofVector_ );
290 #if DUNE_ALBERTA_VERSION >= 0x300
291 dofVector_->user_data = adaptationData;
292 #endif // #if DUNE_ALBERTA_VERSION >= 0x300
295 template<
class Interpolation >
298 assert( dofVector_ );
299 dofVector_->refine_interpol = &refineInterpolate< Interpolation >;
302 template<
class Restriction >
305 assert( dofVector_ );
306 dofVector_->coarse_restrict = &coarsenRestrict< Restriction >;
310 template<
class Interpolation >
311 static void refineInterpolate (
DofVector *dofVector, RC_LIST_EL *list,
int n )
313 const This dofVectorPointer( dofVector );
314 typename Interpolation::Patch patch( list, n );
315 Interpolation::interpolateVector( dofVectorPointer, patch );
318 template<
class Restriction >
319 static void coarsenRestrict (
DofVector *dofVector, RC_LIST_EL *list,
int n )
321 const This dofVectorPointer( dofVector );
322 typename Restriction::Patch patch( list, n );
323 Restriction::restrictVector( dofVectorPointer, patch );
334 assert( !dofVector ==
false );
335 int *array = (
int *)dofVector;
336 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
337 array[ dof ] =
std::abs( array[ dof ] ) );
343 assert( !dofVector ==
false );
344 int *array = (
int *)dofVector;
346 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
347 result =
std::max( result, array[ dof ] ) );
354 assert( !dofVector ==
false );
355 int *array = (
int *)dofVector;
357 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
358 result =
std::min( result, array[ dof ] ) );
366 #endif // #if HAVE_ALBERTA
368 #endif // #ifndef DUNE_ALBERTA_DOFVECTOR_HH
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:50
Definition: dofvector.hh:33
DofVectorPointer()
Definition: dofvector.hh:191
void setAdaptationData(AdaptationData *adaptationData)
Definition: dofvector.hh:287
void initialize(const Dof &value)
Definition: dofvector.hh:268
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:341
provides a wrapper for ALBERTA's refinement patches and the corners for geometryInFather ...
ALBERTA DOF_REAL_D_VEC DofVector
Definition: dofvector.hh:146
void forEach(Functor &functor) const
Definition: dofvector.hh:262
static void free(DofVector *dofVector)
Definition: dofvector.hh:153
void read(const std::string &filename, const MeshPointer< dim > &meshPointer)
Definition: dofvector.hh:241
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:104
ALBERTA FE_SPACE DofSpace
Definition: misc.hh:76
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:55
Definition: dofvector.hh:176
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:82
ALBERTA DOF_UCHAR_VEC DofVector
Definition: dofvector.hh:92
ALBERTA DOF_REAL_VEC DofVector
Definition: dofvector.hh:119
ALBERTA REAL_D GlobalVector
Definition: misc.hh:47
bool write(const std::string &filename) const
Definition: dofvector.hh:247
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:163
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:109
void release()
Definition: dofvector.hh:252
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:131
void setupInterpolation()
Definition: dofvector.hh:296
provides a wrapper for ALBERTA's el_info structure
void create(const DofSpace *dofSpace, const std::string &name="")
Definition: dofvector.hh:234
ALBERTA DOF_SCHAR_VEC DofVector
Definition: dofvector.hh:65
static void free(DofVector *dofVector)
Definition: dofvector.hh:45
std::string name() const
Definition: dofvector.hh:226
ALBERTA MESH Mesh
Definition: misc.hh:60
ALBERTA DOF_INT_VEC DofVector
Definition: dofvector.hh:38
Definition: dofvector.hh:144
#define ALBERTA
Definition: albertaheader.hh:27
DofVectorPointer(const DofSpace *dofSpace, const std::string &name="")
Definition: dofvector.hh:195
static const bool supportsAdaptationData
Definition: dofvector.hh:185
Definition: dofadmin.hh:21
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:136
DofVectorPointer(DofVector *dofVector)
Definition: dofvector.hh:200
DofVectorProvider::DofVector DofVector
Definition: dofvector.hh:183
static void free(DofVector *dofVector)
Definition: dofvector.hh:72
static void free(DofVector *dofVector)
Definition: dofvector.hh:99
ALBERTA REAL Real
Definition: misc.hh:45
void setupRestriction()
Definition: dofvector.hh:303
static void free(DofVector *dofVector)
Definition: dofvector.hh:126
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:158
AdaptationData * getAdaptationData() const
Definition: dofvector.hh:275
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:77
const DofSpace * dofSpace() const
Definition: dofvector.hh:221
int min(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:352
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:332