MFEM  v4.5.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
operator.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2022, 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) const;
42  void GetDiagonal(mfem::Vector &diag) const;
44  virtual ~Operator()
45  {
46 #ifdef MFEM_USE_CEED
47  CeedOperatorDestroy(&oper);
48  CeedVectorDestroy(&u);
49  CeedVectorDestroy(&v);
50 #endif
51  }
52 
53 #ifdef MFEM_USE_CEED
54  CeedOperator& GetCeedOperator() { return oper; }
55 #endif
56 };
57 
58 } // namespace ceed
59 
60 } // namespace mfem
61 
62 #endif // MFEM_LIBCEED_OPERATOR
CeedOperator & GetCeedOperator()
Definition: operator.hpp:54
CeedOperator oper
Definition: operator.hpp:29
void AddMult(const mfem::Vector &x, mfem::Vector &y) const
Definition: operator.cpp:72
void GetDiagonal(mfem::Vector &diag) const
Definition: operator.cpp:102
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:105
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:60
virtual ~Operator()
Virtual destructor.
Definition: operator.hpp:44
Abstract operator.
Definition: operator.hpp:24