https://mooseframework.inl.gov
Loading...
Searching...
No Matches
src
constraints
MortarSegmentInfo.C
Go to the documentation of this file.
1
//* This file is part of the MOOSE framework
2
//* https://mooseframework.inl.gov
3
//*
4
//* All rights reserved, see COPYRIGHT for full restrictions
5
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6
//*
7
//* Licensed under LGPL 2.1, please see LICENSE for details
8
//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10
#include "
MortarSegmentInfo.h
"
11
#include "
MooseError.h
"
12
13
#include "libmesh/elem.h"
14
15
using namespace
libMesh
;
16
17
// Initialize constant static members.
18
const
Real
MortarSegmentInfo::invalid_xi
= 99;
19
20
MortarSegmentInfo::MortarSegmentInfo
()
21
: xi1_a(invalid_xi),
22
xi1_b(invalid_xi),
23
xi2_a(invalid_xi),
24
xi2_b(invalid_xi),
25
secondary_elem(nullptr),
26
primary_elem(nullptr)
27
{
28
}
29
30
MortarSegmentInfo::MortarSegmentInfo
(
Real
x1a,
Real
x1b,
Real
x2a,
Real
x2b)
31
: xi1_a(x1a), xi1_b(x1b), xi2_a(x2a), xi2_b(x2b), secondary_elem(nullptr), primary_elem(nullptr)
32
{
33
}
34
35
void
36
MortarSegmentInfo::print
()
const
37
{
38
Moose::out <<
"xi^(1)_a="
<<
xi1_a
<<
", xi^(1)_b="
<<
xi1_b
<< std::endl;
39
Moose::out <<
"xi^(2)_a="
<<
xi2_a
<<
", xi^(2)_b="
<<
xi2_b
<< std::endl;
40
if
(
secondary_elem
)
41
Moose::out <<
"secondary_elem="
<<
secondary_elem
->
id
() << std::endl;
42
if
(
primary_elem
)
43
Moose::out <<
"primary_elem="
<<
primary_elem
->
id
() << std::endl;
44
}
45
46
bool
47
MortarSegmentInfo::isValid
()
const
48
{
49
bool
b1 = (std::abs(
xi1_a
) < 1. + TOLERANCE) && (std::abs(
xi1_b
) < 1. + TOLERANCE);
50
bool
b2 = (std::abs(
xi2_a
) < 1. + TOLERANCE) && (std::abs(
xi2_b
) < 1. + TOLERANCE);
51
52
bool
xi2a_unset = (std::abs(
xi2_a
-
invalid_xi
) < TOLERANCE);
53
bool
xi2b_unset = (std::abs(
xi2_b
-
invalid_xi
) < TOLERANCE);
54
55
bool
xi2_set = !xi2a_unset && !xi2b_unset;
56
57
// Both xi^(1) values must be set to have a valid segment.
58
if
(!b1)
59
{
60
mooseError
(
"xi1_a = "
,
xi1_a
,
", xi1_b = "
,
xi1_b
,
", one or both xi^(1) values were not set."
);
61
return
false
;
62
}
63
64
// We don't allow really short segments (this probably means
65
// something got screwed up and both xi^(1) values got the same
66
// value).
67
if
(std::abs(
xi1_a
-
xi1_b
) < TOLERANCE)
68
{
69
mooseError
(
"xi^(1) values too close together."
);
70
return
false
;
71
}
72
73
// Must have a valid secondary Elem to have a valid segment.
74
if
(
secondary_elem
==
nullptr
)
75
{
76
mooseError
(
"Secondary Elem was not set."
);
77
return
false
;
78
}
79
80
// Either *both* xi^(2) values should be unset or *neither* should be. Anything else is invalid.
81
if
((xi2a_unset && !xi2b_unset) || (!xi2a_unset && xi2b_unset))
82
{
83
mooseError
(
"One xi^(2) value was set, the other was not set."
);
84
return
false
;
85
}
86
87
// If both xi^(2) values are unset, then primary_elem should be NULL.
88
if
(!xi2_set &&
primary_elem
!=
nullptr
)
89
{
90
mooseError
(
"Both xi^(2) are unset, therefore primary_elem should be NULL."
);
91
return
false
;
92
}
93
94
// On the other hand, if both xi^(2) values are unset, then make sure primary_elem is non-NULL.
95
if
(xi2_set &&
primary_elem
==
nullptr
)
96
{
97
mooseError
(
"Both xi^(2) are set, the primary_elem cannot be NULL."
);
98
return
false
;
99
}
100
101
// If the xi^(2) values are valid, make sure they don't correspond
102
// to a really short segment, which probably means they got
103
// assigned the same value by accident.
104
if
(xi2_set && (std::abs(
xi2_a
-
xi2_b
) < TOLERANCE))
105
{
106
mooseError
(
"xi^(2) are too close together."
);
107
return
false
;
108
}
109
110
// If both xi^(2) values are set, they should be in the range.
111
if
(xi2_set && !b2)
112
{
113
mooseError
(
"xi^(2) are set, but they are not in the range [-1,1]."
);
114
return
false
;
115
}
116
117
// If we made it here, we're valid.
118
return
true
;
119
}
MooseError.h
mooseError
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition
MooseError.h:311
MortarSegmentInfo.h
libMesh::Elem::id
dof_id_type id() const
libMesh
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
MortarSegmentInfo::primary_elem
const Elem * primary_elem
Definition
MortarSegmentInfo.h:77
MortarSegmentInfo::xi2_b
Real xi2_b
Definition
MortarSegmentInfo.h:75
MortarSegmentInfo::xi1_b
Real xi1_b
Definition
MortarSegmentInfo.h:74
MortarSegmentInfo::xi2_a
Real xi2_a
Definition
MortarSegmentInfo.h:75
MortarSegmentInfo::print
void print() const
Prints xi values and secondary/primary Elem ids.
Definition
MortarSegmentInfo.C:36
MortarSegmentInfo::isValid
bool isValid() const
Returns true if the current segment is valid, false otherwise.
Definition
MortarSegmentInfo.C:47
MortarSegmentInfo::xi1_a
Real xi1_a
Definition
MortarSegmentInfo.h:74
MortarSegmentInfo::invalid_xi
static const Real invalid_xi
Definition
MortarSegmentInfo.h:81
MortarSegmentInfo::MortarSegmentInfo
MortarSegmentInfo()
Constructor.
Definition
MortarSegmentInfo.C:20
MortarSegmentInfo::secondary_elem
const Elem * secondary_elem
Definition
MortarSegmentInfo.h:76
Generated on Fri Aug 21 2026 13:33:54 for https://mooseframework.inl.gov by
1.9.8