33#ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_IMPL__
34#define __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_IMPL__
55template <
typename TDomain,
typename TAlgebra>
60 init(spApproxSpace, spDoFDistr, bManage);
63template <
typename TDomain,
typename TAlgebra>
70template <
typename TDomain,
typename TAlgebra>
77template <
typename TDomain,
typename TAlgebra>
81 init(spApproxSpace, spApproxSpace->dof_distribution(gl), bManage);
84template <
typename TDomain,
typename TAlgebra>
90 m_spApproxSpace = spApproxSpace;
93 m_bRedistribute =
true;
94 this->set_dof_distribution_info(m_spApproxSpace->dof_distribution_info());
98 if(m_spDD.invalid())
UG_THROW(
"GridFunction: DoF Distribution is null.");
99 if(m_spApproxSpace.invalid())
UG_THROW(
"GridFunction: ApproxSpace is null.");
105 resize_values(num_indices());
109 m_spDD->manage_grid_function(*
this);
112 register_at_adaption_msg_hub();
118 this->set_layouts(m_spDD->layouts());
125template <
typename TDomain,
typename TAlgebra>
130 const int blockSize = algebra_type::blockSize;
133 if(blockSize > 1 && !this->m_spDD->grouped())
135 UG_THROW(
"Fixed block algebra needs grouped dofs.");
139 && !this->m_spDD->grouped())
141 UG_THROW(
"Variable block algebra needs grouped dofs.");
145 else if (blockSize == 1 && this->m_spDD->grouped())
147 UG_THROW(
"block 1x1 algebra needs non-grouped dofs.");
151template <
typename TDomain,
typename TAlgebra>
166template <
typename TDomain,
typename TAlgebra>
177 this->set_storage_type(v.get_storage_mask());
178 this->set_layouts(v.layouts());
183template <
typename TDomain,
typename TAlgebra>
187 if(v.size() != vector_type::size())
188 UG_THROW(
"GridFunction: Assigned vector has incorrect size.");
194template <
typename TDomain,
typename TAlgebra>
204template <
typename TDomain,
typename TAlgebra>
210 p->enable_redistribution(redistribution_enabled());
211 if(
p->size() != this->size())
212 p->resize(this->size());
214 p->set_layouts(this->layouts());
224template <
typename TDomain,
typename TAlgebra>
230 const size_t oldSize = vector_type::size();
233 vector_type::resize_sloppy(
s);
236 for(
size_t i = oldSize; i <
s; ++i)
237 this->
operator[](i) = defaultValue;
240template <
typename TDomain,
typename TAlgebra>
246 if(vIndNew.size() != this->size())
247 UG_THROW(
"GridFunction::permute_values: For a permutation the"
248 " index set must have same cardinality as vector.");
255 vecTmp.set_storage_type(this->get_storage_mask());
256 vecTmp.set_layouts(this->layouts());
260 for(
size_t i = 0; i < vIndNew.size(); ++i)
261 vecTmp[vIndNew[i]] = this->
operator[](i);
264 this->assign(vecTmp);
267template <
typename TDomain,
typename TAlgebra>
270copy_values(
const std::vector<std::pair<size_t, size_t> >& vIndexMap,
bool bDisjunct)
274 for(
size_t i = 0; i < vIndexMap.size(); ++i)
275 this->
operator[](vIndexMap[i].second)
276 = this->operator[](vIndexMap[i].first);
278 typedef typename vector_type::value_type
value_type;
279 std::vector<value_type> values;
280 values.resize(vIndexMap[vIndexMap.size()-1].first);
281 for(
size_t i = 0; i < vIndexMap.size(); ++i){
282 const size_t index = vIndexMap[i].first;
283 if (index>=values.size()) values.resize(index+1);
284 values[index] = this->operator[](index);
286 for(
size_t i = 0; i < vIndexMap.size(); ++i)
287 this->
operator[](vIndexMap[i].second)
288 = values[vIndexMap[i].first];
296template <
typename TDomain,
typename TAlgebra>
303 m_spGridAdaptionCallbackID =
305 &this_type::grid_changed_callback);
307 m_spGridDistributionCallbackID =
309 &this_type::grid_distribution_callback);
312template <
typename TDomain,
typename TAlgebra>
322 m_spAdaptGridFct->copy_from_surface(*
this);
331 Grid& grid = *domain()->grid();
333 if(m_spDDI->max_dofs(
VERTEX)){
340 if(m_spDDI->max_dofs(
EDGE)){
347 if(m_spDDI->max_dofs(
FACE)){
354 if(m_spDDI->max_dofs(
VOLUME)){
362 m_spAdaptGridFct->do_restrict(msg);
367 m_spAdaptGridFct->prolongate(msg);
374 resize_values(num_indices());
378 this->set_layouts(m_spDD->layouts());
382 m_spAdaptGridFct->copy_to_surface(*
this);
383 m_spAdaptGridFct =
SPNULL;
387template <
typename TDomain,
typename TAlgebra>
399 if(redistribution_enabled()){
400 m_preDistStorageType = this->get_storage_mask();
407 m_spAdaptGridFct->copy_from_surface(*
this);
408 Grid& grid = *domain()->grid();
412 if(m_spDDI->max_dofs(
VERTEX)){
419 create(grid, m_spAdaptGridFct->value_attachment()));
421 if(m_spDDI->max_dofs(
EDGE)){
422 ComPol_CopyAttachment<EdgeLayout, AValues> compol(grid, m_spAdaptGridFct->value_attachment());
427 sh.
add(GeomObjAttachmentSerializer<Edge, AValues>::
428 create(grid, m_spAdaptGridFct->value_attachment()));
430 if(m_spDDI->max_dofs(
FACE)){
431 ComPol_CopyAttachment<FaceLayout, AValues> compol(grid, m_spAdaptGridFct->value_attachment());
436 sh.
add(GeomObjAttachmentSerializer<Face, AValues>::
437 create(grid, m_spAdaptGridFct->value_attachment()));
439 if(m_spDDI->max_dofs(
VOLUME)){
440 ComPol_CopyAttachment<VolumeLayout, AValues> compol(grid, m_spAdaptGridFct->value_attachment());
444 sh.
add(GeomObjAttachmentSerializer<Volume, AValues>::
445 create(grid, m_spAdaptGridFct->value_attachment()));
454 resize_values(num_indices());
457 this->set_layouts(m_spDD->layouts());
459 if(redistribution_enabled()){
460 m_spAdaptGridFct->copy_to_surface(*
this);
461 m_spAdaptGridFct =
SPNULL;
463 if(m_preDistStorageType != this->get_storage_mask()){
469 UG_THROW(
"Can't reestablish storage type!");
399 if(redistribution_enabled()) {
…}
394 #ifdef UG_PARALLEL {
…}
378 this->set_layouts(m_spDD->layouts()); {
…}
312template <
typename TDomain,
typename TAlgebra> {
…}
183template <
typename TDomain,
typename TAlgebra> {
…}
Definition smart_pointer.h:108
Performs communication between interfaces on different processes.
Definition pcl_interface_communicator.h:68
bool communicate(int tag=749345)
sends and receives the collected data.
Definition pcl_interface_communicator_impl.hpp:409
void exchange_data(const TLayoutMap &layoutMap, const typename TLayoutMap::Key &keyFrom, const typename TLayoutMap::Key &keyTo, ICommunicationPolicy< TLayout > &commPol)
internally calls send_data and receive_data with the specified layouts.
Definition pcl_interface_communicator_impl.hpp:213
Definition adaption_surface_grid_function.h:43
@ VariableBlockSize
Definition algebra_type.h:59
base class for approximation spaces without type of algebra or dof distribution
Definition approximation_space.h:279
copies values from a specified attachment to a stream and back.
Definition compol_copy_attachment.h:54
GridLayoutMap & grid_layout_map()
Definition distributed_grid.h:103
Definition dof_count.h:43
static const byte UNIQUE_SS
Definition dof_count.h:53
void sum_values_over_procs(int proc=-1)
sums values over all procs (reduced to 'proc', allreduce for -1)
Definition dof_count.cpp:63
static const byte UNIQUE_ES
Definition dof_count.h:52
uint64 num(int fct, int si, SurfaceView::SurfaceState ss, byte is) const
Definition dof_count.cpp:106
Serialization callback for grid attachments.
Definition serialization.h:290
Serialization of data associated with grid elements.
Definition serialization.h:186
void add(SPVertexDataSerializer cb)
Adds a callback class for serialization and deserialization.
Definition serialization.cpp:69
represents numerical solutions on a grid using an algebraic vector
Definition grid_function.h:121
size_t num_dofs() const
Definition grid_function.h:310
void check_algebra()
checks the algebra
Definition grid_function_impl.h:127
bool redistribution_enabled() const
retruns true if the grid-function is redistributed together with the grid in parallel applications
Definition grid_function.h:361
algebra_type::vector_type vector_type
Vector type used to store dof values.
Definition grid_function.h:139
SmartPtr< ApproximationSpace< TDomain > > m_spApproxSpace
Approximation Space.
Definition grid_function.h:412
virtual void copy_values(const std::vector< std::pair< size_t, size_t > > &vIndexMap, bool bDisjunct=false)
copy values
Definition grid_function_impl.h:270
virtual void clone_pattern(const this_type &v)
copies the GridFunction v, except that the values are copied.
Definition grid_function_impl.h:169
GridFunction(SmartPtr< ApproximationSpace< TDomain > > spApproxSpace, SmartPtr< DoFDistribution > spDoFDistr, bool bManage=true)
Initializing Constructor.
Definition grid_function_impl.h:57
void grid_changed_callback(const GridMessage_Adaption &msg)
Definition grid_function_impl.h:315
virtual void resize_values(size_t s, number defaultValue=0.0)
resize
Definition grid_function_impl.h:227
void grid_distribution_callback(const GridMessage_Distribution &msg)
called during parallel redistribution
Definition grid_function_impl.h:390
virtual void permute_values(const std::vector< size_t > &vIndNew)
permutes all values
Definition grid_function_impl.h:243
void register_at_adaption_msg_hub()
registers at message hub for grid adaption
Definition grid_function_impl.h:299
SmartPtr< DoFDistribution > m_spDD
DoF Distribution this GridFunction relies on.
Definition grid_function.h:409
void assign(const this_type &v)
assigns another GridFunction
Definition grid_function_impl.h:195
bool m_bManaged
boolean for DoF Distribution management of grid function
Definition grid_function.h:415
virtual this_type * virtual_clone_without_values() const
virtual clone using covariant return type excluding values
Definition grid_function_impl.h:206
void init(SmartPtr< ApproximationSpace< TDomain > > spApproxSpace, SmartPtr< DoFDistribution > spDoFDistr, bool bManage)
inits the grid function
Definition grid_function_impl.h:87
Manages the elements of a grid and their interconnection.
Definition grid.h:132
DistributedGridManager * distributed_grid_manager()
returns a pointer to the associated distributed grid manager.
Definition grid_impl.hpp:53
Definition grid_level.h:42
@ TOP
Definition grid_level.h:45
@ SURFACE
Definition grid_level.h:48
A message sent along with "GridRefinement" messages.
Definition lib_grid_messages.h:91
bool step_begins() const
tells whether an adaption step has just been started or has been finished.
Definition lib_grid_messages.cpp:50
bool adaption_ends() const
tells whether grid adaption has just been started or has been finished.
Definition lib_grid_messages.cpp:44
bool adaption_begins() const
tells whether grid adaption has just been started or has been finished.
Definition lib_grid_messages.cpp:38
bool step_ends() const
tells whether an adaption step has just been started or has been finished.
Definition lib_grid_messages.cpp:63
bool coarsening() const
tells whether a step is a coarsen step
Definition lib_grid_messages.cpp:119
bool refinement() const
tells whether a step is a refinement step.
Definition lib_grid_messages.cpp:106
Definition lib_grid_messages.h:166
GridDataSerializationHandler & serialization_handler() const
Definition lib_grid_messages.h:176
GridMessageDistributionType msg() const
Definition lib_grid_messages.h:174
SPCallbackId register_class_callback(TClass *cls, void(TClass::*callback)(const TMsg &), bool autoFree=true)
registers a method callback given a message-type.
Definition message_hub_impl.hpp:53
@ PST_UNDEFINED
Definition parallel_storage_type.h:67
@ PST_CONSISTENT
Definition parallel_storage_type.h:68
@ PST_UNIQUE
Definition parallel_storage_type.h:70
@ PST_ADDITIVE
Definition parallel_storage_type.h:69
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition smart_pointer.h:90
#define UG_THROW(msg)
Definition error.h:57
double number
Definition types.h:124
function util LuaCallbackHelper create(func)
@ GMDT_DISTRIBUTION_STARTS
Definition lib_grid_messages.h:161
@ GMDT_DISTRIBUTION_STOPS
Definition lib_grid_messages.h:162
@ VOLUME
Definition grid_base_objects.h:63
@ VERTEX
Definition grid_base_objects.h:60
@ EDGE
Definition grid_base_objects.h:61
@ FACE
Definition grid_base_objects.h:62
@ INT_V_MASTER
vertical master node
Definition parallel_grid_layout.h:106
@ INT_V_SLAVE
vertical slave node
Definition parallel_grid_layout.h:107
#define PROFILE_BEGIN(name)
Definition profiler.h:254
#define PROFILE_END()
Definition profiler.h:256
#define PROFILE_FUNC()
Definition profiler.h:257
T value_type
Definition sparsematrix_interface.h:2