MFEM  v3.4
Finite element discretization library
linearform.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_LINEARFORM
13 #define MFEM_LINEARFORM
14 
15 #include "../config/config.hpp"
16 #include "lininteg.hpp"
17 #include "gridfunc.hpp"
18 
19 namespace mfem
20 {
21 
22 /// Class for linear form - Vector with associated FE space and LFIntegrators.
23 class LinearForm : public Vector
24 {
25 private:
26  /// FE space on which LF lives.
27  FiniteElementSpace * fes;
28 
29  /// Set of Domain Integrators to be applied.
31 
32  /// Separate array for integrators with delta function coefficients.
33  Array<DeltaLFIntegrator*> dlfi_delta;
34 
35  /// Set of Boundary Integrators to be applied.
37 
38  /// Set of Boundary Face Integrators to be applied.
40  Array<Array<int>*> flfi_marker;
41 
42  /// The element ids where the centers of the delta functions lie
43  Array<int> dlfi_delta_elem_id;
44 
45  /// The reference coordinates where the centers of the delta functions lie
46  Array<IntegrationPoint> dlfi_delta_ip;
47 
48  /// If true, the delta locations are not (re)computed during assembly.
49  bool HaveDeltaLocations() { return (dlfi_delta_elem_id.Size() != 0); }
50 
51  /// Force (re)computation of delta locations.
52  void ResetDeltaLocations() { dlfi_delta_elem_id.SetSize(0); }
53 
54 public:
55  /// Creates linear form associated with FE space *f.
56  LinearForm (FiniteElementSpace * f) : Vector (f -> GetVSize())
57  { fes = f; }
58 
59  LinearForm() { fes = NULL; }
60 
61  /// (DEPRECATED) Return the FE space associated with the LinearForm.
62  /** @deprecated Use FESpace() instead. */
63  FiniteElementSpace * GetFES() { return fes; }
64 
65  /// Read+write access to the associated FiniteElementSpace.
66  FiniteElementSpace *FESpace() { return fes; }
67  /// Read-only access to the associated FiniteElementSpace.
68  const FiniteElementSpace *FESpace() const { return fes; }
69 
70  /// Adds new Domain Integrator.
72 
73  /// Adds new Boundary Integrator.
75 
76  /// Adds new Boundary Face Integrator.
78 
79  /** @brief Add new Boundary Face Integrator, restricted to the given boundary
80  attributes. */
82  Array<int> &bdr_attr_marker);
83 
84  /// Assembles the linear form i.e. sums over all domain/bdr integrators.
85  void Assemble();
86 
87  /// Assembles delta functions of the linear form
88  void AssembleDelta();
89 
90  void Update() { SetSize(fes->GetVSize()); ResetDeltaLocations(); }
91 
93  { fes = f; SetSize(f->GetVSize()); ResetDeltaLocations(); }
94 
95  void Update(FiniteElementSpace *f, Vector &v, int v_offset);
96 
97  /// Return the action of the LinearForm as a linear mapping.
98  /** Linear forms are linear functionals which map GridFunctions to
99  the real numbers. This method performs this mapping which in
100  this case is equivalent as an inner product of the LinearForm
101  and GridFunction. */
102  double operator()(const GridFunction &gf) const { return (*this)*gf; }
103 
104  /// Destroys linear form.
105  ~LinearForm();
106 };
107 
108 }
109 
110 #endif
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
LinearForm(FiniteElementSpace *f)
Creates linear form associated with FE space *f.
Definition: linearform.hpp:56
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:328
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
Definition: linearform.cpp:51
Abstract base class LinearFormIntegrator.
Definition: lininteg.hpp:22
FiniteElementSpace * FESpace()
Read+write access to the associated FiniteElementSpace.
Definition: linearform.hpp:66
void Update(FiniteElementSpace *f)
Definition: linearform.hpp:92
void AddBdrFaceIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Face Integrator.
Definition: linearform.cpp:38
void AddBoundaryIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Integrator.
Definition: linearform.cpp:33
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator.
Definition: linearform.cpp:19
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:66
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
Definition: array.hpp:569
double operator()(const GridFunction &gf) const
Return the action of the LinearForm as a linear mapping.
Definition: linearform.hpp:102
void AssembleDelta()
Assembles delta functions of the linear form.
Definition: linearform.cpp:143
~LinearForm()
Destroys linear form.
Definition: linearform.cpp:183
const FiniteElementSpace * FESpace() const
Read-only access to the associated FiniteElementSpace.
Definition: linearform.hpp:68
int GetVSize() const
Return the number of vector dofs, i.e. GetNDofs() x GetVDim().
Definition: fespace.hpp:253
int Size() const
Logical size of the array.
Definition: array.hpp:133
Vector data type.
Definition: vector.hpp:48
Class for linear form - Vector with associated FE space and LFIntegrators.
Definition: linearform.hpp:23
FiniteElementSpace * GetFES()
(DEPRECATED) Return the FE space associated with the LinearForm.
Definition: linearform.hpp:63