MFEM  v3.2
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 
89 void LinearForm::Update(FiniteElementSpace *f, Vector &v, int v_offset)
90 {
91  fes = f;
92  NewDataAndSize((double *)v + v_offset, fes->GetVSize());
93 }
94 
96 {
97  int k;
98  for (k=0; k < dlfi.Size(); k++) { delete dlfi[k]; }
99  for (k=0; k < blfi.Size(); k++) { delete blfi[k]; }
100  for (k=0; k < flfi.Size(); k++) { delete flfi[k]; }
101 }
102 
103 }
int GetVSize() const
Definition: fespace.hpp:161
void NewDataAndSize(double *d, int s)
Definition: vector.hpp:74
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
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:527
void AddDomainIntegrator(LinearFormIntegrator *lfi)
Adds new Domain Integrator.
Definition: linearform.cpp:19
~LinearForm()
Destroys linear form.
Definition: linearform.cpp:95
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:1113
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:1333