Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
finite_element_dual.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
14 #pragma once
15 
16 #include <memory>
17 
18 #include "mfem.hpp"
19 
21 
22 namespace serac {
23 
29 public:
31  using FiniteElementVector::operator=;
32  using mfem::Vector::Print;
33 
40  {
41  if (rhs.linear_form_) {
42  linearForm();
43  *linear_form_ = *rhs.linear_form_;
44  }
45  }
46 
53  {
54  this->linear_form_ = std::move(rhs.linear_form_);
55  }
56 
64  {
65  this->linear_form_ = std::move(rhs.linear_form_);
66  return *this;
67  }
68 
76  {
78  if (rhs.linear_form_) {
79  linearForm();
80  *linear_form_ = *rhs.linear_form_;
81  }
82  return *this;
83  }
84 
95  void fillLinearForm(mfem::ParLinearForm& linear_form) const
96  {
97  space_->GetRestrictionMatrix()->MultTranspose(*this, linear_form);
98  }
99 
112  void setFromLinearForm(const mfem::ParLinearForm& linear_form)
113  {
114  const_cast<mfem::ParLinearForm&>(linear_form).ParallelAssemble(*this);
115  }
116 
122  mfem::ParLinearForm& linearForm() const
123  {
124  if (!linear_form_) {
125  linear_form_ = std::make_unique<mfem::ParLinearForm>(space_.get());
126  }
127 
129  return *linear_form_;
130  }
131 
132 protected:
139  mutable std::unique_ptr<mfem::ParLinearForm> linear_form_;
140 };
141 
142 } // namespace serac
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
FiniteElementDual & operator=(FiniteElementDual &&rhs)
Move assignment.
void setFromLinearForm(const mfem::ParLinearForm &linear_form)
Initialize the true vector in the FiniteElementDual based on an input linear form.
FiniteElementDual(FiniteElementDual &&rhs)
Move construct a new Finite Element Dual object.
std::unique_ptr< mfem::ParLinearForm > linear_form_
An optional container for a linear form (L-vector) view of the finite element dual.
FiniteElementDual & operator=(const FiniteElementDual &rhs)
Copy assignment.
void fillLinearForm(mfem::ParLinearForm &linear_form) const
Fill a user-provided linear form based on the underlying true vector.
mfem::ParLinearForm & linearForm() const
Construct a linear form from the finite element dual true vector.
FiniteElementDual(const FiniteElementDual &rhs)
Copy constructor.
Class for encapsulating the data associated with a vector derived from a MFEM finite element space....
FiniteElementVector & operator=(const FiniteElementVector &rhs)
Copy assignment.
std::unique_ptr< mfem::ParFiniteElementSpace > space_
Handle to the mfem::ParFiniteElementSpace, which is owned by MFEMSidreDataCollection.
FiniteElementVector(const mfem::ParFiniteElementSpace &space, const std::string &name="")
Minimal constructor for a FiniteElementVector given a finite element space.
This file contains the declaration of structure that manages vectors derived from an MFEM finite elem...
Accelerator functionality.
Definition: serac.cpp:38