3 #ifndef DUNE_ALBERTA_DOFVECTOR_HH 4 #define DUNE_ALBERTA_DOFVECTOR_HH 40 static DofVector *
get (
const DofSpace *dofSpace,
const std::string &name )
42 return ALBERTA get_dof_int_vec( name.c_str(), dofSpace );
45 static void free ( DofVector *dofVector )
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);
67 static DofVector *
get (
const DofSpace *dofSpace,
const std::string &name )
69 return ALBERTA get_dof_schar_vec( name.c_str(), dofSpace );
72 static void free ( DofVector *dofVector )
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);
94 static DofVector *
get (
const DofSpace *dofSpace,
const std::string &name )
96 return ALBERTA get_dof_uchar_vec( name.c_str(), dofSpace );
99 static void free ( DofVector *dofVector )
101 ALBERTA free_dof_uchar_vec( dofVector );
106 return ALBERTA read_dof_uchar_vec_xdr( filename.c_str(), mesh, dofSpace );
109 static bool write (
const DofVector *dofVector,
const std::string &filename )
111 int success =
ALBERTA write_dof_uchar_vec_xdr( dofVector, filename.c_str() );
112 return (success == 0);
121 static DofVector *
get (
const DofSpace *dofSpace,
const std::string &name )
123 return ALBERTA get_dof_real_vec( name.c_str(), dofSpace );
126 static void free ( DofVector *dofVector )
128 ALBERTA free_dof_real_vec( dofVector );
133 return ALBERTA read_dof_real_vec_xdr( filename.c_str(), mesh, dofSpace );
136 static bool write (
const DofVector *dofVector,
const std::string &filename )
138 int success =
ALBERTA write_dof_real_vec_xdr( dofVector, filename.c_str() );
139 return (success == 0);
148 static DofVector *
get (
const DofSpace *dofSpace,
const std::string &name )
150 return ALBERTA get_dof_real_d_vec( name.c_str(), dofSpace );
153 static void free ( DofVector *dofVector )
155 ALBERTA free_dof_real_d_vec( dofVector );
160 return ALBERTA read_dof_real_d_vec_xdr( filename.c_str(), mesh, dofSpace );
163 static bool write (
const DofVector *dofVector,
const std::string &filename )
165 int success =
ALBERTA write_dof_real_d_vec_xdr( dofVector, filename.c_str() );
166 return (success == 0);
175 template<
class Dof >
185 static const bool supportsAdaptationData =
true;
188 DofVector *dofVector_;
196 const std::string &name =
"" )
197 : dofVector_ ( DofVectorProvider::get( dofSpace, name ) )
201 : dofVector_( dofVector )
204 explicit operator bool ()
const 206 return (
bool)dofVector_;
209 operator DofVector * ()
const 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 assert( dofVector_->user_data );
279 return static_cast< AdaptationData *
>( dofVector_->user_data );
282 template<
class AdaptationData >
285 assert( dofVector_ );
286 dofVector_->user_data = adaptationData;
289 template<
class Interpolation >
292 assert( dofVector_ );
293 dofVector_->refine_interpol = &refineInterpolate< Interpolation >;
296 template<
class Restriction >
299 assert( dofVector_ );
300 dofVector_->coarse_restrict = &coarsenRestrict< Restriction >;
304 template<
class Interpolation >
305 static void refineInterpolate ( DofVector *dofVector, RC_LIST_EL *list,
int n )
307 const This dofVectorPointer( dofVector );
308 typename Interpolation::Patch patch( list, n );
309 Interpolation::interpolateVector( dofVectorPointer, patch );
312 template<
class Restriction >
313 static void coarsenRestrict ( DofVector *dofVector, RC_LIST_EL *list,
int n )
315 const This dofVectorPointer( dofVector );
316 typename Restriction::Patch patch( list, n );
317 Restriction::restrictVector( dofVectorPointer, patch );
328 assert( !dofVector ==
false );
329 int *array = (
int *)dofVector;
330 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
331 array[ dof ] =
std::abs( array[ dof ] ) );
337 assert( !dofVector ==
false );
338 int *array = (
int *)dofVector;
340 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
341 result =
std::max( result, array[ dof ] ) );
348 assert( !dofVector ==
false );
349 int *array = (
int *)dofVector;
351 FOR_ALL_DOFS( dofVector.
dofSpace()->admin,
352 result =
std::min( result, array[ dof ] ) );
360 #endif // #if HAVE_ALBERTA 362 #endif // #ifndef DUNE_ALBERTA_DOFVECTOR_HH Include standard header files.
Definition: agrid.hh:58
DofVectorPointer(DofVector *dofVector)
Definition: dofvector.hh:200
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:104
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:77
ALBERTA DOF_REAL_VEC DofVector
Definition: dofvector.hh:119
void read(const std::string &filename, const MeshPointer< dim > &meshPointer)
Definition: dofvector.hh:241
#define ALBERTA
Definition: albertaheader.hh:27
static void free(DofVector *dofVector)
Definition: dofvector.hh:45
void setupRestriction()
Definition: dofvector.hh:297
Definition: dofvector.hh:176
void setupInterpolation()
Definition: dofvector.hh:290
void forEach(Functor &functor) const
Definition: dofvector.hh:262
Definition: dofvector.hh:33
ALBERTA REAL Real
Definition: misc.hh:46
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:82
ALBERTA MESH Mesh
Definition: misc.hh:51
static void free(DofVector *dofVector)
Definition: dofvector.hh:153
DofVectorPointer(const DofSpace *dofSpace, const std::string &name="")
Definition: dofvector.hh:195
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:163
ALBERTA DOF_SCHAR_VEC DofVector
Definition: dofvector.hh:65
provides a wrapper for ALBERTA's el_info structure
void initialize(const Dof &value)
Definition: dofvector.hh:268
const DofSpace * dofSpace() const
Definition: dofvector.hh:221
AdaptationData * getAdaptationData() const
Definition: dofvector.hh:275
void abs(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:326
provides a wrapper for ALBERTA's refinement patches and the corners for geometryInFather ...
int min(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:346
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:131
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:55
ALBERTA DOF_INT_VEC DofVector
Definition: dofvector.hh:38
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:50
int max(const DofVectorPointer< int > &dofVector)
Definition: dofvector.hh:335
void create(const DofSpace *dofSpace, const std::string &name="")
Definition: dofvector.hh:234
static void free(DofVector *dofVector)
Definition: dofvector.hh:99
ALBERTA REAL_D GlobalVector
Definition: misc.hh:48
Definition: dofadmin.hh:24
std::string name() const
Definition: dofvector.hh:226
static void free(DofVector *dofVector)
Definition: dofvector.hh:72
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:136
static bool write(const DofVector *dofVector, const std::string &filename)
Definition: dofvector.hh:109
ALBERTA FE_SPACE DofSpace
Definition: misc.hh:63
DofVectorProvider::DofVector DofVector
Definition: dofvector.hh:183
bool write(const std::string &filename) const
Definition: dofvector.hh:247
static void free(DofVector *dofVector)
Definition: dofvector.hh:126
void release()
Definition: dofvector.hh:252
ALBERTA DOF_UCHAR_VEC DofVector
Definition: dofvector.hh:92
ALBERTA DOF_REAL_D_VEC DofVector
Definition: dofvector.hh:146
DofVectorPointer()
Definition: dofvector.hh:191
void setAdaptationData(AdaptationData *adaptationData)
Definition: dofvector.hh:283
static DofVector * read(const std::string &filename, Mesh *mesh, DofSpace *dofSpace)
Definition: dofvector.hh:158