File: TransferOperator.h

package info (click to toggle)
lammps 20220106.git7586adbb6a%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 348,064 kB
  • sloc: cpp: 831,421; python: 24,896; xml: 14,949; f90: 10,845; ansic: 7,967; sh: 4,226; perl: 4,064; fortran: 2,424; makefile: 1,501; objc: 238; lisp: 163; csh: 16; awk: 14; tcl: 6
file content (1145 lines) | stat: -rw-r--r-- 33,697 bytes parent folder | download | duplicates (2)
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
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
// A class for defining transfer operations

#ifndef TRANSFER_OPERATOR_H
#define TRANSFER_OPERATOR_H

#include "PerAtomQuantityLibrary.h"
#include <set>
#include <vector>

namespace ATC {

  // forward declarations
  class ATC_Method;
  class KernelFunction;
  class FE_Mesh;

  /**
   *  @class  DenseMatrixTransfer
   *  @brief  Class for defining objects that generate dense matrix quantities from other matrix quantities
   */
  template <typename T>
  class DenseMatrixTransfer : public MatrixDependencyManager<DenseMatrix, T> {

  public:

    // constructor
    DenseMatrixTransfer() :
    MatrixDependencyManager<DenseMatrix, T>(),
      lammpsInterface_(LammpsInterface::instance()) {};

    // destructor
    virtual ~DenseMatrixTransfer() {};

    /** apply transfer operator */
    virtual const DenseMatrix<T> & quantity() const {
      if (this->need_reset()) {
        this->reset_quantity();
        MatrixDependencyManager<DenseMatrix, T>::needReset_ = false;
      }
      return MatrixDependencyManager<DenseMatrix, T>::quantity_;
    };


        /** sets the quantity to a given value */
    virtual void operator=(const DenseMatrix<T> & /* target */)
      {throw ATC_Error("DenseMatrixTransfer::set_quantity - Cannot modify transfer-based matrices");};

    /** sets the quantity to a given constant value */
    virtual void operator=(const T & /* target */)
      {throw ATC_Error("DenseMatrixTransfer::operator= - Cannot modify transfer-based matrices");};

    /** adds the given data to the Lammps quantity */
    virtual void operator+=(const DenseMatrix<T> & /* addition */)
      {throw ATC_Error("DenseMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** adds the scalar data to the Lammps quantity for AtC atoms */
    virtual void operator+=(T /* addition */)
      {throw ATC_Error("DenseMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** subtracts the given data from the Lammps quantity */
    virtual void operator-=(const DenseMatrix<T> & /* subtraction */)
      {throw ATC_Error("DenseMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** subtracts the scalar data from the Lammps quantity for AtC atoms */
    virtual void operator-=(T /* subtraction */)
      {throw ATC_Error("DenseMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(const DenseMatrix<T> & /* multiplier */)
      {throw ATC_Error("DenseMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(T /* multiplier */)
      {throw ATC_Error("DenseMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(const DenseMatrix<T> & /* divisor */)
      {throw ATC_Error("DenseMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(T /* divisor */)
      {throw ATC_Error("DenseMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

  protected:

    /** does the actual computation of the quantity */
    virtual void reset_quantity() const = 0;

    /** pointer to LammpsInterface for MPI */
    LammpsInterface * lammpsInterface_;

  };

  /**
   *  @class  SparseMatrixTransfer
   *  @brief  Class for defining objects that generate dense matrix quantities from other matrix quantities
   */
  template <typename T>
  class SparseMatrixTransfer : public MatrixDependencyManager<SparseMatrix, T> {

  public:

    // constructor
    SparseMatrixTransfer() :
    MatrixDependencyManager<SparseMatrix, T>(),
      lammpsInterface_(LammpsInterface::instance()) {};

    // destructor
    virtual ~SparseMatrixTransfer() {};

    /** apply transfer operator */
    virtual const SparseMatrix<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); MatrixDependencyManager<SparseMatrix, T>::needReset_ = false;} return MatrixDependencyManager<SparseMatrix, T>::quantity_;};


        /** sets the quantity to a given value */
    virtual void operator=(const SparseMatrix<T> & /* target */)
      {throw ATC_Error("SparseMatrixTransfer::set_quantity - Cannot modify transfer-based matrices");};

    /** sets the quantity to a given constant value */
    virtual void operator=(const T & /* target */)
      {throw ATC_Error("SparseMatrixTransfer::operator= - Cannot modify transfer-based matrices");};

    /** adds the given data to the Lammps quantity */
    virtual void operator+=(const SparseMatrix<T> & /* addition */)
      {throw ATC_Error("SparseMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** adds the scalar data to the Lammps quantity for AtC atoms */
    virtual void operator+=(T /* addition */)
      {throw ATC_Error("SparseMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** subtracts the given data from the Lammps quantity */
    virtual void operator-=(const SparseMatrix<T> & /* subtraction */)
      {throw ATC_Error("SparseMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** subtracts the scalar data from the Lammps quantity for AtC atoms */
    virtual void operator-=(T /* subtraction */)
      {throw ATC_Error("SparseMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(const SparseMatrix<T> & /* multiplier */)
      {throw ATC_Error("SparseMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(T /* multiplier */)
      {throw ATC_Error("SparseMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(const SparseMatrix<T> & /* divisor */)
      {throw ATC_Error("SparseMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(T /* divisor */)
      {throw ATC_Error("SparseMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

  protected:

    /** does the actual computation of the quantity */
    virtual void reset_quantity() const = 0;

    /** pointer to LammpsInterface for MPI */
    LammpsInterface * lammpsInterface_;

  };

  /**
   *  @class  DiagonalMatrixTransfer
   *  @brief  Class for defining objects that generate diagonal matrix quantities from other matrix quantities
   */
  template <typename T>
  class DiagonalMatrixTransfer : public MatrixDependencyManager<DiagonalMatrix, T> {

  public:

    // constructor
    DiagonalMatrixTransfer() :
    MatrixDependencyManager<DiagonalMatrix, T>(),
      lammpsInterface_(LammpsInterface::instance()) {};

    // destructor
    virtual ~DiagonalMatrixTransfer() {};

    /** apply transfer operator */
    virtual const DiagonalMatrix<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); MatrixDependencyManager<DiagonalMatrix, T>::needReset_ = false;} return MatrixDependencyManager<DiagonalMatrix, T>::quantity_;};


        /** sets the quantity to a given value */
    virtual void operator=(const DiagonalMatrix<T> & /* target */)
      {throw ATC_Error("DiagonalMatrixTransfer::set_quantity - Cannot modify transfer-based matrices");};

    /** sets the quantity to a given constant value */
    virtual void operator=(const T & /* target */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator= - Cannot modify transfer-based matrices");};

    /** adds the given data to the Lammps quantity */
    virtual void operator+=(const DiagonalMatrix<T> & /* addition */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** adds the scalar data to the Lammps quantity for AtC atoms */
    virtual void operator+=(T /* addition */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator+= - Cannot modify transfer-based matrices");};

    /** subtracts the given data from the Lammps quantity */
    virtual void operator-=(const DiagonalMatrix<T> & /* subtraction */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** subtracts the scalar data from the Lammps quantity for AtC atoms */
    virtual void operator-=(T /* subtraction */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator-= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(const DiagonalMatrix<T> & /* multiplier */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator*=(T /* multiplier */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator*= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(const DiagonalMatrix<T> & /* divisor */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

    /** multiples the Lammps quantity by the given data, input is indexed in AtC atom counts */
    virtual void operator/=(T /* divisor */)
      {throw ATC_Error("DiagonalMatrixTransfer::operator/= - Cannot modify transfer-based matrices");};

  protected:

    /** does the actual computation of the quantity */
    virtual void reset_quantity() const = 0;

    /** pointer to LammpsInterface for MPI */
    LammpsInterface * lammpsInterface_;

  };

  /**
   *  @class  SetTransfer
   *  @brief  Class for defining objects that generate sets using prescribed algorithms
   */
  template <typename T>
  class SetTransfer : public SetDependencyManager<T> {

  public:

    // constructor
    SetTransfer() :
      SetDependencyManager<T>() {};

    // destructor
    virtual ~SetTransfer() {};

    /** apply transfer operator */
    virtual const std::set<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); SetDependencyManager<T>::needReset_ = false;} return SetDependencyManager<T>::quantity_;};

    /** returns a non-const version for manipulations and changes, resets dependent quantities */
    virtual std::set<T> & set_quantity()
      {throw ATC_Error("SetTransfer::set_quantity - Cannot modify protected quantities"); return this->quantity_;};

  protected:

    /** does the actual computation of the quantity */
    virtual void reset_quantity() const = 0;

  };

  /**
   *  @class  VectorTransfer
   *  @brief  Class for defining objects that generate sets using prescribed algorithms
   */
  template <typename T>
  class VectorTransfer : public VectorDependencyManager<T> {

  public:

    // constructor
    VectorTransfer() :
      VectorDependencyManager<T>() {};

    // destructor
    virtual ~VectorTransfer() {};

    /** apply transfer operator */
    virtual const std::vector<T> & quantity() const {if (this->need_reset()) {this->reset_quantity(); VectorDependencyManager<T>::needReset_ = false;} return VectorDependencyManager<T>::quantity_;};

    /** returns a non-const version for manipulations and changes, resets dependent quantities */
    virtual std::vector<T> & set_quantity()
      {throw ATC_Error("VectorTransfer::set_quantity - Cannot modify protected quantities"); return this->quantity_;};

  protected:

    /** does the actual computation of the quantity */
    virtual void reset_quantity() const = 0;

  };

  /**
   *  @class  AtomToFeTransfer
   *  @brief  Class for defining objects to transfer atomistic quantities to FE quantities
   */

  class AtomToFeTransfer : public DenseMatrixTransfer<double> {

  public:

    // constructor
    AtomToFeTransfer(ATC_Method * atc,
                     PerAtomQuantity<double> * source);

    // destructor
    virtual ~AtomToFeTransfer();

  protected:

    /** pointer to atc */
    ATC_Method * atc_;

    /** pointer to source atomic quantity data */
    PerAtomQuantity<double> * source_;

  private:

    // do not define
    AtomToFeTransfer();

  };

  /**
   *  @class  AtomDiagonalMatrixToFeTransfer
   *  @brief  Class for defining objects to transfer atomistic quantities to FE quantities
   */

  class AtomDiagonalMatrixToFeTransfer : public DenseMatrixTransfer<double> {

  public:

    // constructor
    AtomDiagonalMatrixToFeTransfer(ATC_Method * atc,
                                   PerAtomDiagonalMatrix<double> * source);

    // destructor
    virtual ~AtomDiagonalMatrixToFeTransfer();

  protected:

    /** pointer to atc */
    ATC_Method * atc_;

    /** pointer to source atomic quantity data */
    PerAtomDiagonalMatrix<double> * source_;

  private:

    // do not define
    AtomDiagonalMatrixToFeTransfer();

  };

  /**
   *  @class  FeToAtomTransfer
   *  @brief  Class for defining objects to transfer FE quantities to atomistic quantities
   */

  class FeToAtomTransfer : public ProtectedAtomQuantity<double> {

  public:

    // constructor
    FeToAtomTransfer(ATC_Method * atc,
                     DENS_MAN * source,
                     AtomType atomType = INTERNAL);

    // destructor
    virtual ~FeToAtomTransfer();

  protected:

    /** pointer to source Fe matrix data */
    DENS_MAN * source_;

  private:

    // do not define
    FeToAtomTransfer();

  };

  /**
   *  @class  FeToAtomDiagonalMatrix
   *  @brief  Class for defining objects to transfer FE quantities to atomistic diagonal matrices
   */

  class FeToAtomDiagonalMatrix : public ProtectedAtomDiagonalMatrix<double> {

  public:

    // constructor
    FeToAtomDiagonalMatrix(ATC_Method * atc,
                           DENS_MAN * source);

    // destructor
    virtual ~FeToAtomDiagonalMatrix();

  protected:

    /** pointer to source Fe matrix data */
    DENS_MAN * source_;

  private:

    // do not define
    FeToAtomDiagonalMatrix();

  };

  /**
   *  @class  MatToMatTransfer
   *  @brief  Class for defining objects that transfer quantities between materials
   */
  template <typename T>
  class MatToMatTransfer : public DenseMatrixTransfer<T> {

  public:

    // constructor
    MatToMatTransfer(MatrixDependencyManager<DenseMatrix, T> * source) :
      source_(source) {source_->register_dependence(this);};

    // destructor
    virtual ~MatToMatTransfer() {source_->remove_dependence(this);};

  protected:

    /** pointer to source matrix data */
    MatrixDependencyManager<DenseMatrix, T> * source_;

  private:

    // do not define
    MatToMatTransfer();

  };

  /**
   *  @class  AtfShapeFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to FE using shape functions
   *          (implements restrict_volumetric_quantity)
   */

  class AtfShapeFunctionRestriction : public AtomToFeTransfer {

  public:

    // constructor
    AtfShapeFunctionRestriction(ATC_Method * atc,
                                PerAtomQuantity<double> * source,
                                SPAR_MAN * shapeFunction);

    // destructor
    virtual ~AtfShapeFunctionRestriction();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** reference to shape function matrix */
    SPAR_MAN * shapeFunction_;

    /** persistent workspace */


    mutable DENS_MAT _workspace_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const SPAR_MAT & shapeFunctionMatrix) const;

  private:

    // do not define
    AtfShapeFunctionRestriction();

  };

  /**
   *  @class  AdmtfShapeFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic diagonal matrices to FE using shape functions=
   */

  class AdmtfShapeFunctionRestriction : public AtomDiagonalMatrixToFeTransfer {

  public:

    // constructor
    AdmtfShapeFunctionRestriction(ATC_Method * atc,
                                PerAtomDiagonalMatrix<double> * source,
                                SPAR_MAN * shapeFunction);

    // destructor
    virtual ~AdmtfShapeFunctionRestriction();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** reference to shape function matrix */
    SPAR_MAN * shapeFunction_;

    /** persistent workspace */


    mutable DENS_MAT _workspace_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const SPAR_MAT & shapeFunctionMatrix) const;

  private:

    // do not define
    AdmtfShapeFunctionRestriction();

  };

  /**
   *  @class  AtfProjection
   *  @brief
   */

  class AtfProjection : public AtomToFeTransfer {

  public:

    // constructor
    AtfProjection(ATC_Method * atc,
                  PerAtomQuantity<double> * source,
                  SPAR_MAN * accumulant,
                  DIAG_MAN * weights = nullptr);

    // destructor
    virtual ~AtfProjection();

    /** apply transfer operator */
    virtual void reset_quantity() const;

    /** get number of columns */
    virtual int nCols() const {return source_->nCols();};

  protected:

    /** reference to shape function matrix */
    SPAR_MAN * accumulant_;
    DIAG_MAN * weights_;
    DENS_MAT * reference_;

    /** persistent workspace */


    mutable DENS_MAT _workspace_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const SPAR_MAT & shapeFunctionMatrix) const;

  private:

    // do not define
    AtfProjection();

  };
  class AtfProjectionScaled : public AtfProjection {

  public:

    // constructor
    AtfProjectionScaled(ATC_Method * atc,
                  PerAtomQuantity<double> * source,
                  SPAR_MAN * accumulant,
                  const double scale,
                  DIAG_MAN * weights = nullptr);

    // destructor
    virtual ~AtfProjectionScaled();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:
    /** reference to shape function matrix */
    double     scale_;

  private:

    // do not define
    AtfProjectionScaled();

  };

  /**
   *  @class  AtfProjectionReferenced
   *  @brief
   */

  class AtfProjectionReferenced : public AtfProjection {

  public:

    // constructor
    AtfProjectionReferenced(ATC_Method * atc,
                  PerAtomQuantity<double> * source,
                  SPAR_MAN * accumulant,
                  DENS_MAN * reference,
                  DIAG_MAN * weights = nullptr);

    // destructor
    virtual ~AtfProjectionReferenced();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** reference value */
    DENS_MAN * reference_;

  private:

    // do not define
    AtfProjectionReferenced();

  };


  /**
   *  @class  AtfWeightedShapeFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to FE using shape functions
   *          including approximate quadrature weights
   *          (implements restrict_unscaled)
   */

  class AtfWeightedShapeFunctionRestriction : public AtfShapeFunctionRestriction {

  public:

    // constructor
    AtfWeightedShapeFunctionRestriction(ATC_Method * atc,
                                        PerAtomQuantity<double> * source,
                                        SPAR_MAN * shapeFunction,
                                        DIAG_MAN * weights);

    // destructor
    virtual ~AtfWeightedShapeFunctionRestriction() {weights_->remove_dependence(this);};

  protected:

    /** reference to diagonal weighting matrix */
    DIAG_MAN * weights_;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const SPAR_MAT & shapeFunctionMatrix) const;

  private:

    // do not define
    AtfWeightedShapeFunctionRestriction();

  };

  /**
   *  @class  AtfNodeWeightedShapeFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to FE using shape functions
   *          including weighting at the mesh nodes
   */

  class AtfNodeWeightedShapeFunctionRestriction : public AtfShapeFunctionRestriction {

  public:

    // constructor
    AtfNodeWeightedShapeFunctionRestriction(ATC_Method * atc,
                                            PerAtomQuantity<double> * source,
                                            SPAR_MAN * shapeFunction,
                                            DIAG_MAN * weights);

    // destructor
    virtual ~AtfNodeWeightedShapeFunctionRestriction() {weights_->remove_dependence(this);};

  protected:

    /** reference to diagonal weighting matrix */
    DIAG_MAN * weights_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

  private:

    // do not define
    AtfNodeWeightedShapeFunctionRestriction();

  };

  /**
   *  @class  AtfShapeFunctionProjection
   *  @brief  Class for defining objects that transfer restricted atomistic quantities to FE using shape functions
   *          (implements project/project_volumetric_quantity assuming restrict_unscaled/
   *           restrict_volumetric_quantity has been applied)
   */

  class AtfShapeFunctionProjection : public MatToMatTransfer<double> {

  public:

    // constructor
    AtfShapeFunctionProjection(ATC_Method * atc,
                               DENS_MAN * source,
                               FieldName thisField);

    // destructor
    virtual ~AtfShapeFunctionProjection();

    /** apply transfer operator */
    virtual void reset_quantity() const ;

  protected:

    /** pointer to atc object for mass matrix inversion */
    ATC_Method * atc_;

    /** field name to define mass matrix to use */
    FieldName thisField_;

  private:

    // do not define
    AtfShapeFunctionProjection();

  };

  /**
   *  @class  AtfShapeFunctionMdProjection
   *  @brief  Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region
   *          (implements project_md/project_md_volumetric_quantity assuming
   *           restrict_unscaled/restrict_volumetric_quantity has been applied)
   */

  class AtfShapeFunctionMdProjection : public MatToMatTransfer<double> {

  public:

    // constructor
    AtfShapeFunctionMdProjection(ATC_Method * atc,
                                 DENS_MAN * source,
                                 FieldName thisField);

    // destructor
    virtual ~AtfShapeFunctionMdProjection();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** pointer to atc object for mass matrix inversion */
    ATC_Method * atc_;

    /** field name to define mass matrix to use */
    FieldName thisField_;

  private:

    // do not define
    AtfShapeFunctionMdProjection();

  };

  /**
   *  @class  AtfShapeFunctionMdProjectionScaled
   *  @brief  Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region with a scaling factor
   *          (implements project_md/project_md_volumetric_quantity assuming
   *           restrict_unscaled/restrict_volumetric_quantity has been applied)
   */

  class AtfShapeFunctionMdProjectionScaled : public AtfShapeFunctionMdProjection {

  public:

    // constructor
    AtfShapeFunctionMdProjectionScaled(ATC_Method * atc,
                                           DENS_MAN * source,
                                           double scale,
                                           FieldName thisField);

    // destructor
    virtual ~AtfShapeFunctionMdProjectionScaled();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** scale multiplier */
   double scale_;

  private:

    // do not define
    AtfShapeFunctionMdProjectionScaled();

  };

  /**
   *  @class  AtfShapeFunctionMdProjectionReferenced
   *  @brief  Class for defining objects that transfer restricted atomistic quantities to FE using shape functions for the MD region with respect to a reference
   *          (implements project_md/project_md_volumetric_quantity assuming
   *           restrict_unscaled/restrict_volumetric_quantity has been applied)
   */

  class AtfShapeFunctionMdProjectionReferenced : public AtfShapeFunctionMdProjection {

  public:

    // constructor
    AtfShapeFunctionMdProjectionReferenced(ATC_Method * atc,
                                           DENS_MAN * source,
                                           DENS_MAN * reference,
                                           FieldName thisField);

    // destructor
    virtual ~AtfShapeFunctionMdProjectionReferenced();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** reference value */
    DENS_MAN * reference_;

  private:

    // do not define
    AtfShapeFunctionMdProjectionReferenced();

  };

  /**
   *  @class  AtfKernelFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to FE using kernel functions
   */

  class AtfKernelFunctionRestriction : public AtomToFeTransfer {

  public:

    // constructor
    AtfKernelFunctionRestriction(ATC_Method * atc,
                                 PerAtomQuantity<double> * source,
                                 PerAtomQuantity<double> * coarseGrainingPositions,
                                 KernelFunction * kernelFunction);

    // destructor
    virtual ~AtfKernelFunctionRestriction();

    /** apply transfer operator */
    virtual void reset_quantity() const;

  protected:

    /** pointer to the kernel function evaluator */
    KernelFunction * kernelFunction_;

    /** reference positions for coarse graining operations */
    PerAtomQuantity<double> * coarseGrainingPositions_;

    /** pointer to the mesh being used */
    const FE_Mesh * feMesh_;

    /** persistent workspace */


    mutable DENS_MAT _workspace_;
    mutable DENS_VEC _xI_, _xa_, _xaI_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const DENS_MAT & positions,
                                   const KernelFunction * kernelFunction) const;

  private:

    // do not define
    AtfKernelFunctionRestriction();

  };

  /**
   *  @class  AtfWeightedKernelFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to mesh using kernel functions
   *          including approximate quadrature weights
   */

  class AtfWeightedKernelFunctionRestriction : public AtfKernelFunctionRestriction {

  public:

    // constructor
    AtfWeightedKernelFunctionRestriction(ATC_Method * atc,
                                         PerAtomQuantity<double> * source,
                                         PerAtomQuantity<double> * coarseGrainingPositions,
                                         KernelFunction * kernelFunction,
                                         DIAG_MAN * weights);

    // destructor
    virtual ~AtfWeightedKernelFunctionRestriction() {weights_->remove_dependence(this);};

  protected:

    /** reference to diagonal weighting matrix */
    DIAG_MAN * weights_;

    /** applies restriction operation on this processor */
    virtual void local_restriction(const DENS_MAT & sourceMatrix,
                                   const DENS_MAT & positions,
                                   const KernelFunction * kernelFunction) const;

  private:

    // do not define
    AtfWeightedKernelFunctionRestriction();

  };

  /**
   *  @class  AtfNodeWeightedKernelFunctionRestriction
   *  @brief  Class for defining objects that transfer atomistic quantities to a mesh using kernel functions
   *          including weighting at the mesh nodes
   */

  class AtfNodeWeightedKernelFunctionRestriction : public AtfKernelFunctionRestriction {

  public:

    // constructor
    AtfNodeWeightedKernelFunctionRestriction(ATC_Method * atc,
                                             PerAtomQuantity<double> * source,
                                             PerAtomQuantity<double> * coarseGrainingPositions,
                                             KernelFunction * kernelFunction,
                                             DIAG_MAN * weights);

    // destructor
    virtual ~AtfNodeWeightedKernelFunctionRestriction() {weights_->remove_dependence(this);};

  protected:

    /** reference to diagonal weighting matrix */
    DIAG_MAN * weights_;

    /** applies restriction operation across all processors */
    virtual void global_restriction() const;

  private:

    // do not define
    AtfNodeWeightedKernelFunctionRestriction();

  };

  /**
   *  @class  FtaShapeFunctionProlongation
   *  @brief  Class for defining objects that transfer FE quantities to atoms using shape functions
   *          (implements prolong)
   */

  class FtaShapeFunctionProlongation : public FeToAtomTransfer {

  public:

    // constructor
    FtaShapeFunctionProlongation(ATC_Method * atc,
                                 DENS_MAN * source,
                                 SPAR_MAN * shapeFunction,
                                 AtomType atomType = INTERNAL);

    // destructor
    virtual ~FtaShapeFunctionProlongation();

  protected:

    /** apply transfer operator if needed */
    virtual void reset() const;

    /** reference to shape function matrix */
    SPAR_MAN * shapeFunction_;

  private:

    // do not define
    FtaShapeFunctionProlongation();

  };

  /**
   *  @class  FtaShapeFunctionProlongationDiagonalMatrix
   *  @brief  Class for defining objects that transfer FE quantities to atomic diagonal matrices using shape functions
   *          (implements prolong)
   */

  class FtaShapeFunctionProlongationDiagonalMatrix : public FeToAtomDiagonalMatrix {

  public:

    // constructor
    FtaShapeFunctionProlongationDiagonalMatrix(ATC_Method * atc,
                                               DENS_MAN * source,
                                               SPAR_MAN * shapeFunction);

    // destructor
    virtual ~FtaShapeFunctionProlongationDiagonalMatrix();

  protected:

    /** apply transfer operator if needed */
    virtual void reset() const;

    /** reference to shape function matrix */
    SPAR_MAN * shapeFunction_;

    // workspace
    mutable DENS_MAT _temp_; // temporary storage for dense matrix

  private:

    // do not define
    FtaShapeFunctionProlongationDiagonalMatrix();

  };

  /**
   *   transfer for a matrix to a gradient mitigated by sparse matrices
   *
   */
  class MatToGradBySparse : public MatToMatTransfer<double> {

  public:

    //constructor
    MatToGradBySparse(ATC_Method * atc,
                      DENS_MAN * source,
                      VectorDependencyManager<SPAR_MAT * > * gradientMatrices);
    //destructor
    virtual ~MatToGradBySparse();

    // apply transfer operator
    virtual void reset_quantity() const;

  protected:

    // pointer to sparseMatrix
    VectorDependencyManager<SPAR_MAT * > * gradientMatrices_;

  private:

    // do not define
    MatToGradBySparse();

  };

  /**
   * transfer from dense to dense by diagonal matrix multiplier for anything
  **/
  class DiagonalMatrixMultiply : public MatToMatTransfer<double> {

  public:

    //constructor
    DiagonalMatrixMultiply(DENS_MAN * source,
                           DIAG_MAN * diagonalMatrix);
    //destructor
    virtual ~DiagonalMatrixMultiply();

    // apply transfer operator
    virtual void reset_quantity() const;

  protected:

    // pointer to sparseMatrix
    DIAG_MAN * diagonalMatrix_;

  private:

    // do not define
    DiagonalMatrixMultiply();

  };

#ifdef ATC_WHO
/**
  // class sparse matrix multiplier for anything
  //delete later
**/
  class SparseMatrixMultiply : public MatToMatTransfer<double> {

  public:

    //constructor
    SparseMatrixMultiply(ATC_Method * atc,
                         DENS_MAN * source,
                         SPAR_MAN * sparseMatrix);
    //destructor
    virtual ~SparseMatrixMultiply();

  protected:

    // pointer to sparseMatrix
    SPAR_MAN * sparseMatrix_;

    // apply transfer operator
    virtual const DENS_MAT & quantity() const;

  private:

    // do not define
    SparseMatrixMultiply();

  };

#endif

}
#endif