File: ShapeFunction.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 (521 lines) | stat: -rw-r--r-- 15,723 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
// a data structure for managing interpolation/restriction operations

#ifndef SHAPE_FUNCTION_H
#define SHAPE_FUNCTION_H

#include "DependencyManager.h"
#include "PaqAtcUtility.h"
#include <map>
#include <vector>
#include <set>
#include <pair>

namespace ATC {

  // forward declarations
  class FE_Engine;
  class ATC_Method;
  class LammpsInterface;

  // type defs
  typedef pair< vector<double>, vector<int> > POINT_VAL;
  typedef pair< vector<vector<double> >, vector<int> > POINT_GRAD;

  /**
   *  @class FeEngineInterface
   *  @class Base class for defining interfaces to the finite element engine to handle different shape functions
   */

  class FeEngineInterface {

  public:

    // constructor
    FeEngineInterface(FE_Engine * feEngine, DENS_MAN * coordinates) : feEngine_(feEngine), coordinates_(coordinates) {};

    // destructor
    virtual ~FeEngineInterface() {};

    /** evaluate shape function at a set of coordinates */
    virtual void evaluate_shape_function(int index,
                                         POINT_VAL & data) = 0;

  protected:

    /** pointer to the engine */
    FE_Engine * feEngine_;

    /** quantity defining locations */
    DENS_MAN * coordinates_;

  private:

    // do not define
    FeEngineInterface();

  };

  /**
   *  @class FeEngineInterfacePu
   *  @class Interfaces to the finite element engine to handle partition of unity (PU) shape functions
   */

  class FeEngineInterfacePu : public FeEngineInterface {

  public:

    // constructor
    FeEngineInterfacePu(FE_Engine * feEngine) : FeEngineInterface(feEngine) {};

    // destructor
    virtual ~FeEngineInterfacePu() {};

    /** evaluate shape function at a set of coordinates */
    virtual void evaluate_shape_function(int index,
                                         POINT_VAL & data);

  protected:

    /** pointer to the point to element map */
    MatrixDependencyManager<DenseMatrix, int> * pointToElementMap_;

  private:

    // do not define
    FeEngineInterfacePu();

  };

  /**
   *  @class FeEngineInterfaceMls
   *  @class Interfaces to the finite element engine to handle moving least squares (MLS) shape functions
   */

  class FeEngineInterfaceMls : public FeEngineInterface {

  public:

    // constructor
    FeEngineInterfaceMls(FE_Engine * feEngine) : FeEngineInterface(feEngine) {};

    // destructor
    virtual ~FeEngineInterfaceMls() {};

    /** evaluate shape function at a set of coordinates */
    virtual void evaluate_shape_function(int index,
                                         POINT_VAL & data);

  protected:


  private:

    // do not define
    FeEngineInterfaceMls();

  };

  /**
   *  @class ShapeFunctionBase
   *  @class Base class for defining shape functions for restriction and interpolation
   */

  class ShapeFunctionBase : public DependencyManager {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    // could also add a manager and pass the interface in on construction
    ShapeFunctionBase(FE_Engine * feEngine,
                      DENS_MAN * coordinates) : DependencyManager(), feEngineInterface_(feEngine), coordinates_(coordinates)
      {coordinates_->register_dependence(this)};

    // destructor
    virtual ~ShapeFunctionBase() {coordinates_->remove_dependence(this)};

    /** use the shape function as a restriction operator */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output) = 0;

