MFEM  v4.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
plinearform.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_PLINEARFORM
13 #define MFEM_PLINEARFORM
14 
15 #include "../config/config.hpp"
16 
17 #ifdef MFEM_USE_MPI
18 
19 #include "pgridfunc.hpp"
20 #include "linearform.hpp"
21 
22 namespace mfem
23 {
24 
25 /// Class for parallel linear form
26 class ParLinearForm : public LinearForm
27 {
28 protected:
29  ParFiniteElementSpace *pfes; ///< Points to the same object as #fes
30 
31 private:
32  /// Copy construction is not supported; body is undefined.
34 
35 public:
36  /** @brief Create an empty ParLinearForm without an associated
37  ParFiniteElementSpace.
38 
39  The associated ParFiniteElementSpace can be set later using one of the
40  methods: Update(ParFiniteElementSpace *) or
41  Update(ParFiniteElementSpace *, Vector &, int). */
42  ParLinearForm() : LinearForm() { pfes = NULL; }
43 
44  /// Create a ParLinearForm on the FE space @a *pf.
45  /** The pointer @a pf is not owned by the newly constructed object. */
47 
48  /** @brief Create a ParLinearForm on the ParFiniteElementSpace @a *pf, using
49  the same integrators as the ParLinearForm @a *plf.
50 
51  The pointer @a pf is not owned by the newly constructed object.
52 
53  The integrators in @a plf are copied as pointers and they are not owned
54  by the newly constructed LinearForm. */
56  : LinearForm(pf, plf) { pfes = pf; }
57 
58  /// Copy assignment. Only the data of the base class Vector is copied.
59  /** It is assumed that this object and @a rhs use ParFiniteElementSpace%s
60  that have the same size.
61 
62  @note Defining this method overwrites the implicitly defined copy
63  assignemnt operator. */
65  { return operator=((const Vector &)rhs); }
66 
67  ParFiniteElementSpace *ParFESpace() const { return pfes; }
68 
69  /// Update the object according to the given new FE space @a *pf.
70  /** If the pointer @a pf is NULL (this is the default value), the FE space
71  already associated with this object is used.
72 
73  This method should be called when the asscociated FE space #fes has been
74  updated, e.g. after its associated Mesh object has been refined.
75 
76  @note This method does not perform assembly. */
77  void Update(ParFiniteElementSpace *pf = NULL);
78 
79  /** @brief Associate a new FE space, @a *pf, with this object and use the
80  data of @a v, offset by @a v_offset, to initialize this object's
81  Vector::data.
82 
83  @note This method does not perform assembly. */
84  void Update(ParFiniteElementSpace *pf, Vector &v, int v_offset);
85 
86  /// Assemble the vector on the true dofs, i.e. P^t v.
87  void ParallelAssemble(Vector &tv);
88 
89  /// Returns the vector assembled on the true dofs, i.e. P^t v.
91 
92  /// Return the action of the ParLinearForm as a linear mapping.
93  /** Linear forms are linear functionals which map ParGridFunction%s to
94  the real numbers. This method performs this mapping which in
95  this case is equivalent as an inner product of the ParLinearForm
96  and ParGridFunction. */
97  double operator()(const ParGridFunction &gf) const
98  {
99  return InnerProduct(pfes->GetComm(), *this, gf);
100  }
101 
102  /// Assign constant values to the ParLinearForm data.
103  ParLinearForm &operator=(double value)
104  { LinearForm::operator=(value); return *this; }
105 
106  /// Copy the data from a Vector to the ParLinearForm data.
108  { LinearForm::operator=(v); return *this; }
109 };
110 
111 }
112 
113 #endif // MFEM_USE_MPI
114 
115 #endif
LinearForm & operator=(const LinearForm &rhs)
Copy assignment. Only the data of the base class Vector is copied.
Definition: linearform.hpp:90
ParLinearForm & operator=(const ParLinearForm &rhs)
Copy assignment. Only the data of the base class Vector is copied.
Definition: plinearform.hpp:64
Abstract parallel finite element space.
Definition: pfespace.hpp:28
ParLinearForm()
Create an empty ParLinearForm without an associated ParFiniteElementSpace.
Definition: plinearform.hpp:42
Class for parallel linear form.
Definition: plinearform.hpp:26
MPI_Comm GetComm() const
Definition: pfespace.hpp:239
ParFiniteElementSpace * ParFESpace() const
Definition: plinearform.hpp:67
double operator()(const ParGridFunction &gf) const
Return the action of the ParLinearForm as a linear mapping.
Definition: plinearform.hpp:97
Wrapper for hypre&#39;s parallel vector class.
Definition: hypre.hpp:73
HypreParVector * ParallelAssemble()
Returns the vector assembled on the true dofs, i.e. P^t v.
Definition: plinearform.cpp:39
void Update()
Update the object according to the associated FE space fes.
Definition: linearform.hpp:158
double InnerProduct(HypreParVector *x, HypreParVector *y)
Definition: hypre.cpp:253
ParLinearForm & operator=(const Vector &v)
Copy the data from a Vector to the ParLinearForm data.
ParLinearForm(ParFiniteElementSpace *pf)
Create a ParLinearForm on the FE space *pf.
Definition: plinearform.hpp:46
ParLinearForm(ParFiniteElementSpace *pf, ParLinearForm *plf)
Create a ParLinearForm on the ParFiniteElementSpace *pf, using the same integrators as the ParLinearF...
Definition: plinearform.hpp:55
ParFiniteElementSpace * pfes
Points to the same object as fes.
Definition: plinearform.hpp:29
Vector data type.
Definition: vector.hpp:48
Class for linear form - Vector with associated FE space and LFIntegrators.
Definition: linearform.hpp:23
Class for parallel grid function.
Definition: pgridfunc.hpp:32
ParLinearForm & operator=(double value)
Assign constant values to the ParLinearForm data.