1 // Copyright (c) 2010-2021, 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 #include "../general/forall.hpp"
13 #include "bilininteg.hpp"
14 #include "gridfunc.hpp"
15 #include "ceed/mass.hpp"
16 
17 using namespace std;
18 
19 namespace mfem
20 {
21 
AssembleMF(const FiniteElementSpace & fes)22 void MassIntegrator::AssembleMF(const FiniteElementSpace &fes)
23 {
24    // Assuming the same element type
25    fespace = &fes;
26    Mesh *mesh = fes.GetMesh();
27    if (mesh->GetNE() == 0) { return; }
28    const FiniteElement &el = *fes.GetFE(0);
29    ElementTransformation *T = mesh->GetElementTransformation(0);
30    const IntegrationRule *ir = IntRule ? IntRule : &GetRule(el, el, *T);
31    if (DeviceCanUseCeed())
32    {
33       delete ceedOp;
34       ceedOp = new ceed::MFMassIntegrator(fes, *ir, Q);
35       return;
36    }
37    MFEM_ABORT("Error: MassIntegrator::AssembleMF only implemented with"
38               " libCEED");
39 }
40 
AddMultMF(const Vector & x,Vector & y) const41 void MassIntegrator::AddMultMF(const Vector &x, Vector &y) const
42 {
43    if (DeviceCanUseCeed())
44    {
45       ceedOp->AddMult(x, y);
46    }
47    else
48    {
49       MFEM_ABORT("Error: MassIntegrator::AddMultMF only implemented with"
50                  " libCEED");
51    }
52 }
53 
AssembleDiagonalMF(Vector & diag)54 void MassIntegrator::AssembleDiagonalMF(Vector &diag)
55 {
56    if (DeviceCanUseCeed())
57    {
58       ceedOp->GetDiagonal(diag);
59    }
60    else
61    {
62       MFEM_ABORT("Error: MassIntegrator::AssembleDiagonalMF only implemented"
63                  " with libCEED");
64    }
65 }
66 
67 } // namespace mfem
68