MFEM  v3.0
 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.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 // 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 {
92  if (P)
93  {
94  b.SetSize(P->Width());
95  P->MultTranspose(*this, b);
96  }
97  else
98  {
99  b = *this;
100  }
101 }
102 
104 {
105  if (fes->GetConformingProlongation())
106  {
107  Vector b;
109  static_cast<Vector&>(*this) = b;
110  }
111 }
112 
113 void LinearForm::Update(FiniteElementSpace *f, Vector &v, int v_offset)
114 {
115  fes = f;
116  NewDataAndSize((double *)v + v_offset, fes->GetVSize());
117 }
118 
120 {
121  int k;
122  for (k=0; k < dlfi.Size(); k++) delete dlfi[k];
123  for (k=0; k < blfi.Size(); k++) delete blfi[k];
124  for (k=0; k < flfi.Size(); k++) delete flfi[k];
125 }
126 
127 }
int GetVSize() const
Definition: fespace.hpp:151
void NewDataAndSize(double *d, int s)
Definition: vector.hpp:67
void ConformingAssemble()
Apply the conforming interpolation matrix to &#39;this&#39;: this = P&#39;*this.
Definition: linearform.cpp:103
void SetSize(int s)
Resizes the vector if the new size is different.
Definition: vector.hpp:248
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:100
SparseMatrix * GetConformingProlongation()
Definition: fespace.hpp:137
Data type sparse matrix.
Definition: sparsemat.hpp:38
void AddBdrFaceIntegrator(LinearFormIntegrator *lfi)
Adds new Boundary Face Integrator.
Definition: linearform.cpp:29
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:449
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator.
Definition: linearform.cpp:19
Abstract finite element space.
Definition: fespace.hpp:61
~LinearForm()
Destroys linear form.
Definition: linearform.cpp:119
void MultTranspose(const Vector &x, Vector &y) const
Multiply a vector with the transposed matrix. y = At * x.
Definition: sparsemat.cpp:387
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:814
Vector data type.
Definition: vector.hpp:29
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i&#39;th boundary element.
Definition: fespace.cpp:976