This file is indexed.

/usr/include/rheolef/field_expr_v2_variational_terminal.h is in librheolef-dev 6.7-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
#ifndef _RHEOLEF_FIELD_EXPR_V2_VARIATIONAL_TERMINAL_H
#define _RHEOLEF_FIELD_EXPR_V2_VARIATIONAL_TERMINAL_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
///
/// =========================================================================
//
// terminals variational expressions are used for field assembly
// e.g. for right-hand-side of linear systems
//
// author: Pierre.Saramito@imag.fr
//
// date: 21 september 2015 
//
// Notes: use template expressions and SFINAE techniques
//
// SUMMARY:
// 1. concept
// 2. grad, grad_s, D, etc
// 3. div, div_s
// 4. curl
// 5. jump, average, inner, outer
//
#include "rheolef/field_expr_v2_nonlinear.h"
#include "rheolef/test.h" // for grad_option_type

namespace rheolef {

// -------------------------------------------------------------------
// 1. concept
// -------------------------------------------------------------------
namespace details {

// Define a trait type for detecting field expression valid arguments
template<class T>                       struct is_field_expr_v2_variational_arg                         : std::false_type {};
template<class T, class M, class VfTag> struct is_field_expr_v2_variational_arg<test_basic<T,M,VfTag> > : std::true_type {};

} // namespace details
// ---------------------------------------------------------------------------
// 2. grad, grad_s, D, etc
// ---------------------------------------------------------------------------
namespace details {

template<class Expr>
class field_expr_v2_variational_grad {
public:
// typedefs:

  typedef geo_element::size_type                        size_type;
  typedef typename Expr::memory_type                    memory_type;
  typedef typename scalar_traits<typename Expr::value_type>::type 		
	  						scalar_type;
  typedef typename space_constant::rank_up<typename Expr::value_type>::type
                                                        value_type;
  typedef typename  float_traits<scalar_type>::type 	float_type;
  typedef space_basic<scalar_type,memory_type>		space_type;
  typedef typename Expr::vf_tag_type                    vf_tag_type;
  typedef typename details::dual_vf_tag<vf_tag_type>::type
                                                        vf_dual_tag_type;
  typedef field_expr_v2_variational_grad<Expr>          self_type;
  typedef field_expr_v2_variational_grad<typename Expr::dual_self_type>  
                                                        dual_self_type;

// alocators:

  field_expr_v2_variational_grad (const Expr& expr, const grad_option_type& opt = grad_option_type())
    : _expr(expr),
      _opt(opt)
  {
    check_macro (opt.broken
              || get_vf_space().get_numbering().is_continuous()
    	      || get_vf_space().get_numbering().name() == "bubble",
      "grad(.): unexpected " << get_vf_space().get_numbering().name() 
	<< " discontinuous approximation (HINT: consider grad_h(.))");
  }
  field_expr_v2_variational_grad (const field_expr_v2_variational_grad<Expr>& x)
    : _expr(x._expr),
      _opt(x._opt)
  {}

// accessors:

  const space_type&  get_vf_space()  const { return _expr.get_vf_space(); }
  static const space_constant::valued_type valued_hint = space_constant::valued_tag_traits<value_type>::value;
  space_constant::valued_type valued_tag() const {
    space_constant::valued_type v = _expr.valued_tag();
    switch (v) {
      case space_constant::scalar: return space_constant::vector;
      case space_constant::vector: return space_constant::unsymmetric_tensor;
      case space_constant::tensor: return space_constant::tensor3;
      default:
        fatal_macro ("unexpected " << space_constant::valued_name(v) << "-valued argument for grad() operator");
        return space_constant::last_valued;
    }
  }
  size_type n_derivative() const { return _expr.n_derivative() + 1; }

// mutable modifiers:

