33 #ifndef __H__UG__LIB_DISC__FUNCTION_SPACS__LOCAL_TRANSFER__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACS__LOCAL_TRANSFER__
45 template <
typename TDomain>
58 template <
typename TElem>
67 for(
int c = 0; c < numChild; ++c){
68 TElem* child = mg->
get_child<TElem>(parent, c);
71 vValueChild[0] = vValueParent[0];
80 template <
typename TElem>
89 UG_ASSERT(vValueParent.
size()==1,
"Exactly one DoF for Piecewise-Constant")
90 vValueParent[0] = 0.0;
92 for(
int c = 0; c < numChild; ++c){
93 TElem* child = mg->
get_child<TElem>(parent, c);
96 UG_ASSERT(vValueChild.
size()==1,
"Exactly one DoF for Piecewise-Constant")
97 vValueParent[0] += vValueChild[0];
99 vValueParent[0] *= (1./numChild);
106 template <
typename TDomain>
119 template <
typename TElem>
126 if(numChild == 0)
return;
127 if(numChild != 1)
UG_THROW(
"Max child Vertex must be 1");
134 if (vValueChild.
size() == 0)
137 const int numVrt = vValueParent.
size();
138 UG_ASSERT(numVrt > 0,
"No function value found on parent vertices.");
140 vValueChild[0] = vValueParent[0];
141 for(
int i = 1; i < numVrt; ++i)
142 vValueChild[0] += vValueParent[i];
143 vValueChild[0] *= 1.0/numVrt;
147 if(gbo ==
VERTEX)
return true;
166 if(numChild != 1)
UG_THROW(
"Num child Vertex must be 1");
173 if (vValueParent.
size() == 0)
176 UG_ASSERT(vValueChild.
size() > 0,
"No function value found on child vertex.");
178 vValueParent[0] = vValueChild[0];
186 template <
typename TDomain>
205 template <
typename TParent,
typename TChild>
220 for(
int c = 0; c < numChild; ++c)
223 TChild* child = mg->
get_child<TChild>(parent, c);
229 std::vector<MathVector<dim> > vDoFPos;
234 ReferenceMappingProvider::get<pdim, dim>(parentRoid, vCornerParent);
237 std::vector<MathVector<pdim> > vLocPos(vDoFPos.size(), 0.0);
241 std::vector<std::vector<number> > vvShape;
242 lsfs.
shapes(vvShape, vLocPos);
245 for(
size_t csh = 0; csh < vValueChild.
size(); ++csh){
246 vValueChild[csh] = 0.0;
247 for(
size_t psh = 0; psh < vValueParent.
size(); ++psh)
248 vValueChild[csh] += vvShape[csh][psh] * vValueParent[psh];
254 template <
typename TElem>
268 std::vector<MathVector<dim> > vCornerParent;
273 LocalFiniteElementProvider::get<pdim>(parentRoid,
m_lfeid);
277 case 3: prolongate<TElem,Volume>(parent, vValueChild, vValueParent, lsfs, vCornerParent, parentRoid);
278 case 2: prolongate<TElem,Face>(parent, vValueChild, vValueParent, lsfs, vCornerParent, parentRoid);
279 case 1: prolongate<TElem,Edge>(parent, vValueChild, vValueParent, lsfs, vCornerParent, parentRoid);
280 prolongate<TElem,Vertex>(parent, vValueChild, vValueParent, lsfs, vCornerParent, parentRoid);
282 default:
UG_THROW(
"Dimension "<<pdim<<
" not supported");
297 if(numChild == 0)
return;
298 if(numChild != 1)
UG_THROW(
"Num child Vertex must be 1");
307 vValueChild[0] = vValueParent[0];
316 template <
typename TElem>
325 std::vector<MathVector<dim> > vDoFPos;
334 for(
size_t ip = 0; ip < vDoFPos.size(); ++ip)
337 for(; c < numChild; ++c)
340 TElem* child = mg->
get_child<TElem>(parent, c);
343 std::vector<MathVector<dim> > vChildDoFPos;
348 for(
size_t i = 0; i < vChildDoFPos.size(); ++i)
353 if(cip == -1)
continue;
359 vValueParent[ip] = vValueChild[cip];
365 UG_THROW(
"Lagrange-Element-Coarsening: Cannot find DoF position "
366 "in child elems for "<<ip<<
"'s Pos: "<<vDoFPos[ip])
376 if(numChild != 1)
UG_THROW(
"Num child Vertex must be 1");
386 vValueParent[0] = vValueChild[0];
395 template <
typename TDomain>
420 UG_THROW(
"No implementation for Vertex and Crouzeix-Raviart.")
423 template <
typename TS
ide>
424 void prolongate(
const std::vector<typename TSide::sideof*>& vParentElem,
425 const std::vector<TSide*>& vChildSide,
430 typedef typename TSide::sideof TElem;
431 if(vParentElem.size() > 2)
432 UG_THROW(
"More than 2 Elements share a side.")
435 for(
size_t c = 0; c < vChildSide.size(); ++c){
437 for(
size_t csh = 0; csh < vValueChild.
size(); ++csh)
438 vValueChild[csh] = 0.0;
442 for(
size_t p = 0;
p < vParentElem.size(); ++
p)
445 TElem* parentElem = vParentElem[
p];
455 std::vector<MathVector<dim> > vCornerParent;
460 LocalFiniteElementProvider::get<pdim>(parentRoid,
m_lfeid);
463 for(
size_t c = 0; c < vChildSide.size(); ++c)
466 TSide* childSide = vChildSide[c];
472 std::vector<MathVector<dim> > vDoFPos;
477 ReferenceMappingProvider::get<pdim, dim>(parentRoid, vCornerParent);
480 std::vector<MathVector<pdim> > vLocPos(vDoFPos.size(), 0.0);
484 std::vector<std::vector<number> > vvShape;
485 lsfs.
shapes(vvShape, vLocPos);
488 for(
size_t csh = 0; csh < vValueChild.
size(); ++csh){
489 for(
size_t psh = 0; psh < vValueParent.
size(); ++psh)
490 vValueChild[csh] += (1./vParentElem.size()) *
491 vvShape[csh][psh] * vValueParent[psh];
497 template <
typename TParent>
505 typedef typename TParent::sideof TElem;
506 typedef TParent TSide;
510 if(numChild == 0)
return;
513 std::vector<TSide*> vChildSide(numChild);
514 for(
int c = 0; c < numChild; ++c)
515 vChildSide[c] = mg->
get_child<TParent>(parent, c);
519 const_cast<MultiGrid*
>(mg)->associated_elements(vElem, parent);
520 std::vector<TElem*> vParentElem(vElem.
size());
521 for(
size_t p = 0;
p < vElem.
size(); ++
p)
522 vParentElem[
p] = vElem[
p];
525 this->
template prolongate<TSide>(vParentElem, vChildSide, vValueChild, vValueParent);
530 typedef TParent TElem;
531 typedef typename TParent::side TSide;
535 if(numChild == 0)
return;
538 std::vector<TSide*> vChildSide(numChild);
539 for(
int c = 0; c < numChild; ++c)
540 vChildSide[c] = mg->
get_child<TSide>(parent, c);
543 std::vector<TElem*> vParentElem(1);
544 vParentElem[0] = parent;
547 this->
template prolongate<TSide>(vParentElem, vChildSide, vValueChild, vValueParent);
557 template <
typename TParent>
569 if(numChild == 0)
return;
573 UG_ASSERT(vValueParent.
size() == 1,
"Num DoFs per Side must be 1 for CR");
576 vValueParent[0] = 0.0;
579 for(
int c = 0; c < numChild; ++c)
582 TParent* childSide = mg->
get_child<TParent>(parent, c);
586 UG_ASSERT(vValueChild.
size() == 1,
"Num DoFs per Side must be 1 for CR");
589 vValueParent[0] += vValueChild[0];
592 vValueParent[0] *= (1./numChild);
Definition: local_transfer.h:399
CrouzeixRaviartElemTransfer(const LFEID &lfeid)
Definition: local_transfer.h:405
void do_restrict(TParent *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:558
virtual bool perform_restriction_on(GridBaseObjectId gbo)
Definition: local_transfer.h:551
void prolongate(const std::vector< typename TSide::sideof * > &vParentElem, const std::vector< TSide * > &vChildSide, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:424
virtual bool perform_prolongation_on(GridBaseObjectId gbo)
Definition: local_transfer.h:407
void prolongate(Vertex *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:416
LFEID m_lfeid
Definition: local_transfer.h:596
static const int dim
world dimension
Definition: local_transfer.h:402
void prolongate(TParent *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:498
virtual base class for reference mappings
Definition: reference_mapping_provider.h:53
virtual void global_to_local(MathVector< dim > &locPos, const MathVector< worldDim > &globPos, const size_t maxIter=1000, const number tol=1e-10) const =0
map global coordinate to local coordinate
Definition: local_transfer_interface.h:108
Definition: local_transfer_interface.h:175
The base class for all geometric objects, such as vertices, edges, faces, volumes,...
Definition: grid_base_objects.h:157
Definition: local_transfer_interface.h:76
Definition: local_transfer_interface.h:143
Identifier for Local Finite Elements.
Definition: local_finite_element_id.h:98
int order() const
returns the order of the local finite element
Definition: local_finite_element_id.h:126
int dim() const
returns the space dimension of the local finite element
Definition: local_finite_element_id.h:129
virtual base class for local shape function sets
Definition: local_shape_function_set.h:70
virtual void shapes(shape_type *vShape, const MathVector< dim > &x) const =0
returns all shape functions evaluated at a point
Definition: multi_grid.h:72
TChild * get_child(TElem *elem, size_t ind) const
returns the i-th child of the given child-type
Definition: multi_grid.h:268
size_t num_children(TElem *elem) const
returns the number of children of the given child-type
Definition: multi_grid.h:225
Definition: local_transfer.h:110
P1LagrangeElemTransfer(const LFEID &lfeid)
Definition: local_transfer.h:112
void do_restrict(GridObject *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:153
LFEID m_lfeid
Definition: local_transfer.h:182
virtual bool perform_restriction_on(GridBaseObjectId gbo)
Definition: local_transfer.h:146
virtual bool perform_prolongation_on(GridBaseObjectId gbo)
Definition: local_transfer.h:114
void do_restrict(Vertex *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:160
void prolongate(TElem *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:120
Definition: local_transfer.h:49
virtual bool perform_restriction_on(GridBaseObjectId gbo)
Definition: local_transfer.h:75
LFEID m_lfeid
Definition: local_transfer.h:103
void do_restrict(TElem *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:81
void prolongate(TElem *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:59
PiecewiseConstantElemTransfer(const LFEID &lfeid)
Definition: local_transfer.h:51
virtual bool perform_prolongation_on(GridBaseObjectId gbo)
Definition: local_transfer.h:53
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
size_t size() const
returns the size of the associated array.
Definition: pointer_const_array_impl.hpp:106
Definition: local_transfer.h:190
static const int dim
world dimension
Definition: local_transfer.h:193
void prolongate(TElem *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:255
LFEID m_lfeid
Definition: local_transfer.h:391
virtual bool perform_restriction_on(GridBaseObjectId gbo)
Definition: local_transfer.h:311
virtual bool perform_prolongation_on(GridBaseObjectId gbo)
Definition: local_transfer.h:198
virtual void do_restrict(Vertex *parent)
Definition: local_transfer.h:372
virtual void prolongate(Vertex *parent)
Definition: local_transfer.h:286
StdLagrangeElemTransfer(const LFEID &lfeid)
Definition: local_transfer.h:196
void prolongate(TParent *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent, const LocalShapeFunctionSet< TParent::dim > &lsfs, const std::vector< MathVector< dim > > &vCornerParent, const ReferenceObjectID parentRoid)
Definition: local_transfer.h:206
void do_restrict(TElem *parent, TransferValueAccessor &vValueChild, TransferValueAccessor &vValueParent)
Definition: local_transfer.h:317
Definition: local_transfer_interface.h:46
virtual void access_inner(GridObject *elem)=0
size_t size() const
Definition: local_transfer_interface.h:64
virtual void access_closure(GridObject *elem)=0
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
void CollectCornerCoordinates(std::vector< typename TAAPos::ValueType > &vCornerCoordsOut, const TElem &elem, const TAAPos &aaPos, bool clearContainer=true)
returns the corner coordinates of a geometric object
Definition: domain_util_impl.h:75
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_THROW(msg)
Definition: error.h:57
vector_t::value_type VecDistanceSq(const vector_t &v1, const vector_t &v2)
returns the squared distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:351
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
bool DoFPosition(std::vector< MathVector< dim > > &vPos, const ReferenceObjectID roid, const std::vector< MathVector< dim > > &vCornerCoord, const LFEID &lfeID)
�
Definition: dof_position_util.cpp:202
GridBaseObjectId
enumeration of the GridBaseObjects that make up a grid.
Definition: grid_base_objects.h:59
@ VERTEX
Definition: grid_base_objects.h:60
bool InnerDoFPosition(std::vector< MathVector< dim > > &vPos, const ReferenceObjectID roid, const std::vector< MathVector< dim > > &vCornerCoord, const LFEID &lfeID)
�
Definition: dof_position_util.cpp:112