~ubuntu-branches/ubuntu/trusty/rheolef/trusty

« back to all changes in this revision

Viewing changes to nfem/plib/field_evaluate.h

  • Committer: Package Import Robot
  • Author(s): Pierre Saramito
  • Date: 2012-04-06 09:12:21 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120406091221-m58me99p1nxqui49
Tags: 6.0-1
* New upstream release 6.0 (major changes):
  - massively distributed and parallel support
  - full FEM characteristic method (Lagrange-Gakerkin method) support
  - enhanced users documentation 
  - source code supports g++-4.7 (closes: #667356)
* debian/control: dependencies for MPI distributed solvers added
* debian/rules: build commands simplified
* debian/librheolef-dev.install: man1/* to man9/* added
* debian/changelog: package description rewritted (closes: #661689)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _RHEOLEF_FIELD_EVALUATE_H
 
2
#define _RHEOLEF_FIELD_EVALUATE_H
 
3
///
 
4
/// This file is part of Rheolef.
 
5
///
 
6
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
 
7
///
 
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.
 
12
///
 
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.
 
17
///
 
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
 
21
/// 
 
22
/// =========================================================================
 
23
// 
 
24
// evaluate a field on a predefined point set: hat_x[q], q=0..nq
 
25
// See also piola_transformation.h
 
26
//
 
27
#include "rheolef/field.h"
 
28
#include "rheolef/basis_on_lattice.h"
 
29
namespace rheolef { 
 
30
 
 
31
template<class T, class M, class BasisOnPointset>
 
32
T
 
33
field_evaluate (
 
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,
 
38
  size_t                        q)
 
39
{
 
40
  typedef typename field_basic<T,M>::size_type size_type;
 
41
   T value = 0;
 
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);
 
46
          iter != last;
 
47
          iter++, loc_idof++) {
 
48
     const T& cdof = *iter;
 
49
     const T& udof = uh.dis_dof (dis_idof[loc_idof]);
 
50
     value += cdof*udof;
 
51
   }
 
52
   return value;
 
53
}
 
54
template<class T, class M, class BasisOnPointset>
 
55
point_basic<T>
 
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,
 
61
  size_t                        q)
 
62
{
 
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);
 
75
          iter != last;
 
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;
 
85
     }
 
86
   }
 
87
   return value;
 
88
}
 
89
 
 
90
}// namespace rheolef
 
91
#endif // _RHEOLEF_FIELD_EVALUATE_H