  void initialize (const geo_basic<float_type,memory_type>& dom, const quadrature<float_type>& quad, bool ignore_sys_coord) const { 
    _expr.initialize (dom, quad, ignore_sys_coord);
  }
  void initialize (const band_basic<float_type,memory_type>& gh, const quadrature<float_type>& quad, bool ignore_sys_coord) const {  
    _expr.initialize (gh, quad, ignore_sys_coord); 
  }
  void element_initialize (const geo_element& K) const {
    _expr.element_initialize (K);
  }
  void element_initialize_on_side (const geo_element& K, const side_information_type& sid) {
    _expr.element_initialize_on_side (K, sid);
  }
  template<class ValueType>
  void basis_evaluate (const reference_element& hat_K, size_type q, std::vector<ValueType>& value) const {
    _expr.grad_basis_evaluate (hat_K, q, _opt, value);
  }
  template<class ValueType>
  void valued_check() const {
    typedef typename space_constant::rank_down<ValueType>::type A1; // may be defined when ValueType is
    _expr.template valued_check<A1>();
  }
protected:
// data:
  Expr               _expr;
  grad_option_type   _opt;
};
template<class Expr> struct is_field_expr_v2_variational_arg    <field_expr_v2_variational_grad<Expr> > : std::true_type {};

} // namespace details

// grad(v)
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
grad (const Expr& expr)
{
  return details::field_expr_v2_variational_grad <Expr> (expr);
}
// grad_s(v) 
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
grad_s (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.surfacic = true;
  return details::field_expr_v2_variational_grad <Expr> (expr, opt);
}
// grad_h(v) 
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
grad_h (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.broken = true;
  return details::field_expr_v2_variational_grad <Expr> (expr, opt);
}
// D(v) 
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
D (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.symmetrized = true;
  return details::field_expr_v2_variational_grad <Expr> (expr, opt);
}
// Ds(v) 
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
Ds (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.symmetrized = true;
  opt.surfacic    = true;
  return details::field_expr_v2_variational_grad <Expr> (expr, opt);
}
// Dh(v) 
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_grad<Expr>
>::type
Dh (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.symmetrized = true;
  opt.broken      = true;
  return details::field_expr_v2_variational_grad <Expr> (expr, opt);
}
// ---------------------------------------------------------------------------
// 3. div, div_s
// ---------------------------------------------------------------------------
namespace details {

template<class Expr>
class field_expr_v2_variational_div {
public:
// typedefs:

  typedef geo_element::size_type                        size_type;
  typedef typename Expr::memory_type                    memory_type;
  typedef typename space_constant::rank_down<typename Expr::value_type>::type
                                                        value_type;
  typedef typename scalar_traits<typename Expr::value_type>::type 		
	  						scalar_type;
  typedef typename  float_traits<scalar_type>::type 	float_type;
  typedef space_basic<scalar_type,memory_type>		space_type;
  typedef typename Expr::vf_tag_type                    vf_tag_type;
  typedef typename details::dual_vf_tag<vf_tag_type>::type
                                                        vf_dual_tag_type;
  typedef field_expr_v2_variational_div<Expr>                       self_type;
  typedef field_expr_v2_variational_div<typename Expr::dual_self_type>  
                                                        dual_self_type;

// alocators:

  field_expr_v2_variational_div (const Expr& expr, const grad_option_type& opt = grad_option_type())
    : _expr(expr),
      _opt(opt)
  {
    check_macro (opt.broken
              || get_vf_space().get_numbering().is_continuous()
    	      || get_vf_space().get_numbering().name() == "bubble",
      "div(.): unexpected " << get_vf_space().get_numbering().name() 
	<< " discontinuous approximation (HINT: consider div_h(.))");
  }

// accessors:

  const space_type&  get_vf_space()  const { return _expr.get_vf_space(); }
  static const space_constant::valued_type valued_hint = space_constant::valued_tag_traits<value_type>::value;
  space_constant::valued_type valued_tag() const {
    space_constant::valued_type v = _expr.valued_tag();
    switch (v) {
      case space_constant::vector:             return space_constant::scalar;
      case space_constant::tensor:
      case space_constant::unsymmetric_tensor: return space_constant::vector;
      default:
        fatal_macro ("unexpected " << space_constant::valued_name(v) << "-valued argument for div() operator");
        return space_constant::last_valued;
    }
  }
  size_type n_derivative() const { return _expr.n_derivative() + 1; }

// mutable modifiers:

