MFEM  v3.3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fem_extras.cpp
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 #include "fem_extras.hpp"
13 
14 using namespace std;
15 
16 namespace mfem
17 {
18 
19 namespace miniapps
20 {
21 
22 H1_FESpace::H1_FESpace(Mesh *m,
23  const int p, const int space_dim, const int type,
24  int vdim, int order)
25  : FiniteElementSpace(m, new H1_FECollection(p,space_dim,type),vdim,order)
26 {
27  FEC_ = this->FiniteElementSpace::fec;
28 }
29 
31 {
32  delete FEC_;
33 }
34 
35 ND_FESpace::ND_FESpace(Mesh *m, const int p, const int space_dim,
36  int vdim, int order)
37  : FiniteElementSpace(m, new ND_FECollection(p,space_dim),vdim,order)
38 {
39  FEC_ = this->FiniteElementSpace::fec;
40 }
41 
43 {
44  delete FEC_;
45 }
46 
47 RT_FESpace::RT_FESpace(Mesh *m, const int p, const int space_dim,
48  int vdim, int order)
49  : FiniteElementSpace(m, new RT_FECollection(p-1,space_dim),vdim,order)
50 {
51  FEC_ = this->FiniteElementSpace::fec;
52 }
53 
55 {
56  delete FEC_;
57 }
58 
59 void VisualizeField(socketstream &sock, const char *vishost, int visport,
60  GridFunction &gf, const char *title,
61  int x, int y, int w, int h, bool vec)
62 {
63  Mesh &mesh = *gf.FESpace()->GetMesh();
64 
65  bool newly_opened = false;
66  int connection_failed;
67 
68  do
69  {
70  if (!sock.is_open() || !sock)
71  {
72  sock.open(vishost, visport);
73  sock.precision(8);
74  newly_opened = true;
75  }
76  sock << "solution\n";
77 
78  mesh.Print(sock);
79  gf.Save(sock);
80 
81  if (newly_opened)
82  {
83  sock << "window_title '" << title << "'\n"
84  << "window_geometry "
85  << x << " " << y << " " << w << " " << h << "\n"
86  << "keys maaAc";
87  if ( vec ) { sock << "vvv"; }
88  sock << endl;
89  }
90 
91  connection_failed = !sock && !newly_opened;
92  }
93  while (connection_failed);
94 }
95 
96 } // namespace miniapps
97 
98 } // namespace mfem
RT_FESpace(Mesh *m, const int p, const int space_dim, int vdim=1, int order=Ordering::byNODES)
Definition: fem_extras.cpp:47
virtual void Print(std::ostream &out=mfem::out) const
Definition: mesh.hpp:1019
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
ND_FESpace(Mesh *m, const int p, const int space_dim, int vdim=1, int order=Ordering::byNODES)
Definition: fem_extras.cpp:35
const FiniteElementCollection * fec
Definition: fespace.hpp:66
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
Definition: gridfunc.cpp:2259
Mesh * GetMesh() const
Returns the mesh.
Definition: fespace.hpp:136
void VisualizeField(socketstream &sock, const char *vishost, int visport, GridFunction &gf, const char *title, int x, int y, int w, int h, bool vec)
Definition: fem_extras.cpp:59
FiniteElementSpace * FESpace()
Definition: gridfunc.hpp:309
Arbitrary order H(div)-conforming Raviart-Thomas finite elements.
Definition: fe_coll.hpp:239
int open(const char hostname[], int port)
Arbitrary order H(curl)-conforming Nedelec finite elements.
Definition: fe_coll.hpp:297
Arbitrary order H1-conforming (continuous) finite elements.
Definition: fe_coll.hpp:146