1
#ifndef _RHEOLEF_FIELD_EVALUATE_H
2
#define _RHEOLEF_FIELD_EVALUATE_H
4
/// This file is part of Rheolef.
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
8
/// Rheolef is free software; you can redistribute it and/or modify
9
/// it under the terms of the GNU General Public License as published by
10
/// the Free Software Foundation; either version 2 of the License, or
11
/// (at your option) any later version.
13
/// Rheolef is distributed in the hope that it will be useful,
14
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
15
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
/// GNU General Public License for more details.
18
/// You should have received a copy of the GNU General Public License
19
/// along with Rheolef; if not, write to the Free Software
20
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
/// =========================================================================
24
// evaluate a field on a predefined point set: hat_x[q], q=0..nq
25
// See also piola_transformation.h
27
#include "rheolef/field.h"
28
#include "rheolef/basis_on_lattice.h"
31
template<class T, class M, class BasisOnPointset>
34
const field_basic<T,M>& uh,
35
const BasisOnPointset& basis_on_pointset,
36
reference_element hat_K,
37
const std::vector<size_t>& dis_idof,
40
typedef typename field_basic<T,M>::size_type size_type;
42
size_type loc_idof = 0;
43
for (typename BasisOnPointset::const_iterator
44
iter = basis_on_pointset.begin(hat_K, q),
45
last = basis_on_pointset.end (hat_K, q);
48
const T& cdof = *iter;
49
const T& udof = uh.dis_dof (dis_idof[loc_idof]);
54
template<class T, class M, class BasisOnPointset>
56
vector_field_evaluate (
57
const field_basic<T,M>& uh,
58
const BasisOnPointset& basis_on_pointset,
59
reference_element hat_K,
60
const std::vector<size_t>& dis_idof_tab,
63
typedef typename field_basic<T,M>::size_type size_type;
64
size_type dis_ndof = uh.dis_ndof();
65
size_type loc_ndof = dis_idof_tab.size();
66
size_type loc_comp_ndof = std::distance (
67
basis_on_pointset.begin(hat_K, q),
68
basis_on_pointset.end (hat_K, q));
69
size_type loc_comp_idof = 0;
70
size_type n_comp = uh.get_geo().dimension();
71
point_basic<T> value (0,0,0);
72
for (typename BasisOnPointset::const_iterator
73
iter = basis_on_pointset.begin(hat_K, q),
74
last = basis_on_pointset.end (hat_K, q);
76
iter++, loc_comp_idof++) {
77
const T& cdof = *iter;
78
for (size_type i_comp = 0; i_comp < n_comp; i_comp++) {
79
size_type loc_idof = loc_comp_idof + i_comp*loc_comp_ndof;
80
assert_macro (loc_idof < loc_ndof, "invalid local index "<<loc_idof<<" out of range [0:"<<loc_ndof<<"[");
81
size_type dis_idof = dis_idof_tab[loc_idof];
82
assert_macro (dis_idof < dis_ndof, "invalid distr index");
83
const T& udof = uh.dis_dof (dis_idof);
84
value[i_comp] += cdof*udof;
91
#endif // _RHEOLEF_FIELD_EVALUATE_H