File: FE_Mesh.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 (712 lines) | stat: -rw-r--r-- 24,544 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
#ifndef FE_MESH_H
#define FE_MESH_H

#include "Array.h"
#include "Array2D.h"
#include "MatrixLibrary.h"
#include "ATC_TypeDefs.h"
#include "KD_Tree.h"
#include <vector>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <utility>
#include <cfloat>
#include <string>
#include <vector>
#include "mpi.h"

namespace ATC {

  class FE_Element;

  /**
   *  @class  FE_Mesh
   *  @brief  Base class for a finite element mesh
   */
  class FE_Mesh {

  public:

    /** constructor */
    FE_Mesh();

    /** destructor */
    virtual ~FE_Mesh();

    /** parser/modifier */
    bool modify(int narg, char **arg);

    /** initialization */
    void initialize(void);

    /** write an unstructured mesh */
    void write_mesh(std::string meshFile);



// SJL why? will they ever be overridden by derived classes? in what
//     situation would that be required, or desirable? virtual functions
//     are slightly less efficient because they cannot be hard-linked at
//     compile time.

    bool is_partitioned() const { return partitioned_; }
    virtual void partition_mesh() = 0;
    virtual void departition_mesh() = 0;

    int map_elem_to_myElem(int elemID) const;
    int map_myElem_to_elem(int myElemID) const;
    void set_lammps_partition(bool t) {lammpsPartition_ = t;}
    void set_data_decomposition(bool t) {decomposition_ = t;}

    /** set quadrature on element from within interpolate class */
    void set_quadrature(FeIntQuadrature type);

    /** evaluate shape function at real coordinates */
    void position(const int elem,
                  const VECTOR &xi,
                        DENS_VEC &x) const;

    /** evaluate shape function at real coordinates */
    void shape_functions(const VECTOR &x,
                         DENS_VEC &N,
                         Array<int> &nodeList) const;

    /** evaluate shape function at real coordinates */
    void shape_functions(const VECTOR &x,
                                 DENS_VEC &N,
                                 Array<int> &nodeList,
                                 const Array<bool> &) const;

    /** evaluate shape function at real coordinates */
    void shape_functions(const DENS_VEC &x,
                         DENS_VEC &N,
                         DENS_MAT &dNdx,
                         Array<int> &nodeList) const;

    /** evaluate shape function at real coordinates */
    void shape_functions(const VECTOR &x,
                         const int eltID,
                         DENS_VEC &N,
                         Array<int> &nodeList) const;

    /** evaluate shape function at real coordinates */
    void shape_functions(const DENS_VEC &x,
                         const int eltID,
                         DENS_VEC &N,
                         DENS_MAT &dNdx,
                         Array<int> &nodeList) const;

    /** evaluate shape function at real coordinates */
    void shape_function_derivatives(const DENS_VEC &x,
                         const int eltID,
                         DENS_MAT &dNdx,
                         Array<int> &nodeList) const;

    /** evaluate shape functions for all ip's on an element */
    // N is numIPsInElement X numNodesInElement
    void shape_function(const int eltID,
                        DENS_MAT &N,
                        DIAG_MAT &weights) const;

    /** evaluate shape functions for all ip's on an element */
    // N is numIPsInElement X numNodesInElement
    void shape_function(const int eltID,
                        DENS_MAT &N,
                        std::vector<DENS_MAT> &dN,
                        DIAG_MAT &weights) const;

    /** evaluate shape functions for all ip's on a face */
    // N is numIPsInFace X numNodesInElement
    void face_shape_function(const PAIR &face,
                             DENS_MAT &N,
                             DENS_MAT &n,
                             DIAG_MAT &weights) const;

    void face_shape_function(const PAIR &face,
                             DENS_MAT &N,
                             std::vector<DENS_MAT> &dN,
                             std::vector<DENS_MAT> &Nn,
                             DIAG_MAT &weights) const;

    /** compute normal vector from the specified face */
    double face_normal(const PAIR &face,
                       const int ip,
                       DENS_VEC &normal) const;


    /** return connectivity (global ID numbers) for element eltID */
    void element_connectivity_global(const int eltID,
                                     Array<int> & nodes) const;

    void element_connectivity_unique(const int eltID,
                                     Array<int> & nodes) const;

    int element_connectivity_global(const int eltID,
                                     const int inode) const;

    int element_connectivity_unique(const int eltID,
                                     const int inode) const;

    AliasArray<int> element_connectivity_global(const int eltID) const;

    AliasArray<int> element_connectivity_unique(const int eltID) const;

