Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
contact_data.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 
13 #pragma once
14 
15 #include <memory>
16 #include <set>
17 #include <vector>
18 
19 #include "mfem.hpp"
20 
21 #include "smith/smith_config.hpp"
24 #ifdef SMITH_USE_TRIBOL
26 #endif
27 
28 namespace smith {
29 
30 namespace contact {
31 
37  .enforcement = ContactEnforcement::Penalty,
39  .penalty = 1.0e3};
40 
41 } // namespace contact
42 
47 class ContactData {
48  public:
54  ContactData(const mfem::ParMesh& mesh);
55 
59  ~ContactData();
60 
69  void addContactInteraction(int interaction_id, const std::set<int>& bdry_attr_surf1,
70  const std::set<int>& bdry_attr_surf2, ContactOptions contact_opts);
71 
79  void update(int cycle, double time, double& dt);
80 
85  void reset();
86 
94  FiniteElementDual forces() const;
95 
105  mfem::HypreParVector mergedPressures() const;
106 
119  mfem::HypreParVector mergedGaps(bool zero_inactive = false) const;
120 
133  std::unique_ptr<mfem::BlockOperator> mergedJacobian() const;
134 
147  void residualFunction(const mfem::Vector& u_shape, const mfem::Vector& u, mfem::Vector& r);
148 
157  std::unique_ptr<mfem::BlockOperator> jacobianFunction(mfem::HypreParMatrix* orig_J) const;
158 
170  void setPressures(const mfem::Vector& merged_pressures) const;
171 
178  void setDisplacements(const mfem::Vector& u_shape, const mfem::Vector& u);
179 
187  {
188 #ifdef SMITH_USE_TRIBOL
189  return !interactions_.empty();
190 #else
191  return false;
192 #endif
193  }
194 
195 #ifdef SMITH_USE_TRIBOL
201  const std::vector<ContactInteraction>& getContactInteractions() const { return interactions_; }
202 #endif
203 
210  bool haveLagrangeMultipliers() const { return have_lagrange_multipliers_; }
211 
217  int numPressureDofs() const { return num_pressure_dofs_; };
218 
219  private:
220 #ifdef SMITH_USE_TRIBOL
226  void updateDofOffsets() const;
227 
231  const mfem::ParMesh& mesh_;
232 #endif
233 
237  const mfem::ParGridFunction* reference_nodes_;
238 
239 #ifdef SMITH_USE_TRIBOL
243  mfem::ParGridFunction current_coords_;
244 
248  std::vector<ContactInteraction> interactions_;
249 #endif
250 
255  bool have_lagrange_multipliers_;
256 
260  int num_pressure_dofs_;
261 
268  mutable bool offsets_up_to_date_;
269 
277  mutable mfem::Array<int> jacobian_offsets_;
278 
287  mutable mfem::Array<int> pressure_dof_offsets_;
288 
297  mutable mfem::Array<HYPRE_BigInt> global_pressure_dof_offsets_;
298 
299  int cycle_{0};
300  double time_{0.0};
301  double dt_{1.0};
302 };
303 
304 } // namespace smith
This class stores all ContactInteractions for a problem, calls Tribol functions that act on all conta...
void residualFunction(const mfem::Vector &u_shape, const mfem::Vector &u, mfem::Vector &r)
Computes the residual including contact terms.
mfem::HypreParVector mergedGaps(bool zero_inactive=false) const
Returns nodal gaps from all contact interactions on the contact surface true degrees of freedom.
bool haveContactInteractions() const
Have there been contact interactions added?
void update(int cycle, double time, double &dt)
Updates the positions, forces, and Jacobian contributions associated with contact.
ContactData(const mfem::ParMesh &mesh)
The constructor.
int numPressureDofs() const
Get the number of Lagrange multiplier true degrees of freedom.
void setPressures(const mfem::Vector &merged_pressures) const
Set the pressure field.
~ContactData()
Destructor to finalize Tribol.
bool haveLagrangeMultipliers() const
Are any contact interactions enforced using Lagrange multipliers?
mfem::HypreParVector mergedPressures() const
Returns pressures from all contact interactions on the contact surface true degrees of freedom.
std::unique_ptr< mfem::BlockOperator > jacobianFunction(mfem::HypreParMatrix *orig_J) const
Computes the Jacobian including contact terms, given the non-contact Jacobian terms.
FiniteElementDual forces() const
Get the contact constraint residual (i.e. nodal forces) from all contact interactions.
std::unique_ptr< mfem::BlockOperator > mergedJacobian() const
Returns a 2x2 block Jacobian on displacement/pressure true degrees of freedom from contact constraint...
void addContactInteraction(int interaction_id, const std::set< int > &bdry_attr_surf1, const std::set< int > &bdry_attr_surf2, ContactOptions contact_opts)
Add another contact interaction.
void setDisplacements(const mfem::Vector &u_shape, const mfem::Vector &u)
Update the current coordinates based on the new displacement field.
void reset()
Resets the contact pressures to zero.
Class for encapsulating the dual vector space of a finite element space (i.e. the space of linear for...
This file contains enumerations and record types for contact configuration.
const ContactOptions default_contact_options
Default contact options: frictionless mortar with penalty = 1000 enforcement.
Class for storing a contact interaction and interfacing with Tribol.
This contains a class that represents the dual of a finite element vector space, i....
Accelerator functionality.
Definition: smith.cpp:36
Stores the options for a contact pair.
ContactMethod method
The contact methodology to be applied.