MFEM  v3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
pgridfunc.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.googlecode.com.
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_PGRIDFUNC
13 #define MFEM_PGRIDFUNC
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "pfespace.hpp"
20 #include "gridfunc.hpp"
21 #include <iostream>
22 #include <limits>
23 
24 namespace mfem
25 {
26 
28 double GlobalLpNorm(const double p, double loc_norm, MPI_Comm comm);
29 
32 {
33 protected:
35 
37 
38 public:
39  ParGridFunction() { pfes = NULL; }
40 
42 
46 
50 
53  ParGridFunction(ParMesh *pmesh, GridFunction *gf, int * partitioning = NULL);
54 
55  ParGridFunction &operator=(double value)
56  { GridFunction::operator=(value); return *this; }
57 
59  { GridFunction::operator=(v); return *this; }
60 
62 
64 
65  void Update(ParFiniteElementSpace *f, Vector &v, int v_offset);
66 
69  void Distribute(const Vector *tv);
70  void Distribute(const Vector &tv) { Distribute(&tv); }
71 
74  { Distribute(&tv); return (*this); }
75 
77  void GetTrueDofs(Vector &tv) const;
78 
80  HypreParVector *GetTrueDofs() const;
81 
83  void ParallelAverage(Vector &tv) const;
84 
86  void ParallelAverage(HypreParVector &tv) const;
87 
90 
92  void ParallelAssemble(Vector &tv) const;
93 
95  void ParallelAssemble(HypreParVector &tv) const;
96 
99 
100  void ExchangeFaceNbrData();
102  const Vector &FaceNbrData() const { return face_nbr_data; }
103 
104  // Redefine to handle the case when i is a face-neighbor element
105  virtual double GetValue(int i, const IntegrationPoint &ip,
106  int vdim = 1) const;
108  { return GetValue(T.ElementNo, T.GetIntPoint()); }
109 
111  void ProjectCoefficient(Coefficient &coeff);
112 
113  double ComputeL1Error(Coefficient *exsol[],
114  const IntegrationRule *irs[] = NULL) const
115  {
117  *exsol, NULL, 1, NULL, irs), pfes->GetComm());
118  }
119 
121  const IntegrationRule *irs[] = NULL) const
122  { return ComputeLpError(1.0, exsol, NULL, irs); }
123 
125  const IntegrationRule *irs[] = NULL) const
126  { return ComputeLpError(1.0, exsol, NULL, NULL, irs); }
127 
128  double ComputeL2Error(Coefficient *exsol[],
129  const IntegrationRule *irs[] = NULL) const
130  { return GlobalLpNorm(2.0, GridFunction::ComputeL2Error(exsol, irs), pfes->GetComm()); }
131 
133  const IntegrationRule *irs[] = NULL) const
134  { return ComputeLpError(2.0, exsol, NULL, irs); }
135 
137  const IntegrationRule *irs[] = NULL,
138  Array<int> *elems = NULL) const
139  {
140  return GlobalLpNorm(2.0, GridFunction::ComputeL2Error(exsol, irs, elems), pfes->GetComm());
141  }
142 
143  double ComputeMaxError(Coefficient *exsol[],
144  const IntegrationRule *irs[] = NULL) const
145  {
146  return GlobalLpNorm(std::numeric_limits<double>::infinity(),
147  GridFunction::ComputeMaxError(exsol, irs), pfes->GetComm());
148  }
149 
151  const IntegrationRule *irs[] = NULL) const
152  {
153  return ComputeLpError(std::numeric_limits<double>::infinity(),
154  exsol, NULL, irs);
155  }
156 
158  const IntegrationRule *irs[] = NULL) const
159  {
160  return ComputeLpError(std::numeric_limits<double>::infinity(),
161  exsol, NULL, NULL, irs);
162  }
163 
164  double ComputeLpError(const double p, Coefficient &exsol,
165  Coefficient *weight = NULL,
166  const IntegrationRule *irs[] = NULL) const
167  {
169  p, exsol, weight, irs), pfes->GetComm());
170  }
171 
175  double ComputeLpError(const double p, VectorCoefficient &exsol,
176  Coefficient *weight = NULL,
177  VectorCoefficient *v_weight = NULL,
178  const IntegrationRule *irs[] = NULL) const
179  {
181  p, exsol, weight, v_weight, irs), pfes->GetComm());
182  }
183 
187  virtual void Save(std::ostream &out) const;
188 
190  void SaveAsOne(std::ostream &out = std::cout);
191 
192  virtual ~ParGridFunction() { }
193 };
194 
195 }
196 
197 #endif // MFEM_USE_MPI
198 
199 #endif
Class for integration rule.
Definition: intrules.hpp:63
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:26
void SaveAsOne(std::ostream &out=std::cout)
Merge the local grid functions.
Definition: pgridfunc.cpp:263
double ComputeL2Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:128
HypreParVector * ParallelAssemble() const
Returns a new vector assembled on the true dofs.
Definition: pgridfunc.cpp:139
virtual ~ParGridFunction()
Definition: pgridfunc.hpp:192
ParFiniteElementSpace * pfes
Definition: pgridfunc.hpp:34
ParGridFunction & operator=(const HypreParVector &tv)
Short semantic for Distribute.
Definition: pgridfunc.hpp:73
ParGridFunction(ParFiniteElementSpace *pf)
Definition: pgridfunc.hpp:41
virtual double GetValue(int i, const IntegrationPoint &ip, int vdim=1) const
Definition: pgridfunc.cpp:193
virtual void Save(std::ostream &out) const
Definition: pgridfunc.cpp:250
Abstract parallel finite element space.
Definition: pfespace.hpp:28
void ProjectCoefficient(Coefficient &coeff)
Definition: pgridfunc.cpp:229
const IntegrationPoint & GetIntPoint()
Definition: eltrans.hpp:35
ParFiniteElementSpace * ParFESpace()
Definition: pgridfunc.hpp:61
void Distribute(const Vector &tv)
Definition: pgridfunc.hpp:70
double GetValue(ElementTransformation &T)
Definition: pgridfunc.hpp:107
double ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: gridfunc.hpp:181
double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: gridfunc.hpp:166
ParGridFunction & operator=(double value)
Definition: pgridfunc.hpp:55
const Vector & FaceNbrData() const
Definition: pgridfunc.hpp:102
double ComputeMaxError(VectorCoefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:157
double ComputeLpError(const double p, VectorCoefficient &exsol, Coefficient *weight=NULL, VectorCoefficient *v_weight=NULL, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:175
double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
Definition: gridfunc.cpp:1593
double ComputeL1Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:120
double ComputeL1Error(VectorCoefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:124
ParGridFunction & operator=(const Vector &v)
Definition: pgridfunc.hpp:58
Vector & FaceNbrData()
Definition: pgridfunc.hpp:101
Wrapper for hypre&#39;s parallel vector class.
Definition: hypre.hpp:38
double GlobalLpNorm(const double p, double loc_norm, MPI_Comm comm)
Compute a global Lp norm from the local Lp norms computed by each processor.
Definition: pgridfunc.cpp:376
Base class Coefficient that may optionally depend on time.
Definition: coefficient.hpp:31
double ComputeMaxError(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:143
void Distribute(const Vector *tv)
Definition: pgridfunc.cpp:78
double ComputeL2Error(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:132
Class for integration point with weight.
Definition: intrules.hpp:25
double ComputeLpError(const double p, Coefficient &exsol, Coefficient *weight=NULL, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:164
HypreParVector * ParallelAverage() const
Returns a new vector averaged on the true dofs.
Definition: pgridfunc.cpp:122
double ComputeL2Error(VectorCoefficient &exsol, const IntegrationRule *irs[]=NULL, Array< int > *elems=NULL) const
Definition: pgridfunc.hpp:136
HypreParVector * GetTrueDofs() const
Returns the true dofs in a new HypreParVector.
Definition: pgridfunc.cpp:103
void ProjectCoefficient(Coefficient &coeff)
Definition: gridfunc.cpp:967
double ComputeW11Error(Coefficient *exsol, VectorCoefficient *exgrad, int norm_type, Array< int > *elems=NULL, const IntegrationRule *irs[]=NULL) const
Definition: gridfunc.cpp:1503
GridFunction & operator=(double value)
Redefine &#39;=&#39; for GridFunction = constant.
Definition: gridfunc.cpp:1731
Vector data type.
Definition: vector.hpp:29
Class for parallel grid function.
Definition: pgridfunc.hpp:31
Class for parallel meshes.
Definition: pmesh.hpp:27
double ComputeL1Error(Coefficient *exsol[], const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:113
double ComputeMaxError(Coefficient &exsol, const IntegrationRule *irs[]=NULL) const
Definition: pgridfunc.hpp:150