MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
linearform.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 // Implementation of class LinearForm
13 
14 #include "fem.hpp"
15 
16 namespace mfem
17 {
18 
20 {
21  dlfi.Append (lfi);
22 }
23 
25 {
26  blfi.Append (lfi);
27 }
28 
30 {
31  flfi.Append (lfi);
32 }
33 
35 {
36  Array<int> vdofs;
37  ElementTransformation *eltrans;
38  Vector elemvect;
39 
40  int i;
41 
42  Vector::operator=(0.0);
43 
44  if (dlfi.Size())
45  for (i = 0; i < fes -> GetNE(); i++)
46  {
47  fes -> GetElementVDofs (i, vdofs);
48  eltrans = fes -> GetElementTransformation (i);
49  for (int k=0; k < dlfi.Size(); k++)
50  {
51  dlfi[k]->AssembleRHSElementVect(*fes->GetFE(i), *eltrans, elemvect);
52  AddElementVector (vdofs, elemvect);
53  }
54  }
55 
56  if (blfi.Size())
57  for (i = 0; i < fes -> GetNBE(); i++)
58  {
59  fes -> GetBdrElementVDofs (i, vdofs);
60  eltrans = fes -> GetBdrElementTransformation (i);
61  for (int k=0; k < blfi.Size(); k++)
62  {
63  blfi[k]->AssembleRHSElementVect(*fes->GetBE(i), *eltrans, elemvect);
64  AddElementVector (vdofs, elemvect);
65  }
66  }
67 
68  if (flfi.Size())
69  {
71  Mesh *mesh = fes -> GetMesh();
72  for (i = 0; i < mesh -> GetNBE(); i++)
73  {
74  tr = mesh -> GetBdrFaceTransformations (i);
75  if (tr != NULL)
76  {
77  fes -> GetElementVDofs (tr -> Elem1No, vdofs);
78  for (int k = 0; k < flfi.Size(); k++)
79  {
80  flfi[k] -> AssembleRHSElementVect (*fes->GetFE(tr -> Elem1No),
81  *tr, elemvect);
82  AddElementVector (vdofs, elemvect);
83  }
84  }
85  }
86  }
87 }
88 
90 {
91  const SparseMatrix *P = fes->GetConformingProlongation();
92  if (P)
93  {
94  b.SetSize(P->Width());
95  P->MultTranspose(*this, b);
96  return;
97  }
98 
99  b = *this;
100 }
101 
103 {
104  if (fes->Nonconforming())
105  {
106  Vector b;
108  static_cast<Vector&>(*this) = b;
109  }
110 }
111 
112 void LinearForm::Update(FiniteElementSpace *f, Vector &v, int v_offset)
113 {
114  fes = f;
115  NewDataAndSize((double *)v + v_offset, fes->GetVSize());
116 }
117 
119 {
120  int k;
121  for (k=0; k < dlfi.Size(); k++) { delete dlfi[k]; }
122  for (k=0; k < blfi.Size(); k++) { delete blfi[k]; }
123  for (k=0; k < flfi.Size(); k++) { delete flfi[k]; }
124 }
125 
126 }
int GetVSize() const
Definition: fespace.hpp:164
void NewDataAndSize(double *d, int s)
Definition: vector.hpp:72
void ConformingAssemble()
Apply the conforming interpolation matrix to &#39;this&#39;: this = P&#39;*this.
Definition: linearform.cpp:102
void SetSize(int s)
Resizes the vector if the new size is different.
Definition: vector.hpp:259
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols.
Definition: operator.hpp:41
void Assemble()
Assembles the linear form i.e. sums over all domain/bdr integrators.
Definition: linearform.cpp:34
Abstract base class LinearFormIntegrator.
Definition: lininteg.hpp:22
Vector & operator=(const double *v)
Definition: vector.cpp:112
Data type sparse matrix.
Definition: sparsemat.hpp:38
void AddBdrFaceIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Face Integrator.
Definition: linearform.cpp:29
const SparseMatrix * GetConformingProlongation()
Definition: fespace.cpp:912
void AddBoundaryIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Integrator.
Definition: linearform.cpp:24
void AddElementVector(const Array< int > &dofs, const Vector &elemvect)
Add (element) subvector to the vector.
Definition: vector.cpp:527
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator.
Definition: linearform.cpp:19
Abstract finite element space.
Definition: fespace.hpp:62
bool Nonconforming() const
Definition: fespace.hpp:146
~LinearForm()
Destroys linear form.
Definition: linearform.cpp:118
void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
Definition: sparsemat.cpp:492
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:1199
Vector data type.
Definition: vector.hpp:33
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i&#39;th boundary element.
Definition: fespace.cpp:1419