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 #include <utility>
18 
19 #include "mfem.hpp"
20 
22 
23 namespace smith {
24 
30  public:
32  using FiniteElementVector::operator=;
33  using mfem::Vector::Print;
34 
41  {
42  if (rhs.linear_form_) {
43  linearForm();
44  *linear_form_ = *rhs.linear_form_;
45  }
46  }
47 
54  {
55  this->linear_form_ = std::move(rhs.linear_form_);
56  }
57 
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 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(const FiniteElementDual &rhs)
Copy constructor.
FiniteElementDual & operator=(FiniteElementDual &&rhs)=delete
Move assignment.
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