MFEM  v4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pumi.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_PUMI
13 #define MFEM_PUMI
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_PUMI
18 #ifdef MFEM_USE_MPI
19 
20 #include "../fem/fespace.hpp"
21 #include "../fem/gridfunc.hpp"
22 #include "../fem/pgridfunc.hpp"
23 #include "../fem/coefficient.hpp"
24 #include "../fem/bilininteg.hpp"
25 
26 #include <iostream>
27 #include <limits>
28 #include <ostream>
29 #include <string>
30 #include "mesh.hpp"
31 #include "pmesh.hpp"
32 
33 #include <pumi.h>
34 #include <apf.h>
35 #include <apfMesh2.h>
36 #include <apfShape.h>
37 #include <apfNumbering.h>
38 #include <apfDynamicVector.h>
39 
40 namespace mfem
41 {
42 
43 /// Base class for PUMI meshes
44 class PumiMesh : public Mesh
45 {
46 protected:
47  Element *ReadElement(apf::MeshEntity* Ent, const int geom, apf::Downward Verts,
48  const int Attr, apf::Numbering* vert_num);
49  void CountBoundaryEntity(apf::Mesh2* apf_mesh, const int BcDim, int &NumBC);
50 
51  // Readers for PUMI mesh formats, used in the Load() method.
52  void ReadSCORECMesh(apf::Mesh2* apf_mesh, apf::Numbering* v_num_loc,
53  const int curved);
54 
55 public:
56  /// Generate an MFEM mesh from a PUMI mesh.
57  PumiMesh(apf::Mesh2* apf_mesh, int generate_edges = 0, int refine = 1,
58  bool fix_orientation = true);
59 
60  using Mesh::Load;
61 
62  /// Load a PUMI mesh (following the steps in the MFEM Load function).
63  void Load(apf::Mesh2* apf_mesh, int generate_edges = 0, int refine = 1,
64  bool fix_orientation = true);
65 
66  /// Destroys Mesh.
67  virtual ~PumiMesh() { }
68 };
69 
70 
71 /// Class for PUMI parallel meshes
72 class ParPumiMesh : public ParMesh
73 {
74 private:
75  apf::Numbering* v_num_loc;
76 
77 protected:
78  Element *ReadElement(apf::MeshEntity* Ent, const int geom, apf::Downward Verts,
79  const int Attr, apf::Numbering* vert_num);
80 
81 public:
82  /// Build a parallel MFEM mesh from a parallel PUMI mesh.
83  ParPumiMesh(MPI_Comm comm, apf::Mesh2* apf_mesh);
84 
85  /// Transfer field from MFEM mesh to PUMI mesh [Mixed].
86  void FieldMFEMtoPUMI(apf::Mesh2* apf_mesh,
87  ParGridFunction* Vel,
88  ParGridFunction* Pr,
89  apf::Field* VelField,
90  apf::Field* PrField,
91  apf::Field* VelMagField);
92 
93  /// Transfer field from MFEM mesh to PUMI mesh [Scalar].
94  void FieldMFEMtoPUMI(apf::Mesh2* apf_mesh,
95  ParGridFunction* Pr,
96  apf::Field* PrField,
97  apf::Field* PrMagField);
98 
99  /// Transfer field from MFEM mesh to PUMI mesh [Vector].
100  void VectorFieldMFEMtoPUMI(apf::Mesh2* apf_mesh,
101  ParGridFunction* Vel,
102  apf::Field* VelField,
103  apf::Field* VelMagField);
104 
105  /// Update the mesh after adaptation.
106  void UpdateMesh(const ParMesh* AdaptedpMesh);
107 
108  /// Transfer a field from PUMI to MFEM after mesh adapt [Scalar].
109  void FieldPUMItoMFEM(apf::Mesh2* apf_mesh,
110  apf::Field* ScalarField,
111  ParGridFunction* Pr);
112 
113  virtual ~ParPumiMesh() { }
114 };
115 
116 
117 /// Class for PUMI grid functions
119 {
120 public:
121  /// Construct a GridFunction from a PUMI mesh.
122  GridFunctionPumi(Mesh* m, apf::Mesh2* PumiM, apf::Numbering* v_num_loc,
123  const int mesh_order);
124 
125  /// Destroy the grid function.
126  virtual ~GridFunctionPumi() { }
127 };
128 
129 } // namespace mfem
130 
131 #endif // MFEM_USE_MPI
132 #endif // MFEM_USE_PUMI
133 
134 #endif
void FieldPUMItoMFEM(apf::Mesh2 *apf_mesh, apf::Field *ScalarField, ParGridFunction *Pr)
Transfer a field from PUMI to MFEM after mesh adapt [Scalar].
Definition: pumi.cpp:1555
void UpdateMesh(const ParMesh *AdaptedpMesh)
Update the mesh after adaptation.
Definition: pumi.cpp:766
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
const Geometry::Type geom
Definition: ex1.cpp:40
PumiMesh(apf::Mesh2 *apf_mesh, int generate_edges=0, int refine=1, bool fix_orientation=true)
Generate an MFEM mesh from a PUMI mesh.
Definition: pumi.cpp:36
Class for PUMI grid functions.
Definition: pumi.hpp:118
Base class for PUMI meshes.
Definition: pumi.hpp:44
Element * ReadElement(apf::MeshEntity *Ent, const int geom, apf::Downward Verts, const int Attr, apf::Numbering *vert_num)
Definition: pumi.cpp:42
void VectorFieldMFEMtoPUMI(apf::Mesh2 *apf_mesh, ParGridFunction *Vel, apf::Field *VelField, apf::Field *VelMagField)
Transfer field from MFEM mesh to PUMI mesh [Vector].
Definition: pumi.cpp:1349
Class for PUMI parallel meshes.
Definition: pumi.hpp:72
virtual void Load(std::istream &input, int generate_edges=0, int refine=1, bool fix_orientation=true)
Definition: mesh.hpp:650
void FieldMFEMtoPUMI(apf::Mesh2 *apf_mesh, ParGridFunction *Vel, ParGridFunction *Pr, apf::Field *VelField, apf::Field *PrField, apf::Field *VelMagField)
Transfer field from MFEM mesh to PUMI mesh [Mixed].
Definition: pumi.cpp:928
void CountBoundaryEntity(apf::Mesh2 *apf_mesh, const int BcDim, int &NumBC)
Definition: pumi.cpp:66
Element * ReadElement(apf::MeshEntity *Ent, const int geom, apf::Downward Verts, const int Attr, apf::Numbering *vert_num)
Definition: pumi.cpp:244
virtual ~PumiMesh()
Destroys Mesh.
Definition: pumi.hpp:67
ParPumiMesh(MPI_Comm comm, apf::Mesh2 *apf_mesh)
Build a parallel MFEM mesh from a parallel PUMI mesh.
Definition: pumi.cpp:270
void Load(apf::Mesh2 *apf_mesh, int generate_edges=0, int refine=1, bool fix_orientation=true)
Load a PUMI mesh (following the steps in the MFEM Load function).
Definition: pumi.cpp:89
virtual ~ParPumiMesh()
Definition: pumi.hpp:113
void ReadSCORECMesh(apf::Mesh2 *apf_mesh, apf::Numbering *v_num_loc, const int curved)
Definition: pumi.cpp:155
Class for parallel grid function.
Definition: pgridfunc.hpp:32
GridFunctionPumi(Mesh *m, apf::Mesh2 *PumiM, apf::Numbering *v_num_loc, const int mesh_order)
Construct a GridFunction from a PUMI mesh.
Definition: pumi.cpp:697
Class for parallel meshes.
Definition: pmesh.hpp:32
Abstract data type element.
Definition: element.hpp:28
virtual ~GridFunctionPumi()
Destroy the grid function.
Definition: pumi.hpp:126