MFEM  v4.2.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
nonlinearform_ext.cpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2020, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 // Implementations of classes FABilinearFormExtension, EABilinearFormExtension,
13 // PABilinearFormExtension and MFBilinearFormExtension.
14 
15 #include "nonlinearform.hpp"
16 
17 namespace mfem
18 {
19 
21  : Operator(form->FESpace()->GetTrueVSize()), n(form)
22 {
23  // empty
24 }
25 
27  NonlinearFormExtension(form), fes(*form->FESpace())
28 {
32  {
35  localY.UseDevice(true); // ensure 'localY = 0.0' is done on device
36  }
37 }
38 
40 {
41  Array<NonlinearFormIntegrator*> &integrators = *n->GetDNFI();
42  const int Ni = integrators.Size();
43  for (int i = 0; i < Ni; ++i)
44  {
45  integrators[i]->AssemblePA(*n->FESpace());
46  }
47 }
48 
50 {
51  Array<NonlinearFormIntegrator*> &integrators = *n->GetDNFI();
52  const int iSz = integrators.Size();
54  {
56  localY = 0.0;
57  for (int i = 0; i < iSz; ++i)
58  {
59  integrators[i]->AddMultPA(localX, localY);
60  }
62  }
63  else
64  {
65  y.UseDevice(true); // typically this is a large vector, so store on device
66  y = 0.0;
67  for (int i = 0; i < iSz; ++i)
68  {
69  integrators[i]->AddMultPA(x, y);
70  }
71  }
72 }
73 
74 }
int Size() const
Return the logical size of the array.
Definition: array.hpp:124
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:459
void UseDevice(bool use_dev) const
Enable execution of Vector operations using the mfem::Device.
Definition: vector.hpp:89
const FiniteElementSpace & fes
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Definition: operator.hpp:92
const Operator * GetElementRestriction(ElementDofOrdering e_ordering) const
Return an Operator that converts L-vectors to E-vectors.
Definition: fespace.cpp:894
NonlinearFormExtension(NonlinearForm *form)
NonlinearForm * n
Not owned.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Definition: operator.hpp:65
Array< NonlinearFormIntegrator * > * GetDNFI()
Access all integrators added with AddDomainIntegrator().
static MemoryType GetMemoryType()
(DEPRECATED) Equivalent to GetDeviceMemoryType().
Definition: device.hpp:265
FiniteElementSpace * FESpace()
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
ElementDofOrdering
Constants describing the possible orderings of the DOFs in one element.
Definition: fespace.hpp:65
Lexicographic ordering for tensor-product FiniteElements.
Vector data type.
Definition: vector.hpp:51
Abstract operator.
Definition: operator.hpp:24