    void face_connectivity(const PAIR & faceID,
                           Array<int> & nodes) const
    { int nNodesPerFace = num_nodes_per_face();
      nodes.reset(nNodesPerFace);
      int eltID = faceID.first;
      int localFace = faceID.second;
      const Array2D<int> & localFaceConn = local_face_connectivity();
      for(int i = 0; i < nNodesPerFace; ++i) {
        nodes(i) = element_connectivity_global(eltID, localFaceConn(localFace,i));
      }
    }
    void face_connectivity_unique(const PAIR & faceID,
                                  Array<int> & nodes) const
    { int nNodesPerFace = num_nodes_per_face();
      nodes.reset(nNodesPerFace);
      int eltID = faceID.first;
      int localFace = faceID.second;
      const Array2D<int> & localFaceConn = local_face_connectivity();
      for(int i = 0; i < nNodesPerFace; ++i) {
        nodes(i) = element_connectivity_unique(eltID, localFaceConn(localFace,i));
      }
    }

    /**
     *  return spatial coordinates for element nodes on eltID,
     *  indexed xCoords(isd,inode)
     */
    void element_coordinates(const int eltID,
                             DENS_MAT & xCoords) const;

    void face_coordinates(const PAIR face,
                          DENS_MAT & xCoords) const;

    /** access to the nodal coordinate values */
    const DENS_MAT & nodal_coordinates(void) const {return nodalCoords_  ;}

    /** access to nodal coordinates of a unique node */
    DENS_VEC nodal_coordinates(const int nodeID) const;

    /** access to nodal coordinates of a node */
    DENS_VEC global_coordinates(const int nodeID) const;

    /** map spatial location to element */
    virtual int map_to_element(const DENS_VEC &x) const = 0;

    /** map global node numbering to unique node numbering */
    int map_global_to_unique(const int global_id) const
    {
      return globalToUniqueMap_(global_id);
    }
    inline const Array<int>& global_to_unique_map(void) const
    {
      return globalToUniqueMap_;
    }

    /** map unique node numbering a global node numbering */
    int map_unique_to_global(const int unique_id)
    {
      return uniqueToGlobalMap_(unique_id);
    }
    inline const Array<int>& unique_to_global_map(void) const
    {
      return uniqueToGlobalMap_;
    }

    /** query whether a nodeset with the given name exists */
    bool query_nodeset(const std::string & name) const;

    /** get node set (unique ID's) from the string name assigned to the set */
    const std::set<int> & nodeset(const std::string & name) const;

    /** create node set with tag "name" from nodes in given spatial range */
    void create_nodeset(const std::string & name, const std::set<int> & nodeset);
    void create_nodeset(const std::string & name,
                        double xmin, double xmax,
                        double ymin, double ymax,
                        double zmin, double zmax);

    /** add to node set with tag "name" from nodes in given spatial range */
    void add_to_nodeset(const std::string & name,
                        double xmin, double xmax,
                        double ymin, double ymax,
                        double zmin, double zmax);

    /** get element set from the string name assigned to the set */
    const std::set<int> & elementset(const std::string & name) const;

    /** create element set with tag "name" from nodes in given spatial range */
    void create_elementset(const std::string & name,
                           double xmin, double xmax,
                           double ymin, double ymax,
                           double zmin, double zmax);


    /** get the minimal element set from a nodeset by name */
    void nodeset_to_minimal_elementset(const std::string &name,
                                       std::set<int> &elemSet) const;
    /** get the minimal element set from a set of nodes */
    void nodeset_to_minimal_elementset(const std::set<int> &nodeSet,
                                       std::set<int> &elemSet) const;
    /** get the maximal element set from a nodeset by name */
    void nodeset_to_maximal_elementset(const std::string &name,
                                       std::set<int> &elemSet) const;
    /** get the maximal element set from a set of nodes */
    void nodeset_to_maximal_elementset(const std::set<int> &nodeSet,
                                       std::set<int> &elemSet) const;

    /** get complement of element set by name */
    void elementset_complement(const std::string &name,
                               std::set<int> &elemSet) const;
    void elementset_complement(const std::set<int> &elemSet,
                               std::set<int> &elemSetComplement) const;

    /** get the node set from an element set by name */
    void elementset_to_minimal_nodeset(const std::string &name,
                                       std::set<int> &nodeSet) const;

    void elementset_to_nodeset(const std::string &name,
                               std::set<int> nodeSet) const;
    void elementset_to_nodeset(const std::set<int> &elemSet,
                               std::set<int> nodeSet) const;
    std::set<int> elementset_to_nodeset(const std::string &name) const;

    /** convert faceset to nodeset in _unique_ node numbering */
    void faceset_to_nodeset(const std::string &name,
                            std::set<int> &nodeSet) const;
    void faceset_to_nodeset(const std::set<PAIR> &faceSet,
                            std::set<int> &nodeSet) const;

    void faceset_to_nodeset_global(const std::string &name,
                                   std::set<int> &nodeSet) const;
    void faceset_to_nodeset_global(const std::set<PAIR> &faceSet,
                                   std::set<int> &nodeSet) const;

    /** get face set from the string name assigned to the set */
    const std::set< std::pair<int,int> > & faceset(const std::string & name) const;

    /** create face set with tag "name" from faces aligned with box */
    void create_faceset(const std::string & name,
                        double xmin, double xmax,
                        double ymin, double ymax,
                        double zmin, double zmax,
                        bool outward);
    /** create face set with tag "name" from faces aligned with plane */
    void create_faceset(const std::string & name, double x, int idir, int isgn,
                        int nIdx2=-1, double x2lo=0.0, double x2hi=0.0,
                        int nIdx3=-1, double x3lo=0.0, double x3hi=0.0);

    /** cut mesh */
    virtual void cut_mesh(const std::set<PAIR> & faceSet, const std::set<int> & nodeSet) = 0;

    /** delete elements */
    virtual void delete_elements(const std::set<int> & elementList) = 0;

    /** return number of spatial dimensions */
    int num_spatial_dimensions() const { return nSD_; }

    /** return total number of nodes */
    int num_nodes() const { return nNodes_; }

    /** return number of unique nodes */
    int num_nodes_unique() const { return nNodesUnique_; }

    /** return number of elements */
    int num_elements() const { return nElts_; }

    /** return number of elements partitioned to my processor */
    int my_num_elements() const { return myNElts_; }

    /** return number of integration points per element */
    int num_ips_per_element() const;

    /** return number of nodes per element */
    int num_nodes_per_element() const;

    /** return number of faces per element */
    int num_faces_per_element() const;

    /** return number of nodes per face */
    int num_nodes_per_face() const;

    /** return number of integration points per face */
    int num_ips_per_face() const;

    /** return a pointer to the connectivity. This function will only work
        when mesh is not partitioned. */
    Array2D<int> * connectivity(void) { return &connectivity_; }
    /** return a pointer to the connectivity */
    DENS_MAT * coordinates(void) { return &nodalCoords_;}
    /** Engine nodeMap stuff  */
    Array<int> *node_map(void) { return &globalToUniqueMap_;}


    /** return scale in x,y,z */
    double xscale() const { return xscale_; }
    double yscale() const { return yscale_; }
    double zscale() const { return zscale_; }

    /** local face connectivity */
    const Array2D<int> & local_face_connectivity() const;

    /** element size in each direction */
    virtual void bounding_box(const int ielem,
                              DENS_VEC & xmin, DENS_VEC & xmax);

    /** element size in each direction */
    virtual void element_size(const int ielem,
                              double & hx, double & hy, double & hz);

    /** element size in each direction */
    virtual double min_element_size(void) const {return 0.0 ;}

    /** get nodal coordinates for a given element */
    void element_field(const int eltIdx, const DENS_MAT f,
                       DENS_MAT &local_field)
    {
      int dof = f.nCols();
      Array<int> nodes;
      element_connectivity_unique(eltIdx,nodes);
      local_field.reset(num_nodes_per_element(), dof);
      for (int i = 0; i < nodes.size(); i++) {
        for (int j = 0; j < dof; j++) local_field(i,j) = f(nodes(i),j);
      }
    }

    /** almost structured */
    bool is_aligned(void) const;

    /** extruded */
    bool is_two_dimensional(void) const {return twoDimensional_;}

   virtual double coordinate_tolerance(void) const {return 1.e-8;}

    /** element type */
    std::string element_type(void) const ;

    /** output mesh subsets */
    void output(std::string prefix) const;

    /* Parallelization data members */

    /** return element vector for this processor */
    const std::vector<int> & owned_elts() const { return myElts_; }
    const std::vector<int> & owned_and_ghost_elts() const {
      return (decomposition_) ? myAndGhostElts_: myElts_; }
    bool is_owned_elt(int elt) const;

  protected:

    void parse_plane(int & argIdx, int narg, char ** arg,
      int & ndir, int * idir, int & isgn, double xlimits[][2]);

    void parse_units(int & argIdx, int narg, char ** arg,
      double & xmin, double & xmax, double & ymin, double & ymax, double & zmin, double & zmax);

    /** will this mesh use data decomposition? */
    bool decomposition_;

    /** should the mesh use the native lammps partitioning? */
    bool lammpsPartition_;

    /** is the element/node data currently partitioned among processors? */
    bool partitioned_;

    /** number of spatial dimensions */
    int nSD_;

    /** number of elements */
    int nElts_;
    /** number of elements partitioned to this processor */
    int myNElts_;

    /** number of nodes */
    int nNodes_;
    int nNodesUnique_;

    /** periodicity flags */
    Array<bool> periodicity_;

    /** element type for this mesh */
    FE_Element *feElement_;

    /** Nodal coordinates: nodalCoords_(nsd, numnode) */
    DENS_MAT nodalCoords_;

    /** Element connectivity: connectivity_(neltnode, nelt) */
    Array2D<int> connectivity_;
    Array2D<int> myConnectivity_;
    Array2D<int> connectivityUnique_;
    Array2D<int> myConnectivityUnique_;

    /** map from unique node id to associated elements for periodic meshes */
    /** this data structure is only ever accessed from an unpartitioned context */
    Array<std::vector<int> > uniqueNodeToElementMap_;

    /** map of global to unique node ID's */
    Array<int> globalToUniqueMap_;
    Array<int> compactRemap_; // for condensing unique numbering

    /** map of unique to global node ID's */
    Array<int> uniqueToGlobalMap_;

    /** map of string names to node sets */
    NODE_SET_MAP nodeSetMap_;

    /** maximal nodeset */
    std::set<int> nodeSetAll_;

    /** map of string names to node sets */
    FACE_SET_MAP faceSetMap_;

    /** map of string names to element sets */
    ELEMENT_SET_MAP elementSetMap_;

    /** maximal elementset */
    std::set<int> elementSetAll_;

    /** length scaling used by lammps */
    double xscale_, yscale_, zscale_;

    /** Processor demarcations */
    std::vector<double> procs_;

    /** Dimension (x=0, y=1, or z=2) */
    int partitionAxis_;

    /** List of nodes for this processor */
    std::vector<int> myNodes_;

    /** List of elements for this processor */
    std::vector<int> myElts_;
    std::vector<int> myAndGhostElts_;

    /** maps between my IDs and the total IDs */
    std::map<int,int> elemToMyElemMap_;

    /** Lists of ghost nodes/neighbor ghost nodes */
    std::vector<int> ghostNodesL_;
    std::vector<int> ghostNodesR_;
    std::vector<int> shareNodesL_;
    std::vector<int> shareNodesR_;

    /** extruded */
    bool twoDimensional_;
    bool hasPlanarFaces_;
    double coordTol_;

  };

  /**
   *  @class  FE_3DMesh
   *  @brief  Derived class for an unstructured 3D mesh
   */
  class FE_3DMesh : public FE_Mesh {
  public:
    /** constructor */
    FE_3DMesh(){};

    /** constructor for read-in mesh **/
    // can later be extended to take nodesets, elementsets, etc.
    FE_3DMesh(const std::string elementType,
              const int nNodes,
              const int nElements,
              const Array2D<int> *connectivity,
              const DENS_MAT *nodalCoordinates,
              const Array<bool> periodicity,
              const Array<std::pair<std::string,std::set<int> > > *nodeSets);

    /** destructor */
    virtual ~FE_3DMesh();

    void partition_mesh(void);

    void departition_mesh(void);

    void lammps_partition_mesh(void);

    /** Removes duplicate elements that appear in more than one vector
         within procEltLists. **/
    void prune_duplicate_elements(std::vector<std::vector<int> > &procEltLists,
                                  int *eltToOwners);

    /** Takes procEltLists, and if there are more than nProcs of them
        it takes the extra elements and distributes them to other vectors
        in procEltLists. */

          //       processors if during pruning processors end up
          //       elementless. This is slightly complicated because of
          //       ghost nodes.
    void redistribute_extra_proclists(std::vector<std::vector<int> > &procEltLists,
                                      int *eltToOwners, int nProcs);

    /** This takes in a dense matrix and a list of elements
        and fills in a standard adjacency list (within the matrix)
        for those elements. **/

          //       the set intersection, which does redundant computations
          //       right now, and filling in the adjacencies for both elements
          //       simultaneously when two elements share a face.
    void compute_face_adjacencies(const std::list<int> &elts,
                                  DENS_MAT &faceAdjacencies);

    /** Counts the number of nonempty vectors in a vector of vectors. **/
    int numNonempty(std::vector<std::vector<int> > &v);

    /**  In the partitioning, we want to sort vectors of integers by size,
          and furthermore we want empty vectors to count as the "largest"
          possible vector because they dont want to count in the minimum. **/
    struct vectorComparer {
        bool operator() (std::vector<int> l, std::vector<int> r) {
          if (l.empty())
            return false;
          if (r.empty())
            return true;
          return (l.size() < r.size());
        }
    } vectorCompSize;

    virtual double min_element_size(void) const {return minEltSize_; }
    virtual double coordinate_tolerance(void) const {
      return 0.25*(this->min_element_size()); // loose
      //return 0.5;
    }
    virtual void cut_mesh(const std::set<PAIR> &faceSet,
                          const std::set<int> &nodeSet);

    virtual void delete_elements(const std::set<int> &elementSet);

    /** map spatial location to element */
    virtual int map_to_element(const DENS_VEC &x) const;

    /** sends out data to processors during partitioning */
    void distribute_mesh_data();
  protected:
    /** create global-to-unique node mapping */
    virtual void setup_periodicity(double tol);
    virtual void setup_periodicity() { setup_periodicity(1.e-8); }
    void fix_periodicity  (int idim);
    int find_boundary_nodes(int idim, std::set<int> & nodes);
    bool match_nodes(int idim, std::set<int> & top, std::set<int> & bot,
                     Array<int> & map);
    void set_unique_connectivity(void);
    bool orient(int idir);

    double minEltSize_;
    KD_Tree *tree_;

    /** test if a specified element actually contains the given point */
    bool contains_point(const int eltID, const DENS_VEC & x) const;

  private:
    Array<std::vector<int> > nodeToParentElements_;

  };

  /**
   *  @class  FE_Rectangular3DMesh
   *  @brief  Derived class for a structured mesh with
   *          variable element sizes in x, y, and z directions
   */
  class FE_Rectangular3DMesh : public FE_3DMesh {
  public:
    /** constructor */
    FE_Rectangular3DMesh(){};
    FE_Rectangular3DMesh(
              const Array<double> & hx,
              const Array<double> & hy,
              const Array<double> & hz,
              const double xmin, const double xmax,
              const double ymin, const double ymax,
              const double zmin, const double zmax,
              const Array<bool> periodicity,
              const double xscale=1,
              const double yscale=1,
              const double zscale=1);

    /** destructor */
    virtual ~FE_Rectangular3DMesh() {};

    void partition_mesh(void);

    void departition_mesh(void);

    /** map spatial location to element */
    virtual int map_to_element(const DENS_VEC &x) const;

  protected:

    /** Number of elements in each spatial direction */
    int n_[3];

    /** Bounds of region on which mesh is defined */
    double borders_[2][3];

    /** Region size in each direction */
    double L_[3];



    /** create global-to-unique node mapping */
    virtual void setup_periodicity(); // note no "tol"

  private: // only used by this class
    /** partitions in x,y,z */
    Array<double> hx_, hy_, hz_;

    /** nodal locations */
    std::vector< Array<double> > x_;
  };

  /**
   *  @class  FE_Uniform3DMesh
   *  @brief  Derived class for a uniform structured mesh with
   *          fixed element sizes in x, y, and z directions
   */
  class FE_Uniform3DMesh : public FE_Rectangular3DMesh {

  public:

    /** constructor */
    FE_Uniform3DMesh(const int nx,
                     const int ny,
                     const int nz,
                     const double xmin, const double xmax,
                     const double ymin, const double ymax,
                     const double zmin, const double zmax,
                     const Array<bool> periodicity,
                     const double xscale=1,
                     const double yscale=1,
                     const double zscale=1);

    /** destructor */
    virtual ~FE_Uniform3DMesh();

    void partition_mesh(void);

    void departition_mesh(void);

    virtual void element_size(const int /* ielem */,
                              double &hx, double &hy, double &hz)
    { hx = L_[0]/n_[0]; hy = L_[1]/n_[1]; hz = L_[2]/n_[2]; }

    virtual double min_element_size(void) const
    { return std::min(L_[0]/n_[0], std::min(L_[1]/n_[1], L_[2]/n_[2])); }

    /** map spatial location to element */
    virtual int map_to_element(const DENS_VEC &x) const;

  private: // only used by this class
    /** Element size in each direction */
    double dx_[3];

  };

} // namespace ATC_Transfer

#endif // FE_MESH_H