https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Moose::Mortar::ADNodalFrames Class Reference

Cache of the secondary nodal normals and tangents of one mortar interface, carrying their displacement derivatives while a Jacobian is assembled. More...

#include <MortarNodalFrames.h>

Public Member Functions

 ADNodalFrames (const std::array< const MooseVariable *, 3 > &disp_vars)
 
const ADRealVectorValue & normal (const AutomaticMortarGeneration &amg, const Node &node, const Point &stored_normal, bool do_derivatives)
 
const std::array< ADRealVectorValue, 2 > & tangents (const AutomaticMortarGeneration &amg, const Node &node, const Point &stored_normal, bool do_derivatives)
 
std::vector< ADRealVectorValue > interpolatedNormals (const AutomaticMortarGeneration &amg, const Elem &secondary_elem, const std::vector< Point > &xi_pts, const std::vector< Point > &stored_normals, bool do_derivatives)
 Interpolate the nodal normals of secondary_elem to reference points in the same way as AutomaticMortarGeneration::getNormals()
 
void clear ()
 

Private Attributes

const std::array< const MooseVariable *, 3 > _disp_vars
 
std::unordered_map< const Node *, ADRealVectorValue > _normals
 
std::unordered_map< const Node *, std::array< ADRealVectorValue, 2 > > _tangents
 

Detailed Description

Cache of the secondary nodal normals and tangents of one mortar interface, carrying their displacement derivatives while a Jacobian is assembled.

Residual-only evaluations hold the stored nodal geometry values. Call clear() whenever the displaced geometry changes.

Definition at line 73 of file MortarNodalFrames.h.

Constructor & Destructor Documentation

◆ ADNodalFrames()

Moose::Mortar::ADNodalFrames::ADNodalFrames ( const std::array< const MooseVariable *, 3 > &  disp_vars)
inlineexplicit
Parameters
disp_varsThe x, y, and z displacement variables; the z entry is null in 2D

Definition at line 79 of file MortarNodalFrames.h.

80 : _disp_vars(disp_vars)
81 {
82 }
const std::array< const MooseVariable *, 3 > _disp_vars

Member Function Documentation

◆ clear()

void Moose::Mortar::ADNodalFrames::clear ( )

Definition at line 146 of file MortarNodalFrames.C.

147{
148 _normals.clear();
149 _tangents.clear();
150}
std::unordered_map< const Node *, ADRealVectorValue > _normals
std::unordered_map< const Node *, std::array< ADRealVectorValue, 2 > > _tangents

◆ interpolatedNormals()

std::vector< ADRealVectorValue > Moose::Mortar::ADNodalFrames::interpolatedNormals ( const AutomaticMortarGeneration &  amg,
const Elem &  secondary_elem,
const std::vector< Point > &  xi_pts,
const std::vector< Point > &  stored_normals,
bool  do_derivatives 
)

Interpolate the nodal normals of secondary_elem to reference points in the same way as AutomaticMortarGeneration::getNormals()

Parameters
amgThe mortar generation object of the interface
secondary_elemThe lower-dimensional secondary element
xi_ptsThe reference points on secondary_elem
stored_normalsThe stored interpolated normals at xi_pts, which also fix the sign convention of a periodic interface
do_derivativesWhether to include displacement derivatives
Returns
The interpolated normals, one per point

Definition at line 105 of file MortarNodalFrames.C.

110{
111 mooseAssert(xi_pts.size() == stored_normals.size(),
112 "There must be one stored normal per reference point.");
113 if (!do_derivatives)
114 return {stored_normals.begin(), stored_normals.end()};
115
116 const auto stored_nodal_normals = amg.getNodalNormals(secondary_elem);
117 const auto mortar_dim = secondary_elem.dim();
118 std::vector<ADRealVectorValue> normals(xi_pts.size());
119 for (const auto n : make_range(secondary_elem.n_nodes()))
120 {
121 const auto & nodal_normal =
122 normal(amg, secondary_elem.node_ref(n), stored_nodal_normals[n], do_derivatives);
123 for (const auto qp : index_range(xi_pts))
124 {
125 const auto phi =
126 (mortar_dim == 1)
127 ? Moose::fe_lagrange_1D_shape(secondary_elem.default_order(), n, xi_pts[qp](0))
128 : Moose::fe_lagrange_2D_shape(secondary_elem.type(),
129 secondary_elem.default_order(),
130 n,
131 cast_ref<const TypeVector<Real> &>(xi_pts[qp]));
132 normals[qp] += phi * nodal_normal;
133 }
134 }
135
136 // getNormals() flips the interpolated normals of a periodic interface. Matching the stored
137 // values keeps the residual unchanged whichever convention the interface uses.
138 for (const auto qp : index_range(normals))
139 if (MetaPhysicL::raw_value(normals[qp]) * stored_normals[qp] < 0)
140 normals[qp] *= -1;
141
142 return normals;
143}
if(!dmm->_nl) SETERRQ(PETSC_COMM_WORLD
std::vector< Point > getNodalNormals(const Elem &secondary_elem) const
const ADRealVectorValue & normal(const AutomaticMortarGeneration &amg, const Node &node, const Point &stored_normal, bool do_derivatives)
We need to instantiate the following CompareTypes to tell the compiler that ADReal is a subtype of Ch...
auto raw_value(const Eigen::Map< T > &in)
T fe_lagrange_2D_shape(const libMesh::ElemType type, const Order order, const unsigned int i, const VectorType< T > &p)
T fe_lagrange_1D_shape(const Order order, const unsigned int i, const T &xi)
auto index_range(const T &sizable)
IntRange< T > make_range(T beg, T end)
const dof_id_type n_nodes

◆ normal()

const ADRealVectorValue & Moose::Mortar::ADNodalFrames::normal ( const AutomaticMortarGeneration &  amg,
const Node &  node,
const Point &  stored_normal,
bool  do_derivatives 
)
Parameters
amgThe mortar generation object of the interface
nodeA secondary node
stored_normalThe stored normal at node, used when do_derivatives is false
do_derivativesWhether to include displacement derivatives
Returns
The unit normal at node

Definition at line 71 of file MortarNodalFrames.C.

75{
76 if (const auto it = _normals.find(&node); it != _normals.end())
77 return it->second;
78
79 if (!do_derivatives)
80 return _normals.emplace(&node, stored_normal).first->second;
81
82 amg.computeADNodalNormals([this](const Node & coordinate_node)
83 { return nodalCoordinate(coordinate_node, _disp_vars); },
84 _normals);
85 return libmesh_map_find(_normals, &node);
86}
void computeADNodalNormals(const std::function< ADPoint(const Node &)> &coordinate, std::unordered_map< const Node *, ADRealVectorValue > &nodal_normals) const
Build the normalized JxW-weighted secondary nodal normals from AD nodal coordinates.
ADPoint nodalCoordinate(const Node &node, const std::array< const MooseVariable *, 3 > &disp_vars)

Referenced by interpolatedNormals(), and tangents().

◆ tangents()

const std::array< ADRealVectorValue, 2 > & Moose::Mortar::ADNodalFrames::tangents ( const AutomaticMortarGeneration &  amg,
const Node &  node,
const Point &  stored_normal,
bool  do_derivatives 
)
Returns
The nodal tangents (nodalTangents()) at node, built from normal() with the same arguments. They carry displacement derivatives exactly when that normal does.

Definition at line 89 of file MortarNodalFrames.C.

93{
94 auto it = _tangents.find(&node);
95 if (it == _tangents.end())
96 it = _tangents
97 .emplace(&node,
98 Moose::Mortar::nodalTangents(normal(amg, node, stored_normal, do_derivatives),
99 amg.dim()))
100 .first;
101 return it->second;
102}
std::array< Vector, 2 > nodalTangents(const Vector &normal, const unsigned int dim)
Construct the two tangent vectors used by mortar from a unit normal on a dim dimensional mesh.

Member Data Documentation

◆ _disp_vars

const std::array<const MooseVariable *, 3> Moose::Mortar::ADNodalFrames::_disp_vars
private

Definition at line 125 of file MortarNodalFrames.h.

Referenced by normal().

◆ _normals

std::unordered_map<const Node *, ADRealVectorValue> Moose::Mortar::ADNodalFrames::_normals
private

Definition at line 126 of file MortarNodalFrames.h.

Referenced by clear(), and normal().

◆ _tangents

std::unordered_map<const Node *, std::array<ADRealVectorValue, 2> > Moose::Mortar::ADNodalFrames::_tangents
private

Definition at line 127 of file MortarNodalFrames.h.

Referenced by clear(), and tangents().


The documentation for this class was generated from the following files: