MFEM v2.0
|
00001 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at 00002 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights 00003 // reserved. See file COPYRIGHT for details. 00004 // 00005 // This file is part of the MFEM library. For more information and source code 00006 // availability see http://mfem.googlecode.com. 00007 // 00008 // MFEM is free software; you can redistribute it and/or modify it under the 00009 // terms of the GNU Lesser General Public License (as published by the Free 00010 // Software Foundation) version 2.1 dated February 1999. 00011 00012 // Implementation of class LinearForm 00013 00014 #include "fem.hpp" 00015 00016 00017 void LinearForm::AddDomainIntegrator (LinearFormIntegrator * lfi) 00018 { 00019 dlfi.Append (lfi); 00020 } 00021 00022 void LinearForm::AddBoundaryIntegrator (LinearFormIntegrator * lfi) 00023 { 00024 blfi.Append (lfi); 00025 } 00026 00027 void LinearForm::AddBdrFaceIntegrator (LinearFormIntegrator * lfi) 00028 { 00029 flfi.Append (lfi); 00030 } 00031 00032 void LinearForm::Assemble() 00033 { 00034 Array<int> vdofs; 00035 ElementTransformation *eltrans; 00036 Vector elemvect; 00037 00038 int i; 00039 00040 Vector::operator=(0.0); 00041 00042 if (dlfi.Size()) 00043 for (i = 0; i < fes -> GetNE(); i++) 00044 { 00045 fes -> GetElementVDofs (i, vdofs); 00046 eltrans = fes -> GetElementTransformation (i); 00047 for (int k=0; k < dlfi.Size(); k++) 00048 { 00049 dlfi[k]->AssembleRHSElementVect(*fes->GetFE(i), *eltrans, elemvect); 00050 AddElementVector (vdofs, elemvect); 00051 } 00052 } 00053 00054 if (blfi.Size()) 00055 for (i = 0; i < fes -> GetNBE(); i++) 00056 { 00057 fes -> GetBdrElementVDofs (i, vdofs); 00058 eltrans = fes -> GetBdrElementTransformation (i); 00059 for (int k=0; k < blfi.Size(); k++) 00060 { 00061 blfi[k]->AssembleRHSElementVect(*fes->GetBE(i), *eltrans, elemvect); 00062 AddElementVector (vdofs, elemvect); 00063 } 00064 } 00065 00066 if (flfi.Size()) 00067 { 00068 FaceElementTransformations *tr; 00069 Mesh *mesh = fes -> GetMesh(); 00070 for (i = 0; i < mesh -> GetNBE(); i++) 00071 { 00072 tr = mesh -> GetBdrFaceTransformations (i); 00073 if (tr != NULL) 00074 { 00075 fes -> GetElementVDofs (tr -> Elem1No, vdofs); 00076 for (int k = 0; k < flfi.Size(); k++) 00077 { 00078 flfi[k] -> AssembleRHSElementVect (*fes->GetFE(tr -> Elem1No), 00079 *tr, elemvect); 00080 AddElementVector (vdofs, elemvect); 00081 } 00082 } 00083 } 00084 } 00085 } 00086 00087 LinearForm::~LinearForm() 00088 { 00089 int k; 00090 for (k=0; k < dlfi.Size(); k++) delete dlfi[k]; 00091 for (k=0; k < blfi.Size(); k++) delete blfi[k]; 00092 for (k=0; k < flfi.Size(); k++) delete flfi[k]; 00093 }