Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
finite_element_dual.hpp
Go to the documentation of this file.
1 // Copyright (c) Lawrence Livermore National Security, LLC and
2 // other Smith 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 smith {
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  {
66  this->linear_form_ = std::move(rhs.linear_form_);
67  return *this;
68  }
69 
77  {
79  if (rhs.linear_form_) {
80  linearForm();
81  *linear_form_ = *rhs.linear_form_;
82  }
83  return *this;
84  }
85 
96  void fillLinearForm(mfem::ParLinearForm& linear_form) const
97  {
98  space_->GetRestrictionMatrix()->MultTranspose(*this, linear_form);
99  }
100 
113  void setFromLinearForm(const mfem::ParLinearForm& linear_form)
114  {
115  const_cast<mfem::ParLinearForm&>(linear_form).ParallelAssemble(*this);
116  }
117 
123  mfem::ParLinearForm& linearForm() const
124  {
125  if (!linear_form_) {
126  linear_form_ = std::make_unique<mfem::ParLinearForm>(space_.get());
127  }
128 
130  return *linear_form_;
131  }
132 
133  protected:
140  mutable std::unique_ptr<mfem::ParLinearForm> linear_form_;
141 };
142 
143 } // namespace smith
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
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 & operator=(FiniteElementDual &&rhs)
Move assignment.
FiniteElementDual(const FiniteElementDual &rhs)
Copy constructor.
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 setFromLinearForm(const mfem::ParLinearForm &linear_form)
Initialize the true vector in the FiniteElementDual based on an input linear form.
Class for encapsulating the data associated with a vector derived from a MFEM finite element space....
std::unique_ptr< mfem::ParFiniteElementSpace > space_
Handle to the mfem::ParFiniteElementSpace, which is owned by MFEMSidreDataCollection.
FiniteElementVector & operator=(const FiniteElementVector &rhs)
Copy assignment.
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: smith.cpp:36