Loading [MathJax]/extensions/tex2jax.js
ug4
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
local_finite_element_provider_impl.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3 * Author: Andreas Vogel
4 *
5 * This file is part of UG4.
6 *
7 * UG4 is free software: you can redistribute it and/or modify it under the
8 * terms of the GNU Lesser General Public License version 3 (as published by the
9 * Free Software Foundation) with the following additional attribution
10 * requirements (according to LGPL/GPL v3 §7):
11 *
12 * (1) The following notice must be displayed in the Appropriate Legal Notices
13 * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14 *
15 * (2) The following notice must be displayed at a prominent place in the
16 * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17 *
18 * (3) The following bibliography is recommended for citation and must be
19 * preserved in all covered files:
20 * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21 * parallel geometric multigrid solver on hierarchically distributed grids.
22 * Computing and visualization in science 16, 4 (2013), 151-164"
23 * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24 * flexible software system for simulating pde based models on high performance
25 * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26 *
27 * This program is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 * GNU Lesser General Public License for more details.
31 */
32
33#ifndef __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__
34#define __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__
35
36#include "common/common.h"
38
39namespace ug{
40
42// LocalFiniteElementProvider
44
45template <int dim, typename TShape, typename TGrad>
46std::map<LFEID, LocalFiniteElementProvider::LocalShapeFunctionSets<dim, TShape, TGrad> >&
48{
49 typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
50 static Map map;
51 return map;
52};
53
54template <int dim>
55std::map<LFEID, LocalFiniteElementProvider::DimLocalDoFSets<dim> >&
57{
58 typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
59 static Map map;
60 return map;
61}
62
63template <int dim, typename TShape, typename TGrad>
65register_set(const LFEID& id,
67{
68// get type of map
69 typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
70 Map& map = inst().lsfs_map<dim, TShape, TGrad>();
72 const ReferenceObjectID roid = set->roid();
73
74 if(vLSFS[roid].valid()){
75 UG_THROW("LocalFiniteElementProvider::register_set(): "
76 "Reference type already registered for trial space: "<<id<<" and "
77 " Reference element type "<<roid<<".");
78 } else {
79 vLSFS[roid] = set;
80 }
81
82 if(m_mContSpace.find(id) == m_mContSpace.end()){
83 m_mContSpace.insert(std::map<LFEID, bool>::value_type(id, set->continuous()));
84 }else{
85 if(m_mContSpace[id] != set->continuous())
86 UG_THROW("LocalFiniteElementProvider::register_set(): "
87 "Reference type says continuous:"<<set->continuous()<<", but "
88 " other Reference element says "<<m_mContSpace[id]<<".");
89 }
90
91// register also as DimLocalDoFSet
92 register_set(id, set.template cast_dynamic<DimLocalDoFSet<dim> >());
93}
94
95template <int dim>
97register_set(const LFEID& id,
99{
100// get type of map
101 typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
102 Map& map = inst().lds_map<dim>();
103 DimLocalDoFSets<dim>& vLDS = map[id];
104
105 const ReferenceObjectID roid = set->roid();
106
107 if(vLDS[roid].valid()){
108 UG_THROW("LocalFiniteElementProvider::register_set(): "
109 "Reference type already registered for trial space: "<<id<<" and "
110 " Reference element type "<<roid<<".");
111 } else {
112 vLDS[roid] = set;
113 }
114
115// register also as LocalDoFSet
116 register_set(id, set.template cast_dynamic<LocalDoFSet>());
117}
118
119
120template <int dim, typename TShape, typename TGrad>
123getptr(ReferenceObjectID roid, const LFEID& id, bool bCreate)
124{
125// init provider and get map
126 typedef std::map<LFEID, LocalShapeFunctionSets<dim, TShape, TGrad> > Map;
127 Map& map = inst().lsfs_map<dim, TShape, TGrad>();
128
129// search for identifier
130 typename Map::const_iterator iter = map.find(id);
131 if(iter == map.end() || (iter->second)[roid].invalid())
132 {
133 // try to create the set
134 if(bCreate){
135 create_set(roid, id);
136 return getptr<dim, TShape, TGrad>(roid, id, false);
137 }
138 return SPNULL;
139 }
140
141// return shape function set
142 return (iter->second)[roid];
143}
144
145template <int dim, typename TShape, typename TGrad>
148get(ReferenceObjectID roid, const LFEID& id, bool bCreate)
149{
151 getptr<dim,TShape,TGrad>(roid, id, bCreate);
152
153 if(ptr.valid()) return *ptr;
154 else
155 UG_THROW("LocalFiniteElementProvider: Local Shape Function Set not "
156 "found for "<<roid<<" (world dim: "<<dim<<") and type = "<<id<<
157 ". (This is usually due to: a) The function set is not implemented at "
158 " all, or b) The finite element space is discontinuous but the "
159 "evaluation is requested on a subelement, i.e. a grid object "
160 "with dimension less than the dimension where the finite element"
161 " space is defined.)");
162}
163
164template <int dim>
167get_dof_ptr(ReferenceObjectID roid, const LFEID& id, bool bCreate)
168{
169// init provider and get map
170 typedef std::map<LFEID, DimLocalDoFSets<dim> > Map;
171 Map& map = inst().lds_map<dim>();
172
173// search for identifier
174 typename Map::const_iterator iter = map.find(id);
175 if(iter == map.end() || (iter->second)[roid].invalid())
176 {
177 // try to create the set
178 if(bCreate){
179 create_dof_set(roid, id);
180 return get_dof_ptr<dim>(roid, id, false);
181 }
182 return SPNULL;
183 }
184
185// return shape function set
186 return (iter->second)[roid];
187}
188
189template <int dim>
192get_dofs(ReferenceObjectID roid, const LFEID& id, bool bCreate)
193{
195 get_dof_ptr<dim>(roid, id, bCreate);
196
197 if(ptr.valid()) return *ptr;
198 else
199 UG_THROW("LocalFiniteElementProvider: Local DoF Set not "
200 "found for "<<roid<<" (world dim: "<<dim<<") and type = "<<id);
201}
202
203}
204#endif /* __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_FINITE_ELEMENT_PROVIDER_IMPL__ */
Definition smart_pointer.h:296
bool valid() const
returns true if the pointer is valid, false if not.
Definition smart_pointer.h:414
Definition local_dof_set.h:158
Identifier for Local Finite Elements.
Definition local_finite_element_id.h:98
static std::map< LFEID, LocalShapeFunctionSets< dim, TShape, TGrad > > & lsfs_map()
Definition local_finite_element_provider_impl.h:47
static void create_dof_set(ReferenceObjectID roid, const LFEID &id)
Definition local_finite_element_provider.cpp:663
static std::map< LFEID, DimLocalDoFSets< dim > > & lds_map()
Definition local_finite_element_provider_impl.h:56
static LocalFiniteElementProvider & inst()
Definition local_finite_element_provider.h:73
static const LocalShapeFunctionSet< dim, TShape, TGrad > & get(ReferenceObjectID roid, const LFEID &id, bool bCreate=true)
returns the Local Shape Function Set
Definition local_finite_element_provider_impl.h:148
static void create_set(ReferenceObjectID roid, const LFEID &id)
creates new set at runtime if available
Definition local_finite_element_provider.cpp:552
static const CommonLocalDoFSet & get_dofs(const LFEID &id, bool bCreate=true)
returns the common dof set for all reference objects of a dimension
Definition local_finite_element_provider.cpp:730
static void register_set(const LFEID &id, ConstSmartPtr< LocalShapeFunctionSet< dim, TShape, TGrad > > set)
register a local shape function set for a given reference element type
Definition local_finite_element_provider_impl.h:65
static ConstSmartPtr< DimLocalDoFSet< dim > > get_dof_ptr(ReferenceObjectID roid, const LFEID &id, bool bCreate=true)
Definition local_finite_element_provider_impl.h:167
static ConstSmartPtr< LocalShapeFunctionSet< dim, TShape, TGrad > > getptr(ReferenceObjectID roid, const LFEID &id, bool bCreate=true)
returns the Local Shape Function Set
Definition local_finite_element_provider_impl.h:123
static std::map< LFEID, bool > m_mContSpace
Definition local_finite_element_provider.h:140
virtual base class for local shape function sets
Definition local_shape_function_set.h:70
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition smart_pointer.h:90
#define UG_THROW(msg)
Definition error.h:57
the ug namespace
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition grid_base_objects.h:74
Definition local_finite_element_provider.h:150
Definition local_finite_element_provider.h:128