8 #ifndef cf3_solver_actions_Proto_BlockAccumulator_hpp
9 #define cf3_solver_actions_Proto_BlockAccumulator_hpp
11 #include <boost/mpl/assert.hpp>
12 #include <boost/proto/core.hpp>
13 #include <boost/proto/traits.hpp>
77 template<
typename TagT>
79 boost::proto::terminal< LSSWrapperImpl<TagT> >
84 template<
typename SystemTagT>
87 template<
typename Tag,
int Dummy = 0>
struct case_ : boost::proto::not_<boost::proto::_> {};
89 template<
int Dummy>
struct case_<
boost::proto::tag::assign, Dummy> : boost::proto::assign<BlockLhsGrammar<SystemTagT> , boost::proto::_ > {};
90 template<
int Dummy>
struct case_<
boost::proto::tag::plus_assign, Dummy> : boost::proto::plus_assign<BlockLhsGrammar<SystemTagT> , boost::proto::_ > {};
91 template<
int Dummy>
struct case_<
boost::proto::tag::minus_assign, Dummy> : boost::proto::minus_assign<BlockLhsGrammar<SystemTagT> , boost::proto::_ > {};
119 template<
typename TagT,
typename TargetT>
122 BOOST_MPL_ASSERT_MSG(
124 , UNSUPPORTED_ASSIGNMENT_OPERATION
130 template<
typename SystemTagT,
typename OpTagT>
133 template<
typename OpTagT>
136 template<
typename LSST,
typename RhsT,
typename DataT>
140 static const Uint mat_size = DataT::EMatrixSizeT::value;
141 detail::assert_nb_nodes<DataT::nb_lss_nodes>();
143 static const Uint nb_dofs = mat_size / nb_nodes;
145 lss.convert_to_lss(data);
147 for(
Uint row = 0; row != mat_size; ++row)
150 const Uint block_row = (row % nb_nodes)*nb_dofs + row / nb_nodes;
151 for(
Uint col = 0; col != mat_size; ++col)
153 const Uint block_col = (col % nb_nodes)*nb_dofs + col / nb_nodes;
154 block_accumulator.
mat(block_row, block_col) = rhs(row, col);
161 template<
typename OpTagT>
164 template<
typename LSST,
typename RhsT,
typename DataT>
168 static const Uint mat_size = DataT::EMatrixSizeT::value;
169 detail::assert_nb_nodes<DataT::nb_lss_nodes>();
171 static const Uint nb_dofs = mat_size / nb_nodes;
173 lss.convert_to_lss(data);
175 for(
Uint i = 0; i != mat_size; ++i)
178 const Uint block_idx = (i % nb_nodes)*nb_dofs + i / nb_nodes;
179 block_accumulator.
rhs[block_idx] = rhs[i];
188 boost::proto::transform< BlockAccumulator >
190 template<
typename ExprT,
typename State,
typename DataT>
191 struct impl : boost::proto::transform_impl<ExprT, State, DataT>
197 typedef typename boost::proto::tag_of<ExprT>::type
OpT;
200 typedef typename boost::remove_reference
202 typename boost::proto::result_of::value
204 typename boost::proto::result_of::left<ExprT>::type
209 typename impl::expr_param expr
210 ,
typename impl::state_param state
211 ,
typename impl::data_param data
220 boost::proto::transform< RHSAccumulator >
222 template<
typename ExprT,
typename State,
typename DataT>
223 struct impl : boost::proto::transform_impl<ExprT, State, DataT>
228 template<
typename LSST,
typename RhsT>
233 typedef typename boost::remove_reference<DataT>::type DataUnrefT;
234 static const Uint mat_size = DataUnrefT::EMatrixSizeT::value;
235 typedef typename DataUnrefT::SupportT SupportT;
236 detail::assert_nb_nodes<DataUnrefT::nb_lss_nodes>();
238 static const Uint nb_dofs = mat_size / nb_nodes;
240 lss_term.convert_to_lss(data);
242 for(
Uint i = 0; i != var_offset; ++i)
244 const Uint block_idx = (i % nb_nodes)*nb_dofs + i / nb_nodes;
245 block_accumulator.
rhs[block_idx] = 0.;
247 const Uint var_end = var_offset + rhs.size();
248 for(
Uint i = var_offset; i != var_end; ++i)
250 const Uint block_idx = (i % nb_nodes)*nb_dofs + i / nb_nodes;
251 block_accumulator.
rhs[block_idx] = rhs[i];
253 for(
Uint i = var_end; i != mat_size; ++i)
255 const Uint block_idx = (i % nb_nodes)*nb_dofs + i / nb_nodes;
256 block_accumulator.
rhs[block_idx] = 0.;
262 typename impl::expr_param expr
263 ,
typename impl::state_param state
264 ,
typename impl::data_param data
273 template<
typename GrammarT>
279 boost::proto::or_< boost::proto::switch_< MatrixAssignOpsCases<SystemMatrixTag> >, boost::proto::switch_< MatrixAssignOpsCases<SystemRHSTag> > >,
280 BlockAccumulator( boost::proto::_expr, GrammarT(boost::proto::_right) )
284 boost::proto::plus_assign< boost::proto::function< BlockLhsGrammar<SystemRHSTag>, FieldTypes >, boost::proto::_ >,
285 RHSAccumulator( boost::proto::_expr, GrammarT(boost::proto::_right) )
296 #endif // cf3_solver_actions_Proto_BlockAccumulator_hpp
void operator()(LSST &lss, const RhsT &rhs, const DataT &data) const
virtual void add_rhs_values(const BlockAccumulator &values)=0
Add a list of values to rhs.
result_type operator()(typename impl::expr_param expr, typename impl::state_param state, typename impl::data_param data) const
void assert_nb_nodes< 0 >()
virtual void set_rhs_values(const BlockAccumulator &values)=0
Set a list of values to rhs.
external boost library namespace
void result_type
Contrary to general C++ assignment, assigning to a LSS doesn't return anything.
This header collects all the headers needed for the linear system solver, also including configure-ti...
void operator()(LSST &lss, const RhsT &rhs, const DataT &data) const
void do_assign_op(TagT, Real &lhs, TargetT &lss_matrix, const math::LSS::BlockAccumulator &block_accumulator)
Translate tag to operator.
virtual void set_values(const BlockAccumulator &values)=0
Set a list of values.
Eigen::Matrix< Real, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor > mat
virtual void add_values(const BlockAccumulator &values)=0
boost::remove_reference< typename boost::proto::result_of::value< typename boost::proto::result_of::left< ExprT >::type >::type >::type::tag_type SystemTagT
Tag indicating if we are modifying the RHS or the system matrix (stored in child 0 of the LHS of the ...
LSSWrapper< SystemRHSTag > SystemRHS
Represents an RHS.
Primitive transform to handle assignment to an LSS matrix.
void do_assign_op_matrix(boost::proto::tag::assign, math::LSS::Matrix &lss_matrix, const math::LSS::BlockAccumulator &block_accumulator)
Translate tag to operator.
Helper to get the number of LSS nodes, avoiding static divide-by-zero.
Grammar matching the LHS of an assignment op.
Grammar matching block accumulation expressions.
Allowed block assignment operations.
Top-level namespace for coolfluid.
LSSWrapper< SystemMatrixTag > SystemMatrix
Represents a system matrix.
Handle< LSS::Vector > rhs()
Accessor to right hand side.
void do_assign_op_rhs(boost::proto::tag::assign, math::LSS::Vector &lss_rhs, const math::LSS::BlockAccumulator &block_accumulator)
Translate tag to operator.
void result_type
Contrary to general C++ assignment, assigning to a LSS doesn't return anything.
Helper struct for assignment to a matrix or RHS.
boost::proto::tag_of< ExprT >::type OpT
Tag type represents the actual operation type.
unsigned int Uint
typedef for unsigned int
void assign_single_variable(LSST &lss_term, const RhsT &rhs, typename impl::data_param data, const Uint var_offset) const
result_type operator()(typename impl::expr_param expr, typename impl::state_param state, typename impl::data_param data) const
RealVector rhs
accessor to blockaccumulator's right hand side vector