MFEM  v4.6.0
Finite element discretization library
operator.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, 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 #ifndef MFEM_LIBCEED_OPERATOR
13 #define MFEM_LIBCEED_OPERATOR
14 
15 #include "../../../linalg/operator.hpp"
16 #include "ceed.hpp"
17 
18 namespace mfem
19 {
20 
21 namespace ceed
22 {
23 
24 /** A base class to represent a CeedOperator as an MFEM Operator. */
25 class Operator : public mfem::Operator
26 {
27 protected:
28 #ifdef MFEM_USE_CEED
29  CeedOperator oper;
30  CeedVector u, v;
31 
32  Operator() : oper(nullptr), u(nullptr), v(nullptr) { }
33 #endif
34 
35 public:
36 #ifdef MFEM_USE_CEED
37  /// This class takes ownership of op and will delete it
38  Operator(CeedOperator op);
39 #endif
40  void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
41  void AddMult(const mfem::Vector &x, mfem::Vector &y,
42  const double a = 1.0) const override;
43  void GetDiagonal(mfem::Vector &diag) const;
45  virtual ~Operator()
46  {
47 #ifdef MFEM_USE_CEED
48  CeedOperatorDestroy(&oper);
49  CeedVectorDestroy(&u);
50  CeedVectorDestroy(&v);
51 #endif
52  }
53 
54 #ifdef MFEM_USE_CEED
55  CeedOperator& GetCeedOperator() { return oper; }
56 #endif
57 };
58 
59 } // namespace ceed
60 
61 } // namespace mfem
62 
63 #endif // MFEM_LIBCEED_OPERATOR
void AddMult(const mfem::Vector &x, mfem::Vector &y, const double a=1.0) const override
Operator application: y+=A(x) (default) or y+=a*A(x).
Definition: operator.cpp:72
CeedOperator & GetCeedOperator()
Definition: operator.hpp:55
CeedOperator oper
Definition: operator.hpp:29
double a
Definition: lissajous.cpp:41
void GetDiagonal(mfem::Vector &diag) const
Definition: operator.cpp:104
Operator * SetupRAP(const Operator *Pi, const Operator *Po)
Returns RAP Operator of this, using input/output Prolongation matrices Pi corresponds to "P"...
Definition: operator.cpp:168
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Operator application: y=A(x).
Definition: operator.cpp:42
Vector data type.
Definition: vector.hpp:58
virtual ~Operator()
Virtual destructor.
Definition: operator.hpp:45
Abstract operator.
Definition: operator.hpp:24