  void initialize (const geo_basic<float_type,memory_type>& dom, const quadrature<float_type>& quad, bool ignore_sys_coord) const { 
    _expr.initialize (dom, quad, ignore_sys_coord);
  }
  void initialize (const band_basic<float_type,memory_type>& gh, const quadrature<float_type>& quad, bool ignore_sys_coord) const {  
    _expr.initialize (gh, quad, ignore_sys_coord); 
  }
  void element_initialize (const geo_element& K) const {
    _expr.element_initialize (K);
  }
  void element_initialize_on_side (const geo_element& K, const side_information_type& sid) {
    _expr.element_initialize_on_side (K, sid);
  }
  template<class ValueType>
  void basis_evaluate (const reference_element& hat_K, size_type q, std::vector<ValueType>& value) const {
    _expr.div_basis_evaluate (hat_K, q, _opt, value);
  }
  template<class ValueType>
  void valued_check() const {
    _expr.template div_valued_check<ValueType>();
  }
protected:
// data:
  Expr              _expr;
  grad_option_type  _opt;
};
template<class Expr> struct is_field_expr_v2_variational_arg    <field_expr_v2_variational_div<Expr> > : std::true_type {};

} // namespace details

// div(v)
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_div<Expr>
>::type
div (const Expr& expr)
{
  return details::field_expr_v2_variational_div <Expr> (expr);
}
// div_s(v)
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_div<Expr>
>::type
div_s (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.surfacic = true;
  return details::field_expr_v2_variational_div <Expr> (expr, opt);
}
// div_h(v)
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_div<Expr>
>::type
div_h (const Expr& expr)
{
  details::grad_option_type   opt;
  opt.broken = true;
  return details::field_expr_v2_variational_div <Expr> (expr, opt);
}
// ---------------------------------------------------------------------------
// 4. curl
// ---------------------------------------------------------------------------
namespace details {

template<class Expr>
class field_expr_v2_variational_curl {
public:
// typedefs:

  typedef geo_element::size_type                        size_type;
  typedef typename Expr::memory_type                    memory_type;
  typedef typename scalar_traits<typename Expr::value_type>::type 		
	  						scalar_type;
  // value_type = vctor  when d=2 and Expr is scalar or when d=3
  //            = scalar when d=2 and Expr is vector 
  // thus is undeterminated at compile-time
  typedef undeterminated_basic<scalar_type>		value_type;
  typedef typename  float_traits<scalar_type>::type 	float_type;
  typedef space_basic<scalar_type,memory_type>		space_type;
  typedef typename Expr::vf_tag_type                    vf_tag_type;
  typedef typename details::dual_vf_tag<vf_tag_type>::type
                                                        vf_dual_tag_type;
  typedef field_expr_v2_variational_curl<Expr>          self_type;
  typedef field_expr_v2_variational_curl<typename Expr::dual_self_type>  
                                                        dual_self_type;

// alocators:

  field_expr_v2_variational_curl (const Expr& expr, const grad_option_type& opt = grad_option_type())
    : _expr(expr),
      _opt(opt)
  {
    check_macro (opt.broken
              || get_vf_space().get_numbering().is_continuous()
    	      || get_vf_space().get_numbering().name() == "bubble",
      "curl(.): unexpected " << get_vf_space().get_numbering().name() 
	<< " discontinuous approximation (HINT: consider curl_h(.))");
  }

// accessors:

  const space_type&  get_vf_space()  const { return _expr.get_vf_space(); }
  static const space_constant::valued_type valued_hint = space_constant::valued_tag_traits<value_type>::value;
  space_constant::valued_type valued_tag() const {
    space_constant::valued_type arg_v = _expr.valued_tag();
    switch (arg_v) {
      case space_constant::scalar:    return space_constant::vector;
      case space_constant::vector: {
        size_type d = get_vf_space().get_geo().dimension();
        return (d==2) ? space_constant::scalar : space_constant::vector;
      }
      default:
        fatal_macro ("unexpected " << space_constant::valued_name(arg_v) << "-valued argument for curl() operator");
        return space_constant::last_valued;
    }
  }
  size_type n_derivative() const { return _expr.n_derivative() + 1; }

// mutable modifiers:

  void initialize (const geo_basic<float_type,memory_type>& dom, const quadrature<float_type>& quad, bool ignore_sys_coord) const { 
    _expr.initialize (dom, quad, ignore_sys_coord);
  }
  void initialize (const band_basic<float_type,memory_type>& gh, const quadrature<float_type>& quad, bool ignore_sys_coord) const {  
    _expr.initialize (gh, quad, ignore_sys_coord); 
  }
  void element_initialize (const geo_element& K) const {
    _expr.element_initialize (K);
  }
  void element_initialize_on_side (const geo_element& K, const side_information_type& sid) {
    _expr.element_initialize_on_side (K, sid);
  }
  template<class ValueType>
  void basis_evaluate (const reference_element& hat_K, size_type q, std::vector<ValueType>& value) const {
    _expr.curl_basis_evaluate (hat_K, q, _opt, value);
  }
  void _valued_check_internal(const scalar_type&) const {
    _expr.template valued_check<point_basic<scalar_type> >();
    size_type d = get_vf_space().get_geo().dimension();
    check_macro (d==2, "unexpected "<<d<<"D physical dimension for the scalar-valued curl() operator");
  }
  void _valued_check_internal(const point_basic<scalar_type>&) const {
    size_type d = get_vf_space().get_geo().dimension();
    check_macro (d==2 || d==3, "unexpected "<<d<<"D physical dimension for the vector-valued curl() operator");
    if (d == 2) {
      _expr.template valued_check<scalar_type>();
    } else {
      _expr.template valued_check<point_basic<scalar_type> >();
    }
  }
  void _valued_check_internal(const tensor_basic<scalar_type>&) const {
    fatal_macro ("unexpected tensor-valued result for the curl() operator");
  }
  template<class ValueType>
  void valued_check() const {
    _valued_check_internal(ValueType());
  }
protected:
// data:
  Expr              _expr;
  grad_option_type  _opt;
};
template<class Expr> struct is_field_expr_v2_variational_arg    <field_expr_v2_variational_curl<Expr> > : std::true_type {};

} // namespace details

// curl(v)
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_curl<Expr>
>::type
curl (const Expr& expr)
{
  return details::field_expr_v2_variational_curl <Expr> (expr);
}
// bcurl(v) = Batchelor curl
template<class Expr>
inline
typename
std::enable_if<
  details::is_field_expr_v2_variational_arg<Expr>::value
 ,details::field_expr_v2_variational_curl<Expr>
>::type
bcurl (const Expr& expr)
{
  details::grad_option_type    opt;
  opt.batchelor_curl = true;
  return details::field_expr_v2_variational_curl <Expr> (expr, opt);
}
// ---------------------------------------------------------------------------
// 5. jump, average, inner, outer
// ---------------------------------------------------------------------------
// discontinuous Galerkin operators
// in expressions templates for variationnal formulations
//
/*

SPECIFICATION: a first example

  Let v be a function defined over Omega
        and discontinuous accross internal sides (e.g. Pkd).
  Let f be a function defined on Oemga.

  We want to assembly
    l(v) = int_{internal sides} f(x) [v](x) ds
  where [v] is the jump of v accross internal sides.

  => l(v) = sum_{K is internal sides} int_K f(x) [v](x) ds

  Let K be an internal side of the mesh of Omega.

    int_K f(x) [v](x) ds
    = int_{hat_K} f(F(hat_x))
                  [v](F(hat_x))
                  det(DF(hat_x)) d hat_s

  where F is the piola transformation from the reference element hat_K to K:
    F : hat_K ---> K
	hat_x |--> x = F(hat_x)

  The fonction v is not defined on a basis over internal sides K but over
  elements L of the mesh of Omega.
  Let L0 and L1 the two elements such that K is the common side of L0 and L1
  and K is oriented from L0 to L1:
 	[v] = v0 - v1 on K, where v0=v/L0 and v1=v/L1.
 
  Let G0 the piola transformation from the reference element tilde_L to L0:
    G0 : tilde_L ---> L0
	 tilde_x |--> x = G0(tilde_x)

  Conversely, let G1 the piola transformation from the reference element tilde_L to L1.

    int_K f(x) [v](x) ds
    = int_{hat_K} f(F(hat_x))
                  (v0-v1)(F(hat_x))
                  det(DF(hat_x)) d hat_s

  The the basis fonction v0 and v1 are defined by using tilde_v, on the reference element tilde_L:
                  v0(x) = tilde_v (G0^{-1}(x))
                  v1(x) = tilde_v (G1^{-1}(x))
  and with x=F(hat_x):
                  v0(F(hat_x)) = tilde_v (G0^{-1}(F(hat_x)))
                  v1(F(hat_x)) = tilde_v (G1^{-1}(F(hat_x)))

  Thus:
    int_K f(x) [v](x) ds
    = int_{hat_K} f(F(hat_x)) 
                  (   tilde_v (G0^{-1}(F(hat_x)))
                    - tilde_v (G1^{-1}(F(hat_x))) )
                  det(DF(hat_x)) ds
  
  Observe that H0=G0^{-1}oF is linear:
     H0 : hat_K ---> tilde0_K subset tilde_L
          hat_x ---> tilde0_x = H0(hat_x)
  Conversely:
     H1 : hat_K ---> tilde1_K subset tilde_L
          hat_x ---> tilde1_x = H1(hat_x)
  Thus, K linearly transforms by H0 into a side tilde0_K of the reference element tilde_L
  and, by H1, into another side tilde1_K of tilde_L.

    int_K f(x) [v](x) ds
    = int_{hat_K} f(F(hat_x)) 
                  (   tilde_v (H0(hat_x))
                    - tilde_v (H1(hat_x)) )
                  det(DF(hat_x)) ds

  Let (hat_xq, hat_wq)_{q=0...} a quadrature formulae over hat_K.  
  The integral becomes:

    int_K f(x) [v](x) ds
    = sum_q f(F(hat_xq)) 
            (   tilde_v (H0(hat_xq))
              - tilde_v (H1(hat_xq)) )
            det(DF(hat_xq)) hat_wq

  Then, the basis functions tilde_v can be computed one time for all
  over all the sides tilde(i)_K of the reference element tilde_L, i=0..nsides(tilde_L)
  at the quadratures nodes tilde(i)_xq = Hi(hat_xq):
            tilde_v (Hi(hat_xq)),  i=0..nsides(tilde_L),  q=0..nq(hat_K)

SPECIFICATION: a second example

  We want to assembly
    l(v) = int_{internal sides} f(x) [grad(v).n](x) ds
  where [grad(v).n] is the jump of the normal derivative of v accross internal sides.

  Let K be an internal side of the mesh of Omega.

    int_K f(x) [grad(v).n](x) ds
    = int_{hat_K} f(F(hat_x))
                 [grad(v).n](F(hat_x))
                 det(DF(hat_x)) d hat_s

    =   int_{hat_K} f(F(hat_x))
                 (grad(v0).n)(F(hat_x))
                  det(DF(hat_x)) d hat_s
      - int_{hat_K} f(F(hat_x))
                 (grad(v1).n)(F(hat_x))
                 det(DF(hat_x)) d hat_s

   where v0=v/L0 and v1=v/L1 and Li are the two elements containing the side K.
   Let us fix one of the Li and omits the i subscript.
   The computation reduces to evaluate:

    int_K f(x) grad(v).n(x) ds
    = sum_q f(F(hat_xq))
                 (grad(v).n)(F(hat_xq))
                 det(DF(hat_xq)) hat_wq
 
   From the gradient transformation:

     grad(v)(F(hat_xq)) = DG^{-T}(H(hat_xq)) * tilde_grad(tilde_v)(H(hat_xq))

   where H = G^{-1}oF is linear from hat_K to tilde_K subset tilde_L.

    int_K f(x) grad(v).n(x) ds
    = sum_q f(F(hat_xq))
                 DG^{-T}(H(hat_xq))*tilde_grad(tilde_v)(H(hat_xq))
                 .n(F(hat_xq))
                 det(DF(hat_xq)) hat_wq

   We can evaluate one time for all the gradients of basis functions tilde_v
   on the quadrature nodes of each sides tilde_K of tilde_L :
                 tilde_grad(tilde_v)(H(hat_xq))
   The piola basis functions and their derivatives are also evaluated one time for all on these nodes :
     		 DG^{-T}(H(hat_xq))

   The normal vector 
                 n(xq), xq=F(hat_xq), q=...
   should be evaluated on K, not on L that has no normal vector.

IMPLEMENTATION: bassis evaluation => test.cc

  The basis_on_pointset class extends to the case of an integration over a side of

     test_rep<T,M>::initialize (const geo_basic<float_type,M>& dom, const quadrature<T>& quad, bool ignore_sys_coord) const {
       _basis_on_quad.set (quad, get_vf_space().get_numbering().get_basis());
       _piola_on_quad.set (quad, get_vf_space().get_geo().get_piola_basis());
	 => inchange'
     }
     test_rep<T,M>::element_initialize (const geo_element& L, size_type loc_isid=-1) const {
        if (loc_isid != -1) {
	  basis_on_quad.restrict_on_side (tilde_L, loc_isid);
	  piola_on_quad.restrict_on_side (tilde_L, loc_isid);
        }
     }
     test_rep<T,M>::basis_evaluate (...) {
        // Then, a subsequent call to 
	basis_on_quad.evaluate (tilde_L, q);
        // will restrict to the loc_isid part.
     }

IMPLEMENTATION: normal vector => field_vf_expr.h & field_nl_expr_terminal.h
  on propage des vf_expr aux nl_expr le fait qu'on travaille sur une face :
    class nl_helper {
      void element_initialize (const This& obj, const geo_element& L, size_type loc_isid=-1) const {
        obj._nl_expr.evaluate (L, isid, obj._vector_nl_value_quad);
      }
    };
  pour la classe normal :
    field_expr_terminal_normal::evaluate (L, loc_isid, value) {
      if (loc_isid != -1) K=side(L,loc_isid); else K=L;
      puis inchange. 
    }
  pour la classe terminal_field: si on evalue un field uh qui est discontinu :
  on sait sur quelle face il se restreint :
    field_expr_terminal_field::evaluate (L, loc_isid, value) {
      if (loc_isid != -1) {
        _basis_on_quad.restrict_on_side (tilde_L, loc_isid);
      }
      for (q..) {
        general_field_evaluate (_uh, _basis_on_quad, tilde_L, _dis_idof, q, value[q]);
      }
    }
IMPLEMENTATION: bassis evaluation => basis_on_pointset.cc
  c'est la que se fait le coeur du travail :
    basis_on_pointset::restrict_on_side (tilde_L, loc_isid)
    => initialise

  a l'initialisation, on evalue une fois pour tte
  sur toutes les faces en transformant la quadrature via 
	tilde(i)_xq = Hi(hat_xq)
	tilde(i)_wq = ci*hat_wq
  avec
	ci = meas(tilde(i)_K)/meas(hat_K)

  puis :
    basis_on_pointset::evaluate (tilde_L, q)
  on se baladera dans la tranche [loc_isid*nq, (loc_isid+1)*nq[
  du coup, on positionne un pointeur de debut q_start  = loc_isid*nq
                               et une taille  q_size = nq
  si les faces sont differentes (tri,qua) dans un prisme, il faudra
  un tableau de pointeurs pour gerer cela :
		q_start [loc_nsid+1]
		q_size  [loc_isid] = q_start[loc_isid+1] - q_start[loc_isid] 

    basis_on_pointset::begin() { return _val[_curr_K_variant][_curr_q].begin() + q_start[_curr_K_variant][loc_isid]; }
    basis_on_pointset::begin() { return _val[_curr_K_variant][_curr_q].begin() + q_start[_curr_K_variant][loc_isid+1]; }

  et le tour est joue' !

PLAN DE DEVELOPPEMENT: 
 1) DG transport
    basis_on_pointset.cc 
    test.cc
    essais :
     lh = integrate(jump(v)*f);
     convect_dg2.cc
 2) DG diffusion : avec normale et gradient
    field_vf_expr.h 
    	class nl_helper 
    field_nl_expr_terminal.h
    	field_expr_terminal_normal::evaluate (L, loc_isid, value) 
    	field_expr_terminal_field ::evaluate (L, loc_isid, value)

*/ 

namespace details {
// ---------------------------------------------------------------------------
// 5.1 class dg
// ---------------------------------------------------------------------------
template<class Expr>
class field_expr_v2_variational_dg {
public:
// typedefs:

  typedef typename Expr::size_type            size_type;
  typedef typename Expr::memory_type          memory_type;
  typedef typename Expr::value_type           value_type;
  typedef typename Expr::scalar_type          scalar_type;
  typedef typename Expr::float_type           float_type;
  typedef typename Expr::space_type           space_type;
  typedef typename Expr::vf_tag_type          vf_tag_type;
  typedef typename details::dual_vf_tag<vf_tag_type>::type
                                              vf_dual_tag_type;
  typedef field_expr_v2_variational_dg<Expr>  self_type;
  typedef field_expr_v2_variational_dg<typename Expr::dual_self_type>  
                                              dual_self_type;

// alocators:

  field_expr_v2_variational_dg (const Expr& expr, const float_type& c0, const float_type& c1) 
    : _expr0(expr), 
      _expr1(expr),
      _c0(c0), 
      _c1(c1),
      _tilde0_L0(),
      _tilde1_L1(),
      _bgd_omega()
   {
   }

// accessors:

  const space_type& get_vf_space() const { return _expr0.get_vf_space(); }
  static const space_constant::valued_type valued_hint = Expr::valued_hint;
  space_constant::valued_type valued_tag() const { return _expr0.valued_tag(); } 
  size_type n_derivative() const { return _expr0.n_derivative(); }

// mutable modifiers:

  void initialize (const geo_basic<float_type,memory_type>& dom, const quadrature<float_type>& quad, bool ignore_sys_coord) const {
    _expr0.initialize (dom, quad, ignore_sys_coord);
    _expr1.initialize (dom, quad, ignore_sys_coord);
    _bgd_omega = get_vf_space().get_geo().get_background_geo();
    check_macro (_bgd_omega == dom.get_background_geo(),
        "discontinuous Galerkin: incompatible integration domain "<<dom.name() << " and test function based domain "
        << get_vf_space().get_geo().name());
  }
  void initialize (const band_basic<float_type,memory_type>& gh, const quadrature<float_type>& quad, bool ignore_sys_coord) const {  
    _expr0.initialize (gh, quad, ignore_sys_coord);
    _expr1.initialize (gh, quad, ignore_sys_coord);
    fatal_macro ("unsupported discontinuous Galerkin on a band"); // how to define background mesh _bgd_omega ?
  }
  void element_initialize (const geo_element& K) const;

  template<class ValueType>
  void basis_evaluate (const reference_element& hat_K, size_type q, std::vector<ValueType>& value) const;

  template<class ValueType>
  void valued_check() const {
    check_macro (get_vf_space().get_numbering().is_discontinuous(),
	"unexpected continuous test-function in space " << get_vf_space().stamp()
	<< " for jump or average operator (HINT: omit jump or average)");
    _expr0.template valued_check<ValueType>();
  }

protected:
// data:
  mutable Expr                              _expr0;
  mutable Expr                              _expr1;
  scalar_type                               _c0;
  scalar_type                               _c1;
  mutable reference_element                 _tilde0_L0;
  mutable reference_element                 _tilde1_L1;
  mutable geo_basic<float_type,memory_type> _bgd_omega;
};
template<class Expr> struct is_field_expr_v2_variational_arg    <field_expr_v2_variational_dg<Expr> > : std::true_type {};
// ---------------------------------------------------------------------------
// 5.2. basis_evaluate
// ---------------------------------------------------------------------------
template<class Expr>
template<class ValueType>
void
field_expr_v2_variational_dg<Expr>::basis_evaluate (
  const reference_element& hat_K, 
  size_type                q, 
  std::vector<ValueType>&  value) const
{
  size_type loc_ndof0 = _expr0.get_vf_space().get_constitution().loc_ndof (_tilde0_L0),
            loc_ndof1 = 0;
  if (_tilde1_L1.variant() != reference_element::max_variant) {
    loc_ndof1 = _expr1.get_vf_space().get_constitution().loc_ndof (_tilde1_L1);
  }
  check_macro (loc_ndof0+loc_ndof1 == value.size(),
	"unexpected value.size="<<value.size()<<": expect size="<<loc_ndof0+loc_ndof1
	<< " for ValueType="<<typename_macro(ValueType)<<" and valued=" << _expr1.get_vf_space().valued());
  std::vector<ValueType> value0 (loc_ndof0), 
                         value1 (loc_ndof1);
  _expr0.basis_evaluate (_tilde0_L0, q, value0);
  // average (i.e. _c0==0.5): fix it on the boundary where c0=1 : average(v)=v on the boundary
  Float c0 = (_tilde1_L1.variant() != reference_element::max_variant || _c0 != 0.5) ? _c0 : 1;
  for (size_type loc_idof = 0; loc_idof < loc_ndof0; ++loc_idof) {
    value[loc_idof] = c0*value0 [loc_idof];
  }
  if (_tilde1_L1.variant() != reference_element::max_variant) {
    _expr1.basis_evaluate (_tilde1_L1, q, value1);
    for (size_type loc_idof = 0; loc_idof < loc_ndof1; ++loc_idof) {
      value[loc_idof+loc_ndof0] = _c1*value1 [loc_idof];
    }
  }
} 
// ---------------------------------------------------------------------------
// 5.3. element_initialize
// ---------------------------------------------------------------------------
template<class Expr>
void
field_expr_v2_variational_dg<Expr>::element_initialize (const geo_element& K) const
{
  size_type L_map_d = K.dimension() + 1;
  size_type L_dis_ie0, L_dis_ie1;
  side_information_type sid0, sid1;

  L_dis_ie0 = K.master(0);
  L_dis_ie1 = K.master(1);
  check_macro (L_dis_ie0 != std::numeric_limits<size_type>::max(),
      "unexpected isolated mesh side K.dis_ie="<<K.dis_ie());
  if (L_dis_ie1 != std::numeric_limits<size_type>::max()) {
    // K is an internal side
    const geo_element& L0 = _bgd_omega.dis_get_geo_element (L_map_d, L_dis_ie0);
    const geo_element& L1 = _bgd_omega.dis_get_geo_element (L_map_d, L_dis_ie1);
    L0.get_side_informations (K, sid0);
    L1.get_side_informations (K, sid1);
    _tilde0_L0 = L0;
    _tilde1_L1 = L1;
    // methode "non-const": provoque une copie physique au 1er appel (c'est ce qu'il faut)
    _expr0.element_initialize_on_side (L0, sid0);
    _expr1.element_initialize_on_side (L1, sid1);
  } else {
    // K is a boundary side
    const geo_element& L0 = _bgd_omega.dis_get_geo_element (L_map_d, L_dis_ie0);
    L0.get_side_informations (K, sid0);
    _tilde0_L0 = L0;
    _tilde1_L1 = reference_element::max_variant;
    _expr0.element_initialize_on_side (L0, sid0);
  }
}

} // namespace details
// ---------------------------------------------------------------------------
// 5.4. user-level interface
// ---------------------------------------------------------------------------
#define _RHEOLEF_make_field_expr_v2_variational_dg(op,c0,c1) \
template<class Expr>					\
inline							\
typename						\
std::enable_if<						\
  details::is_field_expr_v2_variational_arg<Expr>::value \
 ,details::field_expr_v2_variational_dg<Expr>		\
>::type							\
op (const Expr& expr)					\
{							\
  return details::field_expr_v2_variational_dg <Expr> (expr, c0, c1); \
}

_RHEOLEF_make_field_expr_v2_variational_dg (jump,    1,    -1)
_RHEOLEF_make_field_expr_v2_variational_dg (average, 0.5,  0.5)
_RHEOLEF_make_field_expr_v2_variational_dg (inner,   1,    0)
_RHEOLEF_make_field_expr_v2_variational_dg (outer,   0,    1)
#undef _RHEOLEF_make_field_expr_v2_variational_dg

#ifdef TODO
#endif // TODO

} // namespace rheolef
#endif // _RHEOLEF_FIELD_EXPR_V2_VARIATIONAL_TERMINAL_H