MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
plinearform.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, Lawrence Livermore National Security, LLC. Produced
2// at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3// LICENSE and NOTICE for details. LLNL-CODE-806117.
4//
5// This file is part of the MFEM library. For more information and source code
6// availability visit https://mfem.org.
7//
8// MFEM is free software; you can redistribute it and/or modify it under the
9// terms of the BSD-3 license. We welcome feedback and contributions, see file
10// CONTRIBUTING.md for details.
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
22namespace mfem
23{
24
25/// Class for parallel linear form
27{
28protected:
29 ParFiniteElementSpace *pfes; ///< Points to the same object as #fes
30
31private:
32 /// Copy construction is not supported; body is undefined.
34
35public:
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 /// Construct a ParLinearForm using previously allocated array @a data.
49 /** The ParLinearForm does not assume ownership of @a data which is assumed
50 to be of size at least `pf->GetVSize()`. Similar to the LinearForm and
51 Vector constructors for externally allocated array, the pointer @a data
52 can be NULL. The data array can be replaced later using the method
53 SetData(). */
56
57 /** @brief Create a ParLinearForm on the ParFiniteElementSpace @a *pf, using
58 the same integrators as the ParLinearForm @a *plf.
59
60 The pointer @a pf is not owned by the newly constructed object.
61
62 The integrators in @a plf are copied as pointers and they are not owned
63 by the newly constructed LinearForm. */
66
67 /// Copy assignment. Only the data of the base class Vector is copied.
68 /** It is assumed that this object and @a rhs use ParFiniteElementSpace%s
69 that have the same size.
70
71 @note Defining this method overwrites the implicitly defined copy
72 assignment operator. */
74 { return operator=((const Vector &)rhs); }
75
77
78 /// Update the object according to the given new FE space @a *pf.
79 /** If the pointer @a pf is NULL (this is the default value), the FE space
80 already associated with this object is used.
81
82 This method should be called when the associated FE space #fes has been
83 updated, e.g. after its associated Mesh object has been refined.
84
85 @note This method does not perform assembly. */
86 void Update(ParFiniteElementSpace *pf = NULL);
87
88 /** @brief Associate a new FE space, @a *pf, with this object and use the
89 data of @a v, offset by @a v_offset, to initialize this object's
90 Vector::data.
91
92 @note This method does not perform assembly. */
93 void Update(ParFiniteElementSpace *pf, Vector &v, int v_offset);
94
95
96 /** @brief Make the ParLinearForm reference external data on a new
97 FiniteElementSpace. */
98 /** This method changes the FiniteElementSpace associated with the
99 ParLinearForm to @a *f and sets the data of the Vector @a v (plus the @a
100 v_offset) as external data in the ParLinearForm.
101
102 @note This version of the method will also perform bounds checks when the
103 build option MFEM_DEBUG is enabled. */
104 virtual void MakeRef(FiniteElementSpace *f, Vector &v, int v_offset);
105
106 /** @brief Make the ParLinearForm reference external data on a new
107 ParFiniteElementSpace. */
108 /** This method changes the ParFiniteElementSpace associated with the
109 ParLinearForm to @a *pf and sets the data of the Vector @a v (plus the @a
110 v_offset) as external data in the ParLinearForm.
111
112 @note This version of the method will also perform bounds checks when the
113 build option MFEM_DEBUG is enabled. */
114 void MakeRef(ParFiniteElementSpace *pf, Vector &v, int v_offset);
115
116 /// Assembles the ParLinearForm i.e. sums over all domain/bdr integrators.
117 /** When @ref LinearForm::UseFastAssembly "UseFastAssembly(true)" has been
118 called and the linear form assembly is compatible with device execution,
119 the assembly will be executed on the device. */
120 void Assemble();
121
122 /// Return true if assembly on device is supported, false otherwise.
123 virtual bool SupportsDevice() const;
124
125 void AssembleSharedFaces();
126
127 /// Assemble the vector on the true dofs, i.e. P^t v.
128 void ParallelAssemble(Vector &tv);
129
130 /// Returns the vector assembled on the true dofs, i.e. P^t v.
132
133 /// Return the action of the ParLinearForm as a linear mapping.
134 /** Linear forms are linear functionals which map ParGridFunction%s to the
135 real numbers. This method performs this mapping which in this case is
136 equivalent as an inner product of the ParLinearForm and
137 ParGridFunction. */
139 {
140 return InnerProduct(pfes->GetComm(), *this, gf);
141 }
142
143 /// Assign constant values to the ParLinearForm data.
145 { LinearForm::operator=(value); return *this; }
146
147 /// Copy the data from a Vector to the ParLinearForm data.
149 { LinearForm::operator=(v); return *this; }
150};
151
152}
153
154#endif // MFEM_USE_MPI
155
156#endif
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:220
Wrapper for hypre's parallel vector class.
Definition hypre.hpp:206
Vector with associated FE space and LinearFormIntegrators.
LinearForm & operator=(const LinearForm &rhs)
Copy assignment. Only the data of the base class Vector is copied.
void Update()
Update the object according to the associated FE space fes.
Abstract parallel finite element space.
Definition pfespace.hpp:29
MPI_Comm GetComm() const
Definition pfespace.hpp:273
Class for parallel grid function.
Definition pgridfunc.hpp:33
Class for parallel linear form.
real_t operator()(const ParGridFunction &gf) const
Return the action of the ParLinearForm as a linear mapping.
virtual bool SupportsDevice() const
Return true if assembly on device is supported, false otherwise.
HypreParVector * ParallelAssemble()
Returns the vector assembled on the true dofs, i.e. P^t v.
ParLinearForm(ParFiniteElementSpace *pf, real_t *data)
Construct a ParLinearForm using previously allocated array data.
ParLinearForm(ParFiniteElementSpace *pf)
Create a ParLinearForm on the FE space *pf.
ParLinearForm(ParFiniteElementSpace *pf, ParLinearForm *plf)
Create a ParLinearForm on the ParFiniteElementSpace *pf, using the same integrators as the ParLinearF...
virtual void MakeRef(FiniteElementSpace *f, Vector &v, int v_offset)
Make the ParLinearForm reference external data on a new FiniteElementSpace.
ParFiniteElementSpace * pfes
Points to the same object as fes.
void Assemble()
Assembles the ParLinearForm i.e. sums over all domain/bdr integrators.
ParLinearForm & operator=(const ParLinearForm &rhs)
Copy assignment. Only the data of the base class Vector is copied.
ParFiniteElementSpace * ParFESpace() const
ParLinearForm & operator=(const Vector &v)
Copy the data from a Vector to the ParLinearForm data.
ParLinearForm & operator=(real_t value)
Assign constant values to the ParLinearForm data.
ParLinearForm()
Create an empty ParLinearForm without an associated ParFiniteElementSpace.
Vector data type.
Definition vector.hpp:80
Memory< real_t > data
Definition vector.hpp:83
real_t InnerProduct(HypreParVector *x, HypreParVector *y)
Definition hypre.cpp:439
float real_t
Definition config.hpp:43
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30