29 gsExprHelper(
const gsExprHelper &);
31 gsExprHelper() : m_mirror(nullptr), mesh_ptr(nullptr),
32 mutSrc(nullptr), mutMap(nullptr)
35 explicit gsExprHelper(gsExprHelper * m)
37 mesh_ptr(m->mesh_ptr), mutSrc(nullptr), mutMap(nullptr)
41 typedef util::gsThreaded<gsFuncData<T> > thFuncData;
42 typedef util::gsThreaded<gsMapData<T> > thMapData;
43 typedef std::map<const gsFunctionSet<T>*,thFuncData> FuncData;
44 typedef std::map<const gsFunctionSet<T>*,thMapData> MapData;
45 typedef std::pair<const gsFunctionSet<T>*,thMapData*> CFuncKey;
46 typedef std::map<CFuncKey,thFuncData> CFuncData;
48 typedef typename FuncData::iterator FuncDataIt;
49 typedef typename MapData ::iterator MapDataIt;
50 typedef typename CFuncData ::iterator CFuncDataIt;
52 util::gsThreaded<gsMatrix<T> > m_points;
57 memory::shared_ptr<gsExprHelper> m_mirror;
68 expr::gsFeElement<T> m_element;
71 typedef memory::unique_ptr<gsExprHelper> uPtr;
72 typedef memory::shared_ptr<gsExprHelper> Ptr;
74 typedef const expr::gsGeometryMap<T> geometryMap;
75 typedef expr::gsFeElement<T> & element;
78 typedef const expr::gsComposition<T> composition;
79 typedef const expr::gsNullExpr<T> nullExpr;
86 gsMatrix<T> & pointsIfc() {
return this->iface().m_points; }
88 bool isMirrored()
const {
return nullptr!=m_mirror; }
90 static uPtr make() {
return uPtr(
new gsExprHelper()); }
107 mutData.mine().flags = 0;
110 m_mirror->m_mdata.clear();
111 m_mirror->m_fdata.clear();
112 m_mirror->m_cdata.clear();
114 m_mirror->mutMap =
nullptr;
115 m_mirror->mutData.mine().flags = 0;
120 void setMultiBasis(
const gsMultiBasis<T> & mesh) { mesh_ptr = &mesh; }
122 bool multiBasisSet() {
return NULL!=mesh_ptr;}
124 const gsMultiBasis<T> & multiBasis()
126 GISMO_ASSERT(multiBasisSet(),
"Integration elements not set.");
130 const gsMultiPatch<T> & multiPatch()
const
135 "Multipatch geometry map not set.");
136 return *
static_cast<const gsMultiPatch<T>*
>(
m_mdata.begin()->first);
138 if (isMirrored() && !m_mirror->m_mdata.empty() )
140 GISMO_ASSERT(
nullptr!=
dynamic_cast<const gsMultiPatch<T>*
>(m_mirror->m_mdata.begin()->first),
141 "Multipatch geometry map not set.");
142 return *
static_cast<const gsMultiPatch<T>*
>(m_mirror->m_mdata.begin()->first);
147 const gsMapData<T> & multiPatchData()
const
150 return m_mdata.begin()->second;
153 geometryMap getMap(
const gsFunctionSet<T> & mp)
155 expr::gsGeometryMap<T> gm;
160 expr::gsFeVariable<T> getVar(
const gsFunctionSet<T> & mp,
index_t dim = 1)
162 expr::gsFeVariable<T> var;
168 composition getVar(
const gsFunctionSet<T> & mp, geometryMap & G)
170 expr::gsComposition<T> var(G);
175 expr::gsFeSpace<T> getSpace(
const gsFunctionSet<T> & mp,
index_t dim = 1)
177 expr::gsFeSpace<T> var;
183 variable getMutVar()
const
185 expr::gsFeVariable<T> var;
189 element getElement() {
return m_element; }
191 composition getMutVar(geometryMap & G)
193 expr::gsComposition<T> var(G);
198 void setMutSource(
const gsFunctionSet<T> & func)
205 void activateFlags(
unsigned flg)
209 it->second.mine().flags |= flg;
211 it->second.mine().flags |= flg;
213 it->second.mine().flags |= flg;
221 inline gsExprHelper & iface()
223 if (
nullptr==m_mirror )
229 void _parse(
const expr::_expr<E1> & a1)
235 template <
class E1,
class... Rest>
236 void _parse(
const expr::_expr<E1> & a1, Rest &... restArgs)
242 template<
size_t I,
typename... Ts>
243 void _parse_tuple_i (
const std::tuple<Ts...> &tuple)
245 std::get<I>(tuple).parse(*
this);
246 if (I + 1 <
sizeof... (Ts))
247 _parse_tuple_i<(I+1 <
sizeof... (Ts) ? I+1 : I)> (tuple);
250 template<
typename... Ts>
251 void _parse_tuple (
const std::tuple<Ts...> &tuple) {_parse_tuple_i<0>(tuple);}
253 void setInitialFlags()
268 for (MapDataIt it = m_mirror->m_mdata.begin(); it != m_mirror->m_mdata.end(); ++it)
270 for (FuncDataIt it = m_mirror->m_fdata.begin(); it != m_mirror->m_fdata.end(); ++it)
272 for (CFuncDataIt it = m_mirror->m_cdata.begin(); it != m_mirror->m_cdata.end(); ++it)
282 template<
class... Ts>
283 void parse(
const std::tuple<Ts...> &tuple)
290 template<
class... expr>
291 void parse(
const expr &... args)
298 void add(
const expr::gsGeometryMap<T> & sym)
300 GISMO_ASSERT(NULL!=sym.m_fs,
"Geometry map "<<&sym<<
" is invalid");
301 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
302 # pragma omp critical (m_mdata_first_touch)
303 const_cast<expr::gsGeometryMap<T>&
>(sym)
304 .setData(eh.m_mdata[sym.m_fs]);
307 void add(
const expr::gsComposition<T> & sym)
312 if (
nullptr==sym.m_fs)
315 mutMap = &sym.inner().source();
318 # pragma omp critical (m_fdata_first_touch)
319 const_cast<expr::gsComposition<T>&
>(sym)
322 const_cast<expr::gsComposition<T>&
>(sym)
326 gsWarn<<
"\nSomething went terribly wrong here (add gsComposition).\n";
331 auto k = std::make_pair(sym.m_fs,&
m_mdata[sym.inner().m_fs]);
333 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
337 # pragma omp critical (m_cdata_first_touch)
338 const_cast<expr::gsComposition<T>&
>(sym)
339 .setData(eh.m_cdata[
give(k) ]);
341 const_cast<expr::gsComposition<T>&
>(sym)
342 .setData(eh.m_cdata[
give(k) ]);
346 void add(
const expr::symbol_expr<E> & sym)
351 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
368 # pragma omp critical (m_fdata_first_touch)
369 const_cast<expr::symbol_expr<E>&
>(sym)
370 .setData( eh.m_fdata[sym.m_fs] );
378 # pragma omp critical (m_fdata_first_touch)
379 const_cast<expr::symbol_expr<E>&
>(sym)
382 const_cast<expr::symbol_expr<E>&
>(sym)
386 gsWarn<<
"\nSomething went wrong here (add symbol_expr).\n";
390 void precompute(
const index_t patchIndex = 0,
396 it->second.mine().points.swap(m_points.mine());
397 it->second.mine().side = bs;
398 it->second.mine().patchId = patchIndex;
399 it->first->function(patchIndex).computeMap(it->second.mine());
400 it->second.mine().points.swap(m_points.mine());
405 it->second.mine().patchId = patchIndex;
406 it->first->piece(patchIndex)
407 .compute(m_points, it->second.mine());
412 it->first.first->piece(patchIndex)
413 .compute(it->first.second->mine().values[0], it->second.mine());
414 it->second.mine().patchId = patchIndex;
418 if (
nullptr!=mutSrc && 0!=mutData.mine().flags)
420 mutSrc->piece(patchIndex)
421 .compute( mutMap ?
m_mdata[mutMap].mine().values[0]
422 : m_points, mutData );
426 void precompute(
const boundaryInterface & iFace)
428 this->precompute( iFace.first ().patch, iFace.first().side() );
430 m_mirror->precompute(iFace.second().patch, iFace.second().side());
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer. Usefull to refer to objects which should not be destroyed.
Definition: gsMemory.h:189
Definition: gsExpressions.h:96
Defines different expressions.
side
Identifiers for topological sides.
Definition: gsBoundary.h:58
MapData m_mdata
maps
Definition: gsExprHelper.h:54
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
FuncData m_fdata
functions
Definition: gsExprHelper.h:53
#define gsWarn
Definition: gsDebug.h:50
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
Wrapper for thread-local data members.
Active function ids.
Definition: gsForwardDeclarations.h:84
Definition: gsDirichletValues.h:23
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Value of the object.
Definition: gsForwardDeclarations.h:72
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
Definition: gsExpressions.h:114
CFuncData m_cdata
compositions
Definition: gsExprHelper.h:55
shared_ptr< T > make_shared(T *x)
Definition: gsMemory.h:181