    /** apply the restriction on a subset of points */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const set<int> & points) = 0;

    /** apply the restriction on a subset of points discriminating with booleans */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const Array<bool> & points) = 0;

    /** use the shape function as an interpolation operator */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output) = 0;

    /** apply the interpolation on a subset of points */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const set<int> & points) = 0;

    /** apply the interpolation on a subset of points discriminating with booleans */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const Array<bool> & points) = 0;

  protected:

    /** apply a reset if needed */
    virtual void reset() = 0;

    /** object to interface with the engine */
    FeEngineInterface * feEngineInterface_;

    /** quantity defining locations */
    DENS_MAN * coordinates_;

  private:

    // do not define
    ShapeFunctionBase();

  };

  /**
   *  @class ShapeFunction
   *  @class Defines general shape functions for restriction and interpolation
   */

  class ShapeFunction : public ShapeFunctionBase {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunction(FE_Engine * feEngine,
                  DENS_MAN * coordinates) : ShapeFunctionBase(feEngine,coordinates) {values.reserve(coordinates->nRows();};

    // destructor
    virtual ~ShapeFunction() {};

    /** use the shape function as a restriction operator */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output);

    /** apply the restriction on a subset of points */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const set<int> & points);

    /** apply the restriction on a subset of points discriminating with booleans */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const Array<bool> & points);

    /** use the shape function as an interpolation operator */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output);

    /** apply the interpolation on a subset of points */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const set<int> & points);

    /** apply the interpolation on a subset of points discriminating with booleans */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const Array<bool> & points);

  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** storage for shape function values, indexed by rows of coordinates */
    vector<POINT_VAL> values;

  private:

    // do not define
    ShapeFunction();

  };

  /**
   *  @class ShapeFunctionAtomic
   *  @class Defines shape functions for restriction and interpolation for atomic data
   */

  class ShapeFunctionAtomic : public ShapeFunctionBase {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunctionAtomic(ATC_Method * atc,
                        DENS_MAN * coordinates,
                        AtomType atomType) : ShapeFunctionBase(atc->fe_engine(),coordinates), atc_(atc,atomType), quantityToLammps_(atc_.atc_to_lammps_map()) {};

    // destructor
    virtual ~ShapeFunctionAtomic() {};

    /** use the shape function as a restriction operator */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output);

    /** apply the restriction on a subset of points */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const set<int> & points);

    /** apply the restriction on a subset of points discriminating with booleans */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const Array<bool> & points);

    /** use the shape function as an interpolation operator */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output);

    /** apply the interpolation on a subset of points */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const set<int> & points);

    /** apply the interpolation on a subset of points discriminating with booleans */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const Array<bool> & points);

  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** storage for shape function values, map is based on lammps global index */
    map<int,POINT_VAL> values;

    /** interface to atc functionality */
    PaqAtcUtility atc_;

    /** interface to lammps functionality */
    LammpsInterface * lammpsInterface_;

    /** map from this quantity's AtC indexing to Lammps local indexing for atomic arrays */
    const Array<int> & quantityToLammps_;

  private:

    // do not define
    ShapeFunctionAtomic();

  };

  /**
   *  @class ShapeFunctionAtomicMask
   *  @class Defines shape functions for restriction and interpolation for atomic data, but only on a subset of either ghost or internal
   */

  class ShapeFunctionAtomicMask : public ShapeFunctionAtomic {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunctionAtomicMask(ATC_Method * atc,
                            DENS_MAN * coordinates,
                            AtomType atomType,
                            PerAtomQuantity<bool> * mask) : ShapeFunctionAtomic(atc,coordinates,atomType), mask_(mask) {mask_->register_dependence(this);};

    // destructor
      virtual ~ShapeFunctionAtomicMask() {mask_->remove_dependence(this);};



  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** mask to screen out atoms */
    PerAtomQuantity<bool> * mask_;

  private:

    // do not define
    ShapeFunctionAtomicMask();

  };

    /**
   *  @class ShapeFunctionGrad
   *  @class Defines general shape gradients functions for restriction and interpolation
   */

  class ShapeFunctionGrad : public ShapeFunctionBase {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunctionGrad(FE_Engine * feEngine,
                      DENS_MAN * coordinates) : ShapeFunctionBase(feEngine,coordinates) {values.reserve(coordinates->nRows();};

    // destructor
    virtual ~ShapeFunctionGrad() {};

    /** use the shape function as a restriction operator */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output);

    /** apply the restriction on a subset of points */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const set<int> & points);

    /** apply the restriction on a subset of points discriminating with booleans */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const Array<bool> & points);

    /** use the shape function as an interpolation operator */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output);

    /** apply the interpolation on a subset of points */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const set<int> & points);

    /** apply the interpolation on a subset of points discriminating with booleans */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const Array<bool> & points);

  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** storage for shape function gradients, indexed by rows of coordinates */
    vector<POINT_GRAD> values;

  private:

    // do not define
    ShapeFunctionGrad();

  };

  /**
   *  @class ShapeFunctionGradAtomic
   *  @class Defines shape functions gradients for restriction and interpolation for atomic data
   */

  class ShapeFunctionGradAtomic : public ShapeFunctionBase {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunctionGradAtomic(ATC_Method * atc,
                            DENS_MAN * coordinates,
                            AtomType atomType) : ShapeFunctionBase(atc->fe_engine(),coordinates), atc_(atc,atomType), quantityToLammps_(atc_.atc_to_lammps_map()) {};

    // destructor
    virtual ~ShapeFunctionGradAtomic() {};

    /** use the shape function as a restriction operator */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output);

    /** apply the restriction on a subset of points */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const set<int> & points);

    /** apply the restriction on a subset of points discriminating with booleans */
    virtual void restrict(const DENS_MAT & input,
                          DENS_MAT & output,
                          const Array<bool> & points);

    /** use the shape function as an interpolation operator */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output);

    /** apply the interpolation on a subset of points */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const set<int> & points);

    /** apply the interpolation on a subset of points discriminating with booleans */
    virtual void interpolation(const DENS_MAT & input,
                               DENS_MAT & output,
                               const Array<bool> & points);

  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** storage for shape function values, map is based on lammps global index */
    map<int,POINT_GRAD> values;

    /** interface to atc functionality */
    PaqAtcUtility atc_;

    /** interface to lammps functionality */
    LammpsInterface * lammpsInterface_;

    /** map from this quantity's AtC indexing to Lammps local indexing for atomic arrays */
    const Array<int> & quantityToLammps_;

  private:

    // do not define
    ShapeFunctionGradAtomic();

  };

  /**
   *  @class ShapeFunctionGradAtomicMask
   *  @class Defines shape function gradients s for restriction and interpolation for atomic data, but only on a subset of either ghost or internal
   */

  class ShapeFunctionGradAtomicMask : public ShapeFunctionGradAtomic {

  public:

    // constructor
    // discriminate engine interface based on point to element map presence?
    ShapeFunctionGradAtomicMask(ATC_Method * atc,
                            DENS_MAN * coordinates,
                            AtomType atomType,
                            PerAtomQuantity<bool> * mask) : ShapeFunctionGradAtomic(atc,coordinates,atomType), mask_(mask) {mask_->register_dependence(this);};

    // destructor
      virtual ~ShapeFunctionGradAtomicMask() {mask_->remove_dependence(this);};



  protected:

    /** apply a reset if needed */
    virtual void reset();

    /** mask to screen out atoms */
    PerAtomQuantity<bool> * mask_;

  private:

    // do not define
    ShapeFunctionGradAtomicMask();

  };

};





#endif