29 #ifndef __LinearFormContext_H
30 #define __LinearFormContext_H 1
42 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
43 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
44 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::Context( form_type& __form,
45 map_test_geometric_mapping_context_type
const& _gmcTest,
46 map_trial_geometric_mapping_context_type
const & _gmcTrial,
47 map_geometric_mapping_expr_context_type
const& _gmcExpr,
53 M_test_dof( __form.functionSpace()->dof().get() ),
54 M_lb( __form.blockList() ),
56 M_test_pc( new test_precompute_type( M_form.testSpace()->fe(), fusion::at_key<gmc<0> >( _gmcTest )->pc()->nodes() ) ),
57 M_test_pc_face( precomputeTestBasisAtPoints( im ) ),
60 M_gmc_left( fusion::at_key<gmc<0> >( _gmcTest ) ),
61 M_left_map( fusion::make_map<gmc<0> >( M_gmc_left ) ),
62 M_test_fec( fusion::transform( M_gmc,vf::detail::FEContextInit<0,form_context_type>( __form.functionSpace()->fe(), *this ) ) ),
63 M_test_fec0( fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) ) ),
66 M_eval0_expr( new eval0_expr_type( expr, _gmcExpr, M_test_fec0 ) ),
70 M_eval0_expr->init( im );
73 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
74 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
75 template<
typename IM2>
76 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::Context( form_type& __form,
77 map_test_geometric_mapping_context_type
const& _gmcTest,
78 map_trial_geometric_mapping_context_type
const & _gmcTrial,
79 map_geometric_mapping_expr_context_type
const& _gmcExpr,
86 M_test_dof( __form.functionSpace()->dof().get() ),
87 M_lb( __form.blockList() ),
89 M_test_pc( new test_precompute_type( M_form.testSpace()->fe(), im2.
points() ) ),
90 M_test_pc_face( precomputeTestBasisAtPoints( im2 ) ),
93 M_gmc_left( fusion::at_key<gmc<0> >( _gmcTest ) ),
94 M_left_map( fusion::make_map<gmc<0> >( M_gmc_left ) ),
95 M_test_fec( fusion::transform( M_gmc,vf::detail::FEContextInit<0,form_context_type>( __form.functionSpace()->fe(), *this ) ) ),
96 M_test_fec0( fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) ) ),
99 M_eval0_expr( new eval0_expr_type( expr, _gmcExpr, M_test_fec0 ) ),
103 M_eval0_expr->init( im2 );
105 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
106 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
107 template<
typename IM2>
108 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::Context( form_type& __form,
109 map_test_geometric_mapping_context_type
const& _gmcTest,
110 map_trial_geometric_mapping_context_type
const & _gmcTrial,
111 map_geometric_mapping_expr_context_type
const& _gmcExpr,
119 M_test_dof( __form.functionSpace()->dof().get() ),
120 M_lb( __form.blockList() ),
122 M_test_pc( new test_precompute_type( M_form.testSpace()->fe(), im2.
points() ) ),
123 M_test_pc_face( precomputeTestBasisAtPoints( im2 ) ),
126 M_gmc_left( fusion::at_key<gmc<0> >( _gmcTest ) ),
127 M_gmc_right( fusion::at_key<gmc1 >( _gmcTest ) ),
128 M_left_map( fusion::make_map<gmc<0> >( M_gmc_left ) ),
129 M_right_map( fusion::make_map<gmc<0> >( M_gmc_right ) ),
130 M_test_fec( fusion::transform( M_gmc,vf::detail::FEContextInit<0,form_context_type>( __form.functionSpace()->fe(), *this ) ) ),
131 M_test_fec0( fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) ) ),
132 M_test_fec1( fusion::make_pair<gmc1 >( fusion::at_key<gmc1 >( M_test_fec ) ) ),
135 M_eval0_expr( new eval0_expr_type( expr, _gmcExpr, M_test_fec0 ) ),
136 M_eval1_expr( new eval1_expr_type( expr, _gmcExpr, M_test_fec1 ) ),
140 M_eval0_expr->init( im2 );
141 M_eval1_expr->init( im2 );
143 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
144 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
146 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::update( map_test_geometric_mapping_context_type
const& _gmcTest,
147 map_trial_geometric_mapping_context_type
const & _gmcTrial,
148 map_geometric_mapping_expr_context_type
const& _gmcExpr )
151 M_gmc_left = fusion::at_key<gmc<0> >( _gmcTest );
152 M_left_map = fusion::make_map<gmc<0> >( M_gmc_left );
153 fusion::for_each( M_test_fec,vf::detail::FEContextUpdate<0,form_context_type>( _gmcTest, *
this ) );
154 M_test_fec0 = fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) );
155 M_eval0_expr->update( _gmcExpr, M_test_fec0 );
157 M_integrator.update( *fusion::at_key<gmc<0> >( _gmcTest ) );
159 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
160 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
162 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::updateInCaseOfInterpolate( map_test_geometric_mapping_context_type
const& _gmcTest,
163 map_trial_geometric_mapping_context_type
const & _gmcTrial,
164 map_geometric_mapping_expr_context_type
const& _gmcExpr,
165 std::vector<boost::tuple<size_type,size_type> >
const& indexLocalToQuad )
168 M_gmc_left = fusion::at_key<gmc<0> >( _gmcTest );
169 M_left_map = fusion::make_map<gmc<0> >( M_gmc_left );
170 precomputeBasisAtPoints( fusion::at_key<gmc<0> >( _gmcTest )->xRefs() );
171 fusion::for_each( M_test_fec,vf::detail::FEContextUpdate<0,form_context_type>( _gmcTest, *
this ) );
172 M_test_fec0 = fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) );
173 M_eval0_expr->update( _gmcExpr, M_test_fec0 );
175 M_integrator.update( *fusion::at_key<gmc<0> >( _gmcExpr ),indexLocalToQuad );
178 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
179 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
181 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::update( map_test_geometric_mapping_context_type
const& _gmcTest,
182 map_trial_geometric_mapping_context_type
const & _gmcTrial,
183 map_geometric_mapping_expr_context_type
const& _gmcExpr,
192 M_gmc_left = fusion::at_key<gmc<0> >( _gmcTest );
193 M_gmc_right = fusion::at_key<gmc1 >( _gmcTest );
194 M_left_map = fusion::make_map<gmc<0> >( M_gmc_left );
195 M_right_map = fusion::make_map<gmc<0> >( M_gmc_right );
197 fusion::for_each( M_test_fec,vf::detail::FEContextUpdate<0,form_context_type>( _gmcTest, *
this ) );
198 M_test_fec0 = fusion::make_map<gmc<0> >( fusion::at_key<gmc<0> >( M_test_fec ) );
199 M_test_fec1 = fusion::make_map<gmc1 >( fusion::at_key<gmc1 >( M_test_fec ) );
200 M_eval0_expr->update( _gmcExpr, M_test_fec0 );
201 M_eval1_expr->update( _gmcExpr, M_test_fec1 );
203 M_integrator.update( *fusion::at_key<gmc<0> >( _gmcTest ) );
205 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
206 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
208 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::update( map_test_geometric_mapping_context_type
const& _gmcTest,
209 map_trial_geometric_mapping_context_type
const & _gmcTrial,
210 map_geometric_mapping_expr_context_type
const& _gmcExpr,
214 this->update( _gmcTest, _gmcTrial, _gmcExpr );
216 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
217 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
219 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::update( map_test_geometric_mapping_context_type
const& _gmcTest,
220 map_trial_geometric_mapping_context_type
const & _gmcTrial,
221 map_geometric_mapping_expr_context_type
const& _gmcExpr,
222 IM
const& im, mpl::int_<2> )
225 this->update( _gmcTest, _gmcTrial, _gmcExpr, mpl::int_<2>() );
229 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
230 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
234 typedef typename eval0_expr_type::shape shape;
235 BOOST_MPL_ASSERT_MSG( ( shape::M == 1 && shape::N == 1 ),
236 INVALID_TENSOR_SHAPE_SHOULD_BE_RANK_0,
237 ( mpl::int_<shape::M>, mpl::int_<shape::N> ) );
239 for ( uint16_type i = 0; i < test_dof_type::nDofPerElement; ++i )
241 M_rep( i ) = M_integrator( *M_eval0_expr, i, 0, 0 );
244 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
245 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
249 typedef mpl::int_<fusion::result_of::template size<map_test_geometric_mapping_context_type>::type::value> map_size;
250 BOOST_MPL_ASSERT_MSG( map_size::value == 2, INVALID_GEOMAP, ( map_size,map_test_geometric_mapping_context_type ) );
252 typedef typename eval0_expr_type::shape shape;
253 BOOST_MPL_ASSERT_MSG( ( shape::M == 1 && shape::N == 1 ),
254 INVALID_TENSOR_SHAPE_SHOULD_BE_RANK_0,
255 ( mpl::int_<shape::M>, mpl::int_<shape::N> ) );
257 for ( uint16_type i = 0; i < test_dof_type::nDofPerElement; ++i )
261 M_rep_2( ii ) = M_integrator( *M_eval0_expr, i, 0, 0 );
263 ii = i + test_dof_type::nDofPerElement;
265 M_rep_2( ii ) = M_integrator( *M_eval1_expr, i, 0, 0 );
268 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
269 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
271 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::integrateInCaseOfInterpolate( mpl::int_<1>,
272 std::vector<boost::tuple<size_type,size_type> >
const& indexLocalToQuad,
273 bool isFirstExperience )
275 typedef typename eval0_expr_type::shape shape;
276 BOOST_MPL_ASSERT_MSG( ( shape::M == 1 && shape::N == 1 ),
277 INVALID_TENSOR_SHAPE_SHOULD_BE_RANK_0,
278 ( mpl::int_<shape::M>, mpl::int_<shape::N> ) );
280 if ( isFirstExperience )
281 for ( uint16_type i = 0; i < test_dof_type::nDofPerElement; ++i )
283 M_rep( i ) = M_integrator( *M_eval0_expr, i, 0, 0, indexLocalToQuad );
287 for ( uint16_type i = 0; i < test_dof_type::nDofPerElement; ++i )
289 M_rep( i ) += M_integrator( *M_eval0_expr, i, 0, 0, indexLocalToQuad );
294 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
295 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
297 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::assemble( size_type elt_0 )
299 size_type row_start = M_lb.front().globalRowStart();
300 M_local_rows = M_test_dof->localToGlobalIndices( elt_0 ).array() + row_start;
302 if ( test_dof_type::is_modal )
304 M_local_rowsigns = M_test_dof->localToGlobalSigns( elt_0 );
305 M_rep.array() *= M_local_rowsigns.array().template cast<value_type>();
308 M_form.addVector( M_local_rows.data(), M_local_rows.size(),
311 template<
typename SpaceType,
typename VectorType,
typename ElemContType>
312 template<
typename GeomapContext,
typename ExprT,
typename IM,
typename GeomapExprContext>
314 LinearForm<SpaceType, VectorType, ElemContType>::Context<GeomapContext,ExprT,IM,GeomapExprContext>::assemble( size_type elt_0, size_type elt_1 )
316 size_type row_start = M_lb.front().globalRowStart();
317 auto local_rows_0 = M_test_dof->localToGlobalIndices( elt_0 ).array() + row_start;
318 auto local_rows_1 = M_test_dof->localToGlobalIndices( elt_1 ).array() + row_start;
319 M_local_rows_2.template head<test_dof_type::nDofPerElement>() = local_rows_0;
320 M_local_rows_2.template tail<test_dof_type::nDofPerElement>() = local_rows_1;
322 if ( test_dof_type::is_modal )
324 auto local_rowsigns_0 = M_test_dof->localToGlobalSigns( elt_0 );
325 auto local_rowsigns_1 = M_test_dof->localToGlobalSigns( elt_1 );
326 M_local_rowsigns_2.template head<test_dof_type::nDofPerElement>() = local_rowsigns_0;
327 M_local_rowsigns_2.template tail<test_dof_type::nDofPerElement>() = local_rowsigns_1;
329 M_rep_2.array() *= M_local_rowsigns_2.array().template cast<value_type>();
332 M_form.addVector( M_local_rows_2.data(), M_local_rows_2.size(),