20template <
typename TDomain,
typename TAlgebra>
21template <
typename TElem>
29 typedef typename gf_type::template traits<TElem>::const_iterator iterator;
33 const size_t n_co = ref_elem_type::numCorners;
34 const size_t n_scv = FVGeom_type::numSCV;
49 iterator end_e_iter = gf.template end<TElem>(si);
50 for (iterator e_iter = gf.template begin<TElem>(si); e_iter != end_e_iter; ++e_iter)
55 for (
size_t i = 0; i < n_co; i++)
56 e_corners[i] = aaPos [e_vrt[i] = e->vertex (i)];
61 geo.update (e, e_corners, dom.subset_handler().get ());
63 UG_CATCH_THROW(
"SmartRescaler: Cannot update the Finite Volume Geometry for an element.");
71 number factor_values [n_scv];
72 (* m_spFactor) (factor_values, e_corners, 0, si, e,
73 geo.scv_global_ips (), geo.scv_local_ips (), n_scv, &loc_vec);
76 for (
size_t i = 0; i < n_scv; i++)
78 const typename FVGeom_type::SCV & scv = geo.scv (i);
79 aa_factor [e_vrt [scv.node_id()]] += factor_values[i] * scv.volume ();
85template <
typename TDomain,
typename TAlgebra>
95 if (m_spFactor.invalid ())
96 UG_THROW (
"SmartRescaler: No factor specified!");
101 SetAttachmentValues (aa_factor, g.template begin<Vertex> (), g.template end<Vertex> (), 0);
106 for (
int si = 0; si < ssh.num_subsets (); si++)
110 AttachmentAllReduce<Vertex> (g, a_factor,
PCL_RO_SUM);
115template <
typename TDomain,
typename TAlgebra>
122 typedef typename gf_type::template traits<Vertex>::const_iterator iterator;
125 size_t fct = gf->fct_id_by_name (cmp);
131 g.attach_to_vertices (a_factor);
134 get_scaling_factors (*gf, a_factor);
137 iterator end_v_iter = gf->template end<Vertex> ();
138 for (iterator v_iter = gf->template begin<Vertex> (); v_iter != end_v_iter; ++v_iter)
141 number factor = aa_factor [vrt];
143 std::vector<DoFIndex> ind (1);
144 gf->inner_dof_indices (vrt, fct, ind);
145 DoFRef(*gf, ind[0]) *= factor;
148 g.detach_from_vertices (a_factor);
152template <
typename TDomain,
typename TAlgebra>
159 typedef typename gf_type::template traits<Vertex>::const_iterator iterator;
162 size_t fct = gf->fct_id_by_name (cmp);
168 g.attach_to_vertices (a_factor);
171 get_scaling_factors (*gf, a_factor);
174 iterator end_v_iter = gf->template end<Vertex> ();
175 for (iterator v_iter = gf->template begin<Vertex> (); v_iter != end_v_iter; ++v_iter)
178 number factor = aa_factor [vrt];
180 std::vector<DoFIndex> ind (1);
181 gf->inner_dof_indices (vrt, fct, ind);
182 DoFRef(*gf, ind[0]) /= factor;
185 g.detach_from_vertices (a_factor);
ConstSmartPtr< FunctionPattern > function_pattern() const
void indices(TElem *elem, LocalIndices &ind, bool bHang=false) const
SmartPtr< TDomain > domain()
void resize(const LocalIndices &ind)
void get_scaling_factors(gf_type &gf, a_factor_type &factor)
Compute (sum up) the scaling factors (over the entire grid)
Definition smile_rescale_impl.hpp:87
TDomain domain_type
Type of Domain.
Definition smile_rescale.hpp:33
void get_scaling_factors_for_(int si, gf_type &gf, aa_factor_type &factor)
Compute (sum up) the scaling factors (for one element type)
Definition smile_rescale_impl.hpp:23
void divide(SmartPtr< gf_type > gf, const char *cmps)
Divide the given components of the grid function by the factors.
Definition smile_rescale_impl.hpp:154
domain_type::position_type position_type
Type of the position coordinate vectors.
Definition smile_rescale.hpp:45
TDomain::grid_type grid_type
Type of Grid:
Definition smile_rescale.hpp:36
void multiply(SmartPtr< gf_type > gf, const char *cmps)
Multiplies the given components of the grid function by the factors.
Definition smile_rescale_impl.hpp:117
domain_type::position_accessor_type position_accessor_type
Type of the position accessor.
Definition smile_rescale.hpp:42
domain_type::subset_handler_type subset_handler_type
Type of subset handler.
Definition smile_rescale.hpp:39
void SetAttachmentValues(TAttachmentAccessor &aaVal, TIter elemsBegin, TIter elemsEnd, const TVal &val)
#define UG_CATCH_THROW(msg)
const number & DoFRef(const TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
void GetLocalVector(LocalVector &lvec, const TVector &vec)
Helper class for the computation of the factors.
Definition smile_rescale.hpp:102