32 mutSrc(
nullptr), mutMap(
nullptr), m_element(*
this)
37 mesh_ptr(m->mesh_ptr), mutSrc(
nullptr), mutMap(
nullptr), m_element(*
this)
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;
53 util::gsThreaded<gsVector<T> > m_weights;
58 memory::shared_ptr<gsExprHelper> m_mirror;
69 expr::gsFeElement<T> m_element;
72 typedef memory::unique_ptr<gsExprHelper> uPtr;
73 typedef memory::shared_ptr<gsExprHelper> Ptr;
75 typedef const expr::gsGeometryMap<T> geometryMap;
76 typedef expr::gsFeElement<T> & element;
79 typedef const expr::gsComposition<T> composition;
80 typedef const expr::gsNullExpr<T> nullExpr;
87 gsMatrix<T> & pointsIfc() {
return this->iface().m_points; }
89 gsVector<T> & weights() {
return m_weights; }
90 const gsVector<T> & weights()
const {
return m_weights; }
92 gsVector<T> & weightsIfc() {
return this->iface().m_weights; }
93 const gsVector<T> & weightsIfc()
const {
return this->iface().m_weights; }
95 bool isMirrored()
const {
return nullptr!=m_mirror; }
97 static uPtr make() {
return uPtr(
new gsExprHelper()); }
114 mutData.mine().clear();
117 m_mirror->m_mdata.clear();
118 m_mirror->m_fdata.clear();
119 m_mirror->m_cdata.clear();
121 m_mirror->mutMap =
nullptr;
122 m_mirror->mutData.mine().clear();
127 void setMultiBasis(
const gsMultiBasis<T> & mesh) { mesh_ptr = &mesh; }
129 bool multiBasisSet() {
return NULL!=mesh_ptr;}
131 const gsMultiBasis<T> & multiBasis()
133 GISMO_ASSERT(multiBasisSet(),
"Integration elements not set.");
137 const gsMultiPatch<T> & multiPatch()
const
142 "Multipatch geometry map not set.");
143 return *
static_cast<const gsMultiPatch<T>*
>(
m_mdata.begin()->first);
145 if (isMirrored() && !m_mirror->m_mdata.empty() )
147 GISMO_ASSERT(
nullptr!=
dynamic_cast<const gsMultiPatch<T>*
>(m_mirror->m_mdata.begin()->first),
148 "Multipatch geometry map not set.");
149 return *
static_cast<const gsMultiPatch<T>*
>(m_mirror->m_mdata.begin()->first);
154 const gsMapData<T> & multiPatchData()
const
157 return m_mdata.begin()->second;
160 geometryMap getMap(
const gsFunctionSet<T> & mp)
162 expr::gsGeometryMap<T> gm;
167 expr::gsFeVariable<T> getVar(
const gsFunctionSet<T> & mp,
index_t dim = 1)
169 expr::gsFeVariable<T> var;
175 composition getVar(
const gsFunctionSet<T> & mp, geometryMap & G)
177 expr::gsComposition<T> var(G);
182 expr::gsFeSpace<T> getSpace(
const gsFunctionSet<T> & mp,
index_t dim = 1)
184 expr::gsFeSpace<T> var;
190 variable getMutVar()
const
192 expr::gsFeVariable<T> var;
196 element getElement() {
return m_element; }
198 composition getMutVar(geometryMap & G)
200 expr::gsComposition<T> var(G);
205 void setMutSource(
const gsFunctionSet<T> & func)
212 void activateFlags(
unsigned flg)
216 it->second.mine().flags |= flg;
218 it->second.mine().flags |= flg;
220 it->second.mine().flags |= flg;
228 inline gsExprHelper & iface()
230 if (
nullptr==m_mirror )
236 void _parse(
const expr::_expr<E1> & a1)
242 template <
class E1,
class... Rest>
243 void _parse(
const expr::_expr<E1> & a1, Rest &... restArgs)
249 template<
size_t I,
typename... Ts>
250 void _parse_tuple_i (
const std::tuple<Ts...> &tuple)
252 std::get<I>(tuple).parse(*
this);
253 if (I + 1 <
sizeof... (Ts))
254 _parse_tuple_i<(I+1 <
sizeof... (Ts) ? I+1 : I)> (tuple);
257 template<
typename... Ts>
258 void _parse_tuple (
const std::tuple<Ts...> &tuple) {_parse_tuple_i<0>(tuple);}
260 template<
size_t I,
typename... Ts>
261 void _parse_tt_tuple_i (
const std::tuple<Ts...> &tuple)
263 if (std::get<I>(tuple).isMatrix())
265 std::get<I>(tuple).rowVar().parse(*
this);
266 std::get<I>(tuple).colVar().parse(*
this);
268 if (I + 1 <
sizeof... (Ts))
269 _parse_tt_tuple_i<(I+1 <
sizeof... (Ts) ? I+1 : I)> (tuple);
272 template<
typename... Ts>
273 void _parse_tt_tuple (
const std::tuple<Ts...> &tuple) {_parse_tt_tuple_i<0>(tuple);}
275 void setInitialFlags()
290 for (MapDataIt it = m_mirror->m_mdata.begin(); it != m_mirror->m_mdata.end(); ++it)
292 for (FuncDataIt it = m_mirror->m_fdata.begin(); it != m_mirror->m_fdata.end(); ++it)
294 for (CFuncDataIt it = m_mirror->m_cdata.begin(); it != m_mirror->m_cdata.end(); ++it)
304 template<
class... Ts>
305 void parse(
const std::tuple<Ts...> &tuple)
312 template<
class... Ts>
313 void parsePattern(
const std::tuple<Ts...> &tuple)
316 _parse_tt_tuple(tuple);
320 for (FuncDataIt it = m_mirror->m_fdata.begin(); it != m_mirror->m_fdata.end(); ++it)
324 template<
class... expr>
325 void parse(
const expr &... args)
332 void add(
const expr::gsGeometryMap<T> & sym)
334 GISMO_ASSERT(NULL!=sym.m_fs,
"Geometry map "<<&sym<<
" is invalid");
335 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
336# pragma omp critical (m_mdata_first_touch)
337 const_cast<expr::gsGeometryMap<T>&
>(sym)
338 .setData(eh.m_mdata[sym.m_fs]);
341 void add(
const expr::gsComposition<T> & sym)
346 if (
nullptr==sym.m_fs)
349 mutMap = &sym.inner().source();
352# pragma omp critical (m_fdata_first_touch)
353 const_cast<expr::gsComposition<T>&
>(sym)
356 const_cast<expr::gsComposition<T>&
>(sym)
360 gsWarn<<
"\nSomething went terribly wrong here (add gsComposition).\n";
365 auto k = std::make_pair(sym.m_fs,&
m_mdata[sym.inner().m_fs]);
367 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
371# pragma omp critical (m_cdata_first_touch)
372 const_cast<expr::gsComposition<T>&
>(sym)
373 .setData(eh.m_cdata[
give(k) ]);
375 const_cast<expr::gsComposition<T>&
>(sym)
376 .setData(eh.m_cdata[
give(k) ]);
380 void add(
const expr::symbol_expr<E> & sym)
385 gsExprHelper & eh = (sym.isAcross() ? iface() : *this);
402# pragma omp critical (m_fdata_first_touch)
403 const_cast<expr::symbol_expr<E>&
>(sym)
404 .setData( eh.m_fdata[sym.m_fs] );
412# pragma omp critical (m_fdata_first_touch)
413 const_cast<expr::symbol_expr<E>&
>(sym)
416 const_cast<expr::symbol_expr<E>&
>(sym)
420 gsWarn<<
"\nSomething went wrong here (add symbol_expr).\n";
424 void precompute(
const index_t patchIndex = 0,
430 it->second.mine().points.swap(m_points.mine());
431 it->second.mine().side = bs;
432 it->second.mine().patchId = patchIndex;
433 it->first->function(patchIndex).computeMap(it->second.mine());
434 it->second.mine().points.swap(m_points.mine());
439 it->second.mine().patchId = patchIndex;
440 it->first->piece(patchIndex)
441 .compute(m_points, it->second.mine());
446 it->first.first->piece(patchIndex)
447 .compute(it->first.second->mine().values[0], it->second.mine());
448 it->second.mine().patchId = patchIndex;
452 if (
nullptr!=mutSrc && 0!=mutData.mine().flags)
454 mutSrc->
piece(patchIndex)
456 : m_points, mutData.mine() );
460 void precompute(
const boundaryInterface & iFace)
462 this->precompute( iFace.first ().patch, iFace.first().side() );
464 m_mirror->precompute(iFace.second().patch, iFace.